fix_: eth and erc20 fixes

This commit is contained in:
Sale Djenic 2024-05-31 19:21:35 +02:00 committed by saledjenic
parent 2053bd323b
commit aec567fd9f
2 changed files with 3 additions and 11 deletions

View File

@ -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),

View File

@ -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)