From 1116044c9fb2e6940fc5b223ff7a9a0e55a22623 Mon Sep 17 00:00:00 2001 From: Marcos Rodriguez Velez Date: Wed, 7 Feb 2024 15:24:24 -0400 Subject: [PATCH] ADD: Expand Alert component to add custom title --- BlueApp.js | 12 ++++----- blue_modules/BlueElectrum.js | 4 +-- blue_modules/fs.ts | 18 ++++++------- blue_modules/storage-context.js | 9 +++---- class/biometrics.ts | 4 +-- class/payjoin-transaction.js | 4 +-- class/wallets/lightning-ldk-wallet.ts | 6 ++--- components/Alert.ts | 6 ++--- components/addresses/AddressItem.tsx | 7 ++--- screen/lnd/ldkInfo.tsx | 10 +++---- screen/lnd/ldkOpenChannel.tsx | 16 +++++------ screen/lnd/lndCreateInvoice.js | 12 ++++----- .../lndViewAdditionalInvoiceInformation.js | 4 +-- screen/lnd/lnurlPay.js | 8 +++--- screen/lnd/scanLndInvoice.js | 12 ++++----- screen/plausibledeniability.js | 8 +++--- screen/receive/aztecoRedeem.js | 8 +++--- screen/selftest.js | 6 ++--- screen/send/ScanQRCode.js | 4 +-- screen/send/broadcast.js | 5 ++-- screen/send/confirm.js | 4 +-- screen/send/create.js | 6 ++--- screen/send/details.js | 27 ++++++++++--------- screen/send/psbtMultisig.js | 6 ++--- screen/send/psbtMultisigQRCode.js | 6 ++--- screen/send/psbtWithHardwareWallet.js | 16 +++++------ screen/settings/Currency.tsx | 6 +++-- screen/settings/about.js | 4 +-- screen/settings/electrumSettings.js | 12 ++++----- screen/settings/encryptStorage.js | 6 ++--- screen/settings/language.tsx | 4 +-- screen/settings/lightningSettings.tsx | 6 ++--- screen/settings/notificationSettings.js | 8 +++--- screen/transactions/CPFP.js | 8 +++--- screen/transactions/RBFBumpFee.js | 4 +-- screen/transactions/RBFCancel.js | 4 +-- screen/transactions/details.js | 10 +++---- screen/wallets/add.tsx | 10 +++---- screen/wallets/addMultisigStep2.js | 18 ++++++------- screen/wallets/details.js | 16 +++++------ screen/wallets/importDiscovery.js | 5 ++-- screen/wallets/importSpeed.js | 5 ++-- screen/wallets/ldkViewLogs.js | 6 ++--- screen/wallets/signVerify.js | 14 +++++----- screen/wallets/transactions.js | 8 +++--- screen/wallets/viewEditMultisigCosigners.tsx | 8 +++--- .../lightning-ldk-wallet.ts | 4 +-- 47 files changed, 200 insertions(+), 194 deletions(-) diff --git a/BlueApp.js b/BlueApp.js index 84f7e3b33..7e9a2a519 100644 --- a/BlueApp.js +++ b/BlueApp.js @@ -24,7 +24,7 @@ import { SLIP39SegwitBech32Wallet, } from './class/'; import { randomBytes } from './class/rng'; -import alert from './components/Alert'; +import presentAlert from './components/Alert'; import { initCurrencyDaemon } from './blue_modules/currency'; import DefaultPreference from 'react-native-default-preference'; @@ -327,7 +327,7 @@ class AppStorage { try { realm = await this.getRealm(); } catch (error) { - alert(error.message); + presentAlert({ message: error.message }); } data = JSON.parse(data); if (!data.wallets) return false; @@ -425,7 +425,7 @@ class AppStorage { try { if (realm) this.inflateWalletFromRealm(realm, unserializedWallet); } catch (error) { - alert(error.message); + presentAlert({ message: error.message }); } // done @@ -581,7 +581,7 @@ class AppStorage { async saveToDisk() { if (savingInProgress) { console.warn('saveToDisk is in progress'); - if (++savingInProgress > 10) alert('Critical error. Last actions were not saved'); // should never happen + if (++savingInProgress > 10) presentAlert({ message: 'Critical error. Last actions were not saved' }); // should never happen await new Promise(resolve => setTimeout(resolve, 1000 * savingInProgress)); // sleep return this.saveToDisk(); } @@ -593,7 +593,7 @@ class AppStorage { try { realm = await this.getRealm(); } catch (error) { - alert(error.message); + presentAlert({ message: error.message }); } for (const key of this.wallets) { if (typeof key === 'boolean') continue; @@ -667,7 +667,7 @@ class AppStorage { realmkeyValue.close(); } catch (error) { console.error('save to disk exception:', error.message); - alert('save to disk exception: ' + error.message); + presentAlert({ message: 'save to disk exception: ' + error.message }); if (error.message.includes('Realm file decryption failed')) { console.warn('purging realm key-value database file'); this.purgeRealmKeyValueFile(); diff --git a/blue_modules/BlueElectrum.js b/blue_modules/BlueElectrum.js index 85b65e298..aff7ba495 100644 --- a/blue_modules/BlueElectrum.js +++ b/blue_modules/BlueElectrum.js @@ -4,7 +4,7 @@ import { LegacyWallet, SegwitBech32Wallet, SegwitP2SHWallet, TaprootWallet } fro import DefaultPreference from 'react-native-default-preference'; import loc from '../loc'; import WidgetCommunication from './WidgetCommunication'; -import alert from '../components/Alert'; +import presentAlert from '../components/Alert'; const bitcoin = require('bitcoinjs-lib'); const ElectrumClient = require('electrum-client'); const reverse = require('buffer-reverse'); @@ -246,7 +246,7 @@ async function presentNetworkErrorAlert(usingPeer) { // Must be running on Android console.log(e); } - alert(loc.settings.electrum_saved); + presentAlert({ message: loc.settings.electrum_saved }); setTimeout(connectMain, 500); }, }, diff --git a/blue_modules/fs.ts b/blue_modules/fs.ts index 340d975a9..1704a5def 100644 --- a/blue_modules/fs.ts +++ b/blue_modules/fs.ts @@ -5,7 +5,7 @@ import loc from '../loc'; import DocumentPicker from 'react-native-document-picker'; import { launchImageLibrary } from 'react-native-image-picker'; import { isDesktop } from './environment'; -import alert from '../components/Alert'; +import presentAlert from '../components/Alert'; import { readFile } from './react-native-bw-file-access'; const LocalQRCode = require('@remobile/react-native-qrcode-local-image'); @@ -16,7 +16,7 @@ const _shareOpen = async (filePath: string) => { saveToFiles: isDesktop, }) .catch(error => { - alert(error.message); + presentAlert({ message: error.message }); console.log(error); }) .finally(() => { @@ -52,7 +52,7 @@ const writeFileAndExport = async function (filename: string, contents: string) { await _shareOpen(filePath); } catch (e: any) { console.log(e); - alert(e.message); + presentAlert({ message: e.message }); } } else { console.log('Storage Permission: Denied'); @@ -68,7 +68,7 @@ const writeFileAndExport = async function (filename: string, contents: string) { ]); } } else { - alert('Not implemented for this platform'); + presentAlert({ message: 'Not implemented for this platform' }); } }; @@ -84,7 +84,7 @@ const openSignedTransaction = async function (): Promise { return await _readPsbtFileIntoBase64(res.uri); } catch (err) { if (!DocumentPicker.isCancel(err)) { - alert(loc.send.details_no_signed_tx); + presentAlert({ message: loc.send.details_no_signed_tx }); } } @@ -152,7 +152,7 @@ const showFilePickerAndReadFile = async function (): Promise<{ data: string | fa }); if (!res.fileCopyUri) { - alert('Picking and caching a file failed'); + presentAlert({ message: 'Picking and caching a file failed' }); return { data: false, uri: false }; } @@ -169,7 +169,7 @@ const showFilePickerAndReadFile = async function (): Promise<{ data: string | fa return new Promise(resolve => { if (!res.fileCopyUri) { // to make ts happy, should not need this check here - alert('Picking and caching a file failed'); + presentAlert({ message: 'Picking and caching a file failed' }); resolve({ data: false, uri: false }); return; } @@ -188,7 +188,7 @@ const showFilePickerAndReadFile = async function (): Promise<{ data: string | fa return { data: file, uri: fileCopyUri }; } catch (err: any) { if (!DocumentPicker.isCancel(err)) { - alert(err.message); + presentAlert({ message: err.message }); } return { data: false, uri: false }; } @@ -200,7 +200,7 @@ const readFileOutsideSandbox = (filePath: string) => { } else if (Platform.OS === 'android') { return RNFS.readFile(filePath); } else { - alert('Not implemented for this platform'); + presentAlert({ message: 'Not implemented for this platform' }); } }; diff --git a/blue_modules/storage-context.js b/blue_modules/storage-context.js index ff2a86b31..b24e86034 100644 --- a/blue_modules/storage-context.js +++ b/blue_modules/storage-context.js @@ -1,11 +1,10 @@ import React, { createContext, useEffect, useState } from 'react'; -import { Alert } from 'react-native'; import { useAsyncStorage } from '@react-native-async-storage/async-storage'; import { FiatUnit } from '../models/fiatUnit'; import Notifications from '../blue_modules/notifications'; import loc, { STORAGE_KEY as LOC_STORAGE_KEY } from '../loc'; import { LegacyWallet, WatchOnlyWallet } from '../class'; -import alert from '../components/Alert'; +import presentAlert from '../components/Alert'; import triggerHapticFeedback, { HapticFeedbackTypes } from './hapticFeedback'; import { PREFERRED_CURRENCY_STORAGE_KEY } from './currency'; const BlueApp = require('../BlueApp'); @@ -37,7 +36,7 @@ export const BlueStorageProvider = ({ children }) => { useEffect(() => { console.log(`Privacy blur: ${isPrivacyBlurEnabled}`); if (!isPrivacyBlurEnabled) { - alert('Privacy blur has been disabled.'); + presentAlert({ message: 'Privacy blur has been disabled.' }); } }, [isPrivacyBlurEnabled]); @@ -178,7 +177,7 @@ export const BlueStorageProvider = ({ children }) => { const addAndSaveWallet = async w => { if (wallets.some(i => i.getID() === w.getID())) { triggerHapticFeedback(HapticFeedbackTypes.NotificationError); - Alert.alert('', 'This wallet has been previously imported.'); + presentAlert({ message: 'This wallet has been previously imported.' }); return; } const emptyWalletLabel = new LegacyWallet().getLabel(); @@ -188,7 +187,7 @@ export const BlueStorageProvider = ({ children }) => { addWallet(w); await saveToDisk(); A(A.ENUM.CREATED_WALLET); - Alert.alert('', w.type === WatchOnlyWallet.type ? loc.wallets.import_success_watchonly : loc.wallets.import_success); + presentAlert({ message: w.type === WatchOnlyWallet.type ? loc.wallets.import_success_watchonly : loc.wallets.import_success }); Notifications.majorTomToGroundControl(w.getAllExternalAddresses(), [], []); // start balance fetching at the background await w.fetchBalance(); diff --git a/class/biometrics.ts b/class/biometrics.ts index c1068514b..5d662e437 100644 --- a/class/biometrics.ts +++ b/class/biometrics.ts @@ -8,7 +8,7 @@ import RNSecureKeyStore from 'react-native-secure-key-store'; import loc from '../loc'; import { useContext } from 'react'; import { BlueStorageContext } from '../blue_modules/storage-context'; -import alert from '../components/Alert'; +import presentAlert from '../components/Alert'; // Define a function type with properties type DescribableFunction = { @@ -129,7 +129,7 @@ const Biometric: DescribableFunction = function () { isDevicePasscodeSupported = undefined; } if (isDevicePasscodeSupported === false) { - alert(loc.settings.biom_no_passcode); + presentAlert({ message: loc.settings.biom_no_passcode }); } }; diff --git a/class/payjoin-transaction.js b/class/payjoin-transaction.js index b4c83930f..37ee28f93 100644 --- a/class/payjoin-transaction.js +++ b/class/payjoin-transaction.js @@ -1,5 +1,5 @@ import * as bitcoin from 'bitcoinjs-lib'; -import alert from '../components/Alert'; +import presentAlert from '../components/Alert'; import { ECPairFactory } from 'ecpair'; import ecc from '../blue_modules/noble_ecc'; import triggerHapticFeedback, { HapticFeedbackTypes } from '../blue_modules/hapticFeedback'; @@ -75,7 +75,7 @@ export default class PayjoinTransaction { if (result === '') { // TODO: Improve the wording of this error message triggerHapticFeedback(HapticFeedbackTypes.NotificationError); - alert('Something was wrong with the payjoin transaction, the original transaction sucessfully broadcast.'); + presentAlert({ message: 'Something was wrong with the payjoin transaction, the original transaction sucessfully broadcast.' }); } }); } diff --git a/class/wallets/lightning-ldk-wallet.ts b/class/wallets/lightning-ldk-wallet.ts index dcf758027..141e34129 100644 --- a/class/wallets/lightning-ldk-wallet.ts +++ b/class/wallets/lightning-ldk-wallet.ts @@ -8,7 +8,7 @@ import * as bip39 from 'bip39'; import { HDSegwitBech32Wallet } from './hd-segwit-bech32-wallet'; import bolt11 from 'bolt11'; import { SegwitBech32Wallet } from './segwit-bech32-wallet'; -import alert from '../../components/Alert'; +import presentAlert from '../../components/Alert'; const bitcoin = require('bitcoinjs-lib'); export class LightningLdkWallet extends LightningCustodianWallet { @@ -273,7 +273,7 @@ export class LightningLdkWallet extends LightningCustodianWallet { this._execInBackground(this.reestablishChannels); if (this.timeToCheckBlockchain()) this._execInBackground(this.checkBlockchain); } catch (error: any) { - alert('LDK init error: ' + error.message); + presentAlert({ message: 'LDK init error: ' + error.message }); } } @@ -684,7 +684,7 @@ export class LightningLdkWallet extends LightningCustodianWallet { try { await func.call(that); } catch (error: any) { - alert('_execInBackground error:' + error.message); + presentAlert({ message: '_execInBackground error:' + error.message }); } })(); } diff --git a/components/Alert.ts b/components/Alert.ts index 634f16735..8e87591d5 100644 --- a/components/Alert.ts +++ b/components/Alert.ts @@ -1,6 +1,6 @@ import { Alert } from 'react-native'; import loc from '../loc'; -const alert = (text: string) => { - Alert.alert(loc.alert.default, text); +const presentAlert = ({ title, message }: { title?: string; message: string }) => { + Alert.alert(title ?? loc.alert.default, message); }; -export default alert; +export default presentAlert; diff --git a/components/addresses/AddressItem.tsx b/components/addresses/AddressItem.tsx index 07f5ae651..53334d032 100644 --- a/components/addresses/AddressItem.tsx +++ b/components/addresses/AddressItem.tsx @@ -13,6 +13,7 @@ import { BitcoinUnit } from '../../models/bitcoinUnits'; import { BlueStorageContext } from '../../blue_modules/storage-context'; import { AbstractWallet } from '../../class'; import Biometric from '../../class/biometrics'; +import presentAlert from '../Alert'; const confirm = require('../../helpers/confirm'); interface AddressItemProps { @@ -90,19 +91,19 @@ const AddressItem = ({ item, balanceUnit, walletID, allowSignVerifyMessage }: Ad const handleCopyPrivkeyPress = () => { const wallet = wallets.find((w: AbstractWallet) => w.getID() === walletID); if (!wallet) { - alert('Internal error: cant find wallet'); + presentAlert({ message: 'Internal error: cant find wallet' }); return; } try { const wif = wallet._getWIFbyAddress(item.address); if (!wif) { - alert('Internal error: cant get WIF from the wallet'); + presentAlert({ message: 'Internal error: cant get WIF from the wallet' }); return; } Clipboard.setString(wif); } catch (error: any) { - alert(error.message); + presentAlert({ message: error.message }); } }; diff --git a/screen/lnd/ldkInfo.tsx b/screen/lnd/ldkInfo.tsx index b3f684693..fa3dfef6b 100644 --- a/screen/lnd/ldkInfo.tsx +++ b/screen/lnd/ldkInfo.tsx @@ -11,7 +11,7 @@ import BottomModal from '../../components/BottomModal'; import Button from '../../components/Button'; import { Psbt } from 'bitcoinjs-lib'; import { AbstractWallet, LightningLdkWallet } from '../../class'; -import alert from '../../components/Alert'; +import presentAlert from '../../components/Alert'; import { useTheme } from '../../components/themes'; import StyledButton, { StyledButtonType } from '../../components/StyledButton'; import SafeArea from '../../components/SafeArea'; @@ -174,7 +174,7 @@ const LdkInfo = () => { console.warn('want to close to wallet ', toWallet.getLabel()); const address = await toWallet.getAddressAsync(); - if (!address) return alert('Error: could not get address for channel withdrawal'); + if (!address) return presentAlert({ message: 'Error: could not get address for channel withdrawal' }); await wallet.setRefundAddress(address); let forceClose = false; @@ -184,7 +184,7 @@ const LdkInfo = () => { } const rez = await wallet.closeChannel(channel.channel_id, forceClose); if (rez) { - alert(loc._.success); + presentAlert({ message: loc._.success }); return refetchData(); } }; @@ -208,7 +208,7 @@ const LdkInfo = () => { try { const rez = await wallet.claimCoins(address); if (rez) { - alert(loc._.success); + presentAlert({ message: loc._.success }); await refetchData(); } } finally { @@ -318,7 +318,7 @@ const LdkInfo = () => { const navigateToOpenChannel = async ({ isPrivateChannel }: { isPrivateChannel: boolean }) => { const availableWallets = [...wallets.filter((item: AbstractWallet) => item.isSegwit() && item.allowSend())]; if (availableWallets.length === 0) { - return alert(loc.lnd.refill_create); + return presentAlert({ message: loc.lnd.refill_create }); } // @ts-ignore: Address types later navigate('LDKOpenChannelRoot', { diff --git a/screen/lnd/ldkOpenChannel.tsx b/screen/lnd/ldkOpenChannel.tsx index e2a407ad0..4230a25d3 100644 --- a/screen/lnd/ldkOpenChannel.tsx +++ b/screen/lnd/ldkOpenChannel.tsx @@ -13,7 +13,7 @@ import { AbstractWallet, HDSegwitBech32Wallet, LightningLdkWallet } from '../../ import { ArrowPicker } from '../../components/ArrowPicker'; import { Psbt } from 'bitcoinjs-lib'; import Biometric from '../../class/biometrics'; -import alert from '../../components/Alert'; +import presentAlert from '../../components/Alert'; import { useTheme } from '../../components/themes'; import Button from '../../components/Button'; import triggerHapticFeedback, { HapticFeedbackTypes } from '../../blue_modules/hapticFeedback'; @@ -69,7 +69,7 @@ const LdkOpenChannel = (props: any) => { if (psbtOpenChannelStartedTs.current ? +new Date() - psbtOpenChannelStartedTs.current >= 5 * 60 * 1000 : false) { // its 10 min actually, but lets check 5 min just for any case triggerHapticFeedback(HapticFeedbackTypes.NotificationError); - return alert('Channel opening expired. Please try again'); + return presentAlert({ message: 'Channel opening expired. Please try again' }); } setVerified(true); @@ -96,7 +96,7 @@ const LdkOpenChannel = (props: any) => { // its 10 min actually, but lets check 5 min just for any case triggerHapticFeedback(HapticFeedbackTypes.NotificationError); setIsLoading(false); - return alert('Channel opening expired. Please try again'); + return presentAlert({ message: 'Channel opening expired. Please try again' }); } const tx = psbt.extractTransaction(); @@ -105,7 +105,7 @@ const LdkOpenChannel = (props: any) => { if (!res) { triggerHapticFeedback(HapticFeedbackTypes.NotificationError); setIsLoading(false); - return alert('Something wend wrong during opening channel tx broadcast'); + return presentAlert({ message: 'Something wend wrong during opening channel tx broadcast' }); } fetchAndSaveWalletTransactions(ldkWallet.getID()); await new Promise(resolve => setTimeout(resolve, 3000)); // sleep to make sure network propagates @@ -122,14 +122,14 @@ const LdkOpenChannel = (props: any) => { const amountSatsNumber = new BigNumber(fundingAmount.amountSats).toNumber(); if (!amountSatsNumber) { triggerHapticFeedback(HapticFeedbackTypes.NotificationError); - return alert('Amount is not valid'); + return presentAlert({ message: 'Amount is not valid' }); } const pubkey = remoteHostWithPubkey.split('@')[0]; const host = remoteHostWithPubkey.split('@')[1]; if (!pubkey || !host) { triggerHapticFeedback(HapticFeedbackTypes.NotificationError); - return alert('Remote node address is not valid'); + return presentAlert({ message: 'Remote node address is not valid' }); } const fundingAddressTemp = await ldkWallet.openChannel(pubkey, host, fundingAmount.amountSats, isPrivateChannel); @@ -143,7 +143,7 @@ const LdkOpenChannel = (props: any) => { reason += event.reason + ' ' + event.text; } triggerHapticFeedback(HapticFeedbackTypes.NotificationError); - return alert('Initiating channel open failed: ' + reason); + return presentAlert({ message: 'Initiating channel open failed: ' + reason }); } psbtOpenChannelStartedTs.current = +new Date(); @@ -164,7 +164,7 @@ const LdkOpenChannel = (props: any) => { }); } catch (error: any) { triggerHapticFeedback(HapticFeedbackTypes.NotificationError); - alert(error.message); + presentAlert({ message: error.message }); } finally { setIsLoading(false); } diff --git a/screen/lnd/lndCreateInvoice.js b/screen/lnd/lndCreateInvoice.js index 73a931b49..0d87014e1 100644 --- a/screen/lnd/lndCreateInvoice.js +++ b/screen/lnd/lndCreateInvoice.js @@ -25,7 +25,7 @@ import loc, { formatBalance, formatBalanceWithoutSuffix, formatBalancePlain } fr import Lnurl from '../../class/lnurl'; import { BlueStorageContext } from '../../blue_modules/storage-context'; import Notifications from '../../blue_modules/notifications'; -import alert from '../../components/Alert'; +import presentAlert from '../../components/Alert'; import { parse } from 'url'; // eslint-disable-line n/no-deprecated-api import { requestCameraAuthorization } from '../../helpers/scan-qr'; import { useTheme } from '../../components/themes'; @@ -132,7 +132,7 @@ const LNDCreateInvoice = () => { } } else { triggerHapticFeedback(HapticFeedbackTypes.NotificationError); - alert(loc.wallets.add_ln_wallet_first); + presentAlert({ message: loc.wallets.add_ln_wallet_first }); goBack(); } // eslint-disable-next-line react-hooks/exhaustive-deps @@ -180,7 +180,7 @@ const LNDCreateInvoice = () => { : loc.formatString(loc.receive.maxSatsFull, { max, currency: formatBalance(max, unit) }); } triggerHapticFeedback(HapticFeedbackTypes.NotificationError); - alert(text); + presentAlert({ message: text }); setIsLoading(false); return; } @@ -225,7 +225,7 @@ const LNDCreateInvoice = () => { } catch (Err) { triggerHapticFeedback(HapticFeedbackTypes.NotificationError); setIsLoading(false); - alert(Err.message); + presentAlert({ message: Err.message }); } }; @@ -233,7 +233,7 @@ const LNDCreateInvoice = () => { setIsLoading(true); if (!wallet.current) { triggerHapticFeedback(HapticFeedbackTypes.NotificationError); - alert(loc.wallets.no_ln_wallet_error); + presentAlert({ message: loc.wallets.no_ln_wallet_error }); return goBack(); } @@ -308,7 +308,7 @@ const LNDCreateInvoice = () => { Keyboard.dismiss(); setIsLoading(false); triggerHapticFeedback(HapticFeedbackTypes.NotificationError); - alert(Err.message); + presentAlert({ message: Err.message }); } }; diff --git a/screen/lnd/lndViewAdditionalInvoiceInformation.js b/screen/lnd/lndViewAdditionalInvoiceInformation.js index 900183aa2..dda5bcc5c 100644 --- a/screen/lnd/lndViewAdditionalInvoiceInformation.js +++ b/screen/lnd/lndViewAdditionalInvoiceInformation.js @@ -6,7 +6,7 @@ import navigationStyle from '../../components/navigationStyle'; import loc from '../../loc'; import { BlueStorageContext } from '../../blue_modules/storage-context'; import QRCodeComponent from '../../components/QRCodeComponent'; -import alert from '../../components/Alert'; +import presentAlert from '../../components/Alert'; import { useTheme } from '../../components/themes'; import Button from '../../components/Button'; import SafeArea from '../../components/SafeArea'; @@ -36,7 +36,7 @@ const LNDViewAdditionalInvoiceInformation = () => { }) .catch(error => { console.log(error); - alert(loc.errors.network); + presentAlert({ message: loc.errors.network }); goBack(); }); } diff --git a/screen/lnd/lnurlPay.js b/screen/lnd/lnurlPay.js index 62c95a75e..57ac71370 100644 --- a/screen/lnd/lnurlPay.js +++ b/screen/lnd/lnurlPay.js @@ -12,7 +12,7 @@ import { BitcoinUnit, Chain } from '../../models/bitcoinUnits'; import loc, { formatBalanceWithoutSuffix, formatBalance } from '../../loc'; import Biometric from '../../class/biometrics'; import { BlueStorageContext } from '../../blue_modules/storage-context'; -import alert from '../../components/Alert'; +import presentAlert from '../../components/Alert'; import { useTheme } from '../../components/themes'; import Button from '../../components/Button'; import triggerHapticFeedback, { HapticFeedbackTypes } from '../../blue_modules/hapticFeedback'; @@ -62,7 +62,7 @@ const LnurlPay = () => { ln.callLnurlPayService() .then(setPayload) .catch(error => { - alert(error.message); + presentAlert({ message: error.message }); pop(); }); setLN(ln); @@ -81,7 +81,7 @@ const LnurlPay = () => { let originalSatAmount; let newAmount = (originalSatAmount = LN.getMin()); if (!newAmount) { - alert('Internal error: incorrect LNURL amount'); + presentAlert({ message: 'Internal error: incorrect LNURL amount' }); return; } switch (unit) { @@ -163,7 +163,7 @@ const LnurlPay = () => { setIsLoading(false); setPayButtonDisabled(false); triggerHapticFeedback(HapticFeedbackTypes.NotificationError); - return alert(Err.message); + return presentAlert({ message: Err.message }); } }; diff --git a/screen/lnd/scanLndInvoice.js b/screen/lnd/scanLndInvoice.js index a8bd2697f..842d1e620 100644 --- a/screen/lnd/scanLndInvoice.js +++ b/screen/lnd/scanLndInvoice.js @@ -22,7 +22,7 @@ import { BitcoinUnit, Chain } from '../../models/bitcoinUnits'; import Biometric from '../../class/biometrics'; import loc, { formatBalanceWithoutSuffix } from '../../loc'; import { BlueStorageContext } from '../../blue_modules/storage-context'; -import alert from '../../components/Alert'; +import presentAlert from '../../components/Alert'; import { useTheme } from '../../components/themes'; import Button from '../../components/Button'; import triggerHapticFeedback, { HapticFeedbackTypes } from '../../blue_modules/hapticFeedback'; @@ -84,7 +84,7 @@ const ScanLndInvoice = () => { if (!wallet) { triggerHapticFeedback(HapticFeedbackTypes.NotificationError); goBack(); - setTimeout(() => alert(loc.wallets.no_ln_wallet_error), 500); + setTimeout(() => presentAlert({ message: loc.wallets.no_ln_wallet_error }), 500); } // eslint-disable-next-line react-hooks/exhaustive-deps }, [wallet]), @@ -128,7 +128,7 @@ const ScanLndInvoice = () => { triggerHapticFeedback(HapticFeedbackTypes.NotificationError); Keyboard.dismiss(); setParams({ uri: undefined }); - setTimeout(() => alert(Err.message), 10); + setTimeout(() => presentAlert({ message: Err.message }), 10); setIsLoading(false); setAmount(); setDestination(); @@ -194,14 +194,14 @@ const ScanLndInvoice = () => { if (+new Date() > newExpiresIn) { setIsLoading(false); triggerHapticFeedback(HapticFeedbackTypes.NotificationError); - return alert(loc.lnd.errorInvoiceExpired); + return presentAlert({ message: loc.lnd.errorInvoiceExpired }); } const currentUserInvoices = wallet.user_invoices_raw; // not fetching invoices, as we assume they were loaded previously if (currentUserInvoices.some(i => i.payment_hash === decoded.payment_hash)) { setIsLoading(false); triggerHapticFeedback(HapticFeedbackTypes.NotificationError); - return alert(loc.lnd.sameWalletAsInvoiceError); + return presentAlert({ message: loc.lnd.sameWalletAsInvoiceError }); } try { @@ -210,7 +210,7 @@ const ScanLndInvoice = () => { console.log(Err.message); setIsLoading(false); triggerHapticFeedback(HapticFeedbackTypes.NotificationError); - return alert(Err.message); + return presentAlert({ message: Err.message }); } navigate('Success', { diff --git a/screen/plausibledeniability.js b/screen/plausibledeniability.js index 7346adb3b..a36959547 100644 --- a/screen/plausibledeniability.js +++ b/screen/plausibledeniability.js @@ -6,7 +6,7 @@ import navigationStyle from '../components/navigationStyle'; import { BlueLoading, BlueCard, BlueText, BlueSpacing20 } from '../BlueComponents'; import loc from '../loc'; import { BlueStorageContext } from '../blue_modules/storage-context'; -import alert from '../components/Alert'; +import presentAlert from '../components/Alert'; import Button from '../components/Button'; import triggerHapticFeedback, { HapticFeedbackTypes } from '../blue_modules/hapticFeedback'; import SafeArea from '../components/SafeArea'; @@ -25,7 +25,7 @@ const PlausibleDeniability = () => { if (isProvidedPasswordInUse) { setIsLoading(false); triggerHapticFeedback(HapticFeedbackTypes.NotificationError); - return alert(loc.plausibledeniability.password_should_not_match); + return presentAlert({ message: loc.plausibledeniability.password_should_not_match }); } if (!p1) { setIsLoading(false); @@ -35,13 +35,13 @@ const PlausibleDeniability = () => { if (p1 !== p2) { setIsLoading(false); triggerHapticFeedback(HapticFeedbackTypes.NotificationError); - return alert(loc.plausibledeniability.passwords_do_not_match); + return presentAlert({ message: loc.plausibledeniability.passwords_do_not_match }); } await createFakeStorage(p1); await resetWallets(); triggerHapticFeedback(HapticFeedbackTypes.NotificationSuccess); - alert(loc.plausibledeniability.success); + presentAlert({ message: loc.plausibledeniability.success }); popToTop(); } catch { setIsLoading(false); diff --git a/screen/receive/aztecoRedeem.js b/screen/receive/aztecoRedeem.js index 4e82d4938..bf188533b 100644 --- a/screen/receive/aztecoRedeem.js +++ b/screen/receive/aztecoRedeem.js @@ -8,7 +8,7 @@ import { navigationStyleTx } from '../../components/navigationStyle'; import loc from '../../loc'; import Azteco from '../../class/azteco'; import { BlueStorageContext } from '../../blue_modules/storage-context'; -import alert from '../../components/Alert'; +import presentAlert from '../../components/Alert'; import Button from '../../components/Button'; const styles = StyleSheet.create({ @@ -64,7 +64,7 @@ export default class AztecoRedeem extends Component { const wallets = context.wallets; if (wallets.length === 0) { - alert(loc.azteco.errorBeforeRefeem); + presentAlert({ message: loc.azteco.errorBeforeRefeem }); return props.navigation.goBack(null); } else { if (wallets.length > 0) { @@ -97,12 +97,12 @@ export default class AztecoRedeem extends Component { const address = await this.state.toWallet.getAddressAsync(); const result = await Azteco.redeem([this.state.c1, this.state.c2, this.state.c3, this.state.c4], address); if (!result) { - alert(loc.azteco.errorSomething); + presentAlert({ message: loc.azteco.errorSomething }); this.setState({ isLoading: false }); } else { this.props.navigation.pop(); // remote because we want to refetch from server tx list and balance - alert(loc.azteco.success); + presentAlert({ message: loc.azteco.success }); } }; diff --git a/screen/selftest.js b/screen/selftest.js index 791073b00..a07ddc9ad 100644 --- a/screen/selftest.js +++ b/screen/selftest.js @@ -19,7 +19,7 @@ import { import ecc from '../blue_modules/noble_ecc'; import Button from '../components/Button'; import SafeArea from '../components/SafeArea'; -import alert from '../components/Alert'; +import presentAlert from '../components/Alert'; const bitcoin = require('bitcoinjs-lib'); const BlueCrypto = require('react-native-blue-crypto'); const encryption = require('../blue_modules/encryption'); @@ -49,9 +49,9 @@ export default class Selftest extends Component { try { fs.showFilePickerAndReadFile().then(file => { if (file && file.data && file.data.length > 0) { - alert(file.data); + presentAlert({ message: file.data }); } else { - alert('Error reading file'); + presentAlert({ message: 'Error reading file' }); } }); } catch (err) { diff --git a/screen/send/ScanQRCode.js b/screen/send/ScanQRCode.js index 559026eb5..5f91e3c49 100644 --- a/screen/send/ScanQRCode.js +++ b/screen/send/ScanQRCode.js @@ -7,7 +7,7 @@ import { decodeUR, extractSingleWorkload, BlueURDecoder } from '../../blue_modul import { useNavigation, useRoute, useIsFocused } from '@react-navigation/native'; import loc from '../../loc'; import { BlueLoading, BlueText, BlueSpacing40 } from '../../BlueComponents'; -import alert from '../../components/Alert'; +import presentAlert from '../../components/Alert'; import { openPrivacyDesktopSettings } from '../../class/camera'; import { isCameraAuthorizationStatusGranted } from '../../helpers/scan-qr'; import { useTheme } from '../../components/themes'; @@ -288,7 +288,7 @@ const ScanQRCode = () => { if (!error) { onBarCodeRead({ data: result }); } else { - alert(loc.send.qr_error_no_qrcode); + presentAlert({ message: loc.send.qr_error_no_qrcode }); setIsLoading(false); } }); diff --git a/screen/send/broadcast.js b/screen/send/broadcast.js index e661ac0d8..d7581268a 100644 --- a/screen/send/broadcast.js +++ b/screen/send/broadcast.js @@ -1,6 +1,6 @@ import React, { useState } from 'react'; import PropTypes from 'prop-types'; -import { ActivityIndicator, Alert, KeyboardAvoidingView, Linking, StyleSheet, Platform, TextInput, View, Keyboard } from 'react-native'; +import { ActivityIndicator, KeyboardAvoidingView, Linking, StyleSheet, Platform, TextInput, View, Keyboard } from 'react-native'; import { useRoute, useNavigation } from '@react-navigation/native'; import * as bitcoin from 'bitcoinjs-lib'; @@ -22,6 +22,7 @@ import { useTheme } from '../../components/themes'; import Button from '../../components/Button'; import triggerHapticFeedback, { HapticFeedbackTypes } from '../../blue_modules/hapticFeedback'; import SafeArea from '../../components/SafeArea'; +import presentAlert from '../../components/Alert'; const scanqr = require('../../helpers/scan-qr'); @@ -70,7 +71,7 @@ const Broadcast = () => { setBroadcastResult(BROADCAST_RESULT.error); } } catch (error) { - Alert.alert(loc.errors.error, error.message); + presentAlert({ title: loc.errors.error, message: error.message }); triggerHapticFeedback(HapticFeedbackTypes.NotificationError); setBroadcastResult(BROADCAST_RESULT.error); } diff --git a/screen/send/confirm.js b/screen/send/confirm.js index 511bc009a..a4641496f 100644 --- a/screen/send/confirm.js +++ b/screen/send/confirm.js @@ -12,7 +12,7 @@ import loc, { formatBalance, formatBalanceWithoutSuffix } from '../../loc'; import Notifications from '../../blue_modules/notifications'; import { BlueStorageContext } from '../../blue_modules/storage-context'; import { useNavigation, useRoute } from '@react-navigation/native'; -import alert from '../../components/Alert'; +import presentAlert from '../../components/Alert'; import { useTheme } from '../../components/themes'; import Button from '../../components/Button'; import triggerHapticFeedback, { HapticFeedbackTypes } from '../../blue_modules/hapticFeedback'; @@ -155,7 +155,7 @@ const Confirm = () => { } catch (error) { triggerHapticFeedback(HapticFeedbackTypes.NotificationError); setIsLoading(false); - alert(error.message); + presentAlert({ message: error.message }); } }; diff --git a/screen/send/create.js b/screen/send/create.js index 3127da7df..0a8786cd9 100644 --- a/screen/send/create.js +++ b/screen/send/create.js @@ -14,7 +14,7 @@ import loc from '../../loc'; import { DynamicQRCode } from '../../components/DynamicQRCode'; import { isDesktop } from '../../blue_modules/environment'; import { useNavigation, useRoute } from '@react-navigation/native'; -import alert from '../../components/Alert'; +import presentAlert from '../../components/Alert'; import { PERMISSIONS, RESULTS, request } from 'react-native-permissions'; import { useTheme } from '../../components/themes'; import { satoshiToBTC } from '../../blue_modules/currency'; @@ -76,10 +76,10 @@ const SendCreate = () => { const filePath = RNFS.DownloadDirectoryPath + `/${fileName}`; try { await RNFS.writeFile(filePath, tx); - alert(loc.formatString(loc.send.txSaved, { filePath })); + presentAlert({ message: loc.formatString(loc.send.txSaved, { filePath }) }); } catch (e) { console.log(e); - alert(e.message); + presentAlert({ message: e.message }); } } else { console.log('Storage Permission: Denied'); diff --git a/screen/send/details.js b/screen/send/details.js index 900250d3a..4b4f82100 100644 --- a/screen/send/details.js +++ b/screen/send/details.js @@ -45,6 +45,7 @@ import Button from '../../components/Button'; import ListItem from '../../components/ListItem'; import triggerHapticFeedback, { HapticFeedbackTypes } from '../../blue_modules/hapticFeedback'; import { btcToSatoshi, fiatToBTC } from '../../blue_modules/currency'; +import presentAlert from '../../components/Alert'; const prompt = require('../../helpers/prompt'); const fs = require('../../blue_modules/fs'); const btcAddressRx = /^[a-zA-Z0-9]{26,35}$/; @@ -161,7 +162,7 @@ const SendDetails = () => { setPayjoinUrl(pjUrl); } catch (error) { console.log(error); - Alert.alert(loc.errors.error, loc.send.details_error_decode); + presentAlert({ title: loc.errors.error, message: loc.send.details_error_decode }); } } else if (routeParams.address) { const { amount, amountSats, unit = BitcoinUnit.BTC } = routeParams; @@ -191,7 +192,7 @@ const SendDetails = () => { // check if we have a suitable wallet const suitable = wallets.filter(w => w.chain === Chain.ONCHAIN && w.allowSend()); if (suitable.length === 0) { - Alert.alert(loc.errors.error, loc.send.details_wallet_before_tx); + presentAlert({ title: loc.errors.error, message: loc.send.details_wallet_before_tx }); navigation.goBack(); return; } @@ -395,7 +396,7 @@ const SendDetails = () => { if (!data.replace) { // user probably scanned PSBT and got an object instead of string..? setIsLoading(false); - return Alert.alert(loc.errors.error, loc.send.details_address_field_is_not_valid); + return presentAlert({ title: loc.errors.error, message: loc.send.details_address_field_is_not_valid }); } const dataWithoutSchema = data.replace('bitcoin:', '').replace('BITCOIN:', ''); @@ -485,7 +486,7 @@ const SendDetails = () => { if (error) { scrollView.current.scrollToIndex({ index }); setIsLoading(false); - Alert.alert(loc.errors.error, error); + presentAlert({ title: loc.errors.error, message: error.message }); triggerHapticFeedback(HapticFeedbackTypes.NotificationError); return; } @@ -495,7 +496,7 @@ const SendDetails = () => { await createPsbtTransaction(); } catch (Err) { setIsLoading(false); - Alert.alert(loc.errors.error, Err.message); + presentAlert({ title: loc.errors.error, message: Err.message }); triggerHapticFeedback(HapticFeedbackTypes.NotificationError); } }; @@ -600,7 +601,7 @@ const SendDetails = () => { */ const importQrTransaction = () => { if (wallet.type !== WatchOnlyWallet.type) { - return Alert.alert(loc.errors.error, 'Error: importing transaction in non-watchonly wallet (this should never happen)'); + return presentAlert({ title: loc.errors.error, message: 'Importing transaction in non-watchonly wallet (this should never happen)' }); } setOptionsVisible(false); @@ -619,7 +620,7 @@ const SendDetails = () => { navigation.getParent().pop(); if (!ret.data) ret = { data: ret }; if (ret.data.toUpperCase().startsWith('UR')) { - Alert.alert(loc.errors.error, 'BC-UR not decoded. This should never happen'); + presentAlert({ title: loc.errors.error, message: 'BC-UR not decoded. This should never happen' }); } else if (ret.data.indexOf('+') === -1 && ret.data.indexOf('=') === -1 && ret.data.indexOf('=') === -1) { // this looks like NOT base64, so maybe its transaction's hex // we dont support it in this flow @@ -649,7 +650,7 @@ const SendDetails = () => { */ const importTransaction = async () => { if (wallet.type !== WatchOnlyWallet.type) { - return Alert.alert(loc.errors.error, 'Importing transaction in non-watchonly wallet (this should never happen)'); + return presentAlert({ title: loc.errors.error, message: 'Importing transaction in non-watchonly wallet (this should never happen)' }); } try { @@ -692,10 +693,10 @@ const SendDetails = () => { return; } - Alert.alert(loc.errors.error, loc.send.details_unrecognized_file_format); + presentAlert({ title: loc.errors.error, message: loc.send.details_unrecognized_file_format }); } catch (err) { if (!DocumentPicker.isCancel(err)) { - Alert.alert(loc.errors.error, loc.send.details_no_signed_tx); + presentAlert({ title: loc.errors.error, message: loc.send.details_no_signed_tx }); } } }; @@ -742,7 +743,7 @@ const SendDetails = () => { walletID: wallet.getID(), }); } catch (error) { - Alert.alert(loc.send.problem_with_psbt, error.message); + presentAlert({ title: loc.send.problem_with_psbt, message: error.message }); } setIsLoading(false); setOptionsVisible(false); @@ -756,7 +757,7 @@ const SendDetails = () => { navigation.getParent().pop(); if (!ret.data) ret = { data: ret }; if (ret.data.toUpperCase().startsWith('UR')) { - Alert.alert(loc.errors.error, 'BC-UR not decoded. This should never happen'); + presentAlert({ title: loc.errors.error, message: 'BC-UR not decoded. This should never happen' }); } else if (ret.data.indexOf('+') === -1 && ret.data.indexOf('=') === -1 && ret.data.indexOf('=') === -1) { // this looks like NOT base64, so maybe its transaction's hex // we dont support it in this flow @@ -823,7 +824,7 @@ const SendDetails = () => { psbt = bitcoin.Psbt.fromBase64(scannedData); tx = wallet.cosignPsbt(psbt).tx; } catch (e) { - Alert.alert(loc.errors.error, e.message); + presentAlert({ title: loc.errors.error, message: e.message }); return; } finally { setIsLoading(false); diff --git a/screen/send/psbtMultisig.js b/screen/send/psbtMultisig.js index 39bd33bc6..c9a4a5a13 100644 --- a/screen/send/psbtMultisig.js +++ b/screen/send/psbtMultisig.js @@ -8,7 +8,7 @@ import navigationStyle from '../../components/navigationStyle'; import loc from '../../loc'; import { BitcoinUnit } from '../../models/bitcoinUnits'; import { BlueStorageContext } from '../../blue_modules/storage-context'; -import alert from '../../components/Alert'; +import presentAlert from '../../components/Alert'; import { useTheme } from '../../components/themes'; import Button from '../../components/Button'; import SafeArea from '../../components/SafeArea'; @@ -158,7 +158,7 @@ const PsbtMultisig = () => { const newPsbt = psbt.combine(receivedPSBT); setPsbt(newPsbt); } catch (error) { - alert(error); + presentAlert({ message: error }); } }; @@ -186,7 +186,7 @@ const PsbtMultisig = () => { satoshiPerByte, }); } catch (error) { - alert(error); + presentAlert({ message: error }); } }; diff --git a/screen/send/psbtMultisigQRCode.js b/screen/send/psbtMultisigQRCode.js index 710aa8bcd..d35da5435 100644 --- a/screen/send/psbtMultisigQRCode.js +++ b/screen/send/psbtMultisigQRCode.js @@ -9,7 +9,7 @@ import { DynamicQRCode } from '../../components/DynamicQRCode'; import { SquareButton } from '../../components/SquareButton'; import loc from '../../loc'; -import alert from '../../components/Alert'; +import presentAlert from '../../components/Alert'; import { requestCameraAuthorization } from '../../helpers/scan-qr'; import { useTheme } from '../../components/themes'; import SafeArea from '../../components/SafeArea'; @@ -52,11 +52,11 @@ const PsbtMultisigQRCode = () => { const onBarScanned = ret => { if (!ret.data) ret = { data: ret }; if (ret.data.toUpperCase().startsWith('UR')) { - alert('BC-UR not decoded. This should never happen'); + presentAlert({ message: 'BC-UR not decoded. This should never happen' }); } else if (ret.data.indexOf('+') === -1 && ret.data.indexOf('=') === -1 && ret.data.indexOf('=') === -1) { // this looks like NOT base64, so maybe its transaction's hex // we dont support it in this flow - alert(loc.wallets.import_error); + presentAlert({ message: loc.wallets.import_error }); } else { // psbt base64? navigate({ name: 'PsbtMultisig', params: { receivedPSBTBase64: ret.data }, merge: true }); diff --git a/screen/send/psbtWithHardwareWallet.js b/screen/send/psbtWithHardwareWallet.js index ba4591d0d..baedd50d6 100644 --- a/screen/send/psbtWithHardwareWallet.js +++ b/screen/send/psbtWithHardwareWallet.js @@ -12,7 +12,7 @@ import loc from '../../loc'; import { BlueStorageContext } from '../../blue_modules/storage-context'; import Notifications from '../../blue_modules/notifications'; import { DynamicQRCode } from '../../components/DynamicQRCode'; -import alert from '../../components/Alert'; +import presentAlert from '../../components/Alert'; import { requestCameraAuthorization } from '../../helpers/scan-qr'; import { useTheme } from '../../components/themes'; import triggerHapticFeedback, { HapticFeedbackTypes } from '../../blue_modules/hapticFeedback'; @@ -65,7 +65,7 @@ const PsbtWithHardwareWallet = () => { const onBarScanned = ret => { if (ret && !ret.data) ret = { data: ret }; if (ret.data.toUpperCase().startsWith('UR')) { - alert('BC-UR not decoded. This should never happen'); + presentAlert({ message: 'BC-UR not decoded. This should never happen' }); } if (ret.data.indexOf('+') === -1 && ret.data.indexOf('=') === -1 && ret.data.indexOf('=') === -1) { // this looks like NOT base64, so maybe its transaction's hex @@ -83,7 +83,7 @@ const PsbtWithHardwareWallet = () => { // (passed by reference) } } catch (Err) { - alert(Err.message); + presentAlert({ message: Err.message }); } }; @@ -97,7 +97,7 @@ const PsbtWithHardwareWallet = () => { useEffect(() => { if (!psbt && !route.params.txhex) { - alert(loc.send.no_tx_signing_in_progress); + presentAlert({ message: loc.send.no_tx_signing_in_progress }); } if (deepLinkPSBT) { @@ -106,7 +106,7 @@ const PsbtWithHardwareWallet = () => { const Tx = fromWallet.combinePsbt(routeParamsPSBT.current, newPsbt); setTxHex(Tx.toHex()); } catch (Err) { - alert(Err); + presentAlert({ message: Err }); } } else if (routeParamsTXHex) { setTxHex(routeParamsTXHex); @@ -142,12 +142,12 @@ const PsbtWithHardwareWallet = () => { } else { triggerHapticFeedback(HapticFeedbackTypes.NotificationError); setIsLoading(false); - alert(loc.errors.broadcast); + presentAlert({ message: loc.errors.broadcast }); } } catch (error) { triggerHapticFeedback(HapticFeedbackTypes.NotificationError); setIsLoading(false); - alert(error.message); + presentAlert({ message: error.message }); } }; @@ -205,7 +205,7 @@ const PsbtWithHardwareWallet = () => { } } catch (err) { if (!DocumentPicker.isCancel(err)) { - alert(loc.send.details_no_signed_tx); + presentAlert({ message: loc.send.details_no_signed_tx }); } } }; diff --git a/screen/settings/Currency.tsx b/screen/settings/Currency.tsx index 98492c112..429a66bd7 100644 --- a/screen/settings/Currency.tsx +++ b/screen/settings/Currency.tsx @@ -7,7 +7,7 @@ import { FiatUnit, FiatUnitSource, FiatUnitType, getFiatRate } from '../../model import loc from '../../loc'; import { BlueStorageContext } from '../../blue_modules/storage-context'; import dayjs from 'dayjs'; -import alert from '../../components/Alert'; +import presentAlert from '../../components/Alert'; import { useTheme } from '../../components/themes'; import ListItem from '../../components/ListItem'; import { @@ -86,7 +86,9 @@ const Currency: React.FC = () => { setPreferredFiatCurrency(); } catch (error: any) { console.log(error); - alert(error.message ? `${loc.settings.currency_fetch_error}: ${error.message}}` : loc.settings.currency_fetch_error); + presentAlert({ + message: error.message ? `${loc.settings.currency_fetch_error}: ${error.message}}` : loc.settings.currency_fetch_error, + }); } finally { setIsSavingNewPreferredCurrency(false); } diff --git a/screen/settings/about.js b/screen/settings/about.js index bf724ffe2..ba09999e0 100644 --- a/screen/settings/about.js +++ b/screen/settings/about.js @@ -9,7 +9,7 @@ import navigationStyle from '../../components/navigationStyle'; import loc, { formatStringAddTwoWhiteSpaces } from '../../loc'; import Clipboard from '@react-native-clipboard/clipboard'; import { BlueStorageContext } from '../../blue_modules/storage-context'; -import alert from '../../components/Alert'; +import presentAlert from '../../components/Alert'; import { HDSegwitBech32Wallet } from '../../class'; import { useTheme } from '../../components/themes'; import Button from '../../components/Button'; @@ -84,7 +84,7 @@ const About = () => { const handleOnSelfTestPress = () => { if (isElectrumDisabled) { - alert(loc.settings.about_selftest_electrum_disabled); + presentAlert({ message: loc.settings.about_selftest_electrum_disabled }); } else { navigate('Selftest'); } diff --git a/screen/settings/electrumSettings.js b/screen/settings/electrumSettings.js index 572cf15c7..a2e7728e7 100644 --- a/screen/settings/electrumSettings.js +++ b/screen/settings/electrumSettings.js @@ -31,7 +31,7 @@ import { import { BlueCurrentTheme } from '../../components/themes'; import WidgetCommunication from '../../blue_modules/WidgetCommunication'; import { BlueStorageContext } from '../../blue_modules/storage-context'; -import alert from '../../components/Alert'; +import presentAlert from '../../components/Alert'; import { requestCameraAuthorization } from '../../helpers/scan-qr'; import Button from '../../components/Button'; import ListItem from '../../components/ListItem'; @@ -112,7 +112,7 @@ export default class ElectrumSettings extends Component { this.setState({ isLoading: true }, async () => { const features = await BlueElectrum.serverFeatures(); triggerHapticFeedback(HapticFeedbackTypes.NotificationWarning); - alert(JSON.stringify(features, null, 2)); + presentAlert({ message: JSON.stringify(features, null, 2) }); this.setState({ isLoading: false }); }); }; @@ -177,10 +177,10 @@ export default class ElectrumSettings extends Component { console.log(e); } triggerHapticFeedback(HapticFeedbackTypes.NotificationSuccess); - alert(loc.settings.electrum_saved); + presentAlert({ message: loc.settings.electrum_saved }); } else if (!(await BlueElectrum.testConnection(host, port, sslPort))) { triggerHapticFeedback(HapticFeedbackTypes.NotificationError); - alert(loc.settings.electrum_error_connect); + presentAlert({ message: loc.settings.electrum_error_connect }); } else { await AsyncStorage.setItem(BlueElectrum.ELECTRUM_HOST, host); await AsyncStorage.setItem(BlueElectrum.ELECTRUM_TCP_PORT, port); @@ -206,11 +206,11 @@ export default class ElectrumSettings extends Component { console.log(e); } triggerHapticFeedback(HapticFeedbackTypes.NotificationSuccess); - alert(loc.settings.electrum_saved); + presentAlert({ message: loc.settings.electrum_saved }); } } catch (error) { triggerHapticFeedback(HapticFeedbackTypes.NotificationError); - alert(error); + presentAlert({ message: error }); } this.setState({ isLoading: false }); }); diff --git a/screen/settings/encryptStorage.js b/screen/settings/encryptStorage.js index ba389b9c8..acb366f51 100644 --- a/screen/settings/encryptStorage.js +++ b/screen/settings/encryptStorage.js @@ -6,7 +6,7 @@ import { BlueLoading, BlueSpacing20, BlueCard, BlueText } from '../../BlueCompon import Biometric from '../../class/biometrics'; import loc from '../../loc'; import { BlueStorageContext } from '../../blue_modules/storage-context'; -import alert from '../../components/Alert'; +import presentAlert from '../../components/Alert'; import ListItem from '../../components/ListItem'; import triggerHapticFeedback, { HapticFeedbackTypes } from '../../blue_modules/hapticFeedback'; import { useTheme } from '../../components/themes'; @@ -53,7 +53,7 @@ const EncryptStorage = () => { popToTop(); } catch (e) { if (password) { - alert(loc._.bad_password); + presentAlert({ message: loc._.bad_password }); triggerHapticFeedback(HapticFeedbackTypes.NotificationError); } @@ -83,7 +83,7 @@ const EncryptStorage = () => { saveToDisk(); } else { setIsLoading(false); - alert(loc.settings.passwords_do_not_match); + presentAlert({ message: loc.settings.passwords_do_not_match }); } } else { Alert.alert( diff --git a/screen/settings/language.tsx b/screen/settings/language.tsx index f618e02b7..fcb31e56f 100644 --- a/screen/settings/language.tsx +++ b/screen/settings/language.tsx @@ -7,7 +7,7 @@ import navigationStyle from '../../components/navigationStyle'; import loc, { saveLanguage } from '../../loc'; import { AvailableLanguages, TLanguage } from '../../loc/languages'; import { BlueStorageContext } from '../../blue_modules/storage-context'; -import alert from '../../components/Alert'; +import presentAlert from '../../components/Alert'; import { useTheme } from '../../components/themes'; import ListItem from '../../components/ListItem'; @@ -43,7 +43,7 @@ const Language: React.FC = () => { setSelectedLanguage(item.value); setLanguage(); if (currentLanguage?.isRTL !== item.isRTL) { - alert(loc.settings.language_isRTL); + presentAlert({ message: loc.settings.language_isRTL }); } }); }; diff --git a/screen/settings/lightningSettings.tsx b/screen/settings/lightningSettings.tsx index 83b6de432..78f81500b 100644 --- a/screen/settings/lightningSettings.tsx +++ b/screen/settings/lightningSettings.tsx @@ -9,7 +9,7 @@ import { LightningCustodianWallet } from '../../class/wallets/lightning-custodia import loc from '../../loc'; import { useTheme } from '../../components/themes'; import DeeplinkSchemaMatch from '../../class/deeplink-schema-match'; -import alert from '../../components/Alert'; +import presentAlert from '../../components/Alert'; import { requestCameraAuthorization } from '../../helpers/scan-qr'; import { Button } from '../../components/Button'; @@ -107,9 +107,9 @@ const LightningSettings: React.FC & { navigationOptions: NavigationOptionsGetter } else { await AsyncStorage.removeItem(AppStorage.LNDHUB); } - alert(loc.settings.lightning_saved); + presentAlert({ message: loc.settings.lightning_saved }); } catch (error) { - alert(loc.settings.lightning_error_lndhub_uri); + presentAlert({ message: loc.settings.lightning_error_lndhub_uri }); console.log(error); } setIsLoading(false); diff --git a/screen/settings/notificationSettings.js b/screen/settings/notificationSettings.js index 13124d4e6..80d980b09 100644 --- a/screen/settings/notificationSettings.js +++ b/screen/settings/notificationSettings.js @@ -8,7 +8,7 @@ import { BlueCard, BlueCopyToClipboardButton, BlueLoading, BlueSpacing20, BlueTe import loc from '../../loc'; import { BlueCurrentTheme, useTheme } from '../../components/themes'; import Notifications from '../../blue_modules/notifications'; -import alert from '../../components/Alert'; +import presentAlert from '../../components/Alert'; import { Button } from '../../components/Button'; import ListItem from '../../components/ListItem'; @@ -79,13 +79,13 @@ const NotificationSettings = () => { // validating only if its not empty. empty means use default if (await Notifications.isGroundControlUriValid(URI)) { await Notifications.saveUri(URI); - alert(loc.settings.saved); + presentAlert({ message: loc.settings.saved }); } else { - alert(loc.settings.not_a_valid_uri); + presentAlert({ message: loc.settings.not_a_valid_uri }); } } else { await Notifications.saveUri(''); - alert(loc.settings.saved); + presentAlert({ message: loc.settings.saved }); } } catch (error) { console.warn(error); diff --git a/screen/transactions/CPFP.js b/screen/transactions/CPFP.js index 546199133..02f492114 100644 --- a/screen/transactions/CPFP.js +++ b/screen/transactions/CPFP.js @@ -21,7 +21,7 @@ import { HDSegwitBech32Transaction, HDSegwitBech32Wallet } from '../../class'; import loc from '../../loc'; import { BlueStorageContext } from '../../blue_modules/storage-context'; import Notifications from '../../blue_modules/notifications'; -import alert from '../../components/Alert'; +import presentAlert from '../../components/Alert'; import Button from '../../components/Button'; import triggerHapticFeedback, { HapticFeedbackTypes } from '../../blue_modules/hapticFeedback'; import SafeArea from '../../components/SafeArea'; @@ -95,12 +95,12 @@ export default class CPFP extends Component { } else { triggerHapticFeedback(HapticFeedbackTypes.NotificationError); this.setState({ isLoading: false }); - alert(loc.errors.broadcast); + presentAlert({ message: loc.errors.broadcast }); } } catch (error) { triggerHapticFeedback(HapticFeedbackTypes.NotificationError); this.setState({ isLoading: false }); - alert(error.message); + presentAlert({ message: error.message }); } }); }; @@ -154,7 +154,7 @@ export default class CPFP extends Component { this.setState({ isLoading: false }); } catch (_) { this.setState({ isLoading: false }); - alert(loc.errors.error + ': ' + _.message); + presentAlert({ message: loc.errors.error + ': ' + _.message }); } } } diff --git a/screen/transactions/RBFBumpFee.js b/screen/transactions/RBFBumpFee.js index 91d0511b0..6c9dc7620 100644 --- a/screen/transactions/RBFBumpFee.js +++ b/screen/transactions/RBFBumpFee.js @@ -7,7 +7,7 @@ import { HDSegwitBech32Transaction, HDSegwitBech32Wallet } from '../../class'; import CPFP from './CPFP'; import loc from '../../loc'; import { BlueStorageContext } from '../../blue_modules/storage-context'; -import alert from '../../components/Alert'; +import presentAlert from '../../components/Alert'; import SafeArea from '../../components/SafeArea'; const styles = StyleSheet.create({ @@ -57,7 +57,7 @@ export default class RBFBumpFee extends CPFP { this.setState({ isLoading: false }); } catch (_) { this.setState({ isLoading: false }); - alert(loc.errors.error + ': ' + _.message); + presentAlert({ message: loc.errors.error + ': ' + _.message }); } } } diff --git a/screen/transactions/RBFCancel.js b/screen/transactions/RBFCancel.js index 39bc192ba..4550c2f7c 100644 --- a/screen/transactions/RBFCancel.js +++ b/screen/transactions/RBFCancel.js @@ -7,7 +7,7 @@ import { HDSegwitBech32Transaction, HDSegwitBech32Wallet } from '../../class'; import CPFP from './CPFP'; import loc from '../../loc'; import { BlueStorageContext } from '../../blue_modules/storage-context'; -import alert from '../../components/Alert'; +import presentAlert from '../../components/Alert'; import SafeArea from '../../components/SafeArea'; export default class RBFCancel extends CPFP { @@ -55,7 +55,7 @@ export default class RBFCancel extends CPFP { this.setState({ isLoading: false }); } catch (_) { this.setState({ isLoading: false }); - alert(loc.errors.error + ': ' + _.message); + presentAlert({ message: loc.errors.error + ': ' + _.message }); } } } diff --git a/screen/transactions/details.js b/screen/transactions/details.js index d283b0a01..54fdaf2a2 100644 --- a/screen/transactions/details.js +++ b/screen/transactions/details.js @@ -8,7 +8,7 @@ import HandoffComponent from '../../components/handoff'; import loc from '../../loc'; import { BlueStorageContext } from '../../blue_modules/storage-context'; import ToolTipMenu from '../../components/TooltipMenu'; -import alert from '../../components/Alert'; +import presentAlert from '../../components/Alert'; import { useTheme } from '../../components/themes'; const dayjs = require('dayjs'); @@ -113,7 +113,7 @@ const TransactionsDetails = () => { const handleOnSaveButtonTapped = () => { Keyboard.dismiss(); txMetadata[tx.hash] = { memo }; - saveToDisk().then(_success => alert(loc.transactions.transaction_note_saved)); + saveToDisk().then(_success => presentAlert({ message: loc.transactions.transaction_note_saved })); }; const handleOnOpenTransactionOnBlockExporerTapped = () => { @@ -124,17 +124,17 @@ const TransactionsDetails = () => { Linking.openURL(url).catch(e => { console.log('openURL failed in handleOnOpenTransactionOnBlockExporerTapped'); console.log(e.message); - alert(e.message); + presentAlert({ message: e.message }); }); } else { console.log('canOpenURL supported is false in handleOnOpenTransactionOnBlockExporerTapped'); - alert(loc.transactions.open_url_error); + presentAlert({ message: loc.transactions.open_url_error }); } }) .catch(e => { console.log('canOpenURL failed in handleOnOpenTransactionOnBlockExporerTapped'); console.log(e.message); - alert(e.message); + presentAlert({ message: e.message }); }); }; diff --git a/screen/wallets/add.tsx b/screen/wallets/add.tsx index a5f9b6b21..6722df92d 100644 --- a/screen/wallets/add.tsx +++ b/screen/wallets/add.tsx @@ -27,7 +27,7 @@ import { Chain } from '../../models/bitcoinUnits'; import loc from '../../loc'; import { BlueStorageContext } from '../../blue_modules/storage-context'; import { LdkButton } from '../../components/LdkButton'; -import alert from '../../components/Alert'; +import presentAlert from '../../components/Alert'; import useAsyncPromise from '../../hooks/useAsyncPromise'; import { useTheme } from '../../components/themes'; import Button from '../../components/Button'; @@ -240,7 +240,7 @@ const WalletsAdd: React.FC = () => { await w.generateFromEntropy(entropy); } catch (e: any) { console.log(e.toString()); - alert(e.toString()); + presentAlert({ message: e.toString() }); goBack(); return; } @@ -273,7 +273,7 @@ const WalletsAdd: React.FC = () => { const createLightningLdkWallet = async () => { const foundLdk = wallets.find((w: AbstractWallet) => w.type === LightningLdkWallet.type); if (foundLdk) { - return alert('LDK wallet already exists'); + return presentAlert({ message: 'LDK wallet already exists' }); } setIsLoading(true); const wallet = new LightningLdkWallet(); @@ -314,9 +314,9 @@ const WalletsAdd: React.FC = () => { setIsLoading(false); console.warn('lnd create failure', Err); if (Err.message) { - return alert(Err.message); + return presentAlert({ message: Err.message }); } else { - return alert(loc.wallets.add_lndhub_error); + return presentAlert({ message: loc.wallets.add_lndhub_error }); } // giving app, not adding anything } diff --git a/screen/wallets/addMultisigStep2.js b/screen/wallets/addMultisigStep2.js index deba30fe3..9cf124579 100644 --- a/screen/wallets/addMultisigStep2.js +++ b/screen/wallets/addMultisigStep2.js @@ -31,7 +31,7 @@ import MultipleStepsListItem, { import { BlueStorageContext } from '../../blue_modules/storage-context'; import { encodeUR } from '../../blue_modules/ur'; import QRCodeComponent from '../../components/QRCodeComponent'; -import alert from '../../components/Alert'; +import presentAlert from '../../components/Alert'; import confirm from '../../helpers/confirm'; import { scanQrHelper } from '../../helpers/scan-qr'; import { useTheme } from '../../components/themes'; @@ -130,7 +130,7 @@ const WalletsAddMultisigStep2 = () => { await _onCreate(); // this can fail with "Duplicate fingerprint" error or other } catch (e) { setIsLoading(false); - alert(e.message); + presentAlert({ message: e.message }); console.log('create MS wallet error', e); } }; @@ -261,7 +261,7 @@ const WalletsAddMultisigStep2 = () => { setIsLoading(false); setImportText(''); setAskPassphrase(false); - alert(loc.multisig.not_a_multisignature_xpub); + presentAlert({ message: loc.multisig.not_a_multisignature_xpub }); return; } if (fp) { @@ -326,7 +326,7 @@ const WalletsAddMultisigStep2 = () => { hd.setSecret(importText); if (!hd.validateMnemonic()) { setIsLoading(false); - return alert(loc.multisig.invalid_mnemonics); + return presentAlert({ message: loc.multisig.invalid_mnemonics }); } let passphrase; @@ -375,19 +375,19 @@ const WalletsAddMultisigStep2 = () => { } catch (_) {} if (ret.data.toUpperCase().startsWith('UR')) { - alert('BC-UR not decoded. This should never happen'); + presentAlert({ message: 'BC-UR not decoded. This should never happen' }); } else if (isValidMnemonicSeed(ret.data)) { setIsProvideMnemonicsModalVisible(true); setImportText(ret.data); } else { if (MultisigHDWallet.isXpubValid(ret.data) && !MultisigHDWallet.isXpubForMultisig(ret.data)) { - return alert(loc.multisig.not_a_multisignature_xpub); + return presentAlert({ message: loc.multisig.not_a_multisignature_xpub }); } if (MultisigHDWallet.isXpubValid(ret.data)) { return tryUsingXpub(ret.data); } let cosigner = new MultisigCosigner(ret.data); - if (!cosigner.isValid()) return alert(loc.multisig.invalid_cosigner); + if (!cosigner.isValid()) return presentAlert({ message: loc.multisig.invalid_cosigner }); setIsProvideMnemonicsModalVisible(false); if (cosigner.howManyCosignersWeHave() > 1) { // lets look for the correct cosigner. thats probably gona be the one with specific corresponding path, @@ -420,7 +420,7 @@ const WalletsAddMultisigStep2 = () => { } for (const existingCosigner of cosigners) { - if (existingCosigner[0] === cosigner.getXpub()) return alert(loc.multisig.this_cosigner_is_already_imported); + if (existingCosigner[0] === cosigner.getXpub()) return presentAlert({ message: loc.multisig.this_cosigner_is_already_imported }); } // now, validating that cosigner is in correct format: @@ -447,7 +447,7 @@ const WalletsAddMultisigStep2 = () => { throw new Error('This should never happen'); } - if (!correctFormat) return alert(loc.formatString(loc.multisig.invalid_cosigner_format, { format })); + if (!correctFormat) return presentAlert({ message: loc.formatString(loc.multisig.invalid_cosigner_format, { format }) }); const cosignersCopy = [...cosigners]; cosignersCopy.push([cosigner.getXpub(), cosigner.getFp(), cosigner.getPath()]); diff --git a/screen/wallets/details.js b/screen/wallets/details.js index d7cde51a6..a2aaa07e0 100644 --- a/screen/wallets/details.js +++ b/screen/wallets/details.js @@ -39,7 +39,7 @@ import { BlueStorageContext } from '../../blue_modules/storage-context'; import Notifications from '../../blue_modules/notifications'; import { isDesktop } from '../../blue_modules/environment'; import { AbstractHDElectrumWallet } from '../../class/wallets/abstract-hd-electrum-wallet'; -import alert from '../../components/Alert'; +import presentAlert from '../../components/Alert'; import { BitcoinUnit, Chain } from '../../models/bitcoinUnits'; import { writeFileAndExport } from '../../blue_modules/fs'; import { PERMISSIONS, RESULTS, request } from 'react-native-permissions'; @@ -196,7 +196,7 @@ const WalletDetails = () => { } saveToDisk() .then(() => { - alert(loc.wallets.details_wallet_updated); + presentAlert({ message: loc.wallets.details_wallet_updated }); goBack(); }) .catch(error => { @@ -261,7 +261,7 @@ const WalletDetails = () => { } else { triggerHapticFeedback(HapticFeedbackTypes.NotificationError); setIsLoading(false); - alert(loc.wallets.details_del_wb_err); + presentAlert({ message: loc.wallets.details_del_wb_err }); } } catch (_) {} // eslint-disable-next-line react-hooks/exhaustive-deps @@ -359,7 +359,7 @@ const WalletDetails = () => { }) .catch(error => { console.log(error); - alert(error.message); + presentAlert({ message: error.message }); }) .finally(() => { RNFS.unlink(filePath); @@ -371,10 +371,10 @@ const WalletDetails = () => { const filePath = RNFS.DownloadDirectoryPath + `/${fileName}`; try { await RNFS.writeFile(filePath, contents); - alert(loc.formatString(loc.send.txSaved, { filePath: fileName })); + presentAlert({ message: loc.formatString(loc.send.txSaved, { filePath: fileName }) }); } catch (e) { console.log(e); - alert(e.message); + presentAlert({ message: e.message }); } } else { console.log('Storage Permission: Denied'); @@ -400,13 +400,13 @@ const WalletDetails = () => { if (wallet.type === HDSegwitBech32Wallet.type) { wallet._txs_by_external_index = {}; wallet._txs_by_internal_index = {}; - alert(msg); + presentAlert({ message: msg }); } if (wallet._hdWalletInstance) { wallet._hdWalletInstance._txs_by_external_index = {}; wallet._hdWalletInstance._txs_by_internal_index = {}; - alert(msg); + presentAlert({ message: msg }); } }; diff --git a/screen/wallets/importDiscovery.js b/screen/wallets/importDiscovery.js index 7c34ae403..5e0462d0b 100644 --- a/screen/wallets/importDiscovery.js +++ b/screen/wallets/importDiscovery.js @@ -1,5 +1,5 @@ import React, { useContext, useEffect, useState, useRef, useMemo } from 'react'; -import { ActivityIndicator, Alert, FlatList, LayoutAnimation, StyleSheet, View } from 'react-native'; +import { ActivityIndicator, FlatList, LayoutAnimation, StyleSheet, View } from 'react-native'; import IdleTimerManager from 'react-native-idle-timer'; import { useNavigation, useRoute } from '@react-navigation/native'; import { BlueButtonLink, BlueFormLabel, BlueSpacing10, BlueSpacing20 } from '../../BlueComponents'; @@ -14,6 +14,7 @@ import { useTheme } from '../../components/themes'; import Button from '../../components/Button'; import triggerHapticFeedback, { HapticFeedbackTypes } from '../../blue_modules/hapticFeedback'; import SafeArea from '../../components/SafeArea'; +import presentAlert from '../../components/Alert'; const ImportWalletDiscovery = () => { const navigation = useNavigation(); @@ -90,7 +91,7 @@ const ImportWalletDiscovery = () => { }) .catch(e => { console.warn('import error', e); - Alert.alert('import error', e.message); + presentAlert({ title: 'Import error', message: e.message }); }) .finally(() => { LayoutAnimation.configureNext(LayoutAnimation.Presets.easeInEaseOut); diff --git a/screen/wallets/importSpeed.js b/screen/wallets/importSpeed.js index 7a4ab54d4..9b742a991 100644 --- a/screen/wallets/importSpeed.js +++ b/screen/wallets/importSpeed.js @@ -1,5 +1,5 @@ import React, { useContext, useState } from 'react'; -import { Alert, View, StyleSheet, TextInput, ActivityIndicator } from 'react-native'; +import { View, StyleSheet, TextInput, ActivityIndicator } from 'react-native'; import { useNavigation } from '@react-navigation/native'; import { HDSegwitBech32Wallet, WatchOnlyWallet } from '../../class'; import loc from '../../loc'; @@ -9,6 +9,7 @@ import { BlueStorageContext } from '../../blue_modules/storage-context'; import { useTheme } from '../../components/themes'; import Button from '../../components/Button'; import SafeArea from '../../components/SafeArea'; +import presentAlert from '../../components/Alert'; const WalletsImportSpeed = () => { const navigation = useNavigation(); @@ -66,7 +67,7 @@ const WalletsImportSpeed = () => { navigation.getParent().pop(); addAndSaveWallet(wallet); } catch (e) { - Alert.alert(e.message); + presentAlert({ message: e.message }); } finally { setLoading(false); } diff --git a/screen/wallets/ldkViewLogs.js b/screen/wallets/ldkViewLogs.js index cd65b540d..c5d212c6a 100644 --- a/screen/wallets/ldkViewLogs.js +++ b/screen/wallets/ldkViewLogs.js @@ -8,7 +8,7 @@ import navigationStyle from '../../components/navigationStyle'; import { BlueStorageContext } from '../../blue_modules/storage-context'; import loc from '../../loc'; import { LightningLdkWallet } from '../../class'; -import alert from '../../components/Alert'; +import presentAlert from '../../components/Alert'; import { useTheme } from '../../components/themes'; import SafeArea from '../../components/SafeArea'; const fs = require('../../blue_modules/fs'); @@ -75,9 +75,9 @@ const LdkViewLogs = () => { const selfTest = async () => { try { await wallet.selftest(); - alert('ok'); + presentAlert({ message: 'ok' }); } catch (error) { - alert(error.message); + presentAlert({ message: error.message }); } }; diff --git a/screen/wallets/signVerify.js b/screen/wallets/signVerify.js index 8abdc20c8..5bd944381 100644 --- a/screen/wallets/signVerify.js +++ b/screen/wallets/signVerify.js @@ -1,7 +1,6 @@ import React, { useEffect, useState, useContext } from 'react'; import { ActivityIndicator, - Alert, Keyboard, KeyboardAvoidingView, LayoutAnimation, @@ -22,6 +21,7 @@ import loc from '../../loc'; import { useTheme } from '../../components/themes'; import triggerHapticFeedback, { HapticFeedbackTypes } from '../../blue_modules/hapticFeedback'; import SafeArea from '../../components/SafeArea'; +import presentAlert from '../../components/Alert'; const SignVerify = () => { const { colors } = useTheme(); @@ -75,7 +75,7 @@ const SignVerify = () => { setIsShareVisible(true); } catch (e) { triggerHapticFeedback(HapticFeedbackTypes.NotificationError); - Alert.alert(loc.errors.error, e.message); + presentAlert({ title: loc.errors.error, message: e.message }); } setLoading(false); @@ -86,16 +86,16 @@ const SignVerify = () => { await sleep(10); // wait for loading indicator to appear try { const res = wallet.verifyMessage(message, address, signature); - Alert.alert( - res ? loc._.success : loc.errors.error, - res ? loc.addresses.sign_signature_correct : loc.addresses.sign_signature_incorrect, - ); + presentAlert({ + title: res ? loc._.success : loc.errors.error, + message: res ? loc.addresses.sign_signature_correct : loc.addresses.sign_signature_incorrect, + }); if (res) { triggerHapticFeedback(HapticFeedbackTypes.NotificationSuccess); } } catch (e) { triggerHapticFeedback(HapticFeedbackTypes.NotificationError); - Alert.alert(loc.errors.error, e.message); + presentAlert({ title: loc.errors.error, message: e.message }); } setLoading(false); }; diff --git a/screen/wallets/transactions.js b/screen/wallets/transactions.js index 0f09ebcce..ae6af8bcb 100644 --- a/screen/wallets/transactions.js +++ b/screen/wallets/transactions.js @@ -31,7 +31,7 @@ import BlueClipboard from '../../blue_modules/clipboard'; import LNNodeBar from '../../components/LNNodeBar'; import TransactionsNavigationHeader, { actionKeys } from '../../components/TransactionsNavigationHeader'; import { TransactionListItem } from '../../components/TransactionListItem'; -import alert from '../../components/Alert'; +import presentAlert from '../../components/Alert'; import PropTypes from 'prop-types'; import { requestCameraAuthorization } from '../../helpers/scan-qr'; import { useTheme } from '../../components/themes'; @@ -232,7 +232,7 @@ const WalletTransactions = ({ navigation }) => { console.log(wallet.getLabel(), 'fetch tx took', (end - start) / 1000, 'sec'); } catch (err) { noErr = false; - alert(err.message); + presentAlert({ message: err.message }); setIsLoading(false); setTimeElapsed(prev => prev + 1); } @@ -316,7 +316,7 @@ const WalletTransactions = ({ navigation }) => { await wallet.fetchBtcAddress(); toAddress = wallet.refill_addressess[0]; } catch (Err) { - return alert(Err.message); + return presentAlert({ message: Err.message }); } } navigate('SendDetailsRoot', { @@ -476,7 +476,7 @@ const WalletTransactions = ({ navigation }) => { if (id === actionKeys.Refill) { const availableWallets = [...wallets.filter(item => item.chain === Chain.ONCHAIN && item.allowSend())]; if (availableWallets.length === 0) { - alert(loc.lnd.refill_create); + presentAlert({ message: loc.lnd.refill_create }); } else { navigate('SelectWallet', { onWalletSelect, chainType: Chain.ONCHAIN }); } diff --git a/screen/wallets/viewEditMultisigCosigners.tsx b/screen/wallets/viewEditMultisigCosigners.tsx index f977f5eb6..56c1b5c02 100644 --- a/screen/wallets/viewEditMultisigCosigners.tsx +++ b/screen/wallets/viewEditMultisigCosigners.tsx @@ -42,7 +42,7 @@ import Biometric from '../../class/biometrics'; import { SquareButton } from '../../components/SquareButton'; import { encodeUR } from '../../blue_modules/ur'; import QRCodeComponent from '../../components/QRCodeComponent'; -import alert from '../../components/Alert'; +import presentAlert from '../../components/Alert'; import { scanQrHelper } from '../../helpers/scan-qr'; import { useTheme } from '../../components/themes'; import Button from '../../components/Button'; @@ -421,12 +421,12 @@ const ViewEditMultisigCosigners = ({ route }: NativeStackScreenProps