1import React, { useCallback, useEffect } from 'react';
2import cn from 'classnames';
3import { Grid, Text, Input } from 'indigo-react';
4import * as azimuth from 'azimuth-js';
6import { useNetwork } from 'store/network';
7import { usePointCursor } from 'store/pointCursor';
8import { usePointCache } from 'store/pointCache';
10import * as need from 'lib/need';
11import { usePointInput, useNumberInput } from 'lib/useInputs';
12import useEthereumTransaction from 'lib/useEthereumTransaction';
13import { GAS_LIMITS } from 'lib/constants';
14import { useLocalRouter } from 'lib/LocalRouter';
16import ViewHeader from 'components/ViewHeader';
17import InlineEthereumTransaction from 'components/InlineEthereumTransaction';
18import patp2dec from 'lib/patp2dec';
19import View from 'components/View';
20import useCurrentPermissions from 'lib/useCurrentPermissions';
21import WarningBox from 'components/WarningBox';
23function useSetPoolSize() {
24 const { contracts } = useNetwork();
25 const { pointCursor } = usePointCursor();
26 const { syncOwnedPoint } = usePointCache();
28 const _contracts = need.contracts(contracts);
29 const _point = need.point(pointCursor);
31 return useEthereumTransaction(
33 (poolOwner, poolSize) =>
34 azimuth.delegatedSending.setPoolSize(
42 useCallback(() => syncOwnedPoint(_point), [_point, syncOwnedPoint]),
43 GAS_LIMITS.DEFAULT // TODO: GAS_LIMITS.SET_POOL_SIZE
47export default function PartySetPoolSize() {
48 const { pop } = useLocalRouter();
49 const { contracts } = useNetwork();
51 const _contracts = need.contracts(contracts);
53 const { spawnIsDelegatedSending } = useCurrentPermissions();
63 const [poolOwnerInput, { pass: validPoint, data: poolOwner }] = usePointInput(
67 disabled: inputsLocked,
73 { pass: validPoolSize, data: poolSize },
78 disabled: inputsLocked,
82 if (validPoint && validPoolSize) {
83 construct(patp2dec(poolOwner), poolSize);
87 }, [poolOwner, construct, validPoint, validPoolSize, poolSize, unconstruct]);
90 <View pop={pop} inset>
92 <Grid.Item full as={ViewHeader}>
95 {!spawnIsDelegatedSending && (
96 <Grid.Item full as={WarningBox} className="mb4">
97 The spawn proxy must be set to{' '}
98 <code className="mono f6">
99 {_contracts.delegatedSending.address}
101 for invitations to be available.
107 className={cn('f5', {
111 ? `${poolSize} invites have been allocated to ${poolOwner}`
112 : `Allocate invites to a child point.`}
117 <Grid.Item full as={Input} {...poolOwnerInput} className="mt4" />
118 <Grid.Item full as={Input} {...poolSizeInput} className="mb4" />
124 as={InlineEthereumTransaction}
126 onReturn={() => pop()}
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list