@@ -1,7 +1,7 @@
11import Maybe from 'folktale/maybe'
22import React from 'react'
33import * as azimuth from 'azimuth-js'
4−import { Row, Col, H1, P, InnerLabel, ShowBlockie, Anchor } from '../components/Base'
4+import { Row, Col, H1, P, InnerLabel, ShowBlockie, Anchor, HorizontalSelector } from '../components/Base'
55import { AddressInput } from '../components/Base'
66import * as ob from 'urbit-ob'
77
@@ -46,13 +46,23 @@ class SetProxy extends React.Component {
4646 this.state = {
4747 proxyAddress: '',
4848 issuingPoint: issuingPoint,
49+ setProxy: true
4950 }
5051
5152 this.statelessRef = React.createRef();
53+ this.handleSetUnset = this.handleSetUnset.bind(this);
5254 this.handleAddressInput = this.handleAddressInput.bind(this)
5355 this.createUnsignedTxn = this.createUnsignedTxn.bind(this)
5456 }
5557
58+ handleSetUnset(selected) {
59+ const set = (selected === 'set');
60+ this.setState({
61+ setProxy: set,
62+ proxyAddress: set ? '' : '0x0000000000000000000000000000000000000000'
63+ });
64+ }
65+
5666 handleAddressInput(proxyAddress) {
5767 this.setState({ proxyAddress })
5868
@@ -116,42 +126,61 @@ class SetProxy extends React.Component {
116126
117127 const ucFirst = w => w.charAt(0).toUpperCase() + w.slice(1);
118128
129+ const setUnset = [
130+ { title: 'Set', value: 'set' },
131+ { title: 'Unset', value: 'unset' }
132+ ];
133+
134+ const titleVerb = this.state.setProxy ? 'Set' : 'Unset';
135+
136+ let addressInput = null;
137+ if (this.state.setProxy) {
138+ addressInput = (<>
139+ <P className='mt-8'>
140+ {
141+ 'Please provide an Ethereum address to act as the ' +
142+ `${renderedProxyType} proxy. You can also use Wallet ` +
143+ 'Generator to generate a keypair.'
144+ }
145+ </P>
146+
147+ <AddressInput
148+ className='mono mt-8'
149+ prop-size='lg'
150+ prop-format='innerLabel'
151+ placeholder={ `e.g. 0x84295d5e054d8cff5a22428b195f5a1615bd644f` }
152+ value={ state.proxyAddress }
153+ onChange={ v => this.handleAddressInput(v) }>
154+ <InnerLabel>{ 'Proxy Address' }</InnerLabel>
155+ <ShowBlockie className={'mt-1'} address={state.proxyAddress} />
156+ </AddressInput>
157+
158+ <Anchor
159+ className={'mt-1'}
160+ prop-size={'sm'}
161+ prop-disabled={!isValidAddress(state.proxyAddress) || !esvisible}
162+ target={'_blank'}
163+ href={`https://${esdomain}/address/${state.proxyAddress}`}>
164+ {'View on Etherscan ↗'}
165+ </Anchor>
166+ </>)
167+ }
119168
120169 return (
121170 <Row>
122171 <Col>
123172 <H1>
124− { `Set ${ucFirst(renderedProxyType)} Proxy For ` }
173+ { `${titleVerb} ${ucFirst(renderedProxyType)} Proxy For ` }
125174 <code>{ `${ob.patp(state.issuingPoint)}` }</code>
126175 </H1>
127176
128− <P>
129− {
130− 'Please provide an Ethereum address to act as the ' +
131− `${renderedProxyType} proxy. You can also use Wallet ` +
132− 'Generator to generate a keypair.'
133− }
134− </P>
135−
136− <AddressInput
137− className='mono mt-8'
138− prop-size='lg'
139− prop-format='innerLabel'
140− placeholder={ `e.g. 0x84295d5e054d8cff5a22428b195f5a1615bd644f` }
141− value={ state.proxyAddress }
142− onChange={ v => this.handleAddressInput(v) }>
143− <InnerLabel>{ 'Proxy Address' }</InnerLabel>
144− <ShowBlockie className={'mt-1'} address={state.proxyAddress} />
145− </AddressInput>
146−
147− <Anchor
148− className={'mt-1'}
149− prop-size={'sm'}
150− prop-disabled={!isValidAddress(state.proxyAddress) || !esvisible}
151− target={'_blank'}
152− href={`https://${esdomain}/address/${state.proxyAddress}`}>
153− {'View on Etherscan ↗'}
154− </Anchor>
177+ <HorizontalSelector
178+ options={setUnset}
179+ onChange={this.handleSetUnset}
180+ className='mt-8'
181+ />
182+
183+ { addressInput }
155184
156185 <StatelessTransaction
157186 // Upper scope