on master help sign in
fix: minor updates from PR comments
commitb16048ced03e4bbd2d6f512abf33f0fd5d44fb64 authorMatt Condon (shrugs) <mattgcondon@gmail.com> dateWed 17 Jul 2019, 14:53 (7 years ago) parentee32cc5
5 files changed+19−79
src/components/old/StatelessTransaction.js+1−3 src/store/Provider.js−2 src/store/txnConfirmations.js−44 src/views/Admin/Reticket/ReticketExecute.js+15−17 src/views/SentTransaction.js+3−13
src/components/old/StatelessTransaction.js+1−3
@@ -22,7 +22,6 @@ import {
2222 signTransaction,
2323} from '../../lib/txn';
2424
25−import { withTxnConfirmations } from '../../store/txnConfirmations';
2625import { withNetwork } from '../../store/network';
2726import { withHistory } from '../../store/history';
2827import { withWallet } from '../../store/wallet';
@@ -233,7 +232,7 @@ class StatelessTransaction extends React.Component {
233232 } else {
234233 this.setState({ txStatus: SUBMISSION_STATES.SENDING });
235234
236− sendSignedTransaction(web3, stx, usedTank, props.setTxnConfirmations)
235+ sendSignedTransaction(web3, stx, usedTank)
237236 .then(txHash => {
238237 props.setTxnCursor(Just(Ok(txHash)));
239238
@@ -592,7 +591,6 @@ class StatelessTransaction extends React.Component {
592591
593592export default compose(
594593 withNetwork,
595− withTxnConfirmations,
596594 withHistory,
597595 withWallet,
598596 withTxnCursor
src/store/Provider.js−2
@@ -1,7 +1,6 @@
11import nest from 'lib/nest';
22
33import { HistoryProvider } from './history';
4−import { TxnConfirmationsProvider } from './txnConfirmations';
54import { OnlineProvider } from './online';
65import { NetworkProvider } from './network';
76import { WalletProvider } from './wallet';
@@ -16,7 +15,6 @@ export default nest([
1615 OnlineProvider,
1716 NetworkProvider,
1817 WalletProvider,
19− TxnConfirmationsProvider,
2018 PointCursorProvider,
2119 PointCacheProvider,
2220 TxnCursorProvider,
src/store/txnConfirmations.jsdeleted−44
@@ -1,44 +0,0 @@
1−import React, { createContext, forwardRef, useContext, useState } from 'react';
2−
3−export const TxnConfirmationsContext = createContext(null);
4−
5−function _useTxnConfirmations() {
6− const [confirmations, setConfirmations] = useState({});
7−
8− const setTxnConfirmations = (txnHash, txnConfirmations) => {
9− setConfirmations({
10− ...confirmations,
11− [txnHash]: txnConfirmations,
12− });
13− };
14−
15− return {
16− txnConfirmations: confirmations,
17− setTxnConfirmations,
18− };
19−}
20−
21−export function TxnConfirmationsProvider({ children }) {
22− const value = _useTxnConfirmations();
23−
24− return (
25− <TxnConfirmationsContext.Provider value={value}>
26− {children}
27− </TxnConfirmationsContext.Provider>
28− );
29−}
30−
31−// HOC version
32−export const withTxnConfirmations = Component =>
33− forwardRef((props, ref) => (
34− <TxnConfirmationsContext.Consumer>
35− {txnConfirmations => (
36− <Component ref={ref} {...txnConfirmations} {...props} />
37− )}
38− </TxnConfirmationsContext.Consumer>
39− ));
40−
41−// Hook version
42−export function useTxnConfirmations() {
43− return useContext(TxnConfirmationsContext);
44−}
src/views/Admin/Reticket/ReticketExecute.js+15−17
@@ -127,23 +127,7 @@ export default function ReticketExecute({ newWallet, setNewWallet }) {
127127 {label}
128128 </Grid.Item>
129129
130− {!isDone && (
131− <>
132− <Grid.Item full as={Grid} className="mt3" gap={3}>
133− <Grid.Item full as={LoadingBar} progress={progress} />
134− <Grid.Item full>
135− <Text className="f5 green4">
136− This process can take up to 5 minutes to complete. Don't leave
137− this page until the process is complete.
138− </Text>
139− </Grid.Item>
140− </Grid.Item>
141−
142− {renderAdditionalInfo()}
143− </>
144− )}
145−
146− {isDone && (
130+ {isDone ? (
147131 <>
148132 <Grid.Item full as={Text}>
149133 Your changes are now reflected on-chain and you can use the new
@@ -158,6 +142,20 @@ export default function ReticketExecute({ newWallet, setNewWallet }) {
158142 Login with New Master Ticket
159143 </Grid.Item>
160144 </>
145+ ) : (
146+ <>
147+ <Grid.Item full as={Grid} className="mt3" gap={3}>
148+ <Grid.Item full as={LoadingBar} progress={progress} />
149+ <Grid.Item full>
150+ <Text className="f5 green4">
151+ This process can take up to 5 minutes to complete. Don't leave
152+ this page until the process is complete.
153+ </Text>
154+ </Grid.Item>
155+ </Grid.Item>
156+
157+ {renderAdditionalInfo()}
158+ </>
161159 )}
162160 </Grid>
163161 );
src/views/SentTransaction.js+3−13
@@ -8,7 +8,6 @@ import { ROUTE_NAMES } from '../lib/routeNames';
88import { useHistory } from '../store/history';
99import { BRIDGE_ERROR, renderTxnError } from '../lib/error';
1010import { NETWORK_TYPES } from '../lib/network';
11−import { useTxnConfirmations } from '../store/txnConfirmations';
1211import { useNetwork } from '../store/network';
1312import { useTxnCursor } from '../store/txnCursor';
1413import View from 'components/View';
@@ -39,7 +38,7 @@ class Success extends React.Component {
3938
4039 render() {
4140 const { props, state } = this;
42− const { networkType, hash, txnConfirmations } = props;
41+ const { networkType, hash } = props;
4342 const { pending } = state;
4443
4544 const esvisible =
@@ -67,9 +66,7 @@ class Success extends React.Component {
6766 </Anchor>
6867 );
6968
70− const confirmations = Maybe.fromNullable(txnConfirmations[hash]).getOrElse(
71− 0
72− );
69+ const confirmations = 1;
7370
7471 const requiredConfirmations = 1;
7572
@@ -115,7 +112,6 @@ const Failure = props => (
115112
116113function SentTransaction(props) {
117114 const history = useHistory();
118− const { txnConfirmations } = useTxnConfirmations();
119115 const { web3, networkType } = useNetwork();
120116 const { txnCursor } = useTxnCursor();
121117
@@ -132,13 +128,7 @@ function SentTransaction(props) {
132128
133129 const body = result.matchWith({
134130 Error: message => <Failure web3={w3} message={message.value} />,
135− Ok: hash => (
136− <Success
137− hash={hash.value}
138− networkType={networkType}
139− txnConfirmations={txnConfirmations}
140− />
141− ),
131+ Ok: hash => <Success hash={hash.value} networkType={networkType} />,
142132 });
143133
144134 const ok = (