-
Notifications
You must be signed in to change notification settings - Fork 70
feat: add new SequencerInbox getters #114
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
Merged
Merged
Changes from 3 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
4f87d51
Feat: Add v1 SequencerInbox getters
chrstph-dvx c9627be
Refine ActionParameters type
chrstph-dvx a57924e
Remove unecessary generic type
chrstph-dvx 73f6f86
Merge branch 'main' into add-chain-public-actions-decorator
chrstph-dvx 497ae61
Update ABI paths
chrstph-dvx d5b7003
Export actions
chrstph-dvx d4eda1c
Update exports
chrstph-dvx File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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,33 @@ | ||
import { Chain, PublicClient, Transport } from 'viem'; | ||
import { sequencerInbox } from '../contracts'; | ||
import { ActionParameters } from '../types/Actions'; | ||
|
||
export type GetMaxTimeVariationParameters<Curried extends boolean = false> = ActionParameters< | ||
{}, | ||
'sequencerInbox', | ||
Curried | ||
>; | ||
|
||
export type GetMaxTimeVariationReturnType = { | ||
delayBlocks: bigint; | ||
futureBlocks: bigint; | ||
delaySeconds: bigint; | ||
futureSeconds: bigint; | ||
}; | ||
|
||
export async function getMaxTimeVariation<TChain extends Chain | undefined>( | ||
client: PublicClient<Transport, TChain>, | ||
args: GetMaxTimeVariationParameters, | ||
): Promise<GetMaxTimeVariationReturnType> { | ||
const [delayBlocks, futureBlocks, delaySeconds, futureSeconds] = await client.readContract({ | ||
abi: sequencerInbox.abi, | ||
functionName: 'maxTimeVariation', | ||
address: args.sequencerInbox, | ||
}); | ||
return { | ||
delayBlocks, | ||
futureBlocks, | ||
delaySeconds, | ||
futureSeconds, | ||
}; | ||
} |
This file contains hidden or 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,27 @@ | ||
import { Address, Chain, PublicClient, ReadContractReturnType, Transport } from 'viem'; | ||
import { sequencerInbox } from '../contracts'; | ||
import { ActionParameters } from '../types/Actions'; | ||
|
||
type Args = { | ||
batchPoster: Address; | ||
}; | ||
type SequencerInboxABI = typeof sequencerInbox.abi; | ||
export type IsBatchPosterParameters<Curried extends boolean = false> = ActionParameters< | ||
Args, | ||
'sequencerInbox', | ||
Curried | ||
>; | ||
|
||
export type IsBatchPosterReturnType = ReadContractReturnType<SequencerInboxABI, 'isBatchPoster'>; | ||
|
||
export async function isBatchPoster<TChain extends Chain | undefined>( | ||
client: PublicClient<Transport, TChain>, | ||
args: IsBatchPosterParameters, | ||
): Promise<IsBatchPosterReturnType> { | ||
return client.readContract({ | ||
abi: sequencerInbox.abi, | ||
functionName: 'isBatchPoster', | ||
address: args.sequencerInbox, | ||
args: [args.batchPoster], | ||
}); | ||
} |
This file contains hidden or 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,31 @@ | ||
import { Chain, Hex, PublicClient, ReadContractReturnType, Transport } from 'viem'; | ||
import { sequencerInbox } from '../contracts'; | ||
import { ActionParameters } from '../types/Actions'; | ||
|
||
type Args = { | ||
keysetHash: Hex; | ||
}; | ||
type SequencerInboxABI = typeof sequencerInbox.abi; | ||
|
||
export type IsValidKeysetHashParameters<Curried extends boolean = false> = ActionParameters< | ||
Args, | ||
'sequencerInbox', | ||
Curried | ||
>; | ||
|
||
export type IsValidKeysetHashReturnType = ReadContractReturnType< | ||
SequencerInboxABI, | ||
'isValidKeysetHash' | ||
>; | ||
|
||
export async function isValidKeysetHash<TChain extends Chain | undefined>( | ||
client: PublicClient<Transport, TChain>, | ||
args: IsValidKeysetHashParameters, | ||
): Promise<IsValidKeysetHashReturnType> { | ||
return client.readContract({ | ||
abi: sequencerInbox.abi, | ||
functionName: 'isValidKeysetHash', | ||
address: args.sequencerInbox, | ||
args: [args.keysetHash], | ||
}); | ||
} |
This file contains hidden or 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,22 @@ | ||
import { Address } from 'viem'; | ||
import { Prettify } from './utils'; | ||
|
||
/** | ||
* Actions require contract address, but as part of decorators, the address might have been passed already to the decorator. | ||
* | ||
* If the address was passed to the decorator, it's now optional (we still allow overrides of the address per action). | ||
* If the action doesn't have any other parameters beside the contract address, then parameters can either be { contract: address } or void | ||
*/ | ||
export type ActionParameters<Args, ContractName extends string, Curried extends boolean> = Prettify< | ||
Curried extends false | ||
? Args & { [key in ContractName]: Address } | ||
: Args extends Record<string, never> | ||
? | ||
| { | ||
[key in ContractName]: Address; | ||
} | ||
| void | ||
spsjvc marked this conversation as resolved.
Show resolved
Hide resolved
|
||
: Args & { | ||
[key in ContractName]?: Address; | ||
} | ||
>; |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.