fix(wallet) fix erc721 transfer router

Changes

Use token's contract address for `ERC721TransferTxArgs.to` because it
is used as such later on.
Extract Token ID from the symbol as we encoded and set the corresponding
value in the `ERC721TransferTxArgs`.
Set ChainID in `ERC721TransferTxArgs`
Fix wrong order of arguments in `BuildTx`.

Updates status-desktop #14212
This commit is contained in:
Stefan 2024-03-30 13:41:02 +02:00 committed by Stefan Dunca
parent 30e143ca40
commit ff6fb81beb
2 changed files with 12 additions and 4 deletions

View File

@ -99,18 +99,26 @@ func (s *ERC721TransferBridge) EstimateGas(fromNetwork *params.Network, toNetwor
} }
func (s *ERC721TransferBridge) BuildTx(network *params.Network, fromAddress common.Address, toAddress common.Address, token *token.Token, amountIn *big.Int) (*ethTypes.Transaction, error) { func (s *ERC721TransferBridge) BuildTx(network *params.Network, fromAddress common.Address, toAddress common.Address, token *token.Token, amountIn *big.Int) (*ethTypes.Transaction, error) {
toAddr := types.Address(toAddress) contractAddress := types.Address(token.Address)
// We store ERC721 Token ID using big.Int.String() in token.Symbol
tokenID, success := new(big.Int).SetString(token.Symbol, 10)
if !success {
return nil, fmt.Errorf("failed to convert ERC721's Symbol %s to big.Int", token.Symbol)
}
sendArgs := &TransactionBridge{ sendArgs := &TransactionBridge{
ERC721TransferTx: &ERC721TransferTxArgs{ ERC721TransferTx: &ERC721TransferTxArgs{
SendTxArgs: transactions.SendTxArgs{ SendTxArgs: transactions.SendTxArgs{
From: types.Address(fromAddress), From: types.Address(fromAddress),
To: &toAddr, To: &contractAddress,
Value: (*hexutil.Big)(amountIn), Value: (*hexutil.Big)(amountIn),
Data: types.HexBytes("0x0"), Data: types.HexBytes("0x0"),
}, },
TokenID: (*hexutil.Big)(big.NewInt(0)), TokenID: (*hexutil.Big)(tokenID),
Recipient: toAddress, Recipient: toAddress,
}, },
ChainID: network.ChainID,
} }
return s.BuildTransaction(sendArgs) return s.BuildTransaction(sendArgs)

View File

@ -713,7 +713,7 @@ func (r *Router) suggestedRoutes(
continue continue
} }
tx, err := bridge.BuildTx(network, addrTo, addrFrom, token, amountIn) tx, err := bridge.BuildTx(network, addrFrom, addrTo, token, amountIn)
if err != nil { if err != nil {
continue continue
} }