From f2ff47e5d9c9b6679bd52393708f366b382c9350 Mon Sep 17 00:00:00 2001 From: Michael Taylor Date: Fri, 27 May 2022 09:10:59 -0400 Subject: [PATCH] fix: dont attempt to pull governance data if on simulator or testnet --- src/models/governance/governance.model.js | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/src/models/governance/governance.model.js b/src/models/governance/governance.model.js index cb338983..ae14d364 100644 --- a/src/models/governance/governance.model.js +++ b/src/models/governance/governance.model.js @@ -84,9 +84,12 @@ class Governance extends Model { confirmed: true, }); } else if (USE_SIMULATOR || CHIA_NETWORK === 'testnet') { + // this block is just a fallback if the app gets through the upstream checks, + // might be unnecessary + logger.info('SIMULATOR/TESTNET MODE: Using sample picklist'); updates.push({ metaKey: 'pickList', - metaValue: PickListStub, + metaValue: JSON.stringify(PickListStub), confirmed: true, }); } @@ -100,6 +103,18 @@ class Governance extends Model { throw new Error('Missing information in env to sync Governance data'); } + // If on simulator or testnet, use the stubbed picklist data and return + if (USE_SIMULATOR || CHIA_NETWORK === 'testnet') { + logger.info('SIMULATOR/TESTNET MODE: Using sample picklist'); + Governance.upsert({ + metaKey: 'pickList', + metaValue: JSON.stringify(PickListStub), + confirmed: true, + }); + + return; + } + const governanceData = await datalayer.getSubscribedStoreData( GOVERANCE_BODY_ID, GOVERNANCE_BODY_IP, @@ -125,12 +140,6 @@ class Governance extends Model { ); await Governance.upsertGovernanceDownload(versionedGovernanceData); - } else if (USE_SIMULATOR || CHIA_NETWORK === 'testnet') { - Governance.upsert({ - metaKey: 'pickList', - metaValue: PickListStub, - confirmed: true, - }); } else { throw new Error( `Governance data is not available from this source for ${dataModelVersion} data model.`,