@ -1,7 +1,7 @@
/* global alert */
import React , { Component } from 'react' ;
import { ActivityIndicator , View , Text , TextInput , Alert , TouchableOpacity , Keyboard , TouchableWithoutFeedback } from 'react-native' ;
import { BlueButton , SafeBlueArea , BlueCard , BlueSpacing20 , BlueNavigationStyle , BlueText } from '../../BlueComponents' ;
import { BlueButton , SafeBlueArea , BlueCard , BlueSpacing20 , BlueNavigationStyle , BlueText , BluePrivateBalance } from '../../BlueComponents' ;
import PropTypes from 'prop-types' ;
import { LightningCustodianWallet } from '../../class/lightning-custodian-wallet' ;
import { HDLegacyBreadwalletWallet } from '../../class/hd-legacy-breadwallet-wallet' ;
@ -10,6 +10,7 @@ import { HDSegwitP2SHWallet } from '../../class/hd-segwit-p2sh-wallet';
import ReactNativeHapticFeedback from 'react-native-haptic-feedback' ;
import { HDSegwitBech32Wallet } from '../../class' ;
let EV = require ( '../../events' ) ;
let prompt = require ( '../../prompt' ) ;
/** @type {AppStorage} */
let BlueApp = require ( '../../BlueApp' ) ;
let loc = require ( '../../loc' ) ;
@ -65,6 +66,32 @@ export default class WalletDetails extends Component {
} ) ;
}
async presentWalletHasBalanceAlert ( ) {
ReactNativeHapticFeedback . trigger ( 'notificationWarning' , { ignoreAndroidSystemSettings : false } ) ;
const walletBalanceConfirmation = await prompt (
'Wallet Balance' ,
` This wallet has a balance. Before proceeding, please be aware that you will not be able to recover the funds without this wallet's seed phrase. In order to avoid accidental removal this wallet, please enter your wallet's balance of ${ this . state . wallet . getBalance ( ) } satoshis. ` ,
true ,
'plain-text' ,
) ;
if ( Number ( walletBalanceConfirmation ) === this . state . wallet . getBalance ( ) ) {
this . props . navigation . setParams ( { isLoading : true } ) ;
this . setState ( { isLoading : true } , async ( ) => {
BlueApp . deleteWallet ( this . state . wallet ) ;
ReactNativeHapticFeedback . trigger ( 'notificationSuccess' , { ignoreAndroidSystemSettings : false } ) ;
await BlueApp . saveToDisk ( ) ;
EV ( EV . enum . TRANSACTIONS_COUNT_CHANGED ) ;
EV ( EV . enum . WALLETS_COUNT_CHANGED ) ;
this . props . navigation . navigate ( 'Wallets' ) ;
} ) ;
} else {
ReactNativeHapticFeedback . trigger ( 'notificationError' , { ignoreAndroidSystemSettings : false } ) ;
this . setState ( { isLoading : false } , async ( ) => {
alert ( "The provided balance amount does not match this wallet's balance. Please, try again" ) ;
} ) ;
}
}
render ( ) {
if ( this . state . isLoading ) {
return (
@ -190,15 +217,19 @@ export default class WalletDetails extends Component {
{
text : loc . wallets . details . yes_delete ,
onPress : async ( ) => {
this . props . navigation . setParams ( { isLoading : true } ) ;
this . setState ( { isLoading : true } , async ( ) => {
BlueApp . deleteWallet ( this . state . wallet ) ;
ReactNativeHapticFeedback . trigger ( 'notificationSuccess' , { ignoreAndroidSystemSettings : false } ) ;
await BlueApp . saveToDisk ( ) ;
EV ( EV . enum . TRANSACTIONS_COUNT_CHANGED ) ;
EV ( EV . enum . WALLETS_COUNT_CHANGED ) ;
this . props . navigation . navigate ( 'Wallets' ) ;
} ) ;
if ( this . state . wallet . getBalance ( ) > 0 ) {
this . presentWalletHasBalanceAlert ( ) ;
} else {
this . props . navigation . setParams ( { isLoading : true } ) ;
this . setState ( { isLoading : true } , async ( ) => {
BlueApp . deleteWallet ( this . state . wallet ) ;
ReactNativeHapticFeedback . trigger ( 'notificationSuccess' , { ignoreAndroidSystemSettings : false } ) ;
await BlueApp . saveToDisk ( ) ;
EV ( EV . enum . TRANSACTIONS_COUNT_CHANGED ) ;
EV ( EV . enum . WALLETS_COUNT_CHANGED ) ;
this . props . navigation . navigate ( 'Wallets' ) ;
} ) ;
}
} ,
style : 'destructive' ,
} ,