@@ -1,13 +1,13 @@
1−import { Just, Nothing } from "folktale/maybe";
1+import { Just, Nothing } from 'folktale/maybe';
2−import React from "react";
2+import React from 'react';
3−import * as azimuth from "azimuth-js";
3+import * as azimuth from 'azimuth-js';
4−import * as need from "../lib/need";
4+import * as need from '../lib/need';
6−import { hasReceived, sendMail } from "../lib/inviteMail";
6+import { hasReceived, sendMail } from '../lib/inviteMail';
7−import { Row, Col, Button, Input, H3, Warning } from "../components/Base";
7+import { Row, Col, Button, Input, H3, Warning } from '../components/Base';
9// for wallet generation
9// for wallet generation
10−import * as wg from "../../walletgen/lib/lib";
10+import * as wg from '../../walletgen/lib/lib';
12// for transaction generation and signing
12// for transaction generation and signing
@@ -17,27 +17,27 @@ import {
20−} from "../lib/txn";
20+} from '../lib/txn';
21−import * as tank from "../lib/tank";
21+import * as tank from '../lib/tank';
23const GAS_PRICE_GWEI = 20; // we pay the premium for faster ux
23const GAS_PRICE_GWEI = 20; // we pay the premium for faster ux
24const GAS_LIMIT = 350000;
24const 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');
27const STATUS = {
27const STATUS = {
28− INPUT: "Generate invites",
28+ INPUT: 'Generate invites',
29− GENERATING: "Generating invites",
29+ GENERATING: 'Generating invites',
30− CAN_SEND: "Send invites",
30+ CAN_SEND: 'Send invites',
31− FUNDING: "Funding invites",
31+ FUNDING: 'Funding invites',
32− SENDING: "Sending invites",
32+ SENDING: 'Sending invites',
33− DONE: "Done",
33+ DONE: 'Done',
34− FAIL: "Some failed",
34+ FAIL: 'Some failed',
37const EMAIL_STATUS = {
37const EMAIL_STATUS = {
38− BUSY: "⋯",
38+ BUSY: '⋯',
39− DONE: "✔",
39+ DONE: '✔',
40− FAIL: "×",
40+ FAIL: '×',
43class InvitesSend extends React.Component {
43class InvitesSend extends React.Component {
@@ -47,7 +47,7 @@ class InvitesSend extends React.Component {
47 this.state = {
47 this.state = {
48 invitesAvailable: Nothing(),
48 invitesAvailable: Nothing(),
49 invited: Nothing(),
49 invited: Nothing(),
50− targets: [{ email: "", hasReceived: Nothing(), status: Nothing() }],
50+ targets: [{ email: '', hasReceived: Nothing(), status: Nothing() }],
51 status: STATUS.INPUT,
51 status: STATUS.INPUT,
52 errors: Nothing(),
52 errors: Nothing(),
@@ -89,7 +89,7 @@ class InvitesSend extends React.Component {
89 async findInvited() {
89 async findInvited() {
90 let invited = await azimuth.delegatedSending.getInvited(
90 let invited = await azimuth.delegatedSending.getInvited(
91 this.contracts,
91 this.contracts,
92− this.point,
92+ this.point
94 invited = invited.map(async point => {
94 invited = invited.map(async point => {
95 const active = await azimuth.azimuth.isActive(this.contracts, point);
95 const active = await azimuth.azimuth.isActive(this.contracts, point);
@@ -116,13 +116,13 @@ class InvitesSend extends React.Component {
116 const planets = await azimuth.delegatedSending.getPlanetsToSend(
116 const planets = await azimuth.delegatedSending.getPlanetsToSend(
117 this.contracts,
117 this.contracts,
118 this.point,
118 this.point,
119− targets.length,
119+ targets.length
122 // account for the race condition where invites got used up while we were
122 // account for the race condition where invites got used up while we were
123 // composing our target list
123 // composing our target list
124 if (planets.length < targets.length) {
124 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!');
@@ -132,7 +132,7 @@ class InvitesSend extends React.Component {
132 // create invite wallets and transactions
132 // create invite wallets and transactions
133 let invites = []; // { email, ticket, signedTx, rawTx }
133 let invites = []; // { email, ticket, signedTx, rawTx }
134 for (let i = 0; i < targets.length; i++) {
134 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);
136 this.setEmailStatus(i, EMAIL_STATUS.BUSY);
136 this.setEmailStatus(i, EMAIL_STATUS.BUSY);
138 const email = targets[i].email;
138 const email = targets[i].email;
@@ -142,7 +142,7 @@ class InvitesSend extends React.Component {
142 this.contracts,
142 this.contracts,
143 this.point,
143 this.point,
144 planets[i],
144 planets[i],
145− wallet.owner,
145+ wallet.owner
147 const signedTx = await signTransaction({
147 const signedTx = await signTransaction({
148 ...this.props,
148 ...this.props,
@@ -183,7 +183,7 @@ class InvitesSend extends React.Component {
183 this.askForFunding,
183 this.askForFunding,
185 this.setState({ fundingMessage: Nothing() });
185 this.setState({ fundingMessage: Nothing() });
189 this.setState({ status: STATUS.SENDING });
189 this.setState({ status: STATUS.SENDING });
@@ -200,11 +200,11 @@ class InvitesSend extends React.Component {
201 Just(invite.signedTx),
201 Just(invite.signedTx),
202 tankWasUsed,
202 tankWasUsed,
203− () => {},
203+ () => {}
205 } catch (err) {
205 } catch (err) {
206− console.error("invite tx sending failed", err);
206+ console.error('invite tx sending failed', err);
207− this.addError("Invite transaction not sent for " + invite.email);
207+ this.addError('Invite transaction not sent for ' + invite.email);
208 this.setEmailStatus(i, EMAIL_STATUS.FAIL);
208 this.setEmailStatus(i, EMAIL_STATUS.FAIL);
209 continue;
209 continue;
@@ -216,19 +216,19 @@ class InvitesSend extends React.Component {
216 const mailSuccess = await sendMail(
216 const mailSuccess = await sendMail(
217 invite.email,
217 invite.email,
218 invite.ticket,
218 invite.ticket,
219− invite.rawTx,
219+ invite.rawTx
221 if (!mailSuccess) throw new Error();
221 if (!mailSuccess) throw new Error();
222 this.setEmailStatus(i, EMAIL_STATUS.DONE);
222 this.setEmailStatus(i, EMAIL_STATUS.DONE);
223 } catch (e) {
223 } catch (e) {
224− console.log("email send failed");
224+ console.log('email send failed');
225 //NOTE this assumes that the transaction succeeds, but we don't know
225 //NOTE this assumes that the transaction succeeds, but we don't know
226 // that for a fact yet...
226 // that for a fact yet...
227 this.addError(
227 this.addError(
228− "Invite email failed to send for " +
228+ 'Invite email failed to send for ' +
229 invite.email +
229 invite.email +
230− ". Please give them this ticket: " +
230+ '. Please give them this ticket: ' +
231− invite.ticket,
231+ invite.ticket
233 this.setEmailStatus(i, EMAIL_STATUS.FAIL);
233 this.setEmailStatus(i, EMAIL_STATUS.FAIL);
234 continue;
234 continue;
@@ -240,12 +240,12 @@ class InvitesSend extends React.Component {
240 if (success) {
240 if (success) {
241 this.setEmailStatus(i, EMAIL_STATUS.DONE);
241 this.setEmailStatus(i, EMAIL_STATUS.DONE);
243− console.log("invite tx rejected");
243+ console.log('invite tx rejected');
244− this.addError("Invite transaction failed for " + invite.email);
244+ this.addError('Invite transaction failed for ' + invite.email);
245 this.setEmailStatus(i, EMAIL_STATUS.FAIL);
245 this.setEmailStatus(i, EMAIL_STATUS.FAIL);
247 return success;
247 return success;
@@ -279,9 +279,9 @@ class InvitesSend extends React.Component {
279 fundingMessage: Just(
279 fundingMessage: Just(
280 `Please make sure ${address} has at least ${fromWei(minBalance)} ETH,` +
280 `Please make sure ${address} has at least ${fromWei(minBalance)} ETH,` +
281 `we'll continue once that's true. Current balance: ${fromWei(
281 `we'll continue once that's true. Current balance: ${fromWei(
282− balance,
282+ balance
284− `Waiting...`,
284+ `Waiting...`
@@ -328,7 +328,7 @@ class InvitesSend extends React.Component {
329 addTarget() {
329 addTarget() {
330 let targets = this.state.targets;
330 let targets = this.state.targets;
331− targets.push({ email: "", hasReceived: Nothing(), status: Nothing() });
331+ targets.push({ email: '', hasReceived: Nothing(), status: Nothing() });
332 this.setState({ targets });
332 this.setState({ targets });
@@ -343,24 +343,24 @@ class InvitesSend extends React.Component {
343 this.state.status === STATUS.DONE ? this.state.targets.length : null;
343 this.state.status === STATUS.DONE ? this.state.targets.length : null;
345 const invitesAvailable = this.state.invitesAvailable.matchWith({
345 const invitesAvailable = this.state.invitesAvailable.matchWith({
346− Nothing: () => "Loading...",
346+ Nothing: () => 'Loading...',
347 Just: invites => {
347 Just: invites => {
348− const dia = dif ? `(-${dif})` : "";
348+ const dia = dif ? `(-${dif})` : '';
349 return `You currently have ${invites.value}${dia} invitations left.`;
349 return `You currently have ${invites.value}${dia} invitations left.`;
353 const invitesSent = this.state.invited.matchWith({
353 const invitesSent = this.state.invited.matchWith({
354− Nothing: () => <>{"Loading..."}</>,
354+ Nothing: () => <>{'Loading...'}</>,
355 Just: invited => {
355 Just: invited => {
356− const dit = dif ? `(+${dif})` : "";
356+ const dit = dif ? `(+${dif})` : '';
359− {"Out of the "}
359+ {'Out of the '}
360 {invited.value.total + dit}
360 {invited.value.total + dit}
361− {" invites you sent, "}
361+ {' invites you sent, '}
362 {invited.value.accepted}
362 {invited.value.accepted}
363− {" have been accepted."}
363+ {' have been accepted.'}
@@ -369,9 +369,9 @@ class InvitesSend extends React.Component {
369 const error = this.state.errors.matchWith({
369 const error = this.state.errors.matchWith({
370 Nothing: () => null,
370 Nothing: () => null,
371 Just: errors => (
371 Just: errors => (
372− <Warning className={"mt-8"}>
372+ <Warning className={'mt-8'}>
373 <H3 style={{ marginTop: 0, paddingTop: 0 }}>
373 <H3 style={{ marginTop: 0, paddingTop: 0 }}>
374− {"Something went wrong!"}
374+ {'Something went wrong!'}
376 {errors.value.map(err => (
376 {errors.value.map(err => (
377 <p>{err}</p>
377 <p>{err}</p>
@@ -382,31 +382,30 @@ class InvitesSend extends React.Component {
383 const fundingMessage = this.state.fundingMessage.matchWith({
383 const fundingMessage = this.state.fundingMessage.matchWith({
384 Nothing: () => null,
384 Nothing: () => null,
385− Just: msg => <Warning className={"mt-8"}>{msg.value}</Warning>,
385+ Just: msg => <Warning className={'mt-8'}>{msg.value}</Warning>,
388 let inputs;
388 let inputs;
389 if (this.state.status === STATUS.DONE) {
389 if (this.state.status === STATUS.DONE) {
390 //TODO proper clickable router thing
390 //TODO proper clickable router thing
391− inputs = "<- Back to Home";
391+ inputs = '<- Back to Home';
393 const inputDisabled = this.state.status !== STATUS.INPUT;
393 const inputDisabled = this.state.status !== STATUS.INPUT;
395 const lessButton = (
395 const lessButton = (
397− prop-size={"s narrow"}
397+ prop-size={'s narrow'}
398− className={"mt-8"}
398+ className={'mt-8'}
399 disabled={inputDisabled || this.state.targets.length === 1}
399 disabled={inputDisabled || this.state.targets.length === 1}
400− onClick={this.removeTarget}
400+ onClick={this.removeTarget}>
403 </Button>
402 </Button>
406 const moreButton = (
405 const moreButton = (
408− prop-size={"s narrow"}
407+ prop-size={'s narrow'}
409− className={"mt-8"}
408+ className={'mt-8'}
410 disabled={
409 disabled={
411 inputDisabled ||
410 inputDisabled ||
412 this.state.invitesAvailable.matchWith({
411 this.state.invitesAvailable.matchWith({
@@ -414,9 +413,8 @@ class InvitesSend extends React.Component {
414 Just: inv => inv.value <= this.state.targets.length,
413 Just: inv => inv.value <= this.state.targets.length,
417− onClick={this.addTarget}
416+ onClick={this.addTarget}>
420 </Button>
418 </Button>
@@ -424,7 +422,7 @@ class InvitesSend extends React.Component {
424 for (let i = 0; i < this.state.targets.length; i++) {
422 for (let i = 0; i < this.state.targets.length; i++) {
425 const target = this.state.targets[i];
423 const target = this.state.targets[i];
426 let progress = target.status.matchWith({
424 let progress = target.status.matchWith({
427− Nothing: () => "",
425+ Nothing: () => '',
428 Just: status => status.value,
426 Just: status => status.value,
430 targetInputs.push(
428 targetInputs.push(
@@ -434,23 +432,23 @@ class InvitesSend extends React.Component {
434 onChange={value => {
432 onChange={value => {
435 this.handleEmailInput(i, value);
433 this.handleEmailInput(i, value);
437− placeholder={"Email address"}
435+ placeholder={'Email address'}
438 disabled={inputDisabled}
436 disabled={inputDisabled}
440 {target.hasReceived.matchWith({
438 {target.hasReceived.matchWith({
441 Nothing: () => null,
439 Nothing: () => null,
442 Just: has =>
440 Just: has =>
443− has.value ? <span>{"×"}</span> : <span>{"°"}</span>,
441+ has.value ? <span>{'×'}</span> : <span>{'°'}</span>,
445 {progress}
443 {progress}
450 const submitButton = (
448 const submitButton = (
452− prop-size={"xl wide"}
450+ prop-size={'xl wide'}
453− className={"mt-8"}
451+ className={'mt-8'}
454 disabled={
452 disabled={
455 (inputDisabled && this.state.status !== STATUS.CAN_SEND) ||
453 (inputDisabled && this.state.status !== STATUS.CAN_SEND) ||
456 !this.canSend()
454 !this.canSend()
@@ -458,8 +456,7 @@ class InvitesSend extends React.Component {
458 onClick={() => {
456 onClick={() => {
459 if (this.state.status === STATUS.INPUT) this.generateInvites();
457 if (this.state.status === STATUS.INPUT) this.generateInvites();
460 if (this.state.status === STATUS.CAN_SEND) this.sendInvites();
458 if (this.state.status === STATUS.CAN_SEND) this.sendInvites();
463 {this.state.status}
460 {this.state.status}
464 </Button>
461 </Button>
@@ -477,9 +474,9 @@ class InvitesSend extends React.Component {
480− <p>{"send invites here, for planets"}</p>
477+ <p>{'send invites here, for planets'}</p>
482− <p>{"send invites here, for planets"}</p>
479+ <p>{'send invites here, for planets'}</p>
484 <p>{invitesAvailable}</p>
481 <p>{invitesAvailable}</p>