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