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';
15import ViewHeader from 'components/ViewHeader';
16import MiniBackButton from 'components/MiniBackButton';
17import InlineEthereumTransaction from 'components/InlineEthereumTransaction';
18import patp2dec from 'lib/patp2dec';
19import { useHistory } from 'store/history';
20import View from 'components/View';
21import useCurrentPermissions from 'lib/useCurrentPermissions';
22import WarningBox from 'components/WarningBox';
24function useSetPoolSize() {
25 const { contracts } = useNetwork();
26 const { pointCursor } = usePointCursor();
27 const { syncOwnedPoint } = usePointCache();
29 const _contracts = need.contracts(contracts);
30 const _point = need.point(pointCursor);
33 construct: _construct,
38 } = useEthereumTransaction(GAS_LIMITS.DEFAULT);
39 // TODO: GAS_LIMITS.SET_POOL_SIZE
41 const construct = useCallback(
42 (poolOwner, poolSize) =>
44 azimuth.delegatedSending.setPoolSize(
51 [_construct, _contracts, _point]
54 // sync point details after success
57 syncOwnedPoint(_point);
59 }, [_point, confirmed, syncOwnedPoint]);
70export default function PartySetPoolSize() {
71 const { pop } = useHistory();
72 const { contracts } = useNetwork();
74 const _contracts = need.contracts(contracts);
76 const { spawnIsDelegatedSending } = useCurrentPermissions();
86 const [poolOwnerInput, { pass: validPoint, data: poolOwner }] = usePointInput(
90 disabled: inputsLocked,
96 { pass: validPoolSize, data: poolSize },
101 disabled: inputsLocked,
105 if (validPoint && validPoolSize) {
106 construct(patp2dec(poolOwner), poolSize);
110 }, [poolOwner, construct, validPoint, validPoolSize, poolSize, unconstruct]);
115 <Grid.Item full as={MiniBackButton} onClick={() => pop()} />
116 <Grid.Item full as={ViewHeader}>
119 {!spawnIsDelegatedSending && (
120 <Grid.Item full as={WarningBox} className="mb4">
121 The spawn proxy must be set to{' '}
122 <code className="mono f6">
123 {_contracts.delegatedSending.address}
125 for invitations to be available.
131 className={cn('f5', {
135 ? `${poolSize} invites have been allocated to ${poolOwner}`
136 : `Allocate invites to a child point.`}
141 <Grid.Item full as={Input} {...poolOwnerInput} className="mt4" />
142 <Grid.Item full as={Input} {...poolSizeInput} className="mb4" />
148 as={InlineEthereumTransaction}
150 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