@bluxcc/core 0.2.7 → 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.
Files changed (50) hide show
  1. package/dist/constants/networkDetails.d.ts +1 -0
  2. package/dist/exports/blux.d.ts +51 -0
  3. package/dist/exports/core/callBuilder.d.ts +25 -16
  4. package/dist/exports/core/fundAccount.d.ts +34 -0
  5. package/dist/exports/core/getAccount.d.ts +14 -0
  6. package/dist/exports/core/getAccounts.d.ts +27 -23
  7. package/dist/exports/core/getAssets.d.ts +11 -1
  8. package/dist/exports/core/getBalances.d.ts +15 -0
  9. package/dist/exports/core/getClaimableBalances.d.ts +16 -3
  10. package/dist/exports/core/getEffects.d.ts +15 -1
  11. package/dist/exports/core/getLedgers.d.ts +10 -1
  12. package/dist/exports/core/getLiquidityPools.d.ts +15 -3
  13. package/dist/exports/core/getNetwork.d.ts +6 -0
  14. package/dist/exports/core/getOffers.d.ts +19 -4
  15. package/dist/exports/core/getOperations.d.ts +16 -1
  16. package/dist/exports/core/getOrderbook.d.ts +12 -3
  17. package/dist/exports/core/getPayments.d.ts +14 -2
  18. package/dist/exports/core/getSacAddress.d.ts +18 -0
  19. package/dist/exports/core/getStrictReceivePaths.d.ts +15 -3
  20. package/dist/exports/core/getStrictSendPaths.d.ts +15 -3
  21. package/dist/exports/core/getTokenMetadata.d.ts +32 -0
  22. package/dist/exports/core/getTradeAggregation.d.ts +13 -2
  23. package/dist/exports/core/getTrades.d.ts +18 -3
  24. package/dist/exports/core/getTransactions.d.ts +15 -1
  25. package/dist/exports/core/helpers/account.d.ts +20 -0
  26. package/dist/exports/core/helpers/index.d.ts +9 -0
  27. package/dist/exports/core/helpers/resolveAddress.d.ts +47 -0
  28. package/dist/exports/core/helpers/resolveAsset.d.ts +19 -0
  29. package/dist/exports/core/index.d.ts +7 -0
  30. package/dist/exports/core/networks.d.ts +10 -0
  31. package/dist/exports/core/readContracts.d.ts +13 -0
  32. package/dist/exports/core/swap.d.ts +52 -0
  33. package/dist/exports/core/switchNetwork.d.ts +7 -0
  34. package/dist/exports/core/toScVal.d.ts +36 -0
  35. package/dist/exports/core/transfer.d.ts +49 -0
  36. package/dist/exports/core/writeContract.d.ts +12 -1
  37. package/dist/exports/createConfig.d.ts +9 -0
  38. package/dist/exports/utils.d.ts +42 -0
  39. package/dist/index.cjs.js +14 -14
  40. package/dist/index.esm.js +14 -14
  41. package/dist/stellar/getTransactionDetails.d.ts +1 -1
  42. package/dist/stellar/handleTransactionSigning.d.ts +1 -1
  43. package/dist/stellar/submitTransaction.d.ts +2 -4
  44. package/dist/stellar/swapTransaction.d.ts +2 -2
  45. package/dist/store.d.ts +4 -0
  46. package/dist/types.d.ts +71 -2
  47. package/dist/utils/errors.d.ts +6 -0
  48. package/dist/utils/helpers.d.ts +3 -4
  49. package/dist/utils/prices.d.ts +25 -0
  50. package/package.json +4 -3
@@ -1,5 +1,5 @@
1
1
  declare const getTransactionDetails: (xdr: string, network: string) => {
2
- action: "createAccount" | "payment" | "pathPaymentStrictReceive" | "pathPaymentStrictSend" | "createPassiveSellOffer" | "manageSellOffer" | "manageBuyOffer" | "setOptions" | "changeTrust" | "allowTrust" | "accountMerge" | "inflation" | "manageData" | "bumpSequence" | "createClaimableBalance" | "claimClaimableBalance" | "beginSponsoringFutureReserves" | "endSponsoringFutureReserves" | "revokeSponsorship" | "clawback" | "clawbackClaimableBalance" | "setTrustLineFlags" | "liquidityPoolDeposit" | "liquidityPoolWithdraw" | "invokeHostFunction" | "extendFootprintTtl" | "restoreFootprint";
2
+ action: "accountMerge" | "allowTrust" | "beginSponsoringFutureReserves" | "bumpSequence" | "changeTrust" | "claimClaimableBalance" | "clawbackClaimableBalance" | "clawback" | "createAccount" | "createClaimableBalance" | "createPassiveSellOffer" | "endSponsoringFutureReserves" | "extendFootprintTtl" | "inflation" | "invokeHostFunction" | "liquidityPoolDeposit" | "liquidityPoolWithdraw" | "manageBuyOffer" | "manageData" | "manageSellOffer" | "pathPaymentStrictReceive" | "pathPaymentStrictSend" | "payment" | "restoreFootprint" | "revokeAccountSponsorship" | "revokeClaimableBalanceSponsorship" | "revokeDataSponsorship" | "revokeLiquidityPoolSponsorship" | "revokeOfferSponsorship" | "revokeSignerSponsorship" | "revokeTrustlineSponsorship" | "setOptions" | "setTrustLineFlags";
3
3
  operations: number;
4
4
  sender: string;
5
5
  receiver: string;
@@ -1,3 +1,3 @@
1
1
  import { ITransports, IWallet } from '../types';
2
- declare const handleTransactionSigning: (wallet: IWallet, xdr: string, userAddress: string, network: string, transports: ITransports, shouldSubmit: boolean) => Promise<string | import("@stellar/stellar-sdk/lib/horizon").HorizonApi.SubmitTransactionResponse>;
2
+ declare const handleTransactionSigning: (wallet: IWallet, xdr: string, userAddress: string, network: string, transports: ITransports, shouldSubmit: boolean) => Promise<string | import("../types").ISubmittedTransaction>;
3
3
  export default handleTransactionSigning;
@@ -1,5 +1,3 @@
1
- import { Horizon } from "@stellar/stellar-sdk";
2
- import { ITransports } from "../types";
3
- declare function submitTransaction(xdr: string, network: string, transports: ITransports): Promise<// | rpc.Api.GetSuccessfulTransactionResponse
4
- Horizon.HorizonApi.SubmitTransactionResponse>;
1
+ import { ITransports, ISubmittedTransaction } from '../types';
2
+ declare function submitTransaction(xdr: string, network: string, transports: ITransports): Promise<ISubmittedTransaction>;
5
3
  export default submitTransaction;
@@ -1,4 +1,4 @@
1
- import { HorizonServer } from '@stellar/stellar-sdk/lib/horizon/server';
1
+ import { Horizon } from '@stellar/stellar-sdk';
2
2
  import { IAsset } from '../types';
3
- declare const swapTransaction: (rawFromAmount: string, rawToAmount: string, lastFieldChanged: "from" | "to", fromAsset: IAsset, toAsset: IAsset, path: IAsset[], sourceAddress: string, server: HorizonServer, networkPassphrase: string, isChangeTrustNeeded: boolean) => Promise<string>;
3
+ declare const swapTransaction: (rawFromAmount: string, rawToAmount: string, lastFieldChanged: "from" | "to", fromAsset: IAsset, toAsset: IAsset, path: IAsset[], sourceAddress: string, server: Horizon.Server, networkPassphrase: string, isChangeTrustNeeded: boolean) => Promise<string>;
4
4
  export default swapTransaction;
package/dist/store.d.ts CHANGED
@@ -74,7 +74,9 @@ export interface IStoreProperties {
74
74
  signMessage?: ISignMessage;
75
75
  signAuthEntry?: ISignAuthEntry;
76
76
  login?: ILoginPromise;
77
+ loginError?: string;
77
78
  balances: UseBalancesResult;
79
+ balanceValues: Record<string, string>;
78
80
  transactions: UseTransactionsResult;
79
81
  selectAsset: ISelectAsset;
80
82
  detailsAsset?: IAsset;
@@ -105,6 +107,7 @@ export interface IStoreMethods {
105
107
  setAlert: (alert: AlertType, message: string) => void;
106
108
  setDynamicTitle: (title: string) => void;
107
109
  setBalances: (balances: UseBalancesResult) => void;
110
+ setBalanceValues: (balanceValues: Record<string, string>) => void;
108
111
  setSelectAsset: (selectAsset: ISelectAsset) => void;
109
112
  setDetailsAsset: (asset: IAsset | undefined) => void;
110
113
  setTransactions: (transactions: UseTransactionsResult) => void;
@@ -116,6 +119,7 @@ export interface IStoreMethods {
116
119
  setAuth: (a: IAuth) => void;
117
120
  setIsAuthenticated: (isAuthenticated: boolean) => void;
118
121
  setLogin: (loginDetails: ILoginPromise | undefined) => void;
122
+ setLoginError: (message?: string) => void;
119
123
  setLogos: (logos: ILogo[]) => void;
120
124
  }
121
125
  export interface IStore extends IStoreProperties, IStoreMethods {
package/dist/types.d.ts CHANGED
@@ -1,41 +1,75 @@
1
- import { Horizon } from '@stellar/stellar-sdk';
1
+ import { Horizon, rpc } from '@stellar/stellar-sdk';
2
2
  import { SupportedWallet } from './enums';
3
+ /** Supported UI language codes (ISO 639-1). */
3
4
  export type LanguageKey = 'en' | 'es' | 'pt' | 'fr' | 'de' | 'ru' | 'zh' | 'ja' | 'ko';
5
+ /** Custom RPC endpoints keyed by network passphrase. */
4
6
  export type ITransports = Record<string, IServers>;
7
+ /** Block explorer used to build account/transaction links. */
5
8
  export type IExplorer = 'steexp' | 'stellarchain' | 'stellarexpert' | 'lumenscan';
9
+ /** Social login providers supported by Blux. */
6
10
  export type ISocialProvider = 'google';
11
+ /** Login methods to offer in the modal. */
7
12
  export type ILoginMethods = Array<'wallet' | 'sms' | 'email' | 'passkey' | ISocialProvider>;
13
+ /** Canonical names of the wallets Blux can integrate with. */
8
14
  export type IWalletNames = Array<'rabet' | 'albedo' | 'freighter' | 'xbull' | 'lobstr' | 'hana' | 'hot' | 'klever' | 'cactuslink' | 'fordefi' | 'trezor'>;
15
+ /** RPC endpoints for a single network. */
9
16
  interface IServers {
17
+ /** Horizon base URL. */
10
18
  horizon: string;
19
+ /** Soroban RPC base URL. */
11
20
  soroban: string;
12
21
  }
22
+ /** WalletConnect project metadata shown to users during pairing. */
13
23
  export interface IWalletConnectMetaData {
24
+ /** Icon URLs for your app. */
14
25
  icons: string[];
26
+ /** Your app URL. */
15
27
  url: string;
28
+ /** WalletConnect Cloud project id. */
16
29
  projectId: string;
30
+ /** Short description of your app. */
17
31
  description: string;
18
32
  }
33
+ /** Trezor Connect manifest metadata. */
19
34
  export interface ITrezorMetaData {
35
+ /** Contact email required by Trezor Connect. */
20
36
  email: string;
37
+ /** Optional app URL for the Trezor manifest. */
21
38
  appUrl?: string;
22
39
  }
40
+ /** Configuration passed to {@link createConfig}. */
23
41
  export interface IConfig {
42
+ /** Your Blux app id, from the Blux dashboard. Required for email/passkey/social login. */
24
43
  appId: string;
44
+ /** Display name of your app, shown in wallet prompts and UI. */
25
45
  appName: string;
46
+ /** Network passphrases your app supports (e.g. from {@link networks}). */
26
47
  networks: string[];
48
+ /** Which of `networks` to start on. Defaults to the first entry. */
27
49
  defaultNetwork?: string;
50
+ /** Theme overrides for the Blux UI. */
28
51
  appearance?: Partial<IAppearance>;
52
+ /** UI language. Defaults to `'en'`. */
29
53
  lang?: LanguageKey;
54
+ /** Block explorer used for links. Defaults to `'stellarchain'`. */
30
55
  explorer?: IExplorer;
56
+ /** Persist the session across reloads. Defaults to `false`. */
31
57
  isPersistent?: boolean;
58
+ /** Show Blux's built-in signing/approval UIs. When `false`, signing happens headlessly. Defaults to `true`. */
32
59
  showWalletUIs?: boolean;
60
+ /** Login methods to offer. Defaults to `['wallet']`. */
33
61
  loginMethods?: ILoginMethods | string[];
62
+ /** Custom Horizon/Soroban endpoints per network; required for custom networks. */
34
63
  transports?: ITransports;
64
+ /** Wallets to hide from the picker. */
35
65
  excludeWallets?: IWalletNames;
66
+ /** Wallets to surface first in the picker, in the given order. */
36
67
  orderWallets?: IWalletNames | string[];
68
+ /** WalletConnect metadata; required to enable WalletConnect. */
37
69
  walletConnect?: IWalletConnectMetaData;
70
+ /** Trezor manifest metadata; required to enable Trezor. */
38
71
  trezor?: ITrezorMetaData;
72
+ /** Prompt the user when their wallet is on a different network. Defaults to `true`. */
39
73
  promptOnWrongNetwork?: boolean;
40
74
  }
41
75
  export interface IInternalConfig extends IConfig {
@@ -49,21 +83,37 @@ export interface IInternalConfig extends IConfig {
49
83
  orderWallets?: string[];
50
84
  promptOnWrongNetwork: boolean;
51
85
  }
86
+ /** Theme tokens for the Blux modal and components. */
52
87
  export interface IAppearance {
88
+ /** Modal or component background color/image. */
53
89
  background: string;
90
+ /** Background color for input fields or UI sections. */
54
91
  fieldBackground: string;
92
+ /** Primary accent or highlight color. */
55
93
  accentColor: string;
94
+ /** Main text color. */
56
95
  textColor: string;
96
+ /** Font family or style. */
57
97
  fontFamily: string;
98
+ /** Outline width (e.g. `'2px'`); falls back to `borderWidth`. */
58
99
  outlineWidth?: string;
100
+ /** Outline color; falls back to `borderColor`. */
59
101
  outlineColor?: string;
102
+ /** Modal corner radius; falls back to `borderRadius`. */
60
103
  outlineRadius?: string;
104
+ /** Corner radius for UI elements. */
61
105
  borderRadius: string;
106
+ /** Border color for elements. */
62
107
  borderColor: string;
108
+ /** Border width (e.g. `'1px'`, `'0'`). */
63
109
  borderWidth: string;
110
+ /** App logo URL. */
64
111
  logo: string;
112
+ /** Blur level for the backdrop (e.g. `'8px'`). */
65
113
  backdropBlur: string;
114
+ /** Backdrop color behind the modal/overlay. */
66
115
  backdropColor: string;
116
+ /** Box shadow style for the modal. */
67
117
  boxShadow: string;
68
118
  }
69
119
  export interface IWallet {
@@ -109,7 +159,26 @@ export interface IAsset {
109
159
  export interface ISignOptions {
110
160
  network: string;
111
161
  }
112
- export type SendTransactionResult = Horizon.HorizonApi.SubmitTransactionResponse | string;
162
+ /**
163
+ * Lazily resolves to the value the invoked contract function returned, decoded
164
+ * to a native JS value. Resolves to `null` for classic transactions and for
165
+ * Soroban calls whose function returns nothing.
166
+ */
167
+ export type TransactionReturnValue = () => Promise<unknown>;
168
+ /** A transaction that has been submitted to (and accepted by) the network. */
169
+ export interface ISubmittedTransaction {
170
+ /** The transaction hash. */
171
+ hash: string;
172
+ /** Resolves the invoked contract function's return value; see {@link TransactionReturnValue}. */
173
+ returnValue: TransactionReturnValue;
174
+ /**
175
+ * The underlying response: a Horizon submit response for classic
176
+ * transactions, or the finalized Soroban RPC transaction for contract calls.
177
+ */
178
+ raw: Horizon.HorizonApi.SubmitTransactionResponse | rpc.Api.GetSuccessfulTransactionResponse;
179
+ }
180
+ /** Result of a sign-and-send: the submitted transaction, or the signed XDR when not submitting. */
181
+ export type SendTransactionResult = ISubmittedTransaction | string;
113
182
  export interface ISendTransaction {
114
183
  xdr: string;
115
184
  shouldSubmit: boolean;
@@ -0,0 +1,6 @@
1
+ export declare const ACCESS_DENIED_FALLBACK = "This account is not allowed to access this app";
2
+ export declare class BluxAccessDeniedError extends Error {
3
+ constructor(message?: string);
4
+ }
5
+ export declare const isAccessDenied: (error: unknown) => error is BluxAccessDeniedError;
6
+ export declare const looksLikeAccessDenied: (message: string) => boolean;
@@ -3,11 +3,9 @@ import translations from '../constants/locales';
3
3
  import { Route, SupportedWallet } from '../enums';
4
4
  import { IAsset, IWallet, IExplorer, LanguageKey, ITransports, IWalletNames } from '../types';
5
5
  import { INetworkTransports } from '../constants/networkDetails';
6
- import { HorizonApi } from '@stellar/stellar-sdk/lib/horizon';
7
6
  export declare const bufferToBase64Url: (buf: ArrayBuffer) => string;
8
- export declare const base64UrlToBuffer: (value: string) => ArrayBuffer;
9
- export declare const getAssetTitle: (asset: HorizonApi.BalanceLineNative | HorizonApi.BalanceLineAsset<"credit_alphanum4"> | HorizonApi.BalanceLineAsset<"credit_alphanum12"> | HorizonApi.BalanceLineLiquidityPool) => string;
10
- export declare const getAssetSubtitle: (asset: HorizonApi.BalanceLineNative | HorizonApi.BalanceLineAsset<"credit_alphanum4"> | HorizonApi.BalanceLineAsset<"credit_alphanum12"> | HorizonApi.BalanceLineLiquidityPool) => string;
7
+ export declare const getAssetTitle: (asset: Horizon.HorizonApi.BalanceLineNative | Horizon.HorizonApi.BalanceLineAsset<"credit_alphanum4"> | Horizon.HorizonApi.BalanceLineAsset<"credit_alphanum12"> | Horizon.HorizonApi.BalanceLineLiquidityPool) => string;
8
+ export declare const getAssetSubtitle: (asset: Horizon.HorizonApi.BalanceLineNative | Horizon.HorizonApi.BalanceLineAsset<"credit_alphanum4"> | Horizon.HorizonApi.BalanceLineAsset<"credit_alphanum12"> | Horizon.HorizonApi.BalanceLineLiquidityPool) => string;
11
9
  export declare const iAssetToAsset: (asset: IAsset) => Asset;
12
10
  export declare const addXLMToBalances: (balances: IAsset[]) => {
13
11
  assetIssuer: string;
@@ -42,6 +40,7 @@ export declare const getWalletNetwork: (wallet: IWallet) => Promise<string>;
42
40
  export declare const handleLoadWallets: (walletNames: IWalletNames, orderWallets?: string[]) => Promise<IWallet[]>;
43
41
  export declare const hexToRgba: (hex: string, alpha?: number) => string;
44
42
  export declare const humanizeAmount: (amount: number | string, big?: boolean) => string;
43
+ export declare const formatUsd: (value: number | string) => string;
45
44
  export declare const initializeRabetMobile: () => void;
46
45
  export declare const isBackgroundDark: (bgColor: string) => boolean;
47
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.7",
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",
@@ -42,7 +42,7 @@
42
42
  "@ledgerhq/hw-app-str": "^7.2.8",
43
43
  "@lobstrco/signer-extension-api": "^1.0.0-beta.0",
44
44
  "@stellar/freighter-api": "^5.0.0",
45
- "@stellar/stellar-sdk": "^15.1.0",
45
+ "@stellar/stellar-sdk": "^16.0.0",
46
46
  "@walletconnect/core": "^2.21.9",
47
47
  "@walletconnect/sign-client": "^2.21.9",
48
48
  "qrcode.react": "^4.2.0",
@@ -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
  }