fix: estimate gas for erc721

This commit is contained in:
Anthony Laibe 2023-11-10 14:17:39 +01:00
parent b36d95d84d
commit dc2d179692
2 changed files with 3 additions and 4 deletions

View File

@ -56,8 +56,6 @@ func (s *ERC721TransferBridge) EstimateGas(fromNetwork *params.Network, toNetwor
var input []byte
value := new(big.Int)
contractAddress := to
abi, err := abi.JSON(strings.NewReader(collectibles.CollectiblesMetaData.ABI))
if err != nil {
return 0, err
@ -74,7 +72,7 @@ func (s *ERC721TransferBridge) EstimateGas(fromNetwork *params.Network, toNetwor
ctx := context.Background()
if code, err := ethClient.PendingCodeAt(ctx, contractAddress); err != nil {
if code, err := ethClient.PendingCodeAt(ctx, token.Address); err != nil {
return 0, err
} else if len(code) == 0 {
return 0, bind.ErrNoCode
@ -82,7 +80,7 @@ func (s *ERC721TransferBridge) EstimateGas(fromNetwork *params.Network, toNetwor
msg := ethereum.CallMsg{
From: from,
To: &contractAddress,
To: &token.Address,
Value: value,
Data: input,
}

View File

@ -33,6 +33,7 @@ func (s *TransferBridge) CalculateFees(from, to *params.Network, token *token.To
}
func (s *TransferBridge) EstimateGas(fromNetwork *params.Network, toNetwork *params.Network, from common.Address, to common.Address, token *token.Token, amountIn *big.Int) (uint64, error) {
// TODO fix for ERC20
estimation, err := s.transactor.EstimateGas(fromNetwork, from, to, amountIn, []byte("eth_sendRawTransaction"))
if err != nil {
return 0, err