@ecency/wallets 1.4.5 → 1.4.6

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.
@@ -908,17 +908,20 @@ declare function getLarynxAssetGeneralInfoQueryOptions(username: string): _tanst
908
908
 
909
909
  declare function getSpkAssetGeneralInfoQueryOptions(username: string): _tanstack_react_query.OmitKeyof<_tanstack_react_query.UseQueryOptions<{
910
910
  name: string;
911
+ layer: string;
911
912
  title: string;
912
913
  price: number;
913
914
  accountBalance: number;
914
915
  }, Error, {
915
916
  name: string;
917
+ layer: string;
916
918
  title: string;
917
919
  price: number;
918
920
  accountBalance: number;
919
921
  }, string[]>, "queryFn"> & {
920
922
  queryFn?: _tanstack_react_query.QueryFunction<{
921
923
  name: string;
924
+ layer: string;
922
925
  title: string;
923
926
  price: number;
924
927
  accountBalance: number;
@@ -927,6 +930,7 @@ declare function getSpkAssetGeneralInfoQueryOptions(username: string): _tanstack
927
930
  queryKey: string[] & {
928
931
  [dataTagSymbol]: {
929
932
  name: string;
933
+ layer: string;
930
934
  title: string;
931
935
  price: number;
932
936
  accountBalance: number;
@@ -641,10 +641,12 @@ function getHiveAssetGeneralInfoQueryOptions(username) {
641
641
  const accountData = getQueryClient().getQueryData(
642
642
  getAccountFullQueryOptions(username).queryKey
643
643
  );
644
+ const marketTicker = await CONFIG.hiveClient.call("condenser_api", "get_ticker", []).catch(() => void 0);
645
+ const marketPrice = Number.parseFloat(marketTicker?.latest ?? "");
644
646
  return {
645
647
  name: "HIVE",
646
648
  title: "Hive",
647
- price: dynamicProps ? dynamicProps.base / dynamicProps.quote : 0,
649
+ price: Number.isFinite(marketPrice) ? marketPrice : dynamicProps ? dynamicProps.base / dynamicProps.quote : 0,
648
650
  accountBalance: accountData ? parseAsset(accountData.balance).amount : 0
649
651
  };
650
652
  }
@@ -691,10 +693,13 @@ function getHivePowerAssetGeneralInfoQueryOptions(username) {
691
693
  accountBalance: 0
692
694
  };
693
695
  }
696
+ const marketTicker = await CONFIG.hiveClient.call("condenser_api", "get_ticker", []).catch(() => void 0);
697
+ const marketPrice = Number.parseFloat(marketTicker?.latest ?? "");
698
+ const price = Number.isFinite(marketPrice) ? marketPrice : dynamicProps.base / dynamicProps.quote;
694
699
  return {
695
700
  name: "HP",
696
701
  title: "Hive Power",
697
- price: dynamicProps ? dynamicProps.base / dynamicProps.quote : 0,
702
+ price,
698
703
  accountBalance: +vestsToHp(
699
704
  parseAsset(accountData.vesting_shares).amount,
700
705
  // parseAsset(accountData.delegated_vesting_shares).amount +
@@ -739,18 +744,30 @@ function getHbdAssetGeneralInfoQueryOptions(username) {
739
744
  const dynamicProps = getQueryClient().getQueryData(
740
745
  getDynamicPropsQueryOptions().queryKey
741
746
  );
747
+ let price = 1;
748
+ try {
749
+ const response = await fetch(
750
+ "https://api.coingecko.com/api/v3/simple/price?ids=hive_dollar&vs_currencies=usd"
751
+ );
752
+ const data = await response.json();
753
+ const marketPrice = data.hive_dollar?.usd;
754
+ if (typeof marketPrice === "number" && Number.isFinite(marketPrice)) {
755
+ price = marketPrice;
756
+ }
757
+ } catch {
758
+ }
742
759
  if (!accountData) {
743
760
  return {
744
761
  name: "HBD",
745
762
  title: "Hive-based dollar",
746
- price: 1,
763
+ price,
747
764
  accountBalance: 0
748
765
  };
749
766
  }
750
767
  return {
751
768
  name: "HBD",
752
769
  title: "Hive-based dollar",
753
- price: 1,
770
+ price,
754
771
  accountBalance: parseAsset(accountData.hbd_balance).amount + parseAsset(accountData?.savings_hbd_balance).amount,
755
772
  apr: ((dynamicProps?.hbdInterestRate ?? 0) / 100).toFixed(3),
756
773
  parts: [
@@ -1499,6 +1516,7 @@ function getSpkAssetGeneralInfoQueryOptions(username) {
1499
1516
  if (!wallet || !market) {
1500
1517
  return {
1501
1518
  name: "SPK",
1519
+ layer: "SPK",
1502
1520
  title: "SPK Network",
1503
1521
  price: 1,
1504
1522
  accountBalance: 0
@@ -1523,6 +1541,7 @@ function getSpkAssetGeneralInfoQueryOptions(username) {
1523
1541
  );
1524
1542
  return {
1525
1543
  name: "SPK",
1544
+ layer: "SPK",
1526
1545
  title: "SPK Network",
1527
1546
  price: price / accountBalance,
1528
1547
  accountBalance