on master help sign in
fix: login with mnemonic, view points list
b78a856tomholford
src/form/Inputs.js+1−1
@@ -10,7 +10,7 @@ import {
10 stripHexPrefix,
10 stripHexPrefix,
11 ensureHexPrefix,
11 ensureHexPrefix,
12} from 'form/formatters';
12} from 'form/formatters';
13−import { DEFAULT_HD_PATH } from 'lib/wallet';
13+import { DEFAULT_HD_PATH } from 'lib/constants';
14import InputSigil from 'components/InputSigil';
14import InputSigil from 'components/InputSigil';
15
15
16const PLACEHOLDER_POINT = '~sampel-ponnym';
16const 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';
2
3
3−import { keccak256, WALLET_TYPES } from './wallet';
4+import { WALLET_TYPES } from './constants';
4import { ledgerSignMessage } from './ledger';
5import { ledgerSignMessage } from './ledger';
5import { trezorSignMessage } from './trezor';
6import { trezorSignMessage } from './trezor';
6
7
7const MESSAGE = 'Bridge Authentication Token';
8const MESSAGE = 'Bridge Authentication Token';
8
9
9−function signMessage(privateKey) {
10+function signMessage(privateKey: Buffer) {
10− const { signature } = secp256k1.sign(
11− keccak256('\x19Ethereum Signed Message:\n' + MESSAGE.length + MESSAGE),
11+ const msg = '\x19Ethereum Signed Message:\n' + MESSAGE.length + MESSAGE;
12− privateKey
12+ // TODO: Signing function expects 32 length Buffer,
13− );
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+
14 // add key recovery parameter
20 // add key recovery parameter
15 const ethSignature = new Uint8Array(65);
21 const ethSignature = new Uint8Array(65);
16 ethSignature.set(signature);
22 ethSignature.set(signature);
src/lib/constants.js → src/lib/constants.tsrenamed+26
@@ -74,9 +74,33 @@ const PROFILE_STATES = {
74
74
75const PROGRESS_ANIMATION_DELAY_MS = 500; // .animated-width
75const PROGRESS_ANIMATION_DELAY_MS = 500; // .animated-width
76
76
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+
77export {
98export {
78 CHECK_BLOCK_EVERY_MS,
99 CHECK_BLOCK_EVERY_MS,
79 DEFAULT_GAS_PRICE_GWEI,
100 DEFAULT_GAS_PRICE_GWEI,
101+ DEFAULT_HD_PATH,
102+ ETH_ZERO_ADDR,
103+ ETH_ZERO_ADDR_SHORT,
80 MAX_GAS_PRICE_GWEI,
104 MAX_GAS_PRICE_GWEI,
81 GAS_LIMITS,
105 GAS_LIMITS,
82 GEN_STATES,
106 GEN_STATES,
@@ -88,10 +112,12 @@ export {
88 MAX_STAR,
112 MAX_STAR,
89 MIN_PLANET,
113 MIN_PLANET,
90 MAX_PLANET,
114 MAX_PLANET,
115+ NONCUSTODIAL_WALLETS,
91 PLANET_ENTROPY_BITS,
116 PLANET_ENTROPY_BITS,
92 STAR_ENTROPY_BITS,
117 STAR_ENTROPY_BITS,
93 GALAXY_ENTROPY_BITS,
118 GALAXY_ENTROPY_BITS,
94 SEED_ENTROPY_BITS,
119 SEED_ENTROPY_BITS,
120+ WALLET_TYPES,
95 ZOD,
121 ZOD,
96 PROGRESS_ANIMATION_DELAY_MS,
122 PROGRESS_ANIMATION_DELAY_MS,
97};
123};
src/lib/flowCommand.js → src/lib/flowCommand.tsrenamed+9−2
@@ -1,5 +1,5 @@
1import { useMemo } from 'react';
1import { useMemo } from 'react';
2−import { isValidAddress } from './wallet';
2+import { isValidAddress } from './utils/crypto';
3
3
4// looks into the GET parameters and attempts to construct a "flow" object,
4// looks into the GET parameters and attempts to construct a "flow" object,
5// which would indicate bridge is to be used for one specific flow.
5// which would indicate bridge is to be used for one specific flow.
@@ -21,9 +21,16 @@ const COMMANDS = {
21 XPUB: 'xpub',
21 XPUB: 'xpub',
22};
22};
23
23
24+type FlowType = {
25+ kind?: 'takeLockup' | 'btc' | 'xpub';
26+ lock?: 'linear' | 'conditional';
27+ from?: string;
28+ utx?: string;
29+} | null;
30+
24const useFlowCommand = () => {
31const useFlowCommand = () => {
25 const flow = useMemo(() => {
32 const flow = useMemo(() => {
26− let flow = {};
33+ let flow: FlowType = {};
27
34
28 window.location.search
35 window.location.search
29 .substr(1)
36 .substr(1)
src/lib/keys.js+1−1
@@ -5,7 +5,7 @@ import * as noun from '../nockjs/noun';
5import * as serial from '../nockjs/serial';
5import * as serial from '../nockjs/serial';
6import * as kg from 'urbit-key-generation';
6import * as kg from 'urbit-key-generation';
7
7
8−import { eqAddr, addHexPrefix } from './wallet';
8+import { addHexPrefix, eqAddr } from './utils/crypto';
9import { shas } from './networkCode';
9import { shas } from './networkCode';
10
10
11// the curve param for the network keys
11// the curve param for the network keys
src/lib/reticket.js+1−1
@@ -7,7 +7,7 @@ import {
7 deriveNetworkKeys,
7 deriveNetworkKeys,
8 CRYPTO_SUITE_VERSION,
8 CRYPTO_SUITE_VERSION,
9} from './keys';
9} from './keys';
10−import { addHexPrefix } from './wallet';
10+import { addHexPrefix } from './utils/crypto';
11import {
11import {
12 sendAndAwaitAllSerial,
12 sendAndAwaitAllSerial,
13 signTransaction,
13 signTransaction,
src/lib/router.js+1−1
@@ -1,5 +1,5 @@
1import Disclaimer from 'views/Disclaimer';
1import Disclaimer from 'views/Disclaimer';
2−import Login from 'views/Login.js';
2+import Login from 'views/Login';
3import Other from 'views/Login/Other.js';
3import Other from 'views/Login/Other.js';
4import Senate from 'views/Senate';
4import Senate from 'views/Senate';
5import Documents from 'views/Senate/Documents';
5import Documents from 'views/Senate/Documents';
src/lib/tank.js+1−1
@@ -3,7 +3,7 @@
3import retry from 'async-retry';
3import retry from 'async-retry';
4import { toBN } from 'web3-utils';
4import { toBN } from 'web3-utils';
5import { RETRY_OPTIONS, waitForTransactionConfirm } from './txn';
5import { RETRY_OPTIONS, waitForTransactionConfirm } from './txn';
6−import { WALLET_TYPES } from 'lib/wallet';
6+import { WALLET_TYPES } from 'lib/constants';
7
7
8const TANK_ADDRESS = '0x40f0A6db85f8D7A54fF3eA915b040dE8Cd4A0Eb5';
8const TANK_ADDRESS = '0x40f0A6db85f8D7A54fF3eA915b040dE8Cd4A0Eb5';
9
9
src/lib/txn.js+2−2
@@ -7,8 +7,8 @@ import { NETWORK_TYPES } from './network';
7import { ledgerSignTransaction } from './ledger';
7import { ledgerSignTransaction } from './ledger';
8import { trezorSignTransaction } from './trezor';
8import { trezorSignTransaction } from './trezor';
9import { metamaskSignTransaction, FakeMetamaskTransaction } from './metamask';
9import { metamaskSignTransaction, FakeMetamaskTransaction } from './metamask';
10−import { WALLET_TYPES, addHexPrefix } from './wallet';
10+import { addHexPrefix } from './utils/crypto';
11−import { CHECK_BLOCK_EVERY_MS } from './constants';
11+import { CHECK_BLOCK_EVERY_MS, WALLET_TYPES } from './constants';
12import patp2dec from './patp2dec';
12import patp2dec from './patp2dec';
13
13
14const RETRY_OPTIONS = {
14const RETRY_OPTIONS = {
src/lib/useIsEclipticOwner.js+1−1
@@ -1,7 +1,7 @@
1import { useWallet } from 'store/wallet';
1import { useWallet } from 'store/wallet';
2import { usePointCache } from 'store/pointCache';
2import { usePointCache } from 'store/pointCache';
3
3
4−import { eqAddr } from 'lib/wallet';
4+import { eqAddr } from 'lib/utils/crypto';
5import useLifecycle from './useLifecycle';
5import useLifecycle from './useLifecycle';
6
6
7export default function useIsEclipticOwner() {
7export default function useIsEclipticOwner() {
src/lib/usePermissionsForPoint.js+1−1
@@ -5,7 +5,7 @@ import { useNetwork } from 'store/network';
5
5
6import * as need from 'lib/need';
6import * as need from 'lib/need';
7
7
8−import { eqAddr, isZeroAddress } from './wallet';
8+import { eqAddr, isZeroAddress } from './utils/crypto';
9
9
10const NULL_PERMISSIONS = {
10const NULL_PERMISSIONS = {
11 isActive: false,
11 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';
3import ob from 'urbit-ob';
3import ob from 'urbit-ob';
4import { includes } from 'lodash';
4import { includes } from 'lodash';
5
5
6−import { isValidAddress, ETH_ZERO_ADDR, ETH_ZERO_ADDR_SHORT } from './wallet';
6+import { isValidAddress } from './utils/crypto';
7import patp2dec from './patp2dec';
7import patp2dec from './patp2dec';
8import { patpStringLength } from './lib';
8import { patpStringLength } from './lib';
9+import {
10+ ETH_ZERO_ADDR,
11+ ETH_ZERO_ADDR_SHORT,
12+ MIN_GALAXY,
13+ MAX_GALAXY,
9−import { MIN_GALAXY, MAX_GALAXY } from './constants';
14+} from './constants';
10
15
11// NOTE: do not use the /g modifier for these regexes
16// NOTE: do not use the /g modifier for these regexes
12// https://stackoverflow.com/a/21373261
17// 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() {
61 );
61 );
62 }
62 }
63 } catch (error) {
63 } catch (error) {
64+ console.error(error);
64 _setControlledPoints(Just(Result.Error(error)));
65 _setControlledPoints(Just(Result.Error(error)));
65 }
66 }
66 }, [contracts, wallet]);
67 }, [contracts, wallet]);
src/store/lib/useResidentsStore.js → src/store/lib/useResidentsStore.tsrenamed+3−4
@@ -56,13 +56,12 @@ export default function useResidents() {
56 ]);
56 ]);
57
57
58 // Galaxies sponsor themselves
58 // Galaxies sponsor themselves
59+ const parsedCount = Number(residentCount);
59− const _residentCount = isGalaxy
60+ const _residentCount = isGalaxy ? parsedCount - 1 : parsedCount;
60− ? residentCount.toNumber() - 1
61− : residentCount.toNumber();
62
61
63 addToResidentCache(point, {
62 addToResidentCache(point, {
64 residentCount: Just(_residentCount),
63 residentCount: Just(_residentCount),
65− requestCount: Just(requestCount.toNumber()),
64+ requestCount: Just(Number(requestCount)),
66 residents: Nothing(),
65 residents: Nothing(),
67 requests: Nothing(),
66 requests: Nothing(),
68 });
67 });
src/store/wallet.js+6−5
@@ -9,13 +9,13 @@ import React, {
9import { Just, Nothing } from 'folktale/maybe';
9import { Just, Nothing } from 'folktale/maybe';
10import { includes } from 'lodash';
10import { includes } from 'lodash';
11
11
12+import { walletFromMnemonic } from 'lib/wallet';
12import {
13import {
13− WALLET_TYPES,
14 DEFAULT_HD_PATH,
14 DEFAULT_HD_PATH,
15− addressFromSecp256k1Public,
16− walletFromMnemonic,
17 NONCUSTODIAL_WALLETS,
15 NONCUSTODIAL_WALLETS,
16+ WALLET_TYPES,
18−} from 'lib/wallet';
17+} from 'lib/constants';
18+import { publicToAddress } from 'ethereumjs-util';
19import { getAuthToken } from 'lib/authToken';
19import { getAuthToken } from 'lib/authToken';
20import { BRIDGE_ERROR } from 'lib/error';
20import { BRIDGE_ERROR } from 'lib/error';
21
21
@@ -64,6 +64,7 @@ function _useWallet(initialWallet = Nothing(), initialMnemonic = Nothing()) {
64 ) {
64 ) {
65 return;
65 return;
66 }
66 }
67+
67 const _wallet = wallet.value;
68 const _wallet = wallet.value;
68 const _web3 = web3.value;
69 const _web3 = web3.value;
69 const token = await getAuthToken({
70 const token = await getAuthToken({
@@ -93,7 +94,7 @@ function _useWallet(initialWallet = Nothing(), initialMnemonic = Nothing()) {
93 // force that public addresses are derived for each wallet
94 // force that public addresses are derived for each wallet
94 // NOTE wallet is Maybe<> and .map is Maybe#map
95 // NOTE wallet is Maybe<> and .map is Maybe#map
95 wallet.map(wal => {
96 wallet.map(wal => {
96− wal.address = wal.address || addressFromSecp256k1Public(wal.publicKey);
97+ wal.address = wal.address || publicToAddress(wal.publicKey).toString('hex');
97 return wal;
98 return wal;
98 });
99 });
99
100
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';
13import { GAS_LIMITS } from 'lib/constants';
13import { GAS_LIMITS } from 'lib/constants';
14import { useLocalRouter } from 'lib/LocalRouter';
14import { useLocalRouter } from 'lib/LocalRouter';
15import { useFlowCommand } from 'lib/flowCommand';
15import { useFlowCommand } from 'lib/flowCommand';
16−import { isValidAddress, eqAddr } from 'lib/wallet';
16+import { isValidAddress, eqAddr } from 'lib/utils/crypto';
17
17
18import ViewHeader from 'components/ViewHeader';
18import ViewHeader from 'components/ViewHeader';
19import InlineEthereumTransaction from 'components/InlineEthereumTransaction';
19import InlineEthereumTransaction from 'components/InlineEthereumTransaction';
src/views/Activate/ActivateCode.js+2−1
@@ -15,7 +15,8 @@ import { useHistory } from 'store/history';
15
15
16import * as need from 'lib/need';
16import * as need from 'lib/need';
17import { ROUTE_NAMES } from 'lib/routeNames';
17import { 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';
19import { generateWallet } from 'lib/invite';
20import { generateWallet } from 'lib/invite';
20import { generateTemporaryOwnershipWallet } from 'lib/walletgen';
21import { generateTemporaryOwnershipWallet } from 'lib/walletgen';
21import { useLocalRouter } from 'lib/LocalRouter';
22import { useLocalRouter } from 'lib/LocalRouter';
src/views/Activate/ActivatePassport.js+4−6
@@ -14,11 +14,9 @@ import useRouter from 'lib/useRouter';
14import PassportDownload from './PassportDownload';
14import PassportDownload from './PassportDownload';
15import PassportVerify from './PassportVerify';
15import PassportVerify from './PassportVerify';
16import PassportTransfer from './PassportTransfer';
16import PassportTransfer from './PassportTransfer';
17−import {
18− walletFromMnemonic,
17+import { walletFromMnemonic } from 'lib/wallet';
19− DEFAULT_HD_PATH,
18+import { DEFAULT_HD_PATH } from 'lib/constants';
20− addressFromSecp256k1Public,
19+import { publicToAddress } from 'ethereumjs-util';
21−} from 'lib/wallet';
22
20
23const NAMES = {
21const NAMES = {
24 DOWNLOAD: 'DOWNLOAD',
22 DOWNLOAD: 'DOWNLOAD',
@@ -56,7 +54,7 @@ export default function ActivatePassport() {
56 wallet.meta.passphrase
54 wallet.meta.passphrase
57 )
55 )
58 )
56 )
59− .map(wallet => addressFromSecp256k1Public(wallet.publicKey)),
57+ .map(wallet => publicToAddress(wallet.publicKey).toString('hex')),
60 [derivedWallet]
58 [derivedWallet]
61 );
59 );
62 //~hobbyn-mismur-fonrux-datber
60 //~hobbyn-mismur-fonrux-datber
src/views/CancelTransfer.js+1−2
@@ -11,8 +11,7 @@ import * as need from 'lib/need';
11import { useLocalRouter } from 'lib/LocalRouter';
11import { useLocalRouter } from 'lib/LocalRouter';
12import useCurrentPointName from 'lib/useCurrentPointName';
12import useCurrentPointName from 'lib/useCurrentPointName';
13import useEthereumTransaction from 'lib/useEthereumTransaction';
13import useEthereumTransaction from 'lib/useEthereumTransaction';
14−import { GAS_LIMITS } from 'lib/constants';
14+import { ETH_ZERO_ADDR, GAS_LIMITS } from 'lib/constants';
15−import { ETH_ZERO_ADDR } from 'lib/wallet';
16import useLifecycle from 'lib/useLifecycle';
15import useLifecycle from 'lib/useLifecycle';
17
16
18import ViewHeader from 'components/ViewHeader';
17import ViewHeader from 'components/ViewHeader';
src/views/CreateGalaxy.js+1−1
@@ -10,7 +10,7 @@ import * as need from 'lib/need';
10import useEthereumTransaction from 'lib/useEthereumTransaction';
10import useEthereumTransaction from 'lib/useEthereumTransaction';
11import { GAS_LIMITS } from 'lib/constants';
11import { GAS_LIMITS } from 'lib/constants';
12import patp2dec from 'lib/patp2dec';
12import patp2dec from 'lib/patp2dec';
13−import { isZeroAddress } from 'lib/wallet';
13+import { isZeroAddress } from 'lib/utils/crypto';
14import { useLocalRouter } from 'lib/LocalRouter';
14import { useLocalRouter } from 'lib/LocalRouter';
15
15
16import ViewHeader from 'components/ViewHeader';
16import 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';
5
5
6import { useWallet } from 'store/wallet';
6import { useWallet } from 'store/wallet';
7
7
8−import { EthereumWallet, WALLET_TYPES } from 'lib/wallet';
8+import { EthereumWallet } from 'lib/wallet';
9+import { WALLET_TYPES } from 'lib/constants';
9import useLoginView from 'lib/useLoginView';
10import useLoginView from 'lib/useLoginView';
10
11
11import { PassphraseInput } from 'form/Inputs';
12import { PassphraseInput } from 'form/Inputs';
src/views/Login/Ledger.js+1−1
@@ -16,7 +16,7 @@ import {
16 chopHdPrefix,
16 chopHdPrefix,
17 addHdPrefix,
17 addHdPrefix,
18} from 'lib/ledger';
18} from 'lib/ledger';
19−import { WALLET_TYPES } from 'lib/wallet';
19+import { WALLET_TYPES } from 'lib/constants';
20import useLoginView from 'lib/useLoginView';
20import useLoginView from 'lib/useLoginView';
21import useBreakpoints from 'lib/useBreakpoints';
21import useBreakpoints from 'lib/useBreakpoints';
22
22
src/views/Login/Metamask.js+2−1
@@ -6,7 +6,8 @@ import { FORM_ERROR } from 'final-form';
6import { useWallet } from 'store/wallet';
6import { useWallet } from 'store/wallet';
7import { useNetwork } from 'store/network';
7import { useNetwork } from 'store/network';
8
8
9−import { WALLET_TYPES, abbreviateAddress } from 'lib/wallet';
9+import { abbreviateAddress } from 'lib/utils/crypto';
10+import { WALLET_TYPES } from 'lib/constants';
10import { MetamaskWallet } from 'lib/metamask';
11import { MetamaskWallet } from 'lib/metamask';
11import { getAuthToken } from 'lib/authToken';
12import { getAuthToken } from 'lib/authToken';
12import useLoginView from 'lib/useLoginView';
13import useLoginView from 'lib/useLoginView';
src/views/Login/Mnemonic.js+2−1
@@ -5,7 +5,8 @@ import { Grid, CheckboxInput } from 'indigo-react';
5
5
6import { useWallet } from 'store/wallet';
6import { useWallet } from 'store/wallet';
7
7
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';
9import useLoginView from 'lib/useLoginView';
10import useLoginView from 'lib/useLoginView';
10import { MnemonicInput, HdPathInput, PassphraseInput } from 'form/Inputs';
11import { MnemonicInput, HdPathInput, PassphraseInput } from 'form/Inputs';
11import {
12import {
src/views/Login/PrivateKey.js+3−1
@@ -4,7 +4,9 @@ import { Grid } from 'indigo-react';
4
4
5import { useWallet } from 'store/wallet';
5import { useWallet } from 'store/wallet';
6
6
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';
8import useLoginView from 'lib/useLoginView';
10import useLoginView from 'lib/useLoginView';
9
11
10import FormError from 'form/FormError';
12import FormError from 'form/FormError';
src/views/Login/Ticket.js+2−1
@@ -17,7 +17,8 @@ import { useWallet } from 'store/wallet';
17import { usePointCursor } from 'store/pointCursor';
17import { usePointCursor } from 'store/pointCursor';
18
18
19import * as need from 'lib/need';
19import * 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';
21import useImpliedPoint from 'lib/useImpliedPoint';
22import useImpliedPoint from 'lib/useImpliedPoint';
22import useLoginView from 'lib/useLoginView';
23import useLoginView from 'lib/useLoginView';
23import patp2dec from 'lib/patp2dec';
24import patp2dec from 'lib/patp2dec';
src/views/Login/Trezor.js+1−1
@@ -9,7 +9,7 @@ import { Text, Grid, H5, CheckboxInput, SelectInput } from 'indigo-react';
9import { useWallet } from 'store/wallet';
9import { useWallet } from 'store/wallet';
10
10
11import { TREZOR_PATH } from 'lib/trezor';
11import { TREZOR_PATH } from 'lib/trezor';
12−import { WALLET_TYPES } from 'lib/wallet';
12+import { WALLET_TYPES } from 'lib/constants';
13import useLoginView from 'lib/useLoginView';
13import useLoginView from 'lib/useLoginView';
14import { getAuthToken } from 'lib/authToken';
14import { getAuthToken } from 'lib/authToken';
15
15
src/views/Points.js+1−1
@@ -10,7 +10,7 @@ import { usePointCursor } from 'store/pointCursor';
10import { useStarReleaseCache } from 'store/starRelease';
10import { useStarReleaseCache } from 'store/starRelease';
11
11
12import * as need from 'lib/need';
12import * as need from 'lib/need';
13−import { isZeroAddress, abbreviateAddress } from 'lib/wallet';
13+import { isZeroAddress, abbreviateAddress } from 'lib/utils/crypto';
14import useIsEclipticOwner from 'lib/useIsEclipticOwner';
14import useIsEclipticOwner from 'lib/useIsEclipticOwner';
15import useRejectedIncomingPointTransfers from 'lib/useRejectedIncomingPointTransfers';
15import useRejectedIncomingPointTransfers from 'lib/useRejectedIncomingPointTransfers';
16import pluralize from 'lib/pluralize';
16import pluralize from 'lib/pluralize';
src/views/Release/Transfer.js+1−1
@@ -6,7 +6,7 @@ import { conditionalSR, linearSR } from 'azimuth-js';
6import * as need from 'lib/need';
6import * as need from 'lib/need';
7import useEthereumTransaction from 'lib/useEthereumTransaction';
7import useEthereumTransaction from 'lib/useEthereumTransaction';
8import { getLockupKind } from 'lib/starRelease';
8import { getLockupKind } from 'lib/starRelease';
9−import { eqAddr, isZeroAddress } from 'lib/wallet';
9+import { eqAddr, isZeroAddress } from 'lib/utils/crypto';
10
10
11import { useNetwork } from 'store/network';
11import { useNetwork } from 'store/network';
12import { useWallet } from 'store/wallet';
12import { useWallet } from 'store/wallet';
src/views/UrbitID/ResetKeys/ResetExecute.js+1−1
@@ -8,7 +8,7 @@ import {
8} from 'lib/reticket';
8} from 'lib/reticket';
9import * as need from 'lib/need';
9import * as need from 'lib/need';
10import useLifecycle from 'lib/useLifecycle';
10import useLifecycle from 'lib/useLifecycle';
11−import { WALLET_TYPES } from 'lib/wallet';
11+import { WALLET_TYPES } from 'lib/constants';
12import convertToInt from 'lib/convertToInt';
12import convertToInt from 'lib/convertToInt';
13import useBlockWindowClose from 'lib/useBlockWindowClose';
13import useBlockWindowClose from 'lib/useBlockWindowClose';
14
14
src/views/UrbitID/SetProxy.js+2−2
@@ -14,12 +14,12 @@ import {
14} from 'lib/proxy';
14} from 'lib/proxy';
15import * as need from 'lib/need';
15import * as need from 'lib/need';
16import { useLocalRouter } from 'lib/LocalRouter';
16import { useLocalRouter } from 'lib/LocalRouter';
17−import { ETH_ZERO_ADDR, eqAddr, isZeroAddress } from 'lib/wallet';
17+import { eqAddr, isZeroAddress } from 'lib/utils/crypto';
18import capitalize from 'lib/capitalize';
18import capitalize from 'lib/capitalize';
19import useEthereumTransaction from 'lib/useEthereumTransaction';
19import useEthereumTransaction from 'lib/useEthereumTransaction';
20
20
21import InlineEthereumTransaction from 'components/InlineEthereumTransaction';
21import InlineEthereumTransaction from 'components/InlineEthereumTransaction';
22−import { GAS_LIMITS } from 'lib/constants';
22+import { ETH_ZERO_ADDR, GAS_LIMITS } from 'lib/constants';
23import { AddressInput } from 'form/Inputs';
23import { AddressInput } from 'form/Inputs';
24import {
24import {
25 composeValidator,
25 composeValidator,
src/views/UrbitOS/NetworkingKeys.js+1−1
@@ -18,7 +18,7 @@ import {
18} from 'lib/keys';
18} from 'lib/keys';
19import useEthereumTransaction from 'lib/useEthereumTransaction';
19import useEthereumTransaction from 'lib/useEthereumTransaction';
20import { GAS_LIMITS } from 'lib/constants';
20import { GAS_LIMITS } from 'lib/constants';
21−import { addHexPrefix } from 'lib/wallet';
21+import { addHexPrefix } from 'lib/utils/crypto';
22import useKeyfileGenerator from 'lib/useKeyfileGenerator';
22import useKeyfileGenerator from 'lib/useKeyfileGenerator';
23
23
24import ViewHeader from 'components/ViewHeader';
24import ViewHeader from 'components/ViewHeader';