@t2000/sdk 5.2.0 → 5.4.0

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/dist/browser.js CHANGED
@@ -124,6 +124,7 @@ __export(token_registry_exports, {
124
124
  getCoinMeta: () => getCoinMeta,
125
125
  getDecimalsForCoinType: () => getDecimalsForCoinType,
126
126
  isInRegistry: () => isInRegistry,
127
+ resolveCoinDecimals: () => resolveCoinDecimals,
127
128
  resolveSymbol: () => resolveSymbol,
128
129
  resolveTokenType: () => resolveTokenType
129
130
  });
@@ -145,6 +146,16 @@ function getDecimalsForCoinType(coinType) {
145
146
  }
146
147
  return 9;
147
148
  }
149
+ async function resolveCoinDecimals(client, coinType) {
150
+ if (isInRegistry(coinType)) return getDecimalsForCoinType(coinType);
151
+ try {
152
+ const res = await client.core.getCoinMetadata({ coinType });
153
+ const d = res?.metadata?.decimals ?? res?.decimals;
154
+ if (typeof d === "number" && Number.isFinite(d)) return d;
155
+ } catch {
156
+ }
157
+ return getDecimalsForCoinType(coinType);
158
+ }
148
159
  function resolveSymbol(coinType) {
149
160
  const direct = BY_TYPE.get(coinType);
150
161
  if (direct) return direct.symbol;