on master help sign in
Show progress to the user
07eb473Fang
src/bridge/views/InviteTransactions.js+22−7
@@ -34,9 +34,10 @@ const PROGRESS_STATES = {
34 GENERATING: 'Generating transactions',
34 GENERATING: 'Generating transactions',
35 SIGNING: 'Signing transactions',
35 SIGNING: 'Signing transactions',
36 FUNDING: 'Funding transactions',
36 FUNDING: 'Funding transactions',
37− SENDING: 'Sending transactions',
37+ CLAIMING: 'Claiming invite',
38− WAITING: 'Waiting for transaction confirmations',
38+ CONFIGURING: 'Configuring planet',
39− CLEANING: 'Cleaning up'
39+ CLEANING: 'Cleaning up',
40+ DONE: 'Done'
40}
41}
41
42
42class InviteVerify extends React.Component {
43class InviteVerify extends React.Component {
@@ -46,7 +47,8 @@ class InviteVerify extends React.Component {
46
47
47 this.state = {
48 this.state = {
48 point: this.props.routeData.point,
49 point: this.props.routeData.point,
49− ticket: this.props.routeData.ticket
50+ ticket: this.props.routeData.ticket,
51+ progress: 'Starting'
50 }
52 }
51
53
52 this.startTransactions = this.startTransactions.bind(this);
54 this.startTransactions = this.startTransactions.bind(this);
@@ -54,6 +56,7 @@ class InviteVerify extends React.Component {
54
56
55 componentDidMount() {
57 componentDidMount() {
56 //NOTE delayed so that we hang *after* rendering the page
58 //NOTE delayed so that we hang *after* rendering the page
59+ this.updateProgress('Generating transactions');
57 setTimeout(this.startTransactions, 100);
60 setTimeout(this.startTransactions, 100);
58 }
61 }
59
62
@@ -61,6 +64,14 @@ class InviteVerify extends React.Component {
61 //
64 //
62 }
65 }
63
66
67+ updateProgress(msg) {
68+ this.setState({progress: msg+'...'});
69+ }
70+
71+ askForFunding(address, amount, current) {
72+ this.updateProgress(`Please make sure ${address} has at least ${amount} wei, we'll continue once that's true. Current balance: ${current}. Waiting`);
73+ }
74+
64 async startTransactions() {
75 async startTransactions() {
65 const { point } = this.state;
76 const { point } = this.state;
66
77
@@ -104,6 +115,7 @@ class InviteVerify extends React.Component {
104 await this.ensureFundsFor(web3, point, inviteAddress, transferCost, [rawTransferStx]);
115 await this.ensureFundsFor(web3, point, inviteAddress, transferCost, [rawTransferStx]);
105
116
106 // send transaction
117 // send transaction
118+ this.updateProgress(PROGRESS_STATES.CLAIMING);
107 await this.sendAndAwaitConfirm(web3, [rawTransferStx]);
119 await this.sendAndAwaitConfirm(web3, [rawTransferStx]);
108
120
109 //
121 //
@@ -162,11 +174,11 @@ class InviteVerify extends React.Component {
162
174
163 await this.ensureFundsFor(web3, point, newAddress, totalCost, rawStxs);
175 await this.ensureFundsFor(web3, point, newAddress, totalCost, rawStxs);
164
176
177+ this.updateProgress(PROGRESS_STATES.CONFIGURING);
165 await this.sendAndAwaitConfirm(web3, rawStxs);
178 await this.sendAndAwaitConfirm(web3, rawStxs);
166− console.log('sent transactions');
167
179
168 // if non-trivial eth left in invite wallet, transfer to new ownership
180 // if non-trivial eth left in invite wallet, transfer to new ownership
169− //TODO
181+ this.updateProgress(PROGRESS_STATES.CLEANING);
170 let balance = await web3.eth.getBalance(inviteAddress);
182 let balance = await web3.eth.getBalance(inviteAddress);
171 const gasPrice = 20000000000;
183 const gasPrice = 20000000000;
172 const gasLimit = 21000;
184 const gasLimit = 21000;
@@ -191,11 +203,13 @@ class InviteVerify extends React.Component {
191 }
203 }
192
204
193 // proceed without waiting for confirm
205 // proceed without waiting for confirm
206+ this.updateProgress(PROGRESS_STATES.DONE);
194 this.props.setUrbitWallet(Just(newUrbitWallet));
207 this.props.setUrbitWallet(Just(newUrbitWallet));
195 //TODO forward to "all done!" screen
208 //TODO forward to "all done!" screen
196 }
209 }
197
210
198 async ensureFundsFor(web3, point, address, cost, signedTxs) {
211 async ensureFundsFor(web3, point, address, cost, signedTxs) {
212+ this.updateProgress(PROGRESS_STATES.FUNDING);
199 let balance = await web3.eth.getBalance(address);
213 let balance = await web3.eth.getBalance(address);
200
214
201 if (cost > balance) {
215 if (cost > balance) {
@@ -263,7 +277,6 @@ class InviteVerify extends React.Component {
263 </>
277 </>
264 );
278 );
265
279
266− console.log('tickets', this.state.ticket, this.state.realTicket, (this.state.realTicket === this.state.ticket));
267 return (
280 return (
268 <Row>
281 <Row>
269 <Col>
282 <Col>
@@ -272,6 +285,8 @@ class InviteVerify extends React.Component {
272
285
273 <p>{ 'Please wait while your wallet and point are prepared for use. This may take up to five minutes.' }</p>
286 <p>{ 'Please wait while your wallet and point are prepared for use. This may take up to five minutes.' }</p>
274
287
288+ <p>{ this.state.progress }</p>
289+
275 </Col>
290 </Col>
276 </Row>
291 </Row>
277 )
292 )