@@ -1,434 +0,0 @@
1−import { Just, Nothing } from 'folktale/maybe';
2−import React from 'react';
3−import * as azimuth from 'azimuth-js';
4−import * as need from 'lib/need';
6−import View from 'components/View';
15−} from '../components/old/Base';
17−import { randomPatq, compose } from '../lib/lib';
18−import { ROUTE_NAMES } from '../lib/routeNames';
19−import { withHistory } from '../store/history';
22− ownershipWalletFromTicket,
24−} from '../lib/wallet';
25−import { BRIDGE_ERROR } from '../lib/error';
30−} from '../lib/invite';
31−import { generateWallet, claimPointFromInvite } from '../lib/invite';
32−import { withNetwork } from '../store/network';
33−import { withWallet } from '../store/wallet';
34−import { Grid } from 'indigo-react';
36−class InviteTicket extends React.Component {
42− inviteWallet: Nothing(),
45− realPoint: Nothing(),
46− realWallet: Nothing(),
50− stage: INVITE_STAGES.INVITE_LOGIN,
51− transactionProgress: TRANSACTION_STATES.GENERATING,
54− this.pointPlaceholder = randomPatq(4);
55− this.ticketPlaceholder = randomPatq(12);
57− this.handleInviteTicketInput = this.handleInviteTicketInput.bind(this);
58− this.handleVerifyTicketInput = this.handleVerifyTicketInput.bind(this);
59− this.updateProgress = this.updateProgress.bind(this);
60− this.pushWalletState = this.pushWalletState.bind(this);
61− this.navigateLogin = this.navigateLogin.bind(this);
64− pushWalletState(walletState) {
66− walletStates: this.state.walletStates.concat(walletState),
71− this.props.history.popAndPush(ROUTE_NAMES.LOGIN);
74− handleInviteTicketInput(inviteTicket) {
75− this.setState({ inviteTicket });
78− handleVerifyTicketInput(verifyTicket) {
79− this.setState({ verifyTicket });
82− updateTransactionProgress(transactionProgress) {
83− this.setState({ transactionProgress });
86− async unlockInviteWallet(inviteTicket) {
88− walletStates: this.state.walletStates.concat(WALLET_STATES.UNLOCKING),
89− stage: INVITE_STAGES.INVITE_WALLET,
92− //NOTE ~zod because tmp wallet
93− const ownership = await ownershipWalletFromTicket(inviteTicket, 0);
94− const mnemonic = ownership.seed;
95− //TODO isn't all this accessible in the ownership object?
96− const inviteWallet = walletFromMnemonic(
102− throw BRIDGE_ERROR.MISSING_WALLET;
106− const addr = inviteWallet.address;
108− const contracts = need.contracts(this.props.contracts);
110− const incoming = await azimuth.azimuth.getTransferringFor(contracts, addr);
113− walletStates: this.state.walletStates.concat(WALLET_STATES.GENERATING),
116− let realPoint = Nothing();
117− let realWallet = Nothing();
120− if (incoming.length > 0) {
121− let pointNum = parseInt(incoming[0], 10);
122− realPoint = Just(pointNum);
128− let genWallet = await generateWallet(pointNum);
130− realWallet = Just(genWallet);
131− if (incoming.length > 1) {
132− //TODO notify user "...and others / ticket reusable"
136− 'Invite code has no claimable ship. Check your invite code and try again.',
142− inviteWallet: Just(inviteWallet),
143− // dev mode: uncomment this out to autofill verified ticket
144− verifyTicket: !Nothing.hasInstance(realWallet)
145− ? realWallet.value.ticket
147− walletStates: this.state.walletStates.concat(WALLET_STATES.RENDERING),
152− getTicketElement() {
153− const phTick = this.ticketPlaceholder;
155− let isLogin = this.state.stage === INVITE_STAGES.INVITE_LOGIN;
156− let isVerify = this.state.stage === INVITE_STAGES.INVITE_VERIFY;
158− if (isLogin || isVerify) {
159− let value = isLogin ? this.state.inviteTicket : this.state.verifyTicket;
160− let handler = isLogin
161− ? this.handleInviteTicketInput
162− : this.handleVerifyTicketInput;
163− let label = isLogin ? 'Activation code' : 'ticket';
165− // if realWallet is Just, then VerifyTicketInput appropriate contents; if Nothing, remain Nothing
166− const Verified = this.state.realWallet.map(realWallet =>
167− VerifyTicketInput(realWallet.ticket)
170− // Verified.getOrElse(TicketInput) falls back to TicketInput if Verified is Nothing
171− const TicketElem = isVerify
172− ? Verified.getOrElse(TicketInput)
177− className="mono mt-8"
179− prop-format="innerLabel"
183− placeholder={`e.g. ${phTick}`}
186− <InnerLabel>{label}</InnerLabel>
195− const { stage } = this.state;
197− let progressWidth = this.state.transactionProgress.pct;
200− stage === INVITE_STAGES.INVITE_LOGIN ? (
201− <h1 className="text-700 mt-15">Welcome</h1>
202− ) : stage === INVITE_STAGES.INVITE_WALLET ? (
204− <h1 className="fs-6 lh-8 mb-3">Passport</h1>
206− A passport is your digital identity. You will use your passport to
207− access your true computer, send payments, and administer your
208− identity. So naturally, you must keep this secure.
211− After you’ve downloaded your passport, back up the ticket manually
212− or store on a trusted device.
215− ) : stage === INVITE_STAGES.INVITE_VERIFY ? (
217− <h1 className="fs-6 lh-8 mb-3">Verify Passport</h1>
219− Afer you download your passport, verify your custody. Your passport
220− should be a folder of image files. One of them is your Master
221− Ticket. Open it and enter the 4 word phrase below (with hyphens).
224− ) : INVITE_STAGES.INVITE_TRANSACTIONS ? (
225− this.state.transactionProgress.label ===
226− TRANSACTION_STATES.DONE.label ? (
228− <h1 className="fs-6 lh-8 mb-3">
229− <span>Success</span>
230− <span className="ml-4 green">✓</span>
232− <p>Transferring to Bridge...</p>
236− <h1 className="fs-6 lh-8 mb-3">Submitting</h1>
237− <p className="mt-4 mb-4">
238− This step can take up to five minutes. Please do not leave this
239− page until the transactions are complete.
241− <div className="passport-progress mb-2">
243− className="passport-progress-filled"
244− style={{ width: progressWidth }}
247− <div className="flex justify-between">
248− <div className="text-mono text-sm lh-6 green-dark">
249− {this.state.transactionProgress.label}
259− updateProgress(notification) {
261− notification.type === 'progress'
262− ? { transactionProgress: notification.value }
263− : notification.type === 'notify'
264− ? { errors: [notification.value] }
267− this.setState(newState);
270− getContinueButton() {
280− const { web3, contracts, setUrbitWallet } = this.props;
282− const btnColor = this.state.walletStates.includes(WALLET_STATES.PAPER_READY)
286− const clickHandler =
287− stage === INVITE_STAGES.INVITE_LOGIN
289− this.unlockInviteWallet(inviteTicket);
291− : stage === INVITE_STAGES.INVITE_WALLET
294− stage: INVITE_STAGES.INVITE_VERIFY,
297− : stage === INVITE_STAGES.INVITE_VERIFY
300− stage: INVITE_STAGES.INVITE_TRANSACTIONS,
301− walletStates: this.state.walletStates.concat(
302− WALLET_STATES.TRANSACTIONS
306− claimPointFromInvite({
307− inviteWalletM: inviteWallet,
308− realWalletM: realWallet,
309− realPointM: realPoint,
310− realTicket: verifyTicket,
314− updateProgress: this.updateProgress,
317− this.props.history.pop();
323− const ticketMatches = this.state.realWallet.matchWith({
324− Just: wal => wal.value.ticket === this.state.verifyTicket,
325− Nothing: () => false,
328− const continueReady =
329− stage === INVITE_STAGES.INVITE_WALLET
330− ? walletStates.includes(WALLET_STATES.DOWNLOADED)
331− : stage === INVITE_STAGES.INVITE_VERIFY
336− stage === INVITE_STAGES.INVITE_TRANSACTIONS ? null : (
340− prop-color={btnColor}
341− disabled={!continueReady}
342− onClick={clickHandler}>
351− const { stage } = this.state;
353− if (stage === INVITE_STAGES.INVITE_LOGIN) return null;
356− <div className="mt-6 mb-8">
358− className={`fs-35 mr-3 ${stage !== INVITE_STAGES.INVITE_WALLET &&
363− className={`fs-35 mr-3 ${stage !== INVITE_STAGES.INVITE_VERIFY &&
368− className={`fs-35 mr-3 ${stage !==
369− INVITE_STAGES.INVITE_TRANSACTIONS && 'gray-20'}`}>
377− if (this.state.errors.length === 0) return null;
379− let errorElems = this.state.errors.map(e => <span>{e}</span>);
383− <h3 className={'mb-2'}>{'Warning'}</h3>
390− let stageDisplay = this.getStageDisplay();
391− let stageText = this.getStageText();
392− let ticketElem = this.getTicketElement();
393− let continueButton = this.getContinueButton();
394− let errorDisplay = this.getErrors();
399− <Grid.Item half={1}>
406− {this.state.stage === INVITE_STAGES.INVITE_LOGIN && (
410− className={`block mt-4`}
411− onClick={this.navigateLogin}>
416− <Grid.Item half={2}>
418− point={this.state.realPoint}
419− wallet={this.state.realWallet}
420− walletStates={this.state.walletStates}
421− pushWalletState={this.pushWalletState}
430−export default compose(