-
Notifications
You must be signed in to change notification settings - Fork 100
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
Conversation
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) |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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.
Thanks for the review marton, addressed your comments. |
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, |
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: Do you mean it should be a more descreptive message? |
Yeah. |
Thanks for the suggestion, but I am not sure I agree with you. Right now the Which I believe |
Can you share a screenshot of current view when not supported? |
So is what's missing the unsupported version? |
Yeah I think so. If everyone agrees I can change |
Addressed @ukane-philemon comment on my last commit. This is how it looks right now: |
0b8240a
to
491a509
Compare
@@ -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', |
There was a problem hiding this comment.
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.
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)) { |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
text: string; | ||
} { | ||
const { market } = this | ||
const [base, quote] = [market.base, market.quote] |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const symbol = base ? ...
97a8cb2
to
f77e535
Compare
I rebased this PR against #2094 and added the suggested reffactor. |
#2094 is in, can rebase that commit out of your branch |
check if assets are token Add ID_VERSION_NOT_SUPPORTED message on loaderMsg when version not supported lint change text message
f77e535
to
44bcb8f
Compare
rebased |
closes #2039