@unlink-xyz/react 0.1.3-canary.94ce361 → 0.1.3-canary.b0ad588

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/index.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import * as react_jsx_runtime from 'react/jsx-runtime';
2
2
  import { ReactNode } from 'react';
3
- import { BrowserWalletOptions, Environment, UnlinkWallet, AccountInfo, Account, NoteRecord, HistoryStatus, TransferResult, TransferPlanResult, DepositRelayResult, WithdrawalInput, WithdrawResult, WithdrawPlanResult, RelayState, HistoryEntry } from '@unlink-xyz/core';
4
- export { Account, AccountInfo, Chain, HistoryEntry, NoteRecord, ParsedZkAddress, TransferPlanResult, TransferResult, TxStatusChangedEvent, UnlinkWallet, WalletSDKEvent, WithdrawPlanResult, WithdrawResult, computeBalances, decodeAddress, encodeAddress, formatAmount, normalizeAddress, parseAmount, parseZkAddress, randomHex, shortenHex } from '@unlink-xyz/core';
3
+ import { BrowserWalletOptions, SupportedChain, UnlinkWallet, AccountInfo, Account, NoteRecord, HistoryStatus, TransferResult, TransferPlanResult, DepositRelayResult, WithdrawalInput, WithdrawResult, WithdrawPlanResult, SimpleAdapterExecuteParams, AdapterExecuteResult, RelayState, HistoryEntry } from '@unlink-xyz/core';
4
+ export { Account, AccountInfo, AdapterExecuteResult, AdapterExecutionCall, Chain, HistoryEntry, InputTokenSpec, NoteRecord, ParsedZkAddress, ReshieldInput, SimpleAdapterExecuteParams, SupportedChain, TransferPlanResult, TransferResult, TxStatusChangedEvent, UnlinkWallet, WalletSDKEvent, WithdrawPlanResult, WithdrawResult, computeBalances, decodeAddress, encodeAddress, formatAmount, normalizeAddress, parseAmount, parseZkAddress, randomHex, shortenHex } from '@unlink-xyz/core';
5
5
 
6
6
  /**
7
7
  * Wallet note with value as bigint for convenience.
@@ -33,8 +33,6 @@ type PendingWithdrawJob = PendingJobBase & {
33
33
  * Base configuration shared by all UnlinkProvider variants.
34
34
  */
35
35
  type UnlinkConfigBase = {
36
- /** Chain ID for the target blockchain */
37
- chainId: number;
38
36
  /** Auto-sync interval in milliseconds (default: 5000) */
39
37
  syncInterval?: number;
40
38
  /** Whether to start auto-sync on mount (default: true) */
@@ -44,19 +42,22 @@ type UnlinkConfigBase = {
44
42
  };
45
43
  /**
46
44
  * Configuration for the UnlinkProvider.
47
- * Either provide explicit gatewayUrl + poolAddress, or environment to auto-resolve.
45
+ * Either provide a chain name to auto-resolve, or explicit gatewayUrl + poolAddress.
48
46
  */
49
47
  type UnlinkConfig = UnlinkConfigBase & ({
48
+ /** Supported chain name — resolves chainId, gateway, pool, artifacts */
49
+ chain: SupportedChain;
50
+ /** Override pool address from chain config */
51
+ poolAddress?: string;
52
+ chainId?: never;
53
+ gatewayUrl?: never;
54
+ } | {
55
+ /** Chain ID for the target blockchain */
56
+ chainId: number;
50
57
  /** Explicit gateway URL - requires poolAddress */
51
58
  gatewayUrl: string;
52
59
  poolAddress: string;
53
- environment?: never;
54
- } | {
55
- /** Environment to use from the config file */
56
- environment: Environment;
57
- /** Pool contract address - optional, defaults to environment config */
58
- poolAddress?: string;
59
- gatewayUrl?: never;
60
+ chain?: never;
60
61
  });
61
62
  /**
62
63
  * State exposed by the useUnlink hook.
@@ -72,8 +73,8 @@ type UnlinkState = {
72
73
  activeAccount: Account | null;
73
74
  /** Current active account index (null if none) */
74
75
  activeAccountIndex: number | null;
75
- /** Chain ID configured for this provider */
76
- chainId: number;
76
+ /** Chain ID (resolved from chain config or provided explicitly, null before init) */
77
+ chainId: number | null;
77
78
  /** User's notes with value as bigint */
78
79
  notes: WalletNote[];
79
80
  /** Token balances by address */
@@ -181,6 +182,10 @@ type UnlinkActions = {
181
182
  planWithdraw(params: WithdrawInput[]): Promise<WithdrawPlanResult>;
182
183
  /** Execute a pre-built withdrawal plan */
183
184
  executeWithdraw(plans: WithdrawPlanResult): Promise<WithdrawResult>;
185
+ /**
186
+ * Execute an atomic private adapter flow (unshield -> calls -> reshield).
187
+ */
188
+ executeAdapter(params: SimpleAdapterExecuteParams): Promise<AdapterExecuteResult>;
184
189
  /** Refresh notes and balances */
185
190
  refresh(): Promise<void>;
186
191
  /** Force full resync from chain */
@@ -269,7 +274,7 @@ type UnlinkErrorCode = "UNKNOWN" | "SDK_NOT_INITIALIZED" | "NETWORK_ERROR" | "VA
269
274
  /**
270
275
  * Operations that can trigger an error in the Unlink context.
271
276
  */
272
- type UnlinkErrorOperation = "init" | "createWallet" | "importWallet" | "clearWallet" | "createAccount" | "switchAccount" | "send" | "executeTransfer" | "requestDeposit" | "requestWithdraw" | "executeWithdraw" | "refresh" | "forceResync";
277
+ type UnlinkErrorOperation = "init" | "createWallet" | "importWallet" | "clearWallet" | "createAccount" | "switchAccount" | "send" | "executeTransfer" | "requestDeposit" | "requestWithdraw" | "executeAdapter" | "executeWithdraw" | "refresh" | "forceResync";
273
278
  /**
274
279
  * Structured error type for the Unlink context.
275
280
  */
@@ -284,7 +289,7 @@ type UnlinkError = {
284
289
  type UnlinkProviderProps = UnlinkConfig & {
285
290
  children: ReactNode;
286
291
  };
287
- declare function UnlinkProvider({ children, chainId, poolAddress, syncInterval, autoSync, gatewayUrl, environment, prover, }: UnlinkProviderProps): react_jsx_runtime.JSX.Element;
292
+ declare function UnlinkProvider({ children, poolAddress, syncInterval, autoSync, prover, ...configProps }: UnlinkProviderProps): react_jsx_runtime.JSX.Element;
288
293
 
289
294
  /**
290
295
  * Hook to access the Unlink wallet SDK.
@@ -549,4 +554,34 @@ declare function useTransfer(): UseOperationMutationResult<TransferInput[], Tran
549
554
  */
550
555
  declare function useWithdraw(): UseOperationMutationResult<WithdrawInput[], WithdrawResult>;
551
556
 
552
- export { CONFIRMATION_POLL_INTERVAL_MS, DEFAULT_CONFIRMATION_TIMEOUT_MS, type DepositInput, type PendingDepositJob, type PendingTransferJob, type PendingWithdrawJob, TERMINAL_TX_STATES, TimeoutError, TransactionFailedError, type TransferInput, type TxState, type TxStatus, type UnlinkActions, type UnlinkConfig, type UnlinkContextValue, type UnlinkError, type UnlinkErrorCode, type UnlinkErrorOperation, UnlinkProvider, type UnlinkProviderProps, type UnlinkState, type UseOperationMutationResult, type UseTxStatusResult, type UseUnlinkBalanceResult, type UseUnlinkHistoryOptions, type UseUnlinkHistoryResult, type WaitForConfirmationOptions, type WalletNote, type WithdrawInput, useDeposit, useOperationMutation, useTransfer, useTxStatus, useUnlink, useUnlinkBalance, useUnlinkBalances, useUnlinkHistory, useWithdraw };
557
+ /**
558
+ * Hook for executing private DeFi adapter operations with loading/error state.
559
+ *
560
+ * Performs atomic unshield → DeFi call(s) → reshield flows through an adapter contract.
561
+ *
562
+ * @example
563
+ * ```tsx
564
+ * function SwapButton() {
565
+ * const { mutate: executeAdapter, isPending, error } = useAdapter();
566
+ *
567
+ * const handleSwap = async () => {
568
+ * const result = await executeAdapter({
569
+ * adapterAddress: "0x...",
570
+ * inputs: [{ token: "0x...", amount: 1000n }],
571
+ * calls: [approveCall, swapCall],
572
+ * reshields: [{ token: "0x...", minAmount: 500n }],
573
+ * });
574
+ * console.log("Relay ID:", result.relayId);
575
+ * };
576
+ *
577
+ * return (
578
+ * <button onClick={handleSwap} disabled={isPending}>
579
+ * {isPending ? "Executing..." : "Swap"}
580
+ * </button>
581
+ * );
582
+ * }
583
+ * ```
584
+ */
585
+ declare function useAdapter(): UseOperationMutationResult<SimpleAdapterExecuteParams, AdapterExecuteResult>;
586
+
587
+ export { CONFIRMATION_POLL_INTERVAL_MS, DEFAULT_CONFIRMATION_TIMEOUT_MS, type DepositInput, type PendingDepositJob, type PendingTransferJob, type PendingWithdrawJob, TERMINAL_TX_STATES, TimeoutError, TransactionFailedError, type TransferInput, type TxState, type TxStatus, type UnlinkActions, type UnlinkConfig, type UnlinkContextValue, type UnlinkError, type UnlinkErrorCode, type UnlinkErrorOperation, UnlinkProvider, type UnlinkProviderProps, type UnlinkState, type UseOperationMutationResult, type UseTxStatusResult, type UseUnlinkBalanceResult, type UseUnlinkHistoryOptions, type UseUnlinkHistoryResult, type WaitForConfirmationOptions, type WalletNote, type WithdrawInput, useAdapter, useDeposit, useOperationMutation, useTransfer, useTxStatus, useUnlink, useUnlinkBalance, useUnlinkBalances, useUnlinkHistory, useWithdraw };