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';
17import ViewHeader from 'components/ViewHeader';
18import InlineEthereumTransaction from 'components/InlineEthereumTransaction';
19import View from 'components/View';
20import WarningBox from 'components/WarningBox';
22import BridgeForm from 'form/BridgeForm';
23import { PointInput, NumberInput } from 'form/Inputs';
28} from 'form/validators';
29import FormError from 'form/FormError';
30import CopiableAddress from 'components/CopiableAddress';
32function useSetPoolSize() {
33 const { contracts } = useNetwork();
34 const { pointCursor } = usePointCursor();
35 const { syncOwnedPoint } = usePointCache();
37 const _contracts = need.contracts(contracts);
38 const _point = need.point(pointCursor);
40 return useEthereumTransaction(
42 (poolOwner, poolSize) =>
43 azimuth.delegatedSending.setPoolSize(
51 useCallback(() => syncOwnedPoint(_point), [_point, syncOwnedPoint]),
52 GAS_LIMITS.DEFAULT // TODO: GAS_LIMITS.SET_POOL_SIZE
56export default function PartySetPoolSize() {
57 const { pop } = useLocalRouter();
58 const { contracts } = useNetwork();
60 const _contracts = need.contracts(contracts);
62 const { spawnIsDelegatedSending } = useCurrentPermissions();
72 const validate = useMemo(
75 poolOwner: buildPointValidator(),
76 poolSize: buildNumberValidator(0),
81 const onValues = useCallback(
82 ({ valid, values }) => {
84 construct(patp2dec(values.poolOwner), values.poolSize);
89 [construct, unconstruct]
92 const initialValues = useMemo(() => ({ poolSize: 5 }), []);
95 <View pop={pop} inset>
97 <Grid.Item full as={ViewHeader}>
101 {!spawnIsDelegatedSending && (
102 <Grid.Item full as={WarningBox} className="mb4 f6">
103 The spawn proxy must be set to{' '}
105 {_contracts.delegatedSending.address}
106 </CopiableAddress>{' '}
107 for invitations to be available.
114 initialValues={initialValues}>
115 {({ handleSubmit, values }) => (
120 className={cn('f5 wrap', {
125 {values.poolSize} invites have been allocated to{' '}
126 <CopiableAddress>{values.poolOwner}</CopiableAddress>
129 `Allocate invites to a child point.`
141 disabled={inputsLocked}
149 disabled={inputsLocked}
154 <Grid.Item full as={FormError} />
158 as={InlineEthereumTransaction}
160 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