on master help sign in
fix: revert lib export style, consolidate lib functions in walletgen
621eafbMatt Condon (shrugs)
src/bridge/lib/lib.js+25−11
@@ -1,26 +1,26 @@
1import * as ob from 'urbit-ob';
1import * as ob from 'urbit-ob';
2
2
3−export const compose = (...fs) =>
3+const compose = (...fs) =>
4 fs.reduceRight((pF, nF) => (...args) => nF(pF(...args)), v => v);
4 fs.reduceRight((pF, nF) => (...args) => nF(pF(...args)), v => v);
5
5
6−export const allFalse = (...args) => args.every(a => a === false);
6+const allFalse = (...args) => args.every(a => a === false);
7
7
8−export const isLast = (l, i) => i === l - 1;
8+const isLast = (l, i) => i === l - 1;
9
9
10−export const isUndefined = v => v === undefined;
10+const isUndefined = v => v === undefined;
11
11
12−export const defaultTo = (v, d) => (isUndefined(v) ? d : v);
12+const defaultTo = (v, d) => (isUndefined(v) ? d : v);
13
13
14−export const seq = n => Array.from(Array(n), (_, i) => i);
14+const seq = n => Array.from(Array(n), (_, i) => i);
15
15
16−export const fill = (n, v) => Array.from(Array(n), () => v);
16+const fill = (n, v) => Array.from(Array(n), () => v);
17
17
18// Terse true/false checks
18// Terse true/false checks
19−export const t = v => v === true;
19+const t = v => v === true;
20
20
21−export const f = v => v === false;
21+const f = v => v === false;
22
22
23−export const isValidGalaxy = name => {
23+const isValidGalaxy = name => {
24 let point;
24 let point;
25 try {
25 try {
26 point = parseInt(ob.patp2dec(name), 10);
26 point = parseInt(ob.patp2dec(name), 10);
@@ -30,7 +30,7 @@ export const isValidGalaxy = name => {
30 return point >= 0 && point < 256;
30 return point >= 0 && point < 256;
31};
31};
32
32
33−export const randomPatq = len => {
33+const randomPatq = len => {
34 let bytes = window.crypto.getRandomValues(new Uint8Array(len));
34 let bytes = window.crypto.getRandomValues(new Uint8Array(len));
35 let hex = bytes.reduce(
35 let hex = bytes.reduce(
36 (acc, byt) => acc + byt.toString(16).padStart(2, '0'),
36 (acc, byt) => acc + byt.toString(16).padStart(2, '0'),
@@ -38,3 +38,17 @@ export const randomPatq = len => {
38 );
38 );
39 return ob.hex2patq(hex);
39 return ob.hex2patq(hex);
40};
40};
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';
19
19
20import './style/index.css';
20import './style/index.css';
21
21
22−// TODO: actually merge these two projects into one
23import { OnlineProvider } from '../bridge/store/online';
22import { OnlineProvider } from '../bridge/store/online';
24
23
25const ROUTES = [
24const ROUTES = [
src/walletgen/components/Header.js+1−1
@@ -1,7 +1,7 @@
1import React from 'react';
1import React from 'react';
2−import { seq } from '../lib/lib';
3
2
4import { useOnline, ONLINE_STATUS } from '../../bridge/store/online';
3import { useOnline, ONLINE_STATUS } from '../../bridge/store/online';
4+import { seq } from '../../bridge/lib/lib';
5
5
6const StatusIndicator = props => (
6const StatusIndicator = props => (
7 <div className={`flex h-9 align-center ${props.c2} flex-shrink-0`}>
7 <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) => {
66const generateOwnershipWallet = (ship, ticket) =>
66const generateOwnershipWallet = (ship, ticket) =>
67 kg.generateOwnershipWallet({ ship, ticket });
67 kg.generateOwnershipWallet({ ship, ticket });
68
68
69−const seq = num => Array.from(Array(num), (_, i) => i);
70−
71−export { makeTicket, generateWallet, generateOwnershipWallet, seq };
69+export { makeTicket, generateWallet, generateOwnershipWallet };