-
Notifications
You must be signed in to change notification settings - Fork 49
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
cae2f23
commit 72263f7
Showing
5 changed files
with
124 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import { | ||
Chain, | ||
GetFunctionArgs, | ||
PrepareTransactionRequestParameters, | ||
PrepareTransactionRequestReturnType, | ||
PublicClient, | ||
Transport, | ||
encodeFunctionData, | ||
} from 'viem'; | ||
import { sequencerInbox } from '../contracts'; | ||
import { WithContractAddress, ActionParameters, WithAccount } from '../types/Actions'; | ||
|
||
type Args = GetFunctionArgs<SequencerInboxABI, 'addSequencerL2Batch'>; | ||
type SequencerInboxABI = typeof sequencerInbox.abi; | ||
type BuildAddSequencerL2BatchParameters<Curried extends boolean = false> = WithAccount< | ||
WithContractAddress<Args, 'sequencerInbox', Curried> | ||
>; | ||
export type BuildAddSequencerL2BatchActionParameters<Curried extends boolean> = WithAccount< | ||
ActionParameters<Args, 'sequencerInbox', Curried> | ||
>; | ||
|
||
export type BuildAddSequencerL2BatchReturnType = PrepareTransactionRequestReturnType; | ||
|
||
function sequencerInboxFunctionData({ args }: BuildAddSequencerL2BatchParameters) { | ||
return encodeFunctionData({ | ||
abi: sequencerInbox.abi, | ||
functionName: 'addSequencerL2Batch', | ||
args, | ||
}); | ||
} | ||
|
||
export async function buildAddSequencerL2Batch<TChain extends Chain | undefined>( | ||
client: PublicClient<Transport, TChain>, | ||
args: BuildAddSequencerL2BatchParameters, | ||
): Promise<BuildAddSequencerL2BatchReturnType> { | ||
const data = sequencerInboxFunctionData(args); | ||
|
||
return client.prepareTransactionRequest({ | ||
to: args.sequencerInbox, | ||
value: BigInt(0), | ||
chain: client.chain, | ||
data, | ||
account: args.account, | ||
} satisfies PrepareTransactionRequestParameters); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters