Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: use TransactOpts instead of TransactOptsL1 in withdraw and transfer transactions #74

Merged
merged 1 commit into from
Nov 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 32 additions & 26 deletions accounts/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -736,28 +736,32 @@ type TransferTransaction struct {
}

// ToTransaction transforms TransferTransaction to Transaction.
func (t *TransferTransaction) ToTransaction(opts *TransactOptsL1) *Transaction {
func (t *TransferTransaction) ToTransaction(opts *TransactOpts) *Transaction {
return &Transaction{
To: &t.To,
Value: t.Amount,
Nonce: opts.Nonce,
GasFeeCap: opts.GasFeeCap,
GasTipCap: opts.GasTipCap,
Gas: opts.GasLimit,
To: &t.To,
Value: t.Amount,
Nonce: opts.Nonce,
GasFeeCap: opts.GasFeeCap,
GasTipCap: opts.GasTipCap,
Gas: opts.GasLimit,
GasPerPubdata: opts.GasPerPubdata,
PaymasterParams: opts.PaymasterParams,
}
}

// ToTransferCallMsg transforms TransferTransaction to clients.TransferCallMsg.
func (t *TransferTransaction) ToTransferCallMsg(from common.Address, opts *TransactOptsL1) clients.TransferCallMsg {
func (t *TransferTransaction) ToTransferCallMsg(from common.Address, opts *TransactOpts) clients.TransferCallMsg {
return clients.TransferCallMsg{
To: t.To,
Amount: t.Amount,
Token: t.Token,
From: from,
Gas: opts.GasLimit,
GasPrice: opts.GasPrice,
GasFeeCap: opts.GasFeeCap,
GasTipCap: opts.GasTipCap,
To: t.To,
Amount: t.Amount,
Token: t.Token,
From: from,
Gas: opts.GasLimit,
GasPrice: opts.GasPrice,
GasFeeCap: opts.GasFeeCap,
GasTipCap: opts.GasTipCap,
GasPerPubdata: opts.GasPerPubdata,
PaymasterParams: opts.PaymasterParams,
}
}

Expand All @@ -771,17 +775,19 @@ type WithdrawalTransaction struct {
}

// ToWithdrawalCallMsg transforms WithdrawalTransaction to clients.WithdrawalCallMsg.
func (t *WithdrawalTransaction) ToWithdrawalCallMsg(from common.Address, opts *TransactOptsL1) *clients.WithdrawalCallMsg {
func (t *WithdrawalTransaction) ToWithdrawalCallMsg(from common.Address, opts *TransactOpts) *clients.WithdrawalCallMsg {
return &clients.WithdrawalCallMsg{
To: t.To,
Amount: t.Amount,
Token: t.Token,
BridgeAddress: t.BridgeAddress,
From: from,
Gas: opts.GasLimit,
GasPrice: opts.GasPrice,
GasFeeCap: opts.GasFeeCap,
GasTipCap: opts.GasTipCap,
To: t.To,
Amount: t.Amount,
Token: t.Token,
BridgeAddress: t.BridgeAddress,
From: from,
Gas: opts.GasLimit,
GasPrice: opts.GasPrice,
GasFeeCap: opts.GasFeeCap,
GasTipCap: opts.GasTipCap,
GasPerPubdata: opts.GasPerPubdata,
PaymasterParams: opts.PaymasterParams,
}
}

Expand Down
2 changes: 1 addition & 1 deletion accounts/wallet_l2.go
Original file line number Diff line number Diff line change
Expand Up @@ -396,7 +396,7 @@ func (w *WalletL2) SendTransaction(ctx context.Context, tx *Transaction) (common
return w.client.SendRawTransaction(ensureContext(ctx), rawTx)
}

func (w *WalletL2) transferBaseToken(auth *TransactOptsL1, tx TransferTransaction) (*ethTypes.Transaction, error) {
func (w *WalletL2) transferBaseToken(auth *TransactOpts, tx TransferTransaction) (*ethTypes.Transaction, error) {
if auth.GasPrice != nil {
if auth.Nonce == nil {
nonce, err := w.client.NonceAt(auth.Context, w.Address(), nil)
Expand Down