mirror of
https://github.com/status-im/safe-react.git
synced 2025-01-12 11:04:07 +00:00
Mainnet compatibility wip
This commit is contained in:
parent
26d494fe9f
commit
e7383adc44
@ -1,5 +1,6 @@
|
|||||||
/*eslint-disable*/
|
/*eslint-disable*/
|
||||||
process.env.NODE_ENV = 'development'
|
process.env.NODE_ENV = 'development'
|
||||||
|
process.env.NETWORK = 'mainnet'
|
||||||
|
|
||||||
// Load environment variables from .env file. Suppress warnings using silent
|
// Load environment variables from .env file. Suppress warnings using silent
|
||||||
// if this file is missing. dotenv will never modify any environment variables
|
// if this file is missing. dotenv will never modify any environment variables
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
// @flow
|
// @flow
|
||||||
import { ensureOnce } from '~/utils/singleton'
|
import { ensureOnce } from '~/utils/singleton'
|
||||||
|
import { ETHEREUM_NETWORK } from '~/logic/wallets/getWeb3'
|
||||||
import { TX_SERVICE_HOST, SIGNATURES_VIA_METAMASK, RELAY_API_URL } from '~/config/names'
|
import { TX_SERVICE_HOST, SIGNATURES_VIA_METAMASK, RELAY_API_URL } from '~/config/names'
|
||||||
import devConfig from './development'
|
import devConfig from './development'
|
||||||
import testConfig from './testing'
|
import testConfig from './testing'
|
||||||
@ -18,11 +19,12 @@ const configuration = () => {
|
|||||||
|
|
||||||
return prodConfig
|
return prodConfig
|
||||||
}
|
}
|
||||||
|
console.log(process.env)
|
||||||
|
|
||||||
return devConfig
|
return devConfig
|
||||||
}
|
}
|
||||||
|
|
||||||
export const getNetwork = () => process.env.NETWORK || 'rinkeby'
|
export const getNetwork = () => (process.env.NETWORK === 'mainnet' ? ETHEREUM_NETWORK.MAIN : ETHEREUM_NETWORK.RINKEBY)
|
||||||
|
|
||||||
const getConfig = ensureOnce(configuration)
|
const getConfig = ensureOnce(configuration)
|
||||||
|
|
||||||
|
@ -33,7 +33,7 @@ export const ETHEREUM_NETWORK_IDS = {
|
|||||||
42: ETHEREUM_NETWORK.KOVAN,
|
42: ETHEREUM_NETWORK.KOVAN,
|
||||||
}
|
}
|
||||||
|
|
||||||
export const getEtherScanLink = (type: 'address' | 'tx', value: string, network: string) => `https://${network === 'mainnet' ? '' : `${network}.`}etherscan.io/${type}/${value}`
|
export const getEtherScanLink = (type: 'address' | 'tx', value: string, network: string) => `https://${network.toLowerCase() === 'mainnet' ? '' : `${network.toLowerCase()}.`}etherscan.io/${type}/${value}`
|
||||||
|
|
||||||
let web3
|
let web3
|
||||||
export const getWeb3 = () => web3 || (window.web3 && new Web3(window.web3.currentProvider)) || (window.ethereum && new Web3(window.ethereum))
|
export const getWeb3 = () => web3 || (window.web3 && new Web3(window.web3.currentProvider)) || (window.ethereum && new Web3(window.ethereum))
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
// @flow
|
// @flow
|
||||||
import type { Dispatch as ReduxDispatch } from 'redux'
|
import type { Dispatch as ReduxDispatch } from 'redux'
|
||||||
import { ETHEREUM_NETWORK_IDS, ETHEREUM_NETWORK } from '~/logic/wallets/getWeb3'
|
import { ETHEREUM_NETWORK_IDS } from '~/logic/wallets/getWeb3'
|
||||||
|
import { getNetwork } from '~/config'
|
||||||
import type { ProviderProps } from '~/logic/wallets/store/model/provider'
|
import type { ProviderProps } from '~/logic/wallets/store/model/provider'
|
||||||
import { makeProvider } from '~/logic/wallets/store/model/provider'
|
import { makeProvider } from '~/logic/wallets/store/model/provider'
|
||||||
import addProvider from './addProvider'
|
import addProvider from './addProvider'
|
||||||
@ -23,7 +24,7 @@ export const processProviderResponse = (dispatch: ReduxDispatch<*>, provider: Pr
|
|||||||
|
|
||||||
const SUCCESS_MSG = 'Wallet connected sucessfully'
|
const SUCCESS_MSG = 'Wallet connected sucessfully'
|
||||||
const UNLOCK_MSG = 'Unlock your wallet to connect'
|
const UNLOCK_MSG = 'Unlock your wallet to connect'
|
||||||
const WRONG_NETWORK = 'You are connected to wrong network. Please use RINKEBY'
|
const WRONG_NETWORK = `You are connected to wrong network. Please use ${getNetwork()}`
|
||||||
export const WALLET_ERROR_MSG = 'Error connecting to your wallet'
|
export const WALLET_ERROR_MSG = 'Error connecting to your wallet'
|
||||||
|
|
||||||
const handleProviderNotification = (openSnackbar: Function, provider: ProviderProps) => {
|
const handleProviderNotification = (openSnackbar: Function, provider: ProviderProps) => {
|
||||||
@ -34,7 +35,7 @@ const handleProviderNotification = (openSnackbar: Function, provider: ProviderPr
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ETHEREUM_NETWORK_IDS[network] !== ETHEREUM_NETWORK.RINKEBY) {
|
if (ETHEREUM_NETWORK_IDS[network] !== getNetwork()) {
|
||||||
openSnackbar(WRONG_NETWORK, 'error')
|
openSnackbar(WRONG_NETWORK, 'error')
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -183,6 +183,7 @@ class Layout extends React.Component<Props, State> {
|
|||||||
fetchTransactions={fetchTransactions}
|
fetchTransactions={fetchTransactions}
|
||||||
safeAddress={address}
|
safeAddress={address}
|
||||||
userAddress={userAddress}
|
userAddress={userAddress}
|
||||||
|
currentNetwork={network}
|
||||||
granted={granted}
|
granted={granted}
|
||||||
createTransaction={createTransaction}
|
createTransaction={createTransaction}
|
||||||
processTransaction={processTransaction}
|
processTransaction={processTransaction}
|
||||||
|
@ -39,6 +39,7 @@ type Props = {
|
|||||||
safeAddress: string,
|
safeAddress: string,
|
||||||
createTransaction: Function,
|
createTransaction: Function,
|
||||||
processTransaction: Function,
|
processTransaction: Function,
|
||||||
|
currentNetwork: string,
|
||||||
}
|
}
|
||||||
|
|
||||||
const TxsTable = ({
|
const TxsTable = ({
|
||||||
@ -51,6 +52,7 @@ const TxsTable = ({
|
|||||||
safeAddress,
|
safeAddress,
|
||||||
createTransaction,
|
createTransaction,
|
||||||
processTransaction,
|
processTransaction,
|
||||||
|
currentNetwork,
|
||||||
}: Props) => {
|
}: Props) => {
|
||||||
const [expandedTx, setExpandedTx] = useState<string | null>(null)
|
const [expandedTx, setExpandedTx] = useState<string | null>(null)
|
||||||
|
|
||||||
@ -116,6 +118,7 @@ const TxsTable = ({
|
|||||||
threshold={threshold}
|
threshold={threshold}
|
||||||
owners={owners}
|
owners={owners}
|
||||||
granted={granted}
|
granted={granted}
|
||||||
|
currentNetwork={currentNetwork}
|
||||||
userAddress={userAddress}
|
userAddress={userAddress}
|
||||||
createTransaction={createTransaction}
|
createTransaction={createTransaction}
|
||||||
processTransaction={processTransaction}
|
processTransaction={processTransaction}
|
||||||
|
@ -16,6 +16,7 @@ type Props = {
|
|||||||
granted: boolean,
|
granted: boolean,
|
||||||
createTransaction: Function,
|
createTransaction: Function,
|
||||||
processTransaction: Function,
|
processTransaction: Function,
|
||||||
|
currentNetwork: string,
|
||||||
}
|
}
|
||||||
|
|
||||||
const Transactions = ({
|
const Transactions = ({
|
||||||
@ -28,6 +29,7 @@ const Transactions = ({
|
|||||||
createTransaction,
|
createTransaction,
|
||||||
processTransaction,
|
processTransaction,
|
||||||
fetchTransactions,
|
fetchTransactions,
|
||||||
|
currentNetwork,
|
||||||
}: Props) => {
|
}: Props) => {
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
fetchTransactions(safeAddress)
|
fetchTransactions(safeAddress)
|
||||||
@ -43,6 +45,7 @@ const Transactions = ({
|
|||||||
threshold={threshold}
|
threshold={threshold}
|
||||||
owners={owners}
|
owners={owners}
|
||||||
userAddress={userAddress}
|
userAddress={userAddress}
|
||||||
|
currentNetwork={currentNetwork}
|
||||||
granted={granted}
|
granted={granted}
|
||||||
safeAddress={safeAddress}
|
safeAddress={safeAddress}
|
||||||
createTransaction={createTransaction}
|
createTransaction={createTransaction}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user