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