Skip to content

Commit

Permalink
Update to AirseekerRegistry contract
Browse files Browse the repository at this point in the history
  • Loading branch information
Siegrift committed Dec 18, 2023
1 parent 8d14d62 commit 217d2a7
Show file tree
Hide file tree
Showing 29 changed files with 629 additions and 505 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -152,9 +152,9 @@ A record of contract addresses used by Airseeker.
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`
###### `AirseekerRegistry`

The address of the DapiDataRegistry contract.
The address of the AirseekerRegistry contract.

##### `providers`

Expand Down
2 changes: 1 addition & 1 deletion config/airseeker.example.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"31337": {
"contracts": {
"Api3ServerV1": "0xe7f1725E7734CE288F8367e1Bb143E90bb3F0512",
"DapiDataRegistry": "0xDD78254f864F97f65e2d86541BdaEf88A504D2B2"
"AirseekerRegistry": "0xDD78254f864F97f65e2d86541BdaEf88A504D2B2"
},
"providers": {
"hardhat": {
Expand Down
4 changes: 2 additions & 2 deletions contracts/contract-imports.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: UNLICENSED
pragma solidity 0.8.18;

import "@api3/dapi-management/contracts/DapiDataRegistry.sol";
import "@api3/dapi-management/contracts/HashRegistry.sol";
import "@api3/dapi-management/contracts/AirseekerRegistry.sol";
// import "@api3/dapi-management/contracts/HashRegistry.sol";
2 changes: 1 addition & 1 deletion local-test-configuration/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ also required for the monitoring page.

- Open the monitoring page located in `local-test-configuration/monitoring/index.html` in a browser with the following
query parameters appended
`?api3ServerV1Address=<DEPLOYED_API3_SERVER_V1_ADDRESS>&dapiDataRegistryAddress=<DEPLOYED_DAPI_DATA_REGISTRY_ADDRESS>&rpcUrl=<RPC_URL>&airseekerMnemonic=<AIRSEEKER_MNEMONIC>`
`?api3ServerV1Address=<DEPLOYED_API3_SERVER_V1_ADDRESS>&airseekerRegistryAddress=<DEPLOYED_DAPI_DATA_REGISTRY_ADDRESS>&rpcUrl=<RPC_URL>&airseekerMnemonic=<AIRSEEKER_MNEMONIC>`
and open console.

The `AIRSEEKER_MNEMONIC` needs to be URI encoded via `encodeURIComponent` in JS. For example,
Expand Down
2 changes: 1 addition & 1 deletion local-test-configuration/airseeker/airseeker.example.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"31337": {
"contracts": {
"Api3ServerV1": "${API3_SERVER_V1_ADDRESS}",
"DapiDataRegistry": "${DAPI_DATA_REGISTRY_ADDRESS}"
"AirseekerRegistry": "${DAPI_DATA_REGISTRY_ADDRESS}"
},
"providers": {
"hardhat": {
Expand Down
2 changes: 1 addition & 1 deletion local-test-configuration/airseeker/secrets.example.env
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ SPONSOR_WALLET_MNEMONIC=
LOCALHOST_IP=localhost
# NOTE: Use instructions to deploy the contracts and paste the Api3ServerV1 address.
API3_SERVER_V1_ADDRESS=
# NOTE: Use instructions to deploy the contracts and paste the DapiDataRegistry address.
# NOTE: Use instructions to deploy the contracts and paste the AirseekerRegistry address.
DAPI_DATA_REGISTRY_ADDRESS=
30 changes: 15 additions & 15 deletions local-test-configuration/monitoring/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ <h1>Airseeker monitoring</h1>
</p>

<h2>Active dAPIs</h2>
<p>Number of active dAPIs: <span id="activeDapisCount"></span></p>
<p>Number of active dAPIs: <span id="activeactiveDataFeedCount"></span></p>
<pre id="activeDapis"></pre>
</body>
<script
Expand Down Expand Up @@ -744,7 +744,7 @@ <h2>Active dAPIs</h2>
type: 'function',
},
];
const dapiDataRegistryAbi = [
const airseekerRegistryAbi = [
{
inputs: [
{
Expand Down Expand Up @@ -1122,7 +1122,7 @@ <h2>Active dAPIs</h2>
},
{
inputs: [],
name: 'dapisCount',
name: 'activeDataFeedCount',
outputs: [
{
internalType: 'uint256',
Expand Down Expand Up @@ -1205,7 +1205,7 @@ <h2>Active dAPIs</h2>
type: 'uint256',
},
],
name: 'readDapiWithIndex',
name: 'activeDataFeed',
outputs: [
{
internalType: 'bytes32',
Expand All @@ -1230,7 +1230,7 @@ <h2>Active dAPIs</h2>
type: 'uint32',
},
],
internalType: 'struct IDapiDataRegistry.UpdateParameters',
internalType: 'struct IAirseekerRegistry.UpdateParameters',
name: 'updateParameters',
type: 'tuple',
},
Expand All @@ -1247,7 +1247,7 @@ <h2>Active dAPIs</h2>
type: 'uint32',
},
],
internalType: 'struct IDapiDataRegistry.DataFeedValue',
internalType: 'struct IAirseekerRegistry.DataFeedValue',
name: 'dataFeedValue',
type: 'tuple',
},
Expand Down Expand Up @@ -1293,7 +1293,7 @@ <h2>Active dAPIs</h2>
type: 'uint32',
},
],
internalType: 'struct IDapiDataRegistry.UpdateParameters',
internalType: 'struct IAirseekerRegistry.UpdateParameters',
name: 'updateParameters',
type: 'tuple',
},
Expand All @@ -1310,7 +1310,7 @@ <h2>Active dAPIs</h2>
type: 'uint32',
},
],
internalType: 'struct IDapiDataRegistry.DataFeedValue',
internalType: 'struct IAirseekerRegistry.DataFeedValue',
name: 'dataFeedValue',
type: 'tuple',
},
Expand Down Expand Up @@ -1451,11 +1451,11 @@ <h2>Active dAPIs</h2>
const urlParams = new URLSearchParams(window.location.search);
const rpcUrl = urlParams.get('rpcUrl'),
api3ServerV1Address = urlParams.get('api3ServerV1Address'),
dapiDataRegistryAddress = urlParams.get('dapiDataRegistryAddress'),
airseekerRegistryAddress = urlParams.get('airseekerRegistryAddress'),
airseekerMnemonic = decodeURIComponent(urlParams.get('airseekerMnemonic'));

if (!api3ServerV1Address) throw new Error('api3ServerV1Address must be provided as URL parameter');
if (!dapiDataRegistryAddress) throw new Error('dapiDataRegistryAddress must be provided as URL parameter');
if (!airseekerRegistryAddress) throw new Error('airseekerRegistryAddress must be provided as URL parameter');

function deriveBeaconId(airnodeAddress, templateId) {
return ethers.utils.solidityKeccak256(['address', 'bytes32'], [airnodeAddress, templateId]);
Expand Down Expand Up @@ -1559,14 +1559,14 @@ <h2>Active dAPIs</h2>

setInterval(async () => {
const provider = new ethers.providers.JsonRpcProvider(rpcUrl);
const dapiDataRegistry = new ethers.Contract(dapiDataRegistryAddress, dapiDataRegistryAbi, provider);
const activeDapisCount = await dapiDataRegistry.dapisCount();
const airseekerRegistry = new ethers.Contract(airseekerRegistryAddress, airseekerRegistryAbi, provider);
const activeactiveDataFeedCount = await airseekerRegistry.activeDataFeedCount();

document.getElementById('activeDapisCount').innerHTML = activeDapisCount;
document.getElementById('activeactiveDataFeedCount').innerHTML = activeactiveDataFeedCount;
let newActiveDapisHtml = '';
for (let i = 0; i < activeDapisCount; i++) {
for (let i = 0; i < activeactiveDataFeedCount; i++) {
const { dapiName, updateParameters, dataFeedValue, dataFeed, signedApiUrls } =
await dapiDataRegistry.readDapiWithIndex(i);
await airseekerRegistry.activeDataFeed(i);
const { deviationReference, deviationThresholdInPercentage, heartbeatInterval } = updateParameters;
const { value, timestamp } = dataFeedValue;
const dapi = {
Expand Down
Loading

0 comments on commit 217d2a7

Please sign in to comment.