Skip to content

Commit

Permalink
fix_: Send transaction failures
Browse files Browse the repository at this point in the history
1. Fixing a crash on `ValidateAndBuildTransaction`: tx.Nonce() is called on a null tx whenever it fails to build the transaction
2. Fixing gas extimations. The estimations are always done on mainnet and the requested chainId is ignored in the estimation
  • Loading branch information
alexjba committed Sep 19, 2024
1 parent f04a9a8 commit d20c91c
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions transactions/transactor.go
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,10 @@ func (t *Transactor) SendTransactionWithChainID(chainID uint64, sendArgs SendTxA
func (t *Transactor) ValidateAndBuildTransaction(chainID uint64, sendArgs SendTxArgs, lastUsedNonce int64) (tx *gethtypes.Transaction, nonce uint64, err error) {
wrapper := newRPCWrapper(t.rpcWrapper.RPCClient, chainID)
tx, err = t.validateAndBuildTransaction(wrapper, sendArgs, lastUsedNonce)
if err != nil {
return nil, 0, err
}

return tx, tx.Nonce(), err
}

Expand Down Expand Up @@ -412,7 +416,7 @@ func (t *Transactor) validateAndBuildTransaction(rpcWrapper *rpcWrapper, args Se
if args.IsDynamicFeeTx() {
gasFeeCap := (*big.Int)(args.MaxFeePerGas)
gasTipCap := (*big.Int)(args.MaxPriorityFeePerGas)
gas, err = t.rpcWrapper.EstimateGas(ctx, ethereum.CallMsg{
gas, err = rpcWrapper.EstimateGas(ctx, ethereum.CallMsg{
From: common.Address(args.From),
To: gethToPtr,
GasFeeCap: gasFeeCap,
Expand All @@ -421,7 +425,7 @@ func (t *Transactor) validateAndBuildTransaction(rpcWrapper *rpcWrapper, args Se
Data: args.GetInput(),
})
} else {
gas, err = t.rpcWrapper.EstimateGas(ctx, ethereum.CallMsg{
gas, err = rpcWrapper.EstimateGas(ctx, ethereum.CallMsg{
From: common.Address(args.From),
To: gethToPtr,
GasPrice: gasPrice,
Expand Down

0 comments on commit d20c91c

Please sign in to comment.