diff --git a/pkg/client/client.go b/pkg/client/client.go index 8b44a98..7491be4 100644 --- a/pkg/client/client.go +++ b/pkg/client/client.go @@ -195,26 +195,33 @@ func (cl *ETHClient) EstimateGasFromTx(ctx context.Context, tx *gethtypes.Transa if err != nil { return 0, err } - to := tx.To() - value := tx.Value() - gasTipCap := tx.GasTipCap() - gasFeeCap := tx.GasFeeCap() - gasPrice := tx.GasPrice() - data := tx.Data() - accessList := tx.AccessList() + callMsg := ethereum.CallMsg{ - From: from, - To: to, - GasPrice: gasPrice, - GasTipCap: gasTipCap, - GasFeeCap: gasFeeCap, - Value: value, - Data: data, - AccessList: accessList, - } - estimatedGas, err := cl.EstimateGas(ctx, callMsg) - if err != nil { - return 0, err - } - return estimatedGas, nil + From: from, + To: tx.To(), + Value: tx.Value(), + Data: tx.Data(), + } + + switch tx.Type() { + case gethtypes.BlobTxType: + callMsg.GasTipCap = tx.GasTipCap() + callMsg.GasFeeCap = tx.GasFeeCap() + callMsg.AccessList = tx.AccessList() + callMsg.BlobGasFeeCap = tx.BlobGasFeeCap() + callMsg.BlobHashes = tx.BlobHashes() + case gethtypes.DynamicFeeTxType: + callMsg.GasTipCap = tx.GasTipCap() + callMsg.GasFeeCap = tx.GasFeeCap() + callMsg.AccessList = tx.AccessList() + case gethtypes.AccessListTxType: + callMsg.GasPrice = tx.GasPrice() + callMsg.AccessList = tx.AccessList() + case gethtypes.LegacyTxType: + callMsg.GasPrice = tx.GasPrice() + default: + panic("unsupported tx type") + } + + return cl.EstimateGas(ctx, callMsg) }