Add default provider for node

This commit is contained in:
Agustin Pane 2020-06-25 08:53:27 -03:00
parent a7e69683a3
commit 7fe182db3c
3 changed files with 4 additions and 4 deletions

View File

@ -64,7 +64,7 @@ export const getInfuraUrl = () => {
export const web3ReadOnly =
process.env.NODE_ENV !== 'test'
? new Web3(new Web3.providers.HttpProvider(getInfuraUrl()))
: new Web3((window as any).web3.currentProvider)
: new Web3((window as any).web3?.currentProvider || 'ws://localhost:8545')
let web3 = web3ReadOnly
export const getWeb3 = () => web3

View File

@ -72,7 +72,7 @@ export const aMinedSafe = async (
threshold = 1,
name = 'Safe Name',
) => {
const provider = await getProviderInfo((window as any).web3.currentProvider)
const provider = await getProviderInfo((window as any).web3?.currentProvider || 'ws://localhost:8545')
const walletRecord = makeProvider(provider)
store.dispatch(addProvider(walletRecord))

View File

@ -7,7 +7,7 @@ import { ConnectedRouter } from 'connected-react-router'
import Load from 'src/routes/load/container/Load'
import { aNewStore, history, } from 'src/store'
import { sleep } from 'src/utils/timer'
import { getProviderInfo } from 'src/logic/wallets/getWeb3'
import { getProviderInfo, getWeb3 } from 'src/logic/wallets/getWeb3'
import addProvider from 'src/logic/wallets/store/actions/addProvider'
import { makeProvider } from 'src/logic/wallets/store/model/provider'
import { aMinedSafe } from './builder/safe.redux.builder'
@ -29,7 +29,7 @@ afterAll(() => {
})
const renderLoadSafe = async (localStore) => {
const provider = await getProviderInfo((window as any).web3.currentProvider)
const provider = await getProviderInfo((window as any).web3.currentProvider || 'ws://localhost:8545')
const walletRecord = makeProvider(provider)
localStore.dispatch(addProvider(walletRecord))