Skip to content

Commit 0bc15e9

Browse files
authored
Upgrade contracts3 update (#171)
* Update deterministic address * Expose data feed ID for local test configuration * Update contract function naming in local test configuration * Improve readability of comment * Check against unexpected update parameters format
1 parent e0ed70b commit 0bc15e9

File tree

7 files changed

+22
-17
lines changed

7 files changed

+22
-17
lines changed

config/airseeker.example.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"31337": {
55
"contracts": {
66
"Api3ServerV1": "0xe7f1725E7734CE288F8367e1Bb143E90bb3F0512",
7-
"AirseekerRegistry": "0xDD78254f864F97f65e2d86541BdaEf88A504D2B2"
7+
"AirseekerRegistry": "0x9fe46736679d2d9a65f0992f2272de9f3c7fa6e0"
88
},
99
"providers": {
1010
"hardhat": {

local-test-configuration/monitoring/index.html

+2-1
Original file line numberDiff line numberDiff line change
@@ -699,12 +699,13 @@ <h2>Active data feeds</h2>
699699
document.getElementById('activeDataFeedCount').innerHTML = activeDataFeedCount;
700700
let newActiveDataFeedsHtml = '';
701701
for (let i = 0; i < activeDataFeedCount; i++) {
702-
const { dapiName, updateParameters, dataFeedValue, dataFeedDetails, signedApiUrls } =
702+
const { dataFeedId, dapiName, updateParameters, dataFeedValue, dataFeedDetails, signedApiUrls } =
703703
await airseekerRegistry.activeDataFeed(i);
704704
const { deviationReference, deviationThresholdInPercentage, heartbeatInterval } =
705705
decodeUpdateParameters(updateParameters);
706706
const { value, timestamp } = dataFeedValue;
707707
const dataFeed = {
708+
dataFeedId,
708709
dapiName,
709710
updateParameters: {
710711
deviationReference: deviationReference.toString(),

local-test-configuration/scripts/initialize-chain.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ export const deploy = async (funderWallet: ethers.Wallet, provider: ethers.provi
206206
await tx.wait();
207207
tx = await airseekerRegistry
208208
.connect(deployerAndManager)
209-
.setUpdateParametersWithDapiName(
209+
.setDapiNameUpdateParameters(
210210
dapiName,
211211
ethers.utils.defaultAbiCoder.encode(
212212
['uint256', 'uint256', 'uint256'],

src/config/schema.test.ts

+7-7
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ describe('chains schema', () => {
4545
'31337': {
4646
contracts: {
4747
Api3ServerV1: '0xe7f1725E7734CE288F8367e1Bb143E90bb3F0512',
48-
AirseekerRegistry: '0xDD78254f864F97f65e2d86541BdaEf88A504D2B2',
48+
AirseekerRegistry: '0x9fe46736679d2d9a65f0992f2272de9f3c7fa6e0',
4949
},
5050
providers: {
5151
hardhat: {
@@ -62,7 +62,7 @@ describe('chains schema', () => {
6262

6363
expect(parsed['31337']!.contracts).toStrictEqual({
6464
Api3ServerV1: '0xe7f1725E7734CE288F8367e1Bb143E90bb3F0512',
65-
AirseekerRegistry: '0xDD78254f864F97f65e2d86541BdaEf88A504D2B2',
65+
AirseekerRegistry: '0x9fe46736679d2d9a65f0992f2272de9f3c7fa6e0',
6666
});
6767
});
6868

@@ -78,7 +78,7 @@ describe('chains schema', () => {
7878
dataFeedBatchSize: 10,
7979
dataFeedUpdateInterval: 60,
8080
contracts: {
81-
AirseekerRegistry: '0xDD78254f864F97f65e2d86541BdaEf88A504D2B2',
81+
AirseekerRegistry: '0x9fe46736679d2d9a65f0992f2272de9f3c7fa6e0',
8282
},
8383
},
8484
};
@@ -87,7 +87,7 @@ describe('chains schema', () => {
8787

8888
expect(parsed['1']!.contracts).toStrictEqual({
8989
Api3ServerV1: '0x709944a48cAf83535e43471680fDA4905FB3920a',
90-
AirseekerRegistry: '0xDD78254f864F97f65e2d86541BdaEf88A504D2B2',
90+
AirseekerRegistry: '0x9fe46736679d2d9a65f0992f2272de9f3c7fa6e0',
9191
});
9292
});
9393

@@ -100,7 +100,7 @@ describe('chains schema', () => {
100100
},
101101
},
102102
contracts: {
103-
AirseekerRegistry: '0xDD78254f864F97f65e2d86541BdaEf88A504D2B2',
103+
AirseekerRegistry: '0x9fe46736679d2d9a65f0992f2272de9f3c7fa6e0',
104104
},
105105
gasSettings,
106106
dataFeedBatchSize: 10,
@@ -124,7 +124,7 @@ describe('chains schema', () => {
124124
'31337': {
125125
contracts: {
126126
Api3ServerV1: '0xInvalid',
127-
AirseekerRegistry: '0xDD78254f864F97f65e2d86541BdaEf88A504D2B2',
127+
AirseekerRegistry: '0x9fe46736679d2d9a65f0992f2272de9f3c7fa6e0',
128128
},
129129
providers: {
130130
hardhat: {
@@ -168,7 +168,7 @@ describe('chains schema', () => {
168168
'31337': {
169169
contracts: {
170170
Api3ServerV1: '0xe7f1725E7734CE288F8367e1Bb143E90bb3F0512',
171-
AirseekerRegistry: '0xDD78254f864F97f65e2d86541BdaEf88A504D2B2',
171+
AirseekerRegistry: '0x9fe46736679d2d9a65f0992f2272de9f3c7fa6e0',
172172
},
173173
providers: {},
174174
gasSettings,

src/update-feeds-loops/contracts.ts

+7-3
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,9 @@ export const decodeDataFeedDetails = (dataFeed: string): DecodedDataFeed | null
3737
// https://github.com/api3dao/dapi-management/blob/f3d39e4707c33c075a8f07aa8f8369f8dc07736f/contracts/AirseekerRegistry.sol#L209
3838
if (dataFeed === '0x') return null;
3939

40-
if (dataFeed.length === 130) {
41-
// (64 [actual bytes] * 2[hex encoding] ) + 2 [for the '0x' preamble]
42-
// This is a hex encoded string, the contract works with bytes directly
40+
// This is a hex encoded string, the contract works with bytes directly
41+
// 2 characters for the '0x' preamble + 32 * 2 hexadecimals for 32 bytes + 32 * 2 hexadecimals for 32 bytes
42+
if (dataFeed.length === 2 + 32 * 2 + 32 * 2) {
4343
const [airnodeAddress, templateId] = ethers.utils.defaultAbiCoder.decode(['address', 'bytes32'], dataFeed);
4444

4545
const dataFeedId = deriveBeaconId(airnodeAddress, templateId)!;
@@ -73,6 +73,10 @@ export const decodeUpdateParameters = (updateParameters: string): DecodedUpdateP
7373
['uint256', 'int224', 'uint256'],
7474
updateParameters
7575
);
76+
// 2 characters for the '0x' preamble + 3 parameters, 32 * 2 hexadecimals for 32 bytes each
77+
if (updateParameters.length !== 2 + 3 * (32 * 2)) {
78+
throw new Error(`Unexpected trailing data in update parameters`);
79+
}
7680

7781
return {
7882
deviationReference,

src/update-feeds-loops/update-feeds-loops.test.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ describe(updateFeedsLoopsModule.runUpdateFeeds.name, () => {
160160
dataFeedUpdateInterval: 10,
161161
providers: { ['provider-name']: { url: 'provider-url' } },
162162
contracts: {
163-
AirseekerRegistry: '0xDD78254f864F97f65e2d86541BdaEf88A504D2B2',
163+
AirseekerRegistry: '0x9fe46736679d2d9a65f0992f2272de9f3c7fa6e0',
164164
},
165165
}),
166166
'123'
@@ -249,7 +249,7 @@ describe(updateFeedsLoopsModule.runUpdateFeeds.name, () => {
249249
dataFeedUpdateInterval: 0.15,
250250
providers: { ['provider-name']: { url: 'provider-url' } },
251251
contracts: {
252-
AirseekerRegistry: '0xDD78254f864F97f65e2d86541BdaEf88A504D2B2',
252+
AirseekerRegistry: '0x9fe46736679d2d9a65f0992f2272de9f3c7fa6e0',
253253
},
254254
}),
255255
'31337'
@@ -325,7 +325,7 @@ describe(updateFeedsLoopsModule.runUpdateFeeds.name, () => {
325325
dataFeedUpdateInterval: 0.1,
326326
providers: { ['provider-name']: { url: 'provider-url' } },
327327
contracts: {
328-
AirseekerRegistry: '0xDD78254f864F97f65e2d86541BdaEf88A504D2B2',
328+
AirseekerRegistry: '0x9fe46736679d2d9a65f0992f2272de9f3c7fa6e0',
329329
},
330330
}),
331331
'31337'

test/fixtures/mock-config.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ export const generateTestConfig = (): Config => ({
99
'31337': {
1010
contracts: {
1111
Api3ServerV1: '0xe7f1725E7734CE288F8367e1Bb143E90bb3F0512',
12-
AirseekerRegistry: '0xDD78254f864F97f65e2d86541BdaEf88A504D2B2',
12+
AirseekerRegistry: '0x9fe46736679d2d9a65f0992f2272de9f3c7fa6e0',
1313
},
1414
providers: { hardhat: { url: 'http://127.0.0.1:8545' } },
1515
gasSettings: {

0 commit comments

Comments
 (0)