Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: use s3 when on testnet #436

Merged
merged 1 commit into from
Mar 31, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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