Skip to content

Commit

Permalink
feat: use s3 when on testnet
Browse files Browse the repository at this point in the history
  • Loading branch information
MichaelTaylor3D committed Mar 31, 2022
1 parent 6c81357 commit 3071a7b
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 9 deletions.
7 changes: 4 additions & 3 deletions .env.copy
Original file line number Diff line number Diff line change
Expand Up @@ -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=
GOVERNANCE_BODY_PORT=
CHIA_NETWORK=mainnet
27 changes: 21 additions & 6 deletions src/utils/data-loaders.js
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand All @@ -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) => {
Expand Down

0 comments on commit 3071a7b

Please sign in to comment.