on master help sign in
feat: integrate withNetwork across app where required
f412226Matt Condon (shrugs)
src/Root.js+1−1
@@ -15,7 +15,7 @@ class Root extends React.Component {
15 super(props);
15 super(props);
16
16
17 this.state = {
17 this.state = {
18− appView: 'walletgen',
18+ appView: 'bridge',
19 };
19 };
20
20
21 this.setView = this.setView.bind(this);
21 this.setView = this.setView.bind(this);
src/bridge/Bridge.js+8−9
@@ -10,7 +10,7 @@ import { router } from './lib/router';
10import { ROUTE_NAMES } from './lib/routeNames';
10import { ROUTE_NAMES } from './lib/routeNames';
11import { HistoryProvider, withHistory, useHistory } from './store/history';
11import { HistoryProvider, withHistory, useHistory } from './store/history';
12import { TxnConfirmationsProvider } from './store/txnConfirmations';
12import { TxnConfirmationsProvider } from './store/txnConfirmations';
13−import { NETWORK_NAMES } from './lib/network';
13+import { NETWORK_TYPES } from './lib/network';
14import {
14import {
15 WALLET_NAMES,
15 WALLET_NAMES,
16 DEFAULT_HD_PATH,
16 DEFAULT_HD_PATH,
@@ -36,9 +36,12 @@ const kInitialRoutes = isStubbed
36 { name: ROUTE_NAMES.LANDING },
36 { name: ROUTE_NAMES.LANDING },
37 ]
37 ]
38 : [{ name: ROUTE_NAMES.LANDING }];
38 : [{ name: ROUTE_NAMES.LANDING }];
39+const kInitialNetworkType = isDevelopment
40+ ? NETWORK_TYPES.LOCAL
41+ : NETWORK_TYPES.MAINNET;
39
42
40−// the router itself is a component that renders a specific view
43+// the router itself is just a component that renders a specific view
41−// based on the latest history state
44+// depending on the history
42const Router = function(props) {
45const Router = function(props) {
43 const history = useHistory();
46 const history = useHistory();
44 const Route = router(history.peek());
47 const Route = router(history.peek());
@@ -137,7 +140,7 @@ class Bridge extends React.Component {
137 }
140 }
138
141
139 setNetworkType(symbol) {
142 setNetworkType(symbol) {
140− if (includes(NETWORK_NAMES, symbol)) {
143+ if (includes(NETWORK_TYPES, symbol)) {
141 this.setState({
144 this.setState({
142 networkType: symbol,
145 networkType: symbol,
143 });
146 });
@@ -225,14 +228,10 @@ class Bridge extends React.Component {
225 txnHashCursor,
228 txnHashCursor,
226 } = this.state;
229 } = this.state;
227
230
228− const initialNetworkType = isDevelopment
229− ? NETWORK_NAMES.LOCAL
230− : NETWORK_NAMES.MAINNET;
231−
232 return (
231 return (
233 <AllProviders
232 <AllProviders
234 initialRoutes={kInitialRoutes}
233 initialRoutes={kInitialRoutes}
235− initialNetworkType={initialNetworkType}>
234+ initialNetworkType={kInitialNetworkType}>
236 <Container>
235 <Container>
237 <Row>
236 <Row>
238 <VariableWidthColumn>
237 <VariableWidthColumn>
src/bridge/components/Header.js+8−2
@@ -5,9 +5,16 @@ import { getRouteBreadcrumb } from '../lib/router';
5import { ROUTE_NAMES } from '../lib/routeNames';
5import { ROUTE_NAMES } from '../lib/routeNames';
6import { useHistory } from '../store/history';
6import { useHistory } from '../store/history';
7import { isLast } from '../lib/lib';
7import { isLast } from '../lib/lib';
8+import { useNetwork } from '../store/network';
9+
10+function useRouteBreadcrumbBuilder(props) {
11+ const { networkType } = useNetwork();
12+ return getRouteBreadcrumb({ ...props, networkType });
13+}
8
14
9function Crumbs(props) {
15function Crumbs(props) {
10 const history = useHistory();
16 const history = useHistory();
17+ const breadcrumbBuilder = useRouteBreadcrumbBuilder(props);
11
18
12 return (
19 return (
13 <>
20 <>
@@ -17,9 +24,8 @@ function Crumbs(props) {
17 <Button
24 <Button
18 prop-type={'link'}
25 prop-type={'link'}
19 prop-size={'sm'}
26 prop-size={'sm'}
20− key={`history-button-${idx}`}
21 onClick={() => history.pop(history.size - idx - 1)}>
27 onClick={() => history.pop(history.size - idx - 1)}>
22− {getRouteBreadcrumb(props, route)}
28+ {breadcrumbBuilder(route)}
23 </Button>
29 </Button>
24
30
25 {isLast(history.size, idx) ? (
31 {isLast(history.size, idx) ? (
src/bridge/components/StatelessTransaction.js+4−1
@@ -22,6 +22,7 @@ import {
22 signTransaction,
22 signTransaction,
23} from '../lib/txn';
23} from '../lib/txn';
24import { withTxnConfirmations } from '../store/txnConfirmations';
24import { withTxnConfirmations } from '../store/txnConfirmations';
25+import { withNetwork } from '../store/network';
25
26
26const SUBMISSION_STATES = {
27const SUBMISSION_STATES = {
27 PROMPT: 'Send transaction',
28 PROMPT: 'Send transaction',
@@ -579,4 +580,6 @@ class StatelessTransaction extends React.Component {
579 }
580 }
580}
581}
581
582
583+export default withNetwork(
582−export default withTxnConfirmations(withHistory(StatelessTransaction));
584+ withTxnConfirmations(withHistory(StatelessTransaction))
585+);
src/bridge/lib/invite.js+2−2
@@ -105,8 +105,8 @@ async function downloadWallet(paper) {
105async function startTransactions(args) {
105async function startTransactions(args) {
106 let {
106 let {
107 realPointM,
107 realPointM,
108− web3M,
108+ web3: web3M,
109− contractsM,
109+ contracts: contractsM,
110 inviteWalletM,
110 inviteWalletM,
111 realWalletM,
111 realWalletM,
112 setUrbitWallet,
112 setUrbitWallet,
src/bridge/lib/network.js+6−6
@@ -1,4 +1,4 @@
1−const NETWORK_NAMES = {
1+const NETWORK_TYPES = {
2 OFFLINE: Symbol('OFFLINE'),
2 OFFLINE: Symbol('OFFLINE'),
3 LOCAL: Symbol('LOCAL'),
3 LOCAL: Symbol('LOCAL'),
4 ROPSTEN: Symbol('ROPSTEN'),
4 ROPSTEN: Symbol('ROPSTEN'),
@@ -6,14 +6,14 @@ const NETWORK_NAMES = {
6};
6};
7
7
8const renderNetworkType = network =>
8const renderNetworkType = network =>
9− network === NETWORK_NAMES.OFFLINE
9+ network === NETWORK_TYPES.OFFLINE
10 ? 'Offline'
10 ? 'Offline'
11− : network === NETWORK_NAMES.ROPSTEN
11+ : network === NETWORK_TYPES.ROPSTEN
12 ? 'Ropsten'
12 ? 'Ropsten'
13− : network === NETWORK_NAMES.MAINNET
13+ : network === NETWORK_TYPES.MAINNET
14 ? 'Main Network'
14 ? 'Main Network'
15− : network === NETWORK_NAMES.LOCAL
15+ : network === NETWORK_TYPES.LOCAL
16 ? 'Local Node'
16 ? 'Local Node'
17 : 'Offline';
17 : 'Offline';
18
18
19−export { NETWORK_NAMES, renderNetworkType };
19+export { NETWORK_TYPES, renderNetworkType };
src/bridge/lib/router.js+7−5
@@ -67,9 +67,11 @@ const ROUTES = {
67 [ROUTE_NAMES.GEN_KEYFILE]: GenKeyfile,
67 [ROUTE_NAMES.GEN_KEYFILE]: GenKeyfile,
68};
68};
69
69
70−export const getRouteBreadcrumb = (props, route) => {
70+export const getRouteBreadcrumb = ({
71− const { wallet, networkType } = props;
71+ networkType,
72−
72+ wallet,
73+ pointCursor,
74+}) => route => {
73 switch (route.name) {
75 switch (route.name) {
74 case ROUTE_NAMES.INVITE_TICKET:
76 case ROUTE_NAMES.INVITE_TICKET:
75 return 'Invite code';
77 return 'Invite code';
@@ -80,7 +82,7 @@ export const getRouteBreadcrumb = (props, route) => {
80 case ROUTE_NAMES.INVITES_MANAGE:
82 case ROUTE_NAMES.INVITES_MANAGE:
81 return 'Manage invites';
83 return 'Manage invites';
82 case ROUTE_NAMES.NETWORK:
84 case ROUTE_NAMES.NETWORK:
83− return `${renderNetworkType(networkType)}`;
85+ return renderNetworkType(networkType);
84 case ROUTE_NAMES.WALLET:
86 case ROUTE_NAMES.WALLET:
85 return wallet.matchWith({
87 return wallet.matchWith({
86 Nothing: () => 'Wallet',
88 Nothing: () => 'Wallet',
@@ -110,7 +112,7 @@ export const getRouteBreadcrumb = (props, route) => {
110 case ROUTE_NAMES.VIEW_SHIP:
112 case ROUTE_NAMES.VIEW_SHIP:
111 return 'View';
113 return 'View';
112 case ROUTE_NAMES.SHIP:
114 case ROUTE_NAMES.SHIP:
113− return ob.patp(need.pointCursor(props));
115+ return ob.patp(need.pointCursor({ pointCursor }));
114 case ROUTE_NAMES.SET_TRANSFER_PROXY:
116 case ROUTE_NAMES.SET_TRANSFER_PROXY:
115 case ROUTE_NAMES.SET_MANAGEMENT_PROXY:
117 case ROUTE_NAMES.SET_MANAGEMENT_PROXY:
116 case ROUTE_NAMES.SET_SPAWN_PROXY:
118 case ROUTE_NAMES.SET_SPAWN_PROXY:
src/bridge/lib/txn.js+4−4
@@ -4,7 +4,7 @@ import Tx from 'ethereumjs-tx';
4import { toWei, fromWei, toHex } from 'web3-utils';
4import { toWei, fromWei, toHex } from 'web3-utils';
5
5
6import { BRIDGE_ERROR } from '../lib/error';
6import { BRIDGE_ERROR } from '../lib/error';
7−import { NETWORK_NAMES } from '../lib/network';
7+import { NETWORK_TYPES } from '../lib/network';
8import { ledgerSignTransaction } from '../lib/ledger';
8import { ledgerSignTransaction } from '../lib/ledger';
9import { trezorSignTransaction } from '../lib/trezor';
9import { trezorSignTransaction } from '../lib/trezor';
10import { WALLET_NAMES, addHexPrefix } from '../lib/wallet';
10import { WALLET_NAMES, addHexPrefix } from '../lib/wallet';
@@ -90,9 +90,9 @@ const signTransaction = async config => {
90 };
90 };
91
91
92 const defaultEip155Networks = [
92 const defaultEip155Networks = [
93− NETWORK_NAMES.MAINNET,
93+ NETWORK_TYPES.MAINNET,
94− NETWORK_NAMES.ROPSTEN,
94+ NETWORK_TYPES.ROPSTEN,
95− NETWORK_NAMES.OFFLINE,
95+ NETWORK_TYPES.OFFLINE,
96 ];
96 ];
97
97
98 const needEip155Params =
98 const needEip155Params =
src/bridge/store/network.js+5−5
@@ -10,14 +10,14 @@ import Web3 from 'web3';
10import Maybe from 'folktale/maybe';
10import Maybe from 'folktale/maybe';
11
11
12import { CONTRACT_ADDRESSES } from '../lib/contracts';
12import { CONTRACT_ADDRESSES } from '../lib/contracts';
13−import { NETWORK_NAMES } from '../lib/network';
13+import { NETWORK_TYPES } from '../lib/network';
14import { isDevelopment } from '../lib/flags';
14import { isDevelopment } from '../lib/flags';
15
15
16function _useNetwork(initialNetworkType = null) {
16function _useNetwork(initialNetworkType = null) {
17 const [networkType, setNetworkType] = useState(initialNetworkType);
17 const [networkType, setNetworkType] = useState(initialNetworkType);
18
18
19 const { web3, contracts } = useMemo(() => {
19 const { web3, contracts } = useMemo(() => {
20− if (networkType === NETWORK_NAMES.LOCAL) {
20+ if (networkType === NETWORK_TYPES.LOCAL) {
21 const protocol = isDevelopment ? 'ws' : 'wss';
21 const protocol = isDevelopment ? 'ws' : 'wss';
22 const endpoint = `${protocol}://localhost:8545`;
22 const endpoint = `${protocol}://localhost:8545`;
23 const provider = new Web3.providers.WebsocketProvider(endpoint);
23 const provider = new Web3.providers.WebsocketProvider(endpoint);
@@ -27,7 +27,7 @@ function _useNetwork(initialNetworkType = null) {
27 return { web3: Maybe.Just(web3), contracts: Maybe.Just(contracts) };
27 return { web3: Maybe.Just(web3), contracts: Maybe.Just(contracts) };
28 }
28 }
29
29
30− if (networkType === NETWORK_NAMES.ROPSTEN) {
30+ if (networkType === NETWORK_TYPES.ROPSTEN) {
31 const endpoint = `https://ropsten.infura.io/v3/${process.env.REACT_APP_INFURA_ENDPOINT}`;
31 const endpoint = `https://ropsten.infura.io/v3/${process.env.REACT_APP_INFURA_ENDPOINT}`;
32
32
33 const provider = new Web3.providers.HttpProvider(endpoint);
33 const provider = new Web3.providers.HttpProvider(endpoint);
@@ -37,7 +37,7 @@ function _useNetwork(initialNetworkType = null) {
37 return { web3: Maybe.Just(web3), contracts: Maybe.Just(contracts) };
37 return { web3: Maybe.Just(web3), contracts: Maybe.Just(contracts) };
38 }
38 }
39
39
40− if (networkType === NETWORK_NAMES.MAINNET) {
40+ if (networkType === NETWORK_TYPES.MAINNET) {
41 const endpoint = `https://mainnet.infura.io/v3/${process.env.REACT_APP_INFURA_ENDPOINT}`;
41 const endpoint = `https://mainnet.infura.io/v3/${process.env.REACT_APP_INFURA_ENDPOINT}`;
42
42
43 const provider = new Web3.providers.HttpProvider(endpoint);
43 const provider = new Web3.providers.HttpProvider(endpoint);
@@ -47,7 +47,7 @@ function _useNetwork(initialNetworkType = null) {
47 return { web3: Maybe.Just(web3), contracts: Maybe.Just(contracts) };
47 return { web3: Maybe.Just(web3), contracts: Maybe.Just(contracts) };
48 }
48 }
49
49
50− if (networkType === NETWORK_NAMES.OFFLINE) {
50+ if (networkType === NETWORK_TYPES.OFFLINE) {
51 // NB (jtobin):
51 // NB (jtobin):
52 //
52 //
53 // The 'offline' network type targets the mainnet contracts, but does not
53 // The 'offline' network type targets the mainnet contracts, but does not
src/bridge/views/AcceptTransfer.js+6−5
@@ -12,8 +12,9 @@ import * as ob from 'urbit-ob';
12import * as need from '../lib/need';
12import * as need from '../lib/need';
13
13
14import StatelessTransaction from '../components/StatelessTransaction';
14import StatelessTransaction from '../components/StatelessTransaction';
15−import { NETWORK_NAMES } from '../lib/network';
15+import { NETWORK_TYPES } from '../lib/network';
16import { isValidAddress } from '../lib/wallet';
16import { isValidAddress } from '../lib/wallet';
17+import { withNetwork } from '../store/network';
17
18
18class AcceptTransfer extends React.Component {
19class AcceptTransfer extends React.Component {
19 constructor(props) {
20 constructor(props) {
@@ -61,11 +62,11 @@ class AcceptTransfer extends React.Component {
61 const canGenerate = validAddress === true;
62 const canGenerate = validAddress === true;
62
63
63 const esvisible =
64 const esvisible =
64− props.networkType === NETWORK_NAMES.ROPSTEN ||
65+ props.networkType === NETWORK_TYPES.ROPSTEN ||
65− props.networkType === NETWORK_NAMES.MAINNET;
66+ props.networkType === NETWORK_TYPES.MAINNET;
66
67
67 const esdomain =
68 const esdomain =
68− props.networkType === NETWORK_NAMES.ROPSTEN
69+ props.networkType === NETWORK_TYPES.ROPSTEN
69 ? 'ropsten.etherscan.io'
70 ? 'ropsten.etherscan.io'
70 : 'etherscan.io';
71 : 'etherscan.io';
71
72
@@ -117,4 +118,4 @@ class AcceptTransfer extends React.Component {
117 }
118 }
118}
119}
119
120
120−export default AcceptTransfer;
121+export default withNetwork(AcceptTransfer);
src/bridge/views/CancelTransfer.js+2−1
@@ -7,6 +7,7 @@ import * as need from '../lib/need';
7
7
8import StatelessTransaction from '../components/StatelessTransaction';
8import StatelessTransaction from '../components/StatelessTransaction';
9import { ETH_ZERO_ADDR } from '../lib/wallet';
9import { ETH_ZERO_ADDR } from '../lib/wallet';
10+import { withNetwork } from '../store/network';
10
11
11class CancelTransfer extends React.Component {
12class CancelTransfer extends React.Component {
12 constructor(props) {
13 constructor(props) {
@@ -73,4 +74,4 @@ class CancelTransfer extends React.Component {
73 }
74 }
74}
75}
75
76
76−export default CancelTransfer;
77+export default withNetwork(CancelTransfer);
src/bridge/views/CreateGalaxy.js+6−5
@@ -15,12 +15,13 @@ import {
15} from '../components/Base';
15} from '../components/Base';
16import StatelessTransaction from '../components/StatelessTransaction';
16import StatelessTransaction from '../components/StatelessTransaction';
17
17
18−import { NETWORK_NAMES } from '../lib/network';
18+import { NETWORK_TYPES } from '../lib/network';
19import { canDecodePatp } from '../lib/txn';
19import { canDecodePatp } from '../lib/txn';
20
20
21import { ETH_ZERO_ADDR, isValidAddress, eqAddr } from '../lib/wallet';
21import { ETH_ZERO_ADDR, isValidAddress, eqAddr } from '../lib/wallet';
22
22
23import { isValidGalaxy } from '../lib/lib';
23import { isValidGalaxy } from '../lib/lib';
24+import { withNetwork } from '../store/network';
24
25
25const buttonTriState = status => {
26const buttonTriState = status => {
26 if (status === null) return 'blue';
27 if (status === null) return 'blue';
@@ -117,11 +118,11 @@ class CreateGalaxy extends React.Component {
117 state.isAvailable === true;
118 state.isAvailable === true;
118
119
119 const esvisible =
120 const esvisible =
120− props.networkType === NETWORK_NAMES.ROPSTEN ||
121+ props.networkType === NETWORK_TYPES.ROPSTEN ||
121− props.networkType === NETWORK_NAMES.MAINNET;
122+ props.networkType === NETWORK_TYPES.MAINNET;
122
123
123 const esdomain =
124 const esdomain =
124− props.networkType === NETWORK_NAMES.ROPSTEN
125+ props.networkType === NETWORK_TYPES.ROPSTEN
125 ? 'ropsten.etherscan.io'
126 ? 'ropsten.etherscan.io'
126 : 'etherscan.io';
127 : 'etherscan.io';
127
128
@@ -194,4 +195,4 @@ class CreateGalaxy extends React.Component {
194 }
195 }
195}
196}
196
197
197−export default CreateGalaxy;
198+export default withNetwork(CreateGalaxy);
src/bridge/views/InviteTicket.js+4−3
@@ -28,6 +28,7 @@ import {
28 TRANSACTION_STATES,
28 TRANSACTION_STATES,
29} from '../lib/invite';
29} from '../lib/invite';
30import { generateWallet, startTransactions } from '../lib/invite';
30import { generateWallet, startTransactions } from '../lib/invite';
31+import { withNetwork } from '../store/network';
31
32
32class InviteTicket extends React.Component {
33class InviteTicket extends React.Component {
33 constructor(props) {
34 constructor(props) {
@@ -305,8 +306,8 @@ class InviteTicket extends React.Component {
305 realWalletM: realWallet,
306 realWalletM: realWallet,
306 realPointM: realPoint,
307 realPointM: realPoint,
307 realTicket: verifyTicket,
308 realTicket: verifyTicket,
308− web3M: web3,
309+ web3,
309− contractsM: contracts,
310+ contracts,
310 setUrbitWallet,
311 setUrbitWallet,
311 updateProgress: this.updateProgress,
312 updateProgress: this.updateProgress,
312 }).then(() => {
313 }).then(() => {
@@ -422,4 +423,4 @@ class InviteTicket extends React.Component {
422 }
423 }
423}
424}
424
425
425−export default withHistory(InviteTicket);
426+export default withNetwork(withHistory(InviteTicket));
src/bridge/views/InvitesManage.js+2−1
@@ -14,6 +14,7 @@ import {
14 ValidatedSigil,
14 ValidatedSigil,
15} from '../components/Base';
15} from '../components/Base';
16import StatelessTransaction from '../components/StatelessTransaction';
16import StatelessTransaction from '../components/StatelessTransaction';
17+import { withNetwork } from '../store/network';
17
18
18class InvitesManage extends React.Component {
19class InvitesManage extends React.Component {
19 constructor(props) {
20 constructor(props) {
@@ -182,4 +183,4 @@ class InvitesManage extends React.Component {
182 }
183 }
183}
184}
184
185
185−export default InvitesManage;
186+export default withNetwork(InvitesManage);
src/bridge/views/InvitesSend.js+2−1
@@ -19,6 +19,7 @@ import {
19 toWei,
19 toWei,
20} from '../lib/txn';
20} from '../lib/txn';
21import * as tank from '../lib/tank';
21import * as tank from '../lib/tank';
22+import { withNetwork } from '../store/network';
22
23
23const GAS_PRICE_GWEI = 20; // we pay the premium for faster ux
24const GAS_PRICE_GWEI = 20; // we pay the premium for faster ux
24const GAS_LIMIT = 350000;
25const GAS_LIMIT = 350000;
@@ -491,4 +492,4 @@ class InvitesSend extends React.Component {
491 }
492 }
492}
493}
493
494
494−export default InvitesSend;
495+export default withNetwork(InvitesSend);
src/bridge/views/IssueChild.js+6−5
@@ -19,11 +19,12 @@ import {
19
19
20import StatelessTransaction from '../components/StatelessTransaction';
20import StatelessTransaction from '../components/StatelessTransaction';
21
21
22−import { NETWORK_NAMES } from '../lib/network';
22+import { NETWORK_TYPES } from '../lib/network';
23import { getSpawnCandidate } from '../lib/child';
23import { getSpawnCandidate } from '../lib/child';
24import { canDecodePatp } from '../lib/txn';
24import { canDecodePatp } from '../lib/txn';
25
25
26import { isValidAddress } from '../lib/wallet';
26import { isValidAddress } from '../lib/wallet';
27+import { withNetwork } from '../store/network';
27
28
28const setFind = (set, pred) => {
29const setFind = (set, pred) => {
29 for (const e of set) {
30 for (const e of set) {
@@ -151,11 +152,11 @@ class IssueChild extends React.Component {
151 });
152 });
152
153
153 const esvisible =
154 const esvisible =
154− props.networkType === NETWORK_NAMES.ROPSTEN ||
155+ props.networkType === NETWORK_TYPES.ROPSTEN ||
155− props.networkType === NETWORK_NAMES.MAINNET;
156+ props.networkType === NETWORK_TYPES.MAINNET;
156
157
157 const esdomain =
158 const esdomain =
158− props.networkType === NETWORK_NAMES.ROPSTEN
159+ props.networkType === NETWORK_TYPES.ROPSTEN
159 ? 'ropsten.etherscan.io'
160 ? 'ropsten.etherscan.io'
160 : 'etherscan.io';
161 : 'etherscan.io';
161
162
@@ -253,4 +254,4 @@ class IssueChild extends React.Component {
253 }
254 }
254}
255}
255
256
256−export default IssueChild;
257+export default withNetwork(IssueChild);
src/bridge/views/Network.js+5−5
@@ -3,7 +3,7 @@ import React from 'react';
3import { Button } from '../components/Base';
3import { Button } from '../components/Base';
4import { InnerLabelDropdown } from '../components/Base';
4import { InnerLabelDropdown } from '../components/Base';
5import { Row, Col, H1, P } from '../components/Base';
5import { Row, Col, H1, P } from '../components/Base';
6−import { NETWORK_NAMES, renderNetworkType } from '../lib/network';
6+import { NETWORK_TYPES, renderNetworkType } from '../lib/network';
7import { ROUTE_NAMES } from '../lib/routeNames';
7import { ROUTE_NAMES } from '../lib/routeNames';
8import { useHistory } from '../store/history';
8import { useHistory } from '../store/history';
9import { useNetwork } from '../store/network';
9import { useNetwork } from '../store/network';
@@ -11,22 +11,22 @@ import { useNetwork } from '../store/network';
11const kNetworkOptions = [
11const kNetworkOptions = [
12 {
12 {
13 title: 'Main Network (default)',
13 title: 'Main Network (default)',
14− value: NETWORK_NAMES.MAINNET,
14+ value: NETWORK_TYPES.MAINNET,
15 },
15 },
16 {
16 {
17 title: 'Local Node',
17 title: 'Local Node',
18− value: NETWORK_NAMES.LOCAL,
18+ value: NETWORK_TYPES.LOCAL,
19 },
19 },
20 {
20 {
21 title: 'Ropsten',
21 title: 'Ropsten',
22− value: NETWORK_NAMES.ROPSTEN,
22+ value: NETWORK_TYPES.ROPSTEN,
23 },
23 },
24 {
24 {
25 type: 'divider',
25 type: 'divider',
26 },
26 },
27 {
27 {
28 title: 'Offline',
28 title: 'Offline',
29− value: NETWORK_NAMES.OFFLINE,
29+ value: NETWORK_TYPES.OFFLINE,
30 },
30 },
31];
31];
32
32
src/bridge/views/Point.js+2−1
@@ -11,6 +11,7 @@ import KeysAndMetadata from './Point/KeysAndMetadata';
11import Actions from './Point/Actions';
11import Actions from './Point/Actions';
12import { Row, Col, H1, H3 } from '../components/Base';
12import { Row, Col, H1, H3 } from '../components/Base';
13import { withHistory } from '../store/history';
13import { withHistory } from '../store/history';
14+import { withNetwork } from '../store/network';
14
15
15class Point extends React.Component {
16class Point extends React.Component {
16 constructor(props) {
17 constructor(props) {
@@ -135,4 +136,4 @@ class Point extends React.Component {
135 }
136 }
136}
137}
137
138
138−export default withHistory(Point);
139+export default withNetwork(withHistory(Point));
src/bridge/views/Points.js+4−3
@@ -4,10 +4,11 @@ import { Button } from '../components/Base';
4import * as azimuth from 'azimuth-js';
4import * as azimuth from 'azimuth-js';
5
5
6import PointList from '../components/PointList';
6import PointList from '../components/PointList';
7−import { NETWORK_NAMES } from '../lib/network';
7+import { NETWORK_TYPES } from '../lib/network';
8import { ROUTE_NAMES } from '../lib/routeNames';
8import { ROUTE_NAMES } from '../lib/routeNames';
9import { withHistory } from '../store/history';
9import { withHistory } from '../store/history';
10import { ETH_ZERO_ADDR, eqAddr } from '../lib/wallet';
10import { ETH_ZERO_ADDR, eqAddr } from '../lib/wallet';
11+import { withNetwork } from '../store/network';
11
12
12const hasTransferProxy = (cache, point) =>
13const hasTransferProxy = (cache, point) =>
13 point in cache ? !eqAddr(cache[point].transferProxy, ETH_ZERO_ADDR) : false;
14 point in cache ? !eqAddr(cache[point].transferProxy, ETH_ZERO_ADDR) : false;
@@ -17,7 +18,7 @@ class Points extends React.Component {
17 super(props);
18 super(props);
18
19
19 const { networkType } = props;
20 const { networkType } = props;
20− const loading = networkType !== NETWORK_NAMES.OFFLINE;
21+ const loading = networkType !== NETWORK_TYPES.OFFLINE;
21
22
22 this.state = {
23 this.state = {
23 points: [],
24 points: [],
@@ -255,4 +256,4 @@ class Points extends React.Component {
255 }
256 }
256}
257}
257
258
258−export default withHistory(Points);
259+export default withNetwork(withHistory(Points));
src/bridge/views/SentTransaction.js+15−10
@@ -7,8 +7,9 @@ import { Button } from '../components/Base';
7import { ROUTE_NAMES } from '../lib/routeNames';
7import { ROUTE_NAMES } from '../lib/routeNames';
8import { useHistory } from '../store/history';
8import { useHistory } from '../store/history';
9import { BRIDGE_ERROR, renderTxnError } from '../lib/error';
9import { BRIDGE_ERROR, renderTxnError } from '../lib/error';
10−import { NETWORK_NAMES } from '../lib/network';
10+import { NETWORK_TYPES } from '../lib/network';
11−import { withTxnConfirmations } from '../store/txnConfirmations';
11+import { useTxnConfirmations } from '../store/txnConfirmations';
12+import { useNetwork } from '../store/network';
12
13
13class Success extends React.Component {
14class Success extends React.Component {
14 constructor(props) {
15 constructor(props) {
@@ -39,11 +40,11 @@ class Success extends React.Component {
39 const { pending } = state;
40 const { pending } = state;
40
41
41 const esvisible =
42 const esvisible =
42− networkType === NETWORK_NAMES.ROPSTEN ||
43+ networkType === NETWORK_TYPES.ROPSTEN ||
43− networkType === NETWORK_NAMES.MAINNET;
44+ networkType === NETWORK_TYPES.MAINNET;
44
45
45 const esdomain =
46 const esdomain =
46− networkType === NETWORK_NAMES.ROPSTEN
47+ networkType === NETWORK_TYPES.ROPSTEN
47 ? 'ropsten.etherscan.io'
48 ? 'ropsten.etherscan.io'
48 : 'etherscan.io';
49 : 'etherscan.io';
49
50
@@ -109,14 +110,18 @@ const Failure = props => (
109 </Row>
110 </Row>
110);
111);
111
112
112−const SentTransaction = props => {
113+function SentTransaction(props) {
113 const history = useHistory();
114 const history = useHistory();
115+ const { txnConfirmations } = useTxnConfirmations();
116+ const { web3 } = useNetwork();
117+
114− const { txnHashCursor, networkType, txnConfirmations } = props;
118+ const { txnHashCursor, networkType } = props;
115 const { setPointCursor, pointCursor } = props;
119 const { setPointCursor, pointCursor } = props;
116
120
117 const promptKeyfile = history.data && history.data.promptKeyfile;
121 const promptKeyfile = history.data && history.data.promptKeyfile;
118
122
123+ // TODO: remove need's assumption about accepting the props object
119− const w3 = need.web3(props);
124+ const w3 = need.web3({ web3 });
120
125
121 const result = txnHashCursor.matchWith({
126 const result = txnHashCursor.matchWith({
122 Nothing: _ => {
127 Nothing: _ => {
@@ -174,6 +179,6 @@ const SentTransaction = props => {
174 {keyfile}
179 {keyfile}
175 </div>
180 </div>
176 );
181 );
177−};
182+}
178
183
179−export default withTxnConfirmations(SentTransaction);
184+export default SentTransaction;
src/bridge/views/SetKeys.js+2−1
@@ -11,6 +11,7 @@ import { attemptSeedDerivation } from '../lib/keys';
11import * as kg from 'urbit-key-generation/dist/index';
11import * as kg from 'urbit-key-generation/dist/index';
12
12
13import { addHexPrefix } from '../lib/wallet';
13import { addHexPrefix } from '../lib/wallet';
14+import { withNetwork } from '../store/network';
14
15
15class SetKeys extends React.Component {
16class SetKeys extends React.Component {
16 constructor(props) {
17 constructor(props) {
@@ -196,4 +197,4 @@ class SetKeys extends React.Component {
196 }
197 }
197}
198}
198
199
199−export default SetKeys;
200+export default withNetwork(SetKeys);
src/bridge/views/SetProxy.js+19−18
@@ -17,25 +17,14 @@ import * as ob from 'urbit-ob';
17
17
18import { PROXY_TYPE, renderProxyType } from '../lib/proxy';
18import { PROXY_TYPE, renderProxyType } from '../lib/proxy';
19
19
20−import { NETWORK_NAMES } from '../lib/network';
20+import { NETWORK_TYPES } from '../lib/network';
21
21
22import StatelessTransaction from '../components/StatelessTransaction';
22import StatelessTransaction from '../components/StatelessTransaction';
23
23
24import { isValidAddress } from '../lib/wallet';
24import { isValidAddress } from '../lib/wallet';
25+import { withNetwork } from '../store/network';
25
26
26−const SetManagementProxy = props => (
27− <SetProxy {...props} proxyType={PROXY_TYPE.MANAGEMENT_PROXY} />
28−);
29−
30−const SetSpawnProxy = props => (
31− <SetProxy {...props} proxyType={PROXY_TYPE.SPAWN_PROXY} />
32−);
33−
34−const SetTransferProxy = props => (
35− <SetProxy {...props} proxyType={PROXY_TYPE.TRANSFER_PROXY} />
36−);
37−
38−class SetProxy extends React.Component {
27+class _SetProxy extends React.Component {
39 constructor(props) {
28 constructor(props) {
40 super(props);
29 super(props);
41
30
@@ -99,11 +88,11 @@ class SetProxy extends React.Component {
99 const canGenerate = validAddress === true;
88 const canGenerate = validAddress === true;
100
89
101 const esvisible =
90 const esvisible =
102− props.networkType === NETWORK_NAMES.ROPSTEN ||
91+ props.networkType === NETWORK_TYPES.ROPSTEN ||
103− props.networkType === NETWORK_NAMES.MAINNET;
92+ props.networkType === NETWORK_TYPES.MAINNET;
104
93
105 const esdomain =
94 const esdomain =
106− props.networkType === NETWORK_NAMES.ROPSTEN
95+ props.networkType === NETWORK_TYPES.ROPSTEN
107 ? 'ropsten.etherscan.io'
96 ? 'ropsten.etherscan.io'
108 : 'etherscan.io';
97 : 'etherscan.io';
109
98
@@ -179,4 +168,16 @@ class SetProxy extends React.Component {
179 }
168 }
180}
169}
181
170
171+const SetProxy = withNetwork(_SetProxy);
172+
182−export { SetManagementProxy, SetSpawnProxy, SetTransferProxy };
173+export const SetManagementProxy = props => (
174+ <SetProxy {...props} proxyType={PROXY_TYPE.MANAGEMENT_PROXY} />
175+);
176+
177+export const SetSpawnProxy = props => (
178+ <SetProxy {...props} proxyType={PROXY_TYPE.SPAWN_PROXY} />
179+);
180+
181+export const SetTransferProxy = props => (
182+ <SetProxy {...props} proxyType={PROXY_TYPE.TRANSFER_PROXY} />
183+);
src/bridge/views/Transfer.js+6−5
@@ -16,9 +16,10 @@ import {
16import { AddressInput } from '../components/Base';
16import { AddressInput } from '../components/Base';
17import StatelessTransaction from '../components/StatelessTransaction';
17import StatelessTransaction from '../components/StatelessTransaction';
18
18
19−import { NETWORK_NAMES } from '../lib/network';
19+import { NETWORK_TYPES } from '../lib/network';
20
20
21import { isValidAddress } from '../lib/wallet';
21import { isValidAddress } from '../lib/wallet';
22+import { withNetwork } from '../store/network';
22
23
23class Transfer extends React.Component {
24class Transfer extends React.Component {
24 constructor(props) {
25 constructor(props) {
@@ -70,11 +71,11 @@ class Transfer extends React.Component {
70 const canGenerate = validAddress === true;
71 const canGenerate = validAddress === true;
71
72
72 const esvisible =
73 const esvisible =
73− props.networkType === NETWORK_NAMES.ROPSTEN ||
74+ props.networkType === NETWORK_TYPES.ROPSTEN ||
74− props.networkType === NETWORK_NAMES.MAINNET;
75+ props.networkType === NETWORK_TYPES.MAINNET;
75
76
76 const esdomain =
77 const esdomain =
77− props.networkType === NETWORK_NAMES.ROPSTEN
78+ props.networkType === NETWORK_TYPES.ROPSTEN
78 ? 'ropsten.etherscan.io'
79 ? 'ropsten.etherscan.io'
79 : 'etherscan.io';
80 : 'etherscan.io';
80
81
@@ -130,4 +131,4 @@ class Transfer extends React.Component {
130 }
131 }
131}
132}
132
133
133−export default Transfer;
134+export default withNetwork(Transfer);
src/walletgen/Walletgen.js+2
@@ -18,6 +18,8 @@ import Download from './views/Download';
18import Done from './views/Done';
18import Done from './views/Done';
19
19
20import './style/index.css';
20import './style/index.css';
21+
22+// TODO: actually merge these two projects into one
21import { OnlineProvider } from '../bridge/store/online';
23import { OnlineProvider } from '../bridge/store/online';
22
24
23const ROUTES = [
25const ROUTES = [