File tree Expand file tree Collapse file tree 11 files changed +64
-20
lines changed
Expand file tree Collapse file tree 11 files changed +64
-20
lines changed Original file line number Diff line number Diff line change @@ -4,7 +4,7 @@ import type { EthersClient } from '../../client';
44import type { Address , Hex } from '../../../../core/types/primitives' ;
55import type { DepositParams , DepositRoute } from '../../../../core/types/flows/deposits' ;
66import type { CommonCtx } from '../../../../core/types/flows/base' ;
7- import type { TxOverrides } from '../../../../core/types/fees' ;
7+ import { type TxGasOverrides , toGasOverrides } from '../../../../core/types/fees' ;
88import type { ResolvedToken , TokensResource } from '../../../../core/types/flows/token' ;
99import type { ContractsResource } from '../contracts' ;
1010
@@ -22,7 +22,7 @@ export interface BuildCtx extends CommonCtx {
2222
2323 l1AssetRouter : Address ;
2424
25- gasOverrides ?: TxOverrides ;
25+ gasOverrides ?: TxGasOverrides ;
2626 l2GasLimit ?: bigint ;
2727 gasPerPubdata : bigint ;
2828 operatorTip : bigint ;
@@ -72,7 +72,7 @@ export async function commonCtx(
7272 bridgehub,
7373 chainIdL2 : BigInt ( chainId ) ,
7474 sender,
75- gasOverrides : p . l1TxOverrides ,
75+ gasOverrides : p . l1TxOverrides ? toGasOverrides ( p . l1TxOverrides ) : undefined ,
7676 l2GasLimit : p . l2GasLimit ,
7777 gasPerPubdata,
7878 operatorTip,
Original file line number Diff line number Diff line change @@ -182,7 +182,13 @@ export function createDepositsResource(
182182
183183 const managed = new NonceManager ( client . signer ) ;
184184 const from = await managed . getAddress ( ) ;
185- let next = await client . l1 . getTransactionCount ( from , 'latest' ) ;
185+ let next : number ;
186+ if ( typeof p . l1TxOverrides ?. nonce === 'number' ) {
187+ next = p . l1TxOverrides . nonce ;
188+ } else {
189+ const blockTag = p . l1TxOverrides ?. nonce ?? 'latest' ;
190+ next = await client . l1 . getTransactionCount ( from , blockTag ) ;
191+ }
186192
187193 for ( const step of plan . steps ) {
188194 // re-check allowance
Original file line number Diff line number Diff line change 33import type { TransactionRequest } from 'ethers' ;
44import type { BuildCtx } from '../context' ;
55import type { DepositRoute } from '../../../../../core/types/flows/deposits' ;
6- import type { TxOverrides } from '../../../../../core/types/fees' ;
6+ import type { TxGasOverrides } from '../../../../../core/types/fees' ;
77import type { Address } from '../../../../../core/types/primitives' ;
88import {
99 quoteL1Gas as coreQuoteL1Gas ,
@@ -17,7 +17,7 @@ export type { GasQuote };
1717export type QuoteL1GasInput = {
1818 ctx : BuildCtx ;
1919 tx : TransactionRequest ;
20- overrides ?: TxOverrides ;
20+ overrides ?: TxGasOverrides ;
2121 fallbackGasLimit ?: bigint ;
2222} ;
2323
Original file line number Diff line number Diff line change @@ -5,7 +5,7 @@ import type { Address } from '../../../../core/types/primitives';
55import { pickWithdrawRoute } from '../../../../core/resources/withdrawals/route' ;
66import { type WithdrawParams , type WithdrawRoute } from '../../../../core/types/flows/withdrawals' ;
77import type { CommonCtx } from '../../../../core/types/flows/base' ;
8- import type { TxOverrides } from '../../../../core/types/fees' ;
8+ import { type TxGasOverrides , toGasOverrides } from '../../../../core/types/fees' ;
99import type { Hex } from '../../../../core/types/primitives' ;
1010import type { ResolvedToken , TokensResource } from '../../../../core/types/flows/token' ;
1111import type { ContractsResource } from '../contracts' ;
@@ -31,7 +31,7 @@ export interface BuildCtx extends CommonCtx {
3131 l2BaseTokenSystem : Address ;
3232
3333 // L2 gas
34- gasOverrides ?: TxOverrides ;
34+ gasOverrides ?: TxGasOverrides ;
3535}
3636
3737export async function commonCtx (
@@ -79,6 +79,6 @@ export async function commonCtx(
7979 l2NativeTokenVault,
8080 l2BaseTokenSystem,
8181 baseIsEth,
82- gasOverrides : p . l2TxOverrides ,
82+ gasOverrides : p . l2TxOverrides ? toGasOverrides ( p . l2TxOverrides ) : undefined ,
8383 } satisfies BuildCtx & { route : WithdrawRoute } ;
8484}
Original file line number Diff line number Diff line change @@ -193,7 +193,13 @@ export function createWithdrawalsResource(
193193
194194 const managed = new NonceManager ( client . getL2Signer ( ) ) ;
195195 const from = await managed . getAddress ( ) ;
196- let next = await client . l2 . getTransactionCount ( from , 'pending' ) ;
196+ let next : number ;
197+ if ( typeof p . l2TxOverrides ?. nonce === 'number' ) {
198+ next = p . l2TxOverrides . nonce ;
199+ } else {
200+ const blockTag = p . l2TxOverrides ?. nonce ?? 'pending' ;
201+ next = await client . l2 . getTransactionCount ( from , blockTag ) ;
202+ }
197203
198204 for ( const step of plan . steps ) {
199205 step . tx . nonce = next ++ ;
Original file line number Diff line number Diff line change @@ -3,7 +3,7 @@ import type { ViemClient } from '../../client';
33import type { Address , Hex } from '../../../../core/types/primitives' ;
44import type { DepositParams , DepositRoute } from '../../../../core/types/flows/deposits' ;
55import type { CommonCtx } from '../../../../core/types/flows/base' ;
6- import type { TxOverrides } from '../../../../core/types/fees' ;
6+ import { type TxGasOverrides , toGasOverrides } from '../../../../core/types/fees' ;
77import type { ResolvedToken , TokensResource } from '../../../../core/types/flows/token' ;
88import type { ContractsResource } from '../contracts' ;
99
@@ -21,7 +21,7 @@ export interface BuildCtx extends CommonCtx {
2121
2222 l1AssetRouter : Address ;
2323
24- gasOverrides ?: TxOverrides ;
24+ gasOverrides ?: TxGasOverrides ;
2525 l2GasLimit ?: bigint ;
2626 gasPerPubdata : bigint ;
2727 operatorTip : bigint ;
@@ -71,7 +71,7 @@ export async function commonCtx(
7171 bridgehub,
7272 chainIdL2 : BigInt ( chainId ) ,
7373 sender,
74- gasOverrides : p . l1TxOverrides ,
74+ gasOverrides : p . l1TxOverrides ? toGasOverrides ( p . l1TxOverrides ) : undefined ,
7575 l2GasLimit : p . l2GasLimit ,
7676 gasPerPubdata,
7777 operatorTip,
Original file line number Diff line number Diff line change @@ -188,8 +188,13 @@ export function createDepositsResource(
188188 const stepHashes : Record < string , Hex > = { } ;
189189
190190 const from = client . account . address ;
191- // TODO: remove this
192- let next = await client . l1 . getTransactionCount ( { address : from , blockTag : 'latest' } ) ;
191+ let next : number ;
192+ if ( typeof p . l1TxOverrides ?. nonce === 'number' ) {
193+ next = p . l1TxOverrides . nonce ;
194+ } else {
195+ const blockTag = p . l1TxOverrides ?. nonce ?? 'latest' ;
196+ next = await client . l1 . getTransactionCount ( { address : from , blockTag } ) ;
197+ }
193198
194199 for ( const step of plan . steps ) {
195200 // Re-check allowance
Original file line number Diff line number Diff line change 33import { zeroAddress , type TransactionRequest } from 'viem' ;
44import type { BuildCtx } from '../context' ;
55import type { DepositRoute } from '../../../../../core/types/flows/deposits' ;
6- import type { TxOverrides } from '../../../../../core/types/fees' ;
6+ import type { TxGasOverrides } from '../../../../../core/types/fees' ;
77import type { Address } from '../../../../../core/types/primitives' ;
88import {
99 quoteL1Gas as coreQuoteL1Gas ,
@@ -17,7 +17,7 @@ export type { GasQuote };
1717export type QuoteL1GasInput = {
1818 ctx : BuildCtx ;
1919 tx : TransactionRequest ;
20- overrides ?: TxOverrides ;
20+ overrides ?: TxGasOverrides ;
2121 fallbackGasLimit ?: bigint ;
2222} ;
2323
Original file line number Diff line number Diff line change @@ -5,7 +5,7 @@ import type { Address } from '../../../../core/types/primitives';
55import { pickWithdrawRoute } from '../../../../core/resources/withdrawals/route' ;
66import { type WithdrawParams , type WithdrawRoute } from '../../../../core/types/flows/withdrawals' ;
77import type { CommonCtx } from '../../../../core/types/flows/base' ;
8- import type { TxOverrides } from '../../../../core/types/fees' ;
8+ import { type TxGasOverrides , toGasOverrides } from '../../../../core/types/fees' ;
99import type { Hex } from '../../../../core/types/primitives' ;
1010import type { ResolvedToken , TokensResource } from '../../../../core/types/flows/token' ;
1111import type { ContractsResource } from '../contracts' ;
@@ -31,7 +31,7 @@ export interface BuildCtx extends CommonCtx {
3131 l2BaseTokenSystem : Address ;
3232
3333 // L2 gas
34- gasOverrides ?: TxOverrides ;
34+ gasOverrides ?: TxGasOverrides ;
3535}
3636
3737export async function commonCtx (
@@ -78,6 +78,6 @@ export async function commonCtx(
7878 l2NativeTokenVault,
7979 l2BaseTokenSystem,
8080 baseIsEth,
81- gasOverrides : p . l2TxOverrides ,
81+ gasOverrides : p . l2TxOverrides ? toGasOverrides ( p . l2TxOverrides ) : undefined ,
8282 } satisfies BuildCtx & { route : WithdrawRoute } ;
8383}
Original file line number Diff line number Diff line change @@ -190,6 +190,15 @@ export function createWithdrawalsResource(
190190 const stepHashes : Record < string , Hex > = { } ;
191191
192192 const l2Wallet = client . getL2Wallet ( ) ;
193+ const from = client . account . address ;
194+
195+ let next : number ;
196+ if ( typeof p . l2TxOverrides ?. nonce === 'number' ) {
197+ next = p . l2TxOverrides . nonce ;
198+ } else {
199+ const blockTag = p . l2TxOverrides ?. nonce ?? 'pending' ;
200+ next = await client . l2 . getTransactionCount ( { address : from , blockTag } ) ;
201+ }
193202
194203 for ( const step of plan . steps ) {
195204 if ( p . l2TxOverrides ) {
@@ -237,13 +246,16 @@ export function createWithdrawalsResource(
237246 }
238247 : { } ;
239248
249+ const nonce = next ++ ;
250+
240251 const baseReq = {
241252 address : step . tx . address ,
242253 abi : step . tx . abi as Abi ,
243254 functionName : step . tx . functionName ,
244255 args : step . tx . args ?? [ ] ,
245256 account : step . tx . account ?? l2Wallet . account ?? client . account ,
246257 gas : step . tx . gas ,
258+ nonce,
247259 ...fee1559 ,
248260 ...( step . tx . dataSuffix ? { dataSuffix : step . tx . dataSuffix } : { } ) ,
249261 ...( step . tx . chain ? { chain : step . tx . chain } : { } ) ,
You can’t perform that action at this time.
0 commit comments