@@ -7,7 +7,6 @@ import Header from './components/Header';
77import { Container, Row, Col } from './components/Base';
88
99import { router } from './lib/router';
10−import { initWeb3 } from './lib/web3';
1110import { ROUTE_NAMES } from './lib/routeNames';
1211import { HistoryProvider, withHistory, useHistory } from './store/history';
1312import { TxnConfirmationsProvider } from './store/txnConfirmations';
@@ -19,13 +18,15 @@ import {
1918 addressFromSecp256k1Public,
2019} from './lib/wallet';
2120import { BRIDGE_ERROR } from './lib/error';
22−import { isLocal } from './lib/flags';
21+import { isDevelopment } from './lib/flags';
22+import { OnlineProvider } from './store/online';
23+import { NetworkProvider } from './store/network';
2324
2425// NB(shrugs): toggle this variable to use the default local state.
2526// don't commit changes to this line, but there shouldn't be a problem
2627// if you do because we'll never stub on a production build.
2728const shouldStubLocal = false;
28−const isStubbed = isLocal && shouldStubLocal;
29+const isStubbed = isDevelopment && shouldStubLocal;
2930const kInitialRoutes = isStubbed
3031 ? [
3132 { name: ROUTE_NAMES.SHIPS },
@@ -66,12 +67,6 @@ class Bridge extends React.Component {
6667 constructor(props) {
6768 super(props);
6869
69− const networkType = isLocal ? NETWORK_NAMES.LOCAL : NETWORK_NAMES.MAINNET;
70−
71− // Sidestepping full network selection to allow for point viewing,
72− // but still respecting the networkType
73− const { web3, contracts } = initWeb3(networkType);
74−
7570 // NB (jtobin):
7671 //
7772 // Note that the 'wallet' prop has type depending on the 'walletType' prop.
@@ -86,10 +81,6 @@ class Bridge extends React.Component {
8681 // 'EthereumWallet'.
8782
8883 this.state = {
89− // network
90− networkType: networkType,
91− web3: Just(web3),
92− contracts: Just(contracts),
9384 // wallet
9485 walletType: WALLET_NAMES.MNEMONIC,
9586 wallet: Nothing(),
@@ -106,8 +97,6 @@ class Bridge extends React.Component {
10697 txnConfirmations: {},
10798 };
10899
109− this.setNetworkType = this.setNetworkType.bind(this);
110− this.setNetwork = this.setNetwork.bind(this);
111100 this.setWalletType = this.setWalletType.bind(this);
112101 this.setWallet = this.setWallet.bind(this);
113102 this.setWalletHdPath = this.setWalletHdPath.bind(this);
@@ -155,13 +144,6 @@ class Bridge extends React.Component {
155144 });
156145 }
157146
158− setNetwork(web3, contracts) {
159− this.setState({
160− web3: web3,
161− contracts: contracts,
162− });
163− }
164−
165147 setWalletType(symbol) {
166148 if (includes(WALLET_NAMES, symbol)) {
167149 this.setState({
@@ -222,7 +204,6 @@ class Bridge extends React.Component {
222204
223205 render() {
224206 const {
225− networkType,
226207 walletType,
227208 walletHdPath,
228209 wallet,
@@ -233,64 +214,67 @@ class Bridge extends React.Component {
233214 pointCursor,
234215 pointCache,
235216 txnHashCursor,
236− web3,
237− contracts,
238217 } = this.state;
239218
219+ const initialNetworkType = isDevelopment
220+ ? NETWORK_NAMES.LOCAL
221+ : NETWORK_NAMES.MAINNET;
222+
240223 return (
241224 <HistoryProvider initialRoutes={kInitialRoutes}>
242225 <TxnConfirmationsProvider>
243− <Container>
244− <Row>
245− <VariableWidthColumn>
246− <Header
247− skipRoute={this.skipRoute}
248− networkType={networkType}
249− wallet={wallet}
250− pointCursor={pointCursor}
251− />
226+ <OnlineProvider>
227+ <NetworkProvider initialNetworkType={initialNetworkType}>
228+ <Container>
229+ <Row>
230+ <VariableWidthColumn>
231+ <Header
232+ skipRoute={this.skipRoute}
233+ wallet={wallet}
234+ pointCursor={pointCursor}
235+ />
252236
253− <Row className={'row wrapper'}>
254− <Router
255− // network
256− setNetworkType={this.setNetworkType}
257− setNetwork={this.setNetwork}
258− networkType={networkType}
259− web3={web3}
260− contracts={contracts}
261− // wallet
262− setWalletType={this.setWalletType}
263− setWalletHdPath={this.setWalletHdPath}
264− setWallet={this.setWallet}
265− walletType={walletType}
266− walletHdPath={walletHdPath}
267− wallet={wallet}
268− // urbit wallet
269− urbitWallet={urbitWallet}
270− setUrbitWallet={this.setUrbitWallet}
271− authMnemonic={authMnemonic}
272− setAuthMnemonic={this.setAuthMnemonic}
273− // point
274− setPointCursor={this.setPointCursor}
275− addToPointCache={this.addToPointCache}
276− pointCursor={pointCursor}
277− pointCache={pointCache}
278− networkSeedCache={networkSeedCache}
279− networkRevisionCache={networkRevisionCache}
280− setNetworkSeedCache={this.setNetworkSeedCache}
281− // txn
282− onSent={this.setTxnHashCursor}
283− setTxnHashCursor={this.setTxnHashCursor}
284− txnHashCursor={txnHashCursor}
285− />
237+ <Row className={'row wrapper'}>
238+ <Router
239+ setWalletType={
240+ this.setWalletType // wallet
241+ }
242+ setWalletHdPath={this.setWalletHdPath}
243+ setWallet={this.setWallet}
244+ walletType={walletType}
245+ walletHdPath={walletHdPath}
246+ wallet={wallet}
247+ urbitWallet={
248+ urbitWallet // urbit wallet
249+ }
250+ setUrbitWallet={this.setUrbitWallet}
251+ authMnemonic={authMnemonic}
252+ setAuthMnemonic={this.setAuthMnemonic}
253+ setPointCursor={
254+ this.setPointCursor // point
255+ }
256+ addToPointCache={this.addToPointCache}
257+ pointCursor={pointCursor}
258+ pointCache={pointCache}
259+ networkSeedCache={networkSeedCache}
260+ networkRevisionCache={networkRevisionCache}
261+ setNetworkSeedCache={this.setNetworkSeedCache}
262+ onSent={
263+ this.setTxnHashCursor // txn
264+ }
265+ setTxnHashCursor={this.setTxnHashCursor}
266+ txnHashCursor={txnHashCursor}
267+ />
286268
287− <div className={'push'} />
288− </Row>
269+ <div className={'push'} />
270+ </Row>
289271
290− <Footer />
291− </VariableWidthColumn>
292− </Row>
293− </Container>
272+ <Footer />
273+ </VariableWidthColumn>
274+ </Row>
275+ </Container>
276+ </NetworkProvider>
277+ </OnlineProvider>
294278 </TxnConfirmationsProvider>
295279 </HistoryProvider>
296280 );