on master help sign in
feat: standardize refetches, clean up useEthereumTransaction usage, blocking refetches post mutation
e94ff4fMatt Condon (shrugs)
src/components/InlineEthereumTransaction.js+11−6
@@ -28,6 +28,7 @@ export default function InlineEthereumTransaction({
28 broadcast,
28 broadcast,
29 broadcasted,
29 broadcasted,
30 confirmed,
30 confirmed,
31+ completed,
31 reset,
32 reset,
32 error,
33 error,
33 gasPrice,
34 gasPrice,
@@ -45,9 +46,13 @@ export default function InlineEthereumTransaction({
45 onReturn,
46 onReturn,
46}) {
47}) {
47 // show receipt after successful broadcast
48 // show receipt after successful broadcast
48− const showReceipt = broadcasted || confirmed;
49+ const showReceipt = broadcasted || confirmed || completed;
49 // show configure controls pre-broadcast
50 // show configure controls pre-broadcast
50− const showConfigureInput = !(signed || broadcasted || confirmed);
51+ const showConfigureInput = !(signed || broadcasted || confirmed || completed);
52+ // show the send/loading button while signed, broadcasting, or confirme
53+ const showBroadcastButton = signed || broadcasted || confirmed;
54+ const canBroadcast = signed;
55+ const isLoading = broadcasted || confirmed;
51 // show signed tx only when signing (for offline usage)
56 // show signed tx only when signing (for offline usage)
52 const showSignedTx = signed;
57 const showSignedTx = signed;
53
58
@@ -83,7 +88,7 @@ export default function InlineEthereumTransaction({
83 Reset Transaction
88 Reset Transaction
84 </Grid.Item>
89 </Grid.Item>
85 );
90 );
86− } else if (confirmed) {
91+ } else if (completed) {
87 return (
92 return (
88 <>
93 <>
89 <Grid.Divider />
94 <Grid.Divider />
@@ -92,15 +97,15 @@ export default function InlineEthereumTransaction({
92 </Grid.Item>
97 </Grid.Item>
93 </>
98 </>
94 );
99 );
95− } else if (signed || broadcasted) {
100+ } else if (showBroadcastButton) {
96 return (
101 return (
97 <Grid.Item
102 <Grid.Item
98 full
103 full
99 as={ForwardButton}
104 as={ForwardButton}
100 solid
105 solid
101 success
106 success
102− disabled={broadcasted || needFunds}
107+ disabled={!canBroadcast}
103− loading={broadcasted || needFunds}
108+ loading={isLoading}
104 onClick={() => broadcast()}>
109 onClick={() => broadcast()}>
105 Send Transaction
110 Send Transaction
106 </Grid.Item>
111 </Grid.Item>
src/lib/useEthereumTransaction.js+42−8
@@ -1,4 +1,4 @@
1−import { useCallback, useState } from 'react';
1+import { useCallback, useEffect, useState } from 'react';
2import { Just } from 'folktale/maybe';
2import { Just } from 'folktale/maybe';
3import { fromWei, toWei } from 'web3-utils';
3import { fromWei, toWei } from 'web3-utils';
4
4
@@ -23,13 +23,19 @@ const STATE = {
23 SIGNED: 'SIGNED',
23 SIGNED: 'SIGNED',
24 BROADCASTED: 'BROADCASTED',
24 BROADCASTED: 'BROADCASTED',
25 CONFIRMED: 'CONFIRMED',
25 CONFIRMED: 'CONFIRMED',
26+ COMPLETED: 'COMPLETED',
26};
27};
27
28
28/**
29/**
29 * manage the state around sending and confirming an ethereum transaction
30 * manage the state around sending and confirming an ethereum transaction
31+ * @param {Transaction Function()} transactionBuilder
32+ * @param {Promise<any> Function()} refetch async function called after completion
30− * @param {number} initialGasLimit
33+ * @param {number} initialGasLimit gas limit
34+ * @param {number} initialGasPrice gas price in gwei
31 */
35 */
32export default function useEthereumTransaction(
36export default function useEthereumTransaction(
37+ transactionBuilder,
38+ refetch,
33 initialGasLimit = GAS_LIMITS.DEFAULT,
39 initialGasLimit = GAS_LIMITS.DEFAULT,
34 initialGasPrice = 20
40 initialGasPrice = 20
35) {
41) {
@@ -67,16 +73,18 @@ export default function useEthereumTransaction(
67 const signed = state === STATE.SIGNED;
73 const signed = state === STATE.SIGNED;
68 const broadcasted = state === STATE.BROADCASTED;
74 const broadcasted = state === STATE.BROADCASTED;
69 const confirmed = state === STATE.CONFIRMED;
75 const confirmed = state === STATE.CONFIRMED;
76+ const completed = state === STATE.COMPLETED;
70
77
71− // disable the inputs when:
78+ // lock inputs once we're out of the default state
72− const inputsLocked = signed || broadcasted || confirmed;
79+ const inputsLocked = !isDefaultState;
73
80
74 // we can sign when:
81 // we can sign when:
75− const canSign = !initializing && constructed;
82+ const canSign = !initializing && constructed && isDefaultState;
76
83
77− const construct = useCallback(txn => setUnsignedTransaction(txn), [
84+ const construct = useCallback(
78− setUnsignedTransaction,
85+ (...args) => setUnsignedTransaction(transactionBuilder(...args)),
86+ [transactionBuilder]
79− ]);
87+ );
80
88
81 const unconstruct = useCallback(() => setUnsignedTransaction(undefined), [
89 const unconstruct = useCallback(() => setUnsignedTransaction(undefined), [
82 setUnsignedTransaction,
90 setUnsignedTransaction,
@@ -200,6 +208,31 @@ export default function useEthereumTransaction(
200 })();
208 })();
201 });
209 });
202
210
211+ useEffect(() => {
212+ let cancelled = false;
213+
214+ if (confirmed) {
215+ (async () => {
216+ if (refetch) {
217+ try {
218+ await refetch();
219+ } catch (error) {
220+ // NOTE: we don't handle this error on purpose
221+ console.error(error);
222+ }
223+ }
224+
225+ if (cancelled) {
226+ return;
227+ }
228+
229+ setState(STATE.COMPLETED);
230+ })();
231+ }
232+
233+ return () => (cancelled = true);
234+ }, [confirmed, refetch, completed]);
235+
203 const values = useDeepEqualReference({
236 const values = useDeepEqualReference({
204 isDefaultState,
237 isDefaultState,
205 initializing,
238 initializing,
@@ -212,6 +245,7 @@ export default function useEthereumTransaction(
212 broadcast,
245 broadcast,
213 broadcasted,
246 broadcasted,
214 confirmed,
247 confirmed,
248+ completed,
215 reset,
249 reset,
216 error,
250 error,
217 inputsLocked,
251 inputsLocked,
src/store/lib/usePointStore.js+11−12
@@ -20,25 +20,23 @@ export default function usePointStore() {
20
20
21 // sync all of the on-chain info required to display a known point
21 // sync all of the on-chain info required to display a known point
22 const syncKnownPoint = useCallback(
22 const syncKnownPoint = useCallback(
23− point => {
24− syncBirthday(point);
25− syncRekeyDate(point);
23+ async point => Promise.all([syncBirthday(point), syncRekeyDate(point)]),
26− },
27 [syncBirthday, syncRekeyDate]
24 [syncBirthday, syncRekeyDate]
28 );
25 );
29
26
30 // sync all of the on-chain info required to display a foreign point
27 // sync all of the on-chain info required to display a foreign point
31− const syncForeignPoint = useCallback(point => {}, []);
28+ const syncForeignPoint = useCallback(async point => {}, []);
32
29
33 // sync all of the on-chain info required for a point that the user owns
30 // sync all of the on-chain info required for a point that the user owns
34 const syncOwnedPoint = useCallback(
31 const syncOwnedPoint = useCallback(
35− point => {
32+ async point =>
33+ Promise.all([
36− syncForeignPoint(point);
34+ syncForeignPoint(point),
37− syncKnownPoint(point);
35+ syncKnownPoint(point),
38− //
36+ //
39− syncDetails(point);
37+ syncDetails(point),
40− syncInvites(point);
38+ syncInvites(point),
41− },
39+ ]),
42 [syncForeignPoint, syncKnownPoint, syncDetails, syncInvites]
40 [syncForeignPoint, syncKnownPoint, syncDetails, syncInvites]
43 );
41 );
44
42
@@ -49,6 +47,7 @@ export default function usePointStore() {
49 ...invites,
47 ...invites,
50 ...controlledPoints,
48 ...controlledPoints,
51 ...ecliptic,
49 ...ecliptic,
50+ syncDetails,
52 syncInvites,
51 syncInvites,
53 syncControlledPoints,
52 syncControlledPoints,
54 syncKnownPoint,
53 syncKnownPoint,
src/views/Admin/AdminCancelTransfer.js+14−18
@@ -1,4 +1,4 @@
1−import React, { useEffect } from 'react';
1+import React, { useCallback } from 'react';
2import cn from 'classnames';
2import cn from 'classnames';
3import { Grid, Text } from 'indigo-react';
3import { Grid, Text } from 'indigo-react';
4import * as azimuth from 'azimuth-js';
4import * as azimuth from 'azimuth-js';
@@ -22,31 +22,27 @@ import InlineEthereumTransaction from 'components/InlineEthereumTransaction';
22function useCancelTransfer() {
22function useCancelTransfer() {
23 const { contracts } = useNetwork();
23 const { contracts } = useNetwork();
24 const { pointCursor } = usePointCursor();
24 const { pointCursor } = usePointCursor();
25− const { syncOwnedPoint } = usePointCache();
25+ const { syncDetails } = usePointCache();
26
26
27 const _contracts = need.contracts(contracts);
27 const _contracts = need.contracts(contracts);
28 const _point = need.point(pointCursor);
28 const _point = need.point(pointCursor);
29
29
30− const { construct, confirmed, bind } = useEthereumTransaction(
30+ const { construct, ...rest } = useEthereumTransaction(
31+ useCallback(
32+ () =>
33+ azimuth.ecliptic.setTransferProxy(_contracts, _point, ETH_ZERO_ADDR),
34+ [_contracts, _point]
35+ ),
36+ useCallback(() => syncDetails(_point), [_point, syncDetails]),
31 GAS_LIMITS.SET_PROXY
37 GAS_LIMITS.SET_PROXY
32 );
38 );
33
39
34 useLifecycle(() => {
40 useLifecycle(() => {
35− construct(
41+ construct();
36− azimuth.ecliptic.setTransferProxy(_contracts, _point, ETH_ZERO_ADDR)
37− );
38 });
42 });
39
43
40− // sync point details after success
41− useEffect(() => {
42− if (confirmed) {
43− syncOwnedPoint(_point);
44− }
45− }, [_point, confirmed, syncOwnedPoint]);
46−
47 return {
44 return {
48− confirmed,
45+ ...rest,
49− bind,
50 };
46 };
51}
47}
52
48
@@ -59,7 +55,7 @@ export default function AdminCancelTransfer() {
59 const name = useCurrentPointName();
55 const name = useCurrentPointName();
60 const _details = need.details(getDetails(_point));
56 const _details = need.details(getDetails(_point));
61
57
62− const { confirmed, bind } = useCancelTransfer();
58+ const { completed, bind } = useCancelTransfer();
63
59
64 return (
60 return (
65 <Grid>
61 <Grid>
@@ -73,9 +69,9 @@ export default function AdminCancelTransfer() {
73 full
69 full
74 as={Text}
70 as={Text}
75 className={cn('f5', {
71 className={cn('f5', {
76− green3: confirmed,
72+ green3: completed,
77 })}>
73 })}>
78− {confirmed
74+ {completed
79 ? `The outgoing transfer of ${name} has been cancelled.`
75 ? `The outgoing transfer of ${name} has been cancelled.`
80 : `Cancel the outgoing transfer of ${name} to ${_details.transferProxy}.`}
76 : `Cancel the outgoing transfer of ${name} to ${_details.transferProxy}.`}
81 </Grid.Item>
77 </Grid.Item>
src/views/Admin/AdminNetworkingKeys.js+34−51
@@ -57,7 +57,7 @@ const renderNetworkKey = key => {
57function useSetKeys() {
57function useSetKeys() {
58 const { urbitWallet, wallet, authMnemonic } = useWallet();
58 const { urbitWallet, wallet, authMnemonic } = useWallet();
59 const { pointCursor } = usePointCursor();
59 const { pointCursor } = usePointCursor();
60− const { syncOwnedPoint, getDetails } = usePointCache();
60+ const { syncDetails, syncRekeyDate, getDetails } = usePointCache();
61 const { contracts } = useNetwork();
61 const { contracts } = useNetwork();
62
62
63 const _point = need.point(pointCursor);
63 const _point = need.point(pointCursor);
@@ -75,26 +75,6 @@ function useSetKeys() {
75 bind: keyfileBind,
75 bind: keyfileBind,
76 } = useKeyfileGenerator(ndNetworkSeed);
76 } = useKeyfileGenerator(ndNetworkSeed);
77
77
78− const {
79− isDefaultState,
80− construct: _construct,
81− unconstruct,
82− broadcasting,
83− confirmed: _confirmed,
84− inputsLocked,
85− bind,
86− } = useEthereumTransaction(GAS_LIMITS.CONFIGURE_KEYS);
87−
88− // only treat the transaction as confirmed once we also have keys to download
89− const confirmed = _confirmed && keyfileAvailable;
90−
91− // sync point details after success
92− useEffect(() => {
93− if (confirmed) {
94− syncOwnedPoint(_point);
95− }
96− }, [_point, confirmed, syncOwnedPoint]);
97−
98 const buildNetworkSeed = useCallback(
78 const buildNetworkSeed = useCallback(
99 async manualSeed => {
79 async manualSeed => {
100 if (manualSeed !== undefined) {
80 if (manualSeed !== undefined) {
@@ -125,35 +105,38 @@ function useSetKeys() {
125 [_details, authMnemonic, networkRevision, urbitWallet, wallet]
105 [_details, authMnemonic, networkRevision, urbitWallet, wallet]
126 );
106 );
127
107
128− const construct = useCallback(
108+ const { completed: _completed, ...rest } = useEthereumTransaction(
109+ useCallback(
129− async (manualSeed, isDiscontinuity) => {
110+ async (manualSeed, isDiscontinuity) => {
130− const seed = await buildNetworkSeed(manualSeed);
111+ const seed = await buildNetworkSeed(manualSeed);
131− const pair = deriveNetworkKeys(seed);
112+ const pair = deriveNetworkKeys(seed);
132−
113+
133− const txn = azimuth.ecliptic.configureKeys(
114+ return azimuth.ecliptic.configureKeys(
134− _contracts,
115+ _contracts,
135− _point,
116+ _point,
136− addHexPrefix(pair.crypt.public),
117+ addHexPrefix(pair.crypt.public),
137− addHexPrefix(pair.auth.public),
118+ addHexPrefix(pair.auth.public),
138− CRYPTO_SUITE_VERSION,
119+ CRYPTO_SUITE_VERSION,
139− isDiscontinuity
120+ isDiscontinuity
140− );
121+ );
141−
122+ },
142− _construct(txn);
123+ [_contracts, _point, buildNetworkSeed]
143− },
124+ ),
144− [_construct, _contracts, _point, buildNetworkSeed]
125+ useCallback(
126+ () => Promise.all([syncDetails(_point), syncRekeyDate(_point)]),
127+ [_point, syncDetails, syncRekeyDate]
128+ ),
129+ GAS_LIMITS.CONFIGURE_KEYS
145 );
130 );
146
131
132+ // only treat the transaction as completed once we also have keys to download
133+ const completed = _completed && keyfileAvailable;
134+
147 return {
135 return {
148− isDefaultState,
136+ completed,
149− construct,
150− unconstruct,
151− broadcasting,
152− confirmed,
153 ndNetworkSeed,
137 ndNetworkSeed,
154− inputsLocked,
155− bind,
156 keyfileBind,
138 keyfileBind,
139+ ...rest,
157 };
140 };
158}
141}
159
142
@@ -175,7 +158,7 @@ export default function AdminNetworkingKeys() {
175 construct,
158 construct,
176 unconstruct,
159 unconstruct,
177 broadcasting,
160 broadcasting,
178− confirmed,
161+ completed,
179 inputsLocked,
162 inputsLocked,
180 bind,
163 bind,
181 keyfileBind,
164 keyfileBind,
@@ -237,7 +220,7 @@ export default function AdminNetworkingKeys() {
237 const goRelocate = useCallback(() => push(names.RELOCATE), [push, names]);
220 const goRelocate = useCallback(() => push(names.RELOCATE), [push, names]);
238
221
239 const renderTitle = () => {
222 const renderTitle = () => {
240− if (confirmed) {
223+ if (completed) {
241 return 'Networking keys are now set. Download your Keyfile to authenticate Arvo.';
224 return 'Networking keys are now set. Download your Keyfile to authenticate Arvo.';
242 }
225 }
243
226
@@ -344,7 +327,7 @@ export default function AdminNetworkingKeys() {
344 : 'Set your networking keys to authenticate with Arvo.'}
327 : 'Set your networking keys to authenticate with Arvo.'}
345 </Grid.Item>
328 </Grid.Item>
346
329
347− {confirmed && (
330+ {completed && (
348 <>
331 <>
349 <Grid.Item full as={NoticeBox} className="mb3">
332 <Grid.Item full as={NoticeBox} className="mb3">
350 You need this keyfile to authenticate with Arvo.
333 You need this keyfile to authenticate with Arvo.
@@ -353,7 +336,7 @@ export default function AdminNetworkingKeys() {
353 </>
336 </>
354 )}
337 )}
355
338
356− {!confirmed && (
339+ {!completed && (
357 <>
340 <>
358 <Grid.Item full as={ToggleInput} {...showNetworkSeedInput} />
341 <Grid.Item full as={ToggleInput} {...showNetworkSeedInput} />
359 {showNetworkSeed && (
342 {showNetworkSeed && (
@@ -361,7 +344,7 @@ export default function AdminNetworkingKeys() {
361 <Grid.Item full as={NoticeBox} className="mb2">
344 <Grid.Item full as={NoticeBox} className="mb2">
362 When using a custom network seed, you'll need to download your
345 When using a custom network seed, you'll need to download your
363 Arvo keyfile immediately after this transaction is
346 Arvo keyfile immediately after this transaction is
364− confirmed—Multipass does not store your seed.
347+ completed—Multipass does not store your seed.
365 </Grid.Item>
348 </Grid.Item>
366 <Grid.Item full as={Input} {...networkSeedInput} />
349 <Grid.Item full as={Input} {...networkSeedInput} />
367 </>
350 </>
@@ -380,7 +363,7 @@ export default function AdminNetworkingKeys() {
380
363
381 {isDefaultState && renderDetails()}
364 {isDefaultState && renderDetails()}
382
365
383− {confirmed && (
366+ {completed && (
384 <>
367 <>
385 <Grid.Item full as={BootArvoButton} disabled />
368 <Grid.Item full as={BootArvoButton} disabled />
386 <Grid.Divider />
369 <Grid.Divider />
src/views/Admin/AdminSetProxy.js+34−54
@@ -46,64 +46,44 @@ const proxyFromDetails = (details, contracts, proxyType) => {
46function useSetProxy(proxyType) {
46function useSetProxy(proxyType) {
47 const { contracts } = useNetwork();
47 const { contracts } = useNetwork();
48 const { pointCursor } = usePointCursor();
48 const { pointCursor } = usePointCursor();
49− const { syncOwnedPoint } = usePointCache();
49+ const { syncDetails } = usePointCache();
50
50
51 const _contracts = need.contracts(contracts);
51 const _contracts = need.contracts(contracts);
52 const _point = need.point(pointCursor);
52 const _point = need.point(pointCursor);
53
53
54+ const { construct, ...rest } = useEthereumTransaction(
54− const buildUnsignedTx = useCallback(
55+ useCallback(
55− address => {
56+ address => {
56− const txArgs = [_contracts, _point, address];
57+ const txArgs = [_contracts, _point, address];
57−
58+
58− switch (proxyType) {
59+ switch (proxyType) {
59− case PROXY_TYPE.MANAGEMENT:
60+ case PROXY_TYPE.MANAGEMENT:
60− return azimuth.ecliptic.setManagementProxy(...txArgs);
61+ return azimuth.ecliptic.setManagementProxy(...txArgs);
61− case PROXY_TYPE.SPAWN:
62+ case PROXY_TYPE.SPAWN:
62− return azimuth.ecliptic.setSpawnProxy(...txArgs);
63+ return azimuth.ecliptic.setSpawnProxy(...txArgs);
63− case PROXY_TYPE.TRANSFER:
64+ case PROXY_TYPE.TRANSFER:
64− return azimuth.ecliptic.setTransferProxy(...txArgs);
65+ return azimuth.ecliptic.setTransferProxy(...txArgs);
65− case PROXY_TYPE.VOTING:
66+ case PROXY_TYPE.VOTING:
66− return azimuth.ecliptic.setVotingProxy(...txArgs);
67+ return azimuth.ecliptic.setVotingProxy(...txArgs);
67− default:
68+ default:
68− throw new Error(`Unknown proxyType ${proxyType}`);
69+ throw new Error(`Unknown proxyType ${proxyType}`);
69− }
70+ }
70− },
71+ },
71− [_contracts, _point, proxyType]
72+ [_contracts, _point, proxyType]
72− );
73+ ),
73−
74+ useCallback(() => syncDetails(_point), [_point, syncDetails]),
74− const {
75− construct: _construct,
76− unconstruct,
77− confirmed,
78− inputsLocked,
79− bind,
80− } = useEthereumTransaction(GAS_LIMITS.SET_PROXY);
75+ GAS_LIMITS.SET_PROXY
81−
82− // sync point details after success
83− useEffect(() => {
84− if (confirmed) {
85− syncOwnedPoint(_point);
86− }
87− }, [_point, confirmed, syncOwnedPoint]);
88−
89− // construct the unsigned transaction when we have a valid address
90− const construct = useCallback(
91− address => _construct(buildUnsignedTx(address)),
92− [_construct, buildUnsignedTx]
93 );
76 );
94
77
95 // force-unset
78 // force-unset
96 const unset = useCallback(() => {
79 const unset = useCallback(() => {
97− _construct(buildUnsignedTx(ETH_ZERO_ADDR));
80+ construct(ETH_ZERO_ADDR);
98− }, [_construct, buildUnsignedTx]);
81+ }, [construct]);
99
82
100 return {
83 return {
101 construct,
84 construct,
102− unconstruct,
103− confirmed,
104 unset,
85 unset,
105− inputsLocked: inputsLocked,
86+ ...rest,
106− bind,
107 };
87 };
108}
88}
109
89
@@ -124,7 +104,7 @@ export default function AdminSetProxy() {
124 unconstruct,
104 unconstruct,
125 unset,
105 unset,
126 inputsLocked,
106 inputsLocked,
127− confirmed,
107+ completed,
128 bind,
108 bind,
129 } = useSetProxy(data.proxyType);
109 } = useSetProxy(data.proxyType);
130
110
@@ -168,7 +148,7 @@ export default function AdminSetProxy() {
168 const isProxySet = !isZeroAddress(proxyAddress);
148 const isProxySet = !isZeroAddress(proxyAddress);
169
149
170 const proxyAddressLabel = `${
150 const proxyAddressLabel = `${
171− confirmed ? 'New' : 'Current'
151+ completed ? 'New' : 'Current'
172 } ${properProxyType} Address`;
152 } ${properProxyType} Address`;
173
153
174 return (
154 return (
@@ -187,7 +167,7 @@ export default function AdminSetProxy() {
187 full
167 full
188 as={Text}
168 as={Text}
189 className={cn('f6 mb1', {
169 className={cn('f6 mb1', {
190− green3: confirmed,
170+ green3: completed,
191 })}>
171 })}>
192 {proxyAddressLabel}
172 {proxyAddressLabel}
193 </Grid.Item>
173 </Grid.Item>
@@ -197,18 +177,18 @@ export default function AdminSetProxy() {
197 flex
177 flex
198 as={Text}
178 as={Text}
199 className={cn('mono', {
179 className={cn('mono', {
200− black: !confirmed && isProxySet,
180+ black: !completed && isProxySet,
201− gray4: !confirmed && !isProxySet,
181+ gray4: !completed && !isProxySet,
202− green3: confirmed,
182+ green3: completed,
203 })}>
183 })}>
204 {isProxySet ? proxyAddress : 'Unset'}
184 {isProxySet ? proxyAddress : 'Unset'}
205 </Flex.Item>
185 </Flex.Item>
206− {!confirmed && isProxySet && (
186+ {!completed && isProxySet && (
207 <Flex.Item as={ToggleInput} {...unsetInput} />
187 <Flex.Item as={ToggleInput} {...unsetInput} />
208 )}
188 )}
209 </Grid.Item>
189 </Grid.Item>
210
190
211− {confirmed ? (
191+ {completed ? (
212 <Grid.Item full className="mb4" />
192 <Grid.Item full className="mb4" />
213 ) : (
193 ) : (
214 <Grid.Item full as={Input} {...addressInput} className="mv4" />
194 <Grid.Item full as={Input} {...addressInput} className="mv4" />
src/views/Admin/AdminTransfer.js+14−34
@@ -21,41 +21,19 @@ import InlineEthereumTransaction from 'components/InlineEthereumTransaction';
21function useTransfer() {
21function useTransfer() {
22 const { contracts } = useNetwork();
22 const { contracts } = useNetwork();
23 const { pointCursor } = usePointCursor();
23 const { pointCursor } = usePointCursor();
24− const { syncOwnedPoint } = usePointCache();
24+ const { syncDetails } = usePointCache();
25
25
26 const _contracts = need.contracts(contracts);
26 const _contracts = need.contracts(contracts);
27 const _point = need.point(pointCursor);
27 const _point = need.point(pointCursor);
28
28
29− const {
30− construct: _construct,
31− unconstruct,
32− confirmed,
33− inputsLocked,
34− bind,
35− } = useEthereumTransaction(GAS_LIMITS.SET_PROXY);
29+ return useEthereumTransaction(
36−
37− const construct = useCallback(
30+ useCallback(
38− address =>
39− _construct(
40− azimuth.ecliptic.setTransferProxy(_contracts, _point, address)
31+ address => azimuth.ecliptic.setTransferProxy(_contracts, _point, address),
32+ [_contracts, _point]
41− ),
33+ ),
42− [_construct, _contracts, _point]
34+ useCallback(() => syncDetails(_point), [_point, syncDetails]),
35+ GAS_LIMITS.SET_PROXY
43 );
36 );
44−
45− // sync point details after success
46− useEffect(() => {
47− if (confirmed) {
48− syncOwnedPoint(_point);
49− }
50− }, [_point, confirmed, syncOwnedPoint]);
51−
52− return {
53− construct,
54− unconstruct,
55− confirmed,
56− inputsLocked,
57− bind,
58− };
59}
37}
60
38
61export default function AdminTransfer() {
39export default function AdminTransfer() {
@@ -65,7 +43,7 @@ export default function AdminTransfer() {
65 const {
43 const {
66 construct,
44 construct,
67 unconstruct,
45 unconstruct,
68− confirmed,
46+ completed,
69 inputsLocked,
47 inputsLocked,
70 bind,
48 bind,
71 } = useTransfer();
49 } = useTransfer();
@@ -94,14 +72,16 @@ export default function AdminTransfer() {
94 full
72 full
95 as={Text}
73 as={Text}
96 className={cn('f5', {
74 className={cn('f5', {
97− green3: confirmed,
75+ green3: completed,
98 })}>
76 })}>
99− {confirmed
77+ {completed
100 ? `${address} is now the Transfer Proxy for ${name} and can accept the transfer by logging into Multipass themselves. Until they accept your transfer, you will still have ownership over ${name}.`
78 ? `${address} is now the Transfer Proxy for ${name} and can accept the transfer by logging into Multipass themselves. Until they accept your transfer, you will still have ownership over ${name}.`
101 : `Transfer ${name} to a new owner.`}
79 : `Transfer ${name} to a new owner.`}
102 </Grid.Item>
80 </Grid.Item>
103
81
82+ {!completed && (
104− <Grid.Item full as={Input} {...addressInput} className="mv4" />
83+ <Grid.Item full as={Input} {...addressInput} className="mv4" />
84+ )}
105
85
106 <Grid.Item
86 <Grid.Item
107 full
87 full
src/views/CreateGalaxy.js+13−31
@@ -28,35 +28,17 @@ function useCreateGalaxy() {
28
28
29 const [galaxy, setGalaxy] = useState();
29 const [galaxy, setGalaxy] = useState();
30
30
31− const {
32− construct: _construct,
33− unconstruct,
34− confirmed,
35− inputsLocked,
36− bind,
37− } = useEthereumTransaction(GAS_LIMITS.DEFAULT);
31+ return useEthereumTransaction(
38−
39− const construct = useCallback(
32+ useCallback(
40− (galaxy, owner) => {
33+ (galaxy, owner) => {
41− setGalaxy(galaxy);
34+ setGalaxy(galaxy);
42− _construct(azimuth.ecliptic.createGalaxy(_contracts, galaxy, owner));
35+ return azimuth.ecliptic.createGalaxy(_contracts, galaxy, owner);
36+ },
37+ [_contracts]
43− },
38+ ),
44− [_construct, _contracts]
39+ useCallback(() => syncKnownPoint(galaxy), [galaxy, syncKnownPoint]),
40+ GAS_LIMITS.DEFAULT
45 );
41 );
46−
47− useEffect(() => {
48− if (confirmed) {
49− syncKnownPoint(galaxy);
50− }
51− }, [confirmed, galaxy, syncKnownPoint]);
52−
53− return {
54− construct,
55− unconstruct,
56− confirmed,
57− inputsLocked,
58− bind,
59− };
60}
42}
61
43
62export default function CreateGalaxy() {
44export default function CreateGalaxy() {
@@ -70,7 +52,7 @@ export default function CreateGalaxy() {
70 const {
52 const {
71 construct,
53 construct,
72 unconstruct,
54 unconstruct,
73− confirmed,
55+ completed,
74 inputsLocked,
56 inputsLocked,
75 bind,
57 bind,
76 } = useCreateGalaxy();
58 } = useCreateGalaxy();
@@ -153,12 +135,12 @@ export default function CreateGalaxy() {
153 Create a Galaxy
135 Create a Galaxy
154 </Grid.Item>
136 </Grid.Item>
155
137
156− {confirmed && (
138+ {completed && (
157 <Grid.Item
139 <Grid.Item
158 full
140 full
159 as={Text}
141 as={Text}
160 className={cn('f5', {
142 className={cn('f5', {
161− green3: confirmed,
143+ green3: completed,
162 })}>
144 })}>
163 {galaxyName} has been created and is owned by {owner}.
145 {galaxyName} has been created and is owned by {owner}.
164 </Grid.Item>
146 </Grid.Item>
src/views/Party/PartySetPoolSize.js+12−34
@@ -29,42 +29,20 @@ function useSetPoolSize() {
29 const _contracts = need.contracts(contracts);
29 const _contracts = need.contracts(contracts);
30 const _point = need.point(pointCursor);
30 const _point = need.point(pointCursor);
31
31
32− const {
33− construct: _construct,
34− unconstruct,
35− confirmed,
36− inputsLocked,
37− bind,
38− } = useEthereumTransaction(GAS_LIMITS.DEFAULT);
32+ return useEthereumTransaction(
39− // TODO: GAS_LIMITS.SET_POOL_SIZE
40−
41− const construct = useCallback(
33+ useCallback(
42− (poolOwner, poolSize) =>
34+ (poolOwner, poolSize) =>
43− _construct(
44 azimuth.delegatedSending.setPoolSize(
35 azimuth.delegatedSending.setPoolSize(
45 _contracts,
36 _contracts,
46 _point,
37 _point,
47 poolOwner,
38 poolOwner,
48 poolSize
39 poolSize
49− )
40+ ),
50− ),
51− [_construct, _contracts, _point]
41+ [_contracts, _point]
42+ ),
43+ useCallback(() => syncOwnedPoint(_point), [_point, syncOwnedPoint]),
44+ GAS_LIMITS.DEFAULT // TODO: GAS_LIMITS.SET_POOL_SIZE
52 );
45 );
53−
54− // sync point details after success
55− useEffect(() => {
56− if (confirmed) {
57− syncOwnedPoint(_point);
58− }
59− }, [_point, confirmed, syncOwnedPoint]);
60−
61− return {
62− construct,
63− unconstruct,
64− confirmed,
65− inputsLocked,
66− bind,
67− };
68}
46}
69
47
70export default function PartySetPoolSize() {
48export default function PartySetPoolSize() {
@@ -78,7 +56,7 @@ export default function PartySetPoolSize() {
78 const {
56 const {
79 construct,
57 construct,
80 unconstruct,
58 unconstruct,
81− confirmed,
59+ completed,
82 inputsLocked,
60 inputsLocked,
83 bind,
61 bind,
84 } = useSetPoolSize();
62 } = useSetPoolSize();
@@ -129,14 +107,14 @@ export default function PartySetPoolSize() {
129 full
107 full
130 as={Text}
108 as={Text}
131 className={cn('f5', {
109 className={cn('f5', {
132− green3: confirmed,
110+ green3: completed,
133 })}>
111 })}>
134− {confirmed
112+ {completed
135 ? `${poolSize} invites have been allocated to ${poolOwner}`
113 ? `${poolSize} invites have been allocated to ${poolOwner}`
136 : `Allocate invites to a child point.`}
114 : `Allocate invites to a child point.`}
137 </Grid.Item>
115 </Grid.Item>
138
116
139− {!confirmed && (
117+ {!completed && (
140 <>
118 <>
141 <Grid.Item full as={Input} {...poolOwnerInput} className="mt4" />
119 <Grid.Item full as={Input} {...poolOwnerInput} className="mt4" />
142 <Grid.Item full as={Input} {...poolSizeInput} className="mb4" />
120 <Grid.Item full as={Input} {...poolSizeInput} className="mb4" />