Skip to content

Commit ae3d13f

Browse files
authored
wait for txns in get free deso flows (#309)
* wait for txns in get free deso flows * lint and format * Committed -> InMempool
1 parent ae88aeb commit ae3d13f

File tree

4 files changed

+38
-12
lines changed

4 files changed

+38
-12
lines changed

src/app/get-deso/get-deso.component.html

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,13 @@ <h3 class="text--neutral-white">Get starter $DESO</h3>
4545
(error)="onCaptchaError($event)"
4646
>
4747
</ng-hcaptcha>
48+
<div
49+
*ngIf="captchaFlowSpinner"
50+
class="padding-top--medium display--flex flex--column items--center"
51+
>
52+
<div>Waiting for your $DESO to arrive.</div>
53+
<div class="spinner-border" style="width: 6rem; height: 6rem"></div>
54+
</div>
4855
<div *ngIf="captchaFailed" class="warning--error margin-top--small">
4956
There was an issue verifying your captcha. Please
5057
<a (click)="resetCaptcha()">reset the captcha</a> and try again, or

src/app/get-deso/get-deso.component.ts

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,8 @@ export class GetDesoComponent implements OnInit {
4848
captchaFailed = false;
4949
// Whether the backend is offering rewards for solving captchas.
5050
captchaAvailable = true;
51+
// Loader shown while waiting for DESO to arrive.
52+
captchaFlowSpinner = false;
5153

5254
publicKeyCopied = false;
5355

@@ -160,19 +162,26 @@ export class GetDesoComponent implements OnInit {
160162
}
161163

162164
onCaptchaVerify(token: string): void {
163-
this.backendAPIService.VerifyHCaptcha(token, this.publicKeyAdded).subscribe(
164-
(res) => {
165-
if (res.Success) {
166-
this.isFinishFlowDisabled = false;
167-
this.finishFlow();
168-
} else {
165+
this.captchaFlowSpinner = true;
166+
this.backendAPIService
167+
.VerifyHCaptcha(token, this.publicKeyAdded)
168+
.subscribe(
169+
async (res) => {
170+
if (res.Success) {
171+
await this.backendAPIService
172+
.GetTxn(res.TxnHashHex, 'InMempool')
173+
.toPromise();
174+
this.isFinishFlowDisabled = false;
175+
this.finishFlow();
176+
} else {
177+
this.captchaFailed = true;
178+
}
179+
},
180+
(err) => {
169181
this.captchaFailed = true;
170182
}
171-
},
172-
(err) => {
173-
this.captchaFailed = true;
174-
}
175-
);
183+
)
184+
.add(() => (this.captchaFlowSpinner = false));
176185
}
177186

178187
onCaptchaExpired(event: any): void {

src/app/sign-up-get-starter-deso/sign-up-get-starter-deso.component.html

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -285,13 +285,21 @@ <h3 class="text--neutral-white">Confirm your authentication code</h3>
285285
</div>
286286
</div>
287287
<div class="margin-top--medium">
288+
<div
289+
*ngIf="submittingPhoneNumberVerificationCode"
290+
class="padding-top--medium display--flex flex--column items--center"
291+
>
292+
<div>Waiting for your $DESO to arrive.</div>
293+
<div class="spinner-border" style="width: 6rem; height: 6rem"></div>
294+
</div>
288295
<button
289296
data-control-name="get-starter-deso-confirm-code-button"
290297
(click)="submitVerificationCode()"
291298
[ngClass]="{
292299
disabled: !verificationCodeForm.valid,
293300
'btn-loading': submittingPhoneNumberVerificationCode
294301
}"
302+
[disabled]="submittingPhoneNumberVerificationCode"
295303
class="button--primary button--medium margin-bottom--medium"
296304
>
297305
Confirm
@@ -300,6 +308,7 @@ <h3 class="text--neutral-white">Confirm your authentication code</h3>
300308
data-control-name="get-starter-deso-back-button"
301309
*ngIf="displayForSignupFlow"
302310
(click)="backButtonClickedOnSubmitVerificationScreen()"
311+
[disabled]="submittingPhoneNumberVerificationCode"
303312
class="button--primary--outline button--medium"
304313
>
305314
Back

src/app/sign-up-get-starter-deso/sign-up-get-starter-deso.component.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -300,7 +300,8 @@ export class SignUpGetStarterDESOComponent implements OnInit {
300300
this.verificationCodeForm.value.verificationCode
301301
)
302302
.subscribe(
303-
(res) => {
303+
async (res) => {
304+
await this.backendApi.GetTxn(res.TxnHashHex, 'InMempool').toPromise();
304305
this.screenToShow =
305306
SignUpGetStarterDESOComponent.COMPLETED_PHONE_NUMBER_VERIFICATION_SCREEN;
306307
this.phoneNumberVerified.emit();

0 commit comments

Comments
 (0)