@bluxcc/core 0.2.8 → 0.2.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.
package/dist/store.d.ts CHANGED
@@ -76,6 +76,7 @@ export interface IStoreProperties {
76
76
  login?: ILoginPromise;
77
77
  loginError?: string;
78
78
  balances: UseBalancesResult;
79
+ balanceValues: Record<string, string>;
79
80
  transactions: UseTransactionsResult;
80
81
  selectAsset: ISelectAsset;
81
82
  detailsAsset?: IAsset;
@@ -106,6 +107,7 @@ export interface IStoreMethods {
106
107
  setAlert: (alert: AlertType, message: string) => void;
107
108
  setDynamicTitle: (title: string) => void;
108
109
  setBalances: (balances: UseBalancesResult) => void;
110
+ setBalanceValues: (balanceValues: Record<string, string>) => void;
109
111
  setSelectAsset: (selectAsset: ISelectAsset) => void;
110
112
  setDetailsAsset: (asset: IAsset | undefined) => void;
111
113
  setTransactions: (transactions: UseTransactionsResult) => void;
@@ -4,7 +4,6 @@ import { Route, SupportedWallet } from '../enums';
4
4
  import { IAsset, IWallet, IExplorer, LanguageKey, ITransports, IWalletNames } from '../types';
5
5
  import { INetworkTransports } from '../constants/networkDetails';
6
6
  export declare const bufferToBase64Url: (buf: ArrayBuffer) => string;
7
- export declare const base64UrlToBuffer: (value: string) => ArrayBuffer;
8
7
  export declare const getAssetTitle: (asset: Horizon.HorizonApi.BalanceLineNative | Horizon.HorizonApi.BalanceLineAsset<"credit_alphanum4"> | Horizon.HorizonApi.BalanceLineAsset<"credit_alphanum12"> | Horizon.HorizonApi.BalanceLineLiquidityPool) => string;
9
8
  export declare const getAssetSubtitle: (asset: Horizon.HorizonApi.BalanceLineNative | Horizon.HorizonApi.BalanceLineAsset<"credit_alphanum4"> | Horizon.HorizonApi.BalanceLineAsset<"credit_alphanum12"> | Horizon.HorizonApi.BalanceLineLiquidityPool) => string;
10
9
  export declare const iAssetToAsset: (asset: IAsset) => Asset;
@@ -41,6 +40,7 @@ export declare const getWalletNetwork: (wallet: IWallet) => Promise<string>;
41
40
  export declare const handleLoadWallets: (walletNames: IWalletNames, orderWallets?: string[]) => Promise<IWallet[]>;
42
41
  export declare const hexToRgba: (hex: string, alpha?: number) => string;
43
42
  export declare const humanizeAmount: (amount: number | string, big?: boolean) => string;
43
+ export declare const formatUsd: (value: number | string) => string;
44
44
  export declare const initializeRabetMobile: () => void;
45
45
  export declare const isBackgroundDark: (bgColor: string) => boolean;
46
46
  export declare const loadWallets: (excludedWallets: IWalletNames, orderWallets?: string[]) => Promise<IWallet[]>;
@@ -0,0 +1,25 @@
1
+ import { Horizon } from '@stellar/stellar-sdk';
2
+ type BalanceLine = Horizon.HorizonApi.BalanceLine;
3
+ /**
4
+ * Stable key for a balance line used to index its computed USD value. Native is
5
+ * `'native'`, liquidity pools use their pool id, every other asset uses
6
+ * `CODE:ISSUER` — matching {@link assetValueKey} so the UI can look values up.
7
+ */
8
+ export declare const balanceLineKey: (balance: BalanceLine) => string;
9
+ /** Same key as {@link balanceLineKey} but from an {@link IAsset}-style triple. */
10
+ export declare const assetValueKey: (assetType: string, assetCode: string, assetIssuer: string) => string;
11
+ /**
12
+ * Computes the realistic USD value of each balance by selling the full held
13
+ * amount into the live DEX order book (price-impact aware), keyed by
14
+ * {@link balanceLineKey}.
15
+ *
16
+ * Real USD pricing only runs on mainnet, where USDC carries real-world value;
17
+ * on every other network all values resolve to `'0'`. Per-asset failures are
18
+ * isolated, so one unpriceable asset never blanks the rest.
19
+ *
20
+ * @param balances - The account's balance lines.
21
+ * @param network - Active network passphrase.
22
+ * @returns A map of `balanceLineKey` → USD value string (7-dp, never NaN/Infinity).
23
+ */
24
+ export declare const getBalancesUsdValues: (balances: BalanceLine[], network: string) => Promise<Record<string, string>>;
25
+ export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bluxcc/core",
3
- "version": "0.2.8",
3
+ "version": "0.2.9",
4
4
  "homepage": "https://blux.cc",
5
5
  "description": "Blux is a wallet infra for the Stellar network",
6
6
  "type": "module",
@@ -73,6 +73,7 @@
73
73
  "dependencies": {
74
74
  "@hot-wallet/sdk": "^1.0.11",
75
75
  "@ledgerhq/hw-transport-webusb": "^6.29.12",
76
- "@trezor/connect-web": "^10.0.0-alpha.1"
76
+ "@trezor/connect-web": "^10.0.0-alpha.1",
77
+ "bignumber.js": "^9.3.1"
77
78
  }
78
79
  }