@@ -1,7 +1,14 @@
1−import Maybe from 'folktale/maybe'
1+import { Just, Nothing } from 'folktale/maybe'
22import React from 'react'
33import { Button } from '../components/Base'
4−import { InnerLabel, ValidatedSigil, PointInput, TicketInput } from '../components/Base'
4+import {
5+ InnerLabel,
6+ ValidatedSigil,
7+ PointInput,
8+ TicketInput,
9+ Input,
10+ InputCaption
11+ } from '../components/Base'
512import { Row, Col, H1, P } from '../components/Base'
613import * as kg from '../../../node_modules/urbit-key-generation/dist/index'
714import * as ob from 'urbit-ob'
@@ -26,6 +33,7 @@ class Ticket extends React.Component {
2633 this.state = {
2734 ticket: '',
2835 pointName: '',
36+ passphrase: '',
2937 isUnlocking: false
3038 }
3139
@@ -33,6 +41,7 @@ class Ticket extends React.Component {
3341 this.ticketPlaceholder = placeholder(8)
3442
3543 this.handleTicketInput = this.handleTicketInput.bind(this)
44+ this.handlePassphraseInput = this.handlePassphraseInput.bind(this)
3645 this.handlePointNameInput = this.handlePointNameInput.bind(this)
3746 }
3847
@@ -40,19 +49,17 @@ class Ticket extends React.Component {
4049 this.setState({ ticket })
4150 }
4251
52+ handlePassphraseInput(passphrase) {
53+ this.setState({ passphrase })
54+ }
55+
4356 handlePointNameInput(pointName) {
4457 if (pointName.length < 15) {
4558 this.setState({ pointName })
4659 }
4760 }
4861
49− // buttonTriState = (wallet) => {
50− // if (wallet.isNothing()) return 'blue'
51− // if (wallet === false) return 'yellow'
52− // if (Maybe.Nothing.hasInstance(wallet)) return 'green'
53− // }
54−
55− async walletFromTicket(ticket, pointName) {
62+ async walletFromTicket(ticket, pointName, passphrase) {
5663 const { setWallet, setUrbitWallet } = this.props
5764
5865 this.setState({
@@ -61,12 +68,13 @@ class Ticket extends React.Component {
6168
6269 const urbitWallet = await kg.generateWallet({
6370 ticket: ticket,
64− ship: ob.patp2dec(pointName)
71+ ship: ob.patp2dec(pointName),
72+ passphrase: passphrase
6573 })
6674 const mnemonic = urbitWallet.ownership.seed
67− const wallet = walletFromMnemonic(mnemonic, DEFAULT_HD_PATH)
75+ const wallet = walletFromMnemonic(mnemonic, DEFAULT_HD_PATH, passphrase)
6876 setWallet(wallet)
69− setUrbitWallet(Maybe.Just(urbitWallet))
77+ setUrbitWallet(Just(urbitWallet))
7078
7179 this.setState({
7280 isUnlocking: false
@@ -75,7 +83,7 @@ class Ticket extends React.Component {
7583
7684 render() {
7785 const { popRoute, pushRoute, wallet } = this.props
78− const { ticket, pointName } = this.state
86+ const { ticket, pointName, passphrase } = this.state
7987
8088 const phPoint = this.pointPlaceholder
8189 const phTick = this.ticketPlaceholder
@@ -119,12 +127,29 @@ class Ticket extends React.Component {
119127 <InnerLabel>{ 'Ticket' }</InnerLabel>
120128 </TicketInput>
121129
130+ <InputCaption>
131+ { 'If your wallet requires a passphrase, you may enter it below.' }
132+ </InputCaption>
133+
134+ <Input
135+ className='pt-8'
136+ prop-size='md'
137+ prop-format='innerLabel'
138+ name='passphrase'
139+ type='password'
140+ value={ passphrase }
141+ autocomplete='off'
142+ onChange={ this.handlePassphraseInput }>
143+ <InnerLabel>{'Passphrase'}</InnerLabel>
144+ </Input>
145+
122146 <Button
123147 className={'mt-8'}
124148 prop-size={'lg wide'}
125− disabled={this.state.isUnlocking || Maybe.Just.hasInstance(wallet)}
126− // prop-color={this.buttonTriState(wallet)}
127− onClick={() => this.walletFromTicket(ticket, pointName)}>
149+ disabled={this.state.isUnlocking || Just.hasInstance(wallet)}
150+ onClick={
151+ () => this.walletFromTicket(ticket, pointName, passphrase)
152+ }>
128153
129154 <span className="relative">
130155 {this.state.isUnlocking &&
@@ -137,7 +162,7 @@ class Ticket extends React.Component {
137162 <Button
138163 className={'mt-4'}
139164 prop-size={'xl wide'}
140− disabled={ Maybe.Nothing.hasInstance(wallet) }
165+ disabled={ Nothing.hasInstance(wallet) }
141166 onClick={ () => {
142167 popRoute()
143168 pushRoute(ROUTE_NAMES.SHIPS)