-
Notifications
You must be signed in to change notification settings - Fork 45
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
5 changed files
with
215 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,49 @@ | ||
import { | ||
Chain, | ||
Hex, | ||
PrepareTransactionRequestParameters, | ||
PrepareTransactionRequestReturnType, | ||
PublicClient, | ||
Transport, | ||
encodeFunctionData, | ||
} from 'viem'; | ||
import { sequencerInbox } from '../contracts'; | ||
import { ActionParameters, WithAccount } from '../types/Actions'; | ||
import { Prettify } from '../types/utils'; | ||
|
||
export type InvalidateKeysetHashParameters<Curried extends boolean = false> = Prettify< | ||
WithAccount< | ||
ActionParameters< | ||
{ | ||
keysetHash: Hex; | ||
}, | ||
'sequencerInbox', | ||
Curried | ||
> | ||
> | ||
>; | ||
|
||
export type InvalidateKeysetHashReturnType = PrepareTransactionRequestReturnType; | ||
|
||
function sequencerInboxFunctionData({ keysetHash }: InvalidateKeysetHashParameters) { | ||
return encodeFunctionData({ | ||
abi: sequencerInbox.abi, | ||
functionName: 'invalidateKeysetHash', | ||
args: [keysetHash], | ||
}); | ||
} | ||
|
||
export async function invalidateKeysetHash<TChain extends Chain | undefined>( | ||
client: PublicClient<Transport, TChain>, | ||
args: InvalidateKeysetHashParameters, | ||
): Promise<InvalidateKeysetHashReturnType> { | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
import { | ||
Address, | ||
Chain, | ||
PrepareTransactionRequestParameters, | ||
PrepareTransactionRequestReturnType, | ||
PublicClient, | ||
Transport, | ||
encodeFunctionData, | ||
} from 'viem'; | ||
import { sequencerInbox } from '../contracts'; | ||
import { ActionParameters, WithAccount } from '../types/Actions'; | ||
import { Prettify } from '../types/utils'; | ||
|
||
type Args = { | ||
batchPoster: Address; | ||
}; | ||
|
||
export type SetIsBatchPosterParameters<Curried extends boolean = false> = Prettify< | ||
WithAccount<ActionParameters<Args, 'sequencerInbox', Curried>> | ||
>; | ||
|
||
export type SetIsBatchPosterReturnType = PrepareTransactionRequestReturnType; | ||
|
||
function sequencerInboxFunctionData({ | ||
batchPoster, | ||
enable, | ||
}: SetIsBatchPosterParameters & { enable: boolean }) { | ||
return encodeFunctionData({ | ||
abi: sequencerInbox.abi, | ||
functionName: 'setIsBatchPoster', | ||
args: [batchPoster, enable], | ||
}); | ||
} | ||
|
||
async function setIsBatchPoster<TChain extends Chain | undefined>( | ||
client: PublicClient<Transport, TChain>, | ||
args: SetIsBatchPosterParameters & { enable: boolean }, | ||
): Promise<SetIsBatchPosterReturnType> { | ||
const data = sequencerInboxFunctionData(args); | ||
return client.prepareTransactionRequest({ | ||
to: args.sequencerInbox, | ||
value: BigInt(0), | ||
chain: client.chain, | ||
data, | ||
account: args.account, | ||
} satisfies PrepareTransactionRequestParameters); | ||
} | ||
|
||
export async function enableBatchPoster<TChain extends Chain | undefined>( | ||
client: PublicClient<Transport, TChain>, | ||
args: SetIsBatchPosterParameters, | ||
): Promise<SetIsBatchPosterReturnType> { | ||
return setIsBatchPoster(client, { | ||
...args, | ||
enable: true, | ||
}); | ||
} | ||
|
||
export async function disableBatchPoster<TChain extends Chain | undefined>( | ||
client: PublicClient<Transport, TChain>, | ||
args: SetIsBatchPosterParameters, | ||
): Promise<SetIsBatchPosterReturnType> { | ||
return setIsBatchPoster(client, { | ||
...args, | ||
enable: false, | ||
}); | ||
} |
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,49 @@ | ||
import { | ||
Chain, | ||
Hex, | ||
PrepareTransactionRequestParameters, | ||
PrepareTransactionRequestReturnType, | ||
PublicClient, | ||
Transport, | ||
encodeFunctionData, | ||
} from 'viem'; | ||
import { sequencerInbox } from '../contracts'; | ||
import { ActionParameters, WithAccount } from '../types/Actions'; | ||
import { Prettify } from '../types/utils'; | ||
|
||
export type SetKeysetParameters<Curried extends boolean = false> = Prettify< | ||
WithAccount< | ||
ActionParameters< | ||
{ | ||
keyset: Hex; | ||
}, | ||
'sequencerInbox', | ||
Curried | ||
> | ||
> | ||
>; | ||
|
||
export type SetKeysetReturnType = PrepareTransactionRequestReturnType; | ||
|
||
function sequencerInboxFunctionData({ keyset }: SetKeysetParameters) { | ||
return encodeFunctionData({ | ||
abi: sequencerInbox.abi, | ||
functionName: 'setValidKeyset', | ||
args: [keyset], | ||
}); | ||
} | ||
|
||
export async function setKeyset<TChain extends Chain | undefined>( | ||
client: PublicClient<Transport, TChain>, | ||
args: SetKeysetParameters, | ||
): Promise<SetKeysetReturnType> { | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import { | ||
Chain, | ||
PrepareTransactionRequestParameters, | ||
PrepareTransactionRequestReturnType, | ||
PublicClient, | ||
Transport, | ||
encodeFunctionData, | ||
} from 'viem'; | ||
import { sequencerInbox } from '../contracts'; | ||
import { ActionParameters, WithAccount } from '../types/Actions'; | ||
import { Prettify } from '../types/utils'; | ||
|
||
type Args = { | ||
delayBlocks: bigint; | ||
futureBlocks: bigint; | ||
delaySeconds: bigint; | ||
futureSeconds: bigint; | ||
}; | ||
export type SetMaxTimeVariationParameters<Curried extends boolean = false> = Prettify< | ||
WithAccount<ActionParameters<Args, 'sequencerInbox', Curried>> | ||
>; | ||
|
||
export type SetMaxTimeVariationReturnType = PrepareTransactionRequestReturnType; | ||
|
||
function sequencerInboxFunctionData(args: SetMaxTimeVariationParameters) { | ||
return encodeFunctionData({ | ||
abi: sequencerInbox.abi, | ||
functionName: 'setMaxTimeVariation', | ||
args: [args], | ||
}); | ||
} | ||
|
||
export async function setMaxTimeVariation<TChain extends Chain | undefined>( | ||
client: PublicClient<Transport, TChain>, | ||
args: SetMaxTimeVariationParameters, | ||
): Promise<SetMaxTimeVariationReturnType> { | ||
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