diff --git a/client/webserver/site/src/js/locales.ts b/client/webserver/site/src/js/locales.ts index 626cbbc6a6..046db5ab6a 100644 --- a/client/webserver/site/src/js/locales.ts +++ b/client/webserver/site/src/js/locales.ts @@ -14,6 +14,7 @@ export const ID_SHOW_ADDITIONAL_SETTINGS = 'ID_SHOW_ADDITIONAL_SETTINGS' export const ID_BUY = 'ID_BUY' export const ID_SELL = 'ID_SELL' export const ID_NOT_SUPPORTED = 'ID_NOT_SUPPORTED' +export const ID_VERSION_NOT_SUPPORTED = 'ID_VERSION_NOT_SUPPORTED' export const ID_CONNECTION_FAILED = 'ID_CONNECTION_FAILED' export const ID_ORDER_PREVIEW = 'ID_ORDER_PREVIEW' export const ID_CALCULATING = 'ID_CALCULATING' @@ -123,6 +124,7 @@ export const enUS: Locale = { [ID_BUY]: 'Buy', [ID_SELL]: 'Sell', [ID_NOT_SUPPORTED]: '{{ asset }} is not supported', + [ID_VERSION_NOT_SUPPORTED]: '{{ asset }} (v{{version}}) is not supported', [ID_CONNECTION_FAILED]: 'Connection to dex server failed. You can close dexc and try again later or wait for it to reconnect.', [ID_ORDER_PREVIEW]: 'Total: {{ total }} {{ asset }}', [ID_CALCULATING]: 'calculating...', diff --git a/client/webserver/site/src/js/markets.ts b/client/webserver/site/src/js/markets.ts index 0b2df991eb..4122964e05 100644 --- a/client/webserver/site/src/js/markets.ts +++ b/client/webserver/site/src/js/markets.ts @@ -601,9 +601,33 @@ export default class MarketsPage extends BasePage { /* assetsAreSupported is true if all the assets of the current market are * supported */ - assetsAreSupported () { - const [b, q] = [this.market.base, this.market.quote] - return b && q + assetsAreSupported (): { + isSupported: boolean; + text: string; + } { + const { market: { base, quote, baseCfg, quoteCfg } } = this + if (!base || !quote) { + const symbol = base ? quoteCfg.symbol : baseCfg.symbol + return { + isSupported: false, + text: intl.prep(intl.ID_NOT_SUPPORTED, { asset: symbol.toUpperCase() }) + } + } + // check if versions are supported. If asset is a token, we check if its + // parent supports the version. + const bVers = (base.token ? app().assets[base.token.parentID].info?.versions : base.info?.versions) as number[] + const qVers = (quote.token ? app().assets[quote.token.parentID].info?.versions : quote.info?.versions) as number[] + // if none them are token, just check if own asset is supported. + let text = '' + if (!bVers.includes(baseCfg.version)) { + text = intl.prep(intl.ID_VERSION_NOT_SUPPORTED, { asset: base.symbol.toUpperCase(), version: baseCfg.version + '' }) + } else if (!qVers.includes(quoteCfg.version)) { + text = intl.prep(intl.ID_VERSION_NOT_SUPPORTED, { asset: quote.symbol.toUpperCase(), version: quoteCfg.version + '' }) + } + return { + isSupported: bVers.includes(baseCfg.version) && qVers.includes(quoteCfg.version), + text + } } /* @@ -639,7 +663,7 @@ export default class MarketsPage extends BasePage { // and ready for trading the form should show up. Doc.hide(page.orderForm, page.orderTypeBttns) const feePaid = !this.hasFeePending() - const assetsAreSupported = this.assetsAreSupported() + const assetsAreSupported = this.assetsAreSupported().isSupported const { base, quote } = this.market const hasWallets = base && app().assets[base.id].wallet && quote && app().assets[quote.id].wallet @@ -652,15 +676,15 @@ export default class MarketsPage extends BasePage { * supported */ setLoaderMsgVisibility () { - const { page, market } = this + const { page } = this - if (this.assetsAreSupported()) { + const { isSupported, text } = this.assetsAreSupported() + if (isSupported) { // make sure to hide the loader msg Doc.hide(page.loaderMsg) return } - const symbol = market.base ? market.quoteCfg.symbol : market.baseCfg.symbol - page.loaderMsg.textContent = intl.prep(intl.ID_NOT_SUPPORTED, { asset: symbol.toUpperCase() }) + page.loaderMsg.textContent = text Doc.show(page.loaderMsg) Doc.hide(page.noWallet) } diff --git a/client/webserver/site/src/js/registry.ts b/client/webserver/site/src/js/registry.ts index 5d9f102627..87863f6488 100644 --- a/client/webserver/site/src/js/registry.ts +++ b/client/webserver/site/src/js/registry.ts @@ -191,6 +191,7 @@ export interface WalletInfo { name: string version: number availablewallets: WalletDefinition[] + versions: number[] emptyidx: number unitinfo: UnitInfo }