diff --git a/blockchain/storage/leveldb/leveldb_test.go b/blockchain/storage/leveldb/leveldb_test.go index 17fe6418d0..d149c65c6a 100644 --- a/blockchain/storage/leveldb/leveldb_test.go +++ b/blockchain/storage/leveldb/leveldb_test.go @@ -54,16 +54,14 @@ func generateTxs(t *testing.T, startNonce, count int, from types.Address, to *ty txs := make([]*types.Transaction, count) for i := range txs { - tx := types.NewTx(&types.DynamicFeeTx{ - GasFeeCap: big.NewInt(100), - GasTipCap: big.NewInt(10), - BaseTx: &types.BaseTx{ - Gas: types.StateTransactionGasLimit, - Nonce: uint64(startNonce + i), - To: to, - Value: big.NewInt(2000), - }, - }) + tx := types.NewTx(types.NewDynamicFeeTx( + types.WithGasFeeCap(big.NewInt(100)), + types.WithGasTipCap(big.NewInt(10)), + types.WithGas(types.StateTransactionGasLimit), + types.WithNonce(uint64(startNonce+1)), + types.WithTo(to), + types.WithValue(big.NewInt(2000)), + )) input := make([]byte, 1000) _, err := rand.Read(input) diff --git a/blockchain/storage/testing.go b/blockchain/storage/testing.go index f073b55227..f6ce56840e 100644 --- a/blockchain/storage/testing.go +++ b/blockchain/storage/testing.go @@ -338,14 +338,12 @@ func testReceipts(t *testing.T, m PlaceholderStorage) { body := &types.Body{ Transactions: []*types.Transaction{ - types.NewTx(&types.StateTx{ - GasPrice: new(big.Int).SetUint64(100), - BaseTx: &types.BaseTx{ - Nonce: 1000, - Gas: 50, - V: big.NewInt(11), - }, - }), + types.NewTx(types.NewStateTx( + types.WithGasPrice(new(big.Int).SetUint64(100)), + types.WithNonce(1000), + types.WithGas(50), + types.WithSignatureValues(big.NewInt(11), nil, nil), + )), }, } receipts := []*types.Receipt{ diff --git a/consensus/polybft/fsm.go b/consensus/polybft/fsm.go index 994d5c29e1..e754c8920f 100644 --- a/consensus/polybft/fsm.go +++ b/consensus/polybft/fsm.go @@ -716,15 +716,13 @@ func validateHeaderFields(parent *types.Header, header *types.Header, blockTimeD // createStateTransactionWithData creates a state transaction // with provided target address and inputData parameter which is ABI encoded byte array. func createStateTransactionWithData(target types.Address, inputData []byte) *types.Transaction { - tx := types.NewTx(&types.StateTx{ - GasPrice: big.NewInt(0), - BaseTx: &types.BaseTx{ - From: contracts.SystemCaller, - To: &target, - Input: inputData, - Gas: types.StateTransactionGasLimit, - }, - }) + tx := types.NewTx(types.NewStateTx( + types.WithGasPrice(big.NewInt(0)), + types.WithFrom(contracts.SystemCaller), + types.WithTo(&target), + types.WithInput(inputData), + types.WithGas(types.StateTransactionGasLimit), + )) return tx.ComputeHash() } diff --git a/consensus/polybft/fsm_test.go b/consensus/polybft/fsm_test.go index 5ae5440f42..4f588dd03e 100644 --- a/consensus/polybft/fsm_test.go +++ b/consensus/polybft/fsm_test.go @@ -100,13 +100,12 @@ func TestFSM_verifyCommitEpochTx(t *testing.T) { assert.NoError(t, fsm.verifyCommitEpochTx(commitEpochTx)) // submit tampered commit epoch transaction to the epoch ending block - alteredCommitEpochTx := types.NewTx(&types.StateTx{ - BaseTx: &types.BaseTx{ - To: &contracts.EpochManagerContract, - Input: []byte{}, - Gas: 0, - }, - }) + alteredCommitEpochTx := types.NewTx(types.NewStateTx( + types.WithTo(&contracts.EpochManagerContract), + types.WithInput([]byte{}), + types.WithGas(0), + )) + assert.ErrorContains(t, fsm.verifyCommitEpochTx(alteredCommitEpochTx), "invalid commit epoch transaction") // submit validators commit epoch transaction to the non-epoch ending block diff --git a/crypto/txsigner_london_test.go b/crypto/txsigner_london_test.go index 146de82fe1..48067deb1e 100644 --- a/crypto/txsigner_london_test.go +++ b/crypto/txsigner_london_test.go @@ -74,14 +74,12 @@ func TestLondonSignerSender(t *testing.T) { switch tc.txType { case types.AccessListTxType: - txn = types.NewTx(&types.AccessListTxn{ - GasPrice: big.NewInt(5), - ChainID: tc.chainID, - BaseTx: &types.BaseTx{ - To: &recipient, - Value: big.NewInt(1), - }, - }) + txn = types.NewTx(types.NewAccessListTx( + types.WithGasPrice(big.NewInt(5)), + types.WithChainID(tc.chainID), + types.WithTo(&recipient), + types.WithValue(big.NewInt(1)), + )) case types.LegacyTxType: txn = types.NewTx(types.NewLegacyTx( types.WithGasPrice(big.NewInt(5)), @@ -89,21 +87,17 @@ func TestLondonSignerSender(t *testing.T) { types.WithValue(big.NewInt(1)), )) case types.StateTxType: - txn = types.NewTx(&types.StateTx{ - GasPrice: big.NewInt(5), - BaseTx: &types.BaseTx{ - To: &recipient, - Value: big.NewInt(1), - }, - }) + txn = types.NewTx(types.NewStateTx( + types.WithGasPrice(big.NewInt(5)), + types.WithTo(&recipient), + types.WithValue(big.NewInt(1)), + )) case types.DynamicFeeTxType: - txn = types.NewTx(&types.DynamicFeeTx{ - ChainID: tc.chainID, - BaseTx: &types.BaseTx{ - To: &recipient, - Value: big.NewInt(1), - }, - }) + txn = types.NewTx(types.NewDynamicFeeTx( + types.WithChainID(tc.chainID), + types.WithTo(&recipient), + types.WithValue(big.NewInt(1)), + )) } chainID := tc.chainID.Uint64() @@ -140,19 +134,15 @@ func Test_LondonSigner_Sender(t *testing.T) { }{ { name: "sender is 0x85dA99c8a7C2C95964c8EfD687E95E632Fc533D6", - tx: types.NewTx(&types.DynamicFeeTx{ - ChainID: big.NewInt(100), - GasTipCap: ethgo.Gwei(1), - GasFeeCap: ethgo.Gwei(10), - BaseTx: &types.BaseTx{ - Gas: 21000, - To: &to, - Value: big.NewInt(100000000000000), - V: big.NewInt(0), - R: r, - S: s, - }, - }), + tx: types.NewTx(types.NewDynamicFeeTx( + types.WithChainID(big.NewInt(100)), + types.WithGasTipCap(ethgo.Gwei(1)), + types.WithGasFeeCap(ethgo.Gwei(10)), + types.WithGas(21000), + types.WithTo(&to), + types.WithValue(big.NewInt(100000000000000)), + types.WithSignatureValues(big.NewInt(0), r, s), + )), sender: types.StringToAddress("0x85dA99c8a7C2C95964c8EfD687E95E632Fc533D6"), }, } diff --git a/e2e/txpool_test.go b/e2e/txpool_test.go index 72c642e960..55d67cb7b8 100644 --- a/e2e/txpool_test.go +++ b/e2e/txpool_test.go @@ -54,15 +54,12 @@ func generateTx(params generateTxReqParams) *types.Transaction { )) unsignedTx.SetGasPrice(params.gasPrice) } else { - unsignedTx = types.NewTx(&types.DynamicFeeTx{ - ChainID: new(big.Int).SetUint64(defaultChainID), - BaseTx: &types.BaseTx{ - Nonce: params.nonce, - To: ¶ms.toAddress, - Gas: 1000000, - Value: params.value, - }, - }) + unsignedTx = types.NewTx(types.NewDynamicFeeTx( + types.WithNonce(params.nonce), + types.WithTo(¶ms.toAddress), + types.WithGas(1000000), + types.WithValue(params.value), + )) unsignedTx.SetGasFeeCap(params.gasFeeCap) unsignedTx.SetGasTipCap(params.gasTipCap) } @@ -260,18 +257,16 @@ func TestTxPool_RecoverableError(t *testing.T) { types.WithValue(oneEth), types.WithSignatureValues(big.NewInt(27), nil, nil), )), - types.NewTx(&types.DynamicFeeTx{ - ChainID: new(big.Int).SetUint64(defaultChainID), - GasFeeCap: big.NewInt(framework.DefaultGasPrice), - GasTipCap: big.NewInt(1000000000), - BaseTx: &types.BaseTx{ - Nonce: 2, - Gas: 22000, - To: &receiverAddress, - Value: oneEth, - V: big.NewInt(27), - }, - }), + types.NewTx(types.NewDynamicFeeTx( + types.WithChainID(new(big.Int).SetUint64(defaultChainID)), + types.WithGasFeeCap(big.NewInt(framework.DefaultGasPrice)), + types.WithGasTipCap(big.NewInt(1000000000)), + types.WithNonce(2), + types.WithGas(22000), + types.WithTo(&receiverAddress), + types.WithValue(oneEth), + types.WithSignatureValues(big.NewInt(27), nil, nil), + )), } server := framework.NewTestServers(t, 1, func(config *framework.TestServerConfig) { diff --git a/gasprice/feehistory_test.go b/gasprice/feehistory_test.go index a0251c74d2..68f2115168 100644 --- a/gasprice/feehistory_test.go +++ b/gasprice/feehistory_test.go @@ -194,14 +194,12 @@ func TestGasHelper_FeeHistory(t *testing.T) { b.Header.Miner = sender.Bytes() for i := 0; i < 3; i++ { - tx := types.NewTx(&types.DynamicFeeTx{ - GasTipCap: ethgo.Gwei(uint64(200)), - GasFeeCap: ethgo.Gwei(uint64(200 + 200)), - BaseTx: &types.BaseTx{ - Value: ethgo.Ether(1), - To: &types.ZeroAddress, - }, - }) + tx := types.NewTx(types.NewDynamicFeeTx( + types.WithGasTipCap(ethgo.Gwei(200)), + types.WithGasFeeCap(ethgo.Gwei(200+200)), + types.WithValue(ethgo.Ether(1)), + types.WithTo(&types.ZeroAddress), + )) tx, err := signer.SignTx(tx, senderKey) require.NoError(t, err) diff --git a/gasprice/gasprice_test.go b/gasprice/gasprice_test.go index a9ed00d8e7..aba8a0c274 100644 --- a/gasprice/gasprice_test.go +++ b/gasprice/gasprice_test.go @@ -84,16 +84,14 @@ func TestGasHelper_MaxPriorityFeePerGas(t *testing.T) { b.Header.Miner = sender.Bytes() for i := 0; i < 3; i++ { - tx := types.NewTx(&types.DynamicFeeTx{ - GasTipCap: ethgo.Gwei(uint64(rand.Intn(200))), - GasFeeCap: ethgo.Gwei(uint64(rand.Intn(200) + 200)), - ChainID: big.NewInt(backend.Config().ChainID), - BaseTx: &types.BaseTx{ - From: sender, - Value: ethgo.Ether(1), - To: &types.ZeroAddress, - }, - }) + tx := types.NewTx(types.NewDynamicFeeTx( + types.WithGasTipCap(ethgo.Gwei(uint64(rand.Intn(200)))), + types.WithGasFeeCap(ethgo.Gwei(uint64(rand.Intn(200)+200))), + types.WithChainID(big.NewInt(backend.Config().ChainID)), + types.WithFrom(sender), + types.WithValue(ethgo.Ether(1)), + types.WithTo(&types.ZeroAddress), + )) tx, err := signer.SignTx(tx, senderKey) require.NoError(t, err) @@ -221,16 +219,14 @@ func createTestTxs(t *testing.T, backend *backendMock, numOfTxsPerBlock, txCap i for i := 0; i < numOfTxsPerBlock; i++ { senderKey, sender := tests.GenerateKeyAndAddr(t) - tx := types.NewTx(&types.DynamicFeeTx{ - GasTipCap: ethgo.Gwei(uint64(rand.Intn(txCap))), - GasFeeCap: ethgo.Gwei(uint64(rand.Intn(txCap) + txCap)), - ChainID: big.NewInt(backend.Config().ChainID), - BaseTx: &types.BaseTx{ - From: sender, - Value: ethgo.Ether(1), - To: &types.ZeroAddress, - }, - }) + tx := types.NewTx(types.NewDynamicFeeTx( + types.WithGasTipCap(ethgo.Gwei(uint64(rand.Intn(txCap)))), + types.WithGasFeeCap(ethgo.Gwei(uint64(rand.Intn(txCap)+txCap))), + types.WithChainID(big.NewInt(backend.Config().ChainID)), + types.WithFrom(sender), + types.WithValue(ethgo.Ether(1)), + types.WithTo(&types.ZeroAddress), + )) tx, err := signer.SignTx(tx, senderKey) require.NoError(t, err) diff --git a/jsonrpc/debug_endpoint_test.go b/jsonrpc/debug_endpoint_test.go index 778ce207f0..35a2a3653a 100644 --- a/jsonrpc/debug_endpoint_test.go +++ b/jsonrpc/debug_endpoint_test.go @@ -605,18 +605,16 @@ func TestTraceCall(t *testing.T) { Nonce: &nonce, Type: toArgUint64Ptr(uint64(types.DynamicFeeTxType)), } - decodedTx = types.NewTx(&types.DynamicFeeTx{ - GasTipCap: new(big.Int).SetBytes([]byte(gasTipCap)), - GasFeeCap: new(big.Int).SetBytes([]byte(gasFeeCap)), - BaseTx: &types.BaseTx{ - Nonce: uint64(nonce), - Gas: uint64(gas), - To: &to, - Value: new(big.Int).SetBytes([]byte(value)), - Input: data, - From: from, - }, - }) + decodedTx = types.NewTx(types.NewDynamicFeeTx( + types.WithGasTipCap(new(big.Int).SetBytes([]byte(gasTipCap))), + types.WithGasFeeCap(new(big.Int).SetBytes([]byte(gasFeeCap))), + types.WithNonce(uint64(nonce)), + types.WithGas(uint64(gas)), + types.WithTo(&to), + types.WithValue(new(big.Int).SetBytes([]byte(value))), + types.WithInput(data), + types.WithFrom(from), + )) ) decodedTx.ComputeHash() diff --git a/jsonrpc/eth_endpoint_test.go b/jsonrpc/eth_endpoint_test.go index 6093b6161b..c35dd3694d 100644 --- a/jsonrpc/eth_endpoint_test.go +++ b/jsonrpc/eth_endpoint_test.go @@ -46,18 +46,16 @@ func TestEth_DecodeTxn(t *testing.T) { Nonce: toArgUint64Ptr(0), Type: toArgUint64Ptr(uint64(types.DynamicFeeTxType)), }, - res: types.NewTx(&types.DynamicFeeTx{ - GasTipCap: big.NewInt(10000), - GasFeeCap: big.NewInt(10000), - BaseTx: &types.BaseTx{ - From: addr1, - To: &addr2, - Gas: 21000, - Value: oneEther, - Input: []byte{}, - Nonce: 0, - }, - }), + res: types.NewTx(types.NewDynamicFeeTx( + types.WithGasTipCap(big.NewInt(10000)), + types.WithGasFeeCap(big.NewInt(10000)), + types.WithFrom(addr1), + types.WithTo(&addr2), + types.WithGas(21000), + types.WithValue(oneEther), + types.WithInput([]byte{}), + types.WithNonce(0), + )), err: nil, }, { @@ -271,18 +269,16 @@ func TestEth_TxnType(t *testing.T) { Type: toArgUint64Ptr(uint64(types.DynamicFeeTxType)), } - expectedRes := types.NewTx(&types.DynamicFeeTx{ - GasTipCap: big.NewInt(10000), - GasFeeCap: big.NewInt(10000), - BaseTx: &types.BaseTx{ - From: addr1, - To: &addr2, - Gas: 21000, - Value: oneEther, - Input: []byte{}, - Nonce: 0, - }, - }) + expectedRes := types.NewTx(types.NewDynamicFeeTx( + types.WithGasTipCap(big.NewInt(10000)), + types.WithGasFeeCap(big.NewInt(10000)), + types.WithFrom(addr1), + types.WithTo(&addr2), + types.WithGas(21000), + types.WithValue(oneEther), + types.WithInput([]byte{}), + types.WithNonce(0), + )) res, err := DecodeTxn(args, 1, store, false) expectedRes.ComputeHash() diff --git a/jsonrpc/helper_test.go b/jsonrpc/helper_test.go index f04f481ffb..19f521d6c7 100644 --- a/jsonrpc/helper_test.go +++ b/jsonrpc/helper_test.go @@ -706,18 +706,16 @@ func TestDecodeTxn(t *testing.T) { Type: toArgUint64Ptr(uint64(types.DynamicFeeTxType)), }, store: &debugEndpointMockStore{}, - expected: types.NewTx(&types.DynamicFeeTx{ - GasTipCap: new(big.Int).SetBytes([]byte(gasTipCap)), - GasFeeCap: new(big.Int).SetBytes([]byte(gasFeeCap)), - BaseTx: &types.BaseTx{ - Value: new(big.Int).SetBytes([]byte(value)), - Input: input, - Nonce: uint64(nonce), - From: from, - To: &to, - Gas: uint64(gas), - }, - }), + expected: types.NewTx(types.NewDynamicFeeTx( + types.WithGasTipCap(new(big.Int).SetBytes([]byte(gasTipCap))), + types.WithGasFeeCap(new(big.Int).SetBytes([]byte(gasFeeCap))), + types.WithValue(new(big.Int).SetBytes([]byte(value))), + types.WithInput(input), + types.WithNonce(uint64(nonce)), + types.WithFrom(from), + types.WithTo(&to), + types.WithGas(uint64(gas)), + )), err: false, }, { diff --git a/jsonrpc/txpool_endpoint_test.go b/jsonrpc/txpool_endpoint_test.go index 03654ead6c..a46dae8e17 100644 --- a/jsonrpc/txpool_endpoint_test.go +++ b/jsonrpc/txpool_endpoint_test.go @@ -311,22 +311,18 @@ func newTestTransaction(nonce uint64, from types.Address) *types.Transaction { } func newTestDynamicFeeTransaction(nonce uint64, from types.Address) *types.Transaction { - txn := types.NewTx(&types.DynamicFeeTx{ - GasTipCap: big.NewInt(2), - GasFeeCap: big.NewInt(4), - ChainID: big.NewInt(100), - BaseTx: &types.BaseTx{ - Nonce: nonce, - Gas: nonce * 100, - Value: big.NewInt(200), - Input: []byte{0xff}, - From: from, - To: &addr1, - V: big.NewInt(1), - R: big.NewInt(1), - S: big.NewInt(1), - }, - }) + txn := types.NewTx(types.NewDynamicFeeTx( + types.WithGasTipCap(big.NewInt(2)), + types.WithGasFeeCap(big.NewInt(4)), + types.WithChainID(big.NewInt(100)), + types.WithNonce(nonce), + types.WithGas(nonce*100), + types.WithValue(big.NewInt(200)), + types.WithInput([]byte{0xff}), + types.WithFrom(from), + types.WithTo(&addr1), + types.WithSignatureValues(big.NewInt(1), big.NewInt(1), big.NewInt(1)), + )) txn.ComputeHash() diff --git a/jsonrpc/types_test.go b/jsonrpc/types_test.go index 5aec65a284..3b6da3a0ba 100644 --- a/jsonrpc/types_test.go +++ b/jsonrpc/types_test.go @@ -132,22 +132,16 @@ func TestToTransaction_EIP1559(t *testing.T) { v, _ := hex.DecodeHex(hexWithLeading0) r, _ := hex.DecodeHex(hexWithLeading0) s, _ := hex.DecodeHex(hexWithLeading0) - txn := types.NewTx(&types.DynamicFeeTx{ - GasTipCap: big.NewInt(10), - GasFeeCap: big.NewInt(10), - BaseTx: &types.BaseTx{ - Nonce: 0, - Gas: 0, - To: nil, - Value: big.NewInt(0), - Input: nil, - V: new(big.Int).SetBytes(v), - R: new(big.Int).SetBytes(r), - S: new(big.Int).SetBytes(s), - Hash: types.Hash{}, - From: types.Address{}, - }, - }) + txn := types.NewTx(types.NewDynamicFeeTx( + types.WithGasTipCap(big.NewInt(10)), + types.WithGasFeeCap(big.NewInt(10)), + types.WithNonce(0), + types.WithGas(0), + types.WithValue(big.NewInt(0)), + types.WithSignatureValues(new(big.Int).SetBytes(v), new(big.Int).SetBytes(r), new(big.Int).SetBytes(s)), + types.WithHash(types.Hash{}), + types.WithFrom(types.Address{}), + )) jsonTx := toTransaction(txn, nil, nil, nil) diff --git a/state/executor_test.go b/state/executor_test.go index 42e5eb4237..1ad4cb6c16 100644 --- a/state/executor_test.go +++ b/state/executor_test.go @@ -80,11 +80,11 @@ func Test_Transition_checkDynamicFees(t *testing.T) { { name: "happy path", baseFee: big.NewInt(100), - tx: types.NewTx(&types.DynamicFeeTx{ - GasFeeCap: big.NewInt(100), - GasTipCap: big.NewInt(100), - BaseTx: &types.BaseTx{From: types.ZeroAddress}, - }), + tx: types.NewTx(types.NewDynamicFeeTx( + types.WithGasFeeCap(big.NewInt(100)), + types.WithGasTipCap(big.NewInt(100)), + types.WithFrom(types.ZeroAddress), + )), wantErr: func(t assert.TestingT, err error, i ...interface{}) bool { assert.NoError(t, err, i) @@ -94,11 +94,11 @@ func Test_Transition_checkDynamicFees(t *testing.T) { { name: "happy path with empty values", baseFee: big.NewInt(0), - tx: types.NewTx(&types.DynamicFeeTx{ - GasFeeCap: big.NewInt(0), - GasTipCap: big.NewInt(0), - BaseTx: &types.BaseTx{From: types.ZeroAddress}, - }), + tx: types.NewTx(types.NewDynamicFeeTx( + types.WithGasFeeCap(big.NewInt(0)), + types.WithGasTipCap(big.NewInt(0)), + types.WithFrom(types.ZeroAddress), + )), wantErr: func(t assert.TestingT, err error, i ...interface{}) bool { assert.NoError(t, err, i) @@ -108,11 +108,11 @@ func Test_Transition_checkDynamicFees(t *testing.T) { { name: "gas fee cap less than base fee", baseFee: big.NewInt(20), - tx: types.NewTx(&types.DynamicFeeTx{ - GasFeeCap: big.NewInt(10), - GasTipCap: big.NewInt(0), - BaseTx: &types.BaseTx{From: types.ZeroAddress}, - }), + tx: types.NewTx(types.NewDynamicFeeTx( + types.WithGasFeeCap(big.NewInt(10)), + types.WithGasTipCap(big.NewInt(0)), + types.WithFrom(types.ZeroAddress), + )), wantErr: func(t assert.TestingT, err error, i ...interface{}) bool { expectedError := fmt.Sprintf("max fee per gas less than block base fee: "+ "address %s, GasFeeCap/GasPrice: 10, BaseFee: 20", types.ZeroAddress) @@ -124,11 +124,11 @@ func Test_Transition_checkDynamicFees(t *testing.T) { { name: "gas fee cap less than tip cap", baseFee: big.NewInt(5), - tx: types.NewTx(&types.DynamicFeeTx{ - GasFeeCap: big.NewInt(10), - GasTipCap: big.NewInt(15), - BaseTx: &types.BaseTx{From: types.ZeroAddress}, - }), + tx: types.NewTx(types.NewDynamicFeeTx( + types.WithGasFeeCap(big.NewInt(10)), + types.WithGasTipCap(big.NewInt(15)), + types.WithFrom(types.ZeroAddress), + )), wantErr: func(t assert.TestingT, err error, i ...interface{}) bool { expectedError := fmt.Sprintf("max priority fee per gas higher than max fee per gas: "+ "address %s, GasTipCap: 15, GasFeeCap: 10", types.ZeroAddress) diff --git a/tests/state_test_util.go b/tests/state_test_util.go index 4a4b7891bf..71a8568260 100644 --- a/tests/state_test_util.go +++ b/tests/state_test_util.go @@ -329,35 +329,31 @@ func (t *stTransaction) At(i indexes, baseFee *big.Int) (*types.Transaction, err // if tx is not dynamic and accessList is not nil, create an access list transaction if !isDynamiFeeTx && accessList != nil { - txData = &types.AccessListTxn{ - GasPrice: gasPrice, - AccessList: accessList, - BaseTx: &types.BaseTx{ - From: t.From, - To: t.To, - Nonce: t.Nonce, - Value: value, - Gas: t.GasLimit[i.Gas], - Input: hex.MustDecodeHex(t.Data[i.Data]), - }, - } + txData = types.NewAccessListTx( + types.WithGasPrice(gasPrice), + types.WithAccessList(accessList), + types.WithFrom(t.From), + types.WithTo(t.To), + types.WithNonce(t.Nonce), + types.WithValue(value), + types.WithGas(t.GasLimit[i.Gas]), + types.WithInput(hex.MustDecodeHex(t.Data[i.Data])), + ) } if txData == nil { if isDynamiFeeTx { - txData = &types.DynamicFeeTx{ - GasFeeCap: t.MaxFeePerGas, - GasTipCap: t.MaxPriorityFeePerGas, - AccessList: accessList, - BaseTx: &types.BaseTx{ - From: t.From, - To: t.To, - Nonce: t.Nonce, - Value: value, - Gas: t.GasLimit[i.Gas], - Input: hex.MustDecodeHex(t.Data[i.Data]), - }, - } + txData = + types.NewDynamicFeeTx( + types.WithGasFeeCap(t.MaxFeePerGas), + types.WithGasTipCap(t.MaxPriorityFeePerGas), + types.WithFrom(t.From), + types.WithTo(t.To), + types.WithNonce(t.Nonce), + types.WithValue(value), + types.WithGas(t.GasLimit[i.Gas]), + types.WithInput(hex.MustDecodeHex(t.Data[i.Data])), + ) } else { txData = types.NewLegacyTx( types.WithGasPrice(gasPrice),