@@ -1,6 +1,6 @@
1−import React, { useCallback, useEffect, useState } from 'react';
1+import React, { useCallback, useEffect } from 'react';
2import cn from 'classnames';
2import cn from 'classnames';
3−import { Grid, Text, Input, Flex, LinkButton } from 'indigo-react';
3+import { Grid, Text, Input, Flex, ToggleInput } from 'indigo-react';
4import * as azimuth from 'azimuth-js';
4import * as azimuth from 'azimuth-js';
6import { useNetwork } from 'store/network';
6import { useNetwork } from 'store/network';
@@ -16,7 +16,7 @@ import * as need from 'lib/need';
16import { useLocalRouter } from 'lib/LocalRouter';
16import { useLocalRouter } from 'lib/LocalRouter';
17import { ETH_ZERO_ADDR, eqAddr } from 'lib/wallet';
17import { ETH_ZERO_ADDR, eqAddr } from 'lib/wallet';
18import capitalize from 'lib/capitalize';
18import capitalize from 'lib/capitalize';
19−import { useAddressInput } from 'lib/useInputs';
19+import { useAddressInput, useCheckboxInput } from 'lib/useInputs';
20import useEthereumTransaction from 'lib/useEthereumTransaction';
20import useEthereumTransaction from 'lib/useEthereumTransaction';
22import ViewHeader from 'components/ViewHeader';
22import ViewHeader from 'components/ViewHeader';
@@ -51,8 +51,6 @@ function useSetProxy(proxyType) {
51 const _contracts = need.contracts(contracts);
51 const _contracts = need.contracts(contracts);
52 const _point = need.point(pointCursor);
52 const _point = need.point(pointCursor);
54− const [isUnsetting, setUnsetting] = useState(false);
56 const buildUnsignedTx = useCallback(
54 const buildUnsignedTx = useCallback(
57 address => {
55 address => {
58 const txArgs = [_contracts, _point, address];
56 const txArgs = [_contracts, _point, address];
@@ -75,6 +73,7 @@ function useSetProxy(proxyType) {
77 construct: _construct,
75 construct: _construct,
78 confirmed,
77 confirmed,
79 inputsLocked,
78 inputsLocked,
@@ -95,16 +94,15 @@ function useSetProxy(proxyType) {
96 // force-unset
95 // force-unset
97 const unset = useCallback(() => {
96 const unset = useCallback(() => {
99 _construct(buildUnsignedTx(ETH_ZERO_ADDR));
97 _construct(buildUnsignedTx(ETH_ZERO_ADDR));
100 }, [_construct, buildUnsignedTx]);
98 }, [_construct, buildUnsignedTx]);
103 construct,
101 construct,
104 confirmed,
103 confirmed,
107− inputsLocked: inputsLocked || isUnsetting,
105+ inputsLocked: inputsLocked,
@@ -121,20 +119,49 @@ export default function AdminSetProxy() {
122 const properProxyType = capitalize(proxyTypeToHuman(data.proxyType));
120 const properProxyType = capitalize(proxyTypeToHuman(data.proxyType));
124− const { construct, unset, inputsLocked, confirmed, bind } = useSetProxy(
122+ const {
125− data.proxyType
129+ } = useSetProxy(data.proxyType);
131+ const [unsetInput, { data: isUnsetting }] = useCheckboxInput({
134+ inverseLabel: 'Specify',
135+ initialValue: false,
139+ { pass: validAddress, data: address },
140+ { reset: resetAddress },
127− const [addressInput, { pass, data: address }] = useAddressInput({
141+ ] = useAddressInput({
128 name: 'address',
142 name: 'address',
129 label: `New ${properProxyType} Address`,
143 label: `New ${properProxyType} Address`,
130− disabled: inputsLocked,
144+ disabled: inputsLocked || isUnsetting,
133 useEffect(() => {
147 useEffect(() => {
134− if (pass) {
148+ if (isUnsetting) {
151+ } else if (validAddress) {
135 construct(address);
152 construct(address);
137− }, [pass, address, construct]);
159+ construct,
139 const proxyAddress = proxyFromDetails(_details, _contracts, data.proxyType);
166 const proxyAddress = proxyFromDetails(_details, _contracts, data.proxyType);
140 const isProxySet = !eqAddr(ETH_ZERO_ADDR, proxyAddress);
167 const isProxySet = !eqAddr(ETH_ZERO_ADDR, proxyAddress);
@@ -176,9 +203,7 @@ export default function AdminSetProxy() {
176 {isProxySet ? proxyAddress : 'Unset'}
203 {isProxySet ? proxyAddress : 'Unset'}
177 </Flex.Item>
204 </Flex.Item>
178 {!confirmed && isProxySet && (
205 {!confirmed && isProxySet && (
179− <Flex.Item as={LinkButton} onClick={unset} disabled={inputsLocked}>
206+ <Flex.Item as={ToggleInput} {...unsetInput} />
183 </Grid.Item>
208 </Grid.Item>