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