on master help sign in
chore: address PR feedback

- update Development doc - renamings - remove dead code

commit18ffc8e847e4b4b1dda814eb0e44abb9718d1edc authortomholford <tomholford@users.noreply.github.com> dateMon 28 Jun 2021, 22:52 (5 years ago) parent003c083
22 files changed+28−59
DEVELOPMENT.md−16 src/lib/flowCommand.ts+2−9 src/lib/keys.js+1−1 src/lib/reticket.js+1−1 src/lib/txn.js+1−1 src/lib/useIsEclipticOwner.js+1−1 src/lib/usePermissionsForPoint.js+1−1 src/lib/utils/crypto.test.ts → src/lib/utils/address.test.ts+2−2 src/lib/utils/crypto.ts → src/lib/utils/address.ts+3−3 src/lib/validators.js+1−1 src/lib/wallet.ts+3−5 src/store/wallet.js+2−2 src/types/bridge-wallet.type.ts−6 src/views/AcceptLockup.js+1−1 src/views/Activate/ActivatePassport.js+2−2 src/views/CreateGalaxy.js+1−1 src/views/Login/Metamask.js+1−1 src/views/Login/PrivateKey.js+1−1 src/views/Points.js+1−1 src/views/Release/Transfer.js+1−1 src/views/UrbitID/SetProxy.js+1−1 src/views/UrbitOS/NetworkingKeys.js+1−1
DEVELOPMENT.md−16
@@ -106,22 +106,6 @@ Automated tests for critical user journeys are coming Soon™️. Until then, he
1061063. Confirm that you are able to view the Points list view. Since no points have been created yet, you should see the following message:
107107> No points to display. This wallet is not the owner or proxy for any points.
108108
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−
125109### Planet Creation
126110
127111"As a user, I can create a new planet"
src/lib/flowCommand.ts+2−9
@@ -1,5 +1,5 @@
11import { useMemo } from 'react';
2−import { isValidAddress } from './utils/crypto';
2+import { isValidAddress } from './utils/address';
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,16 +21,9 @@ 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−
3124const useFlowCommand = () => {
3225 const flow = useMemo(() => {
33− let flow: FlowType = {};
26+ let flow = {};
3427
3528 window.location.search
3629 .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 { addHexPrefix, eqAddr } from './utils/crypto';
8+import { addHexPrefix, eqAddr } from './utils/address';
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 './utils/crypto';
10+import { addHexPrefix } from './utils/address';
1111import {
1212 sendAndAwaitAllSerial,
1313 signTransaction,
src/lib/txn.js+1−1
@@ -7,7 +7,7 @@ import { NETWORK_TYPES } from './network';
77import { ledgerSignTransaction } from './ledger';
88import { trezorSignTransaction } from './trezor';
99import { metamaskSignTransaction, FakeMetamaskTransaction } from './metamask';
10−import { addHexPrefix } from './utils/crypto';
10+import { addHexPrefix } from './utils/address';
1111import { CHECK_BLOCK_EVERY_MS, WALLET_TYPES } from './constants';
1212import patp2dec from './patp2dec';
1313
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/utils/crypto';
4+import { eqAddr } from 'lib/utils/address';
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 './utils/crypto';
8+import { eqAddr, isZeroAddress } from './utils/address';
99
1010const NULL_PERMISSIONS = {
1111 isActive: false,
src/lib/utils/crypto.test.ts → src/lib/utils/address.test.tsrenamed+2−2
@@ -1,6 +1,6 @@
11import { mnemonicToSeedSync } from 'bip39';
22import { bip32 } from 'bitcoinjs-lib';
3−import { bufferedPublicKeyToAddress } from './crypto';
3+import { publicToAddress } from './address';
44
55describe('#bufferedPublicKeyToAddress', () => {
66 // TODO: why does this seemingly work in the Mnemonic login flow, but not in a test?
@@ -14,6 +14,6 @@ describe('#bufferedPublicKeyToAddress', () => {
1414
1515 const expected = 'foo';
1616
17− expect(bufferedPublicKeyToAddress(wallet.publicKey)).toEqual(expected);
17+ expect(publicToAddress(wallet.publicKey)).toEqual(expected);
1818 });
1919});
src/lib/utils/crypto.ts → src/lib/utils/address.tsrenamed+3−3
@@ -1,6 +1,6 @@
11import { reduce } from 'lodash';
22import { isAddress, keccak256, toHex } from 'web3-utils';
3−import { publicToAddress } from 'ethereumjs-util';
3+import { pubToAddress } from 'ethereumjs-util';
44import { ETH_ZERO_ADDR, ETH_ZERO_ADDR_SHORT } from 'lib/constants';
55
66export const stripHexPrefix = (hex: string) => {
@@ -34,6 +34,6 @@ export const toChecksumAddress = address => {
3434export const eqAddr = (addr0, addr1) =>
3535 toChecksumAddress(addr0) === toChecksumAddress(addr1);
3636
37−export const bufferedPublicKeyToAddress = (publicKey: Buffer): string => {
38− return toHex(publicToAddress(publicKey, true).toString('hex'));
37+export const publicToAddress = (publicKey: Buffer): string => {
38+ return toHex(pubToAddress(publicKey, true).toString('hex'));
3939};
src/lib/validators.js+1−1
@@ -3,7 +3,7 @@ import * as bitcoin from 'bitcoinjs-lib';
33import ob from 'urbit-ob';
44import { includes } from 'lodash';
55
6−import { isValidAddress } from './utils/crypto';
6+import { isValidAddress } from './utils/address';
77import patp2dec from './patp2dec';
88import { patpStringLength } from './lib';
99import {
src/lib/wallet.ts+3−5
@@ -4,14 +4,12 @@ import { bip32 } from 'bitcoinjs-lib';
44import { Just, Nothing } from 'folktale/maybe';
55import * as secp256k1 from 'secp256k1';
66import * as kg from 'urbit-key-generation';
7−import { publicToAddress } from 'ethereumjs-util';
8−import { toHex } from 'web3-utils';
9−import { bufferedPublicKeyToAddress } from './utils/crypto';
7+import { publicToAddress } from './utils/address';
108
119export function EthereumWallet(privateKey) {
1210 this.privateKey = privateKey;
1311 this.publicKey = secp256k1.publicKeyCreate(this.privateKey);
14− this.address = bufferedPublicKeyToAddress(this.publicKey);
12+ this.address = publicToAddress(this.publicKey);
1513}
1614
1715export const urbitWalletFromTicket = async (ticket, point, passphrase) => {
@@ -37,7 +35,7 @@ export const walletFromMnemonic = (
3735 let wal;
3836 const hd = bip32.fromSeed(sd);
3937 wal = hd.derivePath(path);
40− wal.address = bufferedPublicKeyToAddress(wal.publicKey);
38+ wal.address = publicToAddress(wal.publicKey);
4139 wal.passphrase = passphrase || '';
4240 wal = Just(wal);
4341 return wal;
src/store/wallet.js+2−2
@@ -19,7 +19,7 @@ import { getAuthToken } from 'lib/authToken';
1919import { BRIDGE_ERROR } from 'lib/error';
2020
2121import { useNetwork } from 'store/network';
22−import { bufferedPublicKeyToAddress } from 'lib/utils/crypto';
22+import { publicToAddress } from 'lib/utils/address';
2323
2424export const WalletContext = createContext(null);
2525
@@ -94,7 +94,7 @@ function _useWallet(initialWallet = Nothing(), initialMnemonic = Nothing()) {
9494 // force that public addresses are derived for each wallet
9595 // NOTE wallet is Maybe<> and .map is Maybe#map
9696 wallet.map(wal => {
97− wal.address = wal.address || bufferedPublicKeyToAddress(wal.publicKey);
97+ wal.address = wal.address || publicToAddress(wal.publicKey);
9898 return wal;
9999 });
100100
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';
1313import { GAS_LIMITS } from 'lib/constants';
1414import { useLocalRouter } from 'lib/LocalRouter';
1515import { useFlowCommand } from 'lib/flowCommand';
16−import { isValidAddress, eqAddr } from 'lib/utils/crypto';
16+import { isValidAddress, eqAddr } from 'lib/utils/address';
1717
1818import ViewHeader from 'components/ViewHeader';
1919import InlineEthereumTransaction from 'components/InlineEthereumTransaction';
src/views/Activate/ActivatePassport.js+2−2
@@ -16,7 +16,7 @@ import PassportVerify from './PassportVerify';
1616import PassportTransfer from './PassportTransfer';
1717import { walletFromMnemonic } from 'lib/wallet';
1818import { DEFAULT_HD_PATH } from 'lib/constants';
19−import { bufferedPublicKeyToAddress } from 'lib/utils/crypto';
19+import { publicToAddress } from 'lib/utils/address';
2020
2121const NAMES = {
2222 DOWNLOAD: 'DOWNLOAD',
@@ -54,7 +54,7 @@ export default function ActivatePassport() {
5454 wallet.meta.passphrase
5555 )
5656 )
57− .map(wallet => bufferedPublicKeyToAddress(wallet.publicKey)),
57+ .map(wallet => publicToAddress(wallet.publicKey)),
5858 [derivedWallet]
5959 );
6060 //~hobbyn-mismur-fonrux-datber
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/utils/crypto';
13+import { isZeroAddress } from 'lib/utils/address';
1414import { useLocalRouter } from 'lib/LocalRouter';
1515
1616import ViewHeader from 'components/ViewHeader';
src/views/Login/Metamask.js+1−1
@@ -6,7 +6,7 @@ import { FORM_ERROR } from 'final-form';
66import { useWallet } from 'store/wallet';
77import { useNetwork } from 'store/network';
88
9−import { abbreviateAddress } from 'lib/utils/crypto';
9+import { abbreviateAddress } from 'lib/utils/address';
1010import { WALLET_TYPES } from 'lib/constants';
1111import { MetamaskWallet } from 'lib/metamask';
1212import { getAuthToken } from 'lib/authToken';
src/views/Login/PrivateKey.js+1−1
@@ -5,7 +5,7 @@ import { Grid } from 'indigo-react';
55import { useWallet } from 'store/wallet';
66
77import { EthereumWallet } from 'lib/wallet';
8−import { stripHexPrefix } from 'lib/utils/crypto';
8+import { stripHexPrefix } from 'lib/utils/address';
99import { WALLET_TYPES } from 'lib/constants';
1010import useLoginView from 'lib/useLoginView';
1111
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/utils/crypto';
13+import { isZeroAddress, abbreviateAddress } from 'lib/utils/address';
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/utils/crypto';
9+import { eqAddr, isZeroAddress } from 'lib/utils/address';
1010
1111import { useNetwork } from 'store/network';
1212import { useWallet } from 'store/wallet';
src/views/UrbitID/SetProxy.js+1−1
@@ -14,7 +14,7 @@ import {
1414} from 'lib/proxy';
1515import * as need from 'lib/need';
1616import { useLocalRouter } from 'lib/LocalRouter';
17−import { eqAddr, isZeroAddress } from 'lib/utils/crypto';
17+import { eqAddr, isZeroAddress } from 'lib/utils/address';
1818import capitalize from 'lib/capitalize';
1919import useEthereumTransaction from 'lib/useEthereumTransaction';
2020
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/utils/crypto';
21+import { addHexPrefix } from 'lib/utils/address';
2222import useKeyfileGenerator from 'lib/useKeyfileGenerator';
2323
2424import ViewHeader from 'components/ViewHeader';