diff --git a/README.md b/README.md index ec0b03cb..25f81c71 100644 --- a/README.md +++ b/README.md @@ -115,13 +115,12 @@ A record of chain configurations. The record key is the chain ID. For example: ##### `contracts` -A record of contract addresses used by Airseeker. If not specified, the addresses are loaded from -[Airnode protocol v1](https://github.com/api3dao/airnode-protocol-v1). +A record of contract addresses used by Airseeker. ###### Api3ServerV1 _(optional)_ -The address of the Api3ServerV1 contract. If not specified, the address is loaded from the Airnode protocol v1 -repository. +The address of the Api3ServerV1 contract. If not specified, the address is loaded from the +[Airnode protocol v1](https://github.com/api3dao/airnode-protocol-v1) repository. ###### DapiDataRegistry diff --git a/src/config/schema.test.ts b/src/config/schema.test.ts index 332b7220..8dd6dfe2 100644 --- a/src/config/schema.test.ts +++ b/src/config/schema.test.ts @@ -15,30 +15,28 @@ const gasSettings = { maxScalingMultiplier: 2, }; -test('validates example config', async () => { +test('validates example config', () => { const exampleConfig = JSON.parse(readFileSync(join(__dirname, '../../config/airseeker.example.json'), 'utf8')); // The mnemonic is not interpolated (and thus invalid). - await expect(configSchema.parseAsync(exampleConfig)).rejects.toStrictEqual( + expect(() => configSchema.parse(exampleConfig)).toThrow( new ZodError([ + { + code: 'custom', + message: 'Invalid mnemonic', + path: ['sponsorWalletMnemonic'], + }, { validation: 'url', code: 'invalid_string', message: 'Invalid url', path: ['chains', '31337', 'providers', 'hardhat', 'url'], }, - { - code: 'custom', - message: 'Invalid mnemonic', - path: ['sponsorWalletMnemonic'], - }, ]) ); const exampleSecrets = dotenv.parse(readFileSync(join(__dirname, '../../config/secrets.example.env'), 'utf8')); - await expect(configSchema.parseAsync(interpolateSecrets(exampleConfig, exampleSecrets))).resolves.toStrictEqual( - expect.any(Object) - ); + expect(configSchema.parse(interpolateSecrets(exampleConfig, exampleSecrets))).toStrictEqual(expect.any(Object)); }); describe('chains schema', () => { @@ -73,7 +71,7 @@ describe('chains schema', () => { }); }); - it('uses loads the contract address from airnode-protocol-v1', () => { + it('uses the contract address from airnode-protocol-v1', () => { const chains = { '1': { providers: { @@ -111,6 +109,9 @@ describe('chains schema', () => { url: 'http://localhost:8545', }, }, + contracts: { + DapiDataRegistry: '0xDD78254f864F97f65e2d86541BdaEf88A504D2B2', + }, __Temporary__DapiDataRegistry: { airnodeToSignedApiUrl: {}, dataFeedIdToBeacons: {}, @@ -187,6 +188,7 @@ describe('chains schema', () => { '31337': { contracts: { Api3ServerV1: '0xe7f1725E7734CE288F8367e1Bb143E90bb3F0512', + DapiDataRegistry: '0xDD78254f864F97f65e2d86541BdaEf88A504D2B2', }, providers: {}, __Temporary__DapiDataRegistry: { diff --git a/src/config/schema.ts b/src/config/schema.ts index 2f65dfc2..de8333f9 100644 --- a/src/config/schema.ts +++ b/src/config/schema.ts @@ -65,7 +65,7 @@ export const optionalChainSchema = z .object({ providers: z.record(providerSchema), // The record key is the provider "nickname" __Temporary__DapiDataRegistry: temporaryDapiDataRegistrySchema, - contracts: optionalContractsSchema.optional(), + contracts: optionalContractsSchema, gasSettings: gasSettingsSchema, dataFeedUpdateInterval: z.number().positive(), dataFeedBatchSize: z.number().positive(), @@ -109,7 +109,8 @@ export const chainsSchema = z Object.entries(chains).map(([chainId, chain]) => { const { contracts } = chain; const parsedContracts = contractsSchema.safeParse({ - Api3ServerV1: contracts?.Api3ServerV1 ?? references.Api3ServerV1[chainId], + Api3ServerV1: contracts.Api3ServerV1 ?? references.Api3ServerV1[chainId], + DapiDataRegistry: contracts.DapiDataRegistry, }); if (!parsedContracts.success) { ctx.addIssue({