@@ -1,188 +0,0 @@
1−import { Just, Nothing } from 'folktale/maybe'
2−import React from 'react'
3−import { pour } from 'sigil-js'
4−import * as ob from 'urbit-ob'
5−import * as azimuth from 'azimuth-js'
6−
7−import { addressFromSecp256k1Public, EthereumWallet } from '../lib/wallet'
8−import { ROUTE_NAMES } from '../lib/router'
9−
10−import PointList from '../components/PointList'
11−import ReactSVGComponents from '../components/ReactSVGComponents'
12−import KeysAndMetadata from './Point/KeysAndMetadata'
13−import Actions from './Point/Actions'
14−import { BRIDGE_ERROR } from '../lib/error'
15−import { Row, Col, Warning, Button, H1, H3 } from '../components/Base'
16−
17−import { generateWallet, downloadWallet } from '../lib/invite'
18−
19−// for wallet generation
20−import PaperCollateralRenderer from 'PaperCollateralRenderer'
21−
22−class InviteWallet extends React.Component {
23−
24− constructor(props) {
25− super(props)
26−
27− this.state = {
28− loaded: false,
29− point: Nothing(),
30− wallet: Nothing(),
31− paper: Nothing(),
32− downloaded: false
33− }
34−
35− this.download = this.download.bind(this)
36− this.proceed = this.proceed.bind(this)
37− }
38−
39− async componentDidMount() {
40− const { web3, wallet, contracts, setPointCursor } = this.props
41−
42− web3.chain(_ =>
43− contracts.chain(ctrcs =>
44− wallet.chain(async wal => {
45− const addr = addressFromSecp256k1Public(wal.publicKey);
46− console.log('fetching incoming for', addr)
47− const incoming = await azimuth.azimuth.getTransferringFor(ctrcs, addr)
48− console.log('incoming', incoming)
49−
50− let point = Nothing();
51− let wallet = Nothing();
52−
53− if (incoming.length > 0) {
54− let pointNum = parseInt(incoming[0]);
55− point = Just(pointNum);
56− wallet = await generateWallet(pointNum);
57− if (incoming.length > 1) {
58− //TODO notify user "...and others / ticket reusable"
59− }
60− }
61− this.setState({loaded: true, point: point, wallet: Just(wallet)})
62− })))
63− }
64−
65− componentDidUpdate(prevProps) {
66− //
67− }
68−
69− async download() {
70− let result = await downloadWallet(this.state.paper)
71− this.setState({
72− downloaded: true
73− })
74− }
75−
76− proceed() {
77− this.props.pushRoute(ROUTE_NAMES.INVITE_VERIFY, {
78− ticket: this.state.wallet.value.ticket,
79− point: parseInt(this.state.point.value)
80− });
81− }
82−
83− render() {
84− const { loaded, point, wallet, paper, downloaded } = this.state;
85−
86− let loading;
87− if (!loaded) {
88− loading = ( <div>{ 'Loading...' }</div> );
89− }
90−
91− let balanceWarning;
92− if (loaded && Nothing.hasInstance(point)) {
93− balanceWarning = (
94− <Warning>
95− <h3 className={'mb-2'}>{'Warning'}</h3>
96− {
97− 'This invite has no claimable balance.'
98− }
99− </Warning>
100− );
101− }
102−
103− // let pointOverview;
104− // if (loaded && Just.hasInstance(point)) {
105− // const name = ob.patp(point.value);
106− // const sigil = pour({
107− // patp: name,
108− // renderer: ReactSVGComponents,
109− // size: 256
110− // });
111− // pointOverview = (
112− // //TODO Passport display component
113− // <>
114− // <div className={'mt-12 pt-6'}>
115− // { sigil }
116− // </div>
117− // <H3><code>{ name }</code></H3>
118− // </>
119− // );
120− // }
121−
122− let downloadButtonContents = 'Download wallet';
123− if ( Nothing.hasInstance(this.state.wallet) ||
124− Nothing.hasInstance(this.state.paper) ) {
125− downloadButtonContents = (
126− <>
127− <span className="btn-spinner"></span>
128− {'Generating wallet...'}
129− </>
130− );
131− }
132−
133− let downloadButton;
134− let nextButton;
135− if (loaded) {
136− downloadButton = (
137− <Button
138− className={'mt-8'}
139− prop-size={'lg wide'}
140− disabled={( Nothing.hasInstance(this.state.wallet) ||
141− Nothing.hasInstance(this.state.paper) )}
142− onClick={this.download}
143− >
144− <span className="relative">
145− { downloadButtonContents }
146− </span>
147− </Button>
148− );
149−
150− nextButton = (
151− <Button
152− className={'mt-8'}
153− prop-size={'lg wide'}
154− disabled={!this.state.downloaded}
155− onClick={this.proceed}
156− >
157− {'Proceed'}
158− </Button>
159− );
160− }
161−
162− let paperRenderer;
163− if ( Just.hasInstance(this.state.wallet) &&
164− Nothing.hasInstance(this.state.paper) ) {
165− console.log('rendering for', point.value)
166− paperRenderer = (
167− <PaperCollateralRenderer
168− wallet={{[point.value]: wallet.value}}
169− className={'extremely-hidden'}
170− callback={data => {
171− console.log('got paper', data);
172− this.setState({isRendering: false, paper: data})
173− }}
174− mode={'REGISTRATION'} />
175− );
176− }
177−
178− return (
179− <Row>
180− <Col>
181− { paperRenderer }
182− </Col>
183− </Row>
184− )
185− }
186−}
187−
188−export default InviteWallet