@ecency/wallets 1.5.10 → 1.5.11
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/index.d.ts +2 -4
- package/dist/browser/index.js +12 -142
- package/dist/browser/index.js.map +1 -1
- package/dist/node/index.cjs +12 -142
- package/dist/node/index.cjs.map +1 -1
- package/dist/node/index.mjs +12 -142
- package/dist/node/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/node/index.mjs
CHANGED
|
@@ -1562,6 +1562,7 @@ var AssetOperation = /* @__PURE__ */ ((AssetOperation2) => {
|
|
|
1562
1562
|
AssetOperation2["WithdrawRoutes"] = "withdraw-routes";
|
|
1563
1563
|
AssetOperation2["ClaimInterest"] = "claim-interest";
|
|
1564
1564
|
AssetOperation2["Swap"] = "swap";
|
|
1565
|
+
AssetOperation2["Convert"] = "convert";
|
|
1565
1566
|
AssetOperation2["Gift"] = "gift";
|
|
1566
1567
|
AssetOperation2["Promote"] = "promote";
|
|
1567
1568
|
AssetOperation2["Claim"] = "claim";
|
|
@@ -2874,35 +2875,6 @@ function getAllTokensListQueryOptions(username) {
|
|
|
2874
2875
|
}
|
|
2875
2876
|
});
|
|
2876
2877
|
}
|
|
2877
|
-
var DERIVED_PART_KEY_MAP = {
|
|
2878
|
-
liquid: ["liquid", "liquidBalance", "liquid_amount", "liquidTokens"],
|
|
2879
|
-
savings: ["savings", "savingsBalance", "savings_amount"],
|
|
2880
|
-
staked: ["staked", "stakedBalance", "staking", "stake", "power"],
|
|
2881
|
-
delegated: ["delegated", "delegatedBalance", "delegationsOut"],
|
|
2882
|
-
received: ["received", "receivedBalance", "delegationsIn"],
|
|
2883
|
-
pending: [
|
|
2884
|
-
"pending",
|
|
2885
|
-
"pendingRewards",
|
|
2886
|
-
"unclaimed",
|
|
2887
|
-
"unclaimedBalance",
|
|
2888
|
-
"pendingReward"
|
|
2889
|
-
]
|
|
2890
|
-
};
|
|
2891
|
-
var EXTRA_DATA_PART_KEY_MAP = {
|
|
2892
|
-
delegated: "outgoing_delegations",
|
|
2893
|
-
outgoing: "outgoing_delegations",
|
|
2894
|
-
delegations_out: "outgoing_delegations",
|
|
2895
|
-
delegated_hive_power: "outgoing_delegations",
|
|
2896
|
-
delegated_hp: "outgoing_delegations",
|
|
2897
|
-
received: "incoming_delegations",
|
|
2898
|
-
incoming: "incoming_delegations",
|
|
2899
|
-
delegations_in: "incoming_delegations",
|
|
2900
|
-
received_hive_power: "incoming_delegations",
|
|
2901
|
-
received_hp: "incoming_delegations",
|
|
2902
|
-
powering_down: "pending_power_down",
|
|
2903
|
-
power_down: "pending_power_down",
|
|
2904
|
-
powering_down_hive_power: "pending_power_down"
|
|
2905
|
-
};
|
|
2906
2878
|
function normalizeString(value) {
|
|
2907
2879
|
if (typeof value === "string") {
|
|
2908
2880
|
const trimmed = value.trim();
|
|
@@ -2945,100 +2917,6 @@ function normalizeApr(value) {
|
|
|
2945
2917
|
}
|
|
2946
2918
|
return numeric.toString();
|
|
2947
2919
|
}
|
|
2948
|
-
function normalizeParts(rawParts) {
|
|
2949
|
-
if (Array.isArray(rawParts)) {
|
|
2950
|
-
const parsed = rawParts.map((item) => {
|
|
2951
|
-
if (!item || typeof item !== "object") {
|
|
2952
|
-
return void 0;
|
|
2953
|
-
}
|
|
2954
|
-
const name = normalizeString(
|
|
2955
|
-
item.name ?? item.label ?? item.type ?? item.part
|
|
2956
|
-
);
|
|
2957
|
-
const balance = normalizeNumber(
|
|
2958
|
-
item.balance ?? item.amount ?? item.value
|
|
2959
|
-
);
|
|
2960
|
-
if (!name || balance === void 0) {
|
|
2961
|
-
return void 0;
|
|
2962
|
-
}
|
|
2963
|
-
return { name, balance };
|
|
2964
|
-
}).filter((item) => Boolean(item));
|
|
2965
|
-
return parsed.length ? parsed : void 0;
|
|
2966
|
-
}
|
|
2967
|
-
if (rawParts && typeof rawParts === "object") {
|
|
2968
|
-
const parsed = Object.entries(rawParts).map(([name, amount]) => {
|
|
2969
|
-
const balance = normalizeNumber(amount);
|
|
2970
|
-
if (!name || balance === void 0) {
|
|
2971
|
-
return void 0;
|
|
2972
|
-
}
|
|
2973
|
-
return { name, balance };
|
|
2974
|
-
}).filter((item) => Boolean(item));
|
|
2975
|
-
return parsed.length ? parsed : void 0;
|
|
2976
|
-
}
|
|
2977
|
-
return void 0;
|
|
2978
|
-
}
|
|
2979
|
-
function deriveParts(record) {
|
|
2980
|
-
const derived = Object.entries(DERIVED_PART_KEY_MAP).map(([name, keys]) => {
|
|
2981
|
-
for (const key of keys) {
|
|
2982
|
-
const value = normalizeNumber(record[key]);
|
|
2983
|
-
if (value !== void 0) {
|
|
2984
|
-
return { name, balance: value };
|
|
2985
|
-
}
|
|
2986
|
-
}
|
|
2987
|
-
return void 0;
|
|
2988
|
-
}).filter((item) => Boolean(item));
|
|
2989
|
-
return derived.length ? derived : void 0;
|
|
2990
|
-
}
|
|
2991
|
-
function normalizePartKey(value) {
|
|
2992
|
-
return value.trim().toLowerCase().replace(/[\s-]+/g, "_");
|
|
2993
|
-
}
|
|
2994
|
-
function mergeParts(...sources) {
|
|
2995
|
-
const order = [];
|
|
2996
|
-
const values2 = /* @__PURE__ */ new Map();
|
|
2997
|
-
for (const parts of sources) {
|
|
2998
|
-
if (!parts) {
|
|
2999
|
-
continue;
|
|
3000
|
-
}
|
|
3001
|
-
for (const part of parts) {
|
|
3002
|
-
if (!part?.name || typeof part.balance !== "number") {
|
|
3003
|
-
continue;
|
|
3004
|
-
}
|
|
3005
|
-
const existing = values2.get(part.name);
|
|
3006
|
-
if (existing === void 0) {
|
|
3007
|
-
order.push(part.name);
|
|
3008
|
-
values2.set(part.name, part.balance);
|
|
3009
|
-
} else {
|
|
3010
|
-
values2.set(part.name, existing + part.balance);
|
|
3011
|
-
}
|
|
3012
|
-
}
|
|
3013
|
-
}
|
|
3014
|
-
return order.length ? order.map((name) => ({ name, balance: values2.get(name) })) : void 0;
|
|
3015
|
-
}
|
|
3016
|
-
function normalizeExtraDataParts(rawExtraData) {
|
|
3017
|
-
const items = Array.isArray(rawExtraData) ? rawExtraData : rawExtraData && typeof rawExtraData === "object" ? Object.values(rawExtraData) : [];
|
|
3018
|
-
const parts = items.map((item) => {
|
|
3019
|
-
if (!item || typeof item !== "object") {
|
|
3020
|
-
return void 0;
|
|
3021
|
-
}
|
|
3022
|
-
const record = item;
|
|
3023
|
-
const keyCandidate = normalizeString(record.dataKey) ?? normalizeString(record.key) ?? normalizeString(record.name);
|
|
3024
|
-
if (!keyCandidate) {
|
|
3025
|
-
return void 0;
|
|
3026
|
-
}
|
|
3027
|
-
const canonical = normalizePartKey(keyCandidate);
|
|
3028
|
-
const partName = EXTRA_DATA_PART_KEY_MAP[canonical];
|
|
3029
|
-
if (!partName) {
|
|
3030
|
-
return void 0;
|
|
3031
|
-
}
|
|
3032
|
-
const balance = normalizeNumber(
|
|
3033
|
-
record.balance ?? record.amount ?? record.value ?? record.displayValue ?? record.text
|
|
3034
|
-
);
|
|
3035
|
-
if (balance === void 0) {
|
|
3036
|
-
return void 0;
|
|
3037
|
-
}
|
|
3038
|
-
return { name: partName, balance: Math.abs(balance) };
|
|
3039
|
-
}).filter((part) => Boolean(part));
|
|
3040
|
-
return parts.length ? parts : void 0;
|
|
3041
|
-
}
|
|
3042
2920
|
function parseToken(rawToken) {
|
|
3043
2921
|
if (!rawToken || typeof rawToken !== "object") {
|
|
3044
2922
|
return void 0;
|
|
@@ -3054,18 +2932,10 @@ function parseToken(rawToken) {
|
|
|
3054
2932
|
const apr = normalizeApr(token.apr) ?? normalizeApr(token.aprPercent) ?? normalizeApr(token.metrics?.apr) ?? normalizeApr(
|
|
3055
2933
|
token.metrics?.aprPercent
|
|
3056
2934
|
);
|
|
3057
|
-
const
|
|
3058
|
-
token.parts ?? token.balances ?? token.sections ?? token.breakdown ?? token.accountBreakdown ?? token.walletParts
|
|
3059
|
-
) ?? deriveParts(token);
|
|
3060
|
-
const parts = mergeParts(
|
|
3061
|
-
baseParts,
|
|
3062
|
-
normalizeExtraDataParts(
|
|
3063
|
-
token.extraData ?? token.extra_data ?? token.extra ?? token.badges
|
|
3064
|
-
)
|
|
3065
|
-
);
|
|
3066
|
-
const accountBalance = normalizeNumber(token.balance) ?? normalizeNumber(token.accountBalance) ?? normalizeNumber(token.totalBalance) ?? normalizeNumber(token.total) ?? normalizeNumber(token.amount) ?? (baseParts ? baseParts.reduce((total, part) => total + (part.balance ?? 0), 0) : parts ? parts.reduce((total, part) => total + (part.balance ?? 0), 0) : 0);
|
|
2935
|
+
const accountBalance = normalizeNumber(token.balance) ?? normalizeNumber(token.accountBalance) ?? normalizeNumber(token.totalBalance) ?? normalizeNumber(token.total) ?? normalizeNumber(token.amount) ?? 0;
|
|
3067
2936
|
const layer = normalizeString(token.layer) ?? normalizeString(token.chain) ?? normalizeString(token.category) ?? normalizeString(token.type);
|
|
3068
2937
|
const pendingRewards = normalizeNumber(token.pendingRewards);
|
|
2938
|
+
const savings = normalizeNumber(token.savings);
|
|
3069
2939
|
return {
|
|
3070
2940
|
symbol: normalizedSymbol,
|
|
3071
2941
|
name: normalizedSymbol,
|
|
@@ -3075,7 +2945,7 @@ function parseToken(rawToken) {
|
|
|
3075
2945
|
apr: apr ? Number.parseFloat(apr) : void 0,
|
|
3076
2946
|
layer: layer ?? void 0,
|
|
3077
2947
|
pendingRewards: pendingRewards ?? void 0,
|
|
3078
|
-
|
|
2948
|
+
savings: savings ?? void 0,
|
|
3079
2949
|
actions: token.actions ?? token.available_actions ?? token.availableActions ?? token.operations ?? token.supportedActions,
|
|
3080
2950
|
fiatRate: normalizeNumber(token.fiatRate) ?? void 0,
|
|
3081
2951
|
fiatCurrency: normalizeString(token.fiatCurrency) ?? void 0
|
|
@@ -3714,13 +3584,12 @@ function getAccountWalletAssetInfoQueryOptions(username, asset, options2 = { ref
|
|
|
3714
3584
|
if (!assetInfo) return void 0;
|
|
3715
3585
|
return {
|
|
3716
3586
|
name: assetInfo.name,
|
|
3717
|
-
title: assetInfo.title,
|
|
3587
|
+
title: assetInfo.title ?? assetInfo.name,
|
|
3718
3588
|
price: assetInfo.price ?? assetInfo.fiatRate ?? 0,
|
|
3719
3589
|
accountBalance: assetInfo.accountBalance ?? 0,
|
|
3720
|
-
apr: assetInfo.apr,
|
|
3590
|
+
apr: assetInfo.apr?.toString(),
|
|
3721
3591
|
layer: assetInfo.layer,
|
|
3722
|
-
pendingRewards: assetInfo.pendingRewards
|
|
3723
|
-
parts: assetInfo.parts
|
|
3592
|
+
pendingRewards: assetInfo.pendingRewards
|
|
3724
3593
|
};
|
|
3725
3594
|
} catch (e) {
|
|
3726
3595
|
return void 0;
|
|
@@ -3794,7 +3663,7 @@ function getTokenOperationsQueryOptions(token, username, isForOwner = false, cur
|
|
|
3794
3663
|
getVisionPortfolioQueryOptions(username, currency)
|
|
3795
3664
|
);
|
|
3796
3665
|
const assetEntry = portfolio.wallets.find(
|
|
3797
|
-
(assetItem) => assetItem.symbol?.toUpperCase() === normalizedToken
|
|
3666
|
+
(assetItem) => assetItem.symbol?.toUpperCase() === normalizedToken || assetItem.name?.toUpperCase() === normalizedToken
|
|
3798
3667
|
);
|
|
3799
3668
|
if (!assetEntry) {
|
|
3800
3669
|
return [];
|
|
@@ -3849,7 +3718,7 @@ function getTokenOperationsQueryOptions(token, username, isForOwner = false, cur
|
|
|
3849
3718
|
"swap": "swap" /* Swap */,
|
|
3850
3719
|
"swap-token": "swap" /* Swap */,
|
|
3851
3720
|
"swap-tokens": "swap" /* Swap */,
|
|
3852
|
-
"convert": "
|
|
3721
|
+
"convert": "convert" /* Convert */,
|
|
3853
3722
|
// Points operations
|
|
3854
3723
|
"promote": "promote" /* Promote */,
|
|
3855
3724
|
"promote-post": "promote" /* Promote */,
|
|
@@ -3877,9 +3746,10 @@ function getTokenOperationsQueryOptions(token, username, isForOwner = false, cur
|
|
|
3877
3746
|
(op) => op.toLowerCase() === canonical
|
|
3878
3747
|
);
|
|
3879
3748
|
return directMatch;
|
|
3880
|
-
}).filter((op) => Boolean(op));
|
|
3749
|
+
}).filter((op) => Boolean(op)).filter((op, index, self) => self.indexOf(op) === index);
|
|
3881
3750
|
const isHiveOrHbd = ["HIVE", "HBD"].includes(normalizedToken);
|
|
3882
|
-
const
|
|
3751
|
+
const rawToken = assetEntry;
|
|
3752
|
+
const hasSavings = Number(rawToken.savings ?? 0) > 0;
|
|
3883
3753
|
if (isHiveOrHbd && !hasSavings) {
|
|
3884
3754
|
return operations.filter(
|
|
3885
3755
|
(operation) => operation !== "withdraw-saving" /* WithdrawFromSavings */
|