Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Paul/coinhub fixes2 #5341

Merged
merged 3 commits into from
Nov 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 28 additions & 13 deletions src/actions/DeepLinkingActions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -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 => (
<ButtonsModal
bridge={bridge}
title={lstrings.price_change_notification}
message={`${body} ${sprintf(lstrings.price_change_buy_sell_trade, currencyCode)}`}
buttons={{
buy: { label: lstrings.title_buy, type: 'secondary' },
sell: { label: lstrings.title_sell },
exchange: { label: lstrings.buy_crypto_modal_exchange }
}}
/>
))
let result
if (config.disableSwaps === true) {
result = await Airship.show<'buy' | 'sell' | undefined>(bridge => (
<ButtonsModal
bridge={bridge}
title={lstrings.price_change_notification}
message={`${body} ${sprintf(lstrings.price_change_buy_sell_trade, currencyCode)}`}
buttons={{
buy: { label: lstrings.title_buy, type: 'secondary' },
sell: { label: lstrings.title_sell }
}}
/>
))
} else {
result = await Airship.show<'buy' | 'sell' | 'exchange' | undefined>(bridge => (
<ButtonsModal
bridge={bridge}
title={lstrings.price_change_notification}
message={`${body} ${sprintf(lstrings.price_change_buy_sell_trade, currencyCode)}`}
buttons={{
buy: { label: lstrings.title_buy, type: 'secondary' },
sell: { label: lstrings.title_sell },
exchange: { label: lstrings.buy_crypto_modal_exchange }
}}
/>
))
}

if (result === 'buy') {
navigation.navigate('buyTab', { screen: 'pluginListBuy' })
Expand Down
49 changes: 34 additions & 15 deletions src/actions/ScanActions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -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 => (
<ButtonsModal
bridge={bridge}
title={lstrings.buy_crypto_modal_title}
message={messageSyntax}
buttons={{
buy: { label: getUkCompliantString(countryCode, 'buy_1s', currencyCode) },
exchange: { label: lstrings.buy_crypto_modal_exchange, type: 'primary' },
decline: { label: lstrings.buy_crypto_decline }
}}
/>
))
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 => (
<ButtonsModal
bridge={bridge}
title={lstrings.buy_crypto_modal_title}
message={messageSyntax}
buttons={{
buy: { label: getUkCompliantString(countryCode, 'buy_1s', currencyCode) },
decline: { label: lstrings.buy_crypto_decline }
}}
/>
))
} else {
const messageSyntax = sprintf(lstrings.buy_crypto_modal_message, currencyCode, currencyCode, currencyCode)
threeButtonModal = await Airship.show<'buy' | 'exchange' | 'decline' | undefined>(bridge => (
<ButtonsModal
bridge={bridge}
title={lstrings.buy_crypto_modal_title}
message={messageSyntax}
buttons={{
buy: { label: getUkCompliantString(countryCode, 'buy_1s', currencyCode) },
exchange: { label: lstrings.buy_crypto_modal_exchange, type: 'primary' },
decline: { label: lstrings.buy_crypto_decline }
}}
/>
))
}
} else {
// if we're not targetting for buying, but rather exchange
const messageSyntax = sprintf(lstrings.exchange_crypto_modal_message, currencyCode, currencyCode, currencyCode)
Expand All @@ -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:
Expand Down
22 changes: 17 additions & 5 deletions src/components/modals/InsufficientFeesModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -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 (
<EdgeModal bridge={bridge} title={lstrings.buy_crypto_modal_title} onCancel={handleCancel}>
<Paragraph>{message}</Paragraph>
<ButtonsView
primary={{ label: getUkCompliantString(countryCode, 'buy_1s_quote', currencyCode), onPress: handleBuy }}
secondary={{ label: lstrings.buy_crypto_modal_exchange, onPress: handleSwap }}
secondary={secondary}
tertiary={{ label: lstrings.buy_crypto_decline, onPress: handleCancel }}
/>
</EdgeModal>
Expand Down
8 changes: 8 additions & 0 deletions src/components/themed/SideMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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: () => {
Expand Down
5 changes: 2 additions & 3 deletions src/constants/plugins/GuiPlugins.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
3 changes: 3 additions & 0 deletions src/locales/en_US.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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?',
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

buy_crypto_modal_message_no_exchange_1s

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, does this need to go through getUkCompliantString()?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For now no need as it wasnt requested

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',
Expand Down
3 changes: 3 additions & 0 deletions src/locales/strings/enUS.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
Loading