Skip to content

Commit 7e7f2b8

Browse files
authored
Merge pull request #277 from ltonetwork/recaptcha-optional
No recaptcha for testnet bridge
2 parents 16b23c5 + 4b59ccb commit 7e7f2b8

7 files changed

Lines changed: 17 additions & 6 deletions

File tree

src/app/app.module.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ import { environment } from '../environments/environment';
7676
{
7777
provide: RECAPTCHA_SETTINGS,
7878
useValue: {
79-
siteKey: '6LebrZMUAAAAAEhsMU6H0QQChao1Ya3buSsBXunu',
79+
siteKey: environment.recaptcha_site_key
8080
},
8181
},
8282
{

src/app/pages/bridge/bridge-swap/steps/deposit-erc/deposit-erc.component.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ <h2 mat-dialog-title>Your deposit address</h2>
55
</ng-container>
66
<ng-container *ngIf="shouldShowCaptcha && !captchaResponse; then captchaTpl;">
77
</ng-container>
8-
<ng-container *ngIf="captchaResponse; then addressTpl;">
8+
<ng-container *ngIf="captchaResponse || (!shouldSpecifyToAddress && !shouldShowCaptcha); then addressTpl;">
99
</ng-container>
1010
</mat-dialog-content>
1111
<mat-dialog-actions>

src/app/pages/bridge/bridge-swap/steps/deposit-erc/deposit-erc.component.ts

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
1-
import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core';
1+
import { Component, EventEmitter, Inject, Input, OnInit, Output } from '@angular/core';
22
import { BridgeService, WalletService } from '../../../../../core';
33
import { switchMap } from 'rxjs/operators';
44
import { Observable } from 'rxjs';
55
import { SwapTokenType, SwapType } from '../../swap-type';
66
import { AbstractControl, FormControl, FormGroup, ValidatorFn, Validators } from '@angular/forms';
77
import * as bech32 from 'bech32';
8+
import { RECAPTCHA_SETTINGS } from 'ng-recaptcha';
89

910
@Component({
1011
selector: 'lto-wallet-deposit-erc',
@@ -81,13 +82,17 @@ export class DepositErcComponent implements OnInit {
8182

8283
addressPlaceholder!: string;
8384

84-
constructor(private _bridge: BridgeService, private _wallet: WalletService) {}
85+
constructor(
86+
private _bridge: BridgeService,
87+
private _wallet: WalletService,
88+
@Inject(RECAPTCHA_SETTINGS) private _recaptchaSettings: { siteKey: string }
89+
) {}
8590

8691
ngOnInit() {
8792
this.addressPlaceholder = this.swapType === SwapType.ERC20_BINANCE ? 'BEP-2' : 'LTO20';
8893
const addressValidators: ValidatorFn[] = [Validators.required];
8994

90-
this.shouldShowCaptcha = !this.shouldSpecifyToAddress;
95+
this.shouldShowCaptcha = !!this._recaptchaSettings.siteKey && !this.shouldSpecifyToAddress;
9196

9297
if (this.swapType === SwapType.ERC20_BINANCE) {
9398
addressValidators.push((ctrl: AbstractControl) => {
@@ -107,6 +112,8 @@ export class DepositErcComponent implements OnInit {
107112
};
108113
}
109114
});
115+
} else if (!this.shouldShowCaptcha) {
116+
this.resolveCaptcha('');
110117
}
111118

112119
this.depositForm = new FormGroup({

src/environments/environment.local.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,9 @@ export const environment = {
77
anchor_fee: 35000000,
88
bridge: true,
99
swapPageEnabled: false,
10+
recaptcha_site_key: '',
1011
lto_api_url: 'https://testnet.lto.network/',
11-
bridge_url: 'http://localhost:3002',
12+
bridge_url: 'https://bridge.testnet.lto.network',
1213
mobile_auth: {
1314
ws: 'ws://localhost:3030/connect',
1415
url: 'http://localhost:3030/'

src/environments/environment.mainnet.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ export const environment = {
77
set_script_fee: 500000000,
88
bridge: true,
99
swapPageEnabled: true,
10+
recaptcha_site_key: '6LebrZMUAAAAAEhsMU6H0QQChao1Ya3buSsBXunu',
1011
lto_api_url: 'https://nodes.lto.network/',
1112
bridge_url: 'https://bridge.lto.network',
1213
mobile_auth: {

src/environments/environment.testnet.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ export const environment = {
77
set_script_fee: 500000000,
88
bridge: true,
99
swapPageEnabled: false,
10+
recaptcha_site_key: '',
1011
lto_api_url: 'https://testnet.lto.network/',
1112
bridge_url: 'https://bridge.testnet.lto.network',
1213
mobile_auth: {

src/environments/environment.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ export const environment = {
1111
set_script_fee: 500000000,
1212
bridge: true,
1313
swapPageEnabled: true,
14+
recaptcha_site_key: '',
1415
lto_api_url: 'https://testnet.lto.network/',
1516
bridge_url: 'https://bridge.testnet.lto.network',
1617
mobile_auth: {

0 commit comments

Comments
 (0)