Skip to content

Commit 3f33084

Browse files
authored
Support chain configuration (#11)
* Integrate chain config * Add temporary DapiDataRegistry storage * Self review
1 parent 2dd7ec8 commit 3f33084

10 files changed

+921
-5
lines changed

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,5 @@ dist
99
node_modules
1010
coverage
1111
.DS_Store
12+
airseeker.json
13+
secrets.env

README.md

+88-3
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,93 @@ simplified and only works with signed APIs.
77

88
## Getting started
99

10-
To install the dependencies:
10+
1. `pnpm install` - To install the dependencies.
11+
2. `cp config/airseeker.example.json config/airseeker.json` - To create the configuration file.
12+
3. `cp config/secrets.example.env config/secrets.env` - To create the secrets file.
1113

12-
```sh
13-
pnpm install
14+
## Configuration
15+
16+
Airseeker needs two configuration files, `airseeker.json` and `secrets.env`. All expressions of a form `${SECRET_NAME}`
17+
are referring to values from secrets and are interpolated inside the `airseeker.json` at runtime. You are advised to put
18+
sensitive information inside secrets.
19+
20+
### `sponsorWalletMnemonic`
21+
22+
The mnemonic of the wallet used to derive sponsor wallets. Sponsor wallets are derived for each dAPI separately. It is
23+
recommended to interpolate this value from secrets. For example:
24+
25+
```jsonc
26+
// The mnemonic is interpolated from the "SPONSOR_WALLET_MNEMONIC" secret.
27+
"sponsorWalletMnemonic": "${SPONSOR_WALLET_MNEMONIC}",
28+
```
29+
30+
### `chains`
31+
32+
A record of chain configurations. The record key is the chain ID. For example:
33+
34+
```jsonc
35+
{
36+
// Defines a chain configuration with ID 1 (ETH mainnet).
37+
"1": {
38+
"providers": {
39+
"mainnet": {
40+
"url": "http://mainnet.com"
41+
}
42+
}
43+
}
44+
}
1445
```
46+
47+
#### `contracts` _(optional)_
48+
49+
A record of contract addresses used by Airseeker. If not specified, the addresses are loaded from
50+
[Airnode protocol v1](https://github.com/api3dao/airnode-protocol-v1).
51+
52+
##### Api3ServerV1 _(optional)_
53+
54+
The address of the Api3ServerV1 contract. If not specified, the address is loaded from the Airnode protocol v1
55+
repository.
56+
57+
#### `providers`
58+
59+
A record of providers. The record key is the provider name. Provider name is only used for internal purposes and to
60+
uniquely identify the provider for the given chain.
61+
62+
##### `providers[<NAME>]`
63+
64+
A provider configuration.
65+
66+
###### `url`
67+
68+
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

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
{
2+
"sponsorWalletMnemonic": "${SPONSOR_WALLET_MNEMONIC}",
3+
"chains": {
4+
"31337": {
5+
"contracts": {
6+
"Api3ServerV1": "0xe7f1725E7734CE288F8367e1Bb143E90bb3F0512"
7+
},
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+
},
22+
"providers": {
23+
"hardhat": {
24+
"url": "${HARDHAT_PROVIDER_URL}"
25+
}
26+
}
27+
}
28+
}
29+
}

config/secrets.example.env

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Secrets must NOT be quoted.
2+
#
3+
# The mnemonic is randomly generated. !!! USE ONLY FOR DEVELOPMENT PURPOSES !!!.
4+
SPONSOR_WALLET_MNEMONIC=wonder assume clip draw aisle issue angle holiday puzzle glass worry ball
5+
HARDHAT_PROVIDER_URL=http://127.0.0.1:8545/

package.json

+10-1
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,12 @@
1616
"prepare": "husky install",
1717
"prettier:check": "prettier --check \"./**/*.{js,ts,md,json}\"",
1818
"prettier:fix": "prettier --write \"./**/*.{js,ts,md,json}\"",
19-
"test": "jest --passWithNoTests",
19+
"test": "jest",
2020
"tsc": "tsc --project ."
2121
},
2222
"devDependencies": {
2323
"@types/jest": "^29.5.5",
24+
"@types/lodash": "^4.14.199",
2425
"@types/node": "^20.8.0",
2526
"@typescript-eslint/eslint-plugin": "^6.7.3",
2627
"@typescript-eslint/parser": "^6.7.3",
@@ -35,5 +36,13 @@
3536
"ts-jest": "^29.1.1",
3637
"ts-node": "^10.9.1",
3738
"typescript": "^5.2.2"
39+
},
40+
"dependencies": {
41+
"@api3/airnode-protocol-v1": "^2.10.0",
42+
"@api3/promise-utils": "^0.4.0",
43+
"dotenv": "^16.3.1",
44+
"ethers": "^5.7.2",
45+
"lodash": "^4.17.21",
46+
"zod": "^3.22.2"
3847
}
3948
}

0 commit comments

Comments
 (0)