From 71e4bf3009a323af44f9a419b4fd7a427c978eb7 Mon Sep 17 00:00:00 2001 From: David Llop <931684+sembrestels@users.noreply.github.com> Date: Wed, 9 Sep 2020 12:09:28 +0200 Subject: [PATCH] Set xdai as default chain --- src/environment.js | 2 +- src/hooks/useKnownContract.js | 4 ++-- src/hooks/useOrgHooks.js | 5 ++--- src/lib/known-contracts.js | 4 ++-- src/local-settings.js | 2 +- 5 files changed, 8 insertions(+), 9 deletions(-) diff --git a/src/environment.js b/src/environment.js index acce528..137dd5c 100644 --- a/src/environment.js +++ b/src/environment.js @@ -1,5 +1,5 @@ // rinkeby -const DEFAULT_CHAIN_ID = 4 +const DEFAULT_CHAIN_ID = 100 const ENV_VARS = { CHAIN_ID() { diff --git a/src/hooks/useKnownContract.js b/src/hooks/useKnownContract.js index f20cede..ba445a3 100644 --- a/src/hooks/useKnownContract.js +++ b/src/hooks/useKnownContract.js @@ -3,7 +3,7 @@ import { getDefaultProvider as getEthersDefaultProvider, } from 'ethers' import { getKnownContract } from '../lib/known-contracts' -import env from '../environment' +import { getDefaultChain } from '../local-settings' import { getNetwork } from '../networks' const readOnlyContractsCache = new Map() @@ -16,7 +16,7 @@ export function useReadOnlyContract(name) { } const { ensRegistry: ensAddress, chainId, type: networkName } = getNetwork( - env('CHAIN_ID') + getDefaultChain() ) const defaultProvider = getEthersDefaultProvider({ diff --git a/src/hooks/useOrgHooks.js b/src/hooks/useOrgHooks.js index cfe8b9a..04d7dcf 100644 --- a/src/hooks/useOrgHooks.js +++ b/src/hooks/useOrgHooks.js @@ -1,7 +1,6 @@ import { useEffect, useRef, useState } from 'react' import ConvictionVoting from '@1hive/connect-conviction-voting' import { connect } from '@aragon/connect' -import env from '../environment' import { getNetwork } from '../networks' import BigNumber from '../lib/bigNumber' import { getAppAddressByName } from '../lib/data-utils' @@ -39,7 +38,7 @@ export function useOrganzation() { let cancelled = false const fetchOrg = async () => { - const { generalSubgraphUrl, orgAddress } = getNetwork(env('CHAIN_ID')) + const { generalSubgraphUrl, orgAddress } = getNetwork(getDefaultChain()) const organization = await connect(orgAddress, [ 'thegraph', @@ -77,7 +76,7 @@ export function useAppData(organization) { const fetchAppData = async () => { const apps = await organization.apps() const permissions = await organization.permissions() - const { defaultSubgraphUrl } = getNetwork(env('CHAIN_ID')) + const { defaultSubgraphUrl } = getNetwork(getDefaultChain()) const convictionApp = apps.find(app => app.name === APP_NAME) diff --git a/src/lib/known-contracts.js b/src/lib/known-contracts.js index 48c5956..51ba663 100644 --- a/src/lib/known-contracts.js +++ b/src/lib/known-contracts.js @@ -1,5 +1,5 @@ import ercTokenAbi from '../abi/ercToken.json' -import env from '../environment' +import { getDefaultChain } from '../local-settings' const KNOWN_CONTRACTS_BY_ENV = new Map([ [ @@ -19,7 +19,7 @@ const KNOWN_CONTRACTS_BY_ENV = new Map([ const ABIS = new Map([['TOKEN_ANT', ercTokenAbi]]) export function getKnownContract(name) { - const knownContracts = KNOWN_CONTRACTS_BY_ENV.get(env('CHAIN_ID')) || {} + const knownContracts = KNOWN_CONTRACTS_BY_ENV.get(getDefaultChain()) || {} return [knownContracts[name] || null, ABIS.get(name) || []] } diff --git a/src/local-settings.js b/src/local-settings.js index 55fdfdd..4403bf4 100644 --- a/src/local-settings.js +++ b/src/local-settings.js @@ -15,7 +15,7 @@ function setLocalSetting(confKey, value) { } export function getDefaultChain() { - return Number(env(DEFAULT_CHAIN_ID)) || '4' + return Number(env(DEFAULT_CHAIN_ID)) || 100 } export function setDefaultChain(chainId) {