From c1cd6dc515bc3c486d20cd1b3657265f3566897e Mon Sep 17 00:00:00 2001 From: Paul Puey Date: Tue, 13 Aug 2024 16:50:15 -0700 Subject: [PATCH 1/3] Add more disableSwaps checks --- src/actions/DeepLinkingActions.tsx | 41 +++++++++++----- src/actions/ScanActions.tsx | 49 +++++++++++++------ .../modals/InsufficientFeesModal.tsx | 22 +++++++-- src/locales/en_US.ts | 3 ++ src/locales/strings/enUS.json | 3 ++ 5 files changed, 85 insertions(+), 33 deletions(-) diff --git a/src/actions/DeepLinkingActions.tsx b/src/actions/DeepLinkingActions.tsx index 9a2d0d65abf..82d713c41b1 100644 --- a/src/actions/DeepLinkingActions.tsx +++ b/src/actions/DeepLinkingActions.tsx @@ -9,6 +9,7 @@ import { Airship, showError, showToast, showToastSpinner } from '../components/s import { guiPlugins } from '../constants/plugins/GuiPlugins' import { lstrings } from '../locales/strings' import { executePlugin, fiatProviderDeeplinkHandler } from '../plugins/gui/fiatPlugin' +import { config } from '../theme/appConfig' import { DeepLink } from '../types/DeepLinkTypes' import { Dispatch, RootState, ThunkAction } from '../types/reduxTypes' import { NavigationBase } from '../types/routerTypes' @@ -179,19 +180,33 @@ async function handleLink(navigation: NavigationBase, dispatch: Dispatch, state: case 'price-change': { const { pluginId, body } = link const currencyCode = account.currencyConfig[pluginId].currencyInfo.currencyCode - - const result = await Airship.show<'buy' | 'sell' | 'exchange' | undefined>(bridge => ( - - )) + let result + if (config.disableSwaps === true) { + result = await Airship.show<'buy' | 'sell' | undefined>(bridge => ( + + )) + } else { + result = await Airship.show<'buy' | 'sell' | 'exchange' | undefined>(bridge => ( + + )) + } if (result === 'buy') { navigation.navigate('buyTab', { screen: 'pluginListBuy' }) diff --git a/src/actions/ScanActions.tsx b/src/actions/ScanActions.tsx index c435be6c7ca..d87a6b10920 100644 --- a/src/actions/ScanActions.tsx +++ b/src/actions/ScanActions.tsx @@ -7,7 +7,7 @@ import URL from 'url-parse' import { ButtonsModal } from '../components/modals/ButtonsModal' import { ConfirmContinueModal } from '../components/modals/ConfirmContinueModal' import { WalletListModal, WalletListResult } from '../components/modals/WalletListModal' -import { Airship, showError, showWarning } from '../components/services/AirshipInstance' +import { Airship, showDevError, showError, showWarning } from '../components/services/AirshipInstance' import { getSpecialCurrencyInfo } from '../constants/WalletAndCurrencyConstants' import { lstrings } from '../locales/strings' import { getExchangeRate } from '../selectors/WalletSelectors' @@ -351,19 +351,34 @@ export function checkAndShowGetCryptoModal(navigation: NavigationBase, wallet: E let threeButtonModal const { displayBuyCrypto } = getSpecialCurrencyInfo(wallet.currencyInfo.pluginId) if (displayBuyCrypto) { - const messageSyntax = sprintf(lstrings.buy_crypto_modal_message, currencyCode, currencyCode, currencyCode) - threeButtonModal = await Airship.show<'buy' | 'exchange' | 'decline' | undefined>(bridge => ( - - )) + if (config.disableSwaps === true) { + const messageSyntax = sprintf(lstrings.buy_crypto_modal_message_no_exchange_s, currencyCode, currencyCode) + threeButtonModal = await Airship.show<'buy' | 'decline' | undefined>(bridge => ( + + )) + } else { + const messageSyntax = sprintf(lstrings.buy_crypto_modal_message, currencyCode, currencyCode, currencyCode) + threeButtonModal = await Airship.show<'buy' | 'exchange' | 'decline' | undefined>(bridge => ( + + )) + } } else { // if we're not targetting for buying, but rather exchange const messageSyntax = sprintf(lstrings.exchange_crypto_modal_message, currencyCode, currencyCode, currencyCode) @@ -382,7 +397,11 @@ export function checkAndShowGetCryptoModal(navigation: NavigationBase, wallet: E if (threeButtonModal === 'buy') { navigation.navigate('buyTab', { screen: 'pluginListBuy' }) } else if (threeButtonModal === 'exchange') { - navigation.navigate('swapTab', { screen: 'swapCreate', params: { toWalletId: wallet.id, toTokenId: tokenId } }) + if (config.disableSwaps === true) { + showDevError('Swaps are disabled. Cannot navigate to exchange.') + } else { + navigation.navigate('swapTab', { screen: 'swapCreate', params: { toWalletId: wallet.id, toTokenId: tokenId } }) + } } } catch (e: any) { // Don't bother the user with this error, but log it quietly: diff --git a/src/components/modals/InsufficientFeesModal.tsx b/src/components/modals/InsufficientFeesModal.tsx index abea64b8aec..9423fe6fffd 100644 --- a/src/components/modals/InsufficientFeesModal.tsx +++ b/src/components/modals/InsufficientFeesModal.tsx @@ -6,6 +6,7 @@ import { sprintf } from 'sprintf-js' import { useDisplayDenom } from '../../hooks/useDisplayDenom' import { useHandler } from '../../hooks/useHandler' import { lstrings } from '../../locales/strings' +import { config } from '../../theme/appConfig' import { NavigationBase } from '../../types/routerTypes' import { getCurrencyCode } from '../../util/CurrencyInfoHelpers' import { getUkCompliantString } from '../../util/ukComplianceUtils' @@ -52,17 +53,28 @@ export function InsufficientFeesModal(props: Props) { // Give extra information about the network name like Base or Arbitrum where // the mainnet token is ETH but the network is not Ethereum. - const message = - currencyCode === 'ETH' && wallet.currencyInfo.pluginId !== 'ethereum' - ? sprintf(lstrings.buy_parent_crypto_modal_message_3s, amountString, denomName, wallet.currencyInfo.displayName) - : sprintf(lstrings.buy_parent_crypto_modal_message_2s, amountString, denomName) + let message: string + let secondary + if (config.disableSwaps === true) { + secondary = undefined + message = + currencyCode === 'ETH' && wallet.currencyInfo.pluginId !== 'ethereum' + ? sprintf(lstrings.buy_parent_crypto_modal_message_no_exchange_3s, amountString, denomName, wallet.currencyInfo.displayName) + : sprintf(lstrings.buy_parent_crypto_modal_message_no_exchange_2s, amountString, denomName) + } else { + secondary = { label: lstrings.buy_crypto_modal_exchange, onPress: handleSwap } + message = + currencyCode === 'ETH' && wallet.currencyInfo.pluginId !== 'ethereum' + ? sprintf(lstrings.buy_parent_crypto_modal_message_3s, amountString, denomName, wallet.currencyInfo.displayName) + : sprintf(lstrings.buy_parent_crypto_modal_message_2s, amountString, denomName) + } return ( {message} diff --git a/src/locales/en_US.ts b/src/locales/en_US.ts index 431bfec3556..5a1af9f2f85 100644 --- a/src/locales/en_US.ts +++ b/src/locales/en_US.ts @@ -831,9 +831,12 @@ const strings = { buy_crypto_modal_title: 'Wallet Empty', buy_crypto_modal_message: 'Your %s wallet is empty. Would you like to buy %s or exchange another crypto into %s?', + buy_crypto_modal_message_no_exchange_s: 'Your %s wallet is empty. Would you like to buy %s?', buy_parent_crypto_modal_message_2s: '%1$s%2$s is required to send this transaction. Would you like to buy %2$s or exchange another crypto into %2$s?', buy_parent_crypto_modal_message_3s: '%1$s%2$s (on %3$s) is required to send this transaction. Would you like to buy %2$s or exchange another crypto into %2$s?', + buy_parent_crypto_modal_message_no_exchange_2s: '%1$s%2$s is required to send this transaction. Would you like to buy %2$s?', + buy_parent_crypto_modal_message_no_exchange_3s: '%1$s%2$s (on %3$s) is required to send this transaction. Would you like to buy %2$s?', buy_crypto_decline: 'Not at this time', buy_1s: 'Buy %1$s', sell_1s: 'Sell %1$s', diff --git a/src/locales/strings/enUS.json b/src/locales/strings/enUS.json index 533f4e62b85..fb1744ad917 100644 --- a/src/locales/strings/enUS.json +++ b/src/locales/strings/enUS.json @@ -743,8 +743,11 @@ "password": "Password", "buy_crypto_modal_title": "Wallet Empty", "buy_crypto_modal_message": "Your %s wallet is empty. Would you like to buy %s or exchange another crypto into %s?", + "buy_crypto_modal_message_no_exchange_s": "Your %s wallet is empty. Would you like to buy %s?", "buy_parent_crypto_modal_message_2s": "%1$s%2$s is required to send this transaction. Would you like to buy %2$s or exchange another crypto into %2$s?", "buy_parent_crypto_modal_message_3s": "%1$s%2$s (on %3$s) is required to send this transaction. Would you like to buy %2$s or exchange another crypto into %2$s?", + "buy_parent_crypto_modal_message_no_exchange_2s": "%1$s%2$s is required to send this transaction. Would you like to buy %2$s?", + "buy_parent_crypto_modal_message_no_exchange_3s": "%1$s%2$s (on %3$s) is required to send this transaction. Would you like to buy %2$s?", "buy_crypto_decline": "Not at this time", "buy_1s": "Buy %1$s", "sell_1s": "Sell %1$s", From 7b9f766ff051766c6cd2961c5a32a7a23367842a Mon Sep 17 00:00:00 2001 From: Paul Puey Date: Fri, 1 Nov 2024 18:34:03 -0700 Subject: [PATCH 2/3] Remove location permission for coinhub widget --- src/constants/plugins/GuiPlugins.ts | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/constants/plugins/GuiPlugins.ts b/src/constants/plugins/GuiPlugins.ts index ddf78a2c131..fcd0341b9f1 100644 --- a/src/constants/plugins/GuiPlugins.ts +++ b/src/constants/plugins/GuiPlugins.ts @@ -253,9 +253,8 @@ export const guiPlugins: { [pluginId: string]: GuiPlugin } = { coinhub: { pluginId: 'coinhub', storeId: 'coinhub', - baseUri: 'https://coinhubatm.app', - displayName: 'Coinhub ATMs', - permissions: ['location'] + baseUri: 'https://coinhubbitcoinwallet.app', + displayName: 'Coinhub ATMs' }, custom: { pluginId: 'custom', From c48f22bb55804a141e672645cb639b15df0f0e0d Mon Sep 17 00:00:00 2001 From: Paul Puey Date: Fri, 1 Nov 2024 18:30:13 -0700 Subject: [PATCH 3/3] Remove FIO from side menu if disabled --- src/components/themed/SideMenu.tsx | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/components/themed/SideMenu.tsx b/src/components/themed/SideMenu.tsx index d1d9d5d7169..232f0c26131 100644 --- a/src/components/themed/SideMenu.tsx +++ b/src/components/themed/SideMenu.tsx @@ -272,6 +272,14 @@ export function SideMenu(props: DrawerContentComponentProps) { } ] + if (ENV.FIO_INIT == null || ENV.FIO_INIT === false) { + // Remove FIO rows + let index = rowDatas.findIndex(row => row.title === lstrings.drawer_fio_names) + if (index >= 0) rowDatas.splice(index, 1) + index = rowDatas.findIndex(row => row.title === lstrings.drawer_fio_requests) + if (index >= 0) rowDatas.splice(index, 1) + } + if (ENV.ENABLE_VISA_PROGRAM && IONIA_SUPPORTED_FIATS.includes(defaultFiat)) { rowDatas.unshift({ pressHandler: () => {