Skip to content

Commit

Permalink
feat: add development mode
Browse files Browse the repository at this point in the history
  • Loading branch information
MichaelTaylor3D committed Jan 18, 2023
1 parent d32923d commit dbb5b5f
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 9 deletions.
4 changes: 2 additions & 2 deletions src/controllers/governance.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand All @@ -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);
}

Expand Down
8 changes: 4 additions & 4 deletions src/models/governance/governance.model.js
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down Expand Up @@ -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),
Expand All @@ -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',
Expand Down
6 changes: 3 additions & 3 deletions src/utils/data-loaders.js
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand All @@ -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({
Expand Down
1 change: 1 addition & 0 deletions src/utils/defaultConfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit dbb5b5f

Please sign in to comment.