import Maybe from 'folktale/maybe'; import React from 'react'; import * as azimuth from 'azimuth-js'; import * as ob from 'urbit-ob'; import * as need from '../lib/need'; import { H1, InnerLabel, ShowBlockie, P, Anchor } from '../components/old/Base'; import { AddressInput } from '../components/old/Base'; import StatelessTransaction from '../components/old/StatelessTransaction'; import { NETWORK_TYPES } from '../lib/network'; import { isValidAddress } from '../lib/wallet'; import { withNetwork } from '../store/network'; import { compose } from '../lib/lib'; import { withPointCursor } from '../store/pointCursor'; import View from 'components/View'; class Transfer extends React.Component { constructor(props) { super(props); const issuingPoint = need.point(props.pointCursor); this.state = { receivingAddress: '', issuingPoint: issuingPoint, }; this.handleAddressInput = this.handleAddressInput.bind(this); this.createUnsignedTxn = this.createUnsignedTxn.bind(this); this.statelessRef = React.createRef(); } handleAddressInput(receivingAddress) { this.setState({ receivingAddress }); this.statelessRef.current.clearTxn(); } handleConfirmAvailability() { this.confirmPointAvailability().then(r => { this.setState({ isAvailable: r }); }); } createUnsignedTxn() { const { state, props } = this; const validContracts = need.contracts(props.contracts); const validPoint = need.point(props.pointCursor); const txn = azimuth.ecliptic.setTransferProxy( validContracts, validPoint, state.receivingAddress ); return Maybe.Just(txn); } render() { const { props, state } = this; const validAddress = isValidAddress(state.receivingAddress); const canGenerate = validAddress === true; const esvisible = props.networkType === NETWORK_TYPES.ROPSTEN || props.networkType === NETWORK_TYPES.MAINNET; const esdomain = props.networkType === NETWORK_TYPES.ROPSTEN ? 'ropsten.etherscan.io' : 'etherscan.io'; return (

{'Transfer'} {` ${ob.patp(state.issuingPoint)} `} {'To a New Owner'}

{`Please provide the Ethereum address of the new owner. You own these points until the recipient accepts the incoming transfer. You may cancel the transfer until the transfer is accepted.`}

this.handleAddressInput(v)}> {'New ownership address'} {'View on Etherscan ↗'}
); } } export default compose( withNetwork, withPointCursor )(Transfer);