on aee35bb help sign in
bridge/src/views/CancelTransfer.js
80 lines 2.0 kB history raw
1import Maybe from 'folktale/maybe';
2import React from 'react';
3import { 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';
14import View from 'components/View';
16class CancelTransfer extends React.Component {
17 constructor(props) {
18 super(props);
20 const pointInTransfer = need.pointCursor(props.pointCursor);
22 this.state = {
23 proxyAddress: '',
24 pointInTransfer: pointInTransfer,
25 };
27 this.createUnsignedTxn = this.createUnsignedTxn.bind(this);
28 }
30 createUnsignedTxn() {
31 const { props } = this;
33 const validContracts = need.contracts(props.contracts);
34 const validPoint = need.pointCursor(props.pointCursor);
35 //TODO this.state.pointInTransfer ?
37 const txn = azimuth.ecliptic.setTransferProxy(
38 validContracts,
39 validPoint,
40 ETH_ZERO_ADDR
41 );
43 return Maybe.Just(txn);
44 }
46 render() {
47 const { props, state } = this;
49 const online = Maybe.Just.hasInstance(props.web3);
51 const proxy = online
52 ? props.pointCache[state.pointInTransfer].transferProxy
53 : 'any outgoing addresses';
55 // const canGenerate = validAddress === true
57 const canGenerate = true;
59 return (
60 <View>
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 </View>
72 );
73 }
76export default compose(
77 withNetwork,
78 withPointCursor,
79 withPointCache
80)(CancelTransfer);