Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
80d1ee9
feat(scripting): add schema coverage testing utility
yahgwai Apr 9, 2026
3be84da
test(scripting): add schema coverage test for setValidKeysetPrepareTr…
yahgwai Apr 9, 2026
385fb95
refactor(scripting): export schema and execute from example scripts
yahgwai Apr 9, 2026
090c5a6
feat(scripting): add createRollup example to schema coverage tests
yahgwai Apr 9, 2026
27f1b03
refactor(scripting): require sdkFunction in assertSchemaCoverage
yahgwai Apr 9, 2026
99f2373
test(scripting): add transferOwnership example to schema coverage tests
yahgwai Apr 9, 2026
f0cf231
feat(scripting): add execute-level schema coverage testing
yahgwai Apr 9, 2026
0499f1d
feat(scripting): full pipeline schema coverage with side effect tracking
yahgwai Apr 9, 2026
436c0e3
refactor(scripting): simplify schema coverage mock registry
yahgwai Apr 9, 2026
5ce7cca
refactor(scripting): simplify assertSchemaCoverage signature
yahgwai Apr 9, 2026
6bdd3af
refactor(scripting): remove withTransform/withExecute helpers
yahgwai Apr 9, 2026
73bf40f
refactor(scripting): move schema.parse inside assertSchemaCoverage
yahgwai Apr 9, 2026
65d1236
refactor(scripting): type overrides against schema input type
yahgwai Apr 9, 2026
05658fb
test(scripting): add deployNewChain example to schema coverage tests
yahgwai Apr 9, 2026
30a2b2d
fix(scripting): fix TS error in deployNewChain override
yahgwai Apr 9, 2026
f7b2fe6
test(scripting): Stage 1 schema coverage -- 11 simple schemas
yahgwai Apr 9, 2026
9d1b559
test(scripting): Stage 2 schema coverage -- 11 medium schemas
yahgwai Apr 9, 2026
2bab9e5
test(scripting): Stage 3 schema coverage -- 11 complex schemas
yahgwai Apr 9, 2026
76d2d4c
refactor(scripting): move schemaCoverage files to src/scripting/
yahgwai Apr 9, 2026
766802f
chore(scripting): throw on unsupported zod types, add section comments
yahgwai Apr 9, 2026
2fec5bd
feat(scripting): export test utilities from testing.ts
yahgwai Apr 9, 2026
1a1bcce
refactor(scripting): move all mocks into testing.ts, eliminate duplic…
yahgwai Apr 10, 2026
5615961
test(scripting): add consumer test proving shared mocks work
yahgwai Apr 10, 2026
2de1609
refactor(scripting): merge schemaCoverage.ts into testing.ts
yahgwai Apr 10, 2026
38e759f
chore(scripting): rename testing.ts to schemaCoverage.ts, remove cons…
yahgwai Apr 10, 2026
29b9372
refactor(scripting): simplify schemaCoverage from review feedback
yahgwai Apr 10, 2026
b835160
docs(scripting): simplify assertSchemaCoverage jsdoc
yahgwai Apr 10, 2026
155c27d
test(scripting): add v2.1 and v3.2 variant coverage for discriminated…
yahgwai Apr 10, 2026
06c00f0
docs(scripting): document how to add custom mocks to the registry
yahgwai Apr 10, 2026
6d131b9
fix(scripting): address PR review findings
yahgwai Apr 10, 2026
d026af7
chore(scripting): fix formatting and lint
yahgwai Apr 10, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 11 additions & 5 deletions src/scripting/examples/createRollup.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
import { z } from 'zod';
import { runScript } from '../scriptUtils';
import { createRollupDefaultSchema } from '../schemas/createRollup';
import { paramsV3Dot2Schema } from '../schemas/createRollupPrepareDeploymentParamsConfig';
import { prepareChainConfigParamsSchema } from '../schemas/prepareChainConfig';
import { toPublicClient, toAccount } from '../viemTransforms';
import { toPublicClient, toAccount, findChain } from '../viemTransforms';
import { createRollupPrepareDeploymentParamsConfig } from '../../createRollupPrepareDeploymentParamsConfig';
import { prepareChainConfig } from '../../prepareChainConfig';
import { createRollup } from '../../createRollup';

const schema = createRollupDefaultSchema
export const schema = createRollupDefaultSchema
.extend({
params: createRollupDefaultSchema.shape.params.extend({
config: paramsV3Dot2Schema.extend({
Expand All @@ -16,7 +17,10 @@ const schema = createRollupDefaultSchema
}),
})
.transform((input) => {
const parentChainPublicClient = toPublicClient(input.parentChainRpcUrl);
const parentChainPublicClient = toPublicClient(
input.parentChainRpcUrl,
findChain(input.parentChainId),
);
const {
config: { chainConfig: chainConfigParams, ...restConfig },
...params
Expand All @@ -33,7 +37,9 @@ const schema = createRollupDefaultSchema
};
});

runScript(schema, async (input) => {
export const execute = async (input: z.output<typeof schema>) => {
const result = await createRollup(input);
return result.coreContracts;
});
};

runScript(schema, execute);
22 changes: 16 additions & 6 deletions src/scripting/examples/deployNewChain.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
import { z } from 'zod';
import { runScript } from '../scriptUtils';
import { createRollupDefaultSchema } from '../schemas/createRollup';
import { hexSchema, bigintSchema, addressSchema } from '../schemas/common';
import { paramsV3Dot2Schema } from '../schemas/createRollupPrepareDeploymentParamsConfig';
import { prepareChainConfigParamsSchema } from '../schemas/prepareChainConfig';
import { toPublicClient, toAccount, toWalletClient } from '../viemTransforms';
import { toPublicClient, toAccount, toWalletClient, findChain } from '../viemTransforms';
import { createRollupPrepareDeploymentParamsConfig } from '../../createRollupPrepareDeploymentParamsConfig';
import { prepareChainConfig } from '../../prepareChainConfig';
import { createRollup } from '../../createRollup';
import { zeroAddress } from 'viem';
import { setValidKeyset } from '../../setValidKeyset';
import { generateChainId } from '../../utils/generateChainId';

const schema = createRollupDefaultSchema
export const schema = createRollupDefaultSchema
.extend({
params: createRollupDefaultSchema.shape.params.extend({
config: paramsV3Dot2Schema.extend({
Expand All @@ -34,7 +35,10 @@ const schema = createRollupDefaultSchema
}
})
.transform((input) => {
const parentChainPublicClient = toPublicClient(input.parentChainRpcUrl);
const parentChainPublicClient = toPublicClient(
input.parentChainRpcUrl,
findChain(input.parentChainId),
);
const {
config: { chainConfig: chainConfigParams, ...restConfig },
keyset,
Expand All @@ -54,12 +58,16 @@ const schema = createRollupDefaultSchema
params: { config, ...params },
account: toAccount(input.privateKey),
parentChainPublicClient,
walletClient: toWalletClient(input.parentChainRpcUrl, input.privateKey),
walletClient: toWalletClient(
input.parentChainRpcUrl,
input.privateKey,
findChain(input.parentChainId),
),
keyset: isAnytrust ? keyset ?? DEFAULT_KEYSET : undefined,
};
});

runScript(schema, async (input) => {
export const execute = async (input: z.output<typeof schema>) => {
const { keyset, walletClient, ...createRollupArgs } = input;
const result = await createRollup(createRollupArgs);
const coreContracts = result.coreContracts;
Expand All @@ -74,4 +82,6 @@ runScript(schema, async (input) => {
}

return coreContracts;
});
};

runScript(schema, execute);
6 changes: 4 additions & 2 deletions src/scripting/examples/getValidators.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ import { runScript } from '../scriptUtils';
import { getValidatorsSchema, getValidatorsTransform } from '../schemas';
import { getValidators } from '../../getValidators';

const schema = getValidatorsSchema.transform(getValidatorsTransform);
export const schema = getValidatorsSchema.transform(getValidatorsTransform);

runScript(schema, async (args) => getValidators(...args));
export const execute = async (args: Parameters<typeof getValidators>) => getValidators(...args);

runScript(schema, execute);
8 changes: 6 additions & 2 deletions src/scripting/examples/setAnyTrustFastConfirmer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@ import { runScript } from '../scriptUtils';
import { setAnyTrustFastConfirmerSchema, setAnyTrustFastConfirmerTransform } from '../schemas';
import { setAnyTrustFastConfirmerPrepareTransactionRequest } from '../../setAnyTrustFastConfirmerPrepareTransactionRequest';

const schema = setAnyTrustFastConfirmerSchema.transform(setAnyTrustFastConfirmerTransform);
export const schema = setAnyTrustFastConfirmerSchema.transform(setAnyTrustFastConfirmerTransform);

runScript(schema, async (args) => setAnyTrustFastConfirmerPrepareTransactionRequest(...args));
export const execute = async (
args: Parameters<typeof setAnyTrustFastConfirmerPrepareTransactionRequest>,
) => setAnyTrustFastConfirmerPrepareTransactionRequest(...args);

runScript(schema, execute);
8 changes: 5 additions & 3 deletions src/scripting/examples/transferOwnership.ts
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ async function sendL2Message(
return txHash;
}

const schema = z
export const schema = z
.object({
rpcUrl: z.url(),
chainId: z.number(),
Expand All @@ -187,7 +187,7 @@ const schema = z
newOwnerAddress,
}));

runScript(schema, async (input) => {
export const execute = async (input: z.output<typeof schema>) => {
const {
publicClient,
account,
Expand Down Expand Up @@ -277,4 +277,6 @@ runScript(schema, async (input) => {
step5TxHash,
step6TxHash,
};
});
};

runScript(schema, execute);
Loading
Loading