fix(wallet) fix erc721 transfer router

Changes

- Use token's contract address for `ERC1155TransferTxArgs.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 `ERC1155TransferTxArgs`.
- Set ChainID in `ERC1155TransferTxArgs`

Updates status-desktop #14212
This commit is contained in:
Stefan 2024-04-01 15:33:35 +03:00 committed by Stefan Dunca
parent ff6fb81beb
commit ef0e17e0f5
1 changed files with 11 additions and 3 deletions

View File

@ -102,19 +102,27 @@ func (s *ERC1155TransferBridge) EstimateGas(fromNetwork *params.Network, toNetwo
} }
func (s *ERC1155TransferBridge) BuildTx(network *params.Network, fromAddress common.Address, toAddress common.Address, token *token.Token, amountIn *big.Int) (*ethTypes.Transaction, error) { func (s *ERC1155TransferBridge) 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 ERC1155 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 ERC1155's Symbol %s to big.Int", token.Symbol)
}
sendArgs := &TransactionBridge{ sendArgs := &TransactionBridge{
ERC1155TransferTx: &ERC1155TransferTxArgs{ ERC1155TransferTx: &ERC1155TransferTxArgs{
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,
Amount: (*hexutil.Big)(amountIn), Amount: (*hexutil.Big)(amountIn),
}, },
ChainID: network.ChainID,
} }
return s.BuildTransaction(sendArgs) return s.BuildTransaction(sendArgs)