@@ -1,7 +1,14 @@
1−import Maybe from 'folktale/maybe'
1+import { Just, Nothing } from 'folktale/maybe'
2import React from 'react'
2import React from 'react'
3import { Button } from '../components/Base'
3import { Button } from '../components/Base'
4−import { InnerLabel, ValidatedSigil, PointInput, TicketInput } from '../components/Base'
11+ } from '../components/Base'
5import { Row, Col, H1, P } from '../components/Base'
12import { Row, Col, H1, P } from '../components/Base'
6import * as kg from '../../../node_modules/urbit-key-generation/dist/index'
13import * as kg from '../../../node_modules/urbit-key-generation/dist/index'
7import * as ob from 'urbit-ob'
14import * as ob from 'urbit-ob'
@@ -26,6 +33,7 @@ class Ticket extends React.Component {
26 this.state = {
33 this.state = {
27 ticket: '',
34 ticket: '',
28 pointName: '',
35 pointName: '',
29 isUnlocking: false
37 isUnlocking: false
@@ -33,6 +41,7 @@ class Ticket extends React.Component {
33 this.ticketPlaceholder = placeholder(8)
41 this.ticketPlaceholder = placeholder(8)
35 this.handleTicketInput = this.handleTicketInput.bind(this)
43 this.handleTicketInput = this.handleTicketInput.bind(this)
44+ this.handlePassphraseInput = this.handlePassphraseInput.bind(this)
36 this.handlePointNameInput = this.handlePointNameInput.bind(this)
45 this.handlePointNameInput = this.handlePointNameInput.bind(this)
@@ -40,19 +49,17 @@ class Ticket extends React.Component {
40 this.setState({ ticket })
49 this.setState({ ticket })
52+ handlePassphraseInput(passphrase) {
53+ this.setState({ passphrase })
43 handlePointNameInput(pointName) {
56 handlePointNameInput(pointName) {
44 if (pointName.length < 15) {
57 if (pointName.length < 15) {
45 this.setState({ pointName })
58 this.setState({ pointName })
49− // buttonTriState = (wallet) => {
50− // if (wallet.isNothing()) return 'blue'
51− // if (wallet === false) return 'yellow'
52− // if (Maybe.Nothing.hasInstance(wallet)) return 'green'
55− async walletFromTicket(ticket, pointName) {
62+ async walletFromTicket(ticket, pointName, passphrase) {
56 const { setWallet, setUrbitWallet } = this.props
63 const { setWallet, setUrbitWallet } = this.props
58 this.setState({
65 this.setState({
@@ -61,12 +68,13 @@ class Ticket extends React.Component {
62 const urbitWallet = await kg.generateWallet({
69 const urbitWallet = await kg.generateWallet({
63 ticket: ticket,
70 ticket: ticket,
64− ship: ob.patp2dec(pointName)
71+ ship: ob.patp2dec(pointName),
72+ passphrase: passphrase
66 const mnemonic = urbitWallet.ownership.seed
74 const mnemonic = urbitWallet.ownership.seed
67− const wallet = walletFromMnemonic(mnemonic, DEFAULT_HD_PATH)
75+ const wallet = walletFromMnemonic(mnemonic, DEFAULT_HD_PATH, passphrase)
68 setWallet(wallet)
76 setWallet(wallet)
69− setUrbitWallet(Maybe.Just(urbitWallet))
77+ setUrbitWallet(Just(urbitWallet))
71 this.setState({
79 this.setState({
72 isUnlocking: false
80 isUnlocking: false
@@ -75,7 +83,7 @@ class Ticket extends React.Component {
76 render() {
84 render() {
77 const { popRoute, pushRoute, wallet } = this.props
85 const { popRoute, pushRoute, wallet } = this.props
78− const { ticket, pointName } = this.state
86+ const { ticket, pointName, passphrase } = this.state
80 const phPoint = this.pointPlaceholder
88 const phPoint = this.pointPlaceholder
81 const phTick = this.ticketPlaceholder
89 const phTick = this.ticketPlaceholder
@@ -119,12 +127,29 @@ class Ticket extends React.Component {
119 <InnerLabel>{ 'Ticket' }</InnerLabel>
127 <InnerLabel>{ 'Ticket' }</InnerLabel>
120 </TicketInput>
128 </TicketInput>
131+ { 'If your wallet requires a passphrase, you may enter it below.' }
137+ prop-format='innerLabel'
140+ value={ passphrase }
142+ onChange={ this.handlePassphraseInput }>
143+ <InnerLabel>{'Passphrase'}</InnerLabel>
123 className={'mt-8'}
147 className={'mt-8'}
124 prop-size={'lg wide'}
148 prop-size={'lg wide'}
125− disabled={this.state.isUnlocking || Maybe.Just.hasInstance(wallet)}
149+ disabled={this.state.isUnlocking || Just.hasInstance(wallet)}
126− // prop-color={this.buttonTriState(wallet)}
150+ onClick={
127− onClick={() => this.walletFromTicket(ticket, pointName)}>
151+ () => this.walletFromTicket(ticket, pointName, passphrase)
129 <span className="relative">
154 <span className="relative">
130 {this.state.isUnlocking &&
155 {this.state.isUnlocking &&
@@ -137,7 +162,7 @@ class Ticket extends React.Component {
138 className={'mt-4'}
163 className={'mt-4'}
139 prop-size={'xl wide'}
164 prop-size={'xl wide'}
140− disabled={ Maybe.Nothing.hasInstance(wallet) }
165+ disabled={ Nothing.hasInstance(wallet) }
141 onClick={ () => {
166 onClick={ () => {
142 popRoute()
167 popRoute()
143 pushRoute(ROUTE_NAMES.SHIPS)
168 pushRoute(ROUTE_NAMES.SHIPS)