From dbb5b5f12d148afd7bc13a3660e4a9377b1ee15c Mon Sep 17 00:00:00 2001 From: Michael Taylor Date: Wed, 18 Jan 2023 16:00:59 -0500 Subject: [PATCH] feat: add development mode --- src/controllers/governance.controller.js | 4 ++-- src/models/governance/governance.model.js | 8 ++++---- src/utils/data-loaders.js | 6 +++--- src/utils/defaultConfig.json | 1 + 4 files changed, 10 insertions(+), 9 deletions(-) diff --git a/src/controllers/governance.controller.js b/src/controllers/governance.controller.js index d3f82d25..a5186c57 100644 --- a/src/controllers/governance.controller.js +++ b/src/controllers/governance.controller.js @@ -64,7 +64,7 @@ export const findOrgList = async (req, res) => { export const findGlossary = async (req, res) => { try { - if (CONFIG.CHIA_NETWORK === 'testnet') { + if (CONFIG.USE_DEVELOPMENT_MODE) { return res.json(glossary); } @@ -82,7 +82,7 @@ export const findGlossary = async (req, res) => { export const findPickList = async (req, res) => { try { - if (CONFIG.CHIA_NETWORK === 'testnet') { + if (CONFIG.USE_DEVELOPMENT_MODE) { return res.json(pickList); } diff --git a/src/models/governance/governance.model.js b/src/models/governance/governance.model.js index db5fcb42..9a71eb03 100644 --- a/src/models/governance/governance.model.js +++ b/src/models/governance/governance.model.js @@ -13,7 +13,7 @@ import PickListStub from './governance.stub.json'; const { GOVERNANCE_BODY_ID } = getConfig().GOVERNANCE; -const { USE_SIMULATOR, CHIA_NETWORK } = getConfig().APP; +const { USE_SIMULATOR, USE_DEVELOPMENT_MODE } = getConfig().APP; import ModelTypes from './governance.modeltypes.cjs'; @@ -94,10 +94,10 @@ class Governance extends Model { metaValue: governanceData.pickList, confirmed: true, }); - } else if (USE_SIMULATOR || CHIA_NETWORK === 'testnet') { + } else if (USE_SIMULATOR || USE_DEVELOPMENT_MODE) { // 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'); + logger.info('SIMULATOR/DEVELOPMENT MODE: Using sample picklist'); updates.push({ metaKey: 'pickList', metaValue: JSON.stringify(PickListStub), @@ -115,7 +115,7 @@ class Governance extends Model { } // If on simulator or testnet, use the stubbed picklist data and return - if (USE_SIMULATOR || CHIA_NETWORK === 'testnet') { + if (USE_SIMULATOR || USE_DEVELOPMENT_MODE) { logger.info('SIMULATOR/TESTNET MODE: Using sample picklist'); Governance.upsert({ metaKey: 'pickList', diff --git a/src/utils/data-loaders.js b/src/utils/data-loaders.js index 6a61d191..50d21f2e 100644 --- a/src/utils/data-loaders.js +++ b/src/utils/data-loaders.js @@ -7,13 +7,13 @@ import PickListStub from '../models/governance/governance.stub.json'; import { getConfig } from '../utils/config-loader'; import { logger } from '../config/logger.cjs'; -const { USE_SIMULATOR, CHIA_NETWORK } = getConfig().APP; +const { USE_SIMULATOR, USE_DEVELOPMENT_MODE } = getConfig().APP; let downloadedPickList = {}; export const getPicklistValues = () => downloadedPickList; export const pullPickListValues = async () => { - if (USE_SIMULATOR || CHIA_NETWORK === 'testnet') { + if (USE_SIMULATOR || USE_DEVELOPMENT_MODE) { downloadedPickList = PickListStub; } else { const governanceData = await Governance.findOne({ @@ -30,7 +30,7 @@ export const pullPickListValues = async () => { }; export const getDefaultOrganizationList = async () => { - if (USE_SIMULATOR || CHIA_NETWORK === 'testnet') { + if (USE_SIMULATOR || USE_DEVELOPMENT_MODE) { return []; } else { const governanceData = await Governance.findOne({ diff --git a/src/utils/defaultConfig.json b/src/utils/defaultConfig.json index 15014cfb..e59efef8 100644 --- a/src/utils/defaultConfig.json +++ b/src/utils/defaultConfig.json @@ -13,6 +13,7 @@ "READ_ONLY": false, "API_KEY": null, "CHIA_NETWORK": "mainnet", + "USE_DEVELOPMENT_MODE": false, "IS_GOVERNANCE_BODY": false, "DEFAULT_FEE": 300000000, "DEFAULT_COIN_AMOUNT": 300000000,