Skip to content

Commit

Permalink
Support chain configuration (#11)
Browse files Browse the repository at this point in the history
* Integrate chain config

* Add temporary DapiDataRegistry storage

* Self review
  • Loading branch information
Siegrift authored Oct 4, 2023
1 parent 2dd7ec8 commit 3f33084
Show file tree
Hide file tree
Showing 10 changed files with 921 additions and 5 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,5 @@ dist
node_modules
coverage
.DS_Store
airseeker.json
secrets.env
91 changes: 88 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,93 @@ simplified and only works with signed APIs.

## Getting started

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

```sh
pnpm install
## Configuration

Airseeker needs two configuration files, `airseeker.json` and `secrets.env`. All expressions of a form `${SECRET_NAME}`
are referring to values from secrets and are interpolated inside the `airseeker.json` at runtime. You are advised to put
sensitive information inside secrets.

### `sponsorWalletMnemonic`

The mnemonic of the wallet used to derive sponsor wallets. Sponsor wallets are derived for each dAPI separately. It is
recommended to interpolate this value from secrets. For example:

```jsonc
// The mnemonic is interpolated from the "SPONSOR_WALLET_MNEMONIC" secret.
"sponsorWalletMnemonic": "${SPONSOR_WALLET_MNEMONIC}",
```

### `chains`

A record of chain configurations. The record key is the chain ID. For example:

```jsonc
{
// Defines a chain configuration with ID 1 (ETH mainnet).
"1": {
"providers": {
"mainnet": {
"url": "http://mainnet.com"
}
}
}
}
```

#### `contracts` _(optional)_

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).

##### Api3ServerV1 _(optional)_

The address of the Api3ServerV1 contract. If not specified, the address is loaded from the Airnode protocol v1
repository.

#### `providers`

A record of providers. The record key is the provider name. Provider name is only used for internal purposes and to
uniquely identify the provider for the given chain.

##### `providers[<NAME>]`

A provider configuration.

###### `url`

The URL of the provider.

#### `__Temporary__DapiDataRegistry`

The data needed to make the requests to signed API. This data will in the future be stored on-chain in a
`DapiDataRegistry` contract. For the time being, they are statically defined in the configuration file.

##### `airnodeToSignedApiUrl`

A mapping from Airnode address to signed API URL. When data from particular beacon is needed a request is made to the
signed API corresponding to the beacon address.

##### `dataFeedIdToBeacons`

A mapping from data feed ID to a list of beacon data.

##### `dataFeedIdToBeacons<DATA_FEED_ID>`

A single element array for a beacon data. If the data feed is a beacon set, the array contains the data for all the
beacons in the beacon set (in correct order).

###### `dataFeedIdToBeacons<DATA_FEED_ID>[n]`

A beacon data.

`airnode`

The Airnode address of the beacon.

`templateId`

The template ID of the beacon.
29 changes: 29 additions & 0 deletions config/airseeker.example.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{
"sponsorWalletMnemonic": "${SPONSOR_WALLET_MNEMONIC}",
"chains": {
"31337": {
"contracts": {
"Api3ServerV1": "0xe7f1725E7734CE288F8367e1Bb143E90bb3F0512"
},
"__Temporary__DapiDataRegistry": {
"airnodeToSignedApiUrl": {
"0xbF3137b0a7574563a23a8fC8badC6537F98197CC": "http://127.0.0.1:8090/"
},
"dataFeedIdToBeacons": {
"0xebba8507d616ed80766292d200a3598fdba656d9938cecc392765d4a284a69a4": [
{
"airnode": "0xbF3137b0a7574563a23a8fC8badC6537F98197CC",
"templateId": "0xcc35bd1800c06c12856a87311dd95bfcbb3add875844021d59a929d79f3c99bd"
}
]
},
"activeDapiNames": ["ETH/USD"]
},
"providers": {
"hardhat": {
"url": "${HARDHAT_PROVIDER_URL}"
}
}
}
}
}
5 changes: 5 additions & 0 deletions config/secrets.example.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Secrets must NOT be quoted.
#
# The mnemonic is randomly generated. !!! USE ONLY FOR DEVELOPMENT PURPOSES !!!.
SPONSOR_WALLET_MNEMONIC=wonder assume clip draw aisle issue angle holiday puzzle glass worry ball
HARDHAT_PROVIDER_URL=http://127.0.0.1:8545/
11 changes: 10 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,12 @@
"prepare": "husky install",
"prettier:check": "prettier --check \"./**/*.{js,ts,md,json}\"",
"prettier:fix": "prettier --write \"./**/*.{js,ts,md,json}\"",
"test": "jest --passWithNoTests",
"test": "jest",
"tsc": "tsc --project ."
},
"devDependencies": {
"@types/jest": "^29.5.5",
"@types/lodash": "^4.14.199",
"@types/node": "^20.8.0",
"@typescript-eslint/eslint-plugin": "^6.7.3",
"@typescript-eslint/parser": "^6.7.3",
Expand All @@ -35,5 +36,13 @@
"ts-jest": "^29.1.1",
"ts-node": "^10.9.1",
"typescript": "^5.2.2"
},
"dependencies": {
"@api3/airnode-protocol-v1": "^2.10.0",
"@api3/promise-utils": "^0.4.0",
"dotenv": "^16.3.1",
"ethers": "^5.7.2",
"lodash": "^4.17.21",
"zod": "^3.22.2"
}
}
Loading

0 comments on commit 3f33084

Please sign in to comment.