Skip to content

Commit 49eb1a9

Browse files
committed
Add temporary DapiDataRegistry storage
1 parent eda76f4 commit 49eb1a9

File tree

4 files changed

+105
-14
lines changed

4 files changed

+105
-14
lines changed

README.md

+32-1
Original file line numberDiff line numberDiff line change
@@ -59,10 +59,41 @@ repository.
5959
A record of providers. The record key is the provider name. Provider name is only used for internal purposes and to
6060
uniquely identify the provider for the given chain.
6161

62-
##### `providers[<name>]`
62+
##### `providers[<NAME>]`
6363

6464
A provider configuration.
6565

6666
###### `url`
6767

6868
The URL of the provider.
69+
70+
#### `__Temporary__DapiDataRegistry`
71+
72+
The data needed to make the requests to signed API. This data will in the future be stored on-chain in a
73+
`DapiDataRegistry` contract. For the time being, they are statically defined in the configuration file.
74+
75+
##### `airnodeToSignedApiUrl`
76+
77+
A mapping from Airnode address to signed API URL. When data from particular beacon is needed a request is made to the
78+
signed API corresponding to the beacon address.
79+
80+
##### `dataFeedIdToBeacons`
81+
82+
A mapping from data feed ID to a list of beacon data.
83+
84+
##### `dataFeedIdToBeacons<DATA_FEED_ID>`
85+
86+
A single element array for a beacon data. If the data feed is a beacon set, the array contains the data for all the
87+
beacons in the beacon set (in correct order).
88+
89+
###### `dataFeedIdToBeacons<DATA_FEED_ID>[n]`
90+
91+
A beacon data.
92+
93+
`airnode`
94+
95+
The Airnode address of the beacon.
96+
97+
`templateId`
98+
99+
The template ID of the beacon.

config/airseeker.example.json

+14
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,20 @@
55
"contracts": {
66
"Api3ServerV1": "0xe7f1725E7734CE288F8367e1Bb143E90bb3F0512"
77
},
8+
"__Temporary__DapiDataRegistry": {
9+
"airnodeToSignedApiUrl": {
10+
"0xbF3137b0a7574563a23a8fC8badC6537F98197CC": "http://127.0.0.1:8090/"
11+
},
12+
"dataFeedIdToBeacons": {
13+
"0xebba8507d616ed80766292d200a3598fdba656d9938cecc392765d4a284a69a4": [
14+
{
15+
"airnode": "0xbF3137b0a7574563a23a8fC8badC6537F98197CC",
16+
"templateId": "0xcc35bd1800c06c12856a87311dd95bfcbb3add875844021d59a929d79f3c99bd"
17+
}
18+
]
19+
},
20+
"activeDapiNames": ["ETH/USD"]
21+
},
822
"providers": {
923
"hardhat": {
1024
"url": "${HARDHAT_PROVIDER_URL}"

src/config/schema.test.ts

+20
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,11 @@ describe('chains schema', () => {
4343
url: 'http://localhost:8545',
4444
},
4545
},
46+
__Temporary__DapiDataRegistry: {
47+
airnodeToSignedApiUrl: {},
48+
dataFeedIdToBeacons: {},
49+
activeDapiNames: [],
50+
},
4651
},
4752
};
4853

@@ -61,6 +66,11 @@ describe('chains schema', () => {
6166
url: 'http://mainnet-url.com',
6267
},
6368
},
69+
__Temporary__DapiDataRegistry: {
70+
airnodeToSignedApiUrl: {},
71+
dataFeedIdToBeacons: {},
72+
activeDapiNames: [],
73+
},
6474
},
6575
};
6676

@@ -79,6 +89,11 @@ describe('chains schema', () => {
7989
url: 'http://localhost:8545',
8090
},
8191
},
92+
__Temporary__DapiDataRegistry: {
93+
airnodeToSignedApiUrl: {},
94+
dataFeedIdToBeacons: {},
95+
activeDapiNames: [],
96+
},
8297
},
8398
};
8499

@@ -104,6 +119,11 @@ describe('chains schema', () => {
104119
url: 'http://localhost:8545',
105120
},
106121
},
122+
__Temporary__DapiDataRegistry: {
123+
airnodeToSignedApiUrl: {},
124+
dataFeedIdToBeacons: {},
125+
activeDapiNames: [],
126+
},
107127
},
108128
};
109129

src/config/schema.ts

+39-13
Original file line numberDiff line numberDiff line change
@@ -6,36 +6,62 @@ export const evmAddressSchema = z.string().regex(/^0x[a-fA-F0-9]{40}$/, 'Must be
66

77
export const evmIdSchema = z.string().regex(/^0x[a-fA-F0-9]{64}$/, 'Must be a valid EVM hash');
88

9-
export const providerSchema = z.object({
10-
url: z.string().url(),
11-
});
9+
export const providerSchema = z
10+
.object({
11+
url: z.string().url(),
12+
})
13+
.strict();
1214

1315
export type Provider = z.infer<typeof providerSchema>;
1416

1517
// Contracts are optional. If unspecified, they will be loaded from "airnode-protocol-v1" or error out during
1618
// validation. We need a chain ID from parent schema to load the contracts.
17-
export const optionalContractsSchema = z.object({
18-
Api3ServerV1: evmAddressSchema.optional(),
19-
});
19+
export const optionalContractsSchema = z
20+
.object({
21+
Api3ServerV1: evmAddressSchema.optional(),
22+
})
23+
.strict();
2024

2125
// The contracts are guaraneteed to exist after the configuration is passed, but the inferred type would be optional so
2226
// we create a new schema just to infer the type correctly.
2327
const contractsSchema = optionalContractsSchema.required();
2428

2529
export type Contracts = z.infer<typeof contractsSchema>;
2630

31+
export const temporaryBeaconDataSchema = z.object({
32+
airnode: evmAddressSchema,
33+
templateId: evmIdSchema,
34+
});
35+
36+
export type TemporaryBeaconData = z.infer<typeof temporaryBeaconDataSchema>;
37+
38+
// The DapiDataRegistry should live on-chain and Airseeker will query the contract for information. However, the
39+
// contract does not exist as of now, so the data is hardcoded.
40+
export const temporaryDapiDataRegistrySchema = z.object({
41+
airnodeToSignedApiUrl: z.record(z.string()),
42+
dataFeedIdToBeacons: z.record(z.array(temporaryBeaconDataSchema)),
43+
activeDapiNames: z.array(z.string()),
44+
});
45+
46+
export type TemporaryDapiDataRegistry = z.infer<typeof temporaryDapiDataRegistrySchema>;
47+
2748
// Contracts are optional. If unspecified, they will be loaded from "airnode-protocol-v1" or error out during
2849
// validation. We need a chain ID from parent schema to load the contracts.
29-
export const optionalChainSchema = z.object({
30-
providers: z.record(providerSchema), // The record key is the provider "nickname"
31-
contracts: optionalContractsSchema.optional(),
32-
});
50+
export const optionalChainSchema = z
51+
.object({
52+
providers: z.record(providerSchema), // The record key is the provider "nickname"
53+
__Temporary__DapiDataRegistry: temporaryDapiDataRegistrySchema,
54+
contracts: optionalContractsSchema.optional(),
55+
})
56+
.strict();
3357

3458
// The contracts are guaraneteed to exist after the configuration is passed, but the inferred type would be optional so
3559
// we create a new schema just to infer the type correctly.
36-
const chainSchema = optionalChainSchema.extend({
37-
contracts: contractsSchema,
38-
});
60+
const chainSchema = optionalChainSchema
61+
.extend({
62+
contracts: contractsSchema,
63+
})
64+
.strict();
3965

4066
export type Chain = z.infer<typeof chainSchema>;
4167

0 commit comments

Comments
 (0)