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';
31function useSetPoolSize() {
32 const { contracts } = useNetwork();
33 const { pointCursor } = usePointCursor();
34 const { syncOwnedPoint } = usePointCache();
36 const _contracts = need.contracts(contracts);
37 const _point = need.point(pointCursor);
39 return useEthereumTransaction(
41 (poolOwner, poolSize) =>
42 azimuth.delegatedSending.setPoolSize(
50 useCallback(() => syncOwnedPoint(_point), [_point, syncOwnedPoint]),
51 GAS_LIMITS.DEFAULT // TODO: GAS_LIMITS.SET_POOL_SIZE
55export default function PartySetPoolSize() {
56 const { pop } = useLocalRouter();
57 const { contracts } = useNetwork();
59 const _contracts = need.contracts(contracts);
61 const { spawnIsDelegatedSending } = useCurrentPermissions();
71 const validate = useMemo(
74 poolOwner: buildPointValidator(),
75 poolSize: buildNumberValidator(0),
80 const onValues = useCallback(
81 ({ valid, values }) => {
83 construct(patp2dec(values.poolOwner), values.poolSize);
88 [construct, unconstruct]
91 const initialValues = useMemo(() => ({ poolSize: 5 }), []);
94 <View pop={pop} inset>
96 <Grid.Item full as={ViewHeader}>
100 {!spawnIsDelegatedSending && (
101 <Grid.Item full as={WarningBox} className="mb4">
102 The spawn proxy must be set to{' '}
103 <code className="mono f6">
104 {_contracts.delegatedSending.address}
106 for invitations to be available.
113 initialValues={initialValues}>
114 {({ handleSubmit, values }) => (
119 className={cn('f5', {
123 ? `${values.poolSize} invites have been allocated to ${values.poolOwner}`
124 : `Allocate invites to a child point.`}
135 disabled={inputsLocked}
143 disabled={inputsLocked}
148 <Grid.Item full as={FormError} />
152 as={InlineEthereumTransaction}
154 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