on master help sign in
fix: minor updates from PR comments
b16048cMatt Condon (shrugs)
src/components/old/StatelessTransaction.js+1−3
@@ -22,7 +22,6 @@ import {
22 signTransaction,
22 signTransaction,
23} from '../../lib/txn';
23} from '../../lib/txn';
24
24
25−import { withTxnConfirmations } from '../../store/txnConfirmations';
26import { withNetwork } from '../../store/network';
25import { withNetwork } from '../../store/network';
27import { withHistory } from '../../store/history';
26import { withHistory } from '../../store/history';
28import { withWallet } from '../../store/wallet';
27import { withWallet } from '../../store/wallet';
@@ -233,7 +232,7 @@ class StatelessTransaction extends React.Component {
233 } else {
232 } else {
234 this.setState({ txStatus: SUBMISSION_STATES.SENDING });
233 this.setState({ txStatus: SUBMISSION_STATES.SENDING });
235
234
236− sendSignedTransaction(web3, stx, usedTank, props.setTxnConfirmations)
235+ sendSignedTransaction(web3, stx, usedTank)
237 .then(txHash => {
236 .then(txHash => {
238 props.setTxnCursor(Just(Ok(txHash)));
237 props.setTxnCursor(Just(Ok(txHash)));
239
238
@@ -592,7 +591,6 @@ class StatelessTransaction extends React.Component {
592
591
593export default compose(
592export default compose(
594 withNetwork,
593 withNetwork,
595− withTxnConfirmations,
596 withHistory,
594 withHistory,
597 withWallet,
595 withWallet,
598 withTxnCursor
596 withTxnCursor
src/store/Provider.js−2
@@ -1,7 +1,6 @@
1import nest from 'lib/nest';
1import nest from 'lib/nest';
2
2
3import { HistoryProvider } from './history';
3import { HistoryProvider } from './history';
4−import { TxnConfirmationsProvider } from './txnConfirmations';
5import { OnlineProvider } from './online';
4import { OnlineProvider } from './online';
6import { NetworkProvider } from './network';
5import { NetworkProvider } from './network';
7import { WalletProvider } from './wallet';
6import { WalletProvider } from './wallet';
@@ -16,7 +15,6 @@ export default nest([
16 OnlineProvider,
15 OnlineProvider,
17 NetworkProvider,
16 NetworkProvider,
18 WalletProvider,
17 WalletProvider,
19− TxnConfirmationsProvider,
20 PointCursorProvider,
18 PointCursorProvider,
21 PointCacheProvider,
19 PointCacheProvider,
22 TxnCursorProvider,
20 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 }) {
127 {label}
127 {label}
128 </Grid.Item>
128 </Grid.Item>
129
129
130− {!isDone && (
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 && (
147 <>
131 <>
148 <Grid.Item full as={Text}>
132 <Grid.Item full as={Text}>
149 Your changes are now reflected on-chain and you can use the new
133 Your changes are now reflected on-chain and you can use the new
@@ -158,6 +142,20 @@ export default function ReticketExecute({ newWallet, setNewWallet }) {
158 Login with New Master Ticket
142 Login with New Master Ticket
159 </Grid.Item>
143 </Grid.Item>
160 </>
144 </>
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+ </>
161 )}
159 )}
162 </Grid>
160 </Grid>
163 );
161 );
src/views/SentTransaction.js+3−13
@@ -8,7 +8,6 @@ import { 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';
10import { NETWORK_TYPES } from '../lib/network';
10import { NETWORK_TYPES } from '../lib/network';
11−import { useTxnConfirmations } from '../store/txnConfirmations';
12import { useNetwork } from '../store/network';
11import { useNetwork } from '../store/network';
13import { useTxnCursor } from '../store/txnCursor';
12import { useTxnCursor } from '../store/txnCursor';
14import View from 'components/View';
13import View from 'components/View';
@@ -39,7 +38,7 @@ class Success extends React.Component {
39
38
40 render() {
39 render() {
41 const { props, state } = this;
40 const { props, state } = this;
42− const { networkType, hash, txnConfirmations } = props;
41+ const { networkType, hash } = props;
43 const { pending } = state;
42 const { pending } = state;
44
43
45 const esvisible =
44 const esvisible =
@@ -67,9 +66,7 @@ class Success extends React.Component {
67 </Anchor>
66 </Anchor>
68 );
67 );
69
68
70− const confirmations = Maybe.fromNullable(txnConfirmations[hash]).getOrElse(
69+ const confirmations = 1;
71− 0
72− );
73
70
74 const requiredConfirmations = 1;
71 const requiredConfirmations = 1;
75
72
@@ -115,7 +112,6 @@ const Failure = props => (
115
112
116function SentTransaction(props) {
113function SentTransaction(props) {
117 const history = useHistory();
114 const history = useHistory();
118− const { txnConfirmations } = useTxnConfirmations();
119 const { web3, networkType } = useNetwork();
115 const { web3, networkType } = useNetwork();
120 const { txnCursor } = useTxnCursor();
116 const { txnCursor } = useTxnCursor();
121
117
@@ -132,13 +128,7 @@ function SentTransaction(props) {
132
128
133 const body = result.matchWith({
129 const body = result.matchWith({
134 Error: message => <Failure web3={w3} message={message.value} />,
130 Error: message => <Failure web3={w3} message={message.value} />,
135− Ok: hash => (
136− <Success
137− hash={hash.value}
138− networkType={networkType}
131+ Ok: hash => <Success hash={hash.value} networkType={networkType} />,
139− txnConfirmations={txnConfirmations}
140− />
141− ),
142 });
132 });
143
133
144 const ok = (
134 const ok = (