1import Maybe from 'folktale/maybe';
2import React from 'react';
3import * as need from '../lib/need';
4import * as azimuth from 'azimuth-js';
12} from '../components/old/Base';
13import { AddressInput } from '../components/old/Base';
14import * as ob from 'urbit-ob';
16import { PROXY_TYPE, renderProxyType } from '../lib/proxy';
18import { NETWORK_TYPES } from '../lib/network';
20import StatelessTransaction from '../components/old/StatelessTransaction';
22import { isValidAddress } from '../lib/wallet';
23import { withNetwork } from '../store/network';
24import { compose } from '../lib/lib';
25import { withPointCursor } from '../store/pointCursor';
26import View from 'components/View';
28class _SetProxy extends React.Component {
32 const issuingPoint = need.pointCursor(props.pointCursor);
36 issuingPoint: issuingPoint,
40 this.statelessRef = React.createRef();
41 this.handleSetUnset = this.handleSetUnset.bind(this);
42 this.handleAddressInput = this.handleAddressInput.bind(this);
43 this.createUnsignedTxn = this.createUnsignedTxn.bind(this);
46 handleSetUnset(selected) {
47 const set = selected === 'set';
50 proxyAddress: set ? '' : '0x0000000000000000000000000000000000000000',
54 handleAddressInput(proxyAddress) {
55 this.setState({ proxyAddress });
57 this.statelessRef.current.clearTxn();
60 createUnsignedTxn(proxyAddress) {
61 const { state, props } = this;
63 const validContracts = need.contracts(props.contracts);
64 const validPoint = need.pointCursor(props.pointCursor);
66 const txArgs = [validContracts, validPoint, state.proxyAddress];
68 if (props.proxyType === PROXY_TYPE.TRANSFER_PROXY) {
69 return Maybe.Just(azimuth.ecliptic.setTransferProxy(...txArgs));
72 if (props.proxyType === PROXY_TYPE.SPAWN_PROXY) {
73 return Maybe.Just(azimuth.ecliptic.setSpawnProxy(...txArgs));
76 if (props.proxyType === PROXY_TYPE.MANAGEMENT_PROXY) {
77 return Maybe.Just(azimuth.ecliptic.setManagementProxy(...txArgs));
80 return Maybe.Nothing();
84 const { props, state } = this;
86 const renderedProxyType = renderProxyType(props.proxyType);
87 const validAddress = isValidAddress(state.proxyAddress);
88 const canGenerate = validAddress === true;
91 props.networkType === NETWORK_TYPES.ROPSTEN ||
92 props.networkType === NETWORK_TYPES.MAINNET;
95 props.networkType === NETWORK_TYPES.ROPSTEN
96 ? 'ropsten.etherscan.io'
99 const ucFirst = w => w.charAt(0).toUpperCase() + w.slice(1);
102 { title: 'Set', value: 'set' },
103 { title: 'Unset', value: 'unset' },
106 const titleVerb = this.state.setProxy ? 'Set' : 'Unset';
108 let addressInput = null;
109 if (this.state.setProxy) {
113 {'Please provide an Ethereum address to act as the ' +
114 `${renderedProxyType} proxy. You can also use Wallet ` +
115 'Generator to generate a keypair.'}
119 className="mono mt-8"
121 prop-format="innerLabel"
122 placeholder={`e.g. 0x84295d5e054d8cff5a22428b195f5a1615bd644f`}
123 value={state.proxyAddress}
124 onChange={v => this.handleAddressInput(v)}>
125 <InnerLabel>{'Proxy Address'}</InnerLabel>
126 <ShowBlockie className={'mt-1'} address={state.proxyAddress} />
132 prop-disabled={!isValidAddress(state.proxyAddress) || !esvisible}
134 href={`https://${esdomain}/address/${state.proxyAddress}`}>
135 {'View on Etherscan ↗'}
144 {`${titleVerb} ${ucFirst(renderedProxyType)} Proxy For `}
145 <code>{`${ob.patp(state.issuingPoint)}`}</code>
150 onChange={this.handleSetUnset}
156 <StatelessTransaction
157 ref={this.statelessRef}
158 createUnsignedTxn={this.createUnsignedTxn}
159 canGenerate={canGenerate}
166const SetProxy = compose(
171export const SetManagementProxy = props => (
172 <SetProxy {...props} proxyType={PROXY_TYPE.MANAGEMENT_PROXY} />
175export const SetSpawnProxy = props => (
176 <SetProxy {...props} proxyType={PROXY_TYPE.SPAWN_PROXY} />
179export const SetTransferProxy = props => (
180 <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