import { Just, Nothing } from 'folktale/maybe'; import React from 'react'; import { Button } from '../components/old/Base'; import { InnerLabel, ValidatedSigil, PointInput, TicketInput, Input, InputCaption, } from '../components/old/Base'; import { H1, P } from '../components/old/Base'; import { randomPatq, compose } from '../lib/lib'; import { ROUTE_NAMES } from '../lib/routeNames'; import { withHistory } from '../store/history'; import { urbitWalletFromTicket } from '../lib/wallet'; import { withWallet } from '../store/wallet'; import View from 'components/View'; class Ticket extends React.Component { constructor(props) { super(props); this.state = { ticket: '', pointName: '', passphrase: '', isUnlocking: false, }; this.pointPlaceholder = randomPatq(4); this.ticketPlaceholder = randomPatq(8); this.handleTicketInput = this.handleTicketInput.bind(this); this.handlePassphraseInput = this.handlePassphraseInput.bind(this); this.handlePointNameInput = this.handlePointNameInput.bind(this); } handleTicketInput(ticket) { this.setState({ ticket }); } handlePassphraseInput(passphrase) { this.setState({ passphrase }); } handlePointNameInput(pointName) { if (pointName.length < 15) { this.setState({ pointName }); } } async walletFromTicket(ticket, pointName, passphrase) { this.setState({ isUnlocking: true, }); const uhdw = await urbitWalletFromTicket(ticket, pointName, passphrase); this.props.setUrbitWallet(Just(uhdw)); this.setState({ isUnlocking: false, }); } render() { const { history, wallet } = this.props; const { ticket, pointName, passphrase } = this.state; const phPoint = this.pointPlaceholder; const phTick = this.ticketPlaceholder; return (

{'Authenticate'}

{`Please enter your point and Urbit master ticket here. This information is written on your Urbit HD paper wallets.`}

{'Point'} {'Ticket'} {'If your wallet requires a passphrase, you may enter it below.'} {'Passphrase'}
); } } export default compose( withHistory, withWallet )(Ticket);