@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.
@@ -668,10 +668,12 @@ function getHiveAssetGeneralInfoQueryOptions(username) {
668
668
  const accountData = sdk.getQueryClient().getQueryData(
669
669
  sdk.getAccountFullQueryOptions(username).queryKey
670
670
  );
671
+ const marketTicker = await sdk.CONFIG.hiveClient.call("condenser_api", "get_ticker", []).catch(() => void 0);
672
+ const marketPrice = Number.parseFloat(marketTicker?.latest ?? "");
671
673
  return {
672
674
  name: "HIVE",
673
675
  title: "Hive",
674
- price: dynamicProps ? dynamicProps.base / dynamicProps.quote : 0,
676
+ price: Number.isFinite(marketPrice) ? marketPrice : dynamicProps ? dynamicProps.base / dynamicProps.quote : 0,
675
677
  accountBalance: accountData ? parseAsset(accountData.balance).amount : 0
676
678
  };
677
679
  }
@@ -718,10 +720,13 @@ function getHivePowerAssetGeneralInfoQueryOptions(username) {
718
720
  accountBalance: 0
719
721
  };
720
722
  }
723
+ const marketTicker = await sdk.CONFIG.hiveClient.call("condenser_api", "get_ticker", []).catch(() => void 0);
724
+ const marketPrice = Number.parseFloat(marketTicker?.latest ?? "");
725
+ const price = Number.isFinite(marketPrice) ? marketPrice : dynamicProps.base / dynamicProps.quote;
721
726
  return {
722
727
  name: "HP",
723
728
  title: "Hive Power",
724
- price: dynamicProps ? dynamicProps.base / dynamicProps.quote : 0,
729
+ price,
725
730
  accountBalance: +vestsToHp(
726
731
  parseAsset(accountData.vesting_shares).amount,
727
732
  // parseAsset(accountData.delegated_vesting_shares).amount +
@@ -766,18 +771,30 @@ function getHbdAssetGeneralInfoQueryOptions(username) {
766
771
  const dynamicProps = sdk.getQueryClient().getQueryData(
767
772
  sdk.getDynamicPropsQueryOptions().queryKey
768
773
  );
774
+ let price = 1;
775
+ try {
776
+ const response = await fetch(
777
+ "https://api.coingecko.com/api/v3/simple/price?ids=hive_dollar&vs_currencies=usd"
778
+ );
779
+ const data = await response.json();
780
+ const marketPrice = data.hive_dollar?.usd;
781
+ if (typeof marketPrice === "number" && Number.isFinite(marketPrice)) {
782
+ price = marketPrice;
783
+ }
784
+ } catch {
785
+ }
769
786
  if (!accountData) {
770
787
  return {
771
788
  name: "HBD",
772
789
  title: "Hive-based dollar",
773
- price: 1,
790
+ price,
774
791
  accountBalance: 0
775
792
  };
776
793
  }
777
794
  return {
778
795
  name: "HBD",
779
796
  title: "Hive-based dollar",
780
- price: 1,
797
+ price,
781
798
  accountBalance: parseAsset(accountData.hbd_balance).amount + parseAsset(accountData?.savings_hbd_balance).amount,
782
799
  apr: ((dynamicProps?.hbdInterestRate ?? 0) / 100).toFixed(3),
783
800
  parts: [
@@ -1526,6 +1543,7 @@ function getSpkAssetGeneralInfoQueryOptions(username) {
1526
1543
  if (!wallet || !market) {
1527
1544
  return {
1528
1545
  name: "SPK",
1546
+ layer: "SPK",
1529
1547
  title: "SPK Network",
1530
1548
  price: 1,
1531
1549
  accountBalance: 0
@@ -1550,6 +1568,7 @@ function getSpkAssetGeneralInfoQueryOptions(username) {
1550
1568
  );
1551
1569
  return {
1552
1570
  name: "SPK",
1571
+ layer: "SPK",
1553
1572
  title: "SPK Network",
1554
1573
  price: price / accountBalance,
1555
1574
  accountBalance