@ecency/wallets 1.4.7 → 1.4.9

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.
@@ -1055,12 +1055,20 @@ declare function getHiveEngineTokenGeneralInfoQueryOptions(username?: string, sy
1055
1055
  price: number;
1056
1056
  accountBalance: number;
1057
1057
  layer: string;
1058
+ parts: {
1059
+ name: string;
1060
+ balance: number;
1061
+ }[];
1058
1062
  }, Error, {
1059
1063
  name: string;
1060
1064
  title: string;
1061
1065
  price: number;
1062
1066
  accountBalance: number;
1063
1067
  layer: string;
1068
+ parts: {
1069
+ name: string;
1070
+ balance: number;
1071
+ }[];
1064
1072
  }, (string | undefined)[]>, "queryFn"> & {
1065
1073
  queryFn?: _tanstack_react_query.QueryFunction<{
1066
1074
  name: string;
@@ -1068,6 +1076,10 @@ declare function getHiveEngineTokenGeneralInfoQueryOptions(username?: string, sy
1068
1076
  price: number;
1069
1077
  accountBalance: number;
1070
1078
  layer: string;
1079
+ parts: {
1080
+ name: string;
1081
+ balance: number;
1082
+ }[];
1071
1083
  }, (string | undefined)[], never> | undefined;
1072
1084
  } & {
1073
1085
  queryKey: (string | undefined)[] & {
@@ -1077,6 +1089,10 @@ declare function getHiveEngineTokenGeneralInfoQueryOptions(username?: string, sy
1077
1089
  price: number;
1078
1090
  accountBalance: number;
1079
1091
  layer: string;
1092
+ parts: {
1093
+ name: string;
1094
+ balance: number;
1095
+ }[];
1080
1096
  };
1081
1097
  [dataTagErrorSymbol]: Error;
1082
1098
  };
@@ -1149,10 +1165,10 @@ interface HiveEngineMetric {
1149
1165
  timestamp: number;
1150
1166
  }
1151
1167
 
1152
- declare function getHiveEngineTokensMetadataQueryOptions(tokens: string[]): _tanstack_react_query.OmitKeyof<_tanstack_react_query.UseQueryOptions<HiveEngineTokenMetadataResponse[], Error, HiveEngineTokenMetadataResponse[], (string | string[])[]>, "queryFn"> & {
1153
- queryFn?: _tanstack_react_query.QueryFunction<HiveEngineTokenMetadataResponse[], (string | string[])[], never> | undefined;
1168
+ declare function getHiveEngineTokensMetadataQueryOptions(tokens: string[]): _tanstack_react_query.OmitKeyof<_tanstack_react_query.UseQueryOptions<HiveEngineTokenMetadataResponse[], Error, HiveEngineTokenMetadataResponse[], readonly ["assets", "hive-engine", "metadata-list", string[]]>, "queryFn"> & {
1169
+ queryFn?: _tanstack_react_query.QueryFunction<HiveEngineTokenMetadataResponse[], readonly ["assets", "hive-engine", "metadata-list", string[]], never> | undefined;
1154
1170
  } & {
1155
- queryKey: (string | string[])[] & {
1171
+ queryKey: readonly ["assets", "hive-engine", "metadata-list", string[]] & {
1156
1172
  [dataTagSymbol]: HiveEngineTokenMetadataResponse[];
1157
1173
  [dataTagErrorSymbol]: Error;
1158
1174
  };
@@ -1185,10 +1201,10 @@ declare function getHiveEngineTokensMarketQueryOptions(): _tanstack_react_query.
1185
1201
  };
1186
1202
  };
1187
1203
 
1188
- declare function getHiveEngineTokensBalancesQueryOptions(username: string): _tanstack_react_query.OmitKeyof<_tanstack_react_query.UseQueryOptions<HiveEngineTokenBalance[], Error, HiveEngineTokenBalance[], string[]>, "queryFn"> & {
1189
- queryFn?: _tanstack_react_query.QueryFunction<HiveEngineTokenBalance[], string[], never> | undefined;
1204
+ declare function getHiveEngineTokensBalancesQueryOptions(username: string): _tanstack_react_query.OmitKeyof<_tanstack_react_query.UseQueryOptions<HiveEngineTokenBalance[], Error, HiveEngineTokenBalance[], readonly ["assets", "hive-engine", "balances", string]>, "queryFn"> & {
1205
+ queryFn?: _tanstack_react_query.QueryFunction<HiveEngineTokenBalance[], readonly ["assets", "hive-engine", "balances", string], never> | undefined;
1190
1206
  } & {
1191
- queryKey: string[] & {
1207
+ queryKey: readonly ["assets", "hive-engine", "balances", string] & {
1192
1208
  [dataTagSymbol]: HiveEngineTokenBalance[];
1193
1209
  [dataTagErrorSymbol]: Error;
1194
1210
  };
@@ -1413,7 +1429,7 @@ declare function useGetExternalWalletBalanceQuery(currency: EcencyWalletCurrency
1413
1429
 
1414
1430
  declare function useSeedPhrase(username: string): _tanstack_react_query.UseQueryResult<string, Error>;
1415
1431
 
1416
- declare function getCoinGeckoPriceQueryOptions(currency?: string): _tanstack_react_query.OmitKeyof<_tanstack_react_query.UseQueryOptions<number, Error, number, (string | undefined)[]>, "queryFn"> & {
1432
+ declare function getTokenPriceQueryOptions(currency?: string): _tanstack_react_query.OmitKeyof<_tanstack_react_query.UseQueryOptions<number, Error, number, (string | undefined)[]>, "queryFn"> & {
1417
1433
  queryFn?: _tanstack_react_query.QueryFunction<number, (string | undefined)[], never> | undefined;
1418
1434
  } & {
1419
1435
  queryKey: (string | undefined)[] & {
@@ -1644,4 +1660,4 @@ declare function buildExternalTx(currency: EcencyWalletCurrency, tx: ExternalTxP
1644
1660
 
1645
1661
  declare function getBoundFetch(): typeof fetch;
1646
1662
 
1647
- export { type AccountPointsResponse, type Asset, AssetOperation, type DelegateEnginePayload, type EcencyHiveKeys, type EcencyTokenMetadata, EcencyWalletBasicTokens, EcencyWalletCurrency, index as EcencyWalletsPrivateApi, type ExternalTxParams, type ExternalWalletBalance, type GeneralAssetInfo, type GeneralAssetTransaction, type HiveBasedAssetSignType, type HiveEngineMarketResponse, type HiveEngineMetric, type HiveEngineTokenBalance, type HiveEngineTokenMetadataResponse, type HiveEngineTransaction, type HiveKeyDerivation, type HiveRole, NaiMap, type PointTransaction, PointTransactionType, type Points, type PointsResponse, type SpkApiWallet, type SpkMarkets, type StakeEnginePayload, Symbol, type TransferEnginePayload, type TransferPayload, type TransformedSpkMarkets, type UndelegateEnginePayload, type UnstakeEnginePayload, buildAptTx, buildEthTx, buildExternalTx, buildPsbt, buildSolTx, buildTonTx, buildTronTx, decryptMemoWithAccounts, decryptMemoWithKeys, delay, delegateEngineToken, delegateHive, deriveHiveKey, deriveHiveKeys, deriveHiveMasterPasswordKey, deriveHiveMasterPasswordKeys, detectHiveKeyDerivation, encryptMemoWithAccounts, encryptMemoWithKeys, getAccountWalletAssetInfoQueryOptions, getAccountWalletListQueryOptions, getAllTokensListQueryOptions, getBoundFetch, getCoinGeckoPriceQueryOptions, getHbdAssetGeneralInfoQueryOptions, getHbdAssetTransactionsQueryOptions, getHiveAssetGeneralInfoQueryOptions, getHiveAssetMetricQueryOptions, getHiveAssetTransactionsQueryOptions, getHiveAssetWithdrawalRoutesQueryOptions, getHiveEngineTokenGeneralInfoQueryOptions, getHiveEngineTokenTransactionsQueryOptions, getHiveEngineTokensBalancesQueryOptions, getHiveEngineTokensMarketQueryOptions, getHiveEngineTokensMetadataQueryOptions, getHiveEngineTokensMetricsQueryOptions, getHivePowerAssetGeneralInfoQueryOptions, getHivePowerAssetTransactionsQueryOptions, getHivePowerDelegatesInfiniteQueryOptions, getHivePowerDelegatingsQueryOptions, getLarynxAssetGeneralInfoQueryOptions, getLarynxPowerAssetGeneralInfoQueryOptions, getPointsAssetGeneralInfoQueryOptions, getPointsAssetTransactionsQueryOptions, getPointsQueryOptions, getSpkAssetGeneralInfoQueryOptions, getSpkMarketsQueryOptions, getTokenOperationsQueryOptions, getWallet, isEmptyDate, lockLarynx, mnemonicToSeedBip39, parseAsset, powerDownHive, powerUpHive, powerUpLarynx, rewardSpk, signDigest, signExternalTx, signExternalTxAndBroadcast, signTx, signTxAndBroadcast, stakeEngineToken, transferEngineToken, transferHive, transferPoint, transferSpk, transferToSavingsHive, undelegateEngineToken, unstakeEngineToken, useClaimPoints, useClaimRewards, useGetExternalWalletBalanceQuery, useHiveKeysQuery, useImportWallet, useSaveWalletInformationToMetadata, useSeedPhrase, useWalletCreate, useWalletOperation, useWalletsCacheQuery, vestsToHp, withdrawVestingRouteHive };
1663
+ export { type AccountPointsResponse, type Asset, AssetOperation, type DelegateEnginePayload, type EcencyHiveKeys, type EcencyTokenMetadata, EcencyWalletBasicTokens, EcencyWalletCurrency, index as EcencyWalletsPrivateApi, type ExternalTxParams, type ExternalWalletBalance, type GeneralAssetInfo, type GeneralAssetTransaction, type HiveBasedAssetSignType, type HiveEngineMarketResponse, type HiveEngineMetric, type HiveEngineTokenBalance, type HiveEngineTokenMetadataResponse, type HiveEngineTransaction, type HiveKeyDerivation, type HiveRole, NaiMap, type PointTransaction, PointTransactionType, type Points, type PointsResponse, type SpkApiWallet, type SpkMarkets, type StakeEnginePayload, Symbol, type TransferEnginePayload, type TransferPayload, type TransformedSpkMarkets, type UndelegateEnginePayload, type UnstakeEnginePayload, buildAptTx, buildEthTx, buildExternalTx, buildPsbt, buildSolTx, buildTonTx, buildTronTx, decryptMemoWithAccounts, decryptMemoWithKeys, delay, delegateEngineToken, delegateHive, deriveHiveKey, deriveHiveKeys, deriveHiveMasterPasswordKey, deriveHiveMasterPasswordKeys, detectHiveKeyDerivation, encryptMemoWithAccounts, encryptMemoWithKeys, getAccountWalletAssetInfoQueryOptions, getAccountWalletListQueryOptions, getAllTokensListQueryOptions, getBoundFetch, getHbdAssetGeneralInfoQueryOptions, getHbdAssetTransactionsQueryOptions, getHiveAssetGeneralInfoQueryOptions, getHiveAssetMetricQueryOptions, getHiveAssetTransactionsQueryOptions, getHiveAssetWithdrawalRoutesQueryOptions, getHiveEngineTokenGeneralInfoQueryOptions, getHiveEngineTokenTransactionsQueryOptions, getHiveEngineTokensBalancesQueryOptions, getHiveEngineTokensMarketQueryOptions, getHiveEngineTokensMetadataQueryOptions, getHiveEngineTokensMetricsQueryOptions, getHivePowerAssetGeneralInfoQueryOptions, getHivePowerAssetTransactionsQueryOptions, getHivePowerDelegatesInfiniteQueryOptions, getHivePowerDelegatingsQueryOptions, getLarynxAssetGeneralInfoQueryOptions, getLarynxPowerAssetGeneralInfoQueryOptions, getPointsAssetGeneralInfoQueryOptions, getPointsAssetTransactionsQueryOptions, getPointsQueryOptions, getSpkAssetGeneralInfoQueryOptions, getSpkMarketsQueryOptions, getTokenOperationsQueryOptions, getTokenPriceQueryOptions, getWallet, isEmptyDate, lockLarynx, mnemonicToSeedBip39, parseAsset, powerDownHive, powerUpHive, powerUpLarynx, rewardSpk, signDigest, signExternalTx, signExternalTxAndBroadcast, signTx, signTxAndBroadcast, stakeEngineToken, transferEngineToken, transferHive, transferPoint, transferSpk, transferToSavingsHive, undelegateEngineToken, unstakeEngineToken, useClaimPoints, useClaimRewards, useGetExternalWalletBalanceQuery, useHiveKeysQuery, useImportWallet, useSaveWalletInformationToMetadata, useSeedPhrase, useWalletCreate, useWalletOperation, useWalletsCacheQuery, vestsToHp, withdrawVestingRouteHive };
@@ -202,55 +202,67 @@ var cacheGet = (key) => {
202
202
  const v = cache.get(key);
203
203
  return v === undefinedValue ? void 0 : v;
204
204
  };
205
- function getCoinGeckoPriceQueryOptions(currency) {
205
+ var CURRENCY_TO_TOKEN_MAP = {
206
+ ["BTC" /* BTC */]: "btc",
207
+ ["ETH" /* ETH */]: "eth",
208
+ ["SOL" /* SOL */]: "sol",
209
+ ["TON" /* TON */]: "ton",
210
+ ["TRX" /* TRON */]: "trx",
211
+ ["APT" /* APT */]: "apt",
212
+ ["BNB" /* BNB */]: "bnb",
213
+ HBD: "hbd",
214
+ HIVE: "hive"
215
+ };
216
+ var MARKET_DATA_CACHE_KEY = "market-data/latest";
217
+ var normalizeCurrencyToToken = (currency) => {
218
+ const upperCased = currency.toUpperCase();
219
+ return CURRENCY_TO_TOKEN_MAP[upperCased] ?? currency.toLowerCase();
220
+ };
221
+ function getTokenPriceQueryOptions(currency) {
206
222
  return queryOptions({
207
- queryKey: ["ecency-wallets", "coingecko-price", currency],
223
+ queryKey: ["ecency-wallets", "market-data", currency],
208
224
  queryFn: async () => {
209
- let curr = currency;
210
- switch (currency) {
211
- case "BTC" /* BTC */:
212
- curr = "bitcoin";
213
- break;
214
- case "ETH" /* ETH */:
215
- curr = "ethereum";
216
- break;
217
- case "SOL" /* SOL */:
218
- curr = "solana";
219
- break;
220
- case "TON" /* TON */:
221
- curr = "ton";
222
- break;
223
- case "TRX" /* TRON */:
224
- curr = "tron";
225
- break;
226
- case "APT" /* APT */:
227
- curr = "aptos";
228
- break;
229
- case "BNB" /* BNB */:
230
- curr = "binancecoin";
231
- break;
232
- case "TON" /* TON */:
233
- curr = "the-open-network";
234
- break;
235
- default:
236
- curr = currency;
225
+ if (!currency) {
226
+ throw new Error(
227
+ "[SDK][Wallets][MarketData] \u2013 currency wasn`t provided"
228
+ );
237
229
  }
238
- let rate = cacheGet("gecko");
239
- let response;
240
- if (rate) {
241
- response = rate;
242
- } else {
230
+ if (!CONFIG.privateApiHost) {
231
+ throw new Error(
232
+ "[SDK][Wallets][MarketData] \u2013 privateApiHost isn`t configured"
233
+ );
234
+ }
235
+ const token = normalizeCurrencyToToken(currency);
236
+ let marketData = cacheGet(MARKET_DATA_CACHE_KEY);
237
+ if (!marketData) {
243
238
  const httpResponse = await fetch(
244
- `https://api.coingecko.com/api/v3/simple/price?ids=${curr}&vs_currencies=usd`,
239
+ `${CONFIG.privateApiHost}/private-api/market-data/latest`,
245
240
  {
246
241
  method: "GET"
247
242
  }
248
243
  );
244
+ if (!httpResponse.ok) {
245
+ throw new Error(
246
+ `[SDK][Wallets][MarketData] \u2013 failed to fetch latest market data (${httpResponse.status})`
247
+ );
248
+ }
249
249
  const data = await httpResponse.json();
250
- cacheSet("gecko", data === void 0 ? undefinedValue : data);
251
- response = data;
250
+ cacheSet(MARKET_DATA_CACHE_KEY, data);
251
+ marketData = data;
252
+ }
253
+ const tokenData = marketData[token];
254
+ if (!tokenData) {
255
+ throw new Error(
256
+ `[SDK][Wallets][MarketData] \u2013 missing market data for token: ${token}`
257
+ );
258
+ }
259
+ const usdQuote = tokenData.quotes?.usd;
260
+ if (!usdQuote) {
261
+ throw new Error(
262
+ `[SDK][Wallets][MarketData] \u2013 missing USD quote for token: ${token}`
263
+ );
252
264
  }
253
- return +response[curr].usd;
265
+ return Number(usdQuote.price);
254
266
  },
255
267
  enabled: !!currency
256
268
  });
@@ -746,11 +758,12 @@ function getHbdAssetGeneralInfoQueryOptions(username) {
746
758
  );
747
759
  let price = 1;
748
760
  try {
749
- const response = await fetch(
750
- "https://api.coingecko.com/api/v3/simple/price?ids=hive_dollar&vs_currencies=usd"
761
+ await CONFIG.queryClient.prefetchQuery(
762
+ getTokenPriceQueryOptions("HBD")
751
763
  );
752
- const data = await response.json();
753
- const marketPrice = data.hive_dollar?.usd;
764
+ const marketPrice = CONFIG.queryClient.getQueryData(
765
+ getTokenPriceQueryOptions("HBD").queryKey
766
+ ) ?? 0;
754
767
  if (typeof marketPrice === "number" && Number.isFinite(marketPrice)) {
755
768
  price = marketPrice;
756
769
  }
@@ -891,7 +904,7 @@ function getHiveAssetTransactionsQueryOptions(username, limit = 20, group) {
891
904
  case "transfer_to_savings":
892
905
  case "transfer_to_vesting":
893
906
  case "recurrent_transfer":
894
- return ["HIVE"].includes(item.amount);
907
+ return parseAsset(item.amount).symbol === "HIVE";
895
908
  case "fill_recurrent_transfer":
896
909
  const asset = parseAsset(item.amount);
897
910
  return ["HIVE"].includes(asset.symbol);
@@ -941,11 +954,14 @@ function getHivePowerAssetTransactionsQueryOptions(username, limit = 20, group)
941
954
  item.reward_vests
942
955
  );
943
956
  return rewardVests.amount > 0;
957
+ case "transfer_to_vesting":
958
+ return true;
944
959
  case "transfer":
945
960
  case "transfer_to_savings":
946
- case "transfer_to_vesting":
947
961
  case "recurrent_transfer":
948
- return ["VESTS", "HP"].includes(item.amount);
962
+ return ["VESTS", "HP"].includes(
963
+ parseAsset(item.amount).symbol
964
+ );
949
965
  case "fill_recurrent_transfer":
950
966
  const asset = parseAsset(item.amount);
951
967
  return ["VESTS", "HP"].includes(asset.symbol);
@@ -987,7 +1003,7 @@ function getHbdAssetTransactionsQueryOptions(username, limit = 20, group) {
987
1003
  case "transfer_to_savings":
988
1004
  case "transfer_to_vesting":
989
1005
  case "recurrent_transfer":
990
- return ["HBD"].includes(item.amount);
1006
+ return parseAsset(item.amount).symbol === "HBD";
991
1007
  case "fill_recurrent_transfer":
992
1008
  const asset = parseAsset(item.amount);
993
1009
  return ["HBD"].includes(asset.symbol);
@@ -1752,12 +1768,23 @@ function getHiveEngineTokenGeneralInfoQueryOptions(username, symbol) {
1752
1768
  const balance = balanceList?.find((i) => i.symbol === symbol);
1753
1769
  const market = marketList?.find((i) => i.symbol === symbol);
1754
1770
  const lastPrice = +(market?.lastPrice ?? "0");
1771
+ const liquidBalance = parseFloat(balance?.balance ?? "0");
1772
+ const stakedBalance = parseFloat(balance?.stake ?? "0");
1773
+ const unstakingBalance = parseFloat(balance?.pendingUnstake ?? "0");
1774
+ const parts = [
1775
+ { name: "liquid", balance: liquidBalance },
1776
+ { name: "staked", balance: stakedBalance }
1777
+ ];
1778
+ if (unstakingBalance > 0) {
1779
+ parts.push({ name: "unstaking", balance: unstakingBalance });
1780
+ }
1755
1781
  return {
1756
1782
  name: symbol,
1757
1783
  title: metadata?.name ?? "",
1758
1784
  price: lastPrice === 0 ? 0 : Number(lastPrice * (hiveData?.price ?? 0)),
1759
- accountBalance: parseFloat(balance?.balance ?? "0"),
1760
- layer: "ENGINE"
1785
+ accountBalance: liquidBalance + stakedBalance,
1786
+ layer: "ENGINE",
1787
+ parts
1761
1788
  };
1762
1789
  }
1763
1790
  });
@@ -2213,6 +2240,9 @@ function getPointsAssetTransactionsQueryOptions(username, type) {
2213
2240
  `${CONFIG.privateApiHost}/private-api/point-list`,
2214
2241
  {
2215
2242
  method: "POST",
2243
+ headers: {
2244
+ "Content-Type": "application/json"
2245
+ },
2216
2246
  body: JSON.stringify({
2217
2247
  username,
2218
2248
  type: type ?? 0
@@ -2486,10 +2516,10 @@ function getAptAssetGeneralInfoQueryOptions(username) {
2486
2516
  getAptAssetBalanceQueryOptions(address).queryKey
2487
2517
  ) ?? 0) / 1e8;
2488
2518
  await CONFIG.queryClient.prefetchQuery(
2489
- getCoinGeckoPriceQueryOptions("APT")
2519
+ getTokenPriceQueryOptions("APT")
2490
2520
  );
2491
2521
  const price = CONFIG.queryClient.getQueryData(
2492
- getCoinGeckoPriceQueryOptions("APT").queryKey
2522
+ getTokenPriceQueryOptions("APT").queryKey
2493
2523
  ) ?? 0;
2494
2524
  return {
2495
2525
  name: "APT",
@@ -2537,10 +2567,10 @@ function getBnbAssetGeneralInfoQueryOptions(username) {
2537
2567
  getBnbAssetBalanceQueryOptions(address).queryKey
2538
2568
  ) ?? 0) / 1e18;
2539
2569
  await CONFIG.queryClient.prefetchQuery(
2540
- getCoinGeckoPriceQueryOptions("BNB")
2570
+ getTokenPriceQueryOptions("BNB")
2541
2571
  );
2542
2572
  const price = CONFIG.queryClient.getQueryData(
2543
- getCoinGeckoPriceQueryOptions("BNB").queryKey
2573
+ getTokenPriceQueryOptions("BNB").queryKey
2544
2574
  ) ?? 0;
2545
2575
  return {
2546
2576
  name: "BNB",
@@ -2588,10 +2618,10 @@ function getBtcAssetGeneralInfoQueryOptions(username) {
2588
2618
  getBtcAssetBalanceQueryOptions(address).queryKey
2589
2619
  ) ?? 0) / 1e8;
2590
2620
  await CONFIG.queryClient.prefetchQuery(
2591
- getCoinGeckoPriceQueryOptions("BTC")
2621
+ getTokenPriceQueryOptions("BTC")
2592
2622
  );
2593
2623
  const price = CONFIG.queryClient.getQueryData(
2594
- getCoinGeckoPriceQueryOptions("BTC").queryKey
2624
+ getTokenPriceQueryOptions("BTC").queryKey
2595
2625
  ) ?? 0;
2596
2626
  return {
2597
2627
  name: "BTC",
@@ -2639,10 +2669,10 @@ function getEthAssetGeneralInfoQueryOptions(username) {
2639
2669
  getEthAssetBalanceQueryOptions(address).queryKey
2640
2670
  ) ?? 0) / 1e18;
2641
2671
  await CONFIG.queryClient.prefetchQuery(
2642
- getCoinGeckoPriceQueryOptions("ETH")
2672
+ getTokenPriceQueryOptions("ETH")
2643
2673
  );
2644
2674
  const price = CONFIG.queryClient.getQueryData(
2645
- getCoinGeckoPriceQueryOptions("ETH").queryKey
2675
+ getTokenPriceQueryOptions("ETH").queryKey
2646
2676
  ) ?? 0;
2647
2677
  return {
2648
2678
  name: "ETH",
@@ -2690,10 +2720,10 @@ function getSolAssetGeneralInfoQueryOptions(username) {
2690
2720
  getSolAssetBalanceQueryOptions(address).queryKey
2691
2721
  ) ?? 0) / 1e9;
2692
2722
  await CONFIG.queryClient.prefetchQuery(
2693
- getCoinGeckoPriceQueryOptions("SOL")
2723
+ getTokenPriceQueryOptions("SOL")
2694
2724
  );
2695
2725
  const price = CONFIG.queryClient.getQueryData(
2696
- getCoinGeckoPriceQueryOptions("SOL").queryKey
2726
+ getTokenPriceQueryOptions("SOL").queryKey
2697
2727
  ) ?? 0;
2698
2728
  return {
2699
2729
  name: "SOL",
@@ -2741,10 +2771,10 @@ function getTonAssetGeneralInfoQueryOptions(username) {
2741
2771
  getTonAssetBalanceQueryOptions(address).queryKey
2742
2772
  ) ?? 0) / 1e9;
2743
2773
  await CONFIG.queryClient.prefetchQuery(
2744
- getCoinGeckoPriceQueryOptions("TON")
2774
+ getTokenPriceQueryOptions("TON")
2745
2775
  );
2746
2776
  const price = CONFIG.queryClient.getQueryData(
2747
- getCoinGeckoPriceQueryOptions("TON").queryKey
2777
+ getTokenPriceQueryOptions("TON").queryKey
2748
2778
  ) ?? 0;
2749
2779
  return {
2750
2780
  name: "TON",
@@ -2792,10 +2822,10 @@ function getTronAssetGeneralInfoQueryOptions(username) {
2792
2822
  getTronAssetBalanceQueryOptions(address).queryKey
2793
2823
  ) ?? 0) / 1e6;
2794
2824
  await CONFIG.queryClient.prefetchQuery(
2795
- getCoinGeckoPriceQueryOptions("TRX")
2825
+ getTokenPriceQueryOptions("TRX")
2796
2826
  );
2797
2827
  const price = CONFIG.queryClient.getQueryData(
2798
- getCoinGeckoPriceQueryOptions("TRX").queryKey
2828
+ getTokenPriceQueryOptions("TRX").queryKey
2799
2829
  ) ?? 0;
2800
2830
  return {
2801
2831
  name: "TRX",
@@ -2916,22 +2946,30 @@ function getTokenOperationsQueryOptions(token, username, isForOwner = false) {
2916
2946
  case "TRX":
2917
2947
  return [];
2918
2948
  }
2949
+ if (!username) {
2950
+ return ["transfer" /* Transfer */];
2951
+ }
2952
+ const queryClient = getQueryClient();
2919
2953
  const balancesListQuery = getHiveEngineTokensBalancesQueryOptions(username);
2920
- await getQueryClient().prefetchQuery(balancesListQuery);
2921
- const balances = getQueryClient().getQueryData(
2922
- balancesListQuery.queryKey
2923
- );
2954
+ const balances = await queryClient.ensureQueryData(balancesListQuery);
2924
2955
  const tokensQuery = getHiveEngineTokensMetadataQueryOptions(
2925
- balances?.map((b) => b.symbol) ?? []
2956
+ balances.map((b) => b.symbol)
2926
2957
  );
2927
- await getQueryClient().prefetchQuery(tokensQuery);
2928
- const tokens = getQueryClient().getQueryData(tokensQuery.queryKey);
2929
- const balanceInfo = balances?.find((m) => m.symbol === token);
2930
- const tokenInfo = tokens?.find((t) => t.symbol === token);
2958
+ const tokens = await queryClient.ensureQueryData(tokensQuery);
2959
+ const balanceInfo = balances.find((m) => m.symbol === token);
2960
+ const tokenInfo = tokens.find((t) => t.symbol === token);
2931
2961
  const canDelegate = isForOwner && tokenInfo?.delegationEnabled && balanceInfo && parseFloat(balanceInfo.delegationsOut) !== parseFloat(balanceInfo.balance);
2932
2962
  const canUndelegate = isForOwner && parseFloat(balanceInfo?.delegationsOut ?? "0") > 0;
2933
- const canStake = isForOwner && tokenInfo?.stakingEnabled;
2934
- const canUnstake = isForOwner && parseFloat(balanceInfo?.stake ?? "0") > 0;
2963
+ const stakeBalance = parseFloat(balanceInfo?.stake ?? "0");
2964
+ const pendingUnstakeBalance = parseFloat(
2965
+ balanceInfo?.pendingUnstake ?? "0"
2966
+ );
2967
+ const supportsStakingFeature = Boolean(
2968
+ tokenInfo?.stakingEnabled || (tokenInfo?.unstakingCooldown ?? 0) > 0 || parseFloat(tokenInfo?.totalStaked ?? "0") > 0
2969
+ );
2970
+ const hasStakingBalances = stakeBalance > 0 || pendingUnstakeBalance > 0;
2971
+ const canStake = isForOwner && Boolean(tokenInfo?.stakingEnabled);
2972
+ const canUnstake = isForOwner && (supportsStakingFeature || hasStakingBalances);
2935
2973
  return [
2936
2974
  "transfer" /* Transfer */,
2937
2975
  ...canDelegate ? ["delegate" /* Delegate */] : [],
@@ -3342,6 +3380,6 @@ function useWalletOperation(username, asset, operation) {
3342
3380
  // src/index.ts
3343
3381
  rememberScryptBsvVersion();
3344
3382
 
3345
- export { AssetOperation, EcencyWalletBasicTokens, EcencyWalletCurrency, private_api_exports as EcencyWalletsPrivateApi, NaiMap, PointTransactionType, Symbol2 as Symbol, buildAptTx, buildEthTx, buildExternalTx, buildPsbt, buildSolTx, buildTonTx, buildTronTx, decryptMemoWithAccounts, decryptMemoWithKeys, delay, delegateEngineToken, delegateHive, deriveHiveKey, deriveHiveKeys, deriveHiveMasterPasswordKey, deriveHiveMasterPasswordKeys, detectHiveKeyDerivation, encryptMemoWithAccounts, encryptMemoWithKeys, getAccountWalletAssetInfoQueryOptions, getAccountWalletListQueryOptions, getAllTokensListQueryOptions, getBoundFetch, getCoinGeckoPriceQueryOptions, getHbdAssetGeneralInfoQueryOptions, getHbdAssetTransactionsQueryOptions, getHiveAssetGeneralInfoQueryOptions, getHiveAssetMetricQueryOptions, getHiveAssetTransactionsQueryOptions, getHiveAssetWithdrawalRoutesQueryOptions, getHiveEngineTokenGeneralInfoQueryOptions, getHiveEngineTokenTransactionsQueryOptions, getHiveEngineTokensBalancesQueryOptions, getHiveEngineTokensMarketQueryOptions, getHiveEngineTokensMetadataQueryOptions, getHiveEngineTokensMetricsQueryOptions, getHivePowerAssetGeneralInfoQueryOptions, getHivePowerAssetTransactionsQueryOptions, getHivePowerDelegatesInfiniteQueryOptions, getHivePowerDelegatingsQueryOptions, getLarynxAssetGeneralInfoQueryOptions, getLarynxPowerAssetGeneralInfoQueryOptions, getPointsAssetGeneralInfoQueryOptions, getPointsAssetTransactionsQueryOptions, getPointsQueryOptions, getSpkAssetGeneralInfoQueryOptions, getSpkMarketsQueryOptions, getTokenOperationsQueryOptions, getWallet, isEmptyDate, lockLarynx, mnemonicToSeedBip39, parseAsset, powerDownHive, powerUpHive, powerUpLarynx, rewardSpk, signDigest, signExternalTx, signExternalTxAndBroadcast, signTx, signTxAndBroadcast, stakeEngineToken, transferEngineToken, transferHive, transferPoint, transferSpk, transferToSavingsHive, undelegateEngineToken, unstakeEngineToken, useClaimPoints, useClaimRewards, useGetExternalWalletBalanceQuery, useHiveKeysQuery, useImportWallet, useSaveWalletInformationToMetadata, useSeedPhrase, useWalletCreate, useWalletOperation, useWalletsCacheQuery, vestsToHp, withdrawVestingRouteHive };
3383
+ export { AssetOperation, EcencyWalletBasicTokens, EcencyWalletCurrency, private_api_exports as EcencyWalletsPrivateApi, NaiMap, PointTransactionType, Symbol2 as Symbol, buildAptTx, buildEthTx, buildExternalTx, buildPsbt, buildSolTx, buildTonTx, buildTronTx, decryptMemoWithAccounts, decryptMemoWithKeys, delay, delegateEngineToken, delegateHive, deriveHiveKey, deriveHiveKeys, deriveHiveMasterPasswordKey, deriveHiveMasterPasswordKeys, detectHiveKeyDerivation, encryptMemoWithAccounts, encryptMemoWithKeys, getAccountWalletAssetInfoQueryOptions, getAccountWalletListQueryOptions, getAllTokensListQueryOptions, getBoundFetch, getHbdAssetGeneralInfoQueryOptions, getHbdAssetTransactionsQueryOptions, getHiveAssetGeneralInfoQueryOptions, getHiveAssetMetricQueryOptions, getHiveAssetTransactionsQueryOptions, getHiveAssetWithdrawalRoutesQueryOptions, getHiveEngineTokenGeneralInfoQueryOptions, getHiveEngineTokenTransactionsQueryOptions, getHiveEngineTokensBalancesQueryOptions, getHiveEngineTokensMarketQueryOptions, getHiveEngineTokensMetadataQueryOptions, getHiveEngineTokensMetricsQueryOptions, getHivePowerAssetGeneralInfoQueryOptions, getHivePowerAssetTransactionsQueryOptions, getHivePowerDelegatesInfiniteQueryOptions, getHivePowerDelegatingsQueryOptions, getLarynxAssetGeneralInfoQueryOptions, getLarynxPowerAssetGeneralInfoQueryOptions, getPointsAssetGeneralInfoQueryOptions, getPointsAssetTransactionsQueryOptions, getPointsQueryOptions, getSpkAssetGeneralInfoQueryOptions, getSpkMarketsQueryOptions, getTokenOperationsQueryOptions, getTokenPriceQueryOptions, getWallet, isEmptyDate, lockLarynx, mnemonicToSeedBip39, parseAsset, powerDownHive, powerUpHive, powerUpLarynx, rewardSpk, signDigest, signExternalTx, signExternalTxAndBroadcast, signTx, signTxAndBroadcast, stakeEngineToken, transferEngineToken, transferHive, transferPoint, transferSpk, transferToSavingsHive, undelegateEngineToken, unstakeEngineToken, useClaimPoints, useClaimRewards, useGetExternalWalletBalanceQuery, useHiveKeysQuery, useImportWallet, useSaveWalletInformationToMetadata, useSeedPhrase, useWalletCreate, useWalletOperation, useWalletsCacheQuery, vestsToHp, withdrawVestingRouteHive };
3346
3384
  //# sourceMappingURL=index.js.map
3347
3385
  //# sourceMappingURL=index.js.map