@bluxcc/core 0.2.6 → 0.2.8

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/exports/blux.d.ts +51 -0
  2. package/dist/exports/core/callBuilder.d.ts +25 -16
  3. package/dist/exports/core/fundAccount.d.ts +34 -0
  4. package/dist/exports/core/getAccount.d.ts +14 -0
  5. package/dist/exports/core/getAccounts.d.ts +27 -23
  6. package/dist/exports/core/getAssets.d.ts +11 -1
  7. package/dist/exports/core/getBalances.d.ts +15 -0
  8. package/dist/exports/core/getClaimableBalances.d.ts +16 -3
  9. package/dist/exports/core/getEffects.d.ts +15 -1
  10. package/dist/exports/core/getLedgers.d.ts +10 -1
  11. package/dist/exports/core/getLiquidityPools.d.ts +15 -3
  12. package/dist/exports/core/getNetwork.d.ts +6 -0
  13. package/dist/exports/core/getOffers.d.ts +19 -4
  14. package/dist/exports/core/getOperations.d.ts +16 -1
  15. package/dist/exports/core/getOrderbook.d.ts +12 -3
  16. package/dist/exports/core/getPayments.d.ts +14 -2
  17. package/dist/exports/core/getSacAddress.d.ts +18 -0
  18. package/dist/exports/core/getStrictReceivePaths.d.ts +15 -3
  19. package/dist/exports/core/getStrictSendPaths.d.ts +15 -3
  20. package/dist/exports/core/getTokenMetadata.d.ts +32 -0
  21. package/dist/exports/core/getTradeAggregation.d.ts +13 -2
  22. package/dist/exports/core/getTrades.d.ts +18 -3
  23. package/dist/exports/core/getTransactions.d.ts +15 -1
  24. package/dist/exports/core/helpers/account.d.ts +20 -0
  25. package/dist/exports/core/helpers/index.d.ts +9 -0
  26. package/dist/exports/core/helpers/resolveAddress.d.ts +47 -0
  27. package/dist/exports/core/helpers/resolveAsset.d.ts +19 -0
  28. package/dist/exports/core/index.d.ts +7 -0
  29. package/dist/exports/core/networks.d.ts +10 -0
  30. package/dist/exports/core/readContracts.d.ts +13 -0
  31. package/dist/exports/core/swap.d.ts +52 -0
  32. package/dist/exports/core/switchNetwork.d.ts +7 -0
  33. package/dist/exports/core/toScVal.d.ts +36 -0
  34. package/dist/exports/core/transfer.d.ts +49 -0
  35. package/dist/exports/core/writeContract.d.ts +12 -1
  36. package/dist/exports/createConfig.d.ts +9 -0
  37. package/dist/exports/utils.d.ts +42 -0
  38. package/dist/index.cjs.js +14 -14
  39. package/dist/index.esm.js +14 -14
  40. package/dist/stellar/getTransactionDetails.d.ts +1 -1
  41. package/dist/stellar/handleTransactionSigning.d.ts +1 -1
  42. package/dist/stellar/submitTransaction.d.ts +2 -4
  43. package/dist/stellar/swapTransaction.d.ts +2 -2
  44. package/dist/store.d.ts +2 -0
  45. package/dist/types.d.ts +71 -4
  46. package/dist/utils/api.d.ts +0 -1
  47. package/dist/utils/errors.d.ts +6 -0
  48. package/dist/utils/helpers.d.ts +3 -3
  49. package/dist/utils/socialLogin.d.ts +3 -8
  50. package/package.json +2 -2
@@ -0,0 +1,32 @@
1
+ /** Options for {@link getTokenMetadata}. */
2
+ export type GetTokenMetadataOptions = {
3
+ /** Network passphrase to read from. Defaults to the active network. */
4
+ network?: string;
5
+ };
6
+ /** Metadata read from a SEP-41 token / Stellar Asset Contract. */
7
+ export type TokenMetadata = {
8
+ /** Number of decimal places the token uses. */
9
+ decimals: number;
10
+ /** Human-readable token name. */
11
+ name: string;
12
+ /** Token symbol / code. */
13
+ symbol: string;
14
+ /**
15
+ * The token's owner, when the contract exposes an `owner()` function. Absent
16
+ * for contracts without one — notably Stellar Asset Contracts, which expose
17
+ * `admin()` rather than `owner()`.
18
+ */
19
+ owner?: string;
20
+ };
21
+ /**
22
+ * Reads a token contract's metadata by simulating its read-only entrypoints — no
23
+ * account, signing, or fees required. `decimals`, `name`, and `symbol` come from
24
+ * the standard SEP-41 token interface; `owner` is read separately and omitted
25
+ * when the contract has no `owner()` function.
26
+ *
27
+ * @param address - The token contract id (`C...`), e.g. a SAC from {@link getSacAddress}.
28
+ * @param options - Network to read from.
29
+ * @returns The token's {@link TokenMetadata}.
30
+ * @throws If called before {@link createConfig}, if `address` is not a contract id, or if the contract is missing the standard `decimals`/`name`/`symbol` entrypoints.
31
+ */
32
+ export declare const getTokenMetadata: (address: string, options?: GetTokenMetadataOptions) => Promise<TokenMetadata>;
@@ -1,4 +1,15 @@
1
- import { Asset } from '@stellar/stellar-sdk';
1
+ import { type AssetArg } from './helpers';
2
2
  import { CallBuilderOptions } from '../utils';
3
+ /** The Horizon call builder plus the first page of trade-aggregation buckets. */
3
4
  export type GetTradeAggregationResult = any;
4
- export declare const getTradeAggregation: (args: [base: Asset, counter: Asset, start_time: number, end_time: number, resolution: number, offset: number], options: CallBuilderOptions) => Promise<GetTradeAggregationResult>;
5
+ /**
6
+ * Fetches time-bucketed trade aggregations (OHLC-style price/volume data) for an
7
+ * asset pair.
8
+ *
9
+ * @param args - `[base, counter, start_time, end_time, resolution, offset]`.
10
+ * `base`/`counter` accept `'xlm'`, `'CODE:ISSUER'`, or an `Asset`; times are in
11
+ * epoch milliseconds; `resolution` is the bucket size in milliseconds.
12
+ * @param options - Pagination and network.
13
+ * @returns The `builder` (for further paging) and the first-page `response`.
14
+ */
15
+ export declare const getTradeAggregation: (args: [base: AssetArg, counter: AssetArg, start_time: number, end_time: number, resolution: number, offset: number], options: CallBuilderOptions) => Promise<GetTradeAggregationResult>;
@@ -1,15 +1,30 @@
1
- import { Asset, Horizon } from '@stellar/stellar-sdk';
2
- import { TradesCallBuilder } from '@stellar/stellar-sdk/lib/horizon/trades_call_builder';
1
+ import { Horizon } from '@stellar/stellar-sdk';
2
+ import { TradesCallBuilder } from '@stellar/stellar-sdk/lib/esm/horizon/trades_call_builder';
3
+ import { type AssetArg } from './helpers';
3
4
  import { CallBuilderOptions } from '../utils';
5
+ /** Options for {@link getTrades}. Extends the shared {@link CallBuilderOptions}. */
4
6
  export type GetTradesOptions = CallBuilderOptions & {
5
- forAssetPair?: [base: Asset, counter: Asset];
7
+ /** Only trades for this `[base, counter]` asset pair. Each accepts `'xlm'`, `'CODE:ISSUER'`, or an `Asset`. */
8
+ forAssetPair?: [base: AssetArg, counter: AssetArg];
9
+ /** Only trades against this offer id. */
6
10
  forOffer?: string;
11
+ /** Only trades of this type (e.g. `orderbook`, `liquidity_pool`). */
7
12
  forType?: Horizon.ServerApi.TradeType;
13
+ /** Only trades involving this account (address or federated address). */
8
14
  forAccount?: string;
15
+ /** Only trades for this liquidity pool id. */
9
16
  forLiquidityPool?: string;
10
17
  };
18
+ /** The Horizon call builder plus the first page of trades. */
11
19
  export type GetTradesResult = {
12
20
  builder: TradesCallBuilder;
13
21
  response: Horizon.ServerApi.CollectionPage<Horizon.ServerApi.TradeRecord>;
14
22
  };
23
+ /**
24
+ * Lists trades, optionally scoped to an asset pair, offer, type, account, or
25
+ * liquidity pool.
26
+ *
27
+ * @param options - Filters, pagination, and network.
28
+ * @returns The `builder` (for further paging) and the first-page `response`.
29
+ */
15
30
  export declare const getTrades: (options: GetTradesOptions) => Promise<GetTradesResult>;
@@ -1,15 +1,29 @@
1
1
  import { Horizon } from '@stellar/stellar-sdk';
2
- import { TransactionCallBuilder } from '@stellar/stellar-sdk/lib/horizon/transaction_call_builder';
2
+ import { TransactionCallBuilder } from '@stellar/stellar-sdk/lib/esm/horizon/transaction_call_builder';
3
3
  import { CallBuilderOptions } from '../utils';
4
+ /** Options for {@link getTransactions}. Extends the shared {@link CallBuilderOptions}. */
4
5
  export type GetTransactionsOptions = CallBuilderOptions & {
6
+ /** Only transactions touching this account (address or federated address). */
5
7
  forAccount?: string;
8
+ /** Only transactions affecting this claimable balance id. */
6
9
  forClaimableBalance?: string;
10
+ /** Only transactions in this ledger, by sequence number. */
7
11
  forLedger?: string | number;
12
+ /** Only transactions affecting this liquidity pool id. */
8
13
  forLiquidityPool?: string;
14
+ /** Include failed transactions. Defaults to `false`. */
9
15
  includeFailed?: boolean;
10
16
  };
17
+ /** The Horizon call builder plus the first page of transactions. */
11
18
  export type GetTransactionsResult = {
12
19
  builder: TransactionCallBuilder;
13
20
  response: Horizon.ServerApi.CollectionPage<Horizon.ServerApi.TransactionRecord>;
14
21
  };
22
+ /**
23
+ * Lists transactions, optionally scoped to an account, ledger, claimable
24
+ * balance, or liquidity pool.
25
+ *
26
+ * @param options - Filters, pagination, and network.
27
+ * @returns The `builder` (for further paging) and the first-page `response`.
28
+ */
15
29
  export declare const getTransactions: (options: GetTransactionsOptions) => Promise<GetTransactionsResult>;
@@ -0,0 +1,20 @@
1
+ import { Asset, Horizon } from '@stellar/stellar-sdk';
2
+ /**
3
+ * Loads an account from Horizon, returning `null` instead of throwing when the
4
+ * account does not exist on the network yet.
5
+ *
6
+ * @param horizon - The Horizon server to query.
7
+ * @param address - The account id (`G...`) to load.
8
+ * @returns The account, or `null` if it is not found.
9
+ */
10
+ export declare const loadAccount: (horizon: Horizon.Server, address: string) => Promise<Horizon.AccountResponse | null>;
11
+ /**
12
+ * Reports whether `account` can receive `asset` directly: always true for the
13
+ * native asset, otherwise true only when the account already holds a trustline
14
+ * for that exact code + issuer.
15
+ *
16
+ * @param account - The recipient account.
17
+ * @param asset - The asset to check.
18
+ * @returns `true` if a direct payment of `asset` would be accepted.
19
+ */
20
+ export declare const hasTrustline: (account: Horizon.AccountResponse, asset: Asset) => boolean;
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Shared, hook-free helpers for the interacting core functions. Re-exporting
3
+ * `numberish` here lets a caller pull the address resolver, the asset resolver,
4
+ * and the number coercion from a single place.
5
+ */
6
+ export { resolveAsset, type AssetArg } from './resolveAsset';
7
+ export { resolveAddress, resolveAddressKey, type ResolvedAddress, } from './resolveAddress';
8
+ export { loadAccount, hasTrustline } from './account';
9
+ export { numberish, type Numberish } from '../toScVal';
@@ -0,0 +1,47 @@
1
+ import { Federation } from '@stellar/stellar-sdk';
2
+ /** The outcome of resolving a recipient with {@link resolveAddress}. */
3
+ export type ResolvedAddress = {
4
+ /**
5
+ * The address to drop into an operation. A muxed (`M...`) input is preserved
6
+ * here so its embedded memo id survives a classic payment; for every other
7
+ * input this equals {@link ResolvedAddress.publicKey}.
8
+ */
9
+ destination: string;
10
+ /**
11
+ * The underlying Ed25519 account id (`G...`). Use this for account-existence
12
+ * lookups, createAccount destinations, and claimable-balance claimants — none
13
+ * of which accept a muxed address.
14
+ */
15
+ publicKey: string;
16
+ /** The memo a federation record asks senders to attach, when it provided one. */
17
+ memo?: string;
18
+ /** The type of {@link ResolvedAddress.memo} (`text` | `id` | `hash` | `return`). */
19
+ memoType?: string;
20
+ /** `true` when the input was a federated address that required a network lookup. */
21
+ federated: boolean;
22
+ };
23
+ /**
24
+ * Turns whatever a caller passed as a recipient into a usable account id:
25
+ *
26
+ * - A valid Stellar address (`G...` or muxed `M...`) is used as-is.
27
+ * - A SEP-2 federated address (e.g. `alice*example.com`) is looked up against
28
+ * the domain's federation server.
29
+ * - Anything else throws, so a transaction is never built toward garbage.
30
+ *
31
+ * @param value - An address or federated address.
32
+ * @param opts - Optional federation lookup options (e.g. `timeout`, `allowHttp`).
33
+ * @returns The resolved address details — see {@link ResolvedAddress}.
34
+ * @throws If the value is neither a valid address nor a resolvable federated address.
35
+ */
36
+ export declare const resolveAddress: (value: string, opts?: Federation.Api.Options) => Promise<ResolvedAddress>;
37
+ /**
38
+ * Convenience wrapper for the common "I only need the account id" case (Horizon
39
+ * query filters such as `forAccount`/`sponsor`/`claimant`). Passes `undefined`
40
+ * through untouched so optional filters stay optional, and resolves everything
41
+ * else — including federated addresses — down to its base Ed25519 key.
42
+ *
43
+ * @param address - An optional address or federated address.
44
+ * @returns The base `G...` key, or `undefined` when no address was given.
45
+ * @throws If a non-empty `address` is neither valid nor resolvable.
46
+ */
47
+ export declare const resolveAddressKey: (address?: string) => Promise<string | undefined>;
@@ -0,0 +1,19 @@
1
+ import { Asset } from '@stellar/stellar-sdk';
2
+ /**
3
+ * Loose asset input accepted across the SDK and normalized by
4
+ * {@link resolveAsset}:
5
+ *
6
+ * - `'xlm'` / `'native'` — the native lumen
7
+ * - `'USDC:GA5Z...KZVN'` — an issued asset in `CODE:ISSUER` form
8
+ * - an {@link Asset} instance — returned unchanged
9
+ */
10
+ export type AssetArg = string | Asset;
11
+ /**
12
+ * Normalizes an {@link AssetArg} into a stellar-sdk {@link Asset}. Shared by the
13
+ * core functions so they all parse assets the same way.
14
+ *
15
+ * @param asset - `'xlm'`/`'native'`, a `CODE:ISSUER` string, or an `Asset`.
16
+ * @returns The corresponding `Asset` (native for `'xlm'`/`'native'`).
17
+ * @throws If the value is not a recognized form, or the issuer is not a valid Ed25519 public key.
18
+ */
19
+ export declare const resolveAsset: (asset: AssetArg) => Asset;
@@ -4,6 +4,7 @@ export { getAssets } from './getAssets';
4
4
  export { getBalances } from './getBalances';
5
5
  export { getClaimableBalances } from './getClaimableBalances';
6
6
  export { getEffects } from './getEffects';
7
+ export { fundAccount, type FundAccountOptions, type FundAccountResult, type FundAccountStatus, } from './fundAccount';
7
8
  export { getLedgers } from './getLedgers';
8
9
  export { getLiquidityPools } from './getLiquidityPools';
9
10
  export { getNetwork } from './getNetwork';
@@ -18,6 +19,12 @@ export { getTrades } from './getTrades';
18
19
  export { getTransactions } from './getTransactions';
19
20
  export { readContracts } from './readContracts';
20
21
  export { writeContract } from './writeContract';
22
+ export { transfer, type TransferOptions } from './transfer';
23
+ export { swap, type SwapOptions, type SwapType } from './swap';
24
+ export { getSacAddress } from './getSacAddress';
25
+ export { getTokenMetadata, type TokenMetadata, type GetTokenMetadataOptions, } from './getTokenMetadata';
21
26
  export { networks } from './networks';
22
27
  export { switchNetwork } from './switchNetwork';
23
28
  export { type Numberish, numberish, ToScVal } from './toScVal';
29
+ export { resolveAsset, resolveAddress, resolveAddressKey, type AssetArg, type ResolvedAddress, } from './helpers';
30
+ export type { ISubmittedTransaction, TransactionReturnValue, SendTransactionResult, } from '../../types';
@@ -1,8 +1,18 @@
1
1
  import { Networks } from '@stellar/stellar-sdk';
2
+ /**
3
+ * Convenience map of friendly network names to their Stellar passphrases. Pass a
4
+ * value from here as the `network` option on any core function or to
5
+ * {@link switchNetwork}.
6
+ */
2
7
  export declare const networks: {
8
+ /** Public network (mainnet) passphrase. */
3
9
  mainnet: Networks;
10
+ /** Testnet passphrase. */
4
11
  testnet: Networks;
12
+ /** Sandbox passphrase. */
5
13
  sandbox: Networks;
14
+ /** Futurenet passphrase. */
6
15
  futurenet: Networks;
16
+ /** Standalone (local) network passphrase. */
7
17
  standalone: Networks;
8
18
  };
@@ -1,5 +1,18 @@
1
1
  import { rpc } from '@stellar/stellar-sdk';
2
2
  import { IContractCall, ReadContractsOptions } from '../utils';
3
+ /**
4
+ * Reads from one or more Soroban contracts by simulating the calls — no
5
+ * transaction is submitted and no account is required, so this is free and
6
+ * read-only. Each call's return value is decoded to a native JS value (`bigint`
7
+ * results are stringified).
8
+ *
9
+ * @param calls - The contract calls to simulate; build `args` with {@link ToScVal}.
10
+ * @param options - Network to simulate against.
11
+ * @returns `{ raws, values }` aligned to `calls` — `raws` holds the full
12
+ * simulation per call, `values` the decoded return values (`null` for a call
13
+ * that returned nothing). An empty array is returned when `calls` is empty.
14
+ * @throws If called before {@link createConfig}, if `calls` is not an array, or if any simulation fails.
15
+ */
3
16
  export declare const readContracts: (calls: IContractCall[], options?: ReadContractsOptions) => Promise<never[] | {
4
17
  raws: (rpc.Api.SimulateTransactionSuccessResponse | rpc.Api.SimulateTransactionRestoreResponse | undefined)[];
5
18
  values: any[];
@@ -0,0 +1,52 @@
1
+ import { ISubmittedTransaction } from '../../types';
2
+ import { type Numberish } from './toScVal';
3
+ import { type AssetArg } from './helpers';
4
+ /**
5
+ * Which side of the swap is fixed:
6
+ *
7
+ * - `'exactIn'` — send exactly `amount` of `fromAsset` (the received amount floats).
8
+ * - `'exactOut'` — receive exactly `amount` of `toAsset` (the sent amount floats).
9
+ */
10
+ export type SwapType = 'exactIn' | 'exactOut';
11
+ /** Options for {@link swap}. */
12
+ export type SwapOptions = {
13
+ /** Asset being sold. Accepts `'xlm'` / `'native'`, a `CODE:ISSUER` string, or an `Asset`. */
14
+ fromAsset: AssetArg;
15
+ /** Asset being bought. Accepts `'xlm'` / `'native'`, a `CODE:ISSUER` string, or an `Asset`. */
16
+ toAsset: AssetArg;
17
+ /**
18
+ * The fixed amount. For `'exactIn'` this is how much `fromAsset` to send; for
19
+ * `'exactOut'` it is how much `toAsset` to receive. Numbers and bigints are
20
+ * coerced to a string.
21
+ */
22
+ amount: Numberish;
23
+ /** Which side is fixed. Defaults to `'exactIn'`. */
24
+ type?: SwapType;
25
+ /**
26
+ * Where the bought asset is delivered: a Stellar address (`G...`/`M...`) or a
27
+ * SEP-2 federated address. Defaults to the logged-in account (a self-swap).
28
+ */
29
+ to?: string;
30
+ /**
31
+ * Maximum acceptable slippage as a fraction, where `0.005` = 0.5%. Sets the
32
+ * `destMin` (exactIn) / `sendMax` (exactOut) guardrail off the quoted price.
33
+ * Defaults to `0.005`.
34
+ */
35
+ slippage?: number;
36
+ /** Optional text memo to attach to the transaction. */
37
+ memo?: string;
38
+ /** Network passphrase to swap on. Defaults to the active network. */
39
+ network?: string;
40
+ };
41
+ /**
42
+ * Swaps one asset for another through the Stellar DEX / liquidity pools using a
43
+ * path payment, picking the best available path automatically. Defaults to a
44
+ * self-swap; pass `to` to deliver the bought asset to another account. When the
45
+ * recipient is the logged-in account and lacks a trustline for `toAsset`, the
46
+ * required `changeTrust` is added automatically. Requires a logged-in account.
47
+ *
48
+ * @param options - What to swap and how — see {@link SwapOptions}.
49
+ * @returns The submitted transaction.
50
+ * @throws If no account is logged in, the inputs are invalid, no path exists, the destination account does not exist, or the destination (when not self) lacks a trustline for `toAsset`.
51
+ */
52
+ export declare const swap: (options: SwapOptions) => Promise<ISubmittedTransaction>;
@@ -1 +1,8 @@
1
+ /**
2
+ * Switches the active network and stops automatic network syncing with the
3
+ * connected wallet (so the choice sticks until changed again).
4
+ *
5
+ * @param newNetwork - Passphrase of the network to switch to; must be listed in `config.networks`.
6
+ * @throws If called before {@link createConfig} or if the network is not in `config.networks`.
7
+ */
1
8
  export declare const switchNetwork: (newNetwork: string) => void;
@@ -1,30 +1,66 @@
1
1
  import { xdr } from '@stellar/stellar-sdk';
2
+ /** A numeric value accepted in string, number, or bigint form. */
2
3
  export type Numberish = string | number | bigint;
4
+ /**
5
+ * Coerces a {@link Numberish} into a specific primitive type.
6
+ *
7
+ * @param val - The value to convert.
8
+ * @param targetType - The primitive to coerce to: `'string'`, `'number'`, or `'bigint'`.
9
+ * @returns `val` as the requested type.
10
+ */
3
11
  export declare const numberish: <T extends Numberish>(val: Numberish, targetType: "string" | "number" | "bigint") => T;
4
12
  type MapEntry = Record<string, xdr.ScVal | Object>;
13
+ /**
14
+ * Encoders that turn JS values into Soroban {@link xdr.ScVal} arguments for
15
+ * {@link readContracts} / {@link writeContract} calls. Each method maps to one
16
+ * Soroban value type.
17
+ */
5
18
  export declare class ToScVal {
19
+ /** Encodes a signed 32-bit integer (`i32`). */
6
20
  static i32(value: Numberish): xdr.ScVal;
21
+ /** Encodes a signed 64-bit integer (`i64`). */
7
22
  static i64(value: Numberish): xdr.ScVal;
23
+ /** Encodes a signed 128-bit integer (`i128`). */
8
24
  static i128(value: Numberish): xdr.ScVal;
25
+ /** Encodes a signed 256-bit integer (`i256`). */
9
26
  static i256(value: Numberish): xdr.ScVal;
27
+ /** Encodes an unsigned 32-bit integer (`u32`). */
10
28
  static u32(value: Numberish): xdr.ScVal;
29
+ /** Encodes an unsigned 64-bit integer (`u64`). */
11
30
  static u64(value: Numberish): xdr.ScVal;
31
+ /** Encodes an unsigned 128-bit integer (`u128`). */
12
32
  static u128(value: Numberish): xdr.ScVal;
33
+ /** Encodes an unsigned 256-bit integer (`u256`). */
13
34
  static u256(value: Numberish): xdr.ScVal;
35
+ /** Encodes a contract error value. */
14
36
  static error(value: xdr.ScError): xdr.ScVal;
37
+ /** Encodes a duration (seconds, as an unsigned 64-bit value). */
15
38
  static duration(value: Numberish): xdr.ScVal;
39
+ /** Encodes a timepoint (Unix seconds, as an unsigned 64-bit value). */
16
40
  static timepoint(value: Numberish): xdr.ScVal;
41
+ /** Encodes a ledger-key nonce. */
17
42
  static ledgerKeyNonce(value: xdr.ScNonceKey): xdr.ScVal;
43
+ /** Encodes a contract instance value. */
18
44
  static contractInstance(value: xdr.ScContractInstance): xdr.ScVal;
45
+ /** Encodes a map from pre-built {@link xdr.ScMapEntry} entries (or `null`). */
19
46
  static scvMap(value: null | xdr.ScMapEntry[]): xdr.ScVal;
47
+ /** Encodes a map from a plain object, recursing into nested objects (keys become symbols). */
20
48
  static map(value: MapEntry | null): xdr.ScVal;
49
+ /** Encodes a string value. */
21
50
  static string(value: string | Buffer): xdr.ScVal;
51
+ /** Encodes a vector of pre-built ScVals (or `null`). */
22
52
  static vec(value: null | xdr.ScVal[]): xdr.ScVal;
53
+ /** Encodes the void value. */
23
54
  static void(): xdr.ScVal;
55
+ /** Encodes a raw byte array. */
24
56
  static bytes(value: Buffer): xdr.ScVal;
57
+ /** Encodes the ledger-key for a contract instance. */
25
58
  static ledgerKeyContractInstance(): xdr.ScVal;
59
+ /** Encodes a symbol (short identifier, e.g. a function or enum name). */
26
60
  static symbol(symbol: string | Buffer): xdr.ScVal;
61
+ /** Encodes a boolean. */
27
62
  static boolean(bool: boolean): xdr.ScVal;
63
+ /** Encodes an address — an account (`G...`) or contract (`C...`). */
28
64
  static address(address: string): xdr.ScVal;
29
65
  }
30
66
  export {};
@@ -0,0 +1,49 @@
1
+ import { ISubmittedTransaction } from '../../types';
2
+ import { type Numberish } from './toScVal';
3
+ import { type AssetArg } from './helpers';
4
+ /** Options for {@link transfer}. */
5
+ export type TransferOptions = {
6
+ /**
7
+ * Recipient: a Stellar address (`G...` or muxed `M...`) or a SEP-2 federated
8
+ * address (`alice*example.com`). For a `token` transfer a contract id (`C...`)
9
+ * is also accepted.
10
+ */
11
+ to: string;
12
+ /**
13
+ * Amount to send. Numbers and bigints are coerced to a string. For classic
14
+ * assets this is a decimal amount (`"10.5"`); for a `token` it is the integer
15
+ * base-unit amount the contract expects.
16
+ */
17
+ amount: Numberish;
18
+ /**
19
+ * Asset to send. Accepts `'xlm'` / `'native'`, a `CODE:ISSUER` string, or an
20
+ * `Asset`. Defaults to the native lumen. Ignored when `token` is set.
21
+ */
22
+ asset?: AssetArg;
23
+ /** Optional text memo. Ignored for `token` (Soroban) transfers. */
24
+ memo?: string;
25
+ /**
26
+ * When the recipient cannot receive the asset directly (its account does not
27
+ * exist, or it has no trustline for an issued asset), send a claimable balance
28
+ * it can claim later instead of failing. Defaults to `false`.
29
+ */
30
+ claimable?: boolean;
31
+ /**
32
+ * A SEP-41 token contract id (`C...`). When set, value moves through the
33
+ * contract's `transfer(from, to, amount)` entrypoint instead of a classic op.
34
+ */
35
+ token?: string;
36
+ /** Network passphrase to send on. Defaults to the active network. */
37
+ network?: string;
38
+ };
39
+ /**
40
+ * Sends value from the logged-in account to `to`, choosing the right mechanism
41
+ * automatically: createAccount for a new recipient, payment for an existing one,
42
+ * a claimable balance when asked, or a SEP-41 contract call when `token` is set.
43
+ * Requires a logged-in account.
44
+ *
45
+ * @param options - Recipient, amount, and how to send — see {@link TransferOptions}.
46
+ * @returns The submitted transaction.
47
+ * @throws If no account is logged in, the inputs are invalid, or the recipient cannot receive the asset (and `claimable` was not set).
48
+ */
49
+ export declare const transfer: (options: TransferOptions) => Promise<ISubmittedTransaction>;
@@ -1,2 +1,13 @@
1
1
  import { IContractCall, WriteContractsOptions } from '../utils';
2
- export declare const writeContract: (call: IContractCall, options?: WriteContractsOptions) => Promise<unknown>;
2
+ import { ISubmittedTransaction } from '../../types';
3
+ /**
4
+ * Invokes a state-changing Soroban contract function: builds the call, simulates
5
+ * it to attach resource fees / footprint / auth, then signs and submits it with
6
+ * the logged-in account. Requires a logged-in user.
7
+ *
8
+ * @param call - The contract call to make; build `args` with {@link ToScVal}.
9
+ * @param options - Network to submit on.
10
+ * @returns The submitted transaction, whose `returnValue()` resolves to the contract's decoded return value.
11
+ * @throws If called before {@link createConfig}, if `call.address`/`call.fn` are missing, or if simulation fails.
12
+ */
13
+ export declare const writeContract: (call: IContractCall, options?: WriteContractsOptions) => Promise<ISubmittedTransaction>;
@@ -1,3 +1,12 @@
1
1
  import { IConfig } from '../types';
2
2
  import '../tailwind.css';
3
+ /**
4
+ * Initializes the Blux SDK: validates the config, mounts the Blux UI, loads
5
+ * available wallets, wires up integrations (WalletConnect, Trezor), and
6
+ * authenticates the app id. Call this once before any other Blux function.
7
+ *
8
+ * @param config - The app configuration — see {@link IConfig}.
9
+ * @param element - DOM element to mount the Blux UI into. Defaults to `document.body`.
10
+ * @throws If `config` is empty or missing `appId`, `appName`, or `networks`, or if the network options are invalid.
11
+ */
3
12
  export declare function createConfig(config: IConfig, element?: HTMLElement): void;
@@ -1,26 +1,68 @@
1
1
  import { Horizon, rpc, xdr } from '@stellar/stellar-sdk';
2
+ /**
3
+ * A single Soroban contract invocation, consumed by {@link readContracts} and
4
+ * {@link writeContract}.
5
+ */
2
6
  export type IContractCall = {
7
+ /** Contract id (`C...`) to invoke. */
3
8
  address: string;
9
+ /** Name of the contract function to call. */
4
10
  fn: string;
11
+ /** Call arguments, encoded as Soroban values — build these with {@link ToScVal}. */
5
12
  args: xdr.ScVal[];
6
13
  };
14
+ /** Options for {@link readContracts}. */
7
15
  export type ReadContractsOptions = {
16
+ /** Network passphrase to simulate against. Defaults to the active network. */
8
17
  network?: string;
9
18
  };
19
+ /** Options for {@link writeContract}. */
10
20
  export type WriteContractsOptions = {
21
+ /** Network passphrase to submit on. Defaults to the active network. */
11
22
  network?: string;
12
23
  };
24
+ /** Pagination and network options shared by every Horizon list query. */
13
25
  export type CallBuilderOptions = {
26
+ /** Paging token; pass the previous page's cursor to fetch the next page. */
14
27
  cursor?: string;
28
+ /** Maximum number of records returned per page. */
15
29
  limit?: number;
30
+ /** Network passphrase to query. Defaults to the active network. */
16
31
  network?: string;
32
+ /** Sort direction by ledger sequence. Defaults to Horizon's `asc`. */
17
33
  order?: 'asc' | 'desc';
18
34
  };
35
+ /**
36
+ * Reports whether {@link createConfig} has run and the SDK is initialized.
37
+ *
38
+ * @returns `true` once the Stellar transports are configured.
39
+ */
19
40
  export declare const checkConfigCreated: () => boolean;
41
+ /**
42
+ * Resolves which address to act on, defaulting to the logged-in account.
43
+ *
44
+ * @param address - An explicit address to use instead of the logged-in account.
45
+ * @returns The chosen address.
46
+ * @throws If no address is provided and no account is logged in.
47
+ */
20
48
  export declare const getAddress: (address?: string) => string;
49
+ /**
50
+ * Resolves the Horizon server, Soroban RPC server, and passphrase for a network.
51
+ *
52
+ * @param network - Passphrase of the network to use. Defaults to the active network.
53
+ * @returns The `horizon` server, `soroban` RPC server, and `networkPassphrase`.
54
+ * @throws If no network is given and the SDK has no configured transports.
55
+ */
21
56
  export declare const getNetwork: (network?: string) => {
22
57
  horizon: Horizon.Server;
23
58
  soroban: rpc.Server;
24
59
  networkPassphrase: string;
25
60
  };
61
+ /**
62
+ * Switches the active network in the store and emits a network-changed event.
63
+ * Internal plumbing for the exported {@link switchNetwork}.
64
+ *
65
+ * @param newNetwork - Passphrase of the network to switch to; must be listed in `config.networks`.
66
+ * @throws If called before {@link createConfig}, if the network is not configured, or if there is no active network.
67
+ */
26
68
  export declare const internalSwitchNetwork: (newNetwork: string) => void;