@ecency/wallets 1.5.19 → 1.5.21

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.
@@ -63,10 +63,23 @@ if (typeof globalLike._scrypt_bsv !== "undefined") {
63
63
  globalLike._scrypt_bsv = void 0;
64
64
  }
65
65
  }
66
+ if (typeof globalLike._bitcore !== "undefined") {
67
+ if (typeof globalLike._bitcore === "object") {
68
+ globalLike.__bitcorePreviousVersion = globalLike._bitcore;
69
+ }
70
+ try {
71
+ delete globalLike._bitcore;
72
+ } catch {
73
+ globalLike._bitcore = void 0;
74
+ }
75
+ }
66
76
  function rememberScryptBsvVersion() {
67
77
  if (typeof globalLike._scrypt_bsv === "string") {
68
78
  globalLike.__scryptBsvPreviousVersion = globalLike._scrypt_bsv;
69
79
  }
80
+ if (typeof globalLike._bitcore === "object") {
81
+ globalLike.__bitcorePreviousVersion = globalLike._bitcore;
82
+ }
70
83
  }
71
84
 
72
85
  // src/modules/wallets/enums/ecency-wallet-currency.ts
@@ -2987,162 +3000,8 @@ function getAllTokensListQueryOptions(username) {
2987
3000
  }
2988
3001
  });
2989
3002
  }
2990
- function normalizeString(value) {
2991
- if (typeof value === "string") {
2992
- const trimmed = value.trim();
2993
- return trimmed.length > 0 ? trimmed : void 0;
2994
- }
2995
- return void 0;
2996
- }
2997
- function normalizeNumber(value) {
2998
- if (typeof value === "number" && Number.isFinite(value)) {
2999
- return value;
3000
- }
3001
- if (typeof value === "string") {
3002
- const trimmed = value.trim();
3003
- if (!trimmed) {
3004
- return void 0;
3005
- }
3006
- const direct = Number.parseFloat(trimmed);
3007
- if (Number.isFinite(direct)) {
3008
- return direct;
3009
- }
3010
- const sanitized = trimmed.replace(/,/g, "");
3011
- const match = sanitized.match(/[-+]?\d+(?:\.\d+)?/);
3012
- if (match) {
3013
- const parsed = Number.parseFloat(match[0]);
3014
- if (Number.isFinite(parsed)) {
3015
- return parsed;
3016
- }
3017
- }
3018
- }
3019
- return void 0;
3020
- }
3021
- function parseToken(rawToken) {
3022
- if (!rawToken || typeof rawToken !== "object") {
3023
- return void 0;
3024
- }
3025
- const token = rawToken;
3026
- return {
3027
- name: normalizeString(token.name) ?? "",
3028
- symbol: normalizeString(token.symbol) ?? "",
3029
- layer: normalizeString(token.layer) ?? "hive",
3030
- balance: normalizeNumber(token.balance) ?? 0,
3031
- fiatRate: normalizeNumber(token.fiatRate) ?? 0,
3032
- currency: normalizeString(token.currency) ?? "usd",
3033
- precision: normalizeNumber(token.precision) ?? 3,
3034
- address: normalizeString(token.address),
3035
- error: normalizeString(token.error),
3036
- pendingRewards: normalizeNumber(token.pendingRewards),
3037
- pendingRewardsFiat: normalizeNumber(token.pendingRewardsFiat),
3038
- liquid: normalizeNumber(token.liquid),
3039
- liquidFiat: normalizeNumber(token.liquidFiat),
3040
- savings: normalizeNumber(token.savings),
3041
- savingsFiat: normalizeNumber(token.savingsFiat),
3042
- staked: normalizeNumber(token.staked),
3043
- stakedFiat: normalizeNumber(token.stakedFiat),
3044
- iconUrl: normalizeString(token.iconUrl),
3045
- actions: token.actions ?? [],
3046
- extraData: token.extraData ?? [],
3047
- apr: normalizeNumber(token.apr)
3048
- };
3049
- }
3050
- function extractTokens(payload) {
3051
- if (!payload || typeof payload !== "object") {
3052
- return [];
3053
- }
3054
- const containers = [payload];
3055
- const record = payload;
3056
- if (record.data && typeof record.data === "object") {
3057
- containers.push(record.data);
3058
- }
3059
- if (record.result && typeof record.result === "object") {
3060
- containers.push(record.result);
3061
- }
3062
- if (record.portfolio && typeof record.portfolio === "object") {
3063
- containers.push(record.portfolio);
3064
- }
3065
- for (const container of containers) {
3066
- if (Array.isArray(container)) {
3067
- return container;
3068
- }
3069
- if (container && typeof container === "object") {
3070
- for (const key of [
3071
- "wallets",
3072
- "tokens",
3073
- "assets",
3074
- "items",
3075
- "portfolio",
3076
- "balances"
3077
- ]) {
3078
- const value = container[key];
3079
- if (Array.isArray(value)) {
3080
- return value;
3081
- }
3082
- }
3083
- }
3084
- }
3085
- return [];
3086
- }
3087
- function resolveUsername(payload) {
3088
- if (!payload || typeof payload !== "object") {
3089
- return void 0;
3090
- }
3091
- const record = payload;
3092
- return normalizeString(record.username) ?? normalizeString(record.name) ?? normalizeString(record.account);
3093
- }
3094
3003
  function getVisionPortfolioQueryOptions(username, currency = "usd") {
3095
- return reactQuery.queryOptions({
3096
- queryKey: [
3097
- "ecency-wallets",
3098
- "portfolio",
3099
- "v2",
3100
- username,
3101
- "only-enabled",
3102
- currency
3103
- ],
3104
- enabled: Boolean(username),
3105
- staleTime: 6e4,
3106
- refetchInterval: 12e4,
3107
- queryFn: async () => {
3108
- if (!username) {
3109
- throw new Error("[SDK][Wallets] \u2013 username is required");
3110
- }
3111
- if (sdk.CONFIG.privateApiHost === void 0 || sdk.CONFIG.privateApiHost === null) {
3112
- throw new Error(
3113
- "[SDK][Wallets] \u2013 privateApiHost isn't configured for portfolio"
3114
- );
3115
- }
3116
- const endpoint = `${sdk.CONFIG.privateApiHost}/wallet-api/portfolio-v2`;
3117
- const response = await fetch(endpoint, {
3118
- method: "POST",
3119
- headers: {
3120
- Accept: "application/json",
3121
- "Content-Type": "application/json"
3122
- },
3123
- body: JSON.stringify({ username, onlyEnabled: true, currency })
3124
- });
3125
- if (!response.ok) {
3126
- throw new Error(
3127
- `[SDK][Wallets] \u2013 Vision portfolio request failed(${response.status})`
3128
- );
3129
- }
3130
- const payload = await response.json();
3131
- const tokens = extractTokens(payload).map((item) => parseToken(item)).filter((item) => Boolean(item));
3132
- if (!tokens.length) {
3133
- throw new Error(
3134
- "[SDK][Wallets] \u2013 Vision portfolio payload contained no tokens"
3135
- );
3136
- }
3137
- return {
3138
- username: resolveUsername(payload) ?? username,
3139
- currency: normalizeString(
3140
- payload?.fiatCurrency ?? payload?.currency
3141
- )?.toUpperCase(),
3142
- wallets: tokens
3143
- };
3144
- }
3145
- });
3004
+ return sdk.getPortfolioQueryOptions(username, currency, true);
3146
3005
  }
3147
3006
 
3148
3007
  // src/modules/wallets/queries/use-get-account-wallet-list-query.ts
@@ -3647,13 +3506,13 @@ function getTronAssetGeneralInfoQueryOptions(username) {
3647
3506
  function getAccountWalletAssetInfoQueryOptions(username, asset, options2 = { refetch: false }) {
3648
3507
  const queryClient = sdk.getQueryClient();
3649
3508
  const currency = options2.currency ?? "usd";
3650
- const fetchQuery = async (queryOptions43) => {
3509
+ const fetchQuery = async (queryOptions42) => {
3651
3510
  if (options2.refetch) {
3652
- await queryClient.fetchQuery(queryOptions43);
3511
+ await queryClient.fetchQuery(queryOptions42);
3653
3512
  } else {
3654
- await queryClient.prefetchQuery(queryOptions43);
3513
+ await queryClient.prefetchQuery(queryOptions42);
3655
3514
  }
3656
- return queryClient.getQueryData(queryOptions43.queryKey);
3515
+ return queryClient.getQueryData(queryOptions42.queryKey);
3657
3516
  };
3658
3517
  const convertPriceToUserCurrency = async (assetInfo) => {
3659
3518
  if (!assetInfo || currency === "usd") {