1import Maybe from 'folktale/maybe';
2import React from 'react';
3import * as need from '../lib/need';
4import * as azimuth from 'azimuth-js';
14} from '../components/old/Base';
15import { AddressInput } from '../components/old/Base';
16import * as ob from 'urbit-ob';
18import { PROXY_TYPE, renderProxyType } from '../lib/proxy';
20import { NETWORK_TYPES } from '../lib/network';
22import StatelessTransaction from '../components/old/StatelessTransaction';
24import { isValidAddress } from '../lib/wallet';
25import { withNetwork } from '../store/network';
26import { compose } from '../lib/lib';
27import { withPointCursor } from '../store/pointCursor';
29class _SetProxy extends React.Component {
33 const issuingPoint = need.pointCursor(props);
37 issuingPoint: issuingPoint,
41 this.statelessRef = React.createRef();
42 this.handleSetUnset = this.handleSetUnset.bind(this);
43 this.handleAddressInput = this.handleAddressInput.bind(this);
44 this.createUnsignedTxn = this.createUnsignedTxn.bind(this);
47 handleSetUnset(selected) {
48 const set = selected === 'set';
51 proxyAddress: set ? '' : '0x0000000000000000000000000000000000000000',
55 handleAddressInput(proxyAddress) {
56 this.setState({ proxyAddress });
58 this.statelessRef.current.clearTxn();
61 createUnsignedTxn(proxyAddress) {
62 const { state, props } = this;
64 const validContracts = need.contracts(props);
66 const validPoint = need.pointCursor(props);
68 const txArgs = [validContracts, validPoint, state.proxyAddress];
70 if (props.proxyType === PROXY_TYPE.TRANSFER_PROXY) {
71 return Maybe.Just(azimuth.ecliptic.setTransferProxy(...txArgs));
74 if (props.proxyType === PROXY_TYPE.SPAWN_PROXY) {
75 return Maybe.Just(azimuth.ecliptic.setSpawnProxy(...txArgs));
78 if (props.proxyType === PROXY_TYPE.MANAGEMENT_PROXY) {
79 return Maybe.Just(azimuth.ecliptic.setManagementProxy(...txArgs));
82 return Maybe.Nothing();
86 const { props, state } = this;
88 const renderedProxyType = renderProxyType(props.proxyType);
89 const validAddress = isValidAddress(state.proxyAddress);
90 const canGenerate = validAddress === true;
93 props.networkType === NETWORK_TYPES.ROPSTEN ||
94 props.networkType === NETWORK_TYPES.MAINNET;
97 props.networkType === NETWORK_TYPES.ROPSTEN
98 ? 'ropsten.etherscan.io'
101 const ucFirst = w => w.charAt(0).toUpperCase() + w.slice(1);
104 { title: 'Set', value: 'set' },
105 { title: 'Unset', value: 'unset' },
108 const titleVerb = this.state.setProxy ? 'Set' : 'Unset';
110 let addressInput = null;
111 if (this.state.setProxy) {
115 {'Please provide an Ethereum address to act as the ' +
116 `${renderedProxyType} proxy. You can also use Wallet ` +
117 'Generator to generate a keypair.'}
121 className="mono mt-8"
123 prop-format="innerLabel"
124 placeholder={`e.g. 0x84295d5e054d8cff5a22428b195f5a1615bd644f`}
125 value={state.proxyAddress}
126 onChange={v => this.handleAddressInput(v)}>
127 <InnerLabel>{'Proxy Address'}</InnerLabel>
128 <ShowBlockie className={'mt-1'} address={state.proxyAddress} />
134 prop-disabled={!isValidAddress(state.proxyAddress) || !esvisible}
136 href={`https://${esdomain}/address/${state.proxyAddress}`}>
137 {'View on Etherscan ↗'}
147 {`${titleVerb} ${ucFirst(renderedProxyType)} Proxy For `}
148 <code>{`${ob.patp(state.issuingPoint)}`}</code>
153 onChange={this.handleSetUnset}
159 <StatelessTransaction
160 ref={this.statelessRef}
161 createUnsignedTxn={this.createUnsignedTxn}
162 canGenerate={canGenerate}
170const SetProxy = compose(
175export const SetManagementProxy = props => (
176 <SetProxy {...props} proxyType={PROXY_TYPE.MANAGEMENT_PROXY} />
179export const SetSpawnProxy = props => (
180 <SetProxy {...props} proxyType={PROXY_TYPE.SPAWN_PROXY} />
183export const SetTransferProxy = props => (
184 <SetProxy {...props} proxyType={PROXY_TYPE.TRANSFER_PROXY} />
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