1
0
mirror of https://github.com/oceanprotocol/market.git synced 2024-12-02 05:57:29 +01:00

config refactor

This commit is contained in:
Matthias Kretschmann 2020-08-07 10:17:06 +02:00
parent a142509a6f
commit 8316a1ab8b
Signed by: m
GPG Key ID: 606EEEF3C479A91F
2 changed files with 29 additions and 30 deletions

View File

@ -1,28 +1,8 @@
const { ConfigHelper } = require('@oceanprotocol/lib')
const network = process.env.GATSBY_NETWORK || 'rinkeby'
function getDefaultOceanConfig() {
return new ConfigHelper().getConfig(
network,
process.env.GATSBY_INFURA_PROJECT_ID
)
}
const appConfig = {
oceanConfig: {
...getDefaultOceanConfig(),
verbose: 3
},
network,
module.exports = {
network: process.env.GATSBY_NETWORK || 'rinkeby',
infuraProjectId: process.env.GATSBY_INFURA_PROJECT_ID || 'xxx',
marketFeeAddress:
process.env.GATSBY_MARKET_FEE_ADDRESS ||
'0x903322C7E45A60d7c8C3EA236c5beA9Af86310c7',
marketFeeAmount: process.env.GATSBY_MARKET_FEE_AMOUNT || '0.1' // in %
}
module.exports = {
getDefaultOceanConfig,
appConfig
}

View File

@ -1,16 +1,35 @@
import React, { ReactElement } from 'react'
import { OceanProvider } from '@oceanprotocol/react'
import { appConfig } from '../../app.config'
import { ConfigHelper } from '@oceanprotocol/lib'
import { web3ModalOpts } from '../utils/wallet'
import { network } from '../../app.config'
const wrapRootElement = ({
function getOceanConfig(network: string) {
return new ConfigHelper().getConfig(
network,
process.env.GATSBY_INFURA_PROJECT_ID
)
}
export default function wrapRootElement({
element
}: {
element: ReactElement
}): ReactElement => (
<OceanProvider config={appConfig.oceanConfig} web3ModalOpts={web3ModalOpts}>
{element}
</OceanProvider>
)
}): ReactElement {
const oceanInitialConfig = getOceanConfig(network)
export default wrapRootElement
async function handleNetworkChanged(chainId: number) {
const config = getOceanConfig(chainId)
connect(config)
}
return (
<OceanProvider
initialConfig={oceanInitialConfig}
handleNetworkChanged={handleNetworkChanged}
web3ModalOpts={web3ModalOpts}
>
{element}
</OceanProvider>
)
}