on master help sign in
feat: standardize refetches, clean up useEthereumTransaction usage, blocking refetches post mutation
commite94ff4fc49f0d5e5062f3c802fc24157334383a4 authorMatt Condon (shrugs) <mattgcondon@gmail.com> dateThu 18 Jul 2019, 14:38 (7 years ago) parent8282b79
9 files changed+185−248
src/components/InlineEthereumTransaction.js+11−6 src/lib/useEthereumTransaction.js+42−8 src/store/lib/usePointStore.js+11−12 src/views/Admin/AdminCancelTransfer.js+14−18 src/views/Admin/AdminNetworkingKeys.js+34−51 src/views/Admin/AdminSetProxy.js+34−54 src/views/Admin/AdminTransfer.js+14−34 src/views/CreateGalaxy.js+13−31 src/views/Party/PartySetPoolSize.js+12−34
src/components/InlineEthereumTransaction.js+11−6
@@ -28,6 +28,7 @@ export default function InlineEthereumTransaction({
2828 broadcast,
2929 broadcasted,
3030 confirmed,
31+ completed,
3132 reset,
3233 error,
3334 gasPrice,
@@ -45,9 +46,13 @@ export default function InlineEthereumTransaction({
4546 onReturn,
4647}) {
4748 // show receipt after successful broadcast
48− const showReceipt = broadcasted || confirmed;
49+ const showReceipt = broadcasted || confirmed || completed;
4950 // 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;
5156 // show signed tx only when signing (for offline usage)
5257 const showSignedTx = signed;
5358
@@ -83,7 +88,7 @@ export default function InlineEthereumTransaction({
8388 Reset Transaction
8489 </Grid.Item>
8590 );
86− } else if (confirmed) {
91+ } else if (completed) {
8792 return (
8893 <>
8994 <Grid.Divider />
@@ -92,15 +97,15 @@ export default function InlineEthereumTransaction({
9297 </Grid.Item>
9398 </>
9499 );
95− } else if (signed || broadcasted) {
100+ } else if (showBroadcastButton) {
96101 return (
97102 <Grid.Item
98103 full
99104 as={ForwardButton}
100105 solid
101106 success
102− disabled={broadcasted || needFunds}
103− loading={broadcasted || needFunds}
107+ disabled={!canBroadcast}
108+ loading={isLoading}
104109 onClick={() => broadcast()}>
105110 Send Transaction
106111 </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';
22import { Just } from 'folktale/maybe';
33import { fromWei, toWei } from 'web3-utils';
44
@@ -23,13 +23,19 @@ const STATE = {
2323 SIGNED: 'SIGNED',
2424 BROADCASTED: 'BROADCASTED',
2525 CONFIRMED: 'CONFIRMED',
26+ COMPLETED: 'COMPLETED',
2627};
2728
2829/**
2930 * manage the state around sending and confirming an ethereum transaction
30− * @param {number} initialGasLimit
31+ * @param {Transaction Function()} transactionBuilder
32+ * @param {Promise<any> Function()} refetch async function called after completion
33+ * @param {number} initialGasLimit gas limit
34+ * @param {number} initialGasPrice gas price in gwei
3135 */
3236export default function useEthereumTransaction(
37+ transactionBuilder,
38+ refetch,
3339 initialGasLimit = GAS_LIMITS.DEFAULT,
3440 initialGasPrice = 20
3541) {
@@ -67,16 +73,18 @@ export default function useEthereumTransaction(
6773 const signed = state === STATE.SIGNED;
6874 const broadcasted = state === STATE.BROADCASTED;
6975 const confirmed = state === STATE.CONFIRMED;
76+ const completed = state === STATE.COMPLETED;
7077
71− // disable the inputs when:
72− const inputsLocked = signed || broadcasted || confirmed;
78+ // lock inputs once we're out of the default state
79+ const inputsLocked = !isDefaultState;
7380
7481 // we can sign when:
75− const canSign = !initializing && constructed;
82+ const canSign = !initializing && constructed && isDefaultState;
7683
77− const construct = useCallback(txn => setUnsignedTransaction(txn), [
78− setUnsignedTransaction,
79− ]);
84+ const construct = useCallback(
85+ (...args) => setUnsignedTransaction(transactionBuilder(...args)),
86+ [transactionBuilder]
87+ );
8088
8189 const unconstruct = useCallback(() => setUnsignedTransaction(undefined), [
8290 setUnsignedTransaction,
@@ -200,6 +208,31 @@ export default function useEthereumTransaction(
200208 })();
201209 });
202210
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+
203236 const values = useDeepEqualReference({
204237 isDefaultState,
205238 initializing,
@@ -212,6 +245,7 @@ export default function useEthereumTransaction(
212245 broadcast,
213246 broadcasted,
214247 confirmed,
248+ completed,
215249 reset,
216250 error,
217251 inputsLocked,
src/store/lib/usePointStore.js+11−12
@@ -20,25 +20,23 @@ export default function usePointStore() {
2020
2121 // sync all of the on-chain info required to display a known point
2222 const syncKnownPoint = useCallback(
23− point => {
24− syncBirthday(point);
25− syncRekeyDate(point);
26− },
23+ async point => Promise.all([syncBirthday(point), syncRekeyDate(point)]),
2724 [syncBirthday, syncRekeyDate]
2825 );
2926
3027 // sync all of the on-chain info required to display a foreign point
31− const syncForeignPoint = useCallback(point => {}, []);
28+ const syncForeignPoint = useCallback(async point => {}, []);
3229
3330 // sync all of the on-chain info required for a point that the user owns
3431 const syncOwnedPoint = useCallback(
35− point => {
36− syncForeignPoint(point);
37− syncKnownPoint(point);
38− //
39− syncDetails(point);
40− syncInvites(point);
41− },
32+ async point =>
33+ Promise.all([
34+ syncForeignPoint(point),
35+ syncKnownPoint(point),
36+ //
37+ syncDetails(point),
38+ syncInvites(point),
39+ ]),
4240 [syncForeignPoint, syncKnownPoint, syncDetails, syncInvites]
4341 );
4442
@@ -49,6 +47,7 @@ export default function usePointStore() {
4947 ...invites,
5048 ...controlledPoints,
5149 ...ecliptic,
50+ syncDetails,
5251 syncInvites,
5352 syncControlledPoints,
5453 syncKnownPoint,
src/views/Admin/AdminCancelTransfer.js+14−18
@@ -1,4 +1,4 @@
1−import React, { useEffect } from 'react';
1+import React, { useCallback } from 'react';
22import cn from 'classnames';
33import { Grid, Text } from 'indigo-react';
44import * as azimuth from 'azimuth-js';
@@ -22,31 +22,27 @@ import InlineEthereumTransaction from 'components/InlineEthereumTransaction';
2222function useCancelTransfer() {
2323 const { contracts } = useNetwork();
2424 const { pointCursor } = usePointCursor();
25− const { syncOwnedPoint } = usePointCache();
25+ const { syncDetails } = usePointCache();
2626
2727 const _contracts = need.contracts(contracts);
2828 const _point = need.point(pointCursor);
2929
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]),
3137 GAS_LIMITS.SET_PROXY
3238 );
3339
3440 useLifecycle(() => {
35− construct(
36− azimuth.ecliptic.setTransferProxy(_contracts, _point, ETH_ZERO_ADDR)
37− );
41+ construct();
3842 });
3943
40− // sync point details after success
41− useEffect(() => {
42− if (confirmed) {
43− syncOwnedPoint(_point);
44− }
45− }, [_point, confirmed, syncOwnedPoint]);
46−
4744 return {
48− confirmed,
49− bind,
45+ ...rest,
5046 };
5147}
5248
@@ -59,7 +55,7 @@ export default function AdminCancelTransfer() {
5955 const name = useCurrentPointName();
6056 const _details = need.details(getDetails(_point));
6157
62− const { confirmed, bind } = useCancelTransfer();
58+ const { completed, bind } = useCancelTransfer();
6359
6460 return (
6561 <Grid>
@@ -73,9 +69,9 @@ export default function AdminCancelTransfer() {
7369 full
7470 as={Text}
7571 className={cn('f5', {
76− green3: confirmed,
72+ green3: completed,
7773 })}>
78− {confirmed
74+ {completed
7975 ? `The outgoing transfer of ${name} has been cancelled.`
8076 : `Cancel the outgoing transfer of ${name} to ${_details.transferProxy}.`}
8177 </Grid.Item>
src/views/Admin/AdminNetworkingKeys.js+34−51
@@ -57,7 +57,7 @@ const renderNetworkKey = key => {
5757function useSetKeys() {
5858 const { urbitWallet, wallet, authMnemonic } = useWallet();
5959 const { pointCursor } = usePointCursor();
60− const { syncOwnedPoint, getDetails } = usePointCache();
60+ const { syncDetails, syncRekeyDate, getDetails } = usePointCache();
6161 const { contracts } = useNetwork();
6262
6363 const _point = need.point(pointCursor);
@@ -75,26 +75,6 @@ function useSetKeys() {
7575 bind: keyfileBind,
7676 } = useKeyfileGenerator(ndNetworkSeed);
7777
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−
9878 const buildNetworkSeed = useCallback(
9979 async manualSeed => {
10080 if (manualSeed !== undefined) {
@@ -125,35 +105,38 @@ function useSetKeys() {
125105 [_details, authMnemonic, networkRevision, urbitWallet, wallet]
126106 );
127107
128− const construct = useCallback(
129− async (manualSeed, isDiscontinuity) => {
130− const seed = await buildNetworkSeed(manualSeed);
131− const pair = deriveNetworkKeys(seed);
132−
133− const txn = azimuth.ecliptic.configureKeys(
134− _contracts,
135− _point,
136− addHexPrefix(pair.crypt.public),
137− addHexPrefix(pair.auth.public),
138− CRYPTO_SUITE_VERSION,
139− isDiscontinuity
140− );
141−
142− _construct(txn);
143− },
144− [_construct, _contracts, _point, buildNetworkSeed]
108+ const { completed: _completed, ...rest } = useEthereumTransaction(
109+ useCallback(
110+ async (manualSeed, isDiscontinuity) => {
111+ const seed = await buildNetworkSeed(manualSeed);
112+ const pair = deriveNetworkKeys(seed);
113+
114+ return azimuth.ecliptic.configureKeys(
115+ _contracts,
116+ _point,
117+ addHexPrefix(pair.crypt.public),
118+ addHexPrefix(pair.auth.public),
119+ CRYPTO_SUITE_VERSION,
120+ isDiscontinuity
121+ );
122+ },
123+ [_contracts, _point, buildNetworkSeed]
124+ ),
125+ useCallback(
126+ () => Promise.all([syncDetails(_point), syncRekeyDate(_point)]),
127+ [_point, syncDetails, syncRekeyDate]
128+ ),
129+ GAS_LIMITS.CONFIGURE_KEYS
145130 );
146131
132+ // only treat the transaction as completed once we also have keys to download
133+ const completed = _completed && keyfileAvailable;
134+
147135 return {
148− isDefaultState,
149− construct,
150− unconstruct,
151− broadcasting,
152− confirmed,
136+ completed,
153137 ndNetworkSeed,
154− inputsLocked,
155− bind,
156138 keyfileBind,
139+ ...rest,
157140 };
158141}
159142
@@ -175,7 +158,7 @@ export default function AdminNetworkingKeys() {
175158 construct,
176159 unconstruct,
177160 broadcasting,
178− confirmed,
161+ completed,
179162 inputsLocked,
180163 bind,
181164 keyfileBind,
@@ -237,7 +220,7 @@ export default function AdminNetworkingKeys() {
237220 const goRelocate = useCallback(() => push(names.RELOCATE), [push, names]);
238221
239222 const renderTitle = () => {
240− if (confirmed) {
223+ if (completed) {
241224 return 'Networking keys are now set. Download your Keyfile to authenticate Arvo.';
242225 }
243226
@@ -344,7 +327,7 @@ export default function AdminNetworkingKeys() {
344327 : 'Set your networking keys to authenticate with Arvo.'}
345328 </Grid.Item>
346329
347− {confirmed && (
330+ {completed && (
348331 <>
349332 <Grid.Item full as={NoticeBox} className="mb3">
350333 You need this keyfile to authenticate with Arvo.
@@ -353,7 +336,7 @@ export default function AdminNetworkingKeys() {
353336 </>
354337 )}
355338
356− {!confirmed && (
339+ {!completed && (
357340 <>
358341 <Grid.Item full as={ToggleInput} {...showNetworkSeedInput} />
359342 {showNetworkSeed && (
@@ -361,7 +344,7 @@ export default function AdminNetworkingKeys() {
361344 <Grid.Item full as={NoticeBox} className="mb2">
362345 When using a custom network seed, you'll need to download your
363346 Arvo keyfile immediately after this transaction is
364− confirmed—Multipass does not store your seed.
347+ completed—Multipass does not store your seed.
365348 </Grid.Item>
366349 <Grid.Item full as={Input} {...networkSeedInput} />
367350 </>
@@ -380,7 +363,7 @@ export default function AdminNetworkingKeys() {
380363
381364 {isDefaultState && renderDetails()}
382365
383− {confirmed && (
366+ {completed && (
384367 <>
385368 <Grid.Item full as={BootArvoButton} disabled />
386369 <Grid.Divider />
src/views/Admin/AdminSetProxy.js+34−54
@@ -46,64 +46,44 @@ const proxyFromDetails = (details, contracts, proxyType) => {
4646function useSetProxy(proxyType) {
4747 const { contracts } = useNetwork();
4848 const { pointCursor } = usePointCursor();
49− const { syncOwnedPoint } = usePointCache();
49+ const { syncDetails } = usePointCache();
5050
5151 const _contracts = need.contracts(contracts);
5252 const _point = need.point(pointCursor);
5353
54− const buildUnsignedTx = useCallback(
55− address => {
56− const txArgs = [_contracts, _point, address];
57−
58− switch (proxyType) {
59− case PROXY_TYPE.MANAGEMENT:
60− return azimuth.ecliptic.setManagementProxy(...txArgs);
61− case PROXY_TYPE.SPAWN:
62− return azimuth.ecliptic.setSpawnProxy(...txArgs);
63− case PROXY_TYPE.TRANSFER:
64− return azimuth.ecliptic.setTransferProxy(...txArgs);
65− case PROXY_TYPE.VOTING:
66− return azimuth.ecliptic.setVotingProxy(...txArgs);
67− default:
68− throw new Error(`Unknown proxyType ${proxyType}`);
69− }
70− },
71− [_contracts, _point, proxyType]
72− );
73−
74− const {
75− construct: _construct,
76− unconstruct,
77− confirmed,
78− inputsLocked,
79− bind,
80− } = useEthereumTransaction(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]
54+ const { construct, ...rest } = useEthereumTransaction(
55+ useCallback(
56+ address => {
57+ const txArgs = [_contracts, _point, address];
58+
59+ switch (proxyType) {
60+ case PROXY_TYPE.MANAGEMENT:
61+ return azimuth.ecliptic.setManagementProxy(...txArgs);
62+ case PROXY_TYPE.SPAWN:
63+ return azimuth.ecliptic.setSpawnProxy(...txArgs);
64+ case PROXY_TYPE.TRANSFER:
65+ return azimuth.ecliptic.setTransferProxy(...txArgs);
66+ case PROXY_TYPE.VOTING:
67+ return azimuth.ecliptic.setVotingProxy(...txArgs);
68+ default:
69+ throw new Error(`Unknown proxyType ${proxyType}`);
70+ }
71+ },
72+ [_contracts, _point, proxyType]
73+ ),
74+ useCallback(() => syncDetails(_point), [_point, syncDetails]),
75+ GAS_LIMITS.SET_PROXY
9376 );
9477
9578 // force-unset
9679 const unset = useCallback(() => {
97− _construct(buildUnsignedTx(ETH_ZERO_ADDR));
98− }, [_construct, buildUnsignedTx]);
80+ construct(ETH_ZERO_ADDR);
81+ }, [construct]);
9982
10083 return {
10184 construct,
102− unconstruct,
103− confirmed,
10485 unset,
105− inputsLocked: inputsLocked,
106− bind,
86+ ...rest,
10787 };
10888}
10989
@@ -124,7 +104,7 @@ export default function AdminSetProxy() {
124104 unconstruct,
125105 unset,
126106 inputsLocked,
127− confirmed,
107+ completed,
128108 bind,
129109 } = useSetProxy(data.proxyType);
130110
@@ -168,7 +148,7 @@ export default function AdminSetProxy() {
168148 const isProxySet = !isZeroAddress(proxyAddress);
169149
170150 const proxyAddressLabel = `${
171− confirmed ? 'New' : 'Current'
151+ completed ? 'New' : 'Current'
172152 } ${properProxyType} Address`;
173153
174154 return (
@@ -187,7 +167,7 @@ export default function AdminSetProxy() {
187167 full
188168 as={Text}
189169 className={cn('f6 mb1', {
190− green3: confirmed,
170+ green3: completed,
191171 })}>
192172 {proxyAddressLabel}
193173 </Grid.Item>
@@ -197,18 +177,18 @@ export default function AdminSetProxy() {
197177 flex
198178 as={Text}
199179 className={cn('mono', {
200− black: !confirmed && isProxySet,
201− gray4: !confirmed && !isProxySet,
202− green3: confirmed,
180+ black: !completed && isProxySet,
181+ gray4: !completed && !isProxySet,
182+ green3: completed,
203183 })}>
204184 {isProxySet ? proxyAddress : 'Unset'}
205185 </Flex.Item>
206− {!confirmed && isProxySet && (
186+ {!completed && isProxySet && (
207187 <Flex.Item as={ToggleInput} {...unsetInput} />
208188 )}
209189 </Grid.Item>
210190
211− {confirmed ? (
191+ {completed ? (
212192 <Grid.Item full className="mb4" />
213193 ) : (
214194 <Grid.Item full as={Input} {...addressInput} className="mv4" />
src/views/Admin/AdminTransfer.js+14−34
@@ -21,41 +21,19 @@ import InlineEthereumTransaction from 'components/InlineEthereumTransaction';
2121function useTransfer() {
2222 const { contracts } = useNetwork();
2323 const { pointCursor } = usePointCursor();
24− const { syncOwnedPoint } = usePointCache();
24+ const { syncDetails } = usePointCache();
2525
2626 const _contracts = need.contracts(contracts);
2727 const _point = need.point(pointCursor);
2828
29− const {
30− construct: _construct,
31− unconstruct,
32− confirmed,
33− inputsLocked,
34− bind,
35− } = useEthereumTransaction(GAS_LIMITS.SET_PROXY);
36−
37− const construct = useCallback(
38− address =>
39− _construct(
40− azimuth.ecliptic.setTransferProxy(_contracts, _point, address)
41− ),
42− [_construct, _contracts, _point]
29+ return useEthereumTransaction(
30+ useCallback(
31+ address => azimuth.ecliptic.setTransferProxy(_contracts, _point, address),
32+ [_contracts, _point]
33+ ),
34+ useCallback(() => syncDetails(_point), [_point, syncDetails]),
35+ GAS_LIMITS.SET_PROXY
4336 );
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− };
5937}
6038
6139export default function AdminTransfer() {
@@ -65,7 +43,7 @@ export default function AdminTransfer() {
6543 const {
6644 construct,
6745 unconstruct,
68− confirmed,
46+ completed,
6947 inputsLocked,
7048 bind,
7149 } = useTransfer();
@@ -94,14 +72,16 @@ export default function AdminTransfer() {
9472 full
9573 as={Text}
9674 className={cn('f5', {
97− green3: confirmed,
75+ green3: completed,
9876 })}>
99− {confirmed
77+ {completed
10078 ? `${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}.`
10179 : `Transfer ${name} to a new owner.`}
10280 </Grid.Item>
10381
104− <Grid.Item full as={Input} {...addressInput} className="mv4" />
82+ {!completed && (
83+ <Grid.Item full as={Input} {...addressInput} className="mv4" />
84+ )}
10585
10686 <Grid.Item
10787 full
src/views/CreateGalaxy.js+13−31
@@ -28,35 +28,17 @@ function useCreateGalaxy() {
2828
2929 const [galaxy, setGalaxy] = useState();
3030
31− const {
32− construct: _construct,
33− unconstruct,
34− confirmed,
35− inputsLocked,
36− bind,
37− } = useEthereumTransaction(GAS_LIMITS.DEFAULT);
38−
39− const construct = useCallback(
40− (galaxy, owner) => {
41− setGalaxy(galaxy);
42− _construct(azimuth.ecliptic.createGalaxy(_contracts, galaxy, owner));
43− },
44− [_construct, _contracts]
31+ return useEthereumTransaction(
32+ useCallback(
33+ (galaxy, owner) => {
34+ setGalaxy(galaxy);
35+ return azimuth.ecliptic.createGalaxy(_contracts, galaxy, owner);
36+ },
37+ [_contracts]
38+ ),
39+ useCallback(() => syncKnownPoint(galaxy), [galaxy, syncKnownPoint]),
40+ GAS_LIMITS.DEFAULT
4541 );
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− };
6042}
6143
6244export default function CreateGalaxy() {
@@ -70,7 +52,7 @@ export default function CreateGalaxy() {
7052 const {
7153 construct,
7254 unconstruct,
73− confirmed,
55+ completed,
7456 inputsLocked,
7557 bind,
7658 } = useCreateGalaxy();
@@ -153,12 +135,12 @@ export default function CreateGalaxy() {
153135 Create a Galaxy
154136 </Grid.Item>
155137
156− {confirmed && (
138+ {completed && (
157139 <Grid.Item
158140 full
159141 as={Text}
160142 className={cn('f5', {
161− green3: confirmed,
143+ green3: completed,
162144 })}>
163145 {galaxyName} has been created and is owned by {owner}.
164146 </Grid.Item>
src/views/Party/PartySetPoolSize.js+12−34
@@ -29,42 +29,20 @@ function useSetPoolSize() {
2929 const _contracts = need.contracts(contracts);
3030 const _point = need.point(pointCursor);
3131
32− const {
33− construct: _construct,
34− unconstruct,
35− confirmed,
36− inputsLocked,
37− bind,
38− } = useEthereumTransaction(GAS_LIMITS.DEFAULT);
39− // TODO: GAS_LIMITS.SET_POOL_SIZE
40−
41− const construct = useCallback(
42− (poolOwner, poolSize) =>
43− _construct(
32+ return useEthereumTransaction(
33+ useCallback(
34+ (poolOwner, poolSize) =>
4435 azimuth.delegatedSending.setPoolSize(
4536 _contracts,
4637 _point,
4738 poolOwner,
4839 poolSize
49− )
50− ),
51− [_construct, _contracts, _point]
40+ ),
41+ [_contracts, _point]
42+ ),
43+ useCallback(() => syncOwnedPoint(_point), [_point, syncOwnedPoint]),
44+ GAS_LIMITS.DEFAULT // TODO: GAS_LIMITS.SET_POOL_SIZE
5245 );
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− };
6846}
6947
7048export default function PartySetPoolSize() {
@@ -78,7 +56,7 @@ export default function PartySetPoolSize() {
7856 const {
7957 construct,
8058 unconstruct,
81− confirmed,
59+ completed,
8260 inputsLocked,
8361 bind,
8462 } = useSetPoolSize();
@@ -129,14 +107,14 @@ export default function PartySetPoolSize() {
129107 full
130108 as={Text}
131109 className={cn('f5', {
132− green3: confirmed,
110+ green3: completed,
133111 })}>
134− {confirmed
112+ {completed
135113 ? `${poolSize} invites have been allocated to ${poolOwner}`
136114 : `Allocate invites to a child point.`}
137115 </Grid.Item>
138116
139− {!confirmed && (
117+ {!completed && (
140118 <>
141119 <Grid.Item full as={Input} {...poolOwnerInput} className="mt4" />
142120 <Grid.Item full as={Input} {...poolSizeInput} className="mb4" />