Skip to content

frontend: show all sell options #3337

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

Closed
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
2 changes: 1 addition & 1 deletion backend/coins/btc/handlers/handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -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: "",
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Temporary removed this error, but instead the app should probably just return BTC Direct as only sell option (now that it supports coins other than Bitcoin).

Copy link
Collaborator

Choose a reason for hiding this comment

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

I think we should deal with this logic somewhere else; if we use payment requests only for BTC with Pocket, we shouldn't change this logic (which is what I was doing in my other PR that is now closed). If we are not using payment requests for BTC Direct, we should just skip the call to has-payment-request when selling with them. Unless I'm mistaken there's not much we can do in the backend here, as the backend already returns the correct deals, it's just that the frontend stops when the call to has-payment-request fails.

cc @Beerosagos on the disucssion we had earlier

Copy link
Collaborator

Choose a reason for hiding this comment

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

Yeah, I agree 👍

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Unless I'm mistaken there's not much we can do in the backend here, as the backend already returns the correct deals, i

oh, I was somehow under the assumption that the backend doesn't retrurn the correct deals. I'll check again…

Copy link
Collaborator

Choose a reason for hiding this comment

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

@thisconnect let me know if you need any help checking. By looking at the code, I think that if we were to simply ignore the call to has-payment-request, the backend should return the correct deals, but I'm happy to double-check it.

This also would impact the changes we want for the old-FW error, so I'm gonna put an hold on that as well until we make sure :)

}, nil
}

Expand Down
2 changes: 1 addition & 1 deletion frontends/web/src/locales/en/app.json
Original file line number Diff line number Diff line change
Expand Up @@ -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."
},
Expand Down Expand Up @@ -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"
},
Expand Down
51 changes: 29 additions & 22 deletions frontends/web/src/routes/exchange/components/buysell.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@ export const BuySell = ({
setPaymentRequestError(action === 'sell' && hasPaymentRequestResponse?.success === false);
}, [hasPaymentRequestResponse, action]);


useEffect(() => {
if (config) {
setAgreedBTCDirectOTCTerms(config.frontend.skipBTCDirectOTCDisclaimer);
Expand All @@ -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 || '';
}
}
Expand All @@ -106,24 +108,7 @@ export const BuySell = ({
<div className={style.innerRadioButtonsContainer}>
{!exchangeDealsResponse && <Skeleton />}

{exchangeDealsResponse?.success === false || paymentRequestError ? (
<div className="flex flex-column">
<p className={style.noExchangeText}>{constructErrorMessage()}</p>
{exchangeDealsResponse?.success &&
paymentRequestError &&
hasPaymentRequestResponse?.errorCode === 'firmwareUpgradeRequired' && (
<Button
className={style.updateButton}
onClick={() => {
setFirmwareUpdateDialogOpen(true);
navigate(`/settings/device-settings/${deviceIDs[0]}`);
}}
transparent>
{t('exchange.buySell.updateNow')}
</Button>
)}
</div>
) : (
{exchangeDealsResponse?.success && (
<div className={style.exchangeProvidersContainer}>
{exchangeDealsResponse?.exchanges
// skip the exchanges that have only hidden deals.
Expand All @@ -146,6 +131,28 @@ export const BuySell = ({
))}
</div>
)}

{(exchangeDealsResponse?.success === false || paymentRequestError) && (
<div className="flex flex-column">
<p className={style.noExchangeText}>
{constructErrorMessage()}
</p>
{exchangeDealsResponse?.success &&
paymentRequestError &&
hasPaymentRequestResponse?.errorCode === 'firmwareUpgradeRequired' && (
<Button
className={style.updateButton}
onClick={() => {
setFirmwareUpdateDialogOpen(true);
navigate(`/settings/device-settings/${deviceIDs[0]}`);
}}
transparent>
{t('exchange.buySell.updateNow')}
</Button>
)}
</div>
)}

{btcDirectOTCSupported?.success && btcDirectOTCSupported?.supported && (
<div className={style.infoContainer}>
<Message type="info" icon={<Businessman/>}>
Expand Down