diff --git a/lib/components/ens-cache-provider.react.js b/lib/components/ens-cache-provider.react.js index 8b8371c1a..cf4f88b98 100644 --- a/lib/components/ens-cache-provider.react.js +++ b/lib/components/ens-cache-provider.react.js @@ -1,35 +1,35 @@ // @flow import * as React from 'react'; import { ENSCache, type EthersProvider } from '../utils/ens-cache'; type ENSCacheContextType = { +ensCache: ?ENSCache, }; const ENSCacheContext: React.Context = React.createContext( { ensCache: undefined, }, ); type Props = { - +provider: EthersProvider, + +provider: ?EthersProvider, +children: React.Node, }; function ENSCacheProvider(props: Props): React.Node { const { provider, children } = props; const context = React.useMemo( () => ({ - ensCache: new ENSCache(provider), + ensCache: provider ? new ENSCache(provider) : null, }), [provider], ); return ( {children} ); } export { ENSCacheContext, ENSCacheProvider }; diff --git a/native/utils/ethers-utils.js b/native/utils/ethers-utils.js index 75a534904..bbc39968a 100644 --- a/native/utils/ethers-utils.js +++ b/native/utils/ethers-utils.js @@ -1,21 +1,21 @@ // @flow import '@ethersproject/shims'; import { ethers } from 'ethers'; import type { EthersProvider } from 'lib/utils/ens-cache'; let alchemyKey; try { // $FlowExpectedError: file might not exist const { key } = require('../facts/alchemy.json'); alchemyKey = key; } catch {} -const provider: EthersProvider = new ethers.providers.AlchemyProvider( - 'mainnet', - alchemyKey, -); +let provider: ?EthersProvider; +if (alchemyKey) { + provider = new ethers.providers.AlchemyProvider('mainnet', alchemyKey); +} export { provider };