Skip to content
This repository was archived by the owner on Nov 10, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
9ab2060
add network based configs
fernandomg Sep 30, 2020
fd48894
Merge branch 'feature/#1353-xDai-compatibility' into feature/#1414-xD…
fernandomg Sep 30, 2020
8adeaf0
Merge branch 'feature/#1353-xDai-compatibility' into feature/#1414-xD…
fernandomg Sep 30, 2020
79fdcd9
Rename dev config by baseConfig
matextrem Oct 1, 2020
5b90fa9
use ETHEREUM_NETWORK enum to define the network id
fernandomg Oct 1, 2020
c0859fd
change config keys from CONSTANT_CASE to upperCase
fernandomg Oct 1, 2020
1b39ee1
replace Host and Url with Uri in config keys
fernandomg Oct 1, 2020
79e2a70
move network config files into a `networks` directory
fernandomg Oct 1, 2020
ab69f74
add tests for config files
fernandomg Oct 1, 2020
45cb541
Merge branch 'feature/#1353-xDai-compatibility' into feature/#1414-xD…
fernandomg Oct 1, 2020
7ea7c10
replace current configs with generic configs
fernandomg Oct 2, 2020
9e2e755
fix test description
fernandomg Oct 2, 2020
4cc35e1
rename `getNetwork` to `getNetworkId`
fernandomg Oct 2, 2020
1f132ef
create `getNetworkName` function and use it where needed
fernandomg Oct 2, 2020
9a467d0
simplify config file and use CONSTANTS where possible
fernandomg Oct 2, 2020
95bd0fb
update tests
fernandomg Oct 2, 2020
dfd1b2a
change features' type to boolean
fernandomg Oct 2, 2020
dc26462
replace `Uri` with `Url`
fernandomg Oct 2, 2020
35604e7
add `networkExplorerName` key
fernandomg Oct 2, 2020
d0d7a6d
Merge branch 'feature/#1414-xDai-generic-configs' into feature/#1415-…
fernandomg Oct 2, 2020
4e5e8bf
move `ETHEREUM_NETWORK` enum into `config/networks/network.d` definit…
fernandomg Oct 2, 2020
834f383
rename `getxServiceHost` to `getTxServiceUrl`
fernandomg Oct 2, 2020
3e7f284
export all the network config information
fernandomg Oct 2, 2020
b7155a5
return proper config based on network and environment variables
fernandomg Oct 2, 2020
cf29302
changed environment discovery to a switch/case statement
fernandomg Oct 2, 2020
e353434
specify the declaration file on importing from 'src/config/networks/n…
fernandomg Oct 2, 2020
b2fed32
force uppercase for the `NETWORK` const
fernandomg Oct 2, 2020
feea729
add tests
fernandomg Oct 2, 2020
2a26846
Merge branch 'feature/#1353-xDai-compatibility' into feature/#1415-xD…
fernandomg Oct 2, 2020
c871d26
fix typo in dir name
fernandomg Oct 2, 2020
6c61d97
update tests to use dynamic environment values
fernandomg Oct 5, 2020
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
8 changes: 4 additions & 4 deletions src/components/App/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ import CookiesBanner from 'src/components/CookiesBanner'
import Notifier from 'src/components/Notifier'
import Backdrop from 'src/components/layout/Backdrop'
import Img from 'src/components/layout/Img'
import { getNetwork } from 'src/config'
import { ETHEREUM_NETWORK } from 'src/logic/wallets/getWeb3'
import { getNetworkId } from 'src/config'
import { ETHEREUM_NETWORK } from 'src/config/networks/network.d'
import { networkSelector } from 'src/logic/wallets/store/selectors'
import { SAFELIST_ADDRESS, WELCOME_ADDRESS } from 'src/routes/routes'
import { safeNameSelector, safeParamAddressFromStateSelector } from 'src/logic/safe/store/selectors'
Expand All @@ -26,7 +26,7 @@ import SendModal from 'src/routes/safe/components/Balances/SendModal'
import { useLoadSafe } from 'src/logic/safe/hooks/useLoadSafe'
import { useSafeScheduledUpdates } from 'src/logic/safe/hooks/useSafeScheduledUpdates'
import useSafeActions from 'src/logic/safe/hooks/useSafeActions'
import { currentCurrencySelector, safeFiatBalancesTotalSelector } from 'src/logic/currencyValues/store/selectors/index'
import { currentCurrencySelector, safeFiatBalancesTotalSelector } from 'src/logic/currencyValues/store/selectors'
import { formatAmountInUsFormat } from 'src/logic/tokens/utils/formatAmount'
import { grantedSelector } from 'src/routes/safe/container/selector'

Expand Down Expand Up @@ -55,7 +55,7 @@ const Frame = styled.div`
max-width: 100%;
`

const desiredNetwork = getNetwork()
const desiredNetwork = getNetworkId()

const useStyles = makeStyles(notificationStyles)

Expand Down
6 changes: 3 additions & 3 deletions src/components/AppLayout/Header/components/NetworkLabel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ import * as React from 'react'

import Col from 'src/components/layout/Col'
import Paragraph from 'src/components/layout/Paragraph'
import { getNetwork } from 'src/config'
import { ETHEREUM_NETWORK } from 'src/logic/wallets/getWeb3'
import { getNetworkId } from 'src/config'
import { ETHEREUM_NETWORK } from 'src/config/networks/network.d'
import { border, md, screenSm, sm, xs } from 'src/theme/variables'

const interfaceNetwork = getNetwork()
const interfaceNetwork = getNetworkId()
const formatNetwork = (network: number): string =>
ETHEREUM_NETWORK[network][0].toUpperCase() + ETHEREUM_NETWORK[network].substring(1).toLowerCase()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import Paragraph from 'src/components/layout/Paragraph'
import Row from 'src/components/layout/Row'
import { background, connected as connectedBg, lg, md, sm, warning, xs } from 'src/theme/variables'
import { upperFirst } from 'src/utils/css'
import { ETHEREUM_NETWORK } from 'src/logic/wallets/getWeb3'
import { ETHEREUM_NETWORK } from 'src/config/networks/network.d'

const dot = require('../../assets/dotRinkeby.svg')
const walletIcon = require('../../assets/wallet.svg')
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { makeStyles } from '@material-ui/core/styles'
import * as React from 'react'
import { EthHashInfo, Text } from '@gnosis.pm/safe-react-components'
import { ETHEREUM_NETWORK } from 'src/logic/wallets/getWeb3'

import { ETHEREUM_NETWORK } from 'src/config/networks/network.d'
import NetworkLabel from '../NetworkLabel'
import CircleDot from 'src/components/AppLayout/Header/components/CircleDot'
import Col from 'src/components/layout/Col'
Expand Down
5 changes: 2 additions & 3 deletions src/components/AppLayout/Sidebar/SafeHeader/index.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import React from 'react'
import { ETHEREUM_NETWORK } from 'src/logic/wallets/getWeb3'
import styled from 'styled-components'
import {
Icon,
Expand All @@ -12,7 +11,7 @@ import {
EtherscanButton,
} from '@gnosis.pm/safe-react-components'

import { getNetwork } from 'src/config'
import { getNetworkName } from 'src/config'
import FlexSpacer from 'src/components/FlexSpacer'

export const TOGGLE_SIDEBAR_BTN_TESTID = 'TOGGLE_SIDEBAR_BTN'
Expand Down Expand Up @@ -129,7 +128,7 @@ const SafeHeader = ({
<Icon size="sm" type="qrCode" tooltip="Show QR" />
</UnStyledButton>
<CopyToClipboardBtn textToCopy={address} />
<EtherscanButton value={address} network={ETHEREUM_NETWORK[getNetwork()]} />
<EtherscanButton value={address} network={getNetworkName()} />
</IconContainer>

{granted ? null : (
Expand Down
4 changes: 2 additions & 2 deletions src/components/ConnectButton/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import Onboard from 'bnc-onboard'
import React from 'react'

import Button from 'src/components/layout/Button'
import { getNetwork } from 'src/config'
import { getNetworkId } from 'src/config'
import { getWeb3, setWeb3 } from 'src/logic/wallets/getWeb3'
import { fetchProvider } from 'src/logic/wallets/store/actions'
import transactionDataCheck from 'src/logic/wallets/transactionDataCheck'
Expand All @@ -20,7 +20,7 @@ const wallets = getSupportedWallets()

export const onboard = Onboard({
dappId: BLOCKNATIVE_API_KEY,
networkId: getNetwork(),
networkId: getNetworkId(),
subscriptions: {
wallet: (wallet) => {
if (wallet.provider) {
Expand Down
5 changes: 2 additions & 3 deletions src/components/SafeListSidebar/SafeList/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,12 @@ import ListItem from '@material-ui/core/ListItem'
import { makeStyles } from '@material-ui/core/styles'
import { EthHashInfo, Icon, Text, ButtonLink } from '@gnosis.pm/safe-react-components'
import * as React from 'react'
import { ETHEREUM_NETWORK } from 'src/logic/wallets/getWeb3'
import styled from 'styled-components'

import { SafeRecord } from 'src/logic/safe/store/models/safe'
import { DefaultSafe } from 'src/routes/safe/store/reducer/types/safe'
import { SetDefaultSafe } from 'src/logic/safe/store/actions/setDefaultSafe'
import { getNetwork } from 'src/config'
import { getNetworkName } from 'src/config'
import DefaultBadge from './DefaultBadge'
import Hairline from 'src/components/layout/Hairline'
import Link from 'src/components/layout/Link'
Expand Down Expand Up @@ -115,7 +114,7 @@ const SafeList = ({ currentSafe, defaultSafe, onSafeClick, safes, setDefaultSafe
name={safe.name}
showIdenticon
shortenHash={4}
network={ETHEREUM_NETWORK[getNetwork()]}
network={getNetworkName()}
/>

<AddressDetails>
Expand Down
136 changes: 136 additions & 0 deletions src/config/__tests__/config.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,136 @@
import { ETHEREUM_NETWORK } from 'src/config/networks/network.d'
import { default as networks } from 'src/config/networks'

const { mainnet, xdai } = networks

describe('Config Services', () => {
beforeEach(() => {
jest.resetModules()
})

it(`should load 'test' network config`, () => {
// Given
jest.mock('src/utils/constants', () => ({
NODE_ENV: 'test',
}))
const { getNetworkInfo } = require('src/config')

// When
const networkInfo = getNetworkInfo()

// Then
expect(networkInfo.id).toBe(ETHEREUM_NETWORK.LOCAL)
})

it(`should load 'mainnet' network config`, () => {
// Given
jest.mock('src/utils/constants', () => ({
NODE_ENV: '',
NETWORK: 'MAINNET',
}))
const { getNetworkInfo } = require('src/config')

// When
const networkInfo = getNetworkInfo()

// Then
expect(networkInfo.id).toBe(ETHEREUM_NETWORK.MAINNET)
})

it(`should load 'mainnet.dev' network config`, () => {
// Given
jest.mock('src/utils/constants', () => ({
NODE_ENV: '',
NETWORK: 'MAINNET',
}))
const { getTxServiceUrl, getGnosisSafeAppsUrl } = require('src/config')
const TX_SERVICE_URL = mainnet.environment.dev?.txServiceUrl
const SAFE_APPS_URL = mainnet.environment.dev?.safeAppsUrl

// When
const txServiceUrl = getTxServiceUrl()
const safeAppsUrl = getGnosisSafeAppsUrl()

// Then
expect(TX_SERVICE_URL).toBe(txServiceUrl)
expect(SAFE_APPS_URL).toBe(safeAppsUrl)
})

it(`should load 'mainnet.staging' network config`, () => {
// Given
jest.mock('src/utils/constants', () => ({
NODE_ENV: 'production',
NETWORK: 'MAINNET',
}))
const { getTxServiceUrl, getGnosisSafeAppsUrl } = require('src/config')
const TX_SERVICE_URL = mainnet.environment.staging?.txServiceUrl
const SAFE_APPS_URL = mainnet.environment.staging?.safeAppsUrl

// When
const txServiceUrl = getTxServiceUrl()
const safeAppsUrl = getGnosisSafeAppsUrl()

// Then
expect(TX_SERVICE_URL).toBe(txServiceUrl)
expect(SAFE_APPS_URL).toBe(safeAppsUrl)
})

it(`should load 'mainnet.production' network config`, () => {
// Given
jest.mock('src/utils/constants', () => ({
NODE_ENV: 'production',
NETWORK: 'MAINNET',
APP_ENV: 'production'
}))
const { getTxServiceUrl, getGnosisSafeAppsUrl } = require('src/config')
const TX_SERVICE_URL = mainnet.environment.production.txServiceUrl
const SAFE_APPS_URL = mainnet.environment.production.safeAppsUrl

// When
const txServiceUrl = getTxServiceUrl()
const safeAppsUrl = getGnosisSafeAppsUrl()

// Then
expect(TX_SERVICE_URL).toBe(txServiceUrl)
expect(SAFE_APPS_URL).toBe(safeAppsUrl)
})

it(`should load 'xdai.production' network config`, () => {
// Given
jest.mock('src/utils/constants', () => ({
NODE_ENV: 'production',
NETWORK: 'XDAI',
APP_ENV: 'production'
}))
const { getTxServiceUrl, getGnosisSafeAppsUrl } = require('src/config')
const TX_SERVICE_URL = xdai.environment.production.txServiceUrl
const SAFE_APPS_URL = xdai.environment.production.safeAppsUrl

// When
const txServiceUrl = getTxServiceUrl()
const safeAppsUrl = getGnosisSafeAppsUrl()

// Then
expect(TX_SERVICE_URL).toBe(txServiceUrl)
expect(SAFE_APPS_URL).toBe(safeAppsUrl)
})

it(`should default to 'xdai.production' network config if no environment is found`, () => {
// Given
jest.mock('src/utils/constants', () => ({
NODE_ENV: '',
NETWORK: 'XDAI',
}))
const { getTxServiceUrl, getGnosisSafeAppsUrl } = require('src/config')
const TX_SERVICE_URL = xdai.environment.production.txServiceUrl
const SAFE_APPS_URL = xdai.environment.production.safeAppsUrl

// When
const txServiceUrl = getTxServiceUrl()
const safeAppsUrl = getGnosisSafeAppsUrl()

// Then
expect(TX_SERVICE_URL).toBe(txServiceUrl)
expect(SAFE_APPS_URL).toBe(safeAppsUrl)
})
})
11 changes: 0 additions & 11 deletions src/config/development-mainnet.ts

This file was deleted.

11 changes: 0 additions & 11 deletions src/config/development.ts

This file was deleted.

Loading