@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/node/index.cjs
CHANGED
|
@@ -3055,6 +3055,12 @@ function getVisionPortfolioQueryOptions(username) {
|
|
|
3055
3055
|
}
|
|
3056
3056
|
|
|
3057
3057
|
// src/modules/wallets/queries/use-get-account-wallet-list-query.ts
|
|
3058
|
+
var BASIC_TOKENS = [
|
|
3059
|
+
"POINTS" /* Points */,
|
|
3060
|
+
"HIVE" /* Hive */,
|
|
3061
|
+
"HP" /* HivePower */,
|
|
3062
|
+
"HBD" /* HiveDollar */
|
|
3063
|
+
];
|
|
3058
3064
|
function getAccountWalletListQueryOptions(username) {
|
|
3059
3065
|
return reactQuery.queryOptions({
|
|
3060
3066
|
queryKey: ["ecency-wallets", "list", username],
|
|
@@ -3062,39 +3068,54 @@ function getAccountWalletListQueryOptions(username) {
|
|
|
3062
3068
|
queryFn: async () => {
|
|
3063
3069
|
const portfolioQuery = getVisionPortfolioQueryOptions(username);
|
|
3064
3070
|
const queryClient = sdk.getQueryClient();
|
|
3071
|
+
const accountQuery = sdk.getAccountFullQueryOptions(username);
|
|
3072
|
+
let account;
|
|
3073
|
+
try {
|
|
3074
|
+
account = await queryClient.fetchQuery(accountQuery);
|
|
3075
|
+
} catch {
|
|
3076
|
+
}
|
|
3077
|
+
const tokenVisibility = /* @__PURE__ */ new Map();
|
|
3078
|
+
account?.profile?.tokens?.forEach((token) => {
|
|
3079
|
+
const symbol = token.symbol?.toUpperCase?.();
|
|
3080
|
+
if (!symbol) {
|
|
3081
|
+
return;
|
|
3082
|
+
}
|
|
3083
|
+
const showValue = token?.meta?.show;
|
|
3084
|
+
if (typeof showValue === "boolean") {
|
|
3085
|
+
tokenVisibility.set(symbol, showValue);
|
|
3086
|
+
}
|
|
3087
|
+
});
|
|
3088
|
+
const isTokenVisible = (symbol) => {
|
|
3089
|
+
const normalized = symbol?.toUpperCase();
|
|
3090
|
+
if (!normalized) {
|
|
3091
|
+
return false;
|
|
3092
|
+
}
|
|
3093
|
+
if (BASIC_TOKENS.includes(normalized)) {
|
|
3094
|
+
return true;
|
|
3095
|
+
}
|
|
3096
|
+
return tokenVisibility.get(normalized) === true;
|
|
3097
|
+
};
|
|
3065
3098
|
try {
|
|
3066
3099
|
const portfolio = await queryClient.fetchQuery(portfolioQuery);
|
|
3067
3100
|
const tokensFromPortfolio = portfolio.wallets.map(
|
|
3068
3101
|
(asset) => asset.info.name
|
|
3069
3102
|
);
|
|
3070
3103
|
if (tokensFromPortfolio.length > 0) {
|
|
3071
|
-
|
|
3104
|
+
const visibleTokens = tokensFromPortfolio.map((token) => token?.toUpperCase?.()).filter((token) => Boolean(token)).filter(isTokenVisible);
|
|
3105
|
+
if (visibleTokens.length > 0) {
|
|
3106
|
+
return Array.from(new Set(visibleTokens));
|
|
3107
|
+
}
|
|
3072
3108
|
}
|
|
3073
3109
|
} catch {
|
|
3074
3110
|
}
|
|
3075
|
-
const accountQuery = sdk.getAccountFullQueryOptions(username);
|
|
3076
|
-
await queryClient.fetchQuery({
|
|
3077
|
-
queryKey: accountQuery.queryKey
|
|
3078
|
-
});
|
|
3079
|
-
const account = queryClient.getQueryData(
|
|
3080
|
-
accountQuery.queryKey
|
|
3081
|
-
);
|
|
3082
3111
|
if (account?.profile?.tokens instanceof Array) {
|
|
3083
3112
|
const list = [
|
|
3084
|
-
|
|
3085
|
-
|
|
3086
|
-
"HP" /* HivePower */,
|
|
3087
|
-
"HBD" /* HiveDollar */,
|
|
3088
|
-
...account.profile.tokens.filter(({ meta }) => !!meta?.show).map((token) => token.symbol)
|
|
3113
|
+
...BASIC_TOKENS,
|
|
3114
|
+
...account.profile.tokens.map((token) => token.symbol).filter(isTokenVisible)
|
|
3089
3115
|
];
|
|
3090
3116
|
return Array.from(new Set(list).values());
|
|
3091
3117
|
}
|
|
3092
|
-
return [
|
|
3093
|
-
"POINTS" /* Points */,
|
|
3094
|
-
"HIVE" /* Hive */,
|
|
3095
|
-
"HP" /* HivePower */,
|
|
3096
|
-
"HBD" /* HiveDollar */
|
|
3097
|
-
];
|
|
3118
|
+
return [...BASIC_TOKENS];
|
|
3098
3119
|
}
|
|
3099
3120
|
});
|
|
3100
3121
|
}
|
|
@@ -3593,6 +3614,16 @@ function getAccountWalletAssetInfoQueryOptions(username, asset, options2 = { ref
|
|
|
3593
3614
|
}
|
|
3594
3615
|
});
|
|
3595
3616
|
}
|
|
3617
|
+
function normalizePartKey2(value) {
|
|
3618
|
+
return value.trim().toLowerCase().replace(/[\s-]+/g, "_");
|
|
3619
|
+
}
|
|
3620
|
+
function hasNonZeroSavingsBalance(parts) {
|
|
3621
|
+
return Boolean(
|
|
3622
|
+
parts?.some(
|
|
3623
|
+
(part) => normalizePartKey2(part.name) === "savings" && Number(part.balance) > 0
|
|
3624
|
+
)
|
|
3625
|
+
);
|
|
3626
|
+
}
|
|
3596
3627
|
function getTokenOperationsQueryOptions(token, username, isForOwner = false) {
|
|
3597
3628
|
return reactQuery.queryOptions({
|
|
3598
3629
|
queryKey: ["wallets", "token-operations", token, username, isForOwner],
|
|
@@ -3609,7 +3640,19 @@ function getTokenOperationsQueryOptions(token, username, isForOwner = false) {
|
|
|
3609
3640
|
const assetEntry = portfolio.wallets.find(
|
|
3610
3641
|
(assetItem) => assetItem.info.name === normalizedToken
|
|
3611
3642
|
);
|
|
3612
|
-
|
|
3643
|
+
if (!assetEntry) {
|
|
3644
|
+
return [];
|
|
3645
|
+
}
|
|
3646
|
+
const operations = assetEntry.operations ?? [];
|
|
3647
|
+
const isHiveOrHbd = ["HIVE", "HBD"].includes(
|
|
3648
|
+
assetEntry.info.name.toUpperCase()
|
|
3649
|
+
);
|
|
3650
|
+
if (isHiveOrHbd && !hasNonZeroSavingsBalance(assetEntry.info.parts)) {
|
|
3651
|
+
return operations.filter(
|
|
3652
|
+
(operation) => operation !== "withdraw-saving" /* WithdrawFromSavings */
|
|
3653
|
+
);
|
|
3654
|
+
}
|
|
3655
|
+
return operations;
|
|
3613
3656
|
} catch {
|
|
3614
3657
|
return [];
|
|
3615
3658
|
}
|