on e366ef3 help sign in
bridge/src/views/CancelTransfer.js
81 lines 2.0 kB history raw
1import Maybe from 'folktale/maybe';
2import React from 'react';
3import { Row, Col, H1, P } from '../components/old/Base';
4import * as azimuth from 'azimuth-js';
5import * as ob from 'urbit-ob';
6import * as need from '../lib/need';
8import StatelessTransaction from '../components/old/StatelessTransaction';
9import { ETH_ZERO_ADDR } from '../lib/wallet';
10import { withNetwork } from '../store/network';
11import { compose } from '../lib/lib';
12import { withPointCursor } from '../store/pointCursor';
13import { withPointCache } from '../store/pointCache';
15class CancelTransfer extends React.Component {
16 constructor(props) {
17 super(props);
19 const pointInTransfer = need.pointCursor(props);
21 this.state = {
22 proxyAddress: '',
23 pointInTransfer: pointInTransfer,
24 };
26 this.createUnsignedTxn = this.createUnsignedTxn.bind(this);
27 }
29 createUnsignedTxn() {
30 const { props } = this;
32 const validContracts = need.contracts(props);
34 const validPoint = need.pointCursor(props); //TODO this.state.pointInTransfer ?
36 const txn = azimuth.ecliptic.setTransferProxy(
37 validContracts,
38 validPoint,
39 ETH_ZERO_ADDR
40 );
42 return Maybe.Just(txn);
43 }
45 render() {
46 const { props, state } = this;
48 const online = Maybe.Just.hasInstance(props.web3);
50 const proxy = online
51 ? props.pointCache[state.pointInTransfer].transferProxy
52 : 'any outgoing addresses';
54 // const canGenerate = validAddress === true
56 const canGenerate = true;
58 return (
59 <Row>
60 <Col>
61 <H1>
62 {'Cancel Transfer of '}{' '}
63 <code>{` ${ob.patp(state.pointInTransfer)} `}</code>
64 </H1>
66 <P>{`This action will cancel the transfer to ${proxy}.`}</P>
67 <StatelessTransaction
68 canGenerate={canGenerate}
69 createUnsignedTxn={this.createUnsignedTxn}
70 />
71 </Col>
72 </Row>
73 );
74 }
77export default compose(
78 withNetwork,
79 withPointCursor,
80 withPointCache
81)(CancelTransfer);