From 69f8a091d8990e7e04e0383bdc62dc74f9a8879b Mon Sep 17 00:00:00 2001 From: Matthias Kretschmann Date: Mon, 20 Jul 2020 17:04:38 +0200 Subject: [PATCH] refactor network config --- .env.example | 19 ++++--------------- app.config.js | 23 ++++++++--------------- src/hooks/useSiteMetadata.ts | 3 ++- 3 files changed, 14 insertions(+), 31 deletions(-) diff --git a/.env.example b/.env.example index ccca6acaf..294bbb0ce 100644 --- a/.env.example +++ b/.env.example @@ -1,16 +1,5 @@ -GATSBY_INFURA_PROJECT_ID="xxx" +# Network, possible values: development, pacific, rinkeby, mainnet +GATSBY_NETWORK="rinkeby" -# Local config -GATSBY_NODE_URI='http://localhost:8545' -GATSBY_METADATA_STORE_URI='http://aquarius:5000' -GATSBY_PROVIDER_URI='http://localhost:8030' -GATSBY_FACTORY_ADDRESS='0xxxx' -#GATSBY_OCEAN_TOKEN_ADDRESS='0xxxx' - -# Rinkeby -#GATSBY_NODE_URI='https://rinkeby.infura.io/v3/GATSBY_INFURA_PROJECT_ID' -#GATSBY_METADATA_STORE_URI='https://aquarius.rinkeby.v3.dev-ocean.com' -#GATSBY_PROVIDER_URI='https://provider.rinkeby.v3.dev-ocean.com' -#GATSBY_FACTORY_ADDRESS='0xcDfEe5D80041224cDCe9AE2334E85B3236385EA3' -#GATSBY_OCEAN_TOKEN_ADDRESS='0x8967BCF84170c91B0d24D4302C2376283b0B3a07' -#GATSBY_MARKET_ADDRESS='xxx' \ No newline at end of file +#GATSBY_INFURA_PROJECT_ID="xxx" +#GATSBY_MARKET_ADDRESS="xxx" \ No newline at end of file diff --git a/app.config.js b/app.config.js index d36b9577f..91cbdfe3f 100644 --- a/app.config.js +++ b/app.config.js @@ -1,20 +1,13 @@ +const { ConfigHelper } = require('@oceanprotocol/lib') + +const networkConfig = new ConfigHelper().getConfig( + process.env.GATSBY_NETWORK || 'rinkeby' +) + module.exports = { oceanConfig: { - nodeUri: - process.env.GATSBY_NODE_URI || - `https://rinkeby.infura.io/${process.env.GATSBY_INFURA_PROJECT_ID}`, - metadataStoreUri: - process.env.GATSBY_METADATA_STORE_URI || - 'https://aquarius.rinkeby.v3.dev-ocean.com', - providerUri: - process.env.GATSBY_PROVIDER_URI || - 'https://provider.rinkeby.v3.dev-ocean.com', - factoryAddress: - process.env.GATSBY_FACTORY_ADDRESS || - '0xcDfEe5D80041224cDCe9AE2334E85B3236385EA3', - oceanTokenAddress: - process.env.GATSBY_OCEAN_TOKEN_ADDRESS || - '0x8967BCF84170c91B0d24D4302C2376283b0B3a07', + ...networkConfig, + url: `https://rinkeby.infura.io/${process.env.GATSBY_INFURA_PROJECT_ID}`, verbose: 3 }, // Main, Rinkeby, Kovan diff --git a/src/hooks/useSiteMetadata.ts b/src/hooks/useSiteMetadata.ts index be7ba45d7..0a642efec 100644 --- a/src/hooks/useSiteMetadata.ts +++ b/src/hooks/useSiteMetadata.ts @@ -18,9 +18,10 @@ const query = graphql` networks marketAddress oceanConfig { + url factoryAddress + oceanTokenAddress metadataStoreUri - nodeUri providerUri verbose }