diff --git a/src/getNitroContractVersions.unit.test.ts b/src/getNitroContractVersions.unit.test.ts index a7557d31..46231b90 100644 --- a/src/getNitroContractVersions.unit.test.ts +++ b/src/getNitroContractVersions.unit.test.ts @@ -42,7 +42,7 @@ describe('getNitroContractVersions', () => { ); }); - it('throws when the JSON payload is missing top level fields', async () => { + it('throws when the result is missing top-level fields', async () => { vi.mocked(runChainVersioner).mockResolvedValueOnce({ versions: { Inbox: 'v1.1.1' }, } as never); @@ -52,7 +52,7 @@ describe('getNitroContractVersions', () => { ).rejects.toThrow('Failed to parse Nitro contract versions'); }); - it('accepts any JSON payload that includes versions and upgradeRecommendation', async () => { + it('accepts any result that includes versions and upgradeRecommendation', async () => { vi.mocked(runChainVersioner).mockResolvedValueOnce({ versions: 'not-validated', upgradeRecommendation: null, diff --git a/src/scripting/commands.ts b/src/scripting/commands.ts index cf783e81..7f53be63 100644 --- a/src/scripting/commands.ts +++ b/src/scripting/commands.ts @@ -130,6 +130,8 @@ import { schema as deployFullChainSchema, execute as deployFullChainExecute, } from './workflows/deployFullChain'; +import { getChainContractVersions } from '../getChainContractVersions'; +import { getChainContractVersionsSchema } from './schemas/getChainContractVersions'; import { contractRegistry } from './contractRegistry'; import { buildContractCommandSchema } from './contractCommandSchema'; @@ -366,4 +368,5 @@ export const commands: readonly Command[] = [ ), ...contractCommands, + command('getChainContractVersions', getChainContractVersionsSchema, getChainContractVersions), ]; diff --git a/src/scripting/schemaCoverage.ts b/src/scripting/schemaCoverage.ts index dcaf8c92..30280474 100644 --- a/src/scripting/schemaCoverage.ts +++ b/src/scripting/schemaCoverage.ts @@ -407,6 +407,9 @@ vi.mock('viem', async (importOriginal) => { }; }); +vi.mock('../getChainContractVersions', () => ({ + getChainContractVersions: _mocks.fn('getChainContractVersions'), +})); /** * A testable leaf of a schema -- a scalar field the harness will vary when * running coverage. diff --git a/src/scripting/schemas/getChainContractVersions.ts b/src/scripting/schemas/getChainContractVersions.ts new file mode 100644 index 00000000..bd839a76 --- /dev/null +++ b/src/scripting/schemas/getChainContractVersions.ts @@ -0,0 +1,17 @@ +import { z } from 'zod'; + +import { getChainContractVersions } from '../../getChainContractVersions'; +import { addressSchema } from './common'; + +export const getChainContractVersionsSchema = z + .object({ + inboxAddress: addressSchema, + parentChainRpc: z.url(), + }) + .strict() + .transform( + (input): Parameters => [ + input.inboxAddress, + input.parentChainRpc, + ], + ); diff --git a/src/scripting/schemas/index.ts b/src/scripting/schemas/index.ts index 5f73f2b1..6d016e29 100644 --- a/src/scripting/schemas/index.ts +++ b/src/scripting/schemas/index.ts @@ -81,3 +81,4 @@ export { isAllowListEnabledSchema, isAllowedSchema, } from './actions'; +export { getChainContractVersionsSchema } from './getChainContractVersions';