@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.cjs
CHANGED
|
@@ -1589,6 +1589,7 @@ var AssetOperation = /* @__PURE__ */ ((AssetOperation2) => {
|
|
|
1589
1589
|
AssetOperation2["WithdrawRoutes"] = "withdraw-routes";
|
|
1590
1590
|
AssetOperation2["ClaimInterest"] = "claim-interest";
|
|
1591
1591
|
AssetOperation2["Swap"] = "swap";
|
|
1592
|
+
AssetOperation2["Convert"] = "convert";
|
|
1592
1593
|
AssetOperation2["Gift"] = "gift";
|
|
1593
1594
|
AssetOperation2["Promote"] = "promote";
|
|
1594
1595
|
AssetOperation2["Claim"] = "claim";
|
|
@@ -2901,35 +2902,6 @@ function getAllTokensListQueryOptions(username) {
|
|
|
2901
2902
|
}
|
|
2902
2903
|
});
|
|
2903
2904
|
}
|
|
2904
|
-
var DERIVED_PART_KEY_MAP = {
|
|
2905
|
-
liquid: ["liquid", "liquidBalance", "liquid_amount", "liquidTokens"],
|
|
2906
|
-
savings: ["savings", "savingsBalance", "savings_amount"],
|
|
2907
|
-
staked: ["staked", "stakedBalance", "staking", "stake", "power"],
|
|
2908
|
-
delegated: ["delegated", "delegatedBalance", "delegationsOut"],
|
|
2909
|
-
received: ["received", "receivedBalance", "delegationsIn"],
|
|
2910
|
-
pending: [
|
|
2911
|
-
"pending",
|
|
2912
|
-
"pendingRewards",
|
|
2913
|
-
"unclaimed",
|
|
2914
|
-
"unclaimedBalance",
|
|
2915
|
-
"pendingReward"
|
|
2916
|
-
]
|
|
2917
|
-
};
|
|
2918
|
-
var EXTRA_DATA_PART_KEY_MAP = {
|
|
2919
|
-
delegated: "outgoing_delegations",
|
|
2920
|
-
outgoing: "outgoing_delegations",
|
|
2921
|
-
delegations_out: "outgoing_delegations",
|
|
2922
|
-
delegated_hive_power: "outgoing_delegations",
|
|
2923
|
-
delegated_hp: "outgoing_delegations",
|
|
2924
|
-
received: "incoming_delegations",
|
|
2925
|
-
incoming: "incoming_delegations",
|
|
2926
|
-
delegations_in: "incoming_delegations",
|
|
2927
|
-
received_hive_power: "incoming_delegations",
|
|
2928
|
-
received_hp: "incoming_delegations",
|
|
2929
|
-
powering_down: "pending_power_down",
|
|
2930
|
-
power_down: "pending_power_down",
|
|
2931
|
-
powering_down_hive_power: "pending_power_down"
|
|
2932
|
-
};
|
|
2933
2905
|
function normalizeString(value) {
|
|
2934
2906
|
if (typeof value === "string") {
|
|
2935
2907
|
const trimmed = value.trim();
|
|
@@ -2972,100 +2944,6 @@ function normalizeApr(value) {
|
|
|
2972
2944
|
}
|
|
2973
2945
|
return numeric.toString();
|
|
2974
2946
|
}
|
|
2975
|
-
function normalizeParts(rawParts) {
|
|
2976
|
-
if (Array.isArray(rawParts)) {
|
|
2977
|
-
const parsed = rawParts.map((item) => {
|
|
2978
|
-
if (!item || typeof item !== "object") {
|
|
2979
|
-
return void 0;
|
|
2980
|
-
}
|
|
2981
|
-
const name = normalizeString(
|
|
2982
|
-
item.name ?? item.label ?? item.type ?? item.part
|
|
2983
|
-
);
|
|
2984
|
-
const balance = normalizeNumber(
|
|
2985
|
-
item.balance ?? item.amount ?? item.value
|
|
2986
|
-
);
|
|
2987
|
-
if (!name || balance === void 0) {
|
|
2988
|
-
return void 0;
|
|
2989
|
-
}
|
|
2990
|
-
return { name, balance };
|
|
2991
|
-
}).filter((item) => Boolean(item));
|
|
2992
|
-
return parsed.length ? parsed : void 0;
|
|
2993
|
-
}
|
|
2994
|
-
if (rawParts && typeof rawParts === "object") {
|
|
2995
|
-
const parsed = Object.entries(rawParts).map(([name, amount]) => {
|
|
2996
|
-
const balance = normalizeNumber(amount);
|
|
2997
|
-
if (!name || balance === void 0) {
|
|
2998
|
-
return void 0;
|
|
2999
|
-
}
|
|
3000
|
-
return { name, balance };
|
|
3001
|
-
}).filter((item) => Boolean(item));
|
|
3002
|
-
return parsed.length ? parsed : void 0;
|
|
3003
|
-
}
|
|
3004
|
-
return void 0;
|
|
3005
|
-
}
|
|
3006
|
-
function deriveParts(record) {
|
|
3007
|
-
const derived = Object.entries(DERIVED_PART_KEY_MAP).map(([name, keys]) => {
|
|
3008
|
-
for (const key of keys) {
|
|
3009
|
-
const value = normalizeNumber(record[key]);
|
|
3010
|
-
if (value !== void 0) {
|
|
3011
|
-
return { name, balance: value };
|
|
3012
|
-
}
|
|
3013
|
-
}
|
|
3014
|
-
return void 0;
|
|
3015
|
-
}).filter((item) => Boolean(item));
|
|
3016
|
-
return derived.length ? derived : void 0;
|
|
3017
|
-
}
|
|
3018
|
-
function normalizePartKey(value) {
|
|
3019
|
-
return value.trim().toLowerCase().replace(/[\s-]+/g, "_");
|
|
3020
|
-
}
|
|
3021
|
-
function mergeParts(...sources) {
|
|
3022
|
-
const order = [];
|
|
3023
|
-
const values2 = /* @__PURE__ */ new Map();
|
|
3024
|
-
for (const parts of sources) {
|
|
3025
|
-
if (!parts) {
|
|
3026
|
-
continue;
|
|
3027
|
-
}
|
|
3028
|
-
for (const part of parts) {
|
|
3029
|
-
if (!part?.name || typeof part.balance !== "number") {
|
|
3030
|
-
continue;
|
|
3031
|
-
}
|
|
3032
|
-
const existing = values2.get(part.name);
|
|
3033
|
-
if (existing === void 0) {
|
|
3034
|
-
order.push(part.name);
|
|
3035
|
-
values2.set(part.name, part.balance);
|
|
3036
|
-
} else {
|
|
3037
|
-
values2.set(part.name, existing + part.balance);
|
|
3038
|
-
}
|
|
3039
|
-
}
|
|
3040
|
-
}
|
|
3041
|
-
return order.length ? order.map((name) => ({ name, balance: values2.get(name) })) : void 0;
|
|
3042
|
-
}
|
|
3043
|
-
function normalizeExtraDataParts(rawExtraData) {
|
|
3044
|
-
const items = Array.isArray(rawExtraData) ? rawExtraData : rawExtraData && typeof rawExtraData === "object" ? Object.values(rawExtraData) : [];
|
|
3045
|
-
const parts = items.map((item) => {
|
|
3046
|
-
if (!item || typeof item !== "object") {
|
|
3047
|
-
return void 0;
|
|
3048
|
-
}
|
|
3049
|
-
const record = item;
|
|
3050
|
-
const keyCandidate = normalizeString(record.dataKey) ?? normalizeString(record.key) ?? normalizeString(record.name);
|
|
3051
|
-
if (!keyCandidate) {
|
|
3052
|
-
return void 0;
|
|
3053
|
-
}
|
|
3054
|
-
const canonical = normalizePartKey(keyCandidate);
|
|
3055
|
-
const partName = EXTRA_DATA_PART_KEY_MAP[canonical];
|
|
3056
|
-
if (!partName) {
|
|
3057
|
-
return void 0;
|
|
3058
|
-
}
|
|
3059
|
-
const balance = normalizeNumber(
|
|
3060
|
-
record.balance ?? record.amount ?? record.value ?? record.displayValue ?? record.text
|
|
3061
|
-
);
|
|
3062
|
-
if (balance === void 0) {
|
|
3063
|
-
return void 0;
|
|
3064
|
-
}
|
|
3065
|
-
return { name: partName, balance: Math.abs(balance) };
|
|
3066
|
-
}).filter((part) => Boolean(part));
|
|
3067
|
-
return parts.length ? parts : void 0;
|
|
3068
|
-
}
|
|
3069
2947
|
function parseToken(rawToken) {
|
|
3070
2948
|
if (!rawToken || typeof rawToken !== "object") {
|
|
3071
2949
|
return void 0;
|
|
@@ -3081,18 +2959,10 @@ function parseToken(rawToken) {
|
|
|
3081
2959
|
const apr = normalizeApr(token.apr) ?? normalizeApr(token.aprPercent) ?? normalizeApr(token.metrics?.apr) ?? normalizeApr(
|
|
3082
2960
|
token.metrics?.aprPercent
|
|
3083
2961
|
);
|
|
3084
|
-
const
|
|
3085
|
-
token.parts ?? token.balances ?? token.sections ?? token.breakdown ?? token.accountBreakdown ?? token.walletParts
|
|
3086
|
-
) ?? deriveParts(token);
|
|
3087
|
-
const parts = mergeParts(
|
|
3088
|
-
baseParts,
|
|
3089
|
-
normalizeExtraDataParts(
|
|
3090
|
-
token.extraData ?? token.extra_data ?? token.extra ?? token.badges
|
|
3091
|
-
)
|
|
3092
|
-
);
|
|
3093
|
-
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);
|
|
2962
|
+
const accountBalance = normalizeNumber(token.balance) ?? normalizeNumber(token.accountBalance) ?? normalizeNumber(token.totalBalance) ?? normalizeNumber(token.total) ?? normalizeNumber(token.amount) ?? 0;
|
|
3094
2963
|
const layer = normalizeString(token.layer) ?? normalizeString(token.chain) ?? normalizeString(token.category) ?? normalizeString(token.type);
|
|
3095
2964
|
const pendingRewards = normalizeNumber(token.pendingRewards);
|
|
2965
|
+
const savings = normalizeNumber(token.savings);
|
|
3096
2966
|
return {
|
|
3097
2967
|
symbol: normalizedSymbol,
|
|
3098
2968
|
name: normalizedSymbol,
|
|
@@ -3102,7 +2972,7 @@ function parseToken(rawToken) {
|
|
|
3102
2972
|
apr: apr ? Number.parseFloat(apr) : void 0,
|
|
3103
2973
|
layer: layer ?? void 0,
|
|
3104
2974
|
pendingRewards: pendingRewards ?? void 0,
|
|
3105
|
-
|
|
2975
|
+
savings: savings ?? void 0,
|
|
3106
2976
|
actions: token.actions ?? token.available_actions ?? token.availableActions ?? token.operations ?? token.supportedActions,
|
|
3107
2977
|
fiatRate: normalizeNumber(token.fiatRate) ?? void 0,
|
|
3108
2978
|
fiatCurrency: normalizeString(token.fiatCurrency) ?? void 0
|
|
@@ -3741,13 +3611,12 @@ function getAccountWalletAssetInfoQueryOptions(username, asset, options2 = { ref
|
|
|
3741
3611
|
if (!assetInfo) return void 0;
|
|
3742
3612
|
return {
|
|
3743
3613
|
name: assetInfo.name,
|
|
3744
|
-
title: assetInfo.title,
|
|
3614
|
+
title: assetInfo.title ?? assetInfo.name,
|
|
3745
3615
|
price: assetInfo.price ?? assetInfo.fiatRate ?? 0,
|
|
3746
3616
|
accountBalance: assetInfo.accountBalance ?? 0,
|
|
3747
|
-
apr: assetInfo.apr,
|
|
3617
|
+
apr: assetInfo.apr?.toString(),
|
|
3748
3618
|
layer: assetInfo.layer,
|
|
3749
|
-
pendingRewards: assetInfo.pendingRewards
|
|
3750
|
-
parts: assetInfo.parts
|
|
3619
|
+
pendingRewards: assetInfo.pendingRewards
|
|
3751
3620
|
};
|
|
3752
3621
|
} catch (e) {
|
|
3753
3622
|
return void 0;
|
|
@@ -3821,7 +3690,7 @@ function getTokenOperationsQueryOptions(token, username, isForOwner = false, cur
|
|
|
3821
3690
|
getVisionPortfolioQueryOptions(username, currency)
|
|
3822
3691
|
);
|
|
3823
3692
|
const assetEntry = portfolio.wallets.find(
|
|
3824
|
-
(assetItem) => assetItem.symbol?.toUpperCase() === normalizedToken
|
|
3693
|
+
(assetItem) => assetItem.symbol?.toUpperCase() === normalizedToken || assetItem.name?.toUpperCase() === normalizedToken
|
|
3825
3694
|
);
|
|
3826
3695
|
if (!assetEntry) {
|
|
3827
3696
|
return [];
|
|
@@ -3876,7 +3745,7 @@ function getTokenOperationsQueryOptions(token, username, isForOwner = false, cur
|
|
|
3876
3745
|
"swap": "swap" /* Swap */,
|
|
3877
3746
|
"swap-token": "swap" /* Swap */,
|
|
3878
3747
|
"swap-tokens": "swap" /* Swap */,
|
|
3879
|
-
"convert": "
|
|
3748
|
+
"convert": "convert" /* Convert */,
|
|
3880
3749
|
// Points operations
|
|
3881
3750
|
"promote": "promote" /* Promote */,
|
|
3882
3751
|
"promote-post": "promote" /* Promote */,
|
|
@@ -3904,9 +3773,10 @@ function getTokenOperationsQueryOptions(token, username, isForOwner = false, cur
|
|
|
3904
3773
|
(op) => op.toLowerCase() === canonical
|
|
3905
3774
|
);
|
|
3906
3775
|
return directMatch;
|
|
3907
|
-
}).filter((op) => Boolean(op));
|
|
3776
|
+
}).filter((op) => Boolean(op)).filter((op, index, self) => self.indexOf(op) === index);
|
|
3908
3777
|
const isHiveOrHbd = ["HIVE", "HBD"].includes(normalizedToken);
|
|
3909
|
-
const
|
|
3778
|
+
const rawToken = assetEntry;
|
|
3779
|
+
const hasSavings = Number(rawToken.savings ?? 0) > 0;
|
|
3910
3780
|
if (isHiveOrHbd && !hasSavings) {
|
|
3911
3781
|
return operations.filter(
|
|
3912
3782
|
(operation) => operation !== "withdraw-saving" /* WithdrawFromSavings */
|