@ecency/wallets 1.5.7 → 1.5.8

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.
@@ -1781,7 +1781,7 @@ declare function getAllTokensListQueryOptions(username?: string): _tanstack_reac
1781
1781
  };
1782
1782
  };
1783
1783
 
1784
- declare function getAccountWalletListQueryOptions(username: string): _tanstack_react_query.OmitKeyof<_tanstack_react_query.UseQueryOptions<string[], Error, string[], string[]>, "queryFn"> & {
1784
+ declare function getAccountWalletListQueryOptions(username: string, currency?: string): _tanstack_react_query.OmitKeyof<_tanstack_react_query.UseQueryOptions<string[], Error, string[], string[]>, "queryFn"> & {
1785
1785
  queryFn?: _tanstack_react_query.QueryFunction<string[], string[], never> | undefined;
1786
1786
  } & {
1787
1787
  queryKey: string[] & {
@@ -1792,6 +1792,7 @@ declare function getAccountWalletListQueryOptions(username: string): _tanstack_r
1792
1792
 
1793
1793
  interface Options {
1794
1794
  refetch: boolean;
1795
+ currency?: string;
1795
1796
  }
1796
1797
  declare function getAccountWalletAssetInfoQueryOptions(username: string, asset: string, options?: Options): _tanstack_react_query.OmitKeyof<_tanstack_react_query.UseQueryOptions<GeneralAssetInfo | undefined, Error, GeneralAssetInfo | undefined, string[]>, "queryFn"> & {
1797
1798
  queryFn?: _tanstack_react_query.QueryFunction<GeneralAssetInfo | undefined, string[], never> | undefined;
@@ -1802,7 +1803,7 @@ declare function getAccountWalletAssetInfoQueryOptions(username: string, asset:
1802
1803
  };
1803
1804
  };
1804
1805
 
1805
- declare function getTokenOperationsQueryOptions(token: string, username: string, isForOwner?: boolean): _tanstack_react_query.OmitKeyof<_tanstack_react_query.UseQueryOptions<AssetOperation[], Error, AssetOperation[], (string | boolean)[]>, "queryFn"> & {
1806
+ declare function getTokenOperationsQueryOptions(token: string, username: string, isForOwner?: boolean, currency?: string): _tanstack_react_query.OmitKeyof<_tanstack_react_query.UseQueryOptions<AssetOperation[], Error, AssetOperation[], (string | boolean)[]>, "queryFn"> & {
1806
1807
  queryFn?: _tanstack_react_query.QueryFunction<AssetOperation[], (string | boolean)[], never> | undefined;
1807
1808
  } & {
1808
1809
  queryKey: (string | boolean)[] & {
@@ -1823,7 +1824,7 @@ interface VisionPortfolioResponse {
1823
1824
  currency?: string;
1824
1825
  wallets: VisionPortfolioWalletItem[];
1825
1826
  }
1826
- declare function getVisionPortfolioQueryOptions(username: string): _tanstack_react_query.OmitKeyof<_tanstack_react_query.UseQueryOptions<VisionPortfolioResponse, Error, VisionPortfolioResponse, string[]>, "queryFn"> & {
1827
+ declare function getVisionPortfolioQueryOptions(username: string, currency?: string): _tanstack_react_query.OmitKeyof<_tanstack_react_query.UseQueryOptions<VisionPortfolioResponse, Error, VisionPortfolioResponse, string[]>, "queryFn"> & {
1827
1828
  queryFn?: _tanstack_react_query.QueryFunction<VisionPortfolioResponse, string[], never> | undefined;
1828
1829
  } & {
1829
1830
  queryKey: string[] & {
@@ -1477,7 +1477,7 @@ function useClaimRewards(username, auth, onSuccess) {
1477
1477
  queryKey: getAccountFullQueryOptions(username).queryKey
1478
1478
  });
1479
1479
  queryClient.invalidateQueries({
1480
- queryKey: getVisionPortfolioQueryOptions(username).queryKey
1480
+ queryKey: ["ecency-wallets", "portfolio", "v2", username]
1481
1481
  });
1482
1482
  queryClient.invalidateQueries({
1483
1483
  queryKey: getHiveAssetGeneralInfoQueryOptions(username).queryKey
@@ -1498,7 +1498,7 @@ function useClaimRewards(username, auth, onSuccess) {
1498
1498
  queryKey: getAccountFullQueryOptions(username).queryKey
1499
1499
  });
1500
1500
  queryClient.invalidateQueries({
1501
- queryKey: getVisionPortfolioQueryOptions(username).queryKey
1501
+ queryKey: ["ecency-wallets", "portfolio", "v2", username]
1502
1502
  });
1503
1503
  queryClient.invalidateQueries({
1504
1504
  queryKey: getHiveAssetGeneralInfoQueryOptions(username).queryKey
@@ -3125,9 +3125,7 @@ function parseToken(rawToken) {
3125
3125
  }
3126
3126
  const normalizedSymbol = symbol.toUpperCase();
3127
3127
  const title = normalizeString(token.title) ?? normalizeString(token.display) ?? normalizeString(token.label) ?? normalizeString(token.friendlyName) ?? normalizeString(token.name) ?? normalizedSymbol;
3128
- const price = normalizeNumber(token.fiatRate) ?? normalizeNumber(token.price) ?? normalizeNumber(token.priceUsd) ?? normalizeNumber(token.usdPrice) ?? normalizeNumber(token.metrics?.price) ?? normalizeNumber(
3129
- token.metrics?.priceUsd
3130
- ) ?? 0;
3128
+ const price = normalizeNumber(token.fiatRate) ?? 0;
3131
3129
  const apr = normalizeApr(token.apr) ?? normalizeApr(token.aprPercent) ?? normalizeApr(token.metrics?.apr) ?? normalizeApr(
3132
3130
  token.metrics?.aprPercent
3133
3131
  );
@@ -3204,14 +3202,15 @@ function resolveUsername(payload) {
3204
3202
  const record = payload;
3205
3203
  return normalizeString(record.username) ?? normalizeString(record.name) ?? normalizeString(record.account);
3206
3204
  }
3207
- function getVisionPortfolioQueryOptions(username) {
3205
+ function getVisionPortfolioQueryOptions(username, currency = "usd") {
3208
3206
  return queryOptions({
3209
3207
  queryKey: [
3210
3208
  "ecency-wallets",
3211
3209
  "portfolio",
3212
3210
  "v2",
3213
3211
  username,
3214
- "only-enabled"
3212
+ "only-enabled",
3213
+ currency
3215
3214
  ],
3216
3215
  enabled: Boolean(username),
3217
3216
  staleTime: 6e4,
@@ -3232,7 +3231,7 @@ function getVisionPortfolioQueryOptions(username) {
3232
3231
  Accept: "application/json",
3233
3232
  "Content-Type": "application/json"
3234
3233
  },
3235
- body: JSON.stringify({ username, onlyEnabled: true })
3234
+ body: JSON.stringify({ username, onlyEnabled: true, currency })
3236
3235
  });
3237
3236
  if (!response.ok) {
3238
3237
  throw new Error(
@@ -3249,7 +3248,7 @@ function getVisionPortfolioQueryOptions(username) {
3249
3248
  return {
3250
3249
  username: resolveUsername(payload) ?? username,
3251
3250
  currency: normalizeString(
3252
- payload?.currency
3251
+ payload?.fiatCurrency ?? payload?.currency
3253
3252
  )?.toUpperCase(),
3254
3253
  wallets: tokens
3255
3254
  };
@@ -3275,12 +3274,12 @@ var BASIC_TOKENS = [
3275
3274
  "HP" /* HivePower */,
3276
3275
  "HBD" /* HiveDollar */
3277
3276
  ];
3278
- function getAccountWalletListQueryOptions(username) {
3277
+ function getAccountWalletListQueryOptions(username, currency = "usd") {
3279
3278
  return queryOptions({
3280
- queryKey: ["ecency-wallets", "list", username],
3279
+ queryKey: ["ecency-wallets", "list", username, currency],
3281
3280
  enabled: !!username,
3282
3281
  queryFn: async () => {
3283
- const portfolioQuery = getVisionPortfolioQueryOptions(username);
3282
+ const portfolioQuery = getVisionPortfolioQueryOptions(username, currency);
3284
3283
  const queryClient = getQueryClient();
3285
3284
  const accountQuery = getAccountFullQueryOptions(username);
3286
3285
  let account;
@@ -3758,6 +3757,7 @@ function getTronAssetGeneralInfoQueryOptions(username) {
3758
3757
  // src/modules/wallets/queries/get-account-wallet-asset-info-query-options.ts
3759
3758
  function getAccountWalletAssetInfoQueryOptions(username, asset, options2 = { refetch: false }) {
3760
3759
  const queryClient = getQueryClient();
3760
+ const currency = options2.currency ?? "usd";
3761
3761
  const fetchQuery = async (queryOptions43) => {
3762
3762
  if (options2.refetch) {
3763
3763
  await queryClient.fetchQuery(queryOptions43);
@@ -3766,7 +3766,7 @@ function getAccountWalletAssetInfoQueryOptions(username, asset, options2 = { ref
3766
3766
  }
3767
3767
  return queryClient.getQueryData(queryOptions43.queryKey);
3768
3768
  };
3769
- const portfolioQuery = getVisionPortfolioQueryOptions(username);
3769
+ const portfolioQuery = getVisionPortfolioQueryOptions(username, currency);
3770
3770
  const getPortfolioAssetInfo = async () => {
3771
3771
  try {
3772
3772
  const portfolio = await queryClient.fetchQuery(portfolioQuery);
@@ -3779,7 +3779,7 @@ function getAccountWalletAssetInfoQueryOptions(username, asset, options2 = { ref
3779
3779
  }
3780
3780
  };
3781
3781
  return queryOptions({
3782
- queryKey: ["ecency-wallets", "asset-info", username, asset],
3782
+ queryKey: ["ecency-wallets", "asset-info", username, asset, currency],
3783
3783
  queryFn: async () => {
3784
3784
  const portfolioAssetInfo = await getPortfolioAssetInfo();
3785
3785
  if (portfolioAssetInfo) {
@@ -3839,9 +3839,9 @@ function hasNonZeroSavingsBalance(parts) {
3839
3839
  )
3840
3840
  );
3841
3841
  }
3842
- function getTokenOperationsQueryOptions(token, username, isForOwner = false) {
3842
+ function getTokenOperationsQueryOptions(token, username, isForOwner = false, currency = "usd") {
3843
3843
  return queryOptions({
3844
- queryKey: ["wallets", "token-operations", token, username, isForOwner],
3844
+ queryKey: ["wallets", "token-operations", token, username, isForOwner, currency],
3845
3845
  queryFn: async () => {
3846
3846
  const queryClient = getQueryClient();
3847
3847
  const normalizedToken = token.toUpperCase();
@@ -3850,7 +3850,7 @@ function getTokenOperationsQueryOptions(token, username, isForOwner = false) {
3850
3850
  }
3851
3851
  try {
3852
3852
  const portfolio = await queryClient.fetchQuery(
3853
- getVisionPortfolioQueryOptions(username)
3853
+ getVisionPortfolioQueryOptions(username, currency)
3854
3854
  );
3855
3855
  const assetEntry = portfolio.wallets.find(
3856
3856
  (assetItem) => assetItem.info.name === normalizedToken
@@ -4302,7 +4302,7 @@ function useWalletOperation(username, asset, operation, auth) {
4302
4302
  });
4303
4303
  setTimeout(
4304
4304
  () => getQueryClient().invalidateQueries({
4305
- queryKey: getVisionPortfolioQueryOptions(username).queryKey
4305
+ queryKey: ["ecency-wallets", "portfolio", "v2", username]
4306
4306
  }),
4307
4307
  4e3
4308
4308
  );