@@ -7,11 +7,10 @@ import Header from './components/Header';
7import { Container, Row, Col } from './components/Base';
7import { Container, Row, Col } from './components/Base';
9import { router } from './lib/router';
9import { router } from './lib/router';
10−import { initWeb3 } from './lib/web3';
11import { ROUTE_NAMES } from './lib/routeNames';
10import { ROUTE_NAMES } from './lib/routeNames';
12import { HistoryProvider, withHistory, useHistory } from './store/history';
11import { HistoryProvider, withHistory, useHistory } from './store/history';
13import { TxnConfirmationsProvider } from './store/txnConfirmations';
12import { TxnConfirmationsProvider } from './store/txnConfirmations';
14−import { NETWORK_NAMES } from './lib/network';
13+import { NETWORK_TYPES } from './lib/network';
16 WALLET_NAMES,
15 WALLET_NAMES,
17 DEFAULT_HD_PATH,
16 DEFAULT_HD_PATH,
@@ -19,13 +18,16 @@ import {
19 addressFromSecp256k1Public,
18 addressFromSecp256k1Public,
20} from './lib/wallet';
19} from './lib/wallet';
21import { BRIDGE_ERROR } from './lib/error';
20import { BRIDGE_ERROR } from './lib/error';
22−import { isLocal } from './lib/flags';
21+import { isDevelopment } from './lib/flags';
22+import nest from './lib/nest';
23+import { OnlineProvider } from './store/online';
24+import { NetworkProvider } from './store/network';
24// NB(shrugs): toggle this variable to use the default local state.
26// NB(shrugs): toggle this variable to use the default local state.
25// don't commit changes to this line, but there shouldn't be a problem
27// don't commit changes to this line, but there shouldn't be a problem
26// if you do because we'll never stub on a production build.
28// if you do because we'll never stub on a production build.
27const shouldStubLocal = false;
29const shouldStubLocal = false;
28−const isStubbed = isLocal && shouldStubLocal;
30+const isStubbed = isDevelopment && shouldStubLocal;
29const kInitialRoutes = isStubbed
31const kInitialRoutes = isStubbed
31 { name: ROUTE_NAMES.SHIPS },
33 { name: ROUTE_NAMES.SHIPS },
@@ -34,9 +36,12 @@ const kInitialRoutes = isStubbed
34 { name: ROUTE_NAMES.LANDING },
36 { name: ROUTE_NAMES.LANDING },
36 : [{ name: ROUTE_NAMES.LANDING }];
38 : [{ name: ROUTE_NAMES.LANDING }];
39+const kInitialNetworkType = isDevelopment
40+ ? NETWORK_TYPES.LOCAL
41+ : NETWORK_TYPES.MAINNET;
38−// the router itself is a component that renders a specific view
43+// the router itself is just a component that renders a specific view
39−// based on the latest history state
44+// depending on the history
40const Router = function(props) {
45const Router = function(props) {
41 const history = useHistory();
46 const history = useHistory();
42 const Route = router(history.peek());
47 const Route = router(history.peek());
@@ -62,16 +67,18 @@ const VariableWidthColumn = withHistory(({ history, children }) => (
70+// nest all of the providers within each other to avoid hella depth
71+const AllProviders = nest([
73+ TxnConfirmationsProvider,
65class Bridge extends React.Component {
78class Bridge extends React.Component {
66 constructor(props) {
79 constructor(props) {
67 super(props);
80 super(props);
69− const networkType = isLocal ? NETWORK_NAMES.LOCAL : NETWORK_NAMES.MAINNET;
71− // Sidestepping full network selection to allow for point viewing,
72− // but still respecting the networkType
73− const { web3, contracts } = initWeb3(networkType);
75 // NB (jtobin):
82 // NB (jtobin):
77 // Note that the 'wallet' prop has type depending on the 'walletType' prop.
84 // Note that the 'wallet' prop has type depending on the 'walletType' prop.
@@ -86,10 +93,6 @@ class Bridge extends React.Component {
86 // 'EthereumWallet'.
93 // 'EthereumWallet'.
88 this.state = {
95 this.state = {
90− networkType: networkType,
92− contracts: Just(contracts),
94 walletType: WALLET_NAMES.MNEMONIC,
97 walletType: WALLET_NAMES.MNEMONIC,
95 wallet: Nothing(),
98 wallet: Nothing(),
@@ -106,8 +109,6 @@ class Bridge extends React.Component {
106 txnConfirmations: {},
109 txnConfirmations: {},
109− this.setNetworkType = this.setNetworkType.bind(this);
110− this.setNetwork = this.setNetwork.bind(this);
111 this.setWalletType = this.setWalletType.bind(this);
112 this.setWalletType = this.setWalletType.bind(this);
112 this.setWallet = this.setWallet.bind(this);
113 this.setWallet = this.setWallet.bind(this);
113 this.setWalletHdPath = this.setWalletHdPath.bind(this);
114 this.setWalletHdPath = this.setWalletHdPath.bind(this);
@@ -138,16 +139,6 @@ class Bridge extends React.Component {
141− setNetworkType(symbol) {
142− if (includes(NETWORK_NAMES, symbol)) {
144− networkType: symbol,
147− throw BRIDGE_ERROR.INVALID_NETWORK_TYPE;
151 setNetworkSeedCache(networkSeed, revision) {
142 setNetworkSeedCache(networkSeed, revision) {
152 this.setState({
143 this.setState({
153 networkSeedCache: networkSeed,
144 networkSeedCache: networkSeed,
@@ -155,13 +146,6 @@ class Bridge extends React.Component {
158− setNetwork(web3, contracts) {
161− contracts: contracts,
165 setWalletType(symbol) {
149 setWalletType(symbol) {
166 if (includes(WALLET_NAMES, symbol)) {
150 if (includes(WALLET_NAMES, symbol)) {
167 this.setState({
151 this.setState({
@@ -222,7 +206,6 @@ class Bridge extends React.Component {
223 render() {
207 render() {
226 walletType,
209 walletType,
227 walletHdPath,
210 walletHdPath,
@@ -233,66 +216,53 @@ class Bridge extends React.Component {
233 pointCursor,
216 pointCursor,
234 pointCache,
217 pointCache,
235 txnHashCursor,
218 txnHashCursor,
238 } = this.state;
219 } = this.state;
241− <HistoryProvider initialRoutes={kInitialRoutes}>
223+ initialRoutes={kInitialRoutes}
242− <TxnConfirmationsProvider>
224+ initialNetworkType={kInitialNetworkType}>
243− <Container>
225+ <Container>
245− <VariableWidthColumn>
227+ <VariableWidthColumn>
247− skipRoute={this.skipRoute}
229+ skipRoute={this.skipRoute}
248− networkType={networkType}
230+ wallet={wallet}
231+ pointCursor={pointCursor}
234+ <Row className={'row wrapper'}>
236+ setWalletType={this.setWalletType}
237+ setWalletHdPath={this.setWalletHdPath}
238+ setWallet={this.setWallet}
239+ walletType={walletType}
240+ walletHdPath={walletHdPath}
249 wallet={wallet}
241 wallet={wallet}
242+ urbitWallet={urbitWallet}
243+ setUrbitWallet={this.setUrbitWallet}
244+ authMnemonic={authMnemonic}
245+ setAuthMnemonic={this.setAuthMnemonic}
246+ setPointCursor={this.setPointCursor}
247+ addToPointCache={this.addToPointCache}
250 pointCursor={pointCursor}
248 pointCursor={pointCursor}
249+ pointCache={pointCache}
250+ networkSeedCache={networkSeedCache}
251+ networkRevisionCache={networkRevisionCache}
252+ setNetworkSeedCache={this.setNetworkSeedCache}
253+ onSent={this.setTxnHashCursor}
254+ setTxnHashCursor={this.setTxnHashCursor}
255+ txnHashCursor={txnHashCursor}
253− <Row className={'row wrapper'}>
256− setNetworkType={this.setNetworkType}
257− setNetwork={this.setNetwork}
258− networkType={networkType}
260− contracts={contracts}
262− setWalletType={this.setWalletType}
263− setWalletHdPath={this.setWalletHdPath}
264− setWallet={this.setWallet}
265− walletType={walletType}
266− walletHdPath={walletHdPath}
269− urbitWallet={urbitWallet}
270− setUrbitWallet={this.setUrbitWallet}
271− authMnemonic={authMnemonic}
272− setAuthMnemonic={this.setAuthMnemonic}
274− setPointCursor={this.setPointCursor}
275− addToPointCache={this.addToPointCache}
276− pointCursor={pointCursor}
277− pointCache={pointCache}
278− networkSeedCache={networkSeedCache}
279− networkRevisionCache={networkRevisionCache}
280− setNetworkSeedCache={this.setNetworkSeedCache}
282− onSent={this.setTxnHashCursor}
283− setTxnHashCursor={this.setTxnHashCursor}
284− txnHashCursor={txnHashCursor}
287− <div className={'push'} />
258+ <div className={'push'} />
290− <Footer />
261+ <Footer />
291− </VariableWidthColumn>
262+ </VariableWidthColumn>
293− </Container>
264+ </Container>
294− </TxnConfirmationsProvider>
265+ </AllProviders>