@@ -17,6 +17,7 @@ import {
17 sendSignedTransaction,
17 sendSignedTransaction,
18 waitForTransactionConfirm,
18 waitForTransactionConfirm,
20} from './txn';
21} from './txn';
21import * as need from 'lib/need';
22import * as need from 'lib/need';
22import { ensureFundsFor } from 'lib/tank';
23import { ensureFundsFor } from 'lib/tank';
@@ -29,6 +30,7 @@ import { useWalletConnect } from './useWalletConnect';
29const STATE = {
30const STATE = {
30 NONE: 'NONE',
31 NONE: 'NONE',
31 SIGNED: 'SIGNED',
32 SIGNED: 'SIGNED',
33+ FAKE_SIGNED: 'FAKE_SIGNED',
32 BROADCASTED: 'BROADCASTED',
34 BROADCASTED: 'BROADCASTED',
33 CONFIRMED: 'CONFIRMED',
35 CONFIRMED: 'CONFIRMED',
34 COMPLETED: 'COMPLETED',
36 COMPLETED: 'COMPLETED',
@@ -50,7 +52,10 @@ export default function useEthereumTransaction(
50 const { wallet, walletType, walletHdPath } = useWallet();
52 const { wallet, walletType, walletHdPath } = useWallet();
51 const { web3, networkType } = useNetwork();
53 const { web3, networkType } = useNetwork();
52 const { pointCursor } = usePointCursor();
54 const { pointCursor } = usePointCursor();
53− const { signTransaction: wcSign } = useWalletConnect();
56+ signTransaction: wcSign,
57+ sendTransaction: wcSend,
58+ } = useWalletConnect();
55 const _web3 = need.web3(web3);
60 const _web3 = need.web3(web3);
56 const _wallet = need.wallet(wallet);
61 const _wallet = need.wallet(wallet);
@@ -81,7 +86,8 @@ export default function useEthereumTransaction(
81 const initializing = nonce === undefined || chainId === undefined;
86 const initializing = nonce === undefined || chainId === undefined;
82 const constructed = !!unsignedTransactions;
87 const constructed = !!unsignedTransactions;
83 const isDefaultState = state === STATE.NONE;
88 const isDefaultState = state === STATE.NONE;
84− const signed = state === STATE.SIGNED;
89+ const signed = state === STATE.SIGNED || state === STATE.FAKE_SIGNED;
90+ const fakeSigned = state === STATE.FAKE_SIGNED;
85 const broadcasted = state === STATE.BROADCASTED;
91 const broadcasted = state === STATE.BROADCASTED;
86 const confirmed = state === STATE.CONFIRMED;
92 const confirmed = state === STATE.CONFIRMED;
87 const completed = state === STATE.COMPLETED;
93 const completed = state === STATE.COMPLETED;
@@ -115,6 +121,8 @@ export default function useEthereumTransaction(
115 // https://reactjs.org/docs/hooks-rules.html
121 // https://reactjs.org/docs/hooks-rules.html
116 const txnSigner =
122 const txnSigner =
117 walletType === WALLET_TYPES.WALLET_CONNECT ? wcSign : undefined;
123 walletType === WALLET_TYPES.WALLET_CONNECT ? wcSign : undefined;
125+ walletType === WALLET_TYPES.WALLET_CONNECT ? wcSend : undefined;
119 const txns = await Promise.all(
127 const txns = await Promise.all(
120 utxs.map((utx, i) =>
128 utxs.map((utx, i) =>
@@ -129,12 +137,18 @@ export default function useEthereumTransaction(
129 gasPrice: gasPrice.toFixed(0),
137 gasPrice: gasPrice.toFixed(0),
130 gasLimit,
138 gasLimit,
131 txnSigner,
139 txnSigner,
136 setSignedTransactions(txns);
145 setSignedTransactions(txns);
147+ if (txns.some(tx => tx instanceof FakeSignResult)) {
148+ setState(STATE.FAKE_SIGNED);
137− setState(STATE.SIGNED);
150+ setState(STATE.SIGNED);
138 } catch (error) {
152 } catch (error) {
139 console.error('error signing txs', error);
153 console.error('error signing txs', error);
140 setError(error);
154 setError(error);
@@ -151,6 +165,7 @@ export default function useEthereumTransaction(
151 walletHdPath,
165 walletHdPath,
152 walletType,
166 walletType,
156 const broadcast = useCallback(async () => {
171 const broadcast = useCallback(async () => {
@@ -327,6 +342,7 @@ export default function useEthereumTransaction(
328 generateAndSign,
343 generateAndSign,
330 broadcast,
346 broadcast,
331 broadcasted,
347 broadcasted,
332 confirmed,
348 confirmed,