1- import { Component , EventEmitter , Input , OnInit , Output } from '@angular/core' ;
1+ import { Component , EventEmitter , Inject , Input , OnInit , Output } from '@angular/core' ;
22import { BridgeService , WalletService } from '../../../../../core' ;
33import { switchMap } from 'rxjs/operators' ;
44import { Observable } from 'rxjs' ;
55import { SwapTokenType , SwapType } from '../../swap-type' ;
66import { AbstractControl , FormControl , FormGroup , ValidatorFn , Validators } from '@angular/forms' ;
77import * 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 ( {
0 commit comments