Skip to content

Commit 7946227

Browse files
authored
fix(examples): check for AirnodeRrp deployment in localhost flow (#1895)
1 parent cefc5e4 commit 7946227

2 files changed

Lines changed: 23 additions & 1 deletion

File tree

.changeset/curvy-timers-kick.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@api3/airnode-examples': patch
3+
---
4+
5+
Check for AirnodeRrp deployment in localhost flow

packages/airnode-examples/src/scripts/create-airnode-config.ts

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,24 @@
1-
import { readIntegrationInfo, runAndHandleErrors } from '../';
1+
import { readIntegrationInfo, runAndHandleErrors, getDeployedContract, cliPrint } from '../';
22

33
const main = async () => {
44
const integrationInfo = readIntegrationInfo();
5+
6+
// If using the localhost network, check that AirnodeRrp was deployed
7+
if (integrationInfo.network === 'localhost') {
8+
try {
9+
await getDeployedContract('@api3/airnode-protocol/contracts/rrp/AirnodeRrpV0.sol');
10+
} catch (e) {
11+
if (e instanceof Error && (e.message.includes('ENOENT') || e.message.includes('invalid contract address'))) {
12+
cliPrint.error(
13+
'AirnodeRrpV0 contract deployment not found. Please follow the RRP deployment ' +
14+
'instructions in the README before running this command.'
15+
);
16+
process.exit(1);
17+
}
18+
throw e;
19+
}
20+
}
21+
522
// Import the "create-config" file from the chosen integration. See the respective "create-config.ts" file for
623
// details.
724
const createConfig = await import(`../../integrations/${integrationInfo.integration}/create-config.ts`);

0 commit comments

Comments
 (0)