export toTransaction

# Conflicts:
#	internal/ethapi/transaction_args.go
This commit is contained in:
Sina Mahmoodi 2024-03-22 15:08:05 +01:00 committed by Matthieu Vachon
parent d267c7d976
commit bbc363f34c
2 changed files with 10 additions and 16 deletions

View file

@ -449,7 +449,7 @@ func (s *PersonalAccountAPI) signTransaction(ctx context.Context, args *Transact
return nil, err return nil, err
} }
// Assemble the transaction and sign with the wallet // Assemble the transaction and sign with the wallet
tx := args.toTransaction() tx := args.ToTransaction()
return wallet.SignTxWithPassphrase(account, passwd, tx, s.b.ChainConfig().ChainID) return wallet.SignTxWithPassphrase(account, passwd, tx, s.b.ChainConfig().ChainID)
} }
@ -492,7 +492,7 @@ func (s *PersonalAccountAPI) SignTransaction(ctx context.Context, args Transacti
return nil, errors.New("nonce not specified") return nil, errors.New("nonce not specified")
} }
// Before actually signing the transaction, ensure the transaction fee is reasonable. // Before actually signing the transaction, ensure the transaction fee is reasonable.
tx := args.toTransaction() tx := args.ToTransaction()
if err := checkTxFee(tx.GasPrice(), tx.Gas(), s.b.RPCTxFeeCap()); err != nil { if err := checkTxFee(tx.GasPrice(), tx.Gas(), s.b.RPCTxFeeCap()); err != nil {
return nil, err return nil, err
} }
@ -1644,7 +1644,7 @@ func AccessList(ctx context.Context, b Backend, blockNrOrHash rpc.BlockNumberOrH
vmenv, _ := b.GetEVM(ctx, msg, statedb, header, &config, nil) vmenv, _ := b.GetEVM(ctx, msg, statedb, header, &config, nil)
res, err := core.ApplyMessage(vmenv, msg, new(core.GasPool).AddGas(msg.GasLimit)) res, err := core.ApplyMessage(vmenv, msg, new(core.GasPool).AddGas(msg.GasLimit))
if err != nil { if err != nil {
return nil, 0, nil, fmt.Errorf("failed to apply transaction: %v err: %v", args.toTransaction().Hash(), err) return nil, 0, nil, fmt.Errorf("failed to apply transaction: %v err: %v", args.ToTransaction().Hash(), err)
} }
if tracer.Equal(prevTracer) { if tracer.Equal(prevTracer) {
return accessList, res.UsedGas, res.Err, nil return accessList, res.UsedGas, res.Err, nil
@ -1912,7 +1912,7 @@ func (s *TransactionAPI) SendTransaction(ctx context.Context, args TransactionAr
return common.Hash{}, err return common.Hash{}, err
} }
// Assemble the transaction and sign with the wallet // Assemble the transaction and sign with the wallet
tx := args.toTransaction() tx := args.ToTransaction()
signed, err := wallet.SignTx(account, tx, s.b.ChainConfig().ChainID) signed, err := wallet.SignTx(account, tx, s.b.ChainConfig().ChainID)
if err != nil { if err != nil {
@ -1930,7 +1930,7 @@ func (s *TransactionAPI) FillTransaction(ctx context.Context, args TransactionAr
return nil, err return nil, err
} }
// Assemble the transaction and obtain rlp // Assemble the transaction and obtain rlp
tx := args.toTransaction() tx := args.ToTransaction()
data, err := tx.MarshalBinary() data, err := tx.MarshalBinary()
if err != nil { if err != nil {
return nil, err return nil, err
@ -1996,7 +1996,7 @@ func (s *TransactionAPI) SignTransaction(ctx context.Context, args TransactionAr
return nil, err return nil, err
} }
// Before actually sign the transaction, ensure the transaction fee is reasonable. // Before actually sign the transaction, ensure the transaction fee is reasonable.
tx := args.toTransaction() tx := args.ToTransaction()
if err := checkTxFee(tx.GasPrice(), tx.Gas(), s.b.RPCTxFeeCap()); err != nil { if err := checkTxFee(tx.GasPrice(), tx.Gas(), s.b.RPCTxFeeCap()); err != nil {
return nil, err return nil, err
} }
@ -2044,7 +2044,7 @@ func (s *TransactionAPI) Resend(ctx context.Context, sendArgs TransactionArgs, g
if err := sendArgs.setDefaults(ctx, s.b); err != nil { if err := sendArgs.setDefaults(ctx, s.b); err != nil {
return common.Hash{}, err return common.Hash{}, err
} }
matchTx := sendArgs.toTransaction() matchTx := sendArgs.ToTransaction()
// Before replacing the old transaction, ensure the _new_ transaction fee is reasonable. // Before replacing the old transaction, ensure the _new_ transaction fee is reasonable.
var price = matchTx.GasPrice() var price = matchTx.GasPrice()
@ -2074,7 +2074,7 @@ func (s *TransactionAPI) Resend(ctx context.Context, sendArgs TransactionArgs, g
if gasLimit != nil && *gasLimit != 0 { if gasLimit != nil && *gasLimit != 0 {
sendArgs.Gas = gasLimit sendArgs.Gas = gasLimit
} }
signedTx, err := s.sign(sendArgs.from(), sendArgs.toTransaction()) signedTx, err := s.sign(sendArgs.from(), sendArgs.ToTransaction())
if err != nil { if err != nil {
return common.Hash{}, err return common.Hash{}, err
} }

View file

@ -295,9 +295,9 @@ func (args *TransactionArgs) ToMessage(baseFee *big.Int) *core.Message {
} }
} }
// toTransaction converts the arguments to a transaction. // ToTransaction converts the arguments to a transaction.
// This assumes that setDefaults has been called. // This assumes that setDefaults has been called.
func (args *TransactionArgs) toTransaction() *types.Transaction { func (args *TransactionArgs) ToTransaction() *types.Transaction {
var data types.TxData var data types.TxData
switch { switch {
case args.MaxFeePerGas != nil: case args.MaxFeePerGas != nil:
@ -339,9 +339,3 @@ func (args *TransactionArgs) toTransaction() *types.Transaction {
} }
return types.NewTx(data) return types.NewTx(data)
} }
// ToTransaction converts the arguments to a transaction.
// This assumes that setDefaults has been called.
func (args *TransactionArgs) ToTransaction() *types.Transaction {
return args.toTransaction()
}