@t2000/sdk 0.46.8 → 0.46.10

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.
@@ -4645,22 +4645,39 @@ async function addClaimRewardsToTx(tx, client, address) {
4645
4645
  (r) => Number(r.userClaimableReward) > 0
4646
4646
  );
4647
4647
  if (claimable.length === 0) return [];
4648
- const claimed = await Ct(tx, claimable, {
4648
+ await Ct(tx, claimable, {
4649
4649
  env: "prod",
4650
4650
  customCoinReceive: { type: "transfer", transfer: address }
4651
4651
  });
4652
- return claimed.map((c) => ({
4653
- protocol: "navi",
4654
- asset: "",
4655
- coinType: "",
4656
- symbol: "REWARD",
4657
- amount: 0,
4658
- estimatedValueUsd: 0
4659
- }));
4652
+ return aggregateClaimableRewards(claimable);
4660
4653
  } catch {
4661
4654
  return [];
4662
4655
  }
4663
4656
  }
4657
+ function aggregateClaimableRewards(claimable) {
4658
+ const aggregated = /* @__PURE__ */ new Map();
4659
+ for (const c of claimable) {
4660
+ const coinType = c.rewardCoinType;
4661
+ if (!coinType) continue;
4662
+ const symbol = coinType.split("::").pop() ?? "REWARD";
4663
+ const amount = Number(c.userClaimableReward);
4664
+ if (!Number.isFinite(amount) || amount <= 0) continue;
4665
+ const existing = aggregated.get(coinType);
4666
+ if (existing) {
4667
+ existing.amount += amount;
4668
+ } else {
4669
+ aggregated.set(coinType, {
4670
+ protocol: "navi",
4671
+ asset: String(c.assetId ?? ""),
4672
+ coinType,
4673
+ symbol,
4674
+ amount,
4675
+ estimatedValueUsd: 0
4676
+ });
4677
+ }
4678
+ }
4679
+ return Array.from(aggregated.values());
4680
+ }
4664
4681
 
4665
4682
  // src/adapters/descriptors.ts
4666
4683
  var naviDescriptor = {