Skip to content

Commit

Permalink
handle missing asset
Browse files Browse the repository at this point in the history
  • Loading branch information
buck54321 committed Sep 25, 2024
1 parent 45c2a0d commit d6d83a8
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 7 deletions.
4 changes: 4 additions & 0 deletions client/core/core.go
Original file line number Diff line number Diff line change
Expand Up @@ -7139,6 +7139,10 @@ func (c *Core) initialize() error {
c.log.Infof("Connected to %d of %d DEX servers", liveConns, len(accts))

for _, dbWallet := range dbWallets {
if asset.Asset(dbWallet.AssetID) == nil && asset.TokenInfo(dbWallet.AssetID) == nil {
c.log.Infof("Wallet for asset %s no longer supported", dex.BipIDSymbol(dbWallet.AssetID))
continue
}
assetID := dbWallet.AssetID
wallet, err := c.loadWallet(dbWallet)
if err != nil {
Expand Down
13 changes: 10 additions & 3 deletions client/webserver/site/src/js/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -794,12 +794,19 @@ export default class Application {
* updateMarketElements sets the textContent for any ticker or asset name
* elements or any asset logo src attributes for descendents of ancestor.
*/
updateMarketElements (ancestor: PageElement, baseID: number, quoteID: number) {
const { unitInfo: bui, name: baseName, symbol: baseSymbol } = this.assets[baseID]
updateMarketElements (ancestor: PageElement, baseID: number, quoteID: number, xc?: Exchange) {
const getAsset = (assetID: number) => {
const a = this.assets[assetID]
if (a) return a
if (!xc) throw Error(`no asset found for asset ID ${assetID}`)
const xcAsset = xc.assets[assetID]
return { unitInfo: xcAsset.unitInfo, name: xcAsset.symbol, symbol: xcAsset.symbol }
}
const { unitInfo: bui, name: baseName, symbol: baseSymbol } = getAsset(baseID)
for (const el of Doc.applySelector(ancestor, '[data-base-name')) el.textContent = baseName
for (const img of Doc.applySelector(ancestor, '[data-base-logo]')) img.src = Doc.logoPath(baseSymbol)
for (const el of Doc.applySelector(ancestor, '[data-base-ticker]')) el.textContent = bui.conventional.unit
const { unitInfo: qui, name: quoteName, symbol: quoteSymbol } = this.assets[quoteID]
const { unitInfo: qui, name: quoteName, symbol: quoteSymbol } = getAsset(quoteID)
for (const el of Doc.applySelector(ancestor, '[data-quote-name')) el.textContent = quoteName
for (const img of Doc.applySelector(ancestor, '[data-quote-logo]')) img.src = Doc.logoPath(quoteSymbol)
for (const el of Doc.applySelector(ancestor, '[data-quote-ticker]')) el.textContent = qui.conventional.unit
Expand Down
6 changes: 3 additions & 3 deletions client/webserver/site/src/js/markets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -785,7 +785,7 @@ export default class MarketsPage extends BasePage {
}

const mmStatus = app().mmStatus
if (mmStatus && this.mmRunning === undefined) {
if (mmStatus && this.mmRunning === undefined && this.market.base && this.market.quote) {
const { base: { id: baseID }, quote: { id: quoteID }, dex: { host } } = this.market
const botStatus = mmStatus.bots.find(({ config: cfg }) => cfg.baseID === baseID && cfg.quoteID === quoteID && cfg.host === host)
this.mmRunning = Boolean(botStatus?.running)
Expand Down Expand Up @@ -1113,6 +1113,7 @@ export default class MarketsPage extends BasePage {
const mktId = marketID(baseCfg.symbol, quoteCfg.symbol)
const baseAsset = app().assets[baseID]
const quoteAsset = app().assets[quoteID]

const mkt = {
dex: dex,
sid: mktId, // A string market identifier used by the DEX.
Expand All @@ -1139,7 +1140,6 @@ export default class MarketsPage extends BasePage {
this.mmRunning = undefined
page.lotSize.textContent = Doc.formatCoinValue(mkt.cfg.lotsize, mkt.baseUnitInfo)
page.rateStep.textContent = Doc.formatCoinValue(mkt.cfg.ratestep / rateConversionFactor)
app().updateMarketElements(this.main, baseID, quoteID)

this.displayMessageIfMissingWallet()
this.balanceWgt.setWallets(host, baseID, quoteID)
Expand All @@ -1156,7 +1156,7 @@ export default class MarketsPage extends BasePage {
base: baseID,
quote: quoteID
})
app().updateMarketElements(this.main, baseID, quoteID)
app().updateMarketElements(this.main, baseID, quoteID, dex)
this.marketList.select(host, baseID, quoteID)
this.setLoaderMsgVisibility()
this.setTokenApprovalVisibility()
Expand Down
1 change: 1 addition & 0 deletions client/webserver/site/src/js/orders.ts
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,7 @@ export default class OrdersPage extends BasePage {
let fromSymbol, toSymbol, fromUnit, toUnit, fromQty
let toQty = ''
const xc = app().exchanges[ord.host] || undefined
if ((!app().assets[ord.baseID] && !xc.assets[ord.baseID]) || (!app().assets[ord.quoteID] && !xc.assets[ord.quoteID])) continue
const [baseUnitInfo, quoteUnitInfo] = [app().unitInfo(ord.baseID, xc), app().unitInfo(ord.quoteID, xc)]
if (ord.sell) {
[fromSymbol, toSymbol] = [ord.baseSymbol, ord.quoteSymbol];
Expand Down
2 changes: 1 addition & 1 deletion client/webserver/site/src/js/registry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1211,7 +1211,7 @@ export interface Application {
bindTooltips (ancestor: HTMLElement): void
bindUrlHandlers (ancestor: HTMLElement): void
attachHeader (): void
updateMarketElements (ancestor: PageElement, baseID: number, quoteID: number): void
updateMarketElements (ancestor: PageElement, baseID: number, quoteID: number, xc?: Exchange): void
showDropdown (icon: HTMLElement, dialog: HTMLElement): void
ackNotes (): void
setNoteTimes (noteList: HTMLElement): void
Expand Down

0 comments on commit d6d83a8

Please sign in to comment.