You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When using the transferFromEth function to transfer an NFT from Ethereum mainnet, the Wormhole SDK script always has the user send an approve() call, even if the Wormhole bridge contract already has access to that token.
This is a wasteful behavior, since if the bridge contract already has access (through some other approval process, or the user started a bridge process and got interrupted partway through), triggering another on-chain approve() call is just wasted gas.
Steps to reproduce
Trigger a transferFromEth call for a specific token
In the wallet, submit the initial approve() action.
While the approve action is pending, close the Dapp tab, or navigate away from the app.
After the approve action succeeds, come back to the Dapp and attempt to continue the transfer.
Experienced behavior
There's no way to "continue" the transfer. If transferFromEth is called again, the user is requested to submit an additional (useless) approve() action.
Expected behavior
The transferFromEth call skips the approve() call and goes on to the bridge.transferNFT call.
Solution recommendation
Knowing that the token is an ERC721-compliant token, the transferFromEth function should check token.getApproved(tokenID) and see if it's equal to nftBridgeAddress, and token.isApprovedForAll(signer.address, nftBridgeAddress) and see if that's true. If either of those checks pass, skip the step of the user needing to call token.approve again.
The text was updated successfully, but these errors were encountered:
Description and context
When using the
transferFromEth
function to transfer an NFT from Ethereum mainnet, the Wormhole SDK script always has the user send anapprove()
call, even if the Wormhole bridge contract already has access to that token.https://github.com/wormhole-foundation/wormhole/blob/main/sdk/js/src/nft_bridge/transfer.ts#L44-L46
This is a wasteful behavior, since if the bridge contract already has access (through some other approval process, or the user started a bridge process and got interrupted partway through), triggering another on-chain
approve()
call is just wasted gas.Steps to reproduce
transferFromEth
call for a specific tokenapprove()
action.approve
action is pending, close the Dapp tab, or navigate away from the app.approve
action succeeds, come back to the Dapp and attempt to continue the transfer.Experienced behavior
There's no way to "continue" the transfer. If
transferFromEth
is called again, the user is requested to submit an additional (useless)approve()
action.Expected behavior
The
transferFromEth
call skips theapprove()
call and goes on to thebridge.transferNFT
call.Solution recommendation
Knowing that the token is an ERC721-compliant token, the
transferFromEth
function should checktoken.getApproved(tokenID)
and see if it's equal tonftBridgeAddress
, andtoken.isApprovedForAll(signer.address, nftBridgeAddress)
and see if that'strue
. If either of those checks pass, skip the step of the user needing to calltoken.approve
again.The text was updated successfully, but these errors were encountered: