@unicitylabs/sphere-sdk 0.1.7 → 0.1.8
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/core/index.cjs +28 -0
- package/dist/core/index.cjs.map +1 -1
- package/dist/core/index.d.cts +14 -0
- package/dist/core/index.d.ts +14 -0
- package/dist/core/index.js +28 -0
- package/dist/core/index.js.map +1 -1
- package/dist/index.cjs +28 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +43 -1
- package/dist/index.d.ts +43 -1
- package/dist/index.js +28 -0
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/core/index.cjs
CHANGED
|
@@ -3813,6 +3813,34 @@ var PaymentsModule = class {
|
|
|
3813
3813
|
}
|
|
3814
3814
|
return Array.from(balances.values());
|
|
3815
3815
|
}
|
|
3816
|
+
/**
|
|
3817
|
+
* Get aggregated assets (tokens grouped by coinId)
|
|
3818
|
+
* Only includes confirmed tokens
|
|
3819
|
+
*/
|
|
3820
|
+
getAssets(coinId) {
|
|
3821
|
+
const assets = /* @__PURE__ */ new Map();
|
|
3822
|
+
for (const token of this.tokens.values()) {
|
|
3823
|
+
if (token.status !== "confirmed") continue;
|
|
3824
|
+
if (coinId && token.coinId !== coinId) continue;
|
|
3825
|
+
const key = token.coinId;
|
|
3826
|
+
const existing = assets.get(key);
|
|
3827
|
+
if (existing) {
|
|
3828
|
+
existing.totalAmount = (BigInt(existing.totalAmount) + BigInt(token.amount)).toString();
|
|
3829
|
+
existing.tokenCount++;
|
|
3830
|
+
} else {
|
|
3831
|
+
assets.set(key, {
|
|
3832
|
+
coinId: token.coinId,
|
|
3833
|
+
symbol: token.symbol,
|
|
3834
|
+
name: token.name,
|
|
3835
|
+
decimals: token.decimals,
|
|
3836
|
+
iconUrl: token.iconUrl,
|
|
3837
|
+
totalAmount: token.amount,
|
|
3838
|
+
tokenCount: 1
|
|
3839
|
+
});
|
|
3840
|
+
}
|
|
3841
|
+
}
|
|
3842
|
+
return Array.from(assets.values());
|
|
3843
|
+
}
|
|
3816
3844
|
/**
|
|
3817
3845
|
* Get all tokens
|
|
3818
3846
|
*/
|