Skip to content

Commit

Permalink
Prefix setters with prepare
Browse files Browse the repository at this point in the history
  • Loading branch information
chrstph-dvx committed Aug 19, 2024
1 parent 4ca765e commit 8bb0b9b
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 33 deletions.
8 changes: 4 additions & 4 deletions src/actions/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
export * from './getMaxTimeVariation';
export * from './isBatchPoster';
export * from './isValidKeysetHash';
export * from './invalidateKeysetHash';
export * from './setIsbatchPoster';
export * from './setKeyset';
export * from './setMaxTimeVariation';
export * from './prepareInvalidateKeysetHash';
export * from './prepareSetIsbatchPoster';
export * from './prepareSetKeyset';
export * from './prepareSetMaxTimeVariation';
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { sequencerInboxABI } from '../contracts/SequencerInbox';
import { ActionParameters, WithAccount } from '../types/Actions';
import { Prettify } from '../types/utils';

export type InvalidateKeysetHashParameters<Curried extends boolean = false> = Prettify<
export type PrepareInvalidateKeysetHashParameters<Curried extends boolean = false> = Prettify<
WithAccount<
ActionParameters<
{
Expand All @@ -23,20 +23,20 @@ export type InvalidateKeysetHashParameters<Curried extends boolean = false> = Pr
>
>;

export type InvalidateKeysetHashReturnType = PrepareTransactionRequestReturnType;
export type PrepareInvalidateKeysetHashReturnType = PrepareTransactionRequestReturnType;

function sequencerInboxFunctionData({ keysetHash }: InvalidateKeysetHashParameters) {
function sequencerInboxFunctionData({ keysetHash }: PrepareInvalidateKeysetHashParameters) {
return encodeFunctionData({
abi: sequencerInboxABI,
functionName: 'invalidateKeysetHash',
args: [keysetHash],
});
}

export async function invalidateKeysetHash<TChain extends Chain | undefined>(
export async function prepareInvalidateKeysetHash<TChain extends Chain | undefined>(
client: PublicClient<Transport, TChain>,
args: InvalidateKeysetHashParameters,
): Promise<InvalidateKeysetHashReturnType> {
args: PrepareInvalidateKeysetHashParameters,
): Promise<PrepareInvalidateKeysetHashReturnType> {
const data = sequencerInboxFunctionData(args);

return client.prepareTransactionRequest({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,16 @@ type Args = {
batchPoster: Address;
};

export type SetIsBatchPosterParameters<Curried extends boolean = false> = Prettify<
export type PrepareSetIsBatchPosterParameters<Curried extends boolean = false> = Prettify<
WithUpgradeExecutor<WithAccount<ActionParameters<Args, 'sequencerInbox', Curried>>>
>;

export type SetIsBatchPosterReturnType = PrepareTransactionRequestReturnTypeWithChainId;
export type PrepareSetIsBatchPosterReturnType = PrepareTransactionRequestReturnTypeWithChainId;

async function setIsBatchPoster<TChain extends Chain | undefined>(
async function prepareSetIsBatchPoster<TChain extends Chain | undefined>(
client: PublicClient<Transport, TChain>,
params: SetIsBatchPosterParameters & { enable: boolean },
): Promise<SetIsBatchPosterReturnType> {
params: PrepareSetIsBatchPosterParameters & { enable: boolean },
): Promise<PrepareSetIsBatchPosterReturnType> {
const validatedPublicClient = validateParentChainPublicClient(client);
const { account, upgradeExecutor, sequencerInbox: sequencerInboxAddress, ...args } = params;

Expand All @@ -42,21 +42,21 @@ async function setIsBatchPoster<TChain extends Chain | undefined>(
return { ...request, chainId: validatedPublicClient.chain.id };
}

export async function enableBatchPoster<TChain extends Chain | undefined>(
export async function prepareEnableBatchPoster<TChain extends Chain | undefined>(
client: PublicClient<Transport, TChain>,
args: SetIsBatchPosterParameters,
): Promise<SetIsBatchPosterReturnType> {
return setIsBatchPoster(client, {
args: PrepareSetIsBatchPosterParameters,
): Promise<PrepareSetIsBatchPosterReturnType> {
return prepareSetIsBatchPoster(client, {
...args,
enable: true,
});
}

export async function disableBatchPoster<TChain extends Chain | undefined>(
export async function prepareDisableBatchPoster<TChain extends Chain | undefined>(
client: PublicClient<Transport, TChain>,
args: SetIsBatchPosterParameters,
): Promise<SetIsBatchPosterReturnType> {
return setIsBatchPoster(client, {
args: PrepareSetIsBatchPosterParameters,
): Promise<PrepareSetIsBatchPosterReturnType> {
return prepareSetIsBatchPoster(client, {
...args,
enable: false,
});
Expand Down
10 changes: 5 additions & 5 deletions src/actions/setKeyset.ts → src/actions/prepareSetKeyset.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { Prettify } from '../types/utils';
import { validateParentChainPublicClient } from '../types/ParentChain';
import { withUpgradeExecutor } from '../withUpgradeExecutor';

export type SetKeysetParameters<Curried extends boolean = false> = Prettify<
export type PrepareSetKeysetParameters<Curried extends boolean = false> = Prettify<
WithUpgradeExecutor<
WithAccount<
ActionParameters<
Expand All @@ -24,12 +24,12 @@ export type SetKeysetParameters<Curried extends boolean = false> = Prettify<
>
>;

export type SetKeysetReturnType = PrepareTransactionRequestReturnTypeWithChainId;
export type PrepareSetKeysetReturnType = PrepareTransactionRequestReturnTypeWithChainId;

export async function setKeyset<TChain extends Chain | undefined>(
export async function prepareSetKeyset<TChain extends Chain | undefined>(
client: PublicClient<Transport, TChain>,
params: SetKeysetParameters,
): Promise<SetKeysetReturnType> {
params: PrepareSetKeysetParameters,
): Promise<PrepareSetKeysetReturnType> {
const validatedPublicClient = validateParentChainPublicClient(client);
const { account, upgradeExecutor, sequencerInbox: sequencerInboxAddress, ...args } = params;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,16 @@ type Args = {
delaySeconds: bigint;
futureSeconds: bigint;
};
export type SetMaxTimeVariationParameters<Curried extends boolean = false> = Prettify<
export type PrepareSetMaxTimeVariationParameters<Curried extends boolean = false> = Prettify<
WithUpgradeExecutor<WithAccount<ActionParameters<Args, 'sequencerInbox', Curried>>>
>;

export type SetMaxTimeVariationReturnType = PrepareTransactionRequestReturnTypeWithChainId;
export type PrepareSetMaxTimeVariationReturnType = PrepareTransactionRequestReturnTypeWithChainId;

export async function setMaxTimeVariation<TChain extends Chain | undefined>(
export async function prepareSetMaxTimeVariation<TChain extends Chain | undefined>(
client: PublicClient<Transport, TChain>,
params: SetMaxTimeVariationParameters,
): Promise<SetMaxTimeVariationReturnType> {
params: PrepareSetMaxTimeVariationParameters,
): Promise<PrepareSetMaxTimeVariationReturnType> {
const validatedPublicClient = validateParentChainPublicClient(client);
const { account, upgradeExecutor, sequencerInbox: sequencerInboxAddress, ...args } = params;

Expand Down

0 comments on commit 8bb0b9b

Please sign in to comment.