@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.cjs +11 -0
- package/dist/browser.cjs.map +1 -1
- package/dist/browser.js +11 -0
- package/dist/browser.js.map +1 -1
- package/dist/index.cjs +23 -7
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +10 -2
- package/dist/index.d.ts +10 -2
- package/dist/index.js +23 -7
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/browser.cjs
CHANGED
|
@@ -126,6 +126,7 @@ __export(token_registry_exports, {
|
|
|
126
126
|
getCoinMeta: () => getCoinMeta,
|
|
127
127
|
getDecimalsForCoinType: () => getDecimalsForCoinType,
|
|
128
128
|
isInRegistry: () => isInRegistry,
|
|
129
|
+
resolveCoinDecimals: () => resolveCoinDecimals,
|
|
129
130
|
resolveSymbol: () => resolveSymbol,
|
|
130
131
|
resolveTokenType: () => resolveTokenType
|
|
131
132
|
});
|
|
@@ -147,6 +148,16 @@ function getDecimalsForCoinType(coinType) {
|
|
|
147
148
|
}
|
|
148
149
|
return 9;
|
|
149
150
|
}
|
|
151
|
+
async function resolveCoinDecimals(client, coinType) {
|
|
152
|
+
if (isInRegistry(coinType)) return getDecimalsForCoinType(coinType);
|
|
153
|
+
try {
|
|
154
|
+
const res = await client.core.getCoinMetadata({ coinType });
|
|
155
|
+
const d = res?.metadata?.decimals ?? res?.decimals;
|
|
156
|
+
if (typeof d === "number" && Number.isFinite(d)) return d;
|
|
157
|
+
} catch {
|
|
158
|
+
}
|
|
159
|
+
return getDecimalsForCoinType(coinType);
|
|
160
|
+
}
|
|
150
161
|
function resolveSymbol(coinType) {
|
|
151
162
|
const direct = BY_TYPE.get(coinType);
|
|
152
163
|
if (direct) return direct.symbol;
|