Skip to content

Commit b05aa33

Browse files
committed
Adds dappId check for provided proxy address on deploy scripts
1 parent d6abe74 commit b05aa33

File tree

4 files changed

+59
-1
lines changed

4 files changed

+59
-1
lines changed

deploy/001_deploy_InverseApi3ReaderProxyV1.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import type { DeploymentsExtension } from 'hardhat-deploy/types';
33

44
import { getDeploymentName } from '../src';
55
import * as testUtils from '../test/test-utils';
6+
import { IApi3ReaderProxyWithDappId__factory } from '../typechain-types';
67

78
export const CONTRACT_NAME = 'InverseApi3ReaderProxyV1';
89

@@ -42,7 +43,15 @@ module.exports = async (hre: HardhatRuntimeEnvironment) => {
4243
}
4344
log(`Proxy address: ${proxyAddress}`);
4445

45-
// TODO: check that proxyAddress returns a dappId
46+
if (!isLocalNetwork) {
47+
try {
48+
const proxy = IApi3ReaderProxyWithDappId__factory.connect(proxyAddress, ethers.provider);
49+
const dappId = await proxy.dappId();
50+
log(`Proxy dappId: ${dappId}`);
51+
} catch {
52+
throw new Error(`Failed to read dappId from proxy at ${proxyAddress}`);
53+
}
54+
}
4655

4756
const confirmations = isLocalNetwork ? 1 : 5;
4857
log(`Deployment confirmations: ${confirmations}`);

deploy/003_deploy_ProductApi3ReaderProxyV1.ts

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import type { DeploymentsExtension } from 'hardhat-deploy/types';
33

44
import { getDeploymentName } from '../src';
55
import * as testUtils from '../test/test-utils';
6+
import { IApi3ReaderProxyWithDappId__factory } from '../typechain-types';
67

78
export const CONTRACT_NAME = 'ProductApi3ReaderProxyV1';
89

@@ -47,6 +48,17 @@ module.exports = async (hre: HardhatRuntimeEnvironment) => {
4748
}
4849
log(`Proxy 1 address: ${proxy1Address}`);
4950

51+
let dappId1;
52+
if (!isLocalNetwork) {
53+
try {
54+
const proxy1 = IApi3ReaderProxyWithDappId__factory.connect(proxy1Address, ethers.provider);
55+
dappId1 = await proxy1.dappId();
56+
log(`Proxy 1 dappId: ${dappId1}`);
57+
} catch {
58+
throw new Error(`Failed to read dappId from proxy at ${proxy1Address}`);
59+
}
60+
}
61+
5062
// Sleep for 1 sec when deploying to local network in order to generate a different proxy address
5163
if (isLocalNetwork) {
5264
await new Promise((resolve) => setTimeout(resolve, 1000));
@@ -63,6 +75,21 @@ module.exports = async (hre: HardhatRuntimeEnvironment) => {
6375
}
6476
log(`Proxy 2 address: ${proxy2Address}`);
6577

78+
let dappId2;
79+
if (!isLocalNetwork) {
80+
try {
81+
const proxy2 = IApi3ReaderProxyWithDappId__factory.connect(proxy2Address, ethers.provider);
82+
dappId2 = await proxy2.dappId();
83+
log(`Proxy 2 dappId: ${dappId2}`);
84+
} catch {
85+
throw new Error(`Failed to read dappId from proxy at ${proxy2Address}`);
86+
}
87+
}
88+
89+
if (!isLocalNetwork && dappId1 && dappId2 && dappId1 !== dappId2) {
90+
throw new Error(`dApp IDs of PROXY1 (${dappId1}) and PROXY2 (${dappId2}) do not match.`);
91+
}
92+
6693
const confirmations = isLocalNetwork ? 1 : 5;
6794
log(`Deployment confirmations: ${confirmations}`);
6895

deploy/004_deploy_ScaledApi3FeedProxyV1.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import type { DeploymentsExtension } from 'hardhat-deploy/types';
33

44
import { getDeploymentName } from '../src';
55
import * as testUtils from '../test/test-utils';
6+
import { IApi3ReaderProxyWithDappId__factory } from '../typechain-types';
67

78
export const CONTRACT_NAME = 'ScaledApi3FeedProxyV1';
89

@@ -48,6 +49,16 @@ module.exports = async (hre: HardhatRuntimeEnvironment) => {
4849
}
4950
log(`Proxy address: ${proxyAddress}`);
5051

52+
if (!isLocalNetwork) {
53+
try {
54+
const proxy = IApi3ReaderProxyWithDappId__factory.connect(proxyAddress, ethers.provider);
55+
const dappId = await proxy.dappId();
56+
log(`Proxy dappId: ${dappId}`);
57+
} catch {
58+
throw new Error(`Failed to read dappId from proxy at ${proxyAddress}`);
59+
}
60+
}
61+
5162
const confirmations = isLocalNetwork ? 1 : 5;
5263
log(`Deployment confirmations: ${confirmations}`);
5364

deploy/005_deploy_PriceCappedApi3ReaderProxyV1.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import type { DeploymentsExtension } from 'hardhat-deploy/types';
33

44
import { getDeploymentName } from '../src';
55
import * as testUtils from '../test/test-utils';
6+
import { IApi3ReaderProxyWithDappId__factory } from '../typechain-types';
67

78
export const CONTRACT_NAME = 'PriceCappedApi3ReaderProxyV1';
89

@@ -42,6 +43,16 @@ module.exports = async (hre: HardhatRuntimeEnvironment) => {
4243
}
4344
log(`Proxy address: ${proxyAddress}`);
4445

46+
if (!isLocalNetwork) {
47+
try {
48+
const proxy = IApi3ReaderProxyWithDappId__factory.connect(proxyAddress, ethers.provider);
49+
const dappId = await proxy.dappId();
50+
log(`Proxy dappId: ${dappId}`);
51+
} catch {
52+
throw new Error(`Failed to read dappId from proxy at ${proxyAddress}`);
53+
}
54+
}
55+
4556
const lowerBound = process.env.LOWER_BOUND ? BigInt(process.env.LOWER_BOUND) : 0n; // Defaults to 0
4657
log(`Using lower bound: ${lowerBound.toString()}`);
4758

0 commit comments

Comments
 (0)