Skip to content

Commit

Permalink
Fetch rollupAddress from sequencerInbox in setters
Browse files Browse the repository at this point in the history
  • Loading branch information
chrstph-dvx committed Jul 10, 2024
1 parent a5dc412 commit f3b0075
Show file tree
Hide file tree
Showing 6 changed files with 39 additions and 51 deletions.
17 changes: 5 additions & 12 deletions src/actions/setConfirmPeriodBlocks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,12 @@ import {
encodeFunctionData,
} from 'viem';
import { rollupAdminLogic } from '../contracts';
import { ActionParameters, WithAccount } from '../types/Actions';
import { WithAccount, WithContractAddress } from '../types/Actions';
import { Prettify } from '../types/utils';
import { getRollupAddress } from '../getRollupAddress';

export type SetConfirmPeriodBlocksParameters<Curried extends boolean = false> = Prettify<
WithAccount<
ActionParameters<
{
newPeriod: bigint;
},
'rollupAdminLogic',
Curried
>
>
WithAccount<WithContractAddress<{ newPeriod: bigint }, 'rollupAdminLogic', Curried>>
>;

export type SetConfirmPeriodBlocksReturnType = PrepareTransactionRequestReturnType;
Expand All @@ -37,9 +30,9 @@ export async function setConfirmPeriodBlocks<TChain extends Chain | undefined>(
args: SetConfirmPeriodBlocksParameters,
): Promise<SetConfirmPeriodBlocksReturnType> {
const data = rollupAdminLogicFunctionData(args);

const rollupAdminLogicAddresss = await getRollupAddress(client, args);
return client.prepareTransactionRequest({
to: args.rollupAdminLogic,
to: rollupAdminLogicAddresss,
value: BigInt(0),
chain: client.chain,
data,
Expand Down
17 changes: 5 additions & 12 deletions src/actions/setExtraChallengeTimeBlocks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,12 @@ import {
encodeFunctionData,
} from 'viem';
import { rollupAdminLogic } from '../contracts';
import { ActionParameters, WithAccount } from '../types/Actions';
import { WithAccount, WithContractAddress } from '../types/Actions';
import { Prettify } from '../types/utils';
import { getRollupAddress } from '../getRollupAddress';

export type SetExtraChallengeTimeBlocksParameters<Curried extends boolean = false> = Prettify<
WithAccount<
ActionParameters<
{
newExtraTimeBlocks: bigint;
},
'rollupAdminLogic',
Curried
>
>
WithAccount<WithContractAddress<{ newExtraTimeBlocks: bigint }, 'rollupAdminLogic', Curried>>
>;

export type SetExtraChallengeTimeBlocksReturnType = PrepareTransactionRequestReturnType;
Expand All @@ -39,9 +32,9 @@ export async function setExtraChallengeTimeBlocks<TChain extends Chain | undefin
args: SetExtraChallengeTimeBlocksParameters,
): Promise<SetExtraChallengeTimeBlocksReturnType> {
const data = rollupAdminLogicFunctionData(args);

const rollupAdminLogicAddresss = await getRollupAddress(client, args);
return client.prepareTransactionRequest({
to: args.rollupAdminLogic,
to: rollupAdminLogicAddresss,
value: BigInt(0),
chain: client.chain,
data,
Expand Down
17 changes: 5 additions & 12 deletions src/actions/setMinimumAssertionPeriod.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,12 @@ import {
encodeFunctionData,
} from 'viem';
import { rollupAdminLogic } from '../contracts';
import { ActionParameters, WithAccount } from '../types/Actions';
import { WithAccount, WithContractAddress } from '../types/Actions';
import { Prettify } from '../types/utils';
import { getRollupAddress } from '../getRollupAddress';

export type SetMinimumAssertionPeriodParameters<Curried extends boolean = false> = Prettify<
WithAccount<
ActionParameters<
{
newPeriod: bigint;
},
'rollupAdminLogic',
Curried
>
>
WithAccount<WithContractAddress<{ newPeriod: bigint }, 'rollupAdminLogic', Curried>>
>;

export type SetMinimumAssertionPeriodReturnType = PrepareTransactionRequestReturnType;
Expand All @@ -37,9 +30,9 @@ export async function setMinimumAssertionPeriod<TChain extends Chain | undefined
args: SetMinimumAssertionPeriodParameters,
): Promise<SetMinimumAssertionPeriodReturnType> {
const data = rollupAdminLogicFunctionData(args);

const rollupAdminLogicAddresss = await getRollupAddress(client, args);
return client.prepareTransactionRequest({
to: args.rollupAdminLogic,
to: rollupAdminLogicAddresss,
value: BigInt(0),
chain: client.chain,
data,
Expand Down
22 changes: 14 additions & 8 deletions src/actions/setValidator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,21 @@ import {
encodeFunctionData,
} from 'viem';
import { rollupAdminLogic } from '../contracts';
import { ActionParameters, WithAccount } from '../types/Actions';
import { WithAccount, WithContractAddress } from '../types/Actions';
import { Prettify } from '../types/utils';

type Args = {
add: Address[];
remove: Address[];
};
import { getRollupAddress } from '../getRollupAddress';

export type SetIsValidatorParameters<Curried extends boolean = false> = Prettify<
WithAccount<ActionParameters<Args, 'rollupAdminLogic', Curried>>
WithAccount<
WithContractAddress<
{
add: Address[];
remove: Address[];
},
'rollupAdminLogic',
Curried
>
>
>;

export type SetIsValidatorReturnType = PrepareTransactionRequestReturnType;
Expand All @@ -37,8 +42,9 @@ export async function setValidators<TChain extends Chain | undefined>(
args: SetIsValidatorParameters,
): Promise<SetIsValidatorReturnType> {
const data = rollupAdminLogicFunctionData(args);
const rollupAdminLogicAddresss = await getRollupAddress(client, args);
return client.prepareTransactionRequest({
to: args.rollupAdminLogic,
to: rollupAdminLogicAddresss,
value: BigInt(0),
chain: client.chain,
data,
Expand Down
8 changes: 5 additions & 3 deletions src/actions/setValidatorWhitelistDisabled.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,12 @@ import {
encodeFunctionData,
} from 'viem';
import { rollupAdminLogic } from '../contracts';
import { ActionParameters, WithAccount } from '../types/Actions';
import { WithAccount, WithContractAddress } from '../types/Actions';
import { Prettify } from '../types/utils';
import { getRollupAddress } from '../getRollupAddress';

export type SetValidatorWhitelistDisabledParameters<Curried extends boolean = false> = Prettify<
WithAccount<ActionParameters<{}, 'rollupAdminLogic', Curried>>
WithAccount<WithContractAddress<{}, 'rollupAdminLogic', Curried>>
>;

export type SetValidatorWhitelistDisabledReturnType = PrepareTransactionRequestReturnType;
Expand All @@ -31,8 +32,9 @@ async function setValidatorWhitelistDisabled<TChain extends Chain | undefined>(
args: SetValidatorWhitelistDisabledParameters & { enable: boolean },
): Promise<SetValidatorWhitelistDisabledReturnType> {
const data = rollupAdminLogicFunctionData(args);
const rollupAdminLogicAddresss = await getRollupAddress(client, args);
return client.prepareTransactionRequest({
to: args.rollupAdminLogic,
to: rollupAdminLogicAddresss,
value: BigInt(0),
chain: client.chain,
data,
Expand Down
9 changes: 5 additions & 4 deletions src/actions/setWasmModuleRoot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,13 @@ import {
encodeFunctionData,
} from 'viem';
import { rollupAdminLogic } from '../contracts';
import { ActionParameters, WithAccount } from '../types/Actions';
import { WithAccount, WithContractAddress } from '../types/Actions';
import { Prettify } from '../types/utils';
import { getRollupAddress } from '../getRollupAddress';

export type SetWasmModuleRootParameters<Curried extends boolean = false> = Prettify<
WithAccount<
ActionParameters<
WithContractAddress<
{
newWasmModuleRoot: Hex;
},
Expand All @@ -38,9 +39,9 @@ export async function setWasmModuleRoot<TChain extends Chain | undefined>(
args: SetWasmModuleRootParameters,
): Promise<SetWasmModuleRootReturnType> {
const data = rollupAdminLogicFunctionData(args);

const rollupAdminLogicAddresss = await getRollupAddress(client, args);
return client.prepareTransactionRequest({
to: args.rollupAdminLogic,
to: rollupAdminLogicAddresss,
value: BigInt(0),
chain: client.chain,
data,
Expand Down

0 comments on commit f3b0075

Please sign in to comment.