@@ -1,13 +1,13 @@
1−import { Just, Nothing } from "folktale/maybe";
2−import React from "react";
3−import * as azimuth from "azimuth-js";
4−import * as need from "../lib/need";
1+import { Just, Nothing } from 'folktale/maybe';
2+import React from 'react';
3+import * as azimuth from 'azimuth-js';
4+import * as need from '../lib/need';
55
6−import { hasReceived, sendMail } from "../lib/inviteMail";
7−import { Row, Col, Button, Input, H3, Warning } from "../components/Base";
6+import { hasReceived, sendMail } from '../lib/inviteMail';
7+import { Row, Col, Button, Input, H3, Warning } from '../components/Base';
88
99// for wallet generation
10−import * as wg from "../../walletgen/lib/lib";
10+import * as wg from '../../walletgen/lib/lib';
1111
1212// for transaction generation and signing
1313import {
@@ -17,27 +17,27 @@ import {
1717 hexify,
1818 fromWei,
1919 toWei,
20−} from "../lib/txn";
21−import * as tank from "../lib/tank";
20+} from '../lib/txn';
21+import * as tank from '../lib/tank';
2222
2323const GAS_PRICE_GWEI = 20; // we pay the premium for faster ux
2424const GAS_LIMIT = 350000;
25−const INVITE_COST = toWei((GAS_PRICE_GWEI * GAS_LIMIT).toString(), "gwei");
25+const INVITE_COST = toWei((GAS_PRICE_GWEI * GAS_LIMIT).toString(), 'gwei');
2626
2727const STATUS = {
28− INPUT: "Generate invites",
29− GENERATING: "Generating invites",
30− CAN_SEND: "Send invites",
31− FUNDING: "Funding invites",
32− SENDING: "Sending invites",
33− DONE: "Done",
34− FAIL: "Some failed",
28+ INPUT: 'Generate invites',
29+ GENERATING: 'Generating invites',
30+ CAN_SEND: 'Send invites',
31+ FUNDING: 'Funding invites',
32+ SENDING: 'Sending invites',
33+ DONE: 'Done',
34+ FAIL: 'Some failed',
3535};
3636
3737const EMAIL_STATUS = {
38− BUSY: "⋯",
39− DONE: "✔",
40− FAIL: "×",
38+ BUSY: '⋯',
39+ DONE: '✔',
40+ FAIL: '×',
4141};
4242
4343class InvitesSend extends React.Component {
@@ -47,7 +47,7 @@ class InvitesSend extends React.Component {
4747 this.state = {
4848 invitesAvailable: Nothing(),
4949 invited: Nothing(),
50− targets: [{ email: "", hasReceived: Nothing(), status: Nothing() }],
50+ targets: [{ email: '', hasReceived: Nothing(), status: Nothing() }],
5151 status: STATUS.INPUT,
5252 errors: Nothing(),
5353 //
@@ -89,7 +89,7 @@ class InvitesSend extends React.Component {
8989 async findInvited() {
9090 let invited = await azimuth.delegatedSending.getInvited(
9191 this.contracts,
92− this.point,
92+ this.point
9393 );
9494 invited = invited.map(async point => {
9595 const active = await azimuth.azimuth.isActive(this.contracts, point);
@@ -116,13 +116,13 @@ class InvitesSend extends React.Component {
116116 const planets = await azimuth.delegatedSending.getPlanetsToSend(
117117 this.contracts,
118118 this.point,
119− targets.length,
119+ targets.length
120120 );
121121
122122 // account for the race condition where invites got used up while we were
123123 // composing our target list
124124 if (planets.length < targets.length) {
125− this.addError("Can currently only send " + planets.length + " invites!");
125+ this.addError('Can currently only send ' + planets.length + ' invites!');
126126 return;
127127 }
128128
@@ -132,7 +132,7 @@ class InvitesSend extends React.Component {
132132 // create invite wallets and transactions
133133 let invites = []; // { email, ticket, signedTx, rawTx }
134134 for (let i = 0; i < targets.length; i++) {
135− console.log("generating email", i, targets[i].email);
135+ console.log('generating email', i, targets[i].email);
136136 this.setEmailStatus(i, EMAIL_STATUS.BUSY);
137137
138138 const email = targets[i].email;
@@ -142,7 +142,7 @@ class InvitesSend extends React.Component {
142142 this.contracts,
143143 this.point,
144144 planets[i],
145− wallet.owner,
145+ wallet.owner
146146 );
147147 const signedTx = await signTransaction({
148148 ...this.props,
@@ -183,7 +183,7 @@ class InvitesSend extends React.Component {
183183 this.askForFunding,
184184 () => {
185185 this.setState({ fundingMessage: Nothing() });
186− },
186+ }
187187 );
188188
189189 this.setState({ status: STATUS.SENDING });
@@ -200,11 +200,11 @@ class InvitesSend extends React.Component {
200200 web3,
201201 Just(invite.signedTx),
202202 tankWasUsed,
203− () => {},
203+ () => {}
204204 );
205205 } catch (err) {
206− console.error("invite tx sending failed", err);
207− this.addError("Invite transaction not sent for " + invite.email);
206+ console.error('invite tx sending failed', err);
207+ this.addError('Invite transaction not sent for ' + invite.email);
208208 this.setEmailStatus(i, EMAIL_STATUS.FAIL);
209209 continue;
210210 }
@@ -216,19 +216,19 @@ class InvitesSend extends React.Component {
216216 const mailSuccess = await sendMail(
217217 invite.email,
218218 invite.ticket,
219− invite.rawTx,
219+ invite.rawTx
220220 );
221221 if (!mailSuccess) throw new Error();
222222 this.setEmailStatus(i, EMAIL_STATUS.DONE);
223223 } catch (e) {
224− console.log("email send failed");
224+ console.log('email send failed');
225225 //NOTE this assumes that the transaction succeeds, but we don't know
226226 // that for a fact yet...
227227 this.addError(
228− "Invite email failed to send for " +
228+ 'Invite email failed to send for ' +
229229 invite.email +
230− ". Please give them this ticket: " +
231− invite.ticket,
230+ '. Please give them this ticket: ' +
231+ invite.ticket
232232 );
233233 this.setEmailStatus(i, EMAIL_STATUS.FAIL);
234234 continue;
@@ -240,12 +240,12 @@ class InvitesSend extends React.Component {
240240 if (success) {
241241 this.setEmailStatus(i, EMAIL_STATUS.DONE);
242242 } else {
243− console.log("invite tx rejected");
244− this.addError("Invite transaction failed for " + invite.email);
243+ console.log('invite tx rejected');
244+ this.addError('Invite transaction failed for ' + invite.email);
245245 this.setEmailStatus(i, EMAIL_STATUS.FAIL);
246246 }
247247 return success;
248− }),
248+ })
249249 );
250250 }
251251
@@ -279,9 +279,9 @@ class InvitesSend extends React.Component {
279279 fundingMessage: Just(
280280 `Please make sure ${address} has at least ${fromWei(minBalance)} ETH,` +
281281 `we'll continue once that's true. Current balance: ${fromWei(
282− balance,
282+ balance
283283 )}.` +
284− `Waiting...`,
284+ `Waiting...`
285285 ),
286286 });
287287 }
@@ -328,7 +328,7 @@ class InvitesSend extends React.Component {
328328
329329 addTarget() {
330330 let targets = this.state.targets;
331− targets.push({ email: "", hasReceived: Nothing(), status: Nothing() });
331+ targets.push({ email: '', hasReceived: Nothing(), status: Nothing() });
332332 this.setState({ targets });
333333 }
334334
@@ -343,24 +343,24 @@ class InvitesSend extends React.Component {
343343 this.state.status === STATUS.DONE ? this.state.targets.length : null;
344344
345345 const invitesAvailable = this.state.invitesAvailable.matchWith({
346− Nothing: () => "Loading...",
346+ Nothing: () => 'Loading...',
347347 Just: invites => {
348− const dia = dif ? `(-${dif})` : "";
348+ const dia = dif ? `(-${dif})` : '';
349349 return `You currently have ${invites.value}${dia} invitations left.`;
350350 },
351351 });
352352
353353 const invitesSent = this.state.invited.matchWith({
354− Nothing: () => <>{"Loading..."}</>,
354+ Nothing: () => <>{'Loading...'}</>,
355355 Just: invited => {
356− const dit = dif ? `(+${dif})` : "";
356+ const dit = dif ? `(+${dif})` : '';
357357 return (
358358 <>
359− {"Out of the "}
359+ {'Out of the '}
360360 {invited.value.total + dit}
361− {" invites you sent, "}
361+ {' invites you sent, '}
362362 {invited.value.accepted}
363− {" have been accepted."}
363+ {' have been accepted.'}
364364 </>
365365 );
366366 },
@@ -369,9 +369,9 @@ class InvitesSend extends React.Component {
369369 const error = this.state.errors.matchWith({
370370 Nothing: () => null,
371371 Just: errors => (
372− <Warning className={"mt-8"}>
372+ <Warning className={'mt-8'}>
373373 <H3 style={{ marginTop: 0, paddingTop: 0 }}>
374− {"Something went wrong!"}
374+ {'Something went wrong!'}
375375 </H3>
376376 {errors.value.map(err => (
377377 <p>{err}</p>
@@ -382,31 +382,30 @@ class InvitesSend extends React.Component {
382382
383383 const fundingMessage = this.state.fundingMessage.matchWith({
384384 Nothing: () => null,
385− Just: msg => <Warning className={"mt-8"}>{msg.value}</Warning>,
385+ Just: msg => <Warning className={'mt-8'}>{msg.value}</Warning>,
386386 });
387387
388388 let inputs;
389389 if (this.state.status === STATUS.DONE) {
390390 //TODO proper clickable router thing
391− inputs = "<- Back to Home";
391+ inputs = '<- Back to Home';
392392 } else {
393393 const inputDisabled = this.state.status !== STATUS.INPUT;
394394
395395 const lessButton = (
396396 <Button
397− prop-size={"s narrow"}
398− className={"mt-8"}
397+ prop-size={'s narrow'}
398+ className={'mt-8'}
399399 disabled={inputDisabled || this.state.targets.length === 1}
400− onClick={this.removeTarget}
401− >
402− {"-"}
400+ onClick={this.removeTarget}>
401+ {'-'}
403402 </Button>
404403 );
405404
406405 const moreButton = (
407406 <Button
408− prop-size={"s narrow"}
409− className={"mt-8"}
407+ prop-size={'s narrow'}
408+ className={'mt-8'}
410409 disabled={
411410 inputDisabled ||
412411 this.state.invitesAvailable.matchWith({
@@ -414,9 +413,8 @@ class InvitesSend extends React.Component {
414413 Just: inv => inv.value <= this.state.targets.length,
415414 })
416415 }
417− onClick={this.addTarget}
418− >
419− {"+"}
416+ onClick={this.addTarget}>
417+ {'+'}
420418 </Button>
421419 );
422420
@@ -424,7 +422,7 @@ class InvitesSend extends React.Component {
424422 for (let i = 0; i < this.state.targets.length; i++) {
425423 const target = this.state.targets[i];
426424 let progress = target.status.matchWith({
427− Nothing: () => "",
425+ Nothing: () => '',
428426 Just: status => status.value,
429427 });
430428 targetInputs.push(
@@ -434,23 +432,23 @@ class InvitesSend extends React.Component {
434432 onChange={value => {
435433 this.handleEmailInput(i, value);
436434 }}
437− placeholder={"Email address"}
435+ placeholder={'Email address'}
438436 disabled={inputDisabled}
439437 />
440438 {target.hasReceived.matchWith({
441439 Nothing: () => null,
442440 Just: has =>
443− has.value ? <span>{"×"}</span> : <span>{"°"}</span>,
441+ has.value ? <span>{'×'}</span> : <span>{'°'}</span>,
444442 })}
445443 {progress}
446− </>,
444+ </>
447445 );
448446 }
449447
450448 const submitButton = (
451449 <Button
452− prop-size={"xl wide"}
453− className={"mt-8"}
450+ prop-size={'xl wide'}
451+ className={'mt-8'}
454452 disabled={
455453 (inputDisabled && this.state.status !== STATUS.CAN_SEND) ||
456454 !this.canSend()
@@ -458,8 +456,7 @@ class InvitesSend extends React.Component {
458456 onClick={() => {
459457 if (this.state.status === STATUS.INPUT) this.generateInvites();
460458 if (this.state.status === STATUS.CAN_SEND) this.sendInvites();
461− }}
462− >
459+ }}>
463460 {this.state.status}
464461 </Button>
465462 );
@@ -477,9 +474,9 @@ class InvitesSend extends React.Component {
477474 return (
478475 <Row>
479476 <Col>
480− <p>{"send invites here, for planets"}</p>
477+ <p>{'send invites here, for planets'}</p>
481478
482− <p>{"send invites here, for planets"}</p>
479+ <p>{'send invites here, for planets'}</p>
483480
484481 <p>{invitesAvailable}</p>
485482