on master help sign in
- updateProgress in invite#startTransactions now accepts a “notify” type, to alert user in case of insufficient balance
commitb1e33d4d4cc990d68ace7d3f8ba25a5f45a2e535 authorChris Johnson <chris@cjohnson.io> dateWed 1 May 2019, 15:36 (8 years ago) parenta63853f
2 files changed+40−13
src/bridge/lib/invite.js+29−7 src/bridge/views/InviteTicket.js+11−6
src/bridge/lib/invite.js+29−7
@@ -226,8 +226,12 @@ async function startTransactions(args) {
226226 const transferCost = transferTx.gas * transferTx.gasPrice;
227227 await ensureFundsFor(web3, point, inviteAddress, transferCost, [rawTransferStx], updateProgress, true);
228228
229+ updateProgress({
230+ type: "progress",
231+ value: TRANSACTION_STATES.CLAIMING
232+ });
233+
229234 // send transaction
230− updateProgress(TRANSACTION_STATES.CLAIMING);
231235 await sendAndAwaitConfirm(web3, [rawTransferStx]);
232236
233237 //
@@ -286,11 +290,19 @@ async function startTransactions(args) {
286290
287291 await ensureFundsFor(web3, point, newAddress, totalCost, rawStxs, updateProgress, false);
288292
289− updateProgress(TRANSACTION_STATES.CONFIGURING);
293+ updateProgress({
294+ type: "progress",
295+ value: TRANSACTION_STATES.CONFIGURING
296+ });
297+
290298 await sendAndAwaitConfirm(web3, rawStxs);
291299
300+ updateProgress({
301+ type: "progress",
302+ value: TRANSACTION_STATES.CLEANING
303+ });
304+
292305 // if non-trivial eth left in invite wallet, transfer to new ownership
293− updateProgress(TRANSACTION_STATES.CLEANING);
294306 let balance = await web3.eth.getBalance(inviteAddress);
295307 const gasPrice = 20000000000;
296308 const gasLimit = 21000;
@@ -314,16 +326,23 @@ async function startTransactions(args) {
314326 console.log('sent old balance');
315327 }
316328
329+ updateProgress({
330+ type: "progress",
331+ value: TRANSACTION_STATES.DONE
332+ });
333+
317334 // proceed without waiting for confirm
318− updateProgress(TRANSACTION_STATES.DONE);
319335 setUrbitWallet(Just(realWallet));
320− //TODO forward to "all done!" screen
321336}
322337
323338async function ensureFundsFor(web3, point, address, cost, signedTxs, updateProgress, firstTx) {
324339 let fundingState = firstTx? TRANSACTION_STATES.FUNDING_INVITE : TRANSACTION_STATES.FUNDING_RECIPIENT
325340
326− updateProgress(fundingState);
341+ updateProgress({
342+ type: "progress",
343+ value: fundingState
344+ });
345+
327346 let balance = await web3.eth.getBalance(address);
328347
329348 if (cost > balance) {
@@ -422,7 +441,10 @@ function awaitForResult(desired, retryTime, func) {
422441}
423442
424443function askForFunding(address, amount, current, updateProgress) {
425− updateProgress(`Please make sure ${address} has at least ${amount} wei, we'll continue once that's true. Current balance: ${current}. Waiting`);
444+ updateProgress({
445+ type: "notify",
446+ value: `Please make sure ${address} has at least ${amount} wei, we'll continue once that's true. Current balance: ${current}. Waiting`
447+ });
426448}
427449
428450export {
src/bridge/views/InviteTicket.js+11−6
@@ -129,8 +129,9 @@ class InviteTicket extends React.Component {
129129 this.setState({
130130 realPoint,
131131 realWallet,
132+ // dev mode: uncomment this out to autofill verified ticket
132133 inviteWallet: Just(inviteWallet),
133− // verifyTicket: realWallet.value.ticket,
134+ verifyTicket: realWallet.value.ticket,
134135 walletStates: this.state.walletStates.concat(WALLET_STATES.RENDERING),
135136 errors
136137 })
@@ -185,7 +186,7 @@ class InviteTicket extends React.Component {
185186
186187 const stageText = stage === INVITE_STAGES.INVITE_LOGIN
187188 ? <h1 className="text-700 mt-15">Welcome</h1>
188− : stage === INVITE_STAGES.INVITE_LOGIN
189+ : stage === INVITE_STAGES.INVITE_WALLET
189190 ? (
190191 <div>
191192 <h1 className="fs-6 lh-8 mb-3">Passport</h1>
@@ -227,10 +228,14 @@ class InviteTicket extends React.Component {
227228 return stageText
228229 }
229230
230− updateProgress(transactionProgress) {
231− this.setState({
232− transactionProgress
233− })
231+ updateProgress(notification) {
232+ let newState = notification.type === "progress"
233+ ? { transactionProgress: notification.value }
234+ : notification.type === "progress"
235+ ? { errors: [notification.value] }
236+ : {}
237+
238+ this.setState(newState)
234239 }
235240
236241 getContinueButton() {