on master help sign in
Clean up compiler warnings
commit8286dd7d2ff0e50a17f9f21fa4ab3445bc8d3ef3 authorFang <git@fang.io> dateWed 5 Jun 2019, 20:09 (7 years ago) parent6fd0233
8 files changed+22−37
src/bridge/components/StatelessTransaction.js+1−2 src/bridge/lib/invite.js−8 src/bridge/lib/txn.js−1 src/bridge/views/InvitesManage.js+4−2 src/bridge/views/InvitesSend.js+9−14 src/bridge/views/IssueChild.js+6−8 src/bridge/views/Point.js+1−1 src/bridge/views/Point/Actions.js+1−1
src/bridge/components/StatelessTransaction.js+1−2
@@ -15,7 +15,6 @@ import * as tank from '../lib/tank'
1515
1616import {
1717 sendSignedTransaction,
18− waitForTransactionConfirm,
1918 fromWei,
2019 toWei,
2120 hexify,
@@ -195,7 +194,7 @@ class StatelessTransaction extends React.Component {
195194 try {
196195 this.setState({ txStatus: SUBMISSION_STATES.PREPARING });
197196 const res = await props.beforeSend(stx);
198− if (res === false) throw 'beforeSend disallowed sending';
197+ if (res === false) throw new Error('beforeSend disallowed sending');
199198 } catch (e) {
200199 console.log('beforeSend error', e);
201200 this.setState({
src/bridge/lib/invite.js−8
@@ -1,16 +1,10 @@
1−import lodash from 'lodash'
21import { Just, Nothing } from 'folktale/maybe'
32import Tx from 'ethereumjs-tx'
43
54import * as azimuth from 'azimuth-js'
6−import * as more from 'more-entropy'
7−import * as ob from 'urbit-ob'
85import * as kg from '../../../node_modules/urbit-key-generation/dist/index'
96import * as wg from '../../walletgen/lib/lib.js'
107import * as tank from './tank'
11−import { MIN_STAR, MIN_PLANET, SEED_ENTROPY_BITS,
12− GALAXY_ENTROPY_BITS, STAR_ENTROPY_BITS, PLANET_ENTROPY_BITS,
13− } from '../../walletgen/lib/constants'
148
159import JSZip from 'jszip'
1610import saveAs from 'file-saver'
@@ -27,8 +21,6 @@ import {
2721 WALLET_NAMES
2822} from './wallet'
2923
30−const SEED_LENGTH_BYTES = SEED_ENTROPY_BITS / 8
31−
3224const INVITE_STAGES = {
3325 INVITE_LOGIN: "invite login",
3426 INVITE_WALLET: "invite wallet",
src/bridge/lib/txn.js−1
@@ -1,6 +1,5 @@
11import * as ob from 'urbit-ob'
22import { Just } from 'folktale/maybe'
3−import { Ok, Error } from 'folktale/result'
43import Tx from 'ethereumjs-tx'
54import { toWei, fromWei, toHex } from 'web3-utils'
65
src/bridge/views/InvitesManage.js+4−2
@@ -96,11 +96,13 @@ class InvitesManage extends React.Component {
9696 }
9797
9898 updatePoolSize(who, size) {
99− this.state.cachedPoolSizes[who] = size;
99+ const cache = this.state.cachedPoolSizes;
100+ cache[who] = size;
101+ this.setState({ cachedPoolSizes: cache });
100102 const target = this.state.targetPlanet;
101103 const match = Just.hasInstance(target) ? (who === target.value) : false;
102104 if (match) {
103− this.setState({currentPoolSize:Just(size)});
105+ this.setState({ currentPoolSize:Just(size) });
104106 }
105107 }
106108
src/bridge/views/InvitesSend.js+9−14
@@ -1,14 +1,10 @@
11import { Just, Nothing } from 'folktale/maybe'
22import React from 'react'
3−import * as ob from 'urbit-ob'
43import * as azimuth from 'azimuth-js'
54
65import { BRIDGE_ERROR } from '../lib/error'
76import { hasReceived, sendMail } from '../lib/inviteMail'
8−import { Row, Col, Warning, Button, H1, H3,
9− Input, InnerLabel
10−} from '../components/Base'
11−import StatelessTransaction from '../components/StatelessTransaction'
7+import { Row, Col, Button, Input } from '../components/Base'
128import { addressFromSecp256k1Public } from '../lib/wallet'
139
1410// for wallet generation
@@ -19,14 +15,13 @@ import {
1915 signTransaction,
2016 sendSignedTransaction,
2117 waitForTransactionConfirm,
22− isTransactionConfirmed,
2318 hexify
2419} from '../lib/txn'
2520import * as tank from '../lib/tank'
2621
27−const GAS_PRICE = 20000000000; // we pay the premium for faster ux
22+const GAS_PRICE_GWEI = 20; // we pay the premium for faster ux
2823const GAS_LIMIT = 500000; //TODO fine-tune
29−const INVITE_COST = (GAS_PRICE * GAS_LIMIT);
24+const INVITE_COST = (GAS_PRICE_GWEI * 1000000000 * GAS_LIMIT);
3025
3126const STATUS = {
3227 INPUT: 'Generate invites',
@@ -162,13 +157,13 @@ class InvitesSend extends React.Component {
162157 const signedTx = await signTransaction({
163158 ...this.props,
164159 txn: Just(inviteTx),
165− gasPrice: '20', //TODO
166− gasLimit: '600000', //TODO
160+ gasPrice: GAS_PRICE_GWEI.toString(),
161+ gasLimit: GAS_LIMIT.toString(),
167162 nonce: nonce + i,
168163 chainId: chainId,
169164 setStx: () => {}
170165 });
171− const rawTx = '0x'+signedTx.serialize().toString('hex');
166+ const rawTx = hexify(signedTx.serialize());
172167
173168 invites.push({recipient, ticket: wallet.ticket, signedTx, rawTx });
174169 this.setEmailStatus(i, EMAIL_STATUS.DONE);
@@ -234,8 +229,9 @@ class InvitesSend extends React.Component {
234229 }
235230
236231 setEmailStatus(i, status) {
237− this.state.targets[i].status = Just(status);
238− this.setState({ targets: this.state.targets });
232+ const targets = this.state.targets;
233+ targets[i].status = Just(status);
234+ this.setState({ targets });
239235 }
240236
241237 askForFunding(address, minBalance, balance) {
@@ -282,7 +278,6 @@ class InvitesSend extends React.Component {
282278
283279 addTarget() {
284280 let targets = this.state.targets;
285− let i = targets.length;
286281 targets.push({ email: '', hasReceived: Nothing(), status: Nothing() });
287282 this.setState({ targets });
288283 }
src/bridge/views/IssueChild.js+6−8
@@ -3,9 +3,11 @@ import React from 'react'
33import { azimuth, ecliptic } from 'azimuth-js'
44import * as ob from 'urbit-ob'
55
6−import { Row, Col, H1, P, Anchor } from '../components/Base'
7−import { Button, ShowBlockie, ValidatedSigil } from '../components/Base'
8−import { PointInput, AddressInput, InnerLabel } from '../components/Base'
6+import {
7+ Row, Col, H1, P, Anchor,
8+ ShowBlockie, ValidatedSigil,
9+ PointInput, AddressInput, InnerLabel
10+} from '../components/Base'
911
1012import StatelessTransaction from '../components/StatelessTransaction'
1113
@@ -14,11 +16,7 @@ import { BRIDGE_ERROR } from '../lib/error'
1416import { getSpawnCandidate } from '../lib/child'
1517import { canDecodePatp } from '../lib/txn'
1618
17−import {
18− ETH_ZERO_ADDR,
19− isValidAddress,
20− eqAddr
21−} from '../lib/wallet'
19+import { isValidAddress } from '../lib/wallet'
2220
2321const setFind = (set, pred) => {
2422 for (const e of set) {
src/bridge/views/Point.js+1−1
@@ -73,7 +73,7 @@ class Point extends React.Component {
7373 render() {
7474
7575 const {
76− web3, popRoute, pushRoute, wallet, contracts,
76+ web3, popRoute, pushRoute, wallet,
7777 setPointCursor, pointCursor, pointCache
7878 } = this.props;
7979
src/bridge/views/Point/Actions.js+1−1
@@ -18,7 +18,7 @@ const isStar = point =>
1818
1919const Actions = (props) => {
2020 const {
21− pushRoute, online, wallet, delegatedSending,
21+ pushRoute, online, wallet,
2222 point, pointDetails, invites
2323 } = props
2424