mirror of
https://github.com/status-im/safe-react.git
synced 2025-03-02 18:30:34 +00:00
Add util for getting all networks info
This commit is contained in:
parent
ab51fe6be4
commit
9f81e57f05
@ -19,8 +19,7 @@ import { headerHeight, md, screenSm, sm } from 'src/theme/variables'
|
|||||||
import { useStateHandler } from 'src/logic/hooks/useStateHandler'
|
import { useStateHandler } from 'src/logic/hooks/useStateHandler'
|
||||||
|
|
||||||
import SafeLogo from '../assets/gnosis-safe-multisig-logo.svg'
|
import SafeLogo from '../assets/gnosis-safe-multisig-logo.svg'
|
||||||
import { NETWORK_NAMES } from 'src/utils/constants'
|
import { getNetworkName, getNetworks } from 'src/config'
|
||||||
import { getNetworkInfo } from 'src/config'
|
|
||||||
import styled from 'styled-components'
|
import styled from 'styled-components'
|
||||||
|
|
||||||
const StyledDivider = styled(Divider)`
|
const StyledDivider = styled(Divider)`
|
||||||
@ -85,8 +84,9 @@ const styles = () => ({
|
|||||||
const Layout = ({ classes, providerDetails, providerInfo }) => {
|
const Layout = ({ classes, providerDetails, providerInfo }) => {
|
||||||
const { clickAway, open, toggle } = useStateHandler()
|
const { clickAway, open, toggle } = useStateHandler()
|
||||||
const { clickAway: clickAwayNetworks, open: openNetworks, toggle: toggleNetworks } = useStateHandler()
|
const { clickAway: clickAwayNetworks, open: openNetworks, toggle: toggleNetworks } = useStateHandler()
|
||||||
const networkInfo = getNetworkInfo()
|
const networkName = getNetworkName() // Network name to be use for comparision
|
||||||
console.log(networkInfo)
|
const networks = getNetworks()
|
||||||
|
console.log(networkName)
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Row className={classes.summary}>
|
<Row className={classes.summary}>
|
||||||
@ -138,10 +138,10 @@ const Layout = ({ classes, providerDetails, providerInfo }) => {
|
|||||||
<>
|
<>
|
||||||
<ClickAwayListener mouseEvent="onClick" onClickAway={clickAwayNetworks} touchEvent={false}>
|
<ClickAwayListener mouseEvent="onClick" onClickAway={clickAwayNetworks} touchEvent={false}>
|
||||||
<List className={classes.network} component="div">
|
<List className={classes.network} component="div">
|
||||||
{NETWORK_NAMES.map((network) => (
|
{networks.map((network) => (
|
||||||
<React.Fragment key={network.name}>
|
<React.Fragment key={network.id}>
|
||||||
<StyledLink href="#">
|
<StyledLink href={network.safeUrl}>
|
||||||
<NetworkLabel networkName={network.name} />
|
<NetworkLabel networkName={network.label} />
|
||||||
<Icon type="check" size="md" color="primary" />
|
<Icon type="check" size="md" color="primary" />
|
||||||
</StyledLink>
|
</StyledLink>
|
||||||
<StyledDivider />
|
<StyledDivider />
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
import memoize from 'lodash.memoize'
|
import memoize from 'lodash.memoize'
|
||||||
|
|
||||||
import networks from 'src/config/networks'
|
import networks from 'src/config/networks'
|
||||||
import {
|
import {
|
||||||
EnvironmentSettings,
|
EnvironmentSettings,
|
||||||
@ -68,6 +67,16 @@ const configuration = (): NetworkSpecificConfiguration => {
|
|||||||
|
|
||||||
const getConfig: () => NetworkSpecificConfiguration = ensureOnce(configuration)
|
const getConfig: () => NetworkSpecificConfiguration = ensureOnce(configuration)
|
||||||
|
|
||||||
|
export const getNetworks = (): { id: number; label: string; backgroundColor: string; safeUrl: string }[] => {
|
||||||
|
const { local, ...usefulNetworks } = networks
|
||||||
|
return Object.values(usefulNetworks).map((networkObj) => ({
|
||||||
|
id: networkObj.network.id,
|
||||||
|
label: networkObj.network.label,
|
||||||
|
backgroundColor: networkObj.network.backgroundColor,
|
||||||
|
safeUrl: networkObj.environment[getCurrentEnvironment()].safeUrl,
|
||||||
|
}))
|
||||||
|
}
|
||||||
|
|
||||||
export const getClientGatewayUrl = (): string => getConfig().clientGatewayUrl
|
export const getClientGatewayUrl = (): string => getConfig().clientGatewayUrl
|
||||||
|
|
||||||
export const getTxServiceUrl = (): string => getConfig().txServiceUrl
|
export const getTxServiceUrl = (): string => getConfig().txServiceUrl
|
||||||
|
@ -6,6 +6,7 @@ import { EnvironmentSettings, ETHEREUM_NETWORK, NetworkConfig, WALLETS } from 's
|
|||||||
const baseConfig: EnvironmentSettings = {
|
const baseConfig: EnvironmentSettings = {
|
||||||
clientGatewayUrl: 'https://safe-client.ewc.gnosis.io/v1',
|
clientGatewayUrl: 'https://safe-client.ewc.gnosis.io/v1',
|
||||||
txServiceUrl: 'https://safe-transaction.ewc.gnosis.io/api/v1',
|
txServiceUrl: 'https://safe-transaction.ewc.gnosis.io/api/v1',
|
||||||
|
safeUrl: 'https://ewc.gnosis-safe.io/app',
|
||||||
safeAppsUrl: 'https://safe-apps-ewc.staging.gnosisdev.com',
|
safeAppsUrl: 'https://safe-apps-ewc.staging.gnosisdev.com',
|
||||||
gasPriceOracle: {
|
gasPriceOracle: {
|
||||||
url: 'https://station.energyweb.org',
|
url: 'https://station.energyweb.org',
|
||||||
|
@ -5,6 +5,7 @@ const baseConfig: EnvironmentSettings = {
|
|||||||
clientGatewayUrl: 'http://localhost:8001/v1',
|
clientGatewayUrl: 'http://localhost:8001/v1',
|
||||||
txServiceUrl: 'http://localhost:8000/api/v1',
|
txServiceUrl: 'http://localhost:8000/api/v1',
|
||||||
relayApiUrl: 'https://safe-relay.staging.gnosisdev.com/api/v1',
|
relayApiUrl: 'https://safe-relay.staging.gnosisdev.com/api/v1',
|
||||||
|
safeUrl: 'http://localhost:3000/app',
|
||||||
safeAppsUrl: 'http://localhost:3002',
|
safeAppsUrl: 'http://localhost:3002',
|
||||||
gasPriceOracle: {
|
gasPriceOracle: {
|
||||||
url: 'https://ethgasstation.info/json/ethgasAPI.json',
|
url: 'https://ethgasstation.info/json/ethgasAPI.json',
|
||||||
|
@ -5,6 +5,7 @@ import { ETHGASSTATION_API_KEY } from 'src/utils/constants'
|
|||||||
const baseConfig: EnvironmentSettings = {
|
const baseConfig: EnvironmentSettings = {
|
||||||
clientGatewayUrl: 'https://safe-client.mainnet.staging.gnosisdev.com/v1',
|
clientGatewayUrl: 'https://safe-client.mainnet.staging.gnosisdev.com/v1',
|
||||||
txServiceUrl: 'https://safe-transaction.mainnet.staging.gnosisdev.com/api/v1',
|
txServiceUrl: 'https://safe-transaction.mainnet.staging.gnosisdev.com/api/v1',
|
||||||
|
safeUrl: 'https://gnosis-safe.io/app',
|
||||||
safeAppsUrl: 'https://safe-apps.dev.gnosisdev.com',
|
safeAppsUrl: 'https://safe-apps.dev.gnosisdev.com',
|
||||||
gasPriceOracle: {
|
gasPriceOracle: {
|
||||||
url: 'https://ethgasstation.info/json/ethgasAPI.json',
|
url: 'https://ethgasstation.info/json/ethgasAPI.json',
|
||||||
|
1
src/config/networks/network.d.ts
vendored
1
src/config/networks/network.d.ts
vendored
@ -88,6 +88,7 @@ export type EnvironmentSettings = GasPrice & {
|
|||||||
// TODO: Shall we keep a reference to the relay?
|
// TODO: Shall we keep a reference to the relay?
|
||||||
relayApiUrl?: string
|
relayApiUrl?: string
|
||||||
safeAppsUrl: string
|
safeAppsUrl: string
|
||||||
|
safeUrl: string
|
||||||
rpcServiceUrl: string
|
rpcServiceUrl: string
|
||||||
networkExplorerName: string
|
networkExplorerName: string
|
||||||
networkExplorerUrl: string
|
networkExplorerUrl: string
|
||||||
|
@ -5,6 +5,7 @@ import { ETHGASSTATION_API_KEY } from 'src/utils/constants'
|
|||||||
const baseConfig: EnvironmentSettings = {
|
const baseConfig: EnvironmentSettings = {
|
||||||
clientGatewayUrl: 'https://safe-client.rinkeby.staging.gnosisdev.com/v1',
|
clientGatewayUrl: 'https://safe-client.rinkeby.staging.gnosisdev.com/v1',
|
||||||
txServiceUrl: 'https://safe-transaction.rinkeby.staging.gnosisdev.com/api/v1',
|
txServiceUrl: 'https://safe-transaction.rinkeby.staging.gnosisdev.com/api/v1',
|
||||||
|
safeUrl: 'https://rinkeby.gnosis-safe.io/app',
|
||||||
safeAppsUrl: 'https://safe-apps.dev.gnosisdev.com',
|
safeAppsUrl: 'https://safe-apps.dev.gnosisdev.com',
|
||||||
gasPriceOracle: {
|
gasPriceOracle: {
|
||||||
url: `https://ethgasstation.info/json/ethgasAPI.json?api-key=${ETHGASSTATION_API_KEY}`,
|
url: `https://ethgasstation.info/json/ethgasAPI.json?api-key=${ETHGASSTATION_API_KEY}`,
|
||||||
|
@ -4,6 +4,7 @@ import { EnvironmentSettings, ETHEREUM_NETWORK, NetworkConfig, WALLETS } from 's
|
|||||||
const baseConfig: EnvironmentSettings = {
|
const baseConfig: EnvironmentSettings = {
|
||||||
clientGatewayUrl: 'https://safe-client.volta.gnosis.io/v1',
|
clientGatewayUrl: 'https://safe-client.volta.gnosis.io/v1',
|
||||||
txServiceUrl: 'https://safe-transaction.volta.gnosis.io/api/v1',
|
txServiceUrl: 'https://safe-transaction.volta.gnosis.io/api/v1',
|
||||||
|
safeUrl: 'https://volta.gnosis-safe.io/app',
|
||||||
safeAppsUrl: 'https://safe-apps-volta.staging.gnosisdev.com',
|
safeAppsUrl: 'https://safe-apps-volta.staging.gnosisdev.com',
|
||||||
gasPriceOracle: {
|
gasPriceOracle: {
|
||||||
url: 'https://station.energyweb.org',
|
url: 'https://station.energyweb.org',
|
||||||
|
@ -4,6 +4,7 @@ import { EnvironmentSettings, ETHEREUM_NETWORK, FEATURES, NetworkConfig, WALLETS
|
|||||||
const baseConfig: EnvironmentSettings = {
|
const baseConfig: EnvironmentSettings = {
|
||||||
clientGatewayUrl: 'https://safe-client.xdai.gnosis.io/v1',
|
clientGatewayUrl: 'https://safe-client.xdai.gnosis.io/v1',
|
||||||
txServiceUrl: 'https://safe-transaction.xdai.gnosis.io/api/v1',
|
txServiceUrl: 'https://safe-transaction.xdai.gnosis.io/api/v1',
|
||||||
|
safeUrl: 'https://xdai.gnosis-safe.io/app',
|
||||||
safeAppsUrl: 'https://safe-apps-xdai.staging.gnosisdev.com',
|
safeAppsUrl: 'https://safe-apps-xdai.staging.gnosisdev.com',
|
||||||
gasPrice: 1e9,
|
gasPrice: 1e9,
|
||||||
rpcServiceUrl: 'https://dai.poa.network/',
|
rpcServiceUrl: 'https://dai.poa.network/',
|
||||||
@ -14,6 +15,9 @@ const baseConfig: EnvironmentSettings = {
|
|||||||
|
|
||||||
const xDai: NetworkConfig = {
|
const xDai: NetworkConfig = {
|
||||||
environment: {
|
environment: {
|
||||||
|
dev: {
|
||||||
|
...baseConfig,
|
||||||
|
},
|
||||||
staging: {
|
staging: {
|
||||||
...baseConfig,
|
...baseConfig,
|
||||||
},
|
},
|
||||||
|
@ -35,13 +35,3 @@ export const SPENDING_LIMIT_MODULE_ADDRESS =
|
|||||||
export const KNOWN_MODULES = {
|
export const KNOWN_MODULES = {
|
||||||
[SPENDING_LIMIT_MODULE_ADDRESS]: 'Spending limit',
|
[SPENDING_LIMIT_MODULE_ADDRESS]: 'Spending limit',
|
||||||
}
|
}
|
||||||
export const NETWORK_NAMES = [
|
|
||||||
{ name: 'Ethereum', url: 'https://gnosis-safe.io/app' },
|
|
||||||
{ name: 'xDai', url: 'https://xdai.gnosis-safe.io/app' },
|
|
||||||
{ name: 'Polygon', url: 'https://polygon.gnosis-safe.io/app' },
|
|
||||||
{ name: 'BSC', url: 'https://bsc.gnosis-safe.io/app' },
|
|
||||||
{ name: 'Arbitrium', url: 'https://arbitrum.gnosis-safe.io/app' },
|
|
||||||
{ name: 'EWC', url: 'https://ewc.gnosis-safe.io/app' },
|
|
||||||
{ name: 'Rinkeby', url: 'https://rinkeby.gnosis-safe.io/app' },
|
|
||||||
{ name: 'Volta', url: 'https://volta.gnosis-safe.io/app' },
|
|
||||||
]
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user