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