From 162d75166e3331dbdbbf6272c156b15ae4e80544 Mon Sep 17 00:00:00 2001 From: Ovi Trif Date: Fri, 31 May 2024 12:41:58 +0200 Subject: [PATCH] chore(lang): Update copy --- src/components/FactsWidget.tsx | 2 +- src/components/HeadlinesWidget.tsx | 2 +- src/components/SlashtagsProvider.tsx | 6 ++--- src/navigation/bottom-sheet/ForceTransfer.tsx | 2 +- src/screens/Contacts/Contact.tsx | 2 +- src/screens/Lightning/CustomConfirm.tsx | 4 +++- src/screens/Lightning/CustomSetup.tsx | 9 +++----- src/screens/Lightning/QuickSetup.tsx | 4 +++- .../Bitcoin/BitcoinNetworkSelection.tsx | 2 +- .../Settings/Lightning/CloseConnection.tsx | 2 +- src/screens/Settings/WebRelay/index.tsx | 2 +- src/screens/Wallets/Send/Error.tsx | 2 +- src/screens/Wallets/Send/FeeCustom.tsx | 4 ++-- src/screens/Wallets/Send/ReviewAndSend.tsx | 23 ++++++------------- src/store/utils/blocktank.ts | 14 +++++------ src/utils/blocktank/index.ts | 7 +++--- src/utils/i18n/locales/en/lightning.json | 4 ++++ src/utils/i18n/locales/en/other.json | 9 +++++++- src/utils/i18n/locales/en/slashtags.json | 2 +- src/utils/i18n/locales/en/wallet.json | 14 ++++++++--- src/utils/lightning/index.ts | 17 ++++++++++---- src/utils/lnurl.ts | 8 +++++-- src/utils/scanner.ts | 4 ++-- src/utils/slashtags/index.ts | 2 +- src/utils/startup/index.ts | 3 ++- src/utils/wallet/index.ts | 15 +++++++----- src/utils/wallet/transactions.ts | 4 +++- 27 files changed, 100 insertions(+), 69 deletions(-) diff --git a/src/components/FactsWidget.tsx b/src/components/FactsWidget.tsx index 3d8e4c701..6d03e7539 100644 --- a/src/components/FactsWidget.tsx +++ b/src/components/FactsWidget.tsx @@ -46,7 +46,7 @@ const FactsWidget = ({ showToast({ type: 'warning', title: t('widget_error_drive'), - description: `An error occurred: ${error.message}`, + description: t('other:try_again'), }); } }; diff --git a/src/components/HeadlinesWidget.tsx b/src/components/HeadlinesWidget.tsx index 93ce02c6d..dae450550 100644 --- a/src/components/HeadlinesWidget.tsx +++ b/src/components/HeadlinesWidget.tsx @@ -78,7 +78,7 @@ const HeadlinesWidget = ({ showToast({ type: 'warning', title: t('widget_error_drive'), - description: `An error occurred: ${error.message}`, + description: t('other:try_again'), }); } }; diff --git a/src/components/SlashtagsProvider.tsx b/src/components/SlashtagsProvider.tsx index 03f4e098b..ae17ef687 100644 --- a/src/components/SlashtagsProvider.tsx +++ b/src/components/SlashtagsProvider.tsx @@ -13,6 +13,7 @@ import { seedHashSelector } from '../store/reselect/wallet'; import { showToast } from '../utils/notifications'; import { useAppSelector } from '../hooks/redux'; import { webRelaySelector } from '../store/reselect/settings'; +import i18n from '../utils/i18n'; class Store { location: string; @@ -128,9 +129,8 @@ export const SlashtagsProvider = ({ ) { showToast({ type: 'warning', - title: 'Data Connection Issue', - description: - 'An error occurred: Could not load primary key from keychain.', + title: i18n.t('other:error_keychain'), + description: i18n.t('other:error_keychain_msg'), }); return; } diff --git a/src/navigation/bottom-sheet/ForceTransfer.tsx b/src/navigation/bottom-sheet/ForceTransfer.tsx index 9cb6b75cf..56ed4a83d 100644 --- a/src/navigation/bottom-sheet/ForceTransfer.tsx +++ b/src/navigation/bottom-sheet/ForceTransfer.tsx @@ -94,7 +94,7 @@ const ForceTransfer = (): ReactElement => { showToast({ type: 'warning', title: t('close_error'), - description: closeResponse.error.message, + description: t('close_error_msg'), }); setIsPending(false); return; diff --git a/src/screens/Contacts/Contact.tsx b/src/screens/Contacts/Contact.tsx index 2a927c66d..007312be8 100644 --- a/src/screens/Contacts/Contact.tsx +++ b/src/screens/Contacts/Contact.tsx @@ -94,7 +94,7 @@ const Contact = ({ showToast({ type: 'warning', title: t('contact_pay_error'), - description: `An error occurred: ${res.error.message}`, + description: t('other:try_again'), }); } }; diff --git a/src/screens/Lightning/CustomConfirm.tsx b/src/screens/Lightning/CustomConfirm.tsx index 7c757cb76..0a316b5f9 100644 --- a/src/screens/Lightning/CustomConfirm.tsx +++ b/src/screens/Lightning/CustomConfirm.tsx @@ -82,7 +82,9 @@ const CustomConfirm = ({ showToast({ type: 'warning', title: t('error_channel_purchase'), - description: purchaseResponse.error.message, + description: t('error_channel_setup_msg', { + raw: purchaseResponse.error.message, + }), }); return; } diff --git a/src/screens/Lightning/CustomSetup.tsx b/src/screens/Lightning/CustomSetup.tsx index e8d27dff1..f8da5f9a4 100644 --- a/src/screens/Lightning/CustomSetup.tsx +++ b/src/screens/Lightning/CustomSetup.tsx @@ -435,15 +435,12 @@ const CustomSetup = ({ setLoading(false); if (purchaseResponse.isErr()) { let msg = purchaseResponse.error.message; - if (msg.includes('Local channel balance is too small')) { - t('error_channel_receiving', { - usdValue: maxChannelSizeSat, - }); - } showToast({ type: 'warning', title: t('error_channel_purchase'), - description: msg, + description: msg.includes('Local channel balance is too small') + ? t('error_channel_receiving', { usdValue: maxChannelSizeSat }) + : t('error_channel_setup_msg', { raw: msg }), }); } if (purchaseResponse.isOk()) { diff --git a/src/screens/Lightning/QuickSetup.tsx b/src/screens/Lightning/QuickSetup.tsx index 449f3db25..acad6e564 100644 --- a/src/screens/Lightning/QuickSetup.tsx +++ b/src/screens/Lightning/QuickSetup.tsx @@ -172,7 +172,9 @@ const QuickSetup = ({ showToast({ type: 'warning', title: t('error_channel_purchase'), - description: purchaseResponse.error.message, + description: t('error_channel_setup_msg', { + raw: purchaseResponse.error.message, + }), }); return; } diff --git a/src/screens/Settings/Bitcoin/BitcoinNetworkSelection.tsx b/src/screens/Settings/Bitcoin/BitcoinNetworkSelection.tsx index 99afbf23a..dd00c94cf 100644 --- a/src/screens/Settings/Bitcoin/BitcoinNetworkSelection.tsx +++ b/src/screens/Settings/Bitcoin/BitcoinNetworkSelection.tsx @@ -35,7 +35,7 @@ const BitcoinNetworkSelection = ({ showToast({ type: 'error', title: 'Error Switching Networks', - description: switchNetworkRes.error.message, + description: 'Please try again.', }); return; } diff --git a/src/screens/Settings/Lightning/CloseConnection.tsx b/src/screens/Settings/Lightning/CloseConnection.tsx index 9e2788baa..3d667e736 100644 --- a/src/screens/Settings/Lightning/CloseConnection.tsx +++ b/src/screens/Settings/Lightning/CloseConnection.tsx @@ -49,7 +49,7 @@ const CloseConnection = ({ showToast({ type: 'warning', title: t('close_error'), - description: closeResponse.error.message, + description: t('close_error_msg'), }); return; } diff --git a/src/screens/Settings/WebRelay/index.tsx b/src/screens/Settings/WebRelay/index.tsx index 1018a8676..4b399e010 100644 --- a/src/screens/Settings/WebRelay/index.tsx +++ b/src/screens/Settings/WebRelay/index.tsx @@ -109,7 +109,7 @@ const WebRelay = ({ showToast({ type: 'warning', title: t('slashtags:error_saving_profile'), - description: res.error.message, + description: t('other:try_again'), }); }); diff --git a/src/screens/Wallets/Send/Error.tsx b/src/screens/Wallets/Send/Error.tsx index bc3b38be9..03a87f051 100644 --- a/src/screens/Wallets/Send/Error.tsx +++ b/src/screens/Wallets/Send/Error.tsx @@ -78,7 +78,7 @@ const Error = ({ showToast({ type: 'warning', title: t('send_error_contact'), - description: res.error.message, + description: t('other:try_again'), }); return; diff --git a/src/screens/Wallets/Send/FeeCustom.tsx b/src/screens/Wallets/Send/FeeCustom.tsx index 5a63924a9..8c200dad4 100644 --- a/src/screens/Wallets/Send/FeeCustom.tsx +++ b/src/screens/Wallets/Send/FeeCustom.tsx @@ -67,7 +67,7 @@ const FeeCustom = ({ showToast({ type: 'info', title: t('max_possible_fee_rate'), - description: `${maxFee} ${t('sats_per_vbyte')}`, + description: t('max_possible_fee_rate_msg'), }); return; } @@ -75,7 +75,7 @@ const FeeCustom = ({ showToast({ type: 'info', title: t('min_possible_fee_rate'), - description: `${minFee} ${t('sats_per_vbyte')}`, + description: t('min_possible_fee_rate_msg'), }); return; } diff --git a/src/screens/Wallets/Send/ReviewAndSend.tsx b/src/screens/Wallets/Send/ReviewAndSend.tsx index a8b8c1cab..b6004f9dd 100644 --- a/src/screens/Wallets/Send/ReviewAndSend.tsx +++ b/src/screens/Wallets/Send/ReviewAndSend.tsx @@ -182,8 +182,8 @@ const ReviewAndSend = ({ const createLightningTransaction = useCallback(async () => { if (!transaction.lightningInvoice || !decodedInvoice) { - onError(`${t('send_error_create_tx')}. ${t('error_no_invoice')}`); setIsLoading(false); + onError(t('send_error_create_tx')); return; } @@ -230,9 +230,8 @@ const ReviewAndSend = ({ return; } - onError( - `${t('send_error_create_tx')}. ${payInvoiceResponse.error.message}`, - ); + console.error(errorMessage); + onError(t('send_error_create_tx')); return; } @@ -259,25 +258,17 @@ const ReviewAndSend = ({ setIsLoading(true); const transactionIsValid = validateTransaction(transaction); if (transactionIsValid.isErr()) { - setIsLoading(false); - onError( - `${t('send_error_create_tx')}. ${transactionIsValid.error.message}`, - ); - return; + throw Error(transactionIsValid.error.message); } const response = await createTransaction({}); if (response.isErr()) { - setIsLoading(false); - onError(`${t('send_error_create_tx')}. ${response.error.message}`); - return; - } - if (__DEV__) { - console.log(response.value); + throw Error(response.error.message); } setRawTx(response.value); } catch (error) { - onError(`${t('send_error_create_tx')}. ${(error as Error).message}`); setIsLoading(false); + console.error(error.message); + onError(t('send_error_create_tx')); } }, [transaction, onError, t]); diff --git a/src/store/utils/blocktank.ts b/src/store/utils/blocktank.ts index 91a0444a6..3f14ddb30 100644 --- a/src/store/utils/blocktank.ts +++ b/src/store/utils/blocktank.ts @@ -265,7 +265,9 @@ export const startChannelPurchase = async ({ showToast({ type: 'warning', title: i18n.t('other:bt_error_retrieve'), - description: `An error occurred: ${orderData.error.message}`, + description: i18n.t('other:bt_error_retrieve_msg', { + raw: orderData.error.message, + }), }); return err(orderData.error.message); } @@ -336,11 +338,7 @@ export const confirmChannelPurchase = async ({ }): Promise> => { const rawTx = await createTransaction(); if (rawTx.isErr()) { - showToast({ - type: 'warning', - title: i18n.t('wallet:error_create_tx'), - description: rawTx.error.message, - }); + // toast shown from createTransaction return err(rawTx.error.message); } @@ -356,7 +354,9 @@ export const confirmChannelPurchase = async ({ showToast({ type: 'warning', title: i18n.t('wallet:error_broadcast_tx'), - description: broadcastResponse.error.message, + description: i18n.t('wallet:error_broadcast_tx', { + raw: broadcastResponse.error.message, + }), }); return err(broadcastResponse.error.message); } diff --git a/src/utils/blocktank/index.ts b/src/utils/blocktank/index.ts index 860d6dd4c..42d1a97e9 100644 --- a/src/utils/blocktank/index.ts +++ b/src/utils/blocktank/index.ts @@ -24,6 +24,7 @@ import { updateUser } from '../../store/slices/user'; import { setGeoBlock } from '../../store/utils/user'; import { refreshWallet } from '../wallet'; import { __BLOCKTANK_HOST__ } from '../../constants/env'; +import i18n from '../i18n'; const bt = new BlocktankClient(); @@ -86,7 +87,7 @@ export const createOrder = async ({ // Ensure we're properly connected to the Blocktank node prior to buying a channel. const addPeersRes = await addPeers(); if (addPeersRes.isErr()) { - return err('Unable to add Blocktank node as a peer at this time.'); + return err(i18n.t('other:bt_error_connect')); } const buyRes = await bt.createOrder(lspBalance, channelExpiryWeeks, { ...options, @@ -156,7 +157,7 @@ export const createCJitEntry = async ({ // Ensure we're properly connected to the Blocktank node prior to buying a channel. const addPeersRes = await addPeers(); if (addPeersRes.isErr()) { - return err('Unable to add Blocktank node as a peer at this time.'); + return err(i18n.t('other:bt_error_connect')); } const createRes = await bt.createCJitEntry( @@ -171,7 +172,7 @@ export const createCJitEntry = async ({ return ok(createRes); } catch (e) { console.log(e); - return err(e); + return err(i18n.t('wallet:receive_cjit_error_msg', { raw: e })); } }; diff --git a/src/utils/i18n/locales/en/lightning.json b/src/utils/i18n/locales/en/lightning.json index 233579810..4f5bf4434 100644 --- a/src/utils/i18n/locales/en/lightning.json +++ b/src/utils/i18n/locales/en/lightning.json @@ -38,6 +38,7 @@ "continue": "Try Again" }, "error_channel_purchase": "Instant Payments Setup Failed", + "error_channel_setup_msg": "An error occurred when setting up your instant balance. {raw}", "error_channel_receiving": "Receiving amount needs to be greater than ${usdValue}", "enter_money": "Enter the amount of bitcoin you want to be able to spend instantly.", "spending": "Spending", @@ -96,6 +97,8 @@ "error_invoice": "Failed to Create Invoice", "error_add_title": "Unable To Add Lightning Peer", "error_add": "Bitkit could not add the Lightning peer.", + "error_add_raw": "An error occured while we added lightning peer: {raw}", + "error_add_uri": "The URI appears to be invalid.", "error_add_tor": "Bitkit cannot add tor nodes.", "error_save_title": "Unable To Save Lightning Peer", "error_save": "Unable to save lightning peer", @@ -126,6 +129,7 @@ }, "close_conn": "Close Connection", "close_error": "Transfer Failed", + "close_error_msg": "Unable to transfer your funds back to savings. Please try again.", "close_success_title": "Transfer Initiated", "close_success_msg": "Your funds are being transferred back to your savings.", "close_text": "The fee to close this Lightning Connection and transfer your funds back to your savings depends on network conditions.\n\nFunds transfer to savings is usually instant, but settlement may take up to 14 days under certain network conditions.", diff --git a/src/utils/i18n/locales/en/other.json b/src/utils/i18n/locales/en/other.json index 0e2a8f0fb..5cb54a295 100644 --- a/src/utils/i18n/locales/en/other.json +++ b/src/utils/i18n/locales/en/other.json @@ -13,6 +13,8 @@ "buy_header": "Buy some\nBitcoin", "buy_text": "Don’t have any Bitcoin or need more?", "buy_button": "Choose exchange", + "error_keychain": "Data Connection Issue", + "error_keychain_msg": "An error occured: Could not load primaryKey.", "connection_restored_title": "Electrum Connection Restored", "connection_restored_message": "Bitkit successfully reconnected to Electrum.", "connection_issue": "Internet Connectivity Issues", @@ -54,6 +56,7 @@ "lnurl_ln_error_msg": "Could not start local Lightning node. Please try again or restart Bitkit.", "lnurl_pay_error_no_capacity": "Not enough outbound/sending capacity to complete lnurl-pay request.", "lnurl_channel_error": "Unable To Open Channel (LNURL)", + "lnurl_channel_error_raw": "An error occured when you tried paying: {raw}", "lnurl_channel_header": "Lightning Connection", "lnurl_channel_title": "New\nlightning\nconnection", "lnurl_channel_message": "Do you want open a Lightning connection with this Lightning Service Provider?", @@ -68,6 +71,7 @@ "lnurl_channel_success_msg_peer": "Successfully requested channel from: {peer}", "lnurl_channel_success_msg_no_peer": "Successfully requested channel.", "lnurl_auth_error": "Sign In Failed (LNURL)", + "lnurl_auth_error_msg": "An error occurred when you attempted to sign in. {raw}", "lnurl_auth_success_title": "Signed In", "lnurl_auth_success_msg_domain": "You successfully signed in to {domain}.", "lnurl_auth_success_msg_no_domain": "You successfully signed in.", @@ -80,10 +84,13 @@ "lnurl_withdr_success_msg": "Your withdraw was successfully requested.", "phone_settings": "Open Phone Settings", "bt_error_retrieve": "Transfer Failed", + "bt_error_connect": "Unable to add LSP node as a peer at this time.", + "bt_error_retrieve_msg": "An error occurred when moving funds. {raw}", "bt_channel_purchase_cost_error": "You need {delta} more to complete this transaction.", "earlier": "EARLIER", "update_nav_title": "Update Available", "update_title": "Update\nBitkit", "update_text": "Please update Bitkit to the latest version for new features and bug fixes!", - "update_button": "Update" + "update_button": "Update", + "try_again" : "Please try again." } diff --git a/src/utils/i18n/locales/en/slashtags.json b/src/utils/i18n/locales/en/slashtags.json index c6c683d61..e6b00fa24 100644 --- a/src/utils/i18n/locales/en/slashtags.json +++ b/src/utils/i18n/locales/en/slashtags.json @@ -79,7 +79,7 @@ "error_saving_contact": "Unable To Save Contact", "error_saving_profile": "Unable To Save Profile", "error_pay_title": "Unable To Pay Contact", - "error_pay_empty_msg": "There is no payment data available for this contact.", + "error_pay_empty_msg": "This contact has no payment data.", "auth_depricated_title": "Deprecated", "auth_depricated_msg": "Slashauth is deprecated. Please use Bitkit Beta." } diff --git a/src/utils/i18n/locales/en/wallet.json b/src/utils/i18n/locales/en/wallet.json index b3d259da8..a49209653 100644 --- a/src/utils/i18n/locales/en/wallet.json +++ b/src/utils/i18n/locales/en/wallet.json @@ -3,6 +3,8 @@ "receive": "Receive", "balance_total": "Total balance", "balance_total_pending": "Total balance ( pending)", + "create_wallet_error": "Please reopen the app and try again.", + "create_wallet_existing_error": "Wallet \"{walletName}\" already exists.", "create_wallet_mnemonic_error": "Invalid recovery phrase.", "create_wallet_mnemonic_restore_error": "Please double-check if your recovery phrase is accurate.", "send_bitcoin": "Send Bitcoin", @@ -39,7 +41,7 @@ "send_error_slash_ln": "Unfortunately contact could not be paid instantly. You can try a regular payment (more expensive, slower).", "send_error_tx_failed": "Transaction Failed", "send_error_contact": "Unable To Pay to this contact", - "send_error_create_tx": "Error creating transaction", + "send_error_create_tx": "Unable to broadcast the transaction. Please try again.", "tag_remove_error_title": "Removing Tag Failed", "tag_remove_error_description": "Bitkit was unable to find the transaction data.", "error_no_invoice": "No lightning invoice found.", @@ -54,8 +56,10 @@ "send_fee_and_speed": "Speed and fee", "send_fee_speed": "Speed", "send_fee_error": "Fee Invalid", - "max_possible_fee_rate": "Max possible fee rate", - "min_possible_fee_rate": "Min possible fee rate", + "max_possible_fee_rate": "Fee Exceeds Maximum Limit", + "max_possible_fee_rate_msg": "Lower the custom fee and try again.", + "min_possible_fee_rate": "Fee Misses Minimum Limit", + "min_possible_fee_rate_msg": "Increase the custom fee and try again.", "sats_per_vbyte": "sats/vbyte", "send_output_to_small_title": "Send Amount Too Small", "send_output_to_small_description": "Please increase your send amount to proceed.", @@ -97,6 +101,7 @@ "receive_connect_initial": "To set up your spending balance, a {lspFee} service provider fee will be deducted.", "receive_connect_additional": "To receive more instant Bitcoin, Bitkit has to increase your liquidity. A {lspFee} service provider fee will be deducted from the amount you specified.", "receive_cjit_error": "CJIT Error", + "receive_cjit_error_msg": "Failed to send funds to your spending account. {raw}", "receive_will": "You will receive", "minimum": "MINIMUM", "activity": "Activity", @@ -185,7 +190,9 @@ "payment_received": "Received Bitcoin", "instant_payment_received": "Received Instant Bitcoin", "error_create_tx": "Transaction Creation Failed", + "error_create_tx_msg": "An error occurred. Please try again {raw}", "error_broadcast_tx": "Transaction Broadcast Failed", + "error_broadcast_tx_msg": "An error occurred when broadcasting your transaction. {raw}", "error_broadcast_tx_connection": "Please check your connection and try again.\n{message}", "filter_title": "Select Range", "filter_clear": "Clear", @@ -206,6 +213,7 @@ "balance_unit_switched_title": "Switched to {unit}", "balance_unit_switched_message": "Tap your wallet balance to switch it back to {unit}.", "refresh_error_title": "Refresh Failed", + "refresh_error_msg": "An error occurred and couldn't refresh the wallet. Please try again.", "refresh_error_throttle_title": "Connection Throttled", "refresh_error_throttle_description": "Electrum server connection is throttled. Please wait several minutes before trying again.", "ldk_sync_error_title": "Lightning Sync Error", diff --git a/src/utils/lightning/index.ts b/src/utils/lightning/index.ts index aed19c376..c2d182d42 100644 --- a/src/utils/lightning/index.ts +++ b/src/utils/lightning/index.ts @@ -661,7 +661,7 @@ export const refreshLdk = async ({ showToast({ type: 'error', title: i18n.t('wallet:ldk_sync_error_title'), - description: syncResult.error.message, + description: i18n.t('other:try_again'), }); return handleRefreshError(syncResult.error.message); } @@ -1034,11 +1034,11 @@ export const parseUri = ( const uri = str.split('@'); const publicKey = uri[0]; if (uri.length !== 2) { - return err('The URI appears to be invalid.'); + return err(i18n.t('lightning:error_add_uri')); } const parsed = uri[1].split(':'); if (parsed.length < 2) { - return err('The URI appears to be invalid.'); + return err(i18n.t('lightning:error_add_uri')); } const ip = parsed[0]; const port = Number(parsed[1]); @@ -1065,12 +1065,21 @@ export const addPeer = async ({ if (parsedUri.isErr()) { return err(parsedUri.error.message); } - return await lm.addPeer({ + + const res = await lm.addPeer({ pubKey: parsedUri.value.publicKey, address: parsedUri.value.ip, port: parsedUri.value.port, timeout, }); + + if (res.isErr()) { + res.error.message = i18n.t('lightning:error_add_msg', { + raw: res.error.message, + }); + } + + return res; }; /** diff --git a/src/utils/lnurl.ts b/src/utils/lnurl.ts index af97f8f78..6398a4676 100644 --- a/src/utils/lnurl.ts +++ b/src/utils/lnurl.ts @@ -191,7 +191,9 @@ export const handleLnurlChannel = async ({ showToast({ type: 'warning', title: i18n.t('other:lnurl_channel_error'), - description: `An error occurred: ${callbackRes.error.message}`, + description: i18n.t('other:lnurl_channel_error', { + raw: callbackRes.error.message, + }), }); return err(callbackRes.error.message); } @@ -259,7 +261,9 @@ export const handleLnurlAuth = async ({ showToast({ type: 'warning', title: i18n.t('other:lnurl_auth_error'), - description: `An error occurred: ${authRes.error.message}`, + description: i18n.t('other:lnurl_auth_error_msg', { + raw: authRes.error.message, + }), }); return err(authRes.error.message); } diff --git a/src/utils/scanner.ts b/src/utils/scanner.ts index 2fd17cadf..704a6d896 100644 --- a/src/utils/scanner.ts +++ b/src/utils/scanner.ts @@ -270,7 +270,7 @@ export const processInputData = async ({ showToast({ type: 'warning', title: i18n.t('slashtags:error_pay_title'), - description: `An error occurred: ${response.error.message}`, + description: i18n.t('other:try_again'), }); } return err(response.error.message); @@ -1107,7 +1107,7 @@ export const validateInputData = async ({ showToast({ type: 'warning', title: i18n.t('slashtags:error_pay_title'), - description: `An error occurred: ${errorMessage}`, + description: i18n.t('other:try_again'), }); } return err(errorMessage); diff --git a/src/utils/slashtags/index.ts b/src/utils/slashtags/index.ts index e103f0dad..24d4c6456 100644 --- a/src/utils/slashtags/index.ts +++ b/src/utils/slashtags/index.ts @@ -62,7 +62,7 @@ export const saveProfile = async ( showToast({ type: 'warning', title: i18n.t('slashtags:error_saving_contact'), - description: `An error occurred: ${e.message}`, + description: i18n.t('other:try_again'), }); return err(e); } diff --git a/src/utils/startup/index.ts b/src/utils/startup/index.ts index eab73ebae..434a251a0 100644 --- a/src/utils/startup/index.ts +++ b/src/utils/startup/index.ts @@ -25,6 +25,7 @@ import { EAvailableNetwork } from '../networks'; import { TWalletName } from '../../store/types/wallet'; import { runChecks } from '../wallet/checks'; import { setupLedger, syncLedger } from '../ledger'; +import i18n from '../i18n'; /** * Creates a new wallet from scratch @@ -41,7 +42,7 @@ export const createNewWallet = async ({ } const createRes = await createWallet({ mnemonic, bip39Passphrase }); if (createRes.isErr()) { - return err(createRes.error.message); + return err(i18n.t('wallet:create_wallet_error')); } return ok('Wallet created'); }; diff --git a/src/utils/wallet/index.ts b/src/utils/wallet/index.ts index a062b0814..817ef296a 100644 --- a/src/utils/wallet/index.ts +++ b/src/utils/wallet/index.ts @@ -226,11 +226,10 @@ const handleRefreshError = (msg): void => { }); dispatch(updateUi({ isElectrumThrottled: true })); } else { - // If the error is not due to the batch limit, show a toast with the error message. showToast({ type: 'warning', title: i18n.t('wallet:refresh_error_title'), - description: msg, + description: i18n.t('wallet:refresh_error_msg'), }); } }; @@ -879,14 +878,17 @@ export const createDefaultWallet = async ({ const wallets = getWalletStore().wallets; if (walletName in wallets && wallets[walletName]?.id) { - return err(`Wallet "${walletName}" already exists.`); + const msg = i18n.t('wallet:create_wallet_existing_error', { walletName }); + console.error(msg); + return err(msg); } if (!validateMnemonic(mnemonic)) { + let msg = i18n.t('wallet:create_wallet_mnemonic_error'); if (restore) { - return err(i18n.t('wallet:create_wallet_mnemonic_restore_error')); - } else { - return err(i18n.t('wallet:create_wallet_mnemonic_error')); + msg = i18n.t('wallet:create_wallet_mnemonic_restore_error'); } + console.error(msg); + return err(msg); } await setKeychainValue({ key: walletName, value: mnemonic }); await setKeychainValue({ @@ -1627,6 +1629,7 @@ export const switchNetwork = async ( ); if (response.isErr()) { updateWallet({ selectedNetwork: originalNetwork }); + console.error(response.error.message); return err(response.error.message); } wallet = response.value; diff --git a/src/utils/wallet/transactions.ts b/src/utils/wallet/transactions.ts index d6201d562..97fe5e6d0 100644 --- a/src/utils/wallet/transactions.ts +++ b/src/utils/wallet/transactions.ts @@ -153,7 +153,9 @@ export const createTransaction = async ({ showToast({ type: 'warning', title: i18n.t('wallet:error_create_tx'), - description: createTxRes.error.message, + description: i18n.t('wallet:error_create_tx_msg', { + raw: createTxRes.error.message, + }), }); return err(createTxRes.error.message); }