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:
parent
ff6fb81beb
commit
ef0e17e0f5
|
@ -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)
|
||||||
|
|
Loading…
Reference in New Issue