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

client: hide order form if asset version is not supported #2054

Merged
merged 2 commits into from Feb 8, 2023

Conversation

vctt94
Copy link
Member

@vctt94 vctt94 commented Jan 17, 2023

closes #2039

if (!base || !quote) return false
const { baseCfg: b, quoteCfg: q } = this.market
// check if versions are supported
return base.info?.versions.includes(b.version) && quote.info?.versions.includes(q.version)
Copy link
Contributor

Choose a reason for hiding this comment

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

Could you test this with tokens? WalletInfo will not be defined for tokens, so I think this will throw an error.

Copy link
Member Author

@vctt94 vctt94 Jan 18, 2023

Choose a reason for hiding this comment

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

It will not throw an error because of the optional chaining operator, but it will also not work. Fixed in the next commit, now checking if the parent support its version.

thanks for spotting it.

return b && q
const [base, quote] = [this.market.base, this.market.quote]
if (!base || !quote) return false
const { baseCfg: b, quoteCfg: q } = this.market
Copy link
Contributor

Choose a reason for hiding this comment

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

I would just leave this as baseCfg and quoteCfg to be able to more clearly differentiate in the check below.

@vctt94
Copy link
Member Author

vctt94 commented Jan 18, 2023

Thanks for the review marton, addressed your comments.

@ukane-philemon
Copy link
Contributor

Thanks @vctt94 for picking this up.

Don't we want display a message to user if we eventually hide the order form due to this new check? I think, setLoaderMsgVisibility() displays a message for unsupported assets but does not consider assets with unsupported version.

@vctt94
Copy link
Member Author

vctt94 commented Jan 18, 2023

Hey Ukane, my pleasure.

I am not sure I understand what you mean, right now it does show a message if assets aren't supported, which is: {{ asset }} is not supported.

Do you mean it should be a more descreptive message?

@ukane-philemon
Copy link
Contributor

Do you mean it should be a more descreptive message?

Yeah.

@vctt94
Copy link
Member Author

vctt94 commented Jan 18, 2023

Thanks for the suggestion, but I am not sure I agree with you.

Right now the assetsAreSupported() method returns a boolean, which indicates if assets are supported or not. So to be more descriptive about the message we would need to change this method in order to know what is the reason of this asset not being supported so we can show the right message at setLoaderMsgVisibility().

Which I believe {{ asset }} is not supported already covers the point.

@chappjc
Copy link
Member

chappjc commented Jan 18, 2023

Can you share a screenshot of current view when not supported?

@vctt94
Copy link
Member Author

vctt94 commented Jan 18, 2023

This is the currently view:

image

@chappjc
Copy link
Member

chappjc commented Jan 18, 2023

So is what's missing the unsupported version?

@vctt94
Copy link
Member Author

vctt94 commented Jan 18, 2023

Yeah I think so. If everyone agrees I can change assetsAreSupported, to show the unsupported version as well.

@vctt94
Copy link
Member Author

vctt94 commented Jan 18, 2023

Addressed @ukane-philemon comment on my last commit.

This is how it looks right now:

image

@@ -111,6 +112,7 @@ export const enUS: Locale = {
[ID_BUY]: 'Buy',
[ID_SELL]: 'Sell',
[ID_NOT_SUPPORTED]: '{{ asset }} is not supported',
[ID_VERSION_NOT_SUPPORTED]: 'version: {{ version }} of {{ asset }} is not supported',
Copy link
Member

@chappjc chappjc Jan 19, 2023

Choose a reason for hiding this comment

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

Let's rephrase this. The "version: " prefix there is a bit odd. How about:

{{ asset }} version {{ version }} is not supported

e.g. "USDC.ETH version 0 is not supported"

or

{{ asset }} (v{{version}}) is not supported

e.g. "USDC.ETH (v0) is not supported"

Any preferences? I'm leaning towards the "v0" way because that can remain consistent across all languages, no need to translate "version" and hope the meaning comes across.

I think the point of the issue this PR is aiming to resolve is that without naming the version it might be confusing if the user can see that the server does indeed have a market for this asset, so we have to state the version so there's some kind of explanation for why it's not supported.

@vctt94
Copy link
Member Author

vctt94 commented Jan 19, 2023

Addressed the suggested text change, this is how it looks:

image

if (base.token && quote.token) {
const bParent = app().assets[base.token.parentID]
const qParent = app().assets[quote.token.parentID]
if (!bParent.info?.versions.includes(baseCfg.version)) {
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think this is correct, you're checking the parent's version against the token version. The token also has its own version independent of the parent asset, but it doesn't seem to be exposed through the SupportedAsset type. I think the token wallet's version also needs to be exposed through the SupportedAsset type. @buck54321 Am I correct about this?

Copy link
Member

@buck54321 buck54321 Jan 31, 2023

Choose a reason for hiding this comment

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

Sorry for the late response. Yes. We are not properly exposing supported versions for tokens. @vctt94, check out buck54321/dcrdex@97a8cb2...buck54321:dcrdex:supported-versions-addon
Edit: scratch that. Gonna re-evaluate

Copy link
Member

Choose a reason for hiding this comment

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

Just opened #2094 too, so if that goes in first, you can just rebase to get the client/asset parts.

Copy link
Member

@buck54321 buck54321 Feb 3, 2023

Choose a reason for hiding this comment

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

I've changed tacts on this. See the updated #2094, but I think we'll have the server maintain a single protocol version and token assets will share with the parent asset.both a wallet version and a set of supported server versions.

The code here is roughly correct, though I'd recommend the following refactor buck54321/dcrdex@97a8cb2...buck54321:dcrdex:parent-vers-pattern
The only difference is that it will show the token's symbol instead of the parent asset, but I think that makes sense anyway.

@chappjc chappjc added this to the 0.6 milestone Jan 30, 2023
text: string;
} {
const { market } = this
const [base, quote] = [market.base, market.quote]
Copy link
Member

Choose a reason for hiding this comment

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

const { base, baseCfg, quote, quoteCfg } = market

const { market } = this
const [base, quote] = [market.base, market.quote]
if (!base || !quote) {
const symbol = market.base ? market.quoteCfg.symbol : market.baseCfg.symbol
Copy link
Member

Choose a reason for hiding this comment

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

const symbol = base ? ...

@vctt94
Copy link
Member Author

vctt94 commented Feb 6, 2023

I rebased this PR against #2094 and added the suggested reffactor.

@chappjc
Copy link
Member

chappjc commented Feb 7, 2023

#2094 is in, can rebase that commit out of your branch

vctt94 and others added 2 commits February 8, 2023 11:35
check if assets are token

Add ID_VERSION_NOT_SUPPORTED message on loaderMsg when version not supported

lint

change text message
@vctt94
Copy link
Member Author

vctt94 commented Feb 8, 2023

rebased

@chappjc chappjc merged commit adc816d into decred:master Feb 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ui: hide order form for incompatible asset versions
5 participants