1import React, { useCallback, useMemo } from 'react';
2import cn from 'classnames';
3import { Grid, Text } 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 useEthereumTransaction from 'lib/useEthereumTransaction';
12import { GAS_LIMITS } from 'lib/constants';
13import { useLocalRouter } from 'lib/LocalRouter';
14import useCurrentPermissions from 'lib/useCurrentPermissions';
15import { patp2dec } from 'lib/patp2dec';
16import { convertToInt } from 'lib/convertToInt';
18import ViewHeader from 'components/ViewHeader';
19import InlineEthereumTransaction from 'components/InlineEthereumTransaction';
20import View from 'components/View';
21import WarningBox from 'components/WarningBox';
23import BridgeForm from 'form/BridgeForm';
24import { PointInput, NumberInput } from 'form/Inputs';
29} from 'form/validators';
30import FormError from 'form/FormError';
31import CopiableAddress from 'components/CopiableAddress';
33function useSetPoolSize() {
34 const { contracts } = useNetwork();
35 const { pointCursor } = usePointCursor();
36 const { syncExtras } = usePointCache();
38 const _contracts = need.contracts(contracts);
39 const _point = need.point(pointCursor);
41 return useEthereumTransaction(
43 (poolOwner, poolSize) =>
44 azimuth.delegatedSending.setPoolSize(
52 useCallback(() => syncExtras(_point), [_point, syncExtras]),
53 GAS_LIMITS.DEFAULT // TODO: GAS_LIMITS.SET_POOL_SIZE
57export default function PartySetPoolSize() {
58 const { pop } = useLocalRouter();
59 const { contracts } = useNetwork();
60 const { pointCursor } = usePointCursor();
61 const { getDetails } = usePointCache();
63 const _point = need.point(pointCursor);
64 const _details = need.details(getDetails(_point));
66 0 !== convertToInt(_details.encryptionKey, 16) &&
67 0 !== convertToInt(_details.authenticationKey, 16) &&
68 0 !== _details.cryptoSuiteVersion;
70 const _contracts = need.contracts(contracts);
72 const { spawnIsDelegatedSending } = useCurrentPermissions();
82 const validate = useMemo(
85 poolOwner: buildPointValidator(),
86 poolSize: buildNumberValidator(0),
91 const onValues = useCallback(
92 ({ valid, values }) => {
94 construct(patp2dec(values.poolOwner), values.poolSize);
99 [construct, unconstruct]
102 const initialValues = useMemo(() => ({ poolSize: 5 }), []);
105 <View pop={pop} inset>
107 <Grid.Item full as={ViewHeader}>
111 {!spawnIsDelegatedSending && (
112 <Grid.Item full as={WarningBox} className="mb4 f6">
113 The spawn proxy must be set to{' '}
115 {_contracts.delegatedSending.address}
116 </CopiableAddress>{' '}
117 for invitations to be available for use.
122 <Grid.Item full as={WarningBox} className="mb4 f6">
123 Networking keys must be configured for invitations to be available
131 initialValues={initialValues}>
132 {({ handleSubmit, values }) => (
137 className={cn('f5 wrap', {
142 {values.poolSize} invites have been allocated to{' '}
143 <CopiableAddress>{values.poolOwner}</CopiableAddress>
146 `Allocate invites to a child point.`
158 disabled={inputsLocked}
166 disabled={inputsLocked}
171 <Grid.Item full as={FormError} />
175 as={InlineEthereumTransaction}
177 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