@bluxcc/react 0.3.6 → 0.3.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 (42) hide show
  1. package/dist/Provider.d.ts +91 -2
  2. package/dist/hooks/index.d.ts +1 -0
  3. package/dist/hooks/useBlux.d.ts +3 -1
  4. package/dist/hooks/useJwt.d.ts +19 -0
  5. package/dist/hooks/useLoginAction.d.ts +5 -1
  6. package/dist/hooks/useLoginCode.d.ts +21 -2
  7. package/dist/hooks/useLoginEmail.d.ts +33 -3
  8. package/dist/hooks/useLoginOAuth.d.ts +31 -3
  9. package/dist/hooks/useLoginPasskey.d.ts +19 -3
  10. package/dist/hooks/useLoginSms.d.ts +33 -3
  11. package/dist/hooks/useLoginWallet.d.ts +19 -3
  12. package/dist/index.cjs.js +1 -1
  13. package/dist/index.d.ts +2 -2
  14. package/dist/index.esm.js +1 -1
  15. package/dist/useStellar/index.d.ts +3 -0
  16. package/dist/useStellar/useAccount.d.ts +12 -4
  17. package/dist/useStellar/useAccounts.d.ts +2 -2
  18. package/dist/useStellar/useAssets.d.ts +17 -3
  19. package/dist/useStellar/useBalances.d.ts +12 -2
  20. package/dist/useStellar/useClaimableBalances.d.ts +18 -2
  21. package/dist/useStellar/useEffects.d.ts +21 -2
  22. package/dist/useStellar/useLedgers.d.ts +13 -2
  23. package/dist/useStellar/useLiquidityPools.d.ts +16 -2
  24. package/dist/useStellar/useOffers.d.ts +22 -2
  25. package/dist/useStellar/useOperations.d.ts +23 -2
  26. package/dist/useStellar/useOrderbook.d.ts +7 -2
  27. package/dist/useStellar/usePayments.d.ts +19 -2
  28. package/dist/useStellar/useReadContract.d.ts +54 -0
  29. package/dist/useStellar/useReadContracts.d.ts +20 -10
  30. package/dist/useStellar/useResolveXlmName.d.ts +22 -0
  31. package/dist/useStellar/useResolveXlmNameByAddress.d.ts +23 -0
  32. package/dist/useStellar/useSacAddress.d.ts +2 -2
  33. package/dist/useStellar/useStrictReceivePaths.d.ts +9 -4
  34. package/dist/useStellar/useStrictSendPaths.d.ts +10 -5
  35. package/dist/useStellar/useSwap.d.ts +32 -3
  36. package/dist/useStellar/useTokenMetadata.d.ts +7 -4
  37. package/dist/useStellar/useTradeAggregation.d.ts +7 -2
  38. package/dist/useStellar/useTrades.d.ts +22 -2
  39. package/dist/useStellar/useTransactions.d.ts +21 -2
  40. package/dist/useStellar/useTransfer.d.ts +39 -4
  41. package/dist/useStellar/useWriteContract.d.ts +16 -15
  42. package/package.json +2 -2
@@ -1,5 +1,5 @@
1
1
  import { UseQueryResult } from '@tanstack/react-query';
2
- import type { GetTradeAggregationResult } from "@bluxcc/core/dist/exports/core/getTradeAggregation";
2
+ import type { GetTradeAggregationResult } from "@bluxcc/core";
3
3
  import { Asset } from '@stellar/stellar-sdk';
4
4
  import { CallBuilderOptions } from '../utils';
5
5
  import type { QueryOptions } from '../utils';
@@ -37,5 +37,10 @@ export declare function useTradeAggregation(args: [
37
37
  end_time: number,
38
38
  resolution: number,
39
39
  offset: number
40
- ], options?: O, queryOptions?: QueryOptions<R>): UseQueryResult<R, Error>;
40
+ ], options?: {
41
+ cursor?: string;
42
+ limit?: number;
43
+ network?: string;
44
+ order?: 'asc' | 'desc';
45
+ }, queryOptions?: QueryOptions<R>): UseQueryResult<R, Error>;
41
46
  export {};
@@ -1,5 +1,6 @@
1
+ import type { AssetArg } from '@bluxcc/core';
1
2
  import { UseQueryResult } from '@tanstack/react-query';
2
- import type { GetTradesResult, GetTradesOptions } from "@bluxcc/core/dist/exports/core/getTrades";
3
+ import type { GetTradesResult, GetTradesOptions } from "@bluxcc/core";
3
4
  import type { QueryOptions } from "../utils";
4
5
  type R = GetTradesResult;
5
6
  type O = GetTradesOptions;
@@ -23,5 +24,24 @@ type O = GetTradesOptions;
23
24
  * });
24
25
  * ```
25
26
  */
26
- export declare function useTrades(options?: O, queryOptions?: QueryOptions<R>): UseQueryResult<R, Error>;
27
+ export declare function useTrades(options?: {
28
+ /** Paging token; pass the previous page's cursor to fetch the next page. */
29
+ cursor?: string;
30
+ /** Maximum number of records returned per page. */
31
+ limit?: number;
32
+ /** Network passphrase to query. Defaults to the active network. */
33
+ network?: string;
34
+ /** Sort direction by ledger sequence. Defaults to Horizon's `asc`. */
35
+ order?: 'asc' | 'desc';
36
+ /** Only trades for this `[base, counter]` asset pair. Each accepts `'xlm'`, `'CODE:ISSUER'`, or an `Asset`. */
37
+ forAssetPair?: [base: AssetArg, counter: AssetArg];
38
+ /** Only trades against this offer id. */
39
+ forOffer?: string;
40
+ /** Only trades of this type (e.g. `orderbook`, `liquidity_pool`). */
41
+ forType?: Horizon.ServerApi.TradeType;
42
+ /** Only trades involving this account (address, SEP-2 address, or `.xlm` name). */
43
+ forAccount?: string;
44
+ /** Only trades for this liquidity pool id. */
45
+ forLiquidityPool?: string;
46
+ }, queryOptions?: QueryOptions<R>): UseQueryResult<R, Error>;
27
47
  export {};
@@ -1,5 +1,5 @@
1
1
  import { UseQueryResult } from '@tanstack/react-query';
2
- import type { GetTransactionsResult, GetTransactionsOptions } from "@bluxcc/core/dist/exports/core/getTransactions";
2
+ import type { GetTransactionsResult, GetTransactionsOptions } from "@bluxcc/core";
3
3
  import type { QueryOptions } from "../utils";
4
4
  type R = GetTransactionsResult;
5
5
  type O = GetTransactionsOptions;
@@ -21,5 +21,24 @@ type O = GetTransactionsOptions;
21
21
  * const { data } = useTransactions({ forAccount: 'GA…', limit: 25 });
22
22
  * ```
23
23
  */
24
- export declare function useTransactions(options?: O, queryOptions?: QueryOptions<R>): UseQueryResult<R, Error>;
24
+ export declare function useTransactions(options?: {
25
+ /** Paging token; pass the previous page's cursor to fetch the next page. */
26
+ cursor?: string;
27
+ /** Maximum number of records returned per page. */
28
+ limit?: number;
29
+ /** Network passphrase to query. Defaults to the active network. */
30
+ network?: string;
31
+ /** Sort direction by ledger sequence. Defaults to Horizon's `asc`. */
32
+ order?: 'asc' | 'desc';
33
+ /** Only transactions touching this account (address, SEP-2 address, or `.xlm` name). */
34
+ forAccount?: string;
35
+ /** Only transactions affecting this claimable balance id. */
36
+ forClaimableBalance?: string;
37
+ /** Only transactions in this ledger, by sequence number. */
38
+ forLedger?: string | number;
39
+ /** Only transactions affecting this liquidity pool id. */
40
+ forLiquidityPool?: string;
41
+ /** Include failed transactions. Defaults to `false`. */
42
+ includeFailed?: boolean;
43
+ }, queryOptions?: QueryOptions<R>): UseQueryResult<R, Error>;
25
44
  export {};
@@ -1,15 +1,50 @@
1
+ import type { AssetArg, Numberish } from '@bluxcc/core';
1
2
  import { transfer } from '@bluxcc/core';
2
3
  import { UseMutationResult } from '@tanstack/react-query';
3
- import type { TransferOptions } from '@bluxcc/core/dist/exports/core/transfer';
4
+ import type { TransferOptions } from '@bluxcc/core';
4
5
  import type { MutationOptions } from '../utils';
5
6
  type R = Awaited<ReturnType<typeof transfer>>;
6
7
  /**
7
8
  * Variables for {@link useTransfer} — the core `transfer` options verbatim, so
8
9
  * every path it supports (native XLM, issued asset, claimable balance, SEP-41
9
- * token, federated address) is just a different object passed to
10
+ * token, federated address, `.xlm` name) is just a different object passed to
10
11
  * `transfer({ ... })`.
11
12
  */
12
- export type TransferVariables = TransferOptions;
13
+ export type TransferVariables = {
14
+ /**
15
+ * Recipient: a Stellar address (`G...` or muxed `M...`), a SEP-2 federated
16
+ * address (`alice*example.com`), or a `.xlm` name. For a `token` transfer a
17
+ * contract id (`C...`) or a name resolving to one is also accepted.
18
+ */
19
+ to: string;
20
+ /**
21
+ * Amount to send. Numbers and bigints are coerced to a string. For classic
22
+ * assets this is a decimal amount (`"10.5"`); for a `token` it is the integer
23
+ * base-unit amount the contract expects.
24
+ */
25
+ amount: Numberish;
26
+ /**
27
+ * Asset to send. Accepts `'xlm'` / `'native'`, a `CODE:ISSUER` string, or an
28
+ * `Asset`. Defaults to the native lumen. Ignored when `token` is set.
29
+ */
30
+ asset?: AssetArg;
31
+ /** Optional text memo. Ignored for `token` (Soroban) transfers. */
32
+ memo?: string;
33
+ /**
34
+ * When the recipient cannot receive the asset directly (its account does not
35
+ * exist, or it has no trustline for an issued asset), send a claimable balance
36
+ * it can claim later instead of failing. Defaults to `false`.
37
+ */
38
+ claimable?: boolean;
39
+ /**
40
+ * A SEP-41 token contract id (`C...`) or name resolving to one. When set,
41
+ * value moves through the contract's `transfer(from, to, amount)` entrypoint
42
+ * instead of a classic op.
43
+ */
44
+ token?: string;
45
+ /** Network passphrase to send on. Defaults to the active network. */
46
+ network?: string;
47
+ };
13
48
  type V = TransferVariables;
14
49
  /**
15
50
  * Return type of {@link useTransfer}: the full TanStack mutation result plus
@@ -53,7 +88,7 @@ export type UseTransferResult = UseMutationResult<R, Error, V> & {
53
88
  * transfer({ to: 'GB…', amount: '1000000', token: 'C…' });
54
89
  *
55
90
  * // Await the result (e.g. in a form submit handler)
56
- * const tx = await transferAsync({ to: 'alice*example.com', amount: '5' });
91
+ * const tx = await transferAsync({ to: 'alice.xlm', amount: '5' });
57
92
  * ```
58
93
  */
59
94
  export declare function useTransfer(mutationOptions?: MutationOptions<R, V>): UseTransferResult;
@@ -1,8 +1,12 @@
1
1
  import { writeContract } from '@bluxcc/core';
2
2
  import { UseMutationResult } from '@tanstack/react-query';
3
- import type { IContractCall, WriteContractsOptions } from '@bluxcc/core/dist/exports/utils';
3
+ import type { IContractCall, WriteContractsOptions } from '@bluxcc/core';
4
4
  import type { MutationOptions } from '../utils';
5
- type R = Awaited<ReturnType<typeof writeContract>>;
5
+ type CoreWriteContractResult = Awaited<ReturnType<typeof writeContract>>;
6
+ /** Submitted transaction with a caller-specified decoded contract result. */
7
+ export type WriteContractHookResult<TReturnValue = unknown> = Omit<CoreWriteContractResult, 'returnValue'> & {
8
+ returnValue: () => Promise<TReturnValue | null>;
9
+ };
6
10
  /**
7
11
  * Variables for {@link useWriteContract}: the contract `call` to invoke and
8
12
  * optional core write `options` (e.g. `network`).
@@ -14,12 +18,12 @@ export type WriteContractVariables = {
14
18
  type V = WriteContractVariables;
15
19
  /**
16
20
  * Submits a state-changing Soroban contract invocation as a signed, on-chain
17
- * transaction.
21
+ * transaction. Native positional arguments are encoded from the deployed
22
+ * contract ABI; pre-built `xdr.ScVal`s are also accepted.
18
23
  *
19
24
  * A thin wrapper over TanStack Query's `useMutation`: call `mutate` /
20
- * `mutateAsync` with the contract call to sign and send it. Build `args` with
21
- * the exported `ToScVal` helpers. For read-only calls (no signature, no fees)
22
- * use `useReadContracts` instead.
25
+ * `mutateAsync` with the contract call to sign and send it. For read-only calls
26
+ * (no signature, no fees) use `useReadContract` or `useReadContracts` instead.
23
27
  *
24
28
  * @param mutationOptions - Optional TanStack Mutation options (`onSuccess`,
25
29
  * `onError`, `onSettled`, …); `mutationFn` is provided by the hook.
@@ -29,20 +33,17 @@ type V = WriteContractVariables;
29
33
  *
30
34
  * @example
31
35
  * ```tsx
32
- * const { mutate, isPending, data } = useWriteContract();
36
+ * const { mutateAsync, isPending } = useWriteContract<bigint>();
33
37
  *
34
- * mutate({
38
+ * const transaction = await mutateAsync({
35
39
  * call: {
36
- * address: 'C…',
40
+ * address: 'token.xlm',
37
41
  * fn: 'transfer',
38
- * args: [
39
- * ToScVal.address('GFROM…'),
40
- * ToScVal.address('GTO…'),
41
- * ToScVal.i128('1000000'),
42
- * ],
42
+ * args: ['alice.xlm', 'bob.xlm', 1_000_000],
43
43
  * },
44
44
  * });
45
+ * const result = await transaction.returnValue(); // bigint | null
45
46
  * ```
46
47
  */
47
- export declare function useWriteContract(mutationOptions?: MutationOptions<R, V>): UseMutationResult<R, Error, V>;
48
+ export declare function useWriteContract<TReturnValue = unknown>(mutationOptions?: MutationOptions<WriteContractHookResult<TReturnValue>, V>): UseMutationResult<WriteContractHookResult<TReturnValue>, Error, V>;
48
49
  export {};
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@bluxcc/react",
3
3
  "author": "Blux team",
4
- "version": "0.3.6",
4
+ "version": "0.3.8",
5
5
  "homepage": "https://blux.cc",
6
6
  "description": "Connecting to the Stellar Ecosystem and Beyond",
7
7
  "repository": {
@@ -30,7 +30,7 @@
30
30
  "build": "rollup -c rollup.config.prod.js"
31
31
  },
32
32
  "peerDependencies": {
33
- "@bluxcc/core": "^0.3.6",
33
+ "@bluxcc/core": "^0.3.8",
34
34
  "@stellar/stellar-sdk": "^17.0.1",
35
35
  "@tanstack/react-query": "^5.90.11",
36
36
  "react": ">=17.0.0",