From aec567fd9f3052bd3c6d30f6dda949b09177abf5 Mon Sep 17 00:00:00 2001 From: Sale Djenic Date: Fri, 31 May 2024 19:21:35 +0200 Subject: [PATCH] fix_: eth and erc20 fixes --- services/wallet/bridge/transfer.go | 6 +++--- transactions/transactor.go | 8 -------- 2 files changed, 3 insertions(+), 11 deletions(-) diff --git a/services/wallet/bridge/transfer.go b/services/wallet/bridge/transfer.go index 6b329aada..a29a5da4d 100644 --- a/services/wallet/bridge/transfer.go +++ b/services/wallet/bridge/transfer.go @@ -41,7 +41,7 @@ func (s *TransferBridge) CalculateFees(from, to *params.Network, token *token.To } func (s *TransferBridge) PackTxInputData(contractType string, fromNetwork *params.Network, toNetwork *params.Network, from common.Address, to common.Address, token *token.Token, amountIn *big.Int) ([]byte, error) { - if token.Symbol == "ETH" { + if token.IsNative() { return []byte("eth_sendRawTransaction"), nil } else { abi, err := abi.JSON(strings.NewReader(ierc20.IERC20ABI)) @@ -64,7 +64,7 @@ func (s *TransferBridge) EstimateGas(fromNetwork *params.Network, toNetwork *par return 0, err } - if token.Symbol == "ETH" { + if token.IsNative() { estimation, err = s.transactor.EstimateGas(fromNetwork, from, to, amountIn, input) if err != nil { return 0, err @@ -96,7 +96,7 @@ func (s *TransferBridge) EstimateGas(fromNetwork *params.Network, toNetwork *par func (s *TransferBridge) BuildTx(network, _ *params.Network, fromAddress common.Address, toAddress common.Address, token *token.Token, amountIn *big.Int, bonderFee *big.Int) (*ethTypes.Transaction, error) { toAddr := types.Address(toAddress) - if strings.EqualFold(token.Symbol, "ETH") { + if token.IsNative() { sendArgs := &TransactionBridge{ TransferTx: &transactions.SendTxArgs{ From: types.Address(fromAddress), diff --git a/transactions/transactor.go b/transactions/transactor.go index 1d6770c17..032831064 100644 --- a/transactions/transactor.go +++ b/transactions/transactor.go @@ -322,10 +322,6 @@ func (t *Transactor) HashTransaction(args SendTxArgs) (validatedArgs SendTxArgs, if err != nil { return validatedArgs, hash, err } - if gas < defaultGas { - t.log.Info("default gas will be used because estimated is lower", "estimated", gas, "default", defaultGas) - gas = defaultGas - } } else { gas = uint64(*args.Gas) } @@ -412,10 +408,6 @@ func (t *Transactor) validateAndBuildTransaction(rpcWrapper *rpcWrapper, args Se if err != nil { return tx, err } - if gas < defaultGas { - t.log.Info("default gas will be used because estimated is lower", "estimated", gas, "default", defaultGas) - gas = defaultGas - } } tx = t.buildTransactionWithOverrides(nonce, value, gas, gasPrice, args)