From 9091eac3e5eb8ba5fdad4c4f7b851b5872c13d91 Mon Sep 17 00:00:00 2001 From: thisconnect Date: Fri, 9 May 2025 08:05:23 +0200 Subject: [PATCH] frontend: show all sell options Before BTC Direct sell the only sell option was Bitcoin via PocketBitcoin, which require SLIP24 and only supports Bitcoin. If the firmware did not support SLIP24 the app displayed: A firmware update is required to make use of this feature. When an altcoin was selected the app would display: An account must be BTC based to support payment requests. This commit changes to show all sell options and optionally show an warning after the options: A firmware update is required to use all options. This requires a change in the backend that the Pocket options is only returned if the firmware supports SLIP24. --- backend/coins/btc/handlers/handlers.go | 2 +- frontends/web/src/locales/en/app.json | 2 +- .../routes/exchange/components/buysell.tsx | 51 +++++++++++-------- 3 files changed, 31 insertions(+), 24 deletions(-) diff --git a/backend/coins/btc/handlers/handlers.go b/backend/coins/btc/handlers/handlers.go index decf55002b..1b55a99f16 100644 --- a/backend/coins/btc/handlers/handlers.go +++ b/backend/coins/btc/handlers/handlers.go @@ -875,7 +875,7 @@ func (handlers *Handlers) getHasPaymentRequest(r *http.Request) (interface{}, er if !ok { return response{ Success: false, - ErrorMessage: "An account must be BTC based to support payment requests.", + ErrorMessage: "", }, nil } diff --git a/frontends/web/src/locales/en/app.json b/frontends/web/src/locales/en/app.json index 10d29c96c5..ab94530c73 100644 --- a/frontends/web/src/locales/en/app.json +++ b/frontends/web/src/locales/en/app.json @@ -637,7 +637,6 @@ }, "device": { "appUpradeRequired": "Your BitBox is not compatible with this desktop application. Please download and install the latest version.", - "firmwareUpgradeRequired": "A firmware update is required to make use of this feature.", "keystoreConnected": "Connected wallet", "unsupportedFeature": "This feature is not available on this device." }, @@ -759,6 +758,7 @@ "exchange": { "buySell": { "coinNotSupported": "No options available for this coin type.", + "firmwareUpgradeRequired": "A firmware update is required to use all options.", "regionNotSupported": "No options available for this region.", "updateNow": "Update now" }, diff --git a/frontends/web/src/routes/exchange/components/buysell.tsx b/frontends/web/src/routes/exchange/components/buysell.tsx index 3780d1c337..8a8f0c5b21 100644 --- a/frontends/web/src/routes/exchange/components/buysell.tsx +++ b/frontends/web/src/routes/exchange/components/buysell.tsx @@ -70,7 +70,6 @@ export const BuySell = ({ setPaymentRequestError(action === 'sell' && hasPaymentRequestResponse?.success === false); }, [hasPaymentRequestResponse, action]); - useEffect(() => { if (config) { setAgreedBTCDirectOTCTerms(config.frontend.skipBTCDirectOTCDisclaimer); @@ -84,9 +83,12 @@ export const BuySell = ({ } return exchangeDealsResponse.errorMessage; } else if (paymentRequestError) { - if (hasPaymentRequestResponse?.errorCode) { - return t('device.' + hasPaymentRequestResponse.errorCode); - } else { + switch (hasPaymentRequestResponse?.errorCode) { + case 'firmwareUpgradeRequired': + return t('exchange.buySell.firmwareUpgradeRequired'); + case 'unsupportedFeature': + return t('device.unsupportedFeature'); + default: return hasPaymentRequestResponse?.errorMessage || ''; } } @@ -106,24 +108,7 @@ export const BuySell = ({
{!exchangeDealsResponse && } - {exchangeDealsResponse?.success === false || paymentRequestError ? ( -
-

{constructErrorMessage()}

- {exchangeDealsResponse?.success && - paymentRequestError && - hasPaymentRequestResponse?.errorCode === 'firmwareUpgradeRequired' && ( - - )} -
- ) : ( + {exchangeDealsResponse?.success && (
{exchangeDealsResponse?.exchanges // skip the exchanges that have only hidden deals. @@ -146,6 +131,28 @@ export const BuySell = ({ ))}
)} + + {(exchangeDealsResponse?.success === false || paymentRequestError) && ( +
+

+ {constructErrorMessage()} +

+ {exchangeDealsResponse?.success && + paymentRequestError && + hasPaymentRequestResponse?.errorCode === 'firmwareUpgradeRequired' && ( + + )} +
+ )} + {btcDirectOTCSupported?.success && btcDirectOTCSupported?.supported && (
}>