From 7946227592ff28b3b2e3bddd71c157988402cd2e Mon Sep 17 00:00:00 2001 From: Derek Croote Date: Mon, 9 Oct 2023 18:34:25 -0700 Subject: [PATCH] fix(examples): check for AirnodeRrp deployment in localhost flow (#1895) --- .changeset/curvy-timers-kick.md | 5 +++++ .../src/scripts/create-airnode-config.ts | 19 ++++++++++++++++++- 2 files changed, 23 insertions(+), 1 deletion(-) create mode 100644 .changeset/curvy-timers-kick.md diff --git a/.changeset/curvy-timers-kick.md b/.changeset/curvy-timers-kick.md new file mode 100644 index 0000000000..29066efaa5 --- /dev/null +++ b/.changeset/curvy-timers-kick.md @@ -0,0 +1,5 @@ +--- +'@api3/airnode-examples': patch +--- + +Check for AirnodeRrp deployment in localhost flow diff --git a/packages/airnode-examples/src/scripts/create-airnode-config.ts b/packages/airnode-examples/src/scripts/create-airnode-config.ts index 96c5f56a32..daf599448c 100644 --- a/packages/airnode-examples/src/scripts/create-airnode-config.ts +++ b/packages/airnode-examples/src/scripts/create-airnode-config.ts @@ -1,7 +1,24 @@ -import { readIntegrationInfo, runAndHandleErrors } from '../'; +import { readIntegrationInfo, runAndHandleErrors, getDeployedContract, cliPrint } from '../'; const main = async () => { const integrationInfo = readIntegrationInfo(); + + // If using the localhost network, check that AirnodeRrp was deployed + if (integrationInfo.network === 'localhost') { + try { + await getDeployedContract('@api3/airnode-protocol/contracts/rrp/AirnodeRrpV0.sol'); + } catch (e) { + if (e instanceof Error && (e.message.includes('ENOENT') || e.message.includes('invalid contract address'))) { + cliPrint.error( + 'AirnodeRrpV0 contract deployment not found. Please follow the RRP deployment ' + + 'instructions in the README before running this command.' + ); + process.exit(1); + } + throw e; + } + } + // Import the "create-config" file from the chosen integration. See the respective "create-config.ts" file for // details. const createConfig = await import(`../../integrations/${integrationInfo.integration}/create-config.ts`);