@ecency/wallets 1.4.30 → 1.4.32
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.js +63 -20
- package/dist/browser/index.js.map +1 -1
- package/dist/node/index.cjs +63 -20
- package/dist/node/index.cjs.map +1 -1
- package/dist/node/index.mjs +63 -20
- package/dist/node/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/browser/index.js
CHANGED
|
@@ -3028,6 +3028,12 @@ function getVisionPortfolioQueryOptions(username) {
|
|
|
3028
3028
|
}
|
|
3029
3029
|
|
|
3030
3030
|
// src/modules/wallets/queries/use-get-account-wallet-list-query.ts
|
|
3031
|
+
var BASIC_TOKENS = [
|
|
3032
|
+
"POINTS" /* Points */,
|
|
3033
|
+
"HIVE" /* Hive */,
|
|
3034
|
+
"HP" /* HivePower */,
|
|
3035
|
+
"HBD" /* HiveDollar */
|
|
3036
|
+
];
|
|
3031
3037
|
function getAccountWalletListQueryOptions(username) {
|
|
3032
3038
|
return queryOptions({
|
|
3033
3039
|
queryKey: ["ecency-wallets", "list", username],
|
|
@@ -3035,39 +3041,54 @@ function getAccountWalletListQueryOptions(username) {
|
|
|
3035
3041
|
queryFn: async () => {
|
|
3036
3042
|
const portfolioQuery = getVisionPortfolioQueryOptions(username);
|
|
3037
3043
|
const queryClient = getQueryClient();
|
|
3044
|
+
const accountQuery = getAccountFullQueryOptions(username);
|
|
3045
|
+
let account;
|
|
3046
|
+
try {
|
|
3047
|
+
account = await queryClient.fetchQuery(accountQuery);
|
|
3048
|
+
} catch {
|
|
3049
|
+
}
|
|
3050
|
+
const tokenVisibility = /* @__PURE__ */ new Map();
|
|
3051
|
+
account?.profile?.tokens?.forEach((token) => {
|
|
3052
|
+
const symbol = token.symbol?.toUpperCase?.();
|
|
3053
|
+
if (!symbol) {
|
|
3054
|
+
return;
|
|
3055
|
+
}
|
|
3056
|
+
const showValue = token?.meta?.show;
|
|
3057
|
+
if (typeof showValue === "boolean") {
|
|
3058
|
+
tokenVisibility.set(symbol, showValue);
|
|
3059
|
+
}
|
|
3060
|
+
});
|
|
3061
|
+
const isTokenVisible = (symbol) => {
|
|
3062
|
+
const normalized = symbol?.toUpperCase();
|
|
3063
|
+
if (!normalized) {
|
|
3064
|
+
return false;
|
|
3065
|
+
}
|
|
3066
|
+
if (BASIC_TOKENS.includes(normalized)) {
|
|
3067
|
+
return true;
|
|
3068
|
+
}
|
|
3069
|
+
return tokenVisibility.get(normalized) === true;
|
|
3070
|
+
};
|
|
3038
3071
|
try {
|
|
3039
3072
|
const portfolio = await queryClient.fetchQuery(portfolioQuery);
|
|
3040
3073
|
const tokensFromPortfolio = portfolio.wallets.map(
|
|
3041
3074
|
(asset) => asset.info.name
|
|
3042
3075
|
);
|
|
3043
3076
|
if (tokensFromPortfolio.length > 0) {
|
|
3044
|
-
|
|
3077
|
+
const visibleTokens = tokensFromPortfolio.map((token) => token?.toUpperCase?.()).filter((token) => Boolean(token)).filter(isTokenVisible);
|
|
3078
|
+
if (visibleTokens.length > 0) {
|
|
3079
|
+
return Array.from(new Set(visibleTokens));
|
|
3080
|
+
}
|
|
3045
3081
|
}
|
|
3046
3082
|
} catch {
|
|
3047
3083
|
}
|
|
3048
|
-
const accountQuery = getAccountFullQueryOptions(username);
|
|
3049
|
-
await queryClient.fetchQuery({
|
|
3050
|
-
queryKey: accountQuery.queryKey
|
|
3051
|
-
});
|
|
3052
|
-
const account = queryClient.getQueryData(
|
|
3053
|
-
accountQuery.queryKey
|
|
3054
|
-
);
|
|
3055
3084
|
if (account?.profile?.tokens instanceof Array) {
|
|
3056
3085
|
const list = [
|
|
3057
|
-
|
|
3058
|
-
|
|
3059
|
-
"HP" /* HivePower */,
|
|
3060
|
-
"HBD" /* HiveDollar */,
|
|
3061
|
-
...account.profile.tokens.filter(({ meta }) => !!meta?.show).map((token) => token.symbol)
|
|
3086
|
+
...BASIC_TOKENS,
|
|
3087
|
+
...account.profile.tokens.map((token) => token.symbol).filter(isTokenVisible)
|
|
3062
3088
|
];
|
|
3063
3089
|
return Array.from(new Set(list).values());
|
|
3064
3090
|
}
|
|
3065
|
-
return [
|
|
3066
|
-
"POINTS" /* Points */,
|
|
3067
|
-
"HIVE" /* Hive */,
|
|
3068
|
-
"HP" /* HivePower */,
|
|
3069
|
-
"HBD" /* HiveDollar */
|
|
3070
|
-
];
|
|
3091
|
+
return [...BASIC_TOKENS];
|
|
3071
3092
|
}
|
|
3072
3093
|
});
|
|
3073
3094
|
}
|
|
@@ -3566,6 +3587,16 @@ function getAccountWalletAssetInfoQueryOptions(username, asset, options2 = { ref
|
|
|
3566
3587
|
}
|
|
3567
3588
|
});
|
|
3568
3589
|
}
|
|
3590
|
+
function normalizePartKey2(value) {
|
|
3591
|
+
return value.trim().toLowerCase().replace(/[\s-]+/g, "_");
|
|
3592
|
+
}
|
|
3593
|
+
function hasNonZeroSavingsBalance(parts) {
|
|
3594
|
+
return Boolean(
|
|
3595
|
+
parts?.some(
|
|
3596
|
+
(part) => normalizePartKey2(part.name) === "savings" && Number(part.balance) > 0
|
|
3597
|
+
)
|
|
3598
|
+
);
|
|
3599
|
+
}
|
|
3569
3600
|
function getTokenOperationsQueryOptions(token, username, isForOwner = false) {
|
|
3570
3601
|
return queryOptions({
|
|
3571
3602
|
queryKey: ["wallets", "token-operations", token, username, isForOwner],
|
|
@@ -3582,7 +3613,19 @@ function getTokenOperationsQueryOptions(token, username, isForOwner = false) {
|
|
|
3582
3613
|
const assetEntry = portfolio.wallets.find(
|
|
3583
3614
|
(assetItem) => assetItem.info.name === normalizedToken
|
|
3584
3615
|
);
|
|
3585
|
-
|
|
3616
|
+
if (!assetEntry) {
|
|
3617
|
+
return [];
|
|
3618
|
+
}
|
|
3619
|
+
const operations = assetEntry.operations ?? [];
|
|
3620
|
+
const isHiveOrHbd = ["HIVE", "HBD"].includes(
|
|
3621
|
+
assetEntry.info.name.toUpperCase()
|
|
3622
|
+
);
|
|
3623
|
+
if (isHiveOrHbd && !hasNonZeroSavingsBalance(assetEntry.info.parts)) {
|
|
3624
|
+
return operations.filter(
|
|
3625
|
+
(operation) => operation !== "withdraw-saving" /* WithdrawFromSavings */
|
|
3626
|
+
);
|
|
3627
|
+
}
|
|
3628
|
+
return operations;
|
|
3586
3629
|
} catch {
|
|
3587
3630
|
return [];
|
|
3588
3631
|
}
|