@ecency/wallets 1.4.8 → 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.
@@ -931,7 +931,7 @@ function getHiveAssetTransactionsQueryOptions(username, limit = 20, group) {
931
931
  case "transfer_to_savings":
932
932
  case "transfer_to_vesting":
933
933
  case "recurrent_transfer":
934
- return ["HIVE"].includes(item.amount);
934
+ return parseAsset(item.amount).symbol === "HIVE";
935
935
  case "fill_recurrent_transfer":
936
936
  const asset = parseAsset(item.amount);
937
937
  return ["HIVE"].includes(asset.symbol);
@@ -981,11 +981,14 @@ function getHivePowerAssetTransactionsQueryOptions(username, limit = 20, group)
981
981
  item.reward_vests
982
982
  );
983
983
  return rewardVests.amount > 0;
984
+ case "transfer_to_vesting":
985
+ return true;
984
986
  case "transfer":
985
987
  case "transfer_to_savings":
986
- case "transfer_to_vesting":
987
988
  case "recurrent_transfer":
988
- return ["VESTS", "HP"].includes(item.amount);
989
+ return ["VESTS", "HP"].includes(
990
+ parseAsset(item.amount).symbol
991
+ );
989
992
  case "fill_recurrent_transfer":
990
993
  const asset = parseAsset(item.amount);
991
994
  return ["VESTS", "HP"].includes(asset.symbol);
@@ -1027,7 +1030,7 @@ function getHbdAssetTransactionsQueryOptions(username, limit = 20, group) {
1027
1030
  case "transfer_to_savings":
1028
1031
  case "transfer_to_vesting":
1029
1032
  case "recurrent_transfer":
1030
- return ["HBD"].includes(item.amount);
1033
+ return parseAsset(item.amount).symbol === "HBD";
1031
1034
  case "fill_recurrent_transfer":
1032
1035
  const asset = parseAsset(item.amount);
1033
1036
  return ["HBD"].includes(asset.symbol);
@@ -1792,12 +1795,23 @@ function getHiveEngineTokenGeneralInfoQueryOptions(username, symbol) {
1792
1795
  const balance = balanceList?.find((i) => i.symbol === symbol);
1793
1796
  const market = marketList?.find((i) => i.symbol === symbol);
1794
1797
  const lastPrice = +(market?.lastPrice ?? "0");
1798
+ const liquidBalance = parseFloat(balance?.balance ?? "0");
1799
+ const stakedBalance = parseFloat(balance?.stake ?? "0");
1800
+ const unstakingBalance = parseFloat(balance?.pendingUnstake ?? "0");
1801
+ const parts = [
1802
+ { name: "liquid", balance: liquidBalance },
1803
+ { name: "staked", balance: stakedBalance }
1804
+ ];
1805
+ if (unstakingBalance > 0) {
1806
+ parts.push({ name: "unstaking", balance: unstakingBalance });
1807
+ }
1795
1808
  return {
1796
1809
  name: symbol,
1797
1810
  title: metadata?.name ?? "",
1798
1811
  price: lastPrice === 0 ? 0 : Number(lastPrice * (hiveData?.price ?? 0)),
1799
- accountBalance: parseFloat(balance?.balance ?? "0"),
1800
- layer: "ENGINE"
1812
+ accountBalance: liquidBalance + stakedBalance,
1813
+ layer: "ENGINE",
1814
+ parts
1801
1815
  };
1802
1816
  }
1803
1817
  });
@@ -2253,6 +2267,9 @@ function getPointsAssetTransactionsQueryOptions(username, type) {
2253
2267
  `${sdk.CONFIG.privateApiHost}/private-api/point-list`,
2254
2268
  {
2255
2269
  method: "POST",
2270
+ headers: {
2271
+ "Content-Type": "application/json"
2272
+ },
2256
2273
  body: JSON.stringify({
2257
2274
  username,
2258
2275
  type: type ?? 0
@@ -2956,22 +2973,30 @@ function getTokenOperationsQueryOptions(token, username, isForOwner = false) {
2956
2973
  case "TRX":
2957
2974
  return [];
2958
2975
  }
2976
+ if (!username) {
2977
+ return ["transfer" /* Transfer */];
2978
+ }
2979
+ const queryClient = sdk.getQueryClient();
2959
2980
  const balancesListQuery = getHiveEngineTokensBalancesQueryOptions(username);
2960
- await sdk.getQueryClient().prefetchQuery(balancesListQuery);
2961
- const balances = sdk.getQueryClient().getQueryData(
2962
- balancesListQuery.queryKey
2963
- );
2981
+ const balances = await queryClient.ensureQueryData(balancesListQuery);
2964
2982
  const tokensQuery = getHiveEngineTokensMetadataQueryOptions(
2965
- balances?.map((b) => b.symbol) ?? []
2983
+ balances.map((b) => b.symbol)
2966
2984
  );
2967
- await sdk.getQueryClient().prefetchQuery(tokensQuery);
2968
- const tokens = sdk.getQueryClient().getQueryData(tokensQuery.queryKey);
2969
- const balanceInfo = balances?.find((m) => m.symbol === token);
2970
- const tokenInfo = tokens?.find((t) => t.symbol === token);
2985
+ const tokens = await queryClient.ensureQueryData(tokensQuery);
2986
+ const balanceInfo = balances.find((m) => m.symbol === token);
2987
+ const tokenInfo = tokens.find((t) => t.symbol === token);
2971
2988
  const canDelegate = isForOwner && tokenInfo?.delegationEnabled && balanceInfo && parseFloat(balanceInfo.delegationsOut) !== parseFloat(balanceInfo.balance);
2972
2989
  const canUndelegate = isForOwner && parseFloat(balanceInfo?.delegationsOut ?? "0") > 0;
2973
- const canStake = isForOwner && tokenInfo?.stakingEnabled;
2974
- const canUnstake = isForOwner && parseFloat(balanceInfo?.stake ?? "0") > 0;
2990
+ const stakeBalance = parseFloat(balanceInfo?.stake ?? "0");
2991
+ const pendingUnstakeBalance = parseFloat(
2992
+ balanceInfo?.pendingUnstake ?? "0"
2993
+ );
2994
+ const supportsStakingFeature = Boolean(
2995
+ tokenInfo?.stakingEnabled || (tokenInfo?.unstakingCooldown ?? 0) > 0 || parseFloat(tokenInfo?.totalStaked ?? "0") > 0
2996
+ );
2997
+ const hasStakingBalances = stakeBalance > 0 || pendingUnstakeBalance > 0;
2998
+ const canStake = isForOwner && Boolean(tokenInfo?.stakingEnabled);
2999
+ const canUnstake = isForOwner && (supportsStakingFeature || hasStakingBalances);
2975
3000
  return [
2976
3001
  "transfer" /* Transfer */,
2977
3002
  ...canDelegate ? ["delegate" /* Delegate */] : [],