From 3071a7b918e683fb09ce1840584019077cfb95ad Mon Sep 17 00:00:00 2001 From: Michael Taylor Date: Thu, 31 Mar 2022 12:33:17 -0400 Subject: [PATCH] feat: use s3 when on testnet --- .env.copy | 7 ++++--- src/utils/data-loaders.js | 27 +++++++++++++++++++++------ 2 files changed, 25 insertions(+), 9 deletions(-) diff --git a/.env.copy b/.env.copy index 04922193..e3f98140 100644 --- a/.env.copy +++ b/.env.copy @@ -6,11 +6,12 @@ CW_PORT=31310 DATALAYER_URL=https://localhost:8562 WALLET_URL=https://localhost:9256 USE_SIMULATOR=false -PICKLIST_URL=https://climate-warehouse.s3.us-west-2.amazonaws.com/public/picklists.json -DEFAULT_ORGANIZATIONS=https://climate-warehouse.s3.us-west-2.amazonaws.com/public/cw-organizations.json +TESTNET_PICKLIST_URL=https://climate-warehouse.s3.us-west-2.amazonaws.com/public/picklists.json +TESTNET_DEFAULT_ORGANIZATIONS=https://climate-warehouse.s3.us-west-2.amazonaws.com/public/cw-organizations-testnet.json READ_ONLY=false IS_GOVERNANCE_BODY=false API_KEY= GOVERANCE_BODY_ID= GOVERNANCE_BODY_IP= -GOVERNANCE_BODY_PORT= \ No newline at end of file +GOVERNANCE_BODY_PORT= +CHIA_NETWORK=mainnet \ No newline at end of file diff --git a/src/utils/data-loaders.js b/src/utils/data-loaders.js index 5f2d775c..48bc2225 100644 --- a/src/utils/data-loaders.js +++ b/src/utils/data-loaders.js @@ -9,7 +9,10 @@ let downloadedPickList = {}; export const getPicklistValues = () => downloadedPickList; export const pullPickListValues = async () => { - if (process.env.USE_SIMULATOR === 'true') { + if ( + process.env.USE_SIMULATOR === 'true' || + process.env.CHIA_NETWORK === 'testnet' + ) { downloadedPickList = PickListStub; } else { const goveranceData = await Governance.findOne({ @@ -24,12 +27,24 @@ export const pullPickListValues = async () => { }; export const getDefaultOrganizationList = async () => { - const goveranceData = await Governance.findOne({ - where: { metaKey: 'orgList' }, - raw: true, - }); + if ( + process.env.USE_SIMULATOR === 'true' || + process.env.CHIA_NETWORK === 'testnet' + ) { + const options = { + method: 'GET', + url: process.env.TESTNET_DEFAULT_ORGANIZATIONS, + }; - return JSON.parse(_.get(goveranceData, 'metaValue', '[]')); + return JSON.parse(await request(Object.assign({}, options))); + } else { + const goveranceData = await Governance.findOne({ + where: { metaKey: 'orgList' }, + raw: true, + }); + + return JSON.parse(_.get(goveranceData, 'metaValue', '[]')); + } }; export const serverAvailable = async (server, port) => {