on master help sign in
Use latest keygen-js
f1f5966Fang
package.json+1−1
@@ -43,7 +43,7 @@
43 "secp256k1": "^3.5.2",
43 "secp256k1": "^3.5.2",
44 "sigil-js": "github:urbit/sigil-js#f7f29c5",
44 "sigil-js": "github:urbit/sigil-js#f7f29c5",
45 "trezor-connect": "^7.0.1",
45 "trezor-connect": "^7.0.1",
46− "urbit-key-generation": "0.12.1",
46+ "urbit-key-generation": "^0.16.0",
47 "urbit-ob": "^3.1.0",
47 "urbit-ob": "^3.1.0",
48 "web3": "1.0.0-beta.54",
48 "web3": "1.0.0-beta.54",
49 "web3-utils": "^1.0.0-beta.52"
49 "web3-utils": "^1.0.0-beta.52"
src/bridge/lib/wallet.js+14−4
@@ -89,7 +89,7 @@ const eqAddr = (addr0, addr1) =>
89 toChecksumAddress(addr0) === toChecksumAddress(addr1)
89 toChecksumAddress(addr0) === toChecksumAddress(addr1)
90
90
91const urbitWalletFromTicket = async (ticket, point, passphrase) => {
91const urbitWalletFromTicket = async (ticket, point, passphrase) => {
92− if (typeof point === 'string') {
92+ if (typeof point === 'string') { //TODO why not in kg?
93 point = ob.patp2dec(point);
93 point = ob.patp2dec(point);
94 }
94 }
95 let uhdw = await kg.generateWallet({
95 let uhdw = await kg.generateWallet({
@@ -97,12 +97,21 @@ const urbitWalletFromTicket = async (ticket, point, passphrase) => {
97 ship: point,
97 ship: point,
98 passphrase: passphrase
98 passphrase: passphrase
99 });
99 });
100− //TODO remove after keygen-js#61 gets released
101− uhdw.meta.ship = point;
102− uhdw.meta.passphrase = passphrase;
103 return uhdw;
100 return uhdw;
104}
101}
105
102
103+
104+const ownershipWalletFromTicket = async (ticket, point, passphrase) => {
105+ if (typeof point === 'string') { //TODO why not in kg?
106+ point = ob.patp2dec(point);
107+ }
108+ return await kg.generateOwnershipWallet({
109+ ticket,
110+ ship: point,
111+ passphrase
112+ })
113+}
114+
106const walletFromMnemonic = (mnemonic, hdpath, passphrase) => {
115const walletFromMnemonic = (mnemonic, hdpath, passphrase) => {
107 const seed =
116 const seed =
108 bip39.validateMnemonic(mnemonic)
117 bip39.validateMnemonic(mnemonic)
@@ -135,6 +144,7 @@ export {
135 addressFromSecp256k1Public,
144 addressFromSecp256k1Public,
136 eqAddr,
145 eqAddr,
137 urbitWalletFromTicket,
146 urbitWalletFromTicket,
147+ ownershipWalletFromTicket,
138 walletFromMnemonic,
148 walletFromMnemonic,
139 addHexPrefix,
149 addHexPrefix,
140 EthereumWallet
150 EthereumWallet
src/bridge/views/InviteTicket.js+5−5
@@ -6,7 +6,7 @@ import * as azimuth from 'azimuth-js'
6
6
7import { randomPatq } from '../lib/lib'
7import { randomPatq } from '../lib/lib'
8import { ROUTE_NAMES } from '../lib/router'
8import { ROUTE_NAMES } from '../lib/router'
9−import { DEFAULT_HD_PATH, urbitWalletFromTicket,
9+import { DEFAULT_HD_PATH, ownershipWalletFromTicket,
10 walletFromMnemonic, addressFromSecp256k1Public } from '../lib/wallet'
10 walletFromMnemonic, addressFromSecp256k1Public } from '../lib/wallet'
11import { BRIDGE_ERROR } from '../lib/error'
11import { BRIDGE_ERROR } from '../lib/error'
12import { INVITE_STAGES, WALLET_STATES, TRANSACTION_STATES } from '../lib/invite'
12import { INVITE_STAGES, WALLET_STATES, TRANSACTION_STATES } from '../lib/invite'
@@ -71,12 +71,12 @@ class InviteTicket extends React.Component {
71 });
71 });
72
72
73 //NOTE ~zod because tmp wallet
73 //NOTE ~zod because tmp wallet
74− const uhdw = await urbitWalletFromTicket(inviteTicket, '~zod');
74+ const ownership = await ownershipWalletFromTicket(inviteTicket, 0);
75− const mnemonic = uhdw.ownership.seed;
75+ const mnemonic = ownership.seed;
76+ //TODO isn't all this accessible in the ownership object?
76 const inviteWallet = walletFromMnemonic(
77 const inviteWallet = walletFromMnemonic(
77 mnemonic,
78 mnemonic,
78− DEFAULT_HD_PATH,
79+ DEFAULT_HD_PATH
79− uhdw.meta.passphrase
80 ).matchWith({
80 ).matchWith({
81 Just: w => w.value,
81 Just: w => w.value,
82 Nothing: () => {
82 Nothing: () => {
src/walletgen/lib/lib.js+8
@@ -60,6 +60,13 @@ const generateWallet = async (point, ticket, boot) => {
60 return wallet;
60 return wallet;
61}
61}
62
62
63+const generateOwnershipWallet = async (point, ticket) => {
64+ return await kg.generateOwnershipWallet({
65+ ship: point,
66+ ticket
67+ });
68+}
69+
63const seq = num => Array.from(Array(num), (_, i) => i)
70const seq = num => Array.from(Array(num), (_, i) => i)
64
71
65const compose = (...fs) => fs.reduceRight((pF, nF) => (...args) => nF(pF(...args)), v => v)
72const compose = (...fs) => fs.reduceRight((pF, nF) => (...args) => nF(pF(...args)), v => v)
@@ -67,6 +74,7 @@ const compose = (...fs) => fs.reduceRight((pF, nF) => (...args) => nF(pF(...args
67export {
74export {
68 makeTicket,
75 makeTicket,
69 generateWallet,
76 generateWallet,
77+ generateOwnershipWallet,
70 compose,
78 compose,
71 seq,
79 seq,
72}
80}