@xchainjs/xchain-midgard-query 2.0.12 → 2.0.14

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/index.esm.js CHANGED
@@ -305,6 +305,8 @@ class MidgardQuery {
305
305
  'TRON.USDT-0xdAC17F958D2ee523a2206206994597C13D831ec7': 6,
306
306
  // XRP
307
307
  'XRP.XRP': 6,
308
+ // Solana
309
+ 'SOL.SOL': 9,
308
310
  };
309
311
  // Return specific fallback or use chain-based defaults
310
312
  if (fallbackDecimalMap[assetString]) {
@@ -324,6 +326,7 @@ class MidgardQuery {
324
326
  BASE: 18,
325
327
  TRON: 6,
326
328
  XRP: 6,
329
+ SOL: 9,
327
330
  THOR: DEFAULT_THORCHAIN_DECIMALS,
328
331
  };
329
332
  const chainDefault = chainDefaults[asset.chain];
@@ -391,7 +394,12 @@ class MidgardQuery {
391
394
  return DEFAULT_THORCHAIN_DECIMALS;
392
395
  try {
393
396
  const pool = yield this.getPool(assetToString(asset));
394
- return Number(pool.nativeDecimal);
397
+ const decimals = Number(pool.nativeDecimal);
398
+ if (decimals >= 0)
399
+ return decimals;
400
+ // Midgard returns -1 for chains where decimals are not yet configured
401
+ console.warn(`Midgard returned -1 decimals for ${assetToString(asset)}, using fallback`);
402
+ return this.getFallbackDecimals(asset);
395
403
  }
396
404
  catch (error) {
397
405
  // Fallback: if Midgard is down, use standard decimal values for common assets
package/lib/index.js CHANGED
@@ -312,6 +312,8 @@ class MidgardQuery {
312
312
  'TRON.USDT-0xdAC17F958D2ee523a2206206994597C13D831ec7': 6,
313
313
  // XRP
314
314
  'XRP.XRP': 6,
315
+ // Solana
316
+ 'SOL.SOL': 9,
315
317
  };
316
318
  // Return specific fallback or use chain-based defaults
317
319
  if (fallbackDecimalMap[assetString]) {
@@ -331,6 +333,7 @@ class MidgardQuery {
331
333
  BASE: 18,
332
334
  TRON: 6,
333
335
  XRP: 6,
336
+ SOL: 9,
334
337
  THOR: DEFAULT_THORCHAIN_DECIMALS,
335
338
  };
336
339
  const chainDefault = chainDefaults[asset.chain];
@@ -398,7 +401,12 @@ class MidgardQuery {
398
401
  return DEFAULT_THORCHAIN_DECIMALS;
399
402
  try {
400
403
  const pool = yield this.getPool(xchainUtil.assetToString(asset));
401
- return Number(pool.nativeDecimal);
404
+ const decimals = Number(pool.nativeDecimal);
405
+ if (decimals >= 0)
406
+ return decimals;
407
+ // Midgard returns -1 for chains where decimals are not yet configured
408
+ console.warn(`Midgard returned -1 decimals for ${xchainUtil.assetToString(asset)}, using fallback`);
409
+ return this.getFallbackDecimals(asset);
402
410
  }
403
411
  catch (error) {
404
412
  // Fallback: if Midgard is down, use standard decimal values for common assets
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xchainjs/xchain-midgard-query",
3
- "version": "2.0.12",
3
+ "version": "2.0.14",
4
4
  "license": "MIT",
5
5
  "description": "Module that is responsible for get data from Midgard API",
6
6
  "keywords": [
@@ -32,9 +32,9 @@
32
32
  "postversion": "git push --follow-tags"
33
33
  },
34
34
  "dependencies": {
35
- "@xchainjs/xchain-client": "2.0.10",
35
+ "@xchainjs/xchain-client": "2.0.11",
36
36
  "@xchainjs/xchain-midgard": "1.1.0",
37
- "@xchainjs/xchain-util": "2.0.5",
37
+ "@xchainjs/xchain-util": "2.0.6",
38
38
  "axios": "1.13.5",
39
39
  "axios-retry": "^3.9.1"
40
40
  },