on master help sign in
fix: login with mnemonic, view points list

included changes: - converted some files to Typescript and added typings to aid debugging - reorganized some crypto utilities and constants - added our first test! ... currently being skipped for now (:

commitb78a856c4fb0d5b29503c94d7c132de5f9945f52 authortomholford <tomholford@users.noreply.github.com> dateSun 27 Jun 2021, 21:16 (5 years ago) parent0162118
38 files changed+216−173
src/form/Inputs.js+1−1 src/lib/authToken.js → src/lib/authToken.ts+13−7 src/lib/constants.js → src/lib/constants.ts+26 src/lib/flowCommand.js → src/lib/flowCommand.ts+9−2 src/lib/keys.js+1−1 src/lib/reticket.js+1−1 src/lib/router.js+1−1 src/lib/tank.js+1−1 src/lib/txn.js+2−2 src/lib/useIsEclipticOwner.js+1−1 src/lib/usePermissionsForPoint.js+1−1 src/lib/utils/crypto.test.ts+19 src/lib/utils/crypto.ts+39 src/lib/validators.js+7−2 src/lib/wallet.js−120 src/lib/wallet.ts+50 src/store/lib/useControlledPointsStore.js+1 src/store/lib/useResidentsStore.js → src/store/lib/useResidentsStore.ts+3−4 src/store/wallet.js+6−5 src/types/bridge-wallet.type.ts+6 src/views/AcceptLockup.js+1−1 src/views/Activate/ActivateCode.js+2−1 src/views/Activate/ActivatePassport.js+4−6 src/views/CancelTransfer.js+1−2 src/views/CreateGalaxy.js+1−1 src/views/Login.js → src/views/Login.tsx src/views/Login/Keystore.js+2−1 src/views/Login/Ledger.js+1−1 src/views/Login/Metamask.js+2−1 src/views/Login/Mnemonic.js+2−1 src/views/Login/PrivateKey.js+3−1 src/views/Login/Ticket.js+2−1 src/views/Login/Trezor.js+1−1 src/views/Points.js+1−1 src/views/Release/Transfer.js+1−1 src/views/UrbitID/ResetKeys/ResetExecute.js+1−1 src/views/UrbitID/SetProxy.js+2−2 src/views/UrbitOS/NetworkingKeys.js+1−1
src/form/Inputs.js+1−1
@@ -10,7 +10,7 @@ import {
1010 stripHexPrefix,
1111 ensureHexPrefix,
1212} from 'form/formatters';
13−import { DEFAULT_HD_PATH } from 'lib/wallet';
13+import { DEFAULT_HD_PATH } from 'lib/constants';
1414import InputSigil from 'components/InputSigil';
1515
1616const PLACEHOLDER_POINT = '~sampel-ponnym';
src/lib/authToken.js → src/lib/authToken.tsrenamed+13−7
@@ -1,16 +1,22 @@
1−import * as secp256k1 from 'secp256k1';
1+import { ecdsaSign } from 'secp256k1';
2+import { keccak256 } from 'web3-utils';
23
3−import { keccak256, WALLET_TYPES } from './wallet';
4+import { WALLET_TYPES } from './constants';
45import { ledgerSignMessage } from './ledger';
56import { trezorSignMessage } from './trezor';
67
78const MESSAGE = 'Bridge Authentication Token';
89
9−function signMessage(privateKey) {
10− const { signature } = secp256k1.sign(
11− keccak256('\x19Ethereum Signed Message:\n' + MESSAGE.length + MESSAGE),
12− privateKey
13− );
10+function signMessage(privateKey: Buffer) {
11+ const msg = '\x19Ethereum Signed Message:\n' + MESSAGE.length + MESSAGE;
12+ // TODO: Signing function expects 32 length Buffer,
13+ // confirm if it is okay / expected to slice it like this?
14+ // Based on reading docs and comment threads, it seems that
15+ // this limit is sometimes enforced, and varies depending on
16+ // the implementation
17+ const msgHash = Buffer.from(keccak256(msg)).slice(0, 32);
18+ const { signature } = ecdsaSign(msgHash, privateKey);
19+
1420 // add key recovery parameter
1521 const ethSignature = new Uint8Array(65);
1622 ethSignature.set(signature);
src/lib/constants.js → src/lib/constants.tsrenamed+26
@@ -74,9 +74,33 @@ const PROFILE_STATES = {
7474
7575const PROGRESS_ANIMATION_DELAY_MS = 500; // .animated-width
7676
77+const DEFAULT_HD_PATH = "m/44'/60'/0'/0/0";
78+const ETH_ZERO_ADDR = '0x0000000000000000000000000000000000000000';
79+const ETH_ZERO_ADDR_SHORT = '0x0';
80+
81+const WALLET_TYPES = {
82+ MNEMONIC: Symbol('MNEMONIC'),
83+ TICKET: Symbol('TICKET'),
84+ SHARDS: Symbol('SHARDS'),
85+ LEDGER: Symbol('LEDGER'),
86+ TREZOR: Symbol('TREZOR'),
87+ PRIVATE_KEY: Symbol('PRIVATE_KEY'),
88+ KEYSTORE: Symbol('KEYSTORE'),
89+ METAMASK: Symbol('METAMASK'),
90+};
91+
92+const NONCUSTODIAL_WALLETS = new Set([
93+ WALLET_TYPES.METAMASK,
94+ WALLET_TYPES.TREZOR,
95+ WALLET_TYPES.LEDGER,
96+]);
97+
7798export {
7899 CHECK_BLOCK_EVERY_MS,
79100 DEFAULT_GAS_PRICE_GWEI,
101+ DEFAULT_HD_PATH,
102+ ETH_ZERO_ADDR,
103+ ETH_ZERO_ADDR_SHORT,
80104 MAX_GAS_PRICE_GWEI,
81105 GAS_LIMITS,
82106 GEN_STATES,
@@ -88,10 +112,12 @@ export {
88112 MAX_STAR,
89113 MIN_PLANET,
90114 MAX_PLANET,
115+ NONCUSTODIAL_WALLETS,
91116 PLANET_ENTROPY_BITS,
92117 STAR_ENTROPY_BITS,
93118 GALAXY_ENTROPY_BITS,
94119 SEED_ENTROPY_BITS,
120+ WALLET_TYPES,
95121 ZOD,
96122 PROGRESS_ANIMATION_DELAY_MS,
97123};
src/lib/flowCommand.js → src/lib/flowCommand.tsrenamed+9−2
@@ -1,5 +1,5 @@
11import { useMemo } from 'react';
2−import { isValidAddress } from './wallet';
2+import { isValidAddress } from './utils/crypto';
33
44// looks into the GET parameters and attempts to construct a "flow" object,
55// which would indicate bridge is to be used for one specific flow.
@@ -21,9 +21,16 @@ const COMMANDS = {
2121 XPUB: 'xpub',
2222};
2323
24+type FlowType = {
25+ kind?: 'takeLockup' | 'btc' | 'xpub';
26+ lock?: 'linear' | 'conditional';
27+ from?: string;
28+ utx?: string;
29+} | null;
30+
2431const useFlowCommand = () => {
2532 const flow = useMemo(() => {
26− let flow = {};
33+ let flow: FlowType = {};
2734
2835 window.location.search
2936 .substr(1)
src/lib/keys.js+1−1
@@ -5,7 +5,7 @@ import * as noun from '../nockjs/noun';
55import * as serial from '../nockjs/serial';
66import * as kg from 'urbit-key-generation';
77
8−import { eqAddr, addHexPrefix } from './wallet';
8+import { addHexPrefix, eqAddr } from './utils/crypto';
99import { shas } from './networkCode';
1010
1111// the curve param for the network keys
src/lib/reticket.js+1−1
@@ -7,7 +7,7 @@ import {
77 deriveNetworkKeys,
88 CRYPTO_SUITE_VERSION,
99} from './keys';
10−import { addHexPrefix } from './wallet';
10+import { addHexPrefix } from './utils/crypto';
1111import {
1212 sendAndAwaitAllSerial,
1313 signTransaction,
src/lib/router.js+1−1
@@ -1,5 +1,5 @@
11import Disclaimer from 'views/Disclaimer';
2−import Login from 'views/Login.js';
2+import Login from 'views/Login';
33import Other from 'views/Login/Other.js';
44import Senate from 'views/Senate';
55import Documents from 'views/Senate/Documents';
src/lib/tank.js+1−1
@@ -3,7 +3,7 @@
33import retry from 'async-retry';
44import { toBN } from 'web3-utils';
55import { RETRY_OPTIONS, waitForTransactionConfirm } from './txn';
6−import { WALLET_TYPES } from 'lib/wallet';
6+import { WALLET_TYPES } from 'lib/constants';
77
88const TANK_ADDRESS = '0x40f0A6db85f8D7A54fF3eA915b040dE8Cd4A0Eb5';
99
src/lib/txn.js+2−2
@@ -7,8 +7,8 @@ import { NETWORK_TYPES } from './network';
77import { ledgerSignTransaction } from './ledger';
88import { trezorSignTransaction } from './trezor';
99import { metamaskSignTransaction, FakeMetamaskTransaction } from './metamask';
10−import { WALLET_TYPES, addHexPrefix } from './wallet';
11−import { CHECK_BLOCK_EVERY_MS } from './constants';
10+import { addHexPrefix } from './utils/crypto';
11+import { CHECK_BLOCK_EVERY_MS, WALLET_TYPES } from './constants';
1212import patp2dec from './patp2dec';
1313
1414const RETRY_OPTIONS = {
src/lib/useIsEclipticOwner.js+1−1
@@ -1,7 +1,7 @@
11import { useWallet } from 'store/wallet';
22import { usePointCache } from 'store/pointCache';
33
4−import { eqAddr } from 'lib/wallet';
4+import { eqAddr } from 'lib/utils/crypto';
55import useLifecycle from './useLifecycle';
66
77export default function useIsEclipticOwner() {
src/lib/usePermissionsForPoint.js+1−1
@@ -5,7 +5,7 @@ import { useNetwork } from 'store/network';
55
66import * as need from 'lib/need';
77
8−import { eqAddr, isZeroAddress } from './wallet';
8+import { eqAddr, isZeroAddress } from './utils/crypto';
99
1010const NULL_PERMISSIONS = {
1111 isActive: false,
src/lib/utils/crypto.test.tsnew file+19
@@ -0,0 +1,19 @@
1+import { mnemonicToSeedSync } from 'bip39';
2+import { bip32 } from 'bitcoinjs-lib';
3+import { bufferedPublicKeyToAddress } from './crypto';
4+
5+describe('#bufferedPublicKeyToAddress', () => {
6+ // TODO: why does this seemingly work in the Mnemonic login flow, but not in a test?
7+ it.skip('derives an address from a public key buffer', () => {
8+ const mnemonic =
9+ 'benefit crew supreme gesture quantum web media hazard theory mercy wing kitten';
10+ const hdpath = "m/44'/60'/0'/0/0";
11+ const seed = mnemonicToSeedSync(mnemonic);
12+ const hd = bip32.fromSeed(seed);
13+ const wallet = hd.derivePath(hdpath);
14+
15+ const expected = 'foo';
16+
17+ expect(bufferedPublicKeyToAddress(wallet.publicKey)).toEqual(expected);
18+ });
19+});
src/lib/utils/crypto.tsnew file+39
@@ -0,0 +1,39 @@
1+import { reduce } from 'lodash';
2+import { isAddress, keccak256, toHex } from 'web3-utils';
3+import { publicToAddress } from 'ethereumjs-util';
4+import { ETH_ZERO_ADDR, ETH_ZERO_ADDR_SHORT } from 'lib/constants';
5+
6+export const stripHexPrefix = (hex: string) => {
7+ return hex.startsWith('0x') ? hex.slice(2) : hex;
8+};
9+
10+export const addHexPrefix = (hex: string) => {
11+ return hex.startsWith('0x') ? hex : `0x${hex}`;
12+};
13+
14+export const isValidAddress = a => '0x0' === a || isAddress(a);
15+
16+export const abbreviateAddress = address =>
17+ `${address.slice(0, 6)}…${address.slice(-4)}`;
18+
19+export const isZeroAddress = a =>
20+ a === ETH_ZERO_ADDR || a === ETH_ZERO_ADDR_SHORT;
21+
22+export const toChecksumAddress = address => {
23+ const addr = stripHexPrefix(address).toLowerCase();
24+ const hash = keccak256(addr).toString('hex');
25+
26+ return reduce(
27+ addr,
28+ (acc, char, idx) =>
29+ parseInt(hash[idx], 16) >= 8 ? acc + char.toUpperCase() : acc + char,
30+ '0x'
31+ );
32+};
33+
34+export const eqAddr = (addr0, addr1) =>
35+ toChecksumAddress(addr0) === toChecksumAddress(addr1);
36+
37+export const bufferedPublicKeyToAddress = (publicKey: Buffer): string => {
38+ return toHex(publicToAddress(publicKey, true).toString('hex'));
39+};
src/lib/validators.js+7−2
@@ -3,10 +3,15 @@ import * as bitcoin from 'bitcoinjs-lib';
33import ob from 'urbit-ob';
44import { includes } from 'lodash';
55
6−import { isValidAddress, ETH_ZERO_ADDR, ETH_ZERO_ADDR_SHORT } from './wallet';
6+import { isValidAddress } from './utils/crypto';
77import patp2dec from './patp2dec';
88import { patpStringLength } from './lib';
9−import { MIN_GALAXY, MAX_GALAXY } from './constants';
9+import {
10+ ETH_ZERO_ADDR,
11+ ETH_ZERO_ADDR_SHORT,
12+ MIN_GALAXY,
13+ MAX_GALAXY,
14+} from './constants';
1015
1116// NOTE: do not use the /g modifier for these regexes
1217// https://stackoverflow.com/a/21373261
src/lib/wallet.jsdeleted−120
@@ -1,120 +0,0 @@
1−import * as bip32 from 'bip32';
2−import * as bip39 from 'bip39';
3−import keccak from 'keccak';
4−import { reduce } from 'lodash';
5−import { Just, Nothing } from 'folktale/maybe';
6−import * as secp256k1 from 'secp256k1';
7−import * as kg from 'urbit-key-generation';
8−import { isAddress } from 'web3-utils';
9−
10−export const DEFAULT_HD_PATH = "m/44'/60'/0'/0/0";
11−export const ETH_ZERO_ADDR = '0x0000000000000000000000000000000000000000';
12−export const ETH_ZERO_ADDR_SHORT = '0x0';
13−
14−export const WALLET_TYPES = {
15− MNEMONIC: Symbol('MNEMONIC'),
16− TICKET: Symbol('TICKET'),
17− SHARDS: Symbol('SHARDS'),
18− LEDGER: Symbol('LEDGER'),
19− TREZOR: Symbol('TREZOR'),
20− PRIVATE_KEY: Symbol('PRIVATE_KEY'),
21− KEYSTORE: Symbol('KEYSTORE'),
22− METAMASK: Symbol('METAMASK'),
23−};
24−
25−export const NONCUSTODIAL_WALLETS = new Set([
26− WALLET_TYPES.METAMASK,
27− WALLET_TYPES.TREZOR,
28− WALLET_TYPES.LEDGER,
29−]);
30−
31−export function EthereumWallet(privateKey) {
32− this.privateKey = privateKey;
33− this.publicKey = secp256k1.publicKeyCreate(this.privateKey);
34− const pub = this.publicKey.toString('hex');
35− this.address = addressFromSecp256k1Public(pub);
36−}
37−
38−export const addressFromSecp256k1Public = pub => {
39− const compressed = false;
40− const uncompressed = secp256k1.publicKeyConvert(
41− Buffer.from(pub, 'hex'),
42− compressed
43− );
44− const chopped = uncompressed.slice(1); // chop parity byte
45− const hashed = keccak256(chopped);
46− const addr = addHexPrefix(hashed.slice(-20).toString('hex'));
47− return toChecksumAddress(addr);
48−};
49−
50−// TODO: move all of these generic crypto helpers to another file
51−export const addHexPrefix = hex =>
52− hex.slice(0, 2) === '0x' ? hex : '0x' + hex;
53−
54−export const stripHexPrefix = hex =>
55− hex.slice(0, 2) === '0x' ? hex.slice(2) : hex;
56−
57−export const keccak256 = str =>
58− keccak('keccak256')
59− .update(str)
60− .digest();
61−
62−export const isValidAddress = a => '0x0' === a || isAddress(a);
63−
64−export const isZeroAddress = a =>
65− a === ETH_ZERO_ADDR || a === ETH_ZERO_ADDR_SHORT;
66−
67−export const toChecksumAddress = address => {
68− const addr = stripHexPrefix(address).toLowerCase();
69− const hash = keccak256(addr).toString('hex');
70−
71− return reduce(
72− addr,
73− (acc, char, idx) =>
74− parseInt(hash[idx], 16) >= 8 ? acc + char.toUpperCase() : acc + char,
75− '0x'
76− );
77−};
78−
79−export const eqAddr = (addr0, addr1) =>
80− toChecksumAddress(addr0) === toChecksumAddress(addr1);
81−
82−export const urbitWalletFromTicket = async (ticket, point, passphrase) => {
83− return await kg.generateWallet({
84− ticket: ticket,
85− ship: point,
86− passphrase: passphrase,
87− });
88−};
89−
90−export const walletFromMnemonic = (
91− mnemonic,
92− hdpath,
93− passphrase,
94− skipMnemonicCheck
95−) => {
96− const seed =
97− skipMnemonicCheck || bip39.validateMnemonic(mnemonic)
98− ? Just(bip39.mnemonicToSeed(mnemonic, passphrase))
99− : Nothing();
100−
101− const toWallet = (sd, path) => {
102− let wal;
103− try {
104− const hd = bip32.fromSeed(sd);
105− wal = hd.derivePath(path);
106− wal.address = addressFromSecp256k1Public(wal.publicKey);
107− wal.passphrase = passphrase || '';
108− wal = Just(wal);
109− } catch (_) {
110− wal = Nothing();
111− }
112− return wal;
113− };
114−
115− const wallet = seed.chain(sd => toWallet(sd, hdpath));
116− return wallet;
117−};
118−
119−export const abbreviateAddress = address =>
120− `${address.slice(0, 6)}…${address.slice(-4)}`;
src/lib/wallet.tsnew file+50
@@ -0,0 +1,50 @@
1+// import * as bip32 from 'bip32';
2+import * as bip39 from 'bip39';
3+import { bip32 } from 'bitcoinjs-lib';
4+import { Just, Nothing } from 'folktale/maybe';
5+import * as secp256k1 from 'secp256k1';
6+import * as kg from 'urbit-key-generation';
7+import { publicToAddress } from 'ethereumjs-util';
8+import { toHex } from 'web3-utils';
9+import { bufferedPublicKeyToAddress } from './utils/crypto';
10+
11+export function EthereumWallet(privateKey) {
12+ this.privateKey = privateKey;
13+ this.publicKey = secp256k1.publicKeyCreate(this.privateKey);
14+ const pub = this.publicKey.toString('hex');
15+ this.address = publicToAddress(pub).toString('hex');
16+}
17+
18+export const urbitWalletFromTicket = async (ticket, point, passphrase) => {
19+ return await kg.generateWallet({
20+ ticket: ticket,
21+ ship: point,
22+ passphrase: passphrase,
23+ });
24+};
25+
26+export const walletFromMnemonic = (
27+ mnemonic,
28+ hdpath,
29+ passphrase,
30+ skipMnemonicCheck
31+) => {
32+ const seed =
33+ skipMnemonicCheck || bip39.validateMnemonic(mnemonic)
34+ ? Just(bip39.mnemonicToSeedSync(mnemonic, passphrase))
35+ : Nothing();
36+
37+ const toWallet = (sd, path) => {
38+ let wal;
39+ const hd = bip32.fromSeed(sd);
40+ wal = hd.derivePath(path);
41+ wal.address = bufferedPublicKeyToAddress(wal.publicKey);
42+ wal.passphrase = passphrase || '';
43+ wal = Just(wal);
44+ return wal;
45+ };
46+
47+ const wallet = seed.chain(sd => toWallet(sd, hdpath));
48+
49+ return wallet;
50+};
src/store/lib/useControlledPointsStore.js+1
@@ -61,6 +61,7 @@ export default function useControlledPointsStore() {
6161 );
6262 }
6363 } catch (error) {
64+ console.error(error);
6465 _setControlledPoints(Just(Result.Error(error)));
6566 }
6667 }, [contracts, wallet]);
src/store/lib/useResidentsStore.js → src/store/lib/useResidentsStore.tsrenamed+3−4
@@ -56,13 +56,12 @@ export default function useResidents() {
5656 ]);
5757
5858 // Galaxies sponsor themselves
59− const _residentCount = isGalaxy
60− ? residentCount.toNumber() - 1
61− : residentCount.toNumber();
59+ const parsedCount = Number(residentCount);
60+ const _residentCount = isGalaxy ? parsedCount - 1 : parsedCount;
6261
6362 addToResidentCache(point, {
6463 residentCount: Just(_residentCount),
65− requestCount: Just(requestCount.toNumber()),
64+ requestCount: Just(Number(requestCount)),
6665 residents: Nothing(),
6766 requests: Nothing(),
6867 });
src/store/wallet.js+6−5
@@ -9,13 +9,13 @@ import React, {
99import { Just, Nothing } from 'folktale/maybe';
1010import { includes } from 'lodash';
1111
12+import { walletFromMnemonic } from 'lib/wallet';
1213import {
13− WALLET_TYPES,
1414 DEFAULT_HD_PATH,
15− addressFromSecp256k1Public,
16− walletFromMnemonic,
1715 NONCUSTODIAL_WALLETS,
18−} from 'lib/wallet';
16+ WALLET_TYPES,
17+} from 'lib/constants';
18+import { publicToAddress } from 'ethereumjs-util';
1919import { getAuthToken } from 'lib/authToken';
2020import { BRIDGE_ERROR } from 'lib/error';
2121
@@ -64,6 +64,7 @@ function _useWallet(initialWallet = Nothing(), initialMnemonic = Nothing()) {
6464 ) {
6565 return;
6666 }
67+
6768 const _wallet = wallet.value;
6869 const _web3 = web3.value;
6970 const token = await getAuthToken({
@@ -93,7 +94,7 @@ function _useWallet(initialWallet = Nothing(), initialMnemonic = Nothing()) {
9394 // force that public addresses are derived for each wallet
9495 // NOTE wallet is Maybe<> and .map is Maybe#map
9596 wallet.map(wal => {
96− wal.address = wal.address || addressFromSecp256k1Public(wal.publicKey);
97+ wal.address = wal.address || publicToAddress(wal.publicKey).toString('hex');
9798 return wal;
9899 });
99100
src/types/bridge-wallet.type.tsnew file+6
@@ -0,0 +1,6 @@
1+import { BIP32Interface } from 'bitcoinjs-lib';
2+
3+interface BridgeWallet extends BIP32Interface {
4+ address: string;
5+ passphrase: string;
6+}
src/views/AcceptLockup.js+1−1
@@ -13,7 +13,7 @@ import useEthereumTransaction from 'lib/useEthereumTransaction';
1313import { GAS_LIMITS } from 'lib/constants';
1414import { useLocalRouter } from 'lib/LocalRouter';
1515import { useFlowCommand } from 'lib/flowCommand';
16−import { isValidAddress, eqAddr } from 'lib/wallet';
16+import { isValidAddress, eqAddr } from 'lib/utils/crypto';
1717
1818import ViewHeader from 'components/ViewHeader';
1919import InlineEthereumTransaction from 'components/InlineEthereumTransaction';
src/views/Activate/ActivateCode.js+2−1
@@ -15,7 +15,8 @@ import { useHistory } from 'store/history';
1515
1616import * as need from 'lib/need';
1717import { ROUTE_NAMES } from 'lib/routeNames';
18−import { DEFAULT_HD_PATH, walletFromMnemonic } from 'lib/wallet';
18+import { walletFromMnemonic } from 'lib/wallet';
19+import { DEFAULT_HD_PATH } from 'lib/constants';
1920import { generateWallet } from 'lib/invite';
2021import { generateTemporaryOwnershipWallet } from 'lib/walletgen';
2122import { useLocalRouter } from 'lib/LocalRouter';
src/views/Activate/ActivatePassport.js+4−6
@@ -14,11 +14,9 @@ import useRouter from 'lib/useRouter';
1414import PassportDownload from './PassportDownload';
1515import PassportVerify from './PassportVerify';
1616import PassportTransfer from './PassportTransfer';
17−import {
18− walletFromMnemonic,
19− DEFAULT_HD_PATH,
20− addressFromSecp256k1Public,
21−} from 'lib/wallet';
17+import { walletFromMnemonic } from 'lib/wallet';
18+import { DEFAULT_HD_PATH } from 'lib/constants';
19+import { publicToAddress } from 'ethereumjs-util';
2220
2321const NAMES = {
2422 DOWNLOAD: 'DOWNLOAD',
@@ -56,7 +54,7 @@ export default function ActivatePassport() {
5654 wallet.meta.passphrase
5755 )
5856 )
59− .map(wallet => addressFromSecp256k1Public(wallet.publicKey)),
57+ .map(wallet => publicToAddress(wallet.publicKey).toString('hex')),
6058 [derivedWallet]
6159 );
6260 //~hobbyn-mismur-fonrux-datber
src/views/CancelTransfer.js+1−2
@@ -11,8 +11,7 @@ import * as need from 'lib/need';
1111import { useLocalRouter } from 'lib/LocalRouter';
1212import useCurrentPointName from 'lib/useCurrentPointName';
1313import useEthereumTransaction from 'lib/useEthereumTransaction';
14−import { GAS_LIMITS } from 'lib/constants';
15−import { ETH_ZERO_ADDR } from 'lib/wallet';
14+import { ETH_ZERO_ADDR, GAS_LIMITS } from 'lib/constants';
1615import useLifecycle from 'lib/useLifecycle';
1716
1817import ViewHeader from 'components/ViewHeader';
src/views/CreateGalaxy.js+1−1
@@ -10,7 +10,7 @@ import * as need from 'lib/need';
1010import useEthereumTransaction from 'lib/useEthereumTransaction';
1111import { GAS_LIMITS } from 'lib/constants';
1212import patp2dec from 'lib/patp2dec';
13−import { isZeroAddress } from 'lib/wallet';
13+import { isZeroAddress } from 'lib/utils/crypto';
1414import { useLocalRouter } from 'lib/LocalRouter';
1515
1616import ViewHeader from 'components/ViewHeader';
src/views/Login.js → src/views/Login.tsxrenamed

The content is the same.

src/views/Login/Keystore.js+2−1
@@ -5,7 +5,8 @@ import * as keythereum from 'keythereum';
55
66import { useWallet } from 'store/wallet';
77
8−import { EthereumWallet, WALLET_TYPES } from 'lib/wallet';
8+import { EthereumWallet } from 'lib/wallet';
9+import { WALLET_TYPES } from 'lib/constants';
910import useLoginView from 'lib/useLoginView';
1011
1112import { PassphraseInput } from 'form/Inputs';
src/views/Login/Ledger.js+1−1
@@ -16,7 +16,7 @@ import {
1616 chopHdPrefix,
1717 addHdPrefix,
1818} from 'lib/ledger';
19−import { WALLET_TYPES } from 'lib/wallet';
19+import { WALLET_TYPES } from 'lib/constants';
2020import useLoginView from 'lib/useLoginView';
2121import useBreakpoints from 'lib/useBreakpoints';
2222
src/views/Login/Metamask.js+2−1
@@ -6,7 +6,8 @@ import { FORM_ERROR } from 'final-form';
66import { useWallet } from 'store/wallet';
77import { useNetwork } from 'store/network';
88
9−import { WALLET_TYPES, abbreviateAddress } from 'lib/wallet';
9+import { abbreviateAddress } from 'lib/utils/crypto';
10+import { WALLET_TYPES } from 'lib/constants';
1011import { MetamaskWallet } from 'lib/metamask';
1112import { getAuthToken } from 'lib/authToken';
1213import useLoginView from 'lib/useLoginView';
src/views/Login/Mnemonic.js+2−1
@@ -5,7 +5,8 @@ import { Grid, CheckboxInput } from 'indigo-react';
55
66import { useWallet } from 'store/wallet';
77
8−import { walletFromMnemonic, WALLET_TYPES, DEFAULT_HD_PATH } from 'lib/wallet';
8+import { walletFromMnemonic } from 'lib/wallet';
9+import { DEFAULT_HD_PATH, WALLET_TYPES } from 'lib/constants';
910import useLoginView from 'lib/useLoginView';
1011import { MnemonicInput, HdPathInput, PassphraseInput } from 'form/Inputs';
1112import {
src/views/Login/PrivateKey.js+3−1
@@ -4,7 +4,9 @@ import { Grid } from 'indigo-react';
44
55import { useWallet } from 'store/wallet';
66
7−import { EthereumWallet, WALLET_TYPES, stripHexPrefix } from 'lib/wallet';
7+import { EthereumWallet } from 'lib/wallet';
8+import { stripHexPrefix } from 'lib/utils/crypto';
9+import { WALLET_TYPES } from 'lib/constants';
810import useLoginView from 'lib/useLoginView';
911
1012import FormError from 'form/FormError';
src/views/Login/Ticket.js+2−1
@@ -17,7 +17,8 @@ import { useWallet } from 'store/wallet';
1717import { usePointCursor } from 'store/pointCursor';
1818
1919import * as need from 'lib/need';
20−import { WALLET_TYPES, urbitWalletFromTicket } from 'lib/wallet';
20+import { urbitWalletFromTicket } from 'lib/wallet';
21+import { WALLET_TYPES } from 'lib/constants';
2122import useImpliedPoint from 'lib/useImpliedPoint';
2223import useLoginView from 'lib/useLoginView';
2324import patp2dec from 'lib/patp2dec';
src/views/Login/Trezor.js+1−1
@@ -9,7 +9,7 @@ import { Text, Grid, H5, CheckboxInput, SelectInput } from 'indigo-react';
99import { useWallet } from 'store/wallet';
1010
1111import { TREZOR_PATH } from 'lib/trezor';
12−import { WALLET_TYPES } from 'lib/wallet';
12+import { WALLET_TYPES } from 'lib/constants';
1313import useLoginView from 'lib/useLoginView';
1414import { getAuthToken } from 'lib/authToken';
1515
src/views/Points.js+1−1
@@ -10,7 +10,7 @@ import { usePointCursor } from 'store/pointCursor';
1010import { useStarReleaseCache } from 'store/starRelease';
1111
1212import * as need from 'lib/need';
13−import { isZeroAddress, abbreviateAddress } from 'lib/wallet';
13+import { isZeroAddress, abbreviateAddress } from 'lib/utils/crypto';
1414import useIsEclipticOwner from 'lib/useIsEclipticOwner';
1515import useRejectedIncomingPointTransfers from 'lib/useRejectedIncomingPointTransfers';
1616import pluralize from 'lib/pluralize';
src/views/Release/Transfer.js+1−1
@@ -6,7 +6,7 @@ import { conditionalSR, linearSR } from 'azimuth-js';
66import * as need from 'lib/need';
77import useEthereumTransaction from 'lib/useEthereumTransaction';
88import { getLockupKind } from 'lib/starRelease';
9−import { eqAddr, isZeroAddress } from 'lib/wallet';
9+import { eqAddr, isZeroAddress } from 'lib/utils/crypto';
1010
1111import { useNetwork } from 'store/network';
1212import { useWallet } from 'store/wallet';
src/views/UrbitID/ResetKeys/ResetExecute.js+1−1
@@ -8,7 +8,7 @@ import {
88} from 'lib/reticket';
99import * as need from 'lib/need';
1010import useLifecycle from 'lib/useLifecycle';
11−import { WALLET_TYPES } from 'lib/wallet';
11+import { WALLET_TYPES } from 'lib/constants';
1212import convertToInt from 'lib/convertToInt';
1313import useBlockWindowClose from 'lib/useBlockWindowClose';
1414
src/views/UrbitID/SetProxy.js+2−2
@@ -14,12 +14,12 @@ import {
1414} from 'lib/proxy';
1515import * as need from 'lib/need';
1616import { useLocalRouter } from 'lib/LocalRouter';
17−import { ETH_ZERO_ADDR, eqAddr, isZeroAddress } from 'lib/wallet';
17+import { eqAddr, isZeroAddress } from 'lib/utils/crypto';
1818import capitalize from 'lib/capitalize';
1919import useEthereumTransaction from 'lib/useEthereumTransaction';
2020
2121import InlineEthereumTransaction from 'components/InlineEthereumTransaction';
22−import { GAS_LIMITS } from 'lib/constants';
22+import { ETH_ZERO_ADDR, GAS_LIMITS } from 'lib/constants';
2323import { AddressInput } from 'form/Inputs';
2424import {
2525 composeValidator,
src/views/UrbitOS/NetworkingKeys.js+1−1
@@ -18,7 +18,7 @@ import {
1818} from 'lib/keys';
1919import useEthereumTransaction from 'lib/useEthereumTransaction';
2020import { GAS_LIMITS } from 'lib/constants';
21−import { addHexPrefix } from 'lib/wallet';
21+import { addHexPrefix } from 'lib/utils/crypto';
2222import useKeyfileGenerator from 'lib/useKeyfileGenerator';
2323
2424import ViewHeader from 'components/ViewHeader';