Skip to content

Commit 8671916

Browse files
committed
Fix docs and contracts config section
1 parent 7c23c2c commit 8671916

File tree

3 files changed

+19
-17
lines changed

3 files changed

+19
-17
lines changed

README.md

+3-4
Original file line numberDiff line numberDiff line change
@@ -115,13 +115,12 @@ A record of chain configurations. The record key is the chain ID. For example:
115115

116116
##### `contracts`
117117

118-
A record of contract addresses used by Airseeker. If not specified, the addresses are loaded from
119-
[Airnode protocol v1](https://github.com/api3dao/airnode-protocol-v1).
118+
A record of contract addresses used by Airseeker.
120119

121120
###### Api3ServerV1 _(optional)_
122121

123-
The address of the Api3ServerV1 contract. If not specified, the address is loaded from the Airnode protocol v1
124-
repository.
122+
The address of the Api3ServerV1 contract. If not specified, the address is loaded from the
123+
[Airnode protocol v1](https://github.com/api3dao/airnode-protocol-v1) repository.
125124

126125
###### DapiDataRegistry
127126

src/config/schema.test.ts

+13-11
Original file line numberDiff line numberDiff line change
@@ -15,30 +15,28 @@ const gasSettings = {
1515
maxScalingMultiplier: 2,
1616
};
1717

18-
test('validates example config', async () => {
18+
test('validates example config', () => {
1919
const exampleConfig = JSON.parse(readFileSync(join(__dirname, '../../config/airseeker.example.json'), 'utf8'));
2020

2121
// The mnemonic is not interpolated (and thus invalid).
22-
await expect(configSchema.parseAsync(exampleConfig)).rejects.toStrictEqual(
22+
expect(() => configSchema.parse(exampleConfig)).toThrow(
2323
new ZodError([
24+
{
25+
code: 'custom',
26+
message: 'Invalid mnemonic',
27+
path: ['sponsorWalletMnemonic'],
28+
},
2429
{
2530
validation: 'url',
2631
code: 'invalid_string',
2732
message: 'Invalid url',
2833
path: ['chains', '31337', 'providers', 'hardhat', 'url'],
2934
},
30-
{
31-
code: 'custom',
32-
message: 'Invalid mnemonic',
33-
path: ['sponsorWalletMnemonic'],
34-
},
3535
])
3636
);
3737

3838
const exampleSecrets = dotenv.parse(readFileSync(join(__dirname, '../../config/secrets.example.env'), 'utf8'));
39-
await expect(configSchema.parseAsync(interpolateSecrets(exampleConfig, exampleSecrets))).resolves.toStrictEqual(
40-
expect.any(Object)
41-
);
39+
expect(configSchema.parse(interpolateSecrets(exampleConfig, exampleSecrets))).toStrictEqual(expect.any(Object));
4240
});
4341

4442
describe('chains schema', () => {
@@ -73,7 +71,7 @@ describe('chains schema', () => {
7371
});
7472
});
7573

76-
it('uses loads the contract address from airnode-protocol-v1', () => {
74+
it('uses the contract address from airnode-protocol-v1', () => {
7775
const chains = {
7876
'1': {
7977
providers: {
@@ -111,6 +109,9 @@ describe('chains schema', () => {
111109
url: 'http://localhost:8545',
112110
},
113111
},
112+
contracts: {
113+
DapiDataRegistry: '0xDD78254f864F97f65e2d86541BdaEf88A504D2B2',
114+
},
114115
__Temporary__DapiDataRegistry: {
115116
airnodeToSignedApiUrl: {},
116117
dataFeedIdToBeacons: {},
@@ -187,6 +188,7 @@ describe('chains schema', () => {
187188
'31337': {
188189
contracts: {
189190
Api3ServerV1: '0xe7f1725E7734CE288F8367e1Bb143E90bb3F0512',
191+
DapiDataRegistry: '0xDD78254f864F97f65e2d86541BdaEf88A504D2B2',
190192
},
191193
providers: {},
192194
__Temporary__DapiDataRegistry: {

src/config/schema.ts

+3-2
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ export const optionalChainSchema = z
6565
.object({
6666
providers: z.record(providerSchema), // The record key is the provider "nickname"
6767
__Temporary__DapiDataRegistry: temporaryDapiDataRegistrySchema,
68-
contracts: optionalContractsSchema.optional(),
68+
contracts: optionalContractsSchema,
6969
gasSettings: gasSettingsSchema,
7070
dataFeedUpdateInterval: z.number().positive(),
7171
dataFeedBatchSize: z.number().positive(),
@@ -109,7 +109,8 @@ export const chainsSchema = z
109109
Object.entries(chains).map(([chainId, chain]) => {
110110
const { contracts } = chain;
111111
const parsedContracts = contractsSchema.safeParse({
112-
Api3ServerV1: contracts?.Api3ServerV1 ?? references.Api3ServerV1[chainId],
112+
Api3ServerV1: contracts.Api3ServerV1 ?? references.Api3ServerV1[chainId],
113+
DapiDataRegistry: contracts.DapiDataRegistry,
113114
});
114115
if (!parsedContracts.success) {
115116
ctx.addIssue({

0 commit comments

Comments
 (0)