on master help sign in
fix: revert lib export style, consolidate lib functions in walletgen
commit621eafb38e92ccdd58c7a5bd86394b67c81e2798 authorMatt Condon (shrugs) <mattgcondon@gmail.com> dateWed 12 Jun 2019, 15:42 (7 years ago) parent5c24a13
4 files changed+27−16
src/bridge/lib/lib.js+25−11 src/walletgen/Walletgen.js−1 src/walletgen/components/Header.js+1−1 src/walletgen/lib/lib.js+1−3
src/bridge/lib/lib.js+25−11
@@ -1,26 +1,26 @@
11import * as ob from 'urbit-ob';
22
3−export const compose = (...fs) =>
3+const compose = (...fs) =>
44 fs.reduceRight((pF, nF) => (...args) => nF(pF(...args)), v => v);
55
6−export const allFalse = (...args) => args.every(a => a === false);
6+const allFalse = (...args) => args.every(a => a === false);
77
8−export const isLast = (l, i) => i === l - 1;
8+const isLast = (l, i) => i === l - 1;
99
10−export const isUndefined = v => v === undefined;
10+const isUndefined = v => v === undefined;
1111
12−export const defaultTo = (v, d) => (isUndefined(v) ? d : v);
12+const defaultTo = (v, d) => (isUndefined(v) ? d : v);
1313
14−export const seq = n => Array.from(Array(n), (_, i) => i);
14+const seq = n => Array.from(Array(n), (_, i) => i);
1515
16−export const fill = (n, v) => Array.from(Array(n), () => v);
16+const fill = (n, v) => Array.from(Array(n), () => v);
1717
1818// Terse true/false checks
19−export const t = v => v === true;
19+const t = v => v === true;
2020
21−export const f = v => v === false;
21+const f = v => v === false;
2222
23−export const isValidGalaxy = name => {
23+const isValidGalaxy = name => {
2424 let point;
2525 try {
2626 point = parseInt(ob.patp2dec(name), 10);
@@ -30,7 +30,7 @@ export const isValidGalaxy = name => {
3030 return point >= 0 && point < 256;
3131};
3232
33−export const randomPatq = len => {
33+const randomPatq = len => {
3434 let bytes = window.crypto.getRandomValues(new Uint8Array(len));
3535 let hex = bytes.reduce(
3636 (acc, byt) => acc + byt.toString(16).padStart(2, '0'),
@@ -38,3 +38,17 @@ export const randomPatq = len => {
3838 );
3939 return ob.hex2patq(hex);
4040};
41+
42+export {
43+ compose,
44+ allFalse,
45+ isLast,
46+ isUndefined,
47+ defaultTo,
48+ seq,
49+ fill,
50+ t,
51+ f,
52+ isValidGalaxy,
53+ randomPatq,
54+};
src/walletgen/Walletgen.js−1
@@ -19,7 +19,6 @@ import Done from './views/Done';
1919
2020import './style/index.css';
2121
22−// TODO: actually merge these two projects into one
2322import { OnlineProvider } from '../bridge/store/online';
2423
2524const ROUTES = [
src/walletgen/components/Header.js+1−1
@@ -1,7 +1,7 @@
11import React from 'react';
2−import { seq } from '../lib/lib';
32
43import { useOnline, ONLINE_STATUS } from '../../bridge/store/online';
4+import { seq } from '../../bridge/lib/lib';
55
66const StatusIndicator = props => (
77 <div className={`flex h-9 align-center ${props.c2} flex-shrink-0`}>
src/walletgen/lib/lib.js+1−3
@@ -66,6 +66,4 @@ const generateWallet = async (point, ticket, boot) => {
6666const generateOwnershipWallet = (ship, ticket) =>
6767 kg.generateOwnershipWallet({ ship, ticket });
6868
69−const seq = num => Array.from(Array(num), (_, i) => i);
70−
71−export { makeTicket, generateWallet, generateOwnershipWallet, seq };
69+export { makeTicket, generateWallet, generateOwnershipWallet };