on master help sign in
fix: CONSTANT_CASE most of the constants
73303fcMatt Condon (shrugs)
src/Bridge.js+12−12
@@ -14,38 +14,38 @@ import { isDevelopment } from 'lib/flags';
14
14
15import 'style/index.scss';
15import 'style/index.scss';
16
16
17−const kInitialNetworkType = isDevelopment
17+const INITIAL_NETWORK_TYPE = isDevelopment
18 ? NETWORK_TYPES.LOCAL
18 ? NETWORK_TYPES.LOCAL
19 : NETWORK_TYPES.MAINNET;
19 : NETWORK_TYPES.MAINNET;
20
20
21// NB(shrugs): modify these variables to change the default local state.
21// NB(shrugs): modify these variables to change the default local state.
22−const shouldStubLocal = process.env.REACT_APP_STUB_LOCAL === 'true';
22+const SHOULD_STUB_LOCAL = process.env.REACT_APP_STUB_LOCAL === 'true';
23−const kIsStubbed = isDevelopment && shouldStubLocal;
23+const IS_STUBBED = isDevelopment && SHOULD_STUB_LOCAL;
24−const kInitialRoutes = kIsStubbed
24+const INITIAL_ROUTES = IS_STUBBED
25 ? [{ key: ROUTE_NAMES.LANDING }, { key: ROUTE_NAMES.ACTIVATE }]
25 ? [{ key: ROUTE_NAMES.LANDING }, { key: ROUTE_NAMES.ACTIVATE }]
26 : [{ key: ROUTE_NAMES.LANDING }];
26 : [{ key: ROUTE_NAMES.LANDING }];
27
27
28−const kInitialWallet = kIsStubbed
28+const INITIAL_WALLET = IS_STUBBED
29 ? walletFromMnemonic(
29 ? walletFromMnemonic(
30 process.env.REACT_APP_DEV_MNEMONIC,
30 process.env.REACT_APP_DEV_MNEMONIC,
31 process.env.REACT_APP_HD_PATH
31 process.env.REACT_APP_HD_PATH
32 )
32 )
33 : undefined;
33 : undefined;
34−const kInitialMnemonic = kIsStubbed
34+const INITIAL_MNEMONIC = IS_STUBBED
35 ? Just(process.env.REACT_APP_DEV_MNEMONIC)
35 ? Just(process.env.REACT_APP_DEV_MNEMONIC)
36 : Nothing();
36 : Nothing();
37−const kInitialPointCursor = kIsStubbed ? Just(65792) : Nothing();
37+const INITIAL_POINT_CURSOR = IS_STUBBED ? Just(65792) : Nothing();
38
38
39export default function Bridge() {
39export default function Bridge() {
40 return (
40 return (
41 <Provider
41 <Provider
42 views={ROUTES}
42 views={ROUTES}
43 names={ROUTE_NAMES}
43 names={ROUTE_NAMES}
44− initialRoutes={kInitialRoutes}
44+ initialRoutes={INITIAL_ROUTES}
45− initialNetworkType={kInitialNetworkType}
45+ initialNetworkType={INITIAL_NETWORK_TYPE}
46− initialWallet={kInitialWallet}
46+ initialWallet={INITIAL_WALLET}
47− initialMnemonic={kInitialMnemonic}
47+ initialMnemonic={INITIAL_MNEMONIC}
48− initialPointCursor={kInitialPointCursor}>
48+ initialPointCursor={INITIAL_POINT_CURSOR}>
49 <IndigoApp>
49 <IndigoApp>
50 <Router />
50 <Router />
51 </IndigoApp>
51 </IndigoApp>
src/components/Blinky.js+4−4
@@ -3,8 +3,8 @@ import React, { useState, useRef } from 'react';
3import useInterval from 'lib/useInterval';
3import useInterval from 'lib/useInterval';
4
4
5// TODO: make these characters display as the same width
5// TODO: make these characters display as the same width
6−export const kLoadingCharacter = '▓';
6+export const LOADING_CHARACTER = '▓';
7−export const kInterstitialCharacter = '░';
7+export const INTERSTITIAL_CHARACTER = '░';
8const BLINK_AFTER_MS = 2500; // ms
8const BLINK_AFTER_MS = 2500; // ms
9
9
10export const matchBlinky = obj =>
10export const matchBlinky = obj =>
@@ -14,8 +14,8 @@ export const matchBlinky = obj =>
14 });
14 });
15
15
16export default function Blinky({
16export default function Blinky({
17− a = kLoadingCharacter,
17+ a = LOADING_CHARACTER,
18− b = kInterstitialCharacter,
18+ b = INTERSTITIAL_CHARACTER,
19 delayed = false,
19 delayed = false,
20}) {
20}) {
21 const [value, setValue] = useState(true);
21 const [value, setValue] = useState(true);
src/components/Passport.js+16−16
@@ -8,24 +8,24 @@ import { times } from 'lodash';
8import usePointBirthday from 'lib/usePointBirthday';
8import usePointBirthday from 'lib/usePointBirthday';
9import { formatDots } from 'lib/dateFormat';
9import { formatDots } from 'lib/dateFormat';
10
10
11−import Blinky, { kLoadingCharacter, kInterstitialCharacter } from './Blinky';
11+import Blinky, { LOADING_CHARACTER, INTERSTITIAL_CHARACTER } from './Blinky';
12import MaybeSigil from './MaybeSigil';
12import MaybeSigil from './MaybeSigil';
13
13
14const buildDate = char =>
14const buildDate = char =>
15 [4, 2, 2].map(t => times(t, () => char).join('')).join('.');
15 [4, 2, 2].map(t => times(t, () => char).join('')).join('.');
16−const kDateA = buildDate(kLoadingCharacter);
16+const DATE_A = buildDate(LOADING_CHARACTER);
17−const kDateB = buildDate(kInterstitialCharacter);
17+const DATE_B = buildDate(INTERSTITIAL_CHARACTER);
18
18
19−const kTicketCharacterLength = 30;
19+const TICKET_CHAR_LENGTH = 30;
20−const kTicket = times(kTicketCharacterLength, i =>
20+const TICKET = times(TICKET_CHAR_LENGTH, i =>
21− i % 2 === 0 ? kLoadingCharacter : kInterstitialCharacter
21+ i % 2 === 0 ? LOADING_CHARACTER : INTERSTITIAL_CHARACTER
22).join('');
22).join('');
23−const kPendingTicket = kTicket;
23+const PENDING_TICKET = TICKET;
24−const kValidTicket = `${kTicket} ◆`;
24+const VALID_TICKET = `${TICKET} ◆`;
25
25
26−const kVisibleAddressCharacters = 20;
26+const VISIBLE_ADDRESS_CHAR_COUNT = 20;
27−const kEmptyHalfAddress = times(kVisibleAddressCharacters, () => '<').join('');
27+const EMPTY_ADDRESS = times(VISIBLE_ADDRESS_CHAR_COUNT, () => '<').join('');
28−const kBufferAddressCharacters = times(40, () => '<').join('');
28+const ADDRESS_BUFFER_CHARS = times(40, () => '<').join('');
29
29
30/**
30/**
31 * point is Maybe<number>
31 * point is Maybe<number>
@@ -41,7 +41,7 @@ export default function Passport({
41}) {
41}) {
42 const birthday = usePointBirthday(point.getOrElse(null));
42 const birthday = usePointBirthday(point.getOrElse(null));
43 const visualBirthday = birthday.matchWith({
43 const visualBirthday = birthday.matchWith({
44− Nothing: () => <Blinky a={kDateA} b={kDateB} delayed />,
44+ Nothing: () => <Blinky a={DATE_A} b={DATE_B} delayed />,
45 Just: p => formatDots(p.value),
45 Just: p => formatDots(p.value),
46 });
46 });
47
47
@@ -56,11 +56,11 @@ export default function Passport({
56
56
57 const showTicket = ticket !== null;
57 const showTicket = ticket !== null;
58 const isValidTiket = !!ticket;
58 const isValidTiket = !!ticket;
59− const visibleTicket = isValidTiket ? kValidTicket : kPendingTicket;
59+ const visibleTicket = isValidTiket ? VALID_TICKET : PENDING_TICKET;
60 const visibleAddress = `${address.matchWith({
60 const visibleAddress = `${address.matchWith({
61− Nothing: () => kEmptyHalfAddress,
61+ Nothing: () => EMPTY_ADDRESS,
62− Just: p => p.value.slice(0, kVisibleAddressCharacters),
62+ Just: p => p.value.slice(0, VISIBLE_ADDRESS_CHAR_COUNT),
63− })}${kBufferAddressCharacters}`;
63+ })}${ADDRESS_BUFFER_CHARS}`;
64
64
65 return (
65 return (
66 <Grid gap={4} className={cn('bg-black r8 p7', className)}>
66 <Grid gap={4} className={cn('bg-black r8 p7', className)}>
src/lib/MediaQuery.js+2−2
@@ -4,7 +4,7 @@ import { createContext, useContext } from 'react';
4import useMedia from './useMedia';
4import useMedia from './useMedia';
5
5
6// sync with //indigo/indigo/css/src/lib/_breakpoints.scss
6// sync with //indigo/indigo/css/src/lib/_breakpoints.scss
7−const kBreakpoints = [
7+const BREAKPOINTS = [
8 '(min-width: 550px)', // ns
8 '(min-width: 550px)', // ns
9 '(min-width: 750px)', // md
9 '(min-width: 750px)', // md
10 '(min-width: 960px)', // lg
10 '(min-width: 960px)', // lg
@@ -13,7 +13,7 @@ const kBreakpoints = [
13export const MediaQueryContext = createContext(null);
13export const MediaQueryContext = createContext(null);
14// provide the index to consumers so they can easily index an array
14// provide the index to consumers so they can easily index an array
15export const MediaQueryProvider = ({ children }) => (
15export const MediaQueryProvider = ({ children }) => (
16− <MediaQueryContext.Provider value={useMedia(kBreakpoints, [0, 1, 2], 0)}>
16+ <MediaQueryContext.Provider value={useMedia(BREAKPOINTS, [0, 1, 2], 0)}>
17 {children}
17 {children}
18 </MediaQueryContext.Provider>
18 </MediaQueryContext.Provider>
19);
19);
src/store/lib/useControlledPointsStore.js+3−3
@@ -5,7 +5,7 @@ import * as azimuth from 'azimuth-js';
5import { useNetwork } from '../network';
5import { useNetwork } from '../network';
6import { useWallet } from 'store/wallet';
6import { useWallet } from 'store/wallet';
7
7
8−const kEmptyControlledPoints = {
8+const EMPTY_CONTROLLED_POINTS = {
9 ownedPoints: Maybe.Nothing(),
9 ownedPoints: Maybe.Nothing(),
10 incomingPoints: Maybe.Nothing(),
10 incomingPoints: Maybe.Nothing(),
11 managingPoints: Maybe.Nothing(),
11 managingPoints: Maybe.Nothing(),
@@ -17,11 +17,11 @@ export default function useControlledPointsStore() {
17 const { contracts } = useNetwork();
17 const { contracts } = useNetwork();
18 const { wallet } = useWallet();
18 const { wallet } = useWallet();
19 const [controlledPointsCache, _setControlledPointsCache] = useState(
19 const [controlledPointsCache, _setControlledPointsCache] = useState(
20− kEmptyControlledPoints
20+ EMPTY_CONTROLLED_POINTS
21 );
21 );
22
22
23 const getControlledPoints = useCallback(
23 const getControlledPoints = useCallback(
24− () => controlledPointsCache || kEmptyControlledPoints,
24+ () => controlledPointsCache || EMPTY_CONTROLLED_POINTS,
25 [controlledPointsCache]
25 [controlledPointsCache]
26 );
26 );
27
27
src/store/lib/useInvitesStore.js+2−2
@@ -5,7 +5,7 @@ import * as azimuth from 'azimuth-js';
5import { useNetwork } from '../network';
5import { useNetwork } from '../network';
6
6
7// the default value of a point's invites
7// the default value of a point's invites
8−const kEmptyInvites = {
8+const EMPTY_INVITES = {
9 availableInvites: Maybe.Nothing(),
9 availableInvites: Maybe.Nothing(),
10 sentInvites: Maybe.Nothing(),
10 sentInvites: Maybe.Nothing(),
11 acceptedInvites: Maybe.Nothing(),
11 acceptedInvites: Maybe.Nothing(),
@@ -25,7 +25,7 @@ export default function useInvitesStore() {
25 );
25 );
26
26
27 const getInvites = useCallback(
27 const getInvites = useCallback(
28− point => invitesCache[point] || kEmptyInvites,
28+ point => invitesCache[point] || EMPTY_INVITES,
29 [invitesCache]
29 [invitesCache]
30 );
30 );
31
31
src/store/wallet.js+3−3
@@ -18,7 +18,7 @@ import { BRIDGE_ERROR } from 'lib/error';
18
18
19export const WalletContext = createContext(null);
19export const WalletContext = createContext(null);
20
20
21−const kDefaultWalletType = WALLET_TYPES.TICKET;
21+const DEFAULT_WALLET_TYPE = WALLET_TYPES.TICKET;
22
22
23// NB (jtobin):
23// NB (jtobin):
24//
24//
@@ -36,7 +36,7 @@ function _useWallet(
36 initialWallet = Maybe.Nothing(),
36 initialWallet = Maybe.Nothing(),
37 initialMnemonic = Maybe.Nothing()
37 initialMnemonic = Maybe.Nothing()
38) {
38) {
39− const [walletType, _setWalletType] = useState(kDefaultWalletType);
39+ const [walletType, _setWalletType] = useState(DEFAULT_WALLET_TYPE);
40 const [walletHdPath, setWalletHdPath] = useState(DEFAULT_HD_PATH);
40 const [walletHdPath, setWalletHdPath] = useState(DEFAULT_HD_PATH);
41 const [wallet, _setWallet] = useState(initialWallet);
41 const [wallet, _setWallet] = useState(initialWallet);
42 const [urbitWallet, _setUrbitWallet] = useState(Maybe.Nothing());
42 const [urbitWallet, _setUrbitWallet] = useState(Maybe.Nothing());
@@ -90,7 +90,7 @@ function _useWallet(
90 );
90 );
91
91
92 const resetWallet = useCallback(() => {
92 const resetWallet = useCallback(() => {
93− _setWalletType(kDefaultWalletType);
93+ _setWalletType(DEFAULT_WALLET_TYPE);
94 setWalletHdPath(DEFAULT_HD_PATH);
94 setWalletHdPath(DEFAULT_HD_PATH);
95 _setWallet(Maybe.Nothing());
95 _setWallet(Maybe.Nothing());
96 _setUrbitWallet(Maybe.Nothing());
96 _setUrbitWallet(Maybe.Nothing());
src/views/Activate.js+8−8
@@ -9,24 +9,24 @@ import ActivateDisclaimer from './Activate/ActivateDisclaimer';
9import { LocalRouterProvider } from 'lib/LocalRouter';
9import { LocalRouterProvider } from 'lib/LocalRouter';
10import ActivatePassport from './Activate/ActivatePassport';
10import ActivatePassport from './Activate/ActivatePassport';
11
11
12−const kActivateNames = {
12+const NAMES = {
13 CODE: 'CODE',
13 CODE: 'CODE',
14 DISCLAIMER: 'DISCLAIMER',
14 DISCLAIMER: 'DISCLAIMER',
15 PASSPORT: 'PASSPORT',
15 PASSPORT: 'PASSPORT',
16};
16};
17
17
18−const kActivateViews = {
18+const VIEWS = {
19− [kActivateNames.CODE]: ActivateCode,
19+ [NAMES.CODE]: ActivateCode,
20− [kActivateNames.DISCLAIMER]: ActivateDisclaimer,
20+ [NAMES.DISCLAIMER]: ActivateDisclaimer,
21− [kActivateNames.PASSPORT]: ActivatePassport,
21+ [NAMES.PASSPORT]: ActivatePassport,
22};
22};
23
23
24export default function Activate() {
24export default function Activate() {
25 const state = useActivateFlowState();
25 const state = useActivateFlowState();
26 const { Route, ...router } = useRouter({
26 const { Route, ...router } = useRouter({
27− names: kActivateNames,
27+ names: NAMES,
28− views: kActivateViews,
28+ views: VIEWS,
29− initialRoutes: [{ key: kActivateNames.CODE }],
29+ initialRoutes: [{ key: NAMES.CODE }],
30 });
30 });
31
31
32 return (
32 return (
src/views/Activate/ActivateDisclaimer.js+10−10
@@ -8,7 +8,7 @@ import { ForwardButton } from 'components/Buttons';
8import { useLocalRouter } from 'lib/LocalRouter';
8import { useLocalRouter } from 'lib/LocalRouter';
9import WarningBox from 'components/WarningBox';
9import WarningBox from 'components/WarningBox';
10
10
11−const kTextStyle = 'f5';
11+const TEXT_STYLE = 'f5';
12
12
13export default function ActivateDisclaimer() {
13export default function ActivateDisclaimer() {
14 const { push, names } = useLocalRouter();
14 const { push, names } = useLocalRouter();
@@ -26,28 +26,28 @@ export default function ActivateDisclaimer() {
26 Disclaimer
26 Disclaimer
27 </Grid.Item>
27 </Grid.Item>
28 <Grid.Item full>
28 <Grid.Item full>
29− <Text className={cn(kTextStyle, 'block mb4')}>
29+ <Text className={cn(TEXT_STYLE, 'block mb4')}>
30 Welcome to Bridge. Please read this information. Your assets could
30 Welcome to Bridge. Please read this information. Your assets could
31 be stolen if you do not pay attention to these warnings.
31 be stolen if you do not pay attention to these warnings.
32 </Text>
32 </Text>
33
33
34− <Text className={cn(kTextStyle, 'block mb4')}>
34+ <Text className={cn(TEXT_STYLE, 'block mb4')}>
35 <B>You own and control your assets. We do not.</B> If you send your
35 <B>You own and control your assets. We do not.</B> If you send your
36 assets to another address, we can’t get them back for you.
36 assets to another address, we can’t get them back for you.
37 </Text>
37 </Text>
38
38
39− <B className={kTextStyle}>Please understand that nobody can:</B>
39+ <B className={TEXT_STYLE}>Please understand that nobody can:</B>
40− <Text className={cn(kTextStyle, 'block mb4')}>
40+ <Text className={cn(TEXT_STYLE, 'block mb4')}>
41 1. Access your assets for you <br />
41 1. Access your assets for you <br />
42 2. Recover, reset, or modify ANY of your information <br />
42 2. Recover, reset, or modify ANY of your information <br />
43 3. Reverse, cancel, or refund transactions <br />
43 3. Reverse, cancel, or refund transactions <br />
44 4. Hold, back-up, or access your keys
44 4. Hold, back-up, or access your keys
45 </Text>
45 </Text>
46
46
47− <B className={kTextStyle}>
47+ <B className={TEXT_STYLE}>
48 You’re responsible for keeping your information safe. This includes:
48 You’re responsible for keeping your information safe. This includes:
49 </B>
49 </B>
50− <Text className={cn(kTextStyle, 'block mb4')}>
50+ <Text className={cn(TEXT_STYLE, 'block mb4')}>
51 1. Private Keys/Mnemonic Phrases and passwords <br />
51 1. Private Keys/Mnemonic Phrases and passwords <br />
52 2. JSON files <br />
52 2. JSON files <br />
53 3. Hardware wallet PINs; <br />
53 3. Hardware wallet PINs; <br />
@@ -56,12 +56,12 @@ export default function ActivateDisclaimer() {
56 here]
56 here]
57 </Text>
57 </Text>
58
58
59− <B className={kTextStyle}>To be clear</B>
59+ <B className={TEXT_STYLE}>To be clear</B>
60− <Text className={cn(kTextStyle, 'block')}>
60+ <Text className={cn(TEXT_STYLE, 'block')}>
61 This software is provided “as is” without warranties of any kind and
61 This software is provided “as is” without warranties of any kind and
62 our liability to you in connection with the same is limited;
62 our liability to you in connection with the same is limited;
63 </Text>
63 </Text>
64− <Text className={cn(kTextStyle, 'block')}>
64+ <Text className={cn(TEXT_STYLE, 'block')}>
65 We have no liability for any security problems or incidents that you
65 We have no liability for any security problems or incidents that you
66 may experience, including any loss or theft of your keys or any
66 may experience, including any loss or theft of your keys or any
67 problems that may arise in connection with your wallet.
67 problems that may arise in connection with your wallet.
src/views/Activate/ActivatePassport.js+8−8
@@ -21,16 +21,16 @@ import {
21 addressFromSecp256k1Public,
21 addressFromSecp256k1Public,
22} from 'lib/wallet';
22} from 'lib/wallet';
23
23
24−const kPassportNames = {
24+const NAMES = {
25 DOWNLOAD: 'DOWNLOAD',
25 DOWNLOAD: 'DOWNLOAD',
26 VERIFY: 'VERIFY',
26 VERIFY: 'VERIFY',
27 TRANSFER: 'TRANSFER',
27 TRANSFER: 'TRANSFER',
28};
28};
29
29
30−const kPassportViews = {
30+const VIEWS = {
31− [kPassportNames.DOWNLOAD]: PassportDownload,
31+ [NAMES.DOWNLOAD]: PassportDownload,
32− [kPassportNames.VERIFY]: PassportVerify,
32+ [NAMES.VERIFY]: PassportVerify,
33− [kPassportNames.TRANSFER]: PassportTransfer,
33+ [NAMES.TRANSFER]: PassportTransfer,
34};
34};
35
35
36export default function ActivatePassport() {
36export default function ActivatePassport() {
@@ -38,9 +38,9 @@ export default function ActivatePassport() {
38 // pull the reset function out of the 'activate' router
38 // pull the reset function out of the 'activate' router
39 const { reset: resetActivateRouter } = useLocalRouter();
39 const { reset: resetActivateRouter } = useLocalRouter();
40 const { Route, ...router } = useRouter({
40 const { Route, ...router } = useRouter({
41− names: kPassportNames,
41+ names: NAMES,
42− views: kPassportViews,
42+ views: VIEWS,
43− initialRoutes: [{ key: kPassportNames.DOWNLOAD }],
43+ initialRoutes: [{ key: NAMES.DOWNLOAD }],
44 });
44 });
45
45
46 const fullView = useBreakpoints([false, false, true]);
46 const fullView = useBreakpoints([false, false, true]);
src/views/Invite.js+5−5
@@ -19,12 +19,12 @@ import { LocalRouterProvider } from 'lib/LocalRouter';
19import InviteUrl from './Invite/InviteUrl';
19import InviteUrl from './Invite/InviteUrl';
20import InviteEmail from './Invite/InviteEmail';
20import InviteEmail from './Invite/InviteEmail';
21
21
22−const kInviteNames = {
22+const NAMES = {
23 URL: 'URL',
23 URL: 'URL',
24 EMAIL: 'EMAIL',
24 EMAIL: 'EMAIL',
25};
25};
26
26
27−const kInviteViews = {
27+const VIEWS = {
28 URL: InviteUrl,
28 URL: InviteUrl,
29 EMAIL: InviteEmail,
29 EMAIL: InviteEmail,
30};
30};
@@ -32,9 +32,9 @@ const kInviteViews = {
32export default function Invite() {
32export default function Invite() {
33 const history = useHistory();
33 const history = useHistory();
34 const { Route, ...router } = useRouter({
34 const { Route, ...router } = useRouter({
35− names: kInviteNames,
35+ names: NAMES,
36− views: kInviteViews,
36+ views: VIEWS,
37− initialRoutes: [{ key: kInviteNames.URL }],
37+ initialRoutes: [{ key: NAMES.URL }],
38 });
38 });
39 const { pointCursor } = usePointCursor();
39 const { pointCursor } = usePointCursor();
40 const point = need.point(pointCursor);
40 const point = need.point(pointCursor);