on master help sign in
chore: address PR feedback
18ffc8etomholford
DEVELOPMENT.md−16
@@ -106,22 +106,6 @@ Automated tests for critical user journeys are coming Soon™️. Until then, he
1063. Confirm that you are able to view the Points list view. Since no points have been created yet, you should see the following message:
1063. Confirm that you are able to view the Points list view. Since no points have been created yet, you should see the following message:
107> No points to display. This wallet is not the owner or proxy for any points.
107> No points to display. This wallet is not the owner or proxy for any points.
108
108
109−### Galaxy Creation
110−
111−"As a user, I can create a new galaxy"
112−
113−1. Once logged, in, click the "Create a Galaxy" button
114−2. Enter a test galaxy name, e.g. `~wep`, sign and send the transaction
115−3. Log out and back into Bridge, confirm that the newly created galaxy is rendered in the points list
116−
117−### Star Creation
118−
119−"As a user, I can create a new star"
120−
121−1. Once a galaxy has been created, click it in the points list
122−2. Click "Issue Point", enter one of the suggested star names, and sign and send the transaction
123−3. Log out and back into Bridge, confirm that the newly created star is rendered in the points list
124−
125### Planet Creation
109### Planet Creation
126
110
127"As a user, I can create a new planet"
111"As a user, I can create a new planet"
src/lib/flowCommand.ts+2−9
@@ -1,5 +1,5 @@
1import { useMemo } from 'react';
1import { useMemo } from 'react';
2−import { isValidAddress } from './utils/crypto';
2+import { isValidAddress } from './utils/address';
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,16 +21,9 @@ 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−
31const useFlowCommand = () => {
24const useFlowCommand = () => {
32 const flow = useMemo(() => {
25 const flow = useMemo(() => {
33− let flow: FlowType = {};
26+ let flow = {};
34
27
35 window.location.search
28 window.location.search
36 .substr(1)
29 .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 { addHexPrefix, eqAddr } from './utils/crypto';
8+import { addHexPrefix, eqAddr } from './utils/address';
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 './utils/crypto';
10+import { addHexPrefix } from './utils/address';
11import {
11import {
12 sendAndAwaitAllSerial,
12 sendAndAwaitAllSerial,
13 signTransaction,
13 signTransaction,
src/lib/txn.js+1−1
@@ -7,7 +7,7 @@ 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 { addHexPrefix } from './utils/crypto';
10+import { addHexPrefix } from './utils/address';
11import { CHECK_BLOCK_EVERY_MS, WALLET_TYPES } from './constants';
11import { CHECK_BLOCK_EVERY_MS, WALLET_TYPES } from './constants';
12import patp2dec from './patp2dec';
12import patp2dec from './patp2dec';
13
13
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/utils/crypto';
4+import { eqAddr } from 'lib/utils/address';
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 './utils/crypto';
8+import { eqAddr, isZeroAddress } from './utils/address';
9
9
10const NULL_PERMISSIONS = {
10const NULL_PERMISSIONS = {
11 isActive: false,
11 isActive: false,
src/lib/utils/crypto.test.ts → src/lib/utils/address.test.tsrenamed+2−2
@@ -1,6 +1,6 @@
1import { mnemonicToSeedSync } from 'bip39';
1import { mnemonicToSeedSync } from 'bip39';
2import { bip32 } from 'bitcoinjs-lib';
2import { bip32 } from 'bitcoinjs-lib';
3−import { bufferedPublicKeyToAddress } from './crypto';
3+import { publicToAddress } from './address';
4
4
5describe('#bufferedPublicKeyToAddress', () => {
5describe('#bufferedPublicKeyToAddress', () => {
6 // TODO: why does this seemingly work in the Mnemonic login flow, but not in a test?
6 // TODO: why does this seemingly work in the Mnemonic login flow, but not in a test?
@@ -14,6 +14,6 @@ describe('#bufferedPublicKeyToAddress', () => {
14
14
15 const expected = 'foo';
15 const expected = 'foo';
16
16
17− expect(bufferedPublicKeyToAddress(wallet.publicKey)).toEqual(expected);
17+ expect(publicToAddress(wallet.publicKey)).toEqual(expected);
18 });
18 });
19});
19});
src/lib/utils/crypto.ts → src/lib/utils/address.tsrenamed+3−3
@@ -1,6 +1,6 @@
1import { reduce } from 'lodash';
1import { reduce } from 'lodash';
2import { isAddress, keccak256, toHex } from 'web3-utils';
2import { isAddress, keccak256, toHex } from 'web3-utils';
3−import { publicToAddress } from 'ethereumjs-util';
3+import { pubToAddress } from 'ethereumjs-util';
4import { ETH_ZERO_ADDR, ETH_ZERO_ADDR_SHORT } from 'lib/constants';
4import { ETH_ZERO_ADDR, ETH_ZERO_ADDR_SHORT } from 'lib/constants';
5
5
6export const stripHexPrefix = (hex: string) => {
6export const stripHexPrefix = (hex: string) => {
@@ -34,6 +34,6 @@ export const toChecksumAddress = address => {
34export const eqAddr = (addr0, addr1) =>
34export const eqAddr = (addr0, addr1) =>
35 toChecksumAddress(addr0) === toChecksumAddress(addr1);
35 toChecksumAddress(addr0) === toChecksumAddress(addr1);
36
36
37−export const bufferedPublicKeyToAddress = (publicKey: Buffer): string => {
37+export const publicToAddress = (publicKey: Buffer): string => {
38− return toHex(publicToAddress(publicKey, true).toString('hex'));
38+ return toHex(pubToAddress(publicKey, true).toString('hex'));
39};
39};
src/lib/validators.js+1−1
@@ -3,7 +3,7 @@ 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 } from './utils/crypto';
6+import { isValidAddress } from './utils/address';
7import patp2dec from './patp2dec';
7import patp2dec from './patp2dec';
8import { patpStringLength } from './lib';
8import { patpStringLength } from './lib';
9import {
9import {
src/lib/wallet.ts+3−5
@@ -4,14 +4,12 @@ import { bip32 } from 'bitcoinjs-lib';
4import { Just, Nothing } from 'folktale/maybe';
4import { Just, Nothing } from 'folktale/maybe';
5import * as secp256k1 from 'secp256k1';
5import * as secp256k1 from 'secp256k1';
6import * as kg from 'urbit-key-generation';
6import * as kg from 'urbit-key-generation';
7−import { publicToAddress } from 'ethereumjs-util';
7+import { publicToAddress } from './utils/address';
8−import { toHex } from 'web3-utils';
9−import { bufferedPublicKeyToAddress } from './utils/crypto';
10
8
11export function EthereumWallet(privateKey) {
9export function EthereumWallet(privateKey) {
12 this.privateKey = privateKey;
10 this.privateKey = privateKey;
13 this.publicKey = secp256k1.publicKeyCreate(this.privateKey);
11 this.publicKey = secp256k1.publicKeyCreate(this.privateKey);
14− this.address = bufferedPublicKeyToAddress(this.publicKey);
12+ this.address = publicToAddress(this.publicKey);
15}
13}
16
14
17export const urbitWalletFromTicket = async (ticket, point, passphrase) => {
15export const urbitWalletFromTicket = async (ticket, point, passphrase) => {
@@ -37,7 +35,7 @@ export const walletFromMnemonic = (
37 let wal;
35 let wal;
38 const hd = bip32.fromSeed(sd);
36 const hd = bip32.fromSeed(sd);
39 wal = hd.derivePath(path);
37 wal = hd.derivePath(path);
40− wal.address = bufferedPublicKeyToAddress(wal.publicKey);
38+ wal.address = publicToAddress(wal.publicKey);
41 wal.passphrase = passphrase || '';
39 wal.passphrase = passphrase || '';
42 wal = Just(wal);
40 wal = Just(wal);
43 return wal;
41 return wal;
src/store/wallet.js+2−2
@@ -19,7 +19,7 @@ import { getAuthToken } from 'lib/authToken';
19import { BRIDGE_ERROR } from 'lib/error';
19import { BRIDGE_ERROR } from 'lib/error';
20
20
21import { useNetwork } from 'store/network';
21import { useNetwork } from 'store/network';
22−import { bufferedPublicKeyToAddress } from 'lib/utils/crypto';
22+import { publicToAddress } from 'lib/utils/address';
23
23
24export const WalletContext = createContext(null);
24export const WalletContext = createContext(null);
25
25
@@ -94,7 +94,7 @@ function _useWallet(initialWallet = Nothing(), initialMnemonic = Nothing()) {
94 // force that public addresses are derived for each wallet
94 // force that public addresses are derived for each wallet
95 // NOTE wallet is Maybe<> and .map is Maybe#map
95 // NOTE wallet is Maybe<> and .map is Maybe#map
96 wallet.map(wal => {
96 wallet.map(wal => {
97− wal.address = wal.address || bufferedPublicKeyToAddress(wal.publicKey);
97+ wal.address = wal.address || publicToAddress(wal.publicKey);
98 return wal;
98 return wal;
99 });
99 });
100
100
src/types/bridge-wallet.type.tsdeleted−6
@@ -1,6 +0,0 @@
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/utils/crypto';
16+import { isValidAddress, eqAddr } from 'lib/utils/address';
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/ActivatePassport.js+2−2
@@ -16,7 +16,7 @@ import PassportVerify from './PassportVerify';
16import PassportTransfer from './PassportTransfer';
16import PassportTransfer from './PassportTransfer';
17import { walletFromMnemonic } from 'lib/wallet';
17import { walletFromMnemonic } from 'lib/wallet';
18import { DEFAULT_HD_PATH } from 'lib/constants';
18import { DEFAULT_HD_PATH } from 'lib/constants';
19−import { bufferedPublicKeyToAddress } from 'lib/utils/crypto';
19+import { publicToAddress } from 'lib/utils/address';
20
20
21const NAMES = {
21const NAMES = {
22 DOWNLOAD: 'DOWNLOAD',
22 DOWNLOAD: 'DOWNLOAD',
@@ -54,7 +54,7 @@ export default function ActivatePassport() {
54 wallet.meta.passphrase
54 wallet.meta.passphrase
55 )
55 )
56 )
56 )
57− .map(wallet => bufferedPublicKeyToAddress(wallet.publicKey)),
57+ .map(wallet => publicToAddress(wallet.publicKey)),
58 [derivedWallet]
58 [derivedWallet]
59 );
59 );
60 //~hobbyn-mismur-fonrux-datber
60 //~hobbyn-mismur-fonrux-datber
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/utils/crypto';
13+import { isZeroAddress } from 'lib/utils/address';
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/Metamask.js+1−1
@@ -6,7 +6,7 @@ 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 { abbreviateAddress } from 'lib/utils/crypto';
9+import { abbreviateAddress } from 'lib/utils/address';
10import { WALLET_TYPES } from 'lib/constants';
10import { WALLET_TYPES } from 'lib/constants';
11import { MetamaskWallet } from 'lib/metamask';
11import { MetamaskWallet } from 'lib/metamask';
12import { getAuthToken } from 'lib/authToken';
12import { getAuthToken } from 'lib/authToken';
src/views/Login/PrivateKey.js+1−1
@@ -5,7 +5,7 @@ import { Grid } from 'indigo-react';
5import { useWallet } from 'store/wallet';
5import { useWallet } from 'store/wallet';
6
6
7import { EthereumWallet } from 'lib/wallet';
7import { EthereumWallet } from 'lib/wallet';
8−import { stripHexPrefix } from 'lib/utils/crypto';
8+import { stripHexPrefix } from 'lib/utils/address';
9import { WALLET_TYPES } from 'lib/constants';
9import { WALLET_TYPES } from 'lib/constants';
10import useLoginView from 'lib/useLoginView';
10import useLoginView from 'lib/useLoginView';
11
11
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/utils/crypto';
13+import { isZeroAddress, abbreviateAddress } from 'lib/utils/address';
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/utils/crypto';
9+import { eqAddr, isZeroAddress } from 'lib/utils/address';
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/SetProxy.js+1−1
@@ -14,7 +14,7 @@ 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 { eqAddr, isZeroAddress } from 'lib/utils/crypto';
17+import { eqAddr, isZeroAddress } from 'lib/utils/address';
18import capitalize from 'lib/capitalize';
18import capitalize from 'lib/capitalize';
19import useEthereumTransaction from 'lib/useEthereumTransaction';
19import useEthereumTransaction from 'lib/useEthereumTransaction';
20
20
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/utils/crypto';
21+import { addHexPrefix } from 'lib/utils/address';
22import useKeyfileGenerator from 'lib/useKeyfileGenerator';
22import useKeyfileGenerator from 'lib/useKeyfileGenerator';
23
23
24import ViewHeader from 'components/ViewHeader';
24import ViewHeader from 'components/ViewHeader';