on master help sign in
- updateProgress in invite#startTransactions now accepts a “notify” type, to alert user in case of insufficient balance
b1e33d4Chris Johnson
src/bridge/lib/invite.js+29−7
@@ -226,8 +226,12 @@ async function startTransactions(args) {
226 const transferCost = transferTx.gas * transferTx.gasPrice;
226 const transferCost = transferTx.gas * transferTx.gasPrice;
227 await ensureFundsFor(web3, point, inviteAddress, transferCost, [rawTransferStx], updateProgress, true);
227 await ensureFundsFor(web3, point, inviteAddress, transferCost, [rawTransferStx], updateProgress, true);
228
228
229+ updateProgress({
230+ type: "progress",
231+ value: TRANSACTION_STATES.CLAIMING
232+ });
233+
229 // send transaction
234 // send transaction
230− updateProgress(TRANSACTION_STATES.CLAIMING);
231 await sendAndAwaitConfirm(web3, [rawTransferStx]);
235 await sendAndAwaitConfirm(web3, [rawTransferStx]);
232
236
233 //
237 //
@@ -286,11 +290,19 @@ async function startTransactions(args) {
286
290
287 await ensureFundsFor(web3, point, newAddress, totalCost, rawStxs, updateProgress, false);
291 await ensureFundsFor(web3, point, newAddress, totalCost, rawStxs, updateProgress, false);
288
292
293+ updateProgress({
294+ type: "progress",
289− updateProgress(TRANSACTION_STATES.CONFIGURING);
295+ value: TRANSACTION_STATES.CONFIGURING
296+ });
297+
290 await sendAndAwaitConfirm(web3, rawStxs);
298 await sendAndAwaitConfirm(web3, rawStxs);
291
299
300+ updateProgress({
301+ type: "progress",
302+ value: TRANSACTION_STATES.CLEANING
303+ });
304+
292 // if non-trivial eth left in invite wallet, transfer to new ownership
305 // if non-trivial eth left in invite wallet, transfer to new ownership
293− updateProgress(TRANSACTION_STATES.CLEANING);
294 let balance = await web3.eth.getBalance(inviteAddress);
306 let balance = await web3.eth.getBalance(inviteAddress);
295 const gasPrice = 20000000000;
307 const gasPrice = 20000000000;
296 const gasLimit = 21000;
308 const gasLimit = 21000;
@@ -314,16 +326,23 @@ async function startTransactions(args) {
314 console.log('sent old balance');
326 console.log('sent old balance');
315 }
327 }
316
328
329+ updateProgress({
330+ type: "progress",
331+ value: TRANSACTION_STATES.DONE
332+ });
333+
317 // proceed without waiting for confirm
334 // proceed without waiting for confirm
318− updateProgress(TRANSACTION_STATES.DONE);
319 setUrbitWallet(Just(realWallet));
335 setUrbitWallet(Just(realWallet));
320− //TODO forward to "all done!" screen
321}
336}
322
337
323async function ensureFundsFor(web3, point, address, cost, signedTxs, updateProgress, firstTx) {
338async function ensureFundsFor(web3, point, address, cost, signedTxs, updateProgress, firstTx) {
324 let fundingState = firstTx? TRANSACTION_STATES.FUNDING_INVITE : TRANSACTION_STATES.FUNDING_RECIPIENT
339 let fundingState = firstTx? TRANSACTION_STATES.FUNDING_INVITE : TRANSACTION_STATES.FUNDING_RECIPIENT
325
340
326− updateProgress(fundingState);
341+ updateProgress({
342+ type: "progress",
343+ value: fundingState
344+ });
345+
327 let balance = await web3.eth.getBalance(address);
346 let balance = await web3.eth.getBalance(address);
328
347
329 if (cost > balance) {
348 if (cost > balance) {
@@ -422,7 +441,10 @@ function awaitForResult(desired, retryTime, func) {
422}
441}
423
442
424function askForFunding(address, amount, current, updateProgress) {
443function askForFunding(address, amount, current, updateProgress) {
444+ updateProgress({
445+ type: "notify",
425− updateProgress(`Please make sure ${address} has at least ${amount} wei, we'll continue once that's true. Current balance: ${current}. Waiting`);
446+ value: `Please make sure ${address} has at least ${amount} wei, we'll continue once that's true. Current balance: ${current}. Waiting`
447+ });
426}
448}
427
449
428export {
450export {
src/bridge/views/InviteTicket.js+11−6
@@ -129,8 +129,9 @@ class InviteTicket extends React.Component {
129 this.setState({
129 this.setState({
130 realPoint,
130 realPoint,
131 realWallet,
131 realWallet,
132+ // dev mode: uncomment this out to autofill verified ticket
132 inviteWallet: Just(inviteWallet),
133 inviteWallet: Just(inviteWallet),
133− // verifyTicket: realWallet.value.ticket,
134+ verifyTicket: realWallet.value.ticket,
134 walletStates: this.state.walletStates.concat(WALLET_STATES.RENDERING),
135 walletStates: this.state.walletStates.concat(WALLET_STATES.RENDERING),
135 errors
136 errors
136 })
137 })
@@ -185,7 +186,7 @@ class InviteTicket extends React.Component {
185
186
186 const stageText = stage === INVITE_STAGES.INVITE_LOGIN
187 const stageText = stage === INVITE_STAGES.INVITE_LOGIN
187 ? <h1 className="text-700 mt-15">Welcome</h1>
188 ? <h1 className="text-700 mt-15">Welcome</h1>
188− : stage === INVITE_STAGES.INVITE_LOGIN
189+ : stage === INVITE_STAGES.INVITE_WALLET
189 ? (
190 ? (
190 <div>
191 <div>
191 <h1 className="fs-6 lh-8 mb-3">Passport</h1>
192 <h1 className="fs-6 lh-8 mb-3">Passport</h1>
@@ -227,10 +228,14 @@ class InviteTicket extends React.Component {
227 return stageText
228 return stageText
228 }
229 }
229
230
230− updateProgress(transactionProgress) {
231+ updateProgress(notification) {
232+ let newState = notification.type === "progress"
233+ ? { transactionProgress: notification.value }
234+ : notification.type === "progress"
235+ ? { errors: [notification.value] }
236+ : {}
237+
231− this.setState({
238+ this.setState(newState)
232− transactionProgress
233− })
234 }
239 }
235
240
236 getContinueButton() {
241 getContinueButton() {