@@ -17,6 +17,7 @@ import * as need from 'lib/need';
17import { ensureFundsFor } from 'lib/tank';
17import { ensureFundsFor } from 'lib/tank';
18import useDeepEqualReference from './useDeepEqualReference';
18import useDeepEqualReference from './useDeepEqualReference';
19import useGasPrice from './useGasPrice';
19import useGasPrice from './useGasPrice';
20+import timeout from './timeout';
21const STATE = {
22const STATE = {
22 NONE: 'NONE',
23 NONE: 'NONE',
@@ -65,6 +66,7 @@ export default function useEthereumTransaction(
65 const [signedTransaction, setSignedTransaction] = useState();
66 const [signedTransaction, setSignedTransaction] = useState();
66 const [txHash, setTxHash] = useState();
67 const [txHash, setTxHash] = useState();
67 const [needFunds, setNeedFunds] = useState();
68 const [needFunds, setNeedFunds] = useState();
69+ const [confirmationProgress, setConfirmationProgress] = useState(0.0);
69 const initializing = nonce === undefined || chainId === undefined;
71 const initializing = nonce === undefined || chainId === undefined;
70 const constructed = !!unsignedTransaction;
72 const constructed = !!unsignedTransaction;
@@ -126,6 +128,7 @@ export default function useEthereumTransaction(
127 const broadcast = useCallback(async () => {
129 const broadcast = useCallback(async () => {
131+ setConfirmationProgress(0.0);
129 setError(undefined);
132 setError(undefined);
131 const rawTx = hexify(signedTransaction.serialize());
134 const rawTx = hexify(signedTransaction.serialize());
@@ -156,8 +159,14 @@ export default function useEthereumTransaction(
156 setState(STATE.BROADCASTED);
159 setState(STATE.BROADCASTED);
157 setTxHash(txHash);
160 setTxHash(txHash);
162+ await timeout(500); // wait for .animated-width to complete
164+ setConfirmationProgress(0.2);
159 await waitForTransactionConfirm(_web3, txHash);
166 await waitForTransactionConfirm(_web3, txHash);
168+ setConfirmationProgress(0.9);
161 setState(STATE.CONFIRMED);
170 setState(STATE.CONFIRMED);
162 } catch (error) {
171 } catch (error) {
163 setError(error);
172 setError(error);
@@ -181,6 +190,7 @@ export default function useEthereumTransaction(
181 setState(STATE.NONE);
190 setState(STATE.NONE);
182 setError(undefined);
191 setError(undefined);
183 setNeedFunds(undefined);
192 setNeedFunds(undefined);
193+ setConfirmationProgress(0.0);
184 }, [resetGasPrice, setError]);
194 }, [resetGasPrice, setError]);
186 useEffect(() => {
196 useEffect(() => {
@@ -236,6 +246,14 @@ export default function useEthereumTransaction(
249+ setConfirmationProgress(1.0);
251+ await timeout(500); // wait for .animated-width to complete
239 setState(STATE.COMPLETED);
257 setState(STATE.COMPLETED);
@@ -259,7 +277,7 @@ export default function useEthereumTransaction(
261 inputsLocked,
279 inputsLocked,
262− //
280+ confirmationProgress,
264 signedTransaction,
282 signedTransaction,
265 gasPrice,
283 gasPrice,