on master help sign in
- Fix most ESLint warnings
commit643f71515e9e3b52595056425c3411df0a8071e1 authorChris Johnson <chris@cjohnson.io> dateFri 3 May 2019, 16:31 (8 years ago) parentdada87e
11 files changed+21−102
src/Root.js+1−1 src/bridge/components/Header.js+1−1 src/bridge/lib/invite.js+9−28 src/bridge/lib/txn.js−1 src/bridge/views/InviteTicket.js+2−13 src/bridge/views/InvitesManage.js+2−15 src/bridge/views/InvitesSend.js+2−27 src/bridge/views/Shards.js+1−1 src/bridge/views/Ticket.js+1−3 src/walletgen/lib/lib.js+1−3 src/walletgen/views/Generate.js+1−9
src/Root.js+1−1
@@ -5,7 +5,7 @@ import _ from 'lodash'
55
66import Bridge from './bridge/Bridge'
77import Walletgen from './walletgen/Walletgen'
8−import { AppNavigation } from './common/components/AppNavigation'
8+// import { AppNavigation } from './common/components/AppNavigation'
99
1010import './common/style/index.css'
1111import './bridge/style/index.css'
src/bridge/components/Header.js+1−1
@@ -1,7 +1,7 @@
11import React from 'react'
22import { Button, Chevron } from '../components/Base'
33
4−import { renderRoute, ROUTE_NAMES } from '../lib/router'
4+import { renderRoute } from '../lib/router'
55import { isLast } from '../lib/lib'
66
77const Crumbs = (props) => {
src/bridge/lib/invite.js+9−28
@@ -7,32 +7,25 @@ import * as more from 'more-entropy'
77import * as ob from 'urbit-ob'
88import * as kg from '../../../node_modules/urbit-key-generation/dist/index'
99import * as tank from './tank'
10−import { MAX_GALAXY, MIN_STAR, MAX_STAR, MIN_PLANET,
10+import { MIN_STAR, MIN_PLANET, SEED_ENTROPY_BITS,
1111 GALAXY_ENTROPY_BITS, STAR_ENTROPY_BITS, PLANET_ENTROPY_BITS,
12− SEED_ENTROPY_BITS,
13− GEN_STATES
1412 } from '../../walletgen/lib/constants'
1513
1614import JSZip from 'jszip'
1715import saveAs from 'file-saver'
1816
1917import {
20− signTransaction,
21− sendSignedTransaction,
2218 waitForTransactionConfirm,
2319 isTransactionConfirmed
2420} from './txn'
2521import { BRIDGE_ERROR } from './error'
26−import { attemptSeedDerivation, genKey } from './keys'
22+import { attemptSeedDerivation } from './keys'
2723import {
28− EthereumWallet,
2924 addressFromSecp256k1Public,
30− urbitWalletFromTicket,
3125 addHexPrefix,
3226 WALLET_NAMES
3327} from './wallet'
3428
35−const NEXT_STEP_NUM = 6;
3629const SEED_LENGTH_BYTES = SEED_ENTROPY_BITS / 8
3730
3831const INVITE_STAGES = {
@@ -173,7 +166,7 @@ async function downloadWallet(paper) {
173166}
174167
175168async function startTransactions(args) {
176− let { realPointM, web3M, contractsM, realTicket,
169+ let { realPointM, web3M, contractsM,
177170 inviteWalletM, realWalletM, setUrbitWallet, updateProgress } = args
178171
179172 if (Nothing.hasInstance(web3M)) {
@@ -191,10 +184,12 @@ async function startTransactions(args) {
191184 }
192185 const inviteWallet = inviteWalletM.value;
193186
194− // if (Nothing.hasInstance(realWalletM)) {
195− // throw BRIDGE_ERROR.MISSING_WALLET;
196− // }
197− // const realWallet = realWalletM.value;
187+ if (Nothing.hasInstance(realWalletM)) {
188+ throw BRIDGE_ERROR.MISSING_WALLET;
189+ }
190+ const realWallet = realWalletM.value;
191+
192+ // const realWallet = await urbitWalletFromTicket(args.realTicket, point);
198193
199194 if (Nothing.hasInstance(realPointM)) {
200195 throw BRIDGE_ERROR.MISSING_POINT;
@@ -204,8 +199,6 @@ async function startTransactions(args) {
204199 const inviteAddress = addressFromSecp256k1Public(inviteWallet.publicKey);
205200 console.log('working as', inviteAddress);
206201
207− const realWallet = await urbitWalletFromTicket(realTicket, point);
208−
209202 // transfer from invite wallet to new wallet
210203
211204 let transferTx = azimuth.ecliptic.transferPoint(contracts, point, realWallet.ownership.keys.address);
@@ -428,18 +421,6 @@ async function sendAndAwaitConfirm(web3, signedTxs) {
428421 }));
429422}
430423
431−function awaitForResult(desired, retryTime, func) {
432− return new Promise((resolve, reject) => {
433− const retry = async () => {
434− const result = await func();
435− console.log('result vs desired', result, desired);
436− if (result === desired) resolve();
437− else setTimeout(retry, retryTime);
438− };
439− retry();
440− });
441−}
442−
443424function askForFunding(address, amount, current, updateProgress) {
444425 updateProgress({
445426 type: "notify",
src/bridge/lib/txn.js−1
@@ -2,7 +2,6 @@ import * as ob from 'urbit-ob'
22import { Just } from 'folktale/maybe'
33import { Ok, Error } from 'folktale/result'
44import Tx from 'ethereumjs-tx'
5−import Web3 from 'web3'
65import { toWei, fromWei, toHex } from 'web3-utils'
76
87import { BRIDGE_ERROR } from '../lib/error'
src/bridge/views/InviteTicket.js+2−13
@@ -1,13 +1,10 @@
11import { Just, Nothing } from 'folktale/maybe'
22import React from 'react'
3−import { InnerLabel, ValidatedSigil, PointInput, Warning, Input, TicketInput,
4− VerifyTicketInput, Button, Row, Col, H1, P, Passport } from '../components/Base'
5−import * as kg from '../../../node_modules/urbit-key-generation/dist/index'
6−import * as ob from 'urbit-ob'
3+import { InnerLabel, Warning, TicketInput,
4+ VerifyTicketInput, Button, Row, Col, Passport } from '../components/Base'
75import * as azimuth from 'azimuth-js'
86
97import { randomPatq } from '../lib/lib'
10−import { simpleValidatorWrapper } from '../lib/validators'
118import { ROUTE_NAMES } from '../lib/router'
129import { DEFAULT_HD_PATH, urbitWalletFromTicket,
1310 walletFromMnemonic, addressFromSecp256k1Public } from '../lib/wallet'
@@ -252,11 +249,6 @@ class InviteTicket extends React.Component {
252249 }
253250 : stage === INVITE_STAGES.INVITE_VERIFY
254251 ? () => {
255− const realTicket = realWallet.matchWith({
256− Just: w => w.value.ticket,
257− Nothing: null
258− })
259−
260252 this.setState({
261253 stage: INVITE_STAGES.INVITE_TRANSACTIONS,
262254 walletStates: this.state.walletStates.concat(WALLET_STATES.TRANSACTIONS)
@@ -329,9 +321,6 @@ class InviteTicket extends React.Component {
329321 }
330322
331323 render() {
332− const { wallet } = this.props
333− const { inviteTicket } = this.state
334−
335324 let stageDisplay = this.getStageDisplay()
336325 let stageText = this.getStageText()
337326 let ticketElem = this.getTicketElement()
src/bridge/views/InvitesManage.js+2−15
@@ -1,24 +1,11 @@
11import { Just, Nothing } from 'folktale/maybe'
22import React from 'react'
3−import { pour } from 'sigil-js'
43import * as ob from 'urbit-ob'
54import * as azimuth from 'azimuth-js'
65
7−import {
8− EthereumWallet,
9− addressFromSecp256k1Public,
10− urbitWalletFromTicket,
11− addHexPrefix,
12− WALLET_NAMES
13−} from '../lib/wallet'
14−
15−import ReactSVGComponents from '../components/ReactSVGComponents'
16−import KeysAndMetadata from './Point/KeysAndMetadata'
17−import Actions from './Point/Actions'
186import { BRIDGE_ERROR } from '../lib/error'
19−import { Row, Col, Warning, Button, H1, H3, Input,
20− PointInput, InnerLabel, ValidatedSigil
21−} from '../components/Base'
7+import { Row, Col, Warning, Input,
8+ PointInput, InnerLabel, ValidatedSigil } from '../components/Base'
229import StatelessTransaction from '../components/StatelessTransaction'
2310
2411
src/bridge/views/InvitesSend.js+2−27
@@ -1,40 +1,16 @@
11import { Just, Nothing } from 'folktale/maybe'
22import React from 'react'
3−import { pour } from 'sigil-js'
43import * as ob from 'urbit-ob'
54import * as azimuth from 'azimuth-js'
65
7−import {
8− EthereumWallet,
9− addressFromSecp256k1Public,
10− urbitWalletFromTicket,
11− addHexPrefix,
12− WALLET_NAMES
13−} from '../lib/wallet'
14−
15−import ReactSVGComponents from '../components/ReactSVGComponents'
16−import KeysAndMetadata from './Point/KeysAndMetadata'
17−import Actions from './Point/Actions'
186import { BRIDGE_ERROR } from '../lib/error'
197import { sendMail } from '../lib/inviteMail'
20−import { Row, Col, Warning, Button, H1, H3,
21− Input, InnerLabel
22−} from '../components/Base'
8+import { Row, Col, Input, InnerLabel } from '../components/Base'
239import StatelessTransaction from '../components/StatelessTransaction'
2410
2511// for wallet generation
2612import * as wg from '../../walletgen/lib/lib'
2713
28−// for transaction generation and signing
29−import {
30− signTransaction,
31− sendSignedTransaction,
32− waitForTransactionConfirm,
33− isTransactionConfirmed
34−} from '../lib/txn'
35−import * as tank from '../lib/tank'
36−import Tx from 'ethereumjs-tx'
37−
3814class InvitesSend extends React.Component {
3915
4016 constructor(props) {
@@ -165,14 +141,13 @@ class InvitesSend extends React.Component {
165141 }
166142
167143 render() {
168−
169144 const inviteStatus = this.state.invitesAvailable.matchWith({
170145 Nothing: () => 'Loading...',
171146 Just: (invites) => {
172147 let res = `${invites.value} invites available`;
173148 return res + this.state.fromPool.matchWith({
174149 Nothing: () => '',
175− Just: (pool) => (pool.value == this.point)
150+ Just: (pool) => (pool.value === this.point)
176151 ? ''
177152 : ` (from ${ob.patp(pool.value)})`
178153 });
src/bridge/views/Shards.js+1−1
@@ -14,7 +14,7 @@ import * as kg from '../../../node_modules/urbit-key-generation/dist/index'
1414import * as ob from 'urbit-ob'
1515
1616import { ROUTE_NAMES } from '../lib/router'
17−import { DEFAULT_HD_PATH, urbitWalletFromTicket } from '../lib/wallet'
17+import { urbitWalletFromTicket } from '../lib/wallet'
1818
1919const placeholder = (len) => {
2020 let bytes = window.crypto.getRandomValues(new Uint8Array(len))
src/bridge/views/Ticket.js+1−3
@@ -10,12 +10,10 @@ import {
1010 InputCaption
1111 } from '../components/Base'
1212import { Row, Col, H1, P } from '../components/Base'
13−import * as kg from '../../../node_modules/urbit-key-generation/dist/index'
14−import * as ob from 'urbit-ob'
1513
1614import { randomPatq } from '../lib/lib'
1715import { ROUTE_NAMES } from '../lib/router'
18−import { DEFAULT_HD_PATH, urbitWalletFromTicket } from '../lib/wallet'
16+import { urbitWalletFromTicket } from '../lib/wallet'
1917
2018class Ticket extends React.Component {
2119
src/walletgen/lib/lib.js+1−3
@@ -4,10 +4,8 @@ import * as kg from '../../../node_modules/urbit-key-generation/dist/index'
44import * as more from 'more-entropy'
55import lodash from 'lodash'
66import {
7− MAX_GALAXY, MIN_STAR, MAX_STAR, MIN_PLANET,
7+ MIN_STAR, MIN_PLANET, SEED_ENTROPY_BITS,
88 GALAXY_ENTROPY_BITS, STAR_ENTROPY_BITS, PLANET_ENTROPY_BITS,
9− SEED_ENTROPY_BITS,
10− GEN_STATES
119} from './constants'
1210
1311const SEED_LENGTH_BYTES = SEED_ENTROPY_BITS / 8
src/walletgen/views/Generate.js+1−9
@@ -1,6 +1,4 @@
11import React from 'react'
2−import * as more from 'more-entropy'
3−import lodash from 'lodash'
42import * as sigil from 'sigil-js'
53import ob from 'urbit-ob'
64import classnames from 'classnames'
@@ -11,16 +9,10 @@ import Button from '../components/Button'
119import ReactSVGComponents from '../components/ReactSVGComponents'
1210import PaperCollateralRenderer from 'PaperCollateralRenderer'
1311
14−import { MAX_GALAXY, MIN_STAR, MAX_STAR, MIN_PLANET,
15− GALAXY_ENTROPY_BITS, STAR_ENTROPY_BITS, PLANET_ENTROPY_BITS,
16− SEED_ENTROPY_BITS,
17− GEN_STATES
18− } from '../lib/constants'
12+import { MAX_GALAXY, MIN_STAR, MAX_STAR, GEN_STATES } from '../lib/constants'
1913
20−const SEED_LENGTH_BYTES = SEED_ENTROPY_BITS / 8
2114const NEXT_STEP_NUM = 6;
2215
23−
2416const shipInfo = ship => {
2517 const name = ob.patp(ship)
2618 const sig = sigil.pour({