@@ -1,6 +1,6 @@
1−import React, { useCallback, useEffect, useState } from 'react';
1+import React, { useCallback, useEffect } from 'react';
22import cn from 'classnames';
3−import { Grid, Text, Input, Flex, LinkButton } from 'indigo-react';
3+import { Grid, Text, Input, Flex, ToggleInput } from 'indigo-react';
44import * as azimuth from 'azimuth-js';
55
66import { useNetwork } from 'store/network';
@@ -16,7 +16,7 @@ import * as need from 'lib/need';
1616import { useLocalRouter } from 'lib/LocalRouter';
1717import { ETH_ZERO_ADDR, eqAddr } from 'lib/wallet';
1818import capitalize from 'lib/capitalize';
19−import { useAddressInput } from 'lib/useInputs';
19+import { useAddressInput, useCheckboxInput } from 'lib/useInputs';
2020import useEthereumTransaction from 'lib/useEthereumTransaction';
2121
2222import ViewHeader from 'components/ViewHeader';
@@ -51,8 +51,6 @@ function useSetProxy(proxyType) {
5151 const _contracts = need.contracts(contracts);
5252 const _point = need.point(pointCursor);
5353
54− const [isUnsetting, setUnsetting] = useState(false);
55−
5654 const buildUnsignedTx = useCallback(
5755 address => {
5856 const txArgs = [_contracts, _point, address];
@@ -75,6 +73,7 @@ function useSetProxy(proxyType) {
7573
7674 const {
7775 construct: _construct,
76+ unconstruct,
7877 confirmed,
7978 inputsLocked,
8079 bind,
@@ -95,16 +94,15 @@ function useSetProxy(proxyType) {
9594
9695 // force-unset
9796 const unset = useCallback(() => {
98− setUnsetting(true);
9997 _construct(buildUnsignedTx(ETH_ZERO_ADDR));
10098 }, [_construct, buildUnsignedTx]);
10199
102100 return {
103101 construct,
102+ unconstruct,
104103 confirmed,
105104 unset,
106− isUnsetting,
107− inputsLocked: inputsLocked || isUnsetting,
105+ inputsLocked: inputsLocked,
108106 bind,
109107 };
110108}
@@ -121,20 +119,49 @@ export default function AdminSetProxy() {
121119
122120 const properProxyType = capitalize(proxyTypeToHuman(data.proxyType));
123121
124− const { construct, unset, inputsLocked, confirmed, bind } = useSetProxy(
125− data.proxyType
126− );
127− const [addressInput, { pass, data: address }] = useAddressInput({
122+ const {
123+ construct,
124+ unconstruct,
125+ unset,
126+ inputsLocked,
127+ confirmed,
128+ bind,
129+ } = useSetProxy(data.proxyType);
130+
131+ const [unsetInput, { data: isUnsetting }] = useCheckboxInput({
132+ name: 'unset',
133+ label: 'Unset',
134+ inverseLabel: 'Specify',
135+ initialValue: false,
136+ });
137+ const [
138+ addressInput,
139+ { pass: validAddress, data: address },
140+ { reset: resetAddress },
141+ ] = useAddressInput({
128142 name: 'address',
129143 label: `New ${properProxyType} Address`,
130− disabled: inputsLocked,
144+ disabled: inputsLocked || isUnsetting,
131145 });
132146
133147 useEffect(() => {
134− if (pass) {
148+ if (isUnsetting) {
149+ unset();
150+ resetAddress();
151+ } else if (validAddress) {
135152 construct(address);
153+ } else {
154+ unconstruct();
136155 }
137− }, [pass, address, construct]);
156+ }, [
157+ validAddress,
158+ address,
159+ construct,
160+ isUnsetting,
161+ unset,
162+ unconstruct,
163+ resetAddress,
164+ ]);
138165
139166 const proxyAddress = proxyFromDetails(_details, _contracts, data.proxyType);
140167 const isProxySet = !eqAddr(ETH_ZERO_ADDR, proxyAddress);
@@ -176,9 +203,7 @@ export default function AdminSetProxy() {
176203 {isProxySet ? proxyAddress : 'Unset'}
177204 </Flex.Item>
178205 {!confirmed && isProxySet && (
179− <Flex.Item as={LinkButton} onClick={unset} disabled={inputsLocked}>
180− Unset
181− </Flex.Item>
206+ <Flex.Item as={ToggleInput} {...unsetInput} />
182207 )}
183208 </Grid.Item>
184209