@unlink-xyz/react 0.1.3-canary.01ac52d → 0.1.3-canary.05ae89f
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 +58 -44
- package/dist/index.js +700 -441
- package/dist/index.js.map +1 -1
- package/dist/multisig/index.d.ts +106 -0
- package/dist/multisig/index.js +31353 -0
- package/dist/multisig/index.js.map +1 -0
- package/package.json +12 -2
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, SupportedChain,
|
|
4
|
-
export { Account, AccountInfo,
|
|
3
|
+
import { BrowserWalletOptions, SupportedChain, Unlink, AccountInfo, Account, NoteRecord, BurnerAccount, HistoryStatus, SignerOverride, SendResult, SendPlanResult, DepositRelayResult, WithdrawalInput, WithdrawResult, WithdrawPlanResult, BurnerSendParams, SimpleBurnerFundParams, SimpleBurnerSweepToPoolParams, SimpleInteractParams, InteractResult, RelayState, HistoryEntry } from '@unlink-xyz/core';
|
|
4
|
+
export { Account, AccountInfo, AdapterExecutionCall, BurnerAccount, BurnerSendParams, Chain, HistoryEntry, InputTokenSpec, InteractResult, NoteRecord, ParsedZkAddress, ReceiveInput, ReshieldInput, SendPlanResult, SendResult, SignerOverride, SimpleBurnerFundParams, SimpleBurnerSweepToPoolParams, SimpleInteractParams, SpendInput, SupportedChain, TransactionLike, TxStatusChangedEvent, Unlink, UnlinkEvent, UnlinkWallet, WalletSDKEvent, WithdrawPlanResult, WithdrawResult, approve, buildApproveCall, computeBalances, contract, decodeAddress, encodeAddress, formatAmount, normalizeAddress, parseAmount, parseZkAddress, randomHex, shortenHex, toCall } from '@unlink-xyz/core';
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* Wallet note with value as bigint for convenience.
|
|
@@ -23,7 +23,7 @@ type PendingJobBase = {
|
|
|
23
23
|
type PendingDepositJob = PendingJobBase & {
|
|
24
24
|
commitment?: string;
|
|
25
25
|
};
|
|
26
|
-
type
|
|
26
|
+
type PendingSendJob = PendingJobBase & {
|
|
27
27
|
recipient: string;
|
|
28
28
|
};
|
|
29
29
|
type PendingWithdrawJob = PendingJobBase & {
|
|
@@ -63,8 +63,8 @@ type UnlinkConfig = UnlinkConfigBase & ({
|
|
|
63
63
|
* State exposed by the useUnlink hook.
|
|
64
64
|
*/
|
|
65
65
|
type UnlinkState = {
|
|
66
|
-
/** The underlying
|
|
67
|
-
|
|
66
|
+
/** The underlying Unlink instance */
|
|
67
|
+
unlink: Unlink | null;
|
|
68
68
|
/** Whether a wallet (mnemonic) exists */
|
|
69
69
|
walletExists: boolean;
|
|
70
70
|
/** All derived accounts */
|
|
@@ -83,8 +83,8 @@ type UnlinkState = {
|
|
|
83
83
|
burners: BurnerAccount[];
|
|
84
84
|
/** Pending deposit jobs */
|
|
85
85
|
pendingDeposits: PendingDepositJob[];
|
|
86
|
-
/** Pending
|
|
87
|
-
|
|
86
|
+
/** Pending send jobs */
|
|
87
|
+
pendingSends: PendingSendJob[];
|
|
88
88
|
/** Pending withdraw jobs */
|
|
89
89
|
pendingWithdrawals: PendingWithdrawJob[];
|
|
90
90
|
/** Whether the SDK is initialized and ready */
|
|
@@ -99,9 +99,9 @@ type UnlinkState = {
|
|
|
99
99
|
error: UnlinkError | null;
|
|
100
100
|
};
|
|
101
101
|
/**
|
|
102
|
-
*
|
|
102
|
+
* Send parameters for useUnlink.send()
|
|
103
103
|
*/
|
|
104
|
-
type
|
|
104
|
+
type SendInput = {
|
|
105
105
|
token: string;
|
|
106
106
|
/** Unlink address (unlink1... bech32m) */
|
|
107
107
|
recipient: string;
|
|
@@ -117,7 +117,7 @@ type DepositInput = {
|
|
|
117
117
|
depositor: string;
|
|
118
118
|
};
|
|
119
119
|
/**
|
|
120
|
-
* Withdraw parameters for useUnlink.
|
|
120
|
+
* Withdraw parameters for useUnlink.withdraw()
|
|
121
121
|
*/
|
|
122
122
|
type WithdrawInput = WithdrawalInput;
|
|
123
123
|
/**
|
|
@@ -143,28 +143,28 @@ type UnlinkActions = {
|
|
|
143
143
|
* Multiple transfers are processed atomically.
|
|
144
144
|
*
|
|
145
145
|
* @param params - Array of transfers (token + amount + recipient)
|
|
146
|
-
* @returns
|
|
146
|
+
* @returns SendResult with array of plans
|
|
147
147
|
*/
|
|
148
|
-
send(params:
|
|
148
|
+
send(params: SendInput[], overrides?: SignerOverride): Promise<SendResult>;
|
|
149
149
|
/**
|
|
150
|
-
* Get a
|
|
150
|
+
* Get a send plan without executing (for preview).
|
|
151
151
|
* Validates balances and returns plans for each transfer.
|
|
152
152
|
*
|
|
153
153
|
* @param params - Array of transfers (token + amount + recipient)
|
|
154
154
|
* @returns Array of TransactionPlan
|
|
155
155
|
*/
|
|
156
|
-
|
|
157
|
-
/** Execute a pre-built
|
|
158
|
-
|
|
156
|
+
planSend(params: SendInput[]): Promise<SendPlanResult>;
|
|
157
|
+
/** Execute a pre-built send plan */
|
|
158
|
+
executeSend(plans: SendPlanResult, overrides?: SignerOverride): Promise<SendResult>;
|
|
159
159
|
/**
|
|
160
|
-
*
|
|
160
|
+
* Deposit (1 or more tokens).
|
|
161
161
|
* Returns calldata that the user must submit on-chain via their EOA.
|
|
162
162
|
* Use the returned `to` and `calldata` fields to construct the transaction.
|
|
163
163
|
*
|
|
164
164
|
* @param params - Array of deposits (token + amount + depositor)
|
|
165
165
|
* @returns DepositRelayResult with array of commitments
|
|
166
166
|
*/
|
|
167
|
-
|
|
167
|
+
deposit(params: DepositInput[]): Promise<DepositRelayResult>;
|
|
168
168
|
/**
|
|
169
169
|
* High-level withdraw (1 or more tokens).
|
|
170
170
|
* Specify recipient EOA + amount for each withdrawal.
|
|
@@ -173,7 +173,7 @@ type UnlinkActions = {
|
|
|
173
173
|
* @param params - Array of withdrawals (token + amount + recipient)
|
|
174
174
|
* @returns WithdrawResult with array of plans
|
|
175
175
|
*/
|
|
176
|
-
|
|
176
|
+
withdraw(params: WithdrawInput[], overrides?: SignerOverride): Promise<WithdrawResult>;
|
|
177
177
|
/**
|
|
178
178
|
* Get a withdrawal plan without executing (for preview).
|
|
179
179
|
* Validates balances and returns plans for each withdrawal.
|
|
@@ -183,7 +183,7 @@ type UnlinkActions = {
|
|
|
183
183
|
*/
|
|
184
184
|
planWithdraw(params: WithdrawInput[]): Promise<WithdrawPlanResult>;
|
|
185
185
|
/** Execute a pre-built withdrawal plan */
|
|
186
|
-
executeWithdraw(plans: WithdrawPlanResult): Promise<WithdrawResult>;
|
|
186
|
+
executeWithdraw(plans: WithdrawPlanResult, overrides?: SignerOverride): Promise<WithdrawResult>;
|
|
187
187
|
/** Derive and track burner account at index */
|
|
188
188
|
createBurner(index: number): Promise<BurnerAccount>;
|
|
189
189
|
/** Remove tracked burner account (client-side only) */
|
|
@@ -203,9 +203,9 @@ type UnlinkActions = {
|
|
|
203
203
|
/** Get native balance for address */
|
|
204
204
|
burnerGetBalance(address: string): Promise<bigint>;
|
|
205
205
|
/**
|
|
206
|
-
* Execute an atomic private
|
|
206
|
+
* Execute an atomic private DeFi flow (unshield -> calls -> reshield).
|
|
207
207
|
*/
|
|
208
|
-
|
|
208
|
+
interact(params: SimpleInteractParams): Promise<InteractResult>;
|
|
209
209
|
/** Refresh notes and balances */
|
|
210
210
|
refresh(): Promise<void>;
|
|
211
211
|
/** Force full resync from chain */
|
|
@@ -294,7 +294,7 @@ type UnlinkErrorCode = "UNKNOWN" | "SDK_NOT_INITIALIZED" | "NETWORK_ERROR" | "VA
|
|
|
294
294
|
/**
|
|
295
295
|
* Operations that can trigger an error in the Unlink context.
|
|
296
296
|
*/
|
|
297
|
-
type UnlinkErrorOperation = "init" | "createWallet" | "importWallet" | "clearWallet" | "createAccount" | "switchAccount" | "send" | "
|
|
297
|
+
type UnlinkErrorOperation = "init" | "createWallet" | "importWallet" | "clearWallet" | "createAccount" | "switchAccount" | "send" | "executeSend" | "deposit" | "withdraw" | "interact" | "executeWithdraw" | "createBurner" | "burnerSend" | "burnerFund" | "burnerSweepToPool" | "refresh" | "forceResync";
|
|
298
298
|
/**
|
|
299
299
|
* Structured error type for the Unlink context.
|
|
300
300
|
*/
|
|
@@ -350,7 +350,7 @@ type UseUnlinkHistoryResult = {
|
|
|
350
350
|
refresh: () => Promise<void>;
|
|
351
351
|
};
|
|
352
352
|
/**
|
|
353
|
-
* Hook to get transaction history for the
|
|
353
|
+
* Hook to get transaction history for the Unlink instance.
|
|
354
354
|
*
|
|
355
355
|
* Uses the SDK's history service which provides properly categorized
|
|
356
356
|
* transaction entries (Deposit, Receive, Send, SelfSend, Withdraw).
|
|
@@ -462,8 +462,8 @@ declare function useUnlinkBalances(): {
|
|
|
462
462
|
declare function useTxStatus(txId: string | null): UseTxStatusResult;
|
|
463
463
|
|
|
464
464
|
type UseOperationMutationResult<TInput, TOutput> = {
|
|
465
|
-
/** Execute the
|
|
466
|
-
|
|
465
|
+
/** Execute the operation */
|
|
466
|
+
execute: (input: TInput) => Promise<TOutput>;
|
|
467
467
|
/** Last successful result */
|
|
468
468
|
data: TOutput | null;
|
|
469
469
|
/** Whether the mutation is currently running */
|
|
@@ -477,6 +477,13 @@ type UseOperationMutationResult<TInput, TOutput> = {
|
|
|
477
477
|
/** Reset state back to idle */
|
|
478
478
|
reset: () => void;
|
|
479
479
|
};
|
|
480
|
+
/**
|
|
481
|
+
* `UseOperationMutationResult` with `execute` replaced by a semantic action name.
|
|
482
|
+
* Used by operation-specific hooks (useSend, useDeposit, etc.).
|
|
483
|
+
*/
|
|
484
|
+
type NamedMutationResult<TAction extends string, TInput, TOutput> = Omit<UseOperationMutationResult<TInput, TOutput>, "execute"> & {
|
|
485
|
+
[K in TAction]: (input: TInput) => Promise<TOutput>;
|
|
486
|
+
};
|
|
480
487
|
/**
|
|
481
488
|
* Generic async mutation state machine for wallet operations.
|
|
482
489
|
*
|
|
@@ -486,11 +493,11 @@ type UseOperationMutationResult<TInput, TOutput> = {
|
|
|
486
493
|
* @example
|
|
487
494
|
* ```tsx
|
|
488
495
|
* function DepositButton() {
|
|
489
|
-
* const {
|
|
490
|
-
* const {
|
|
496
|
+
* const { deposit } = useUnlink();
|
|
497
|
+
* const { execute, isPending, error } = useOperationMutation(deposit);
|
|
491
498
|
*
|
|
492
499
|
* return (
|
|
493
|
-
* <button onClick={() =>
|
|
500
|
+
* <button onClick={() => execute(params)} disabled={isPending}>
|
|
494
501
|
* {isPending ? "Depositing..." : "Deposit"}
|
|
495
502
|
* </button>
|
|
496
503
|
* );
|
|
@@ -499,13 +506,14 @@ type UseOperationMutationResult<TInput, TOutput> = {
|
|
|
499
506
|
*/
|
|
500
507
|
declare function useOperationMutation<TInput, TOutput>(operation: (input: TInput) => Promise<TOutput>): UseOperationMutationResult<TInput, TOutput>;
|
|
501
508
|
|
|
509
|
+
type UseDepositResult = NamedMutationResult<"deposit", DepositInput[], DepositRelayResult>;
|
|
502
510
|
/**
|
|
503
511
|
* Hook for requesting deposits with loading/error state.
|
|
504
512
|
*
|
|
505
513
|
* @example
|
|
506
514
|
* ```tsx
|
|
507
515
|
* function DepositForm() {
|
|
508
|
-
* const {
|
|
516
|
+
* const { deposit, isPending, error } = useDeposit();
|
|
509
517
|
*
|
|
510
518
|
* const handleDeposit = async () => {
|
|
511
519
|
* const result = await deposit([
|
|
@@ -522,15 +530,18 @@ declare function useOperationMutation<TInput, TOutput>(operation: (input: TInput
|
|
|
522
530
|
* }
|
|
523
531
|
* ```
|
|
524
532
|
*/
|
|
525
|
-
declare function useDeposit():
|
|
533
|
+
declare function useDeposit(): UseDepositResult;
|
|
526
534
|
|
|
535
|
+
type UseSendResult = NamedMutationResult<"send", SendInput[], SendResult>;
|
|
527
536
|
/**
|
|
528
537
|
* Hook for sending private transfers with loading/error state.
|
|
529
538
|
*
|
|
539
|
+
* @param overrides - Optional signer override for multisig transactions
|
|
540
|
+
*
|
|
530
541
|
* @example
|
|
531
542
|
* ```tsx
|
|
532
543
|
* function SendForm() {
|
|
533
|
-
* const {
|
|
544
|
+
* const { send, isPending, error } = useSend();
|
|
534
545
|
*
|
|
535
546
|
* const handleSend = async () => {
|
|
536
547
|
* const result = await send([
|
|
@@ -547,15 +558,18 @@ declare function useDeposit(): UseOperationMutationResult<DepositInput[], Deposi
|
|
|
547
558
|
* }
|
|
548
559
|
* ```
|
|
549
560
|
*/
|
|
550
|
-
declare function
|
|
561
|
+
declare function useSend(overrides?: SignerOverride): UseSendResult;
|
|
551
562
|
|
|
563
|
+
type UseWithdrawResult = NamedMutationResult<"withdraw", WithdrawInput[], WithdrawResult>;
|
|
552
564
|
/**
|
|
553
565
|
* Hook for requesting withdrawals with loading/error state.
|
|
554
566
|
*
|
|
567
|
+
* @param overrides - Optional signer override for multisig transactions
|
|
568
|
+
*
|
|
555
569
|
* @example
|
|
556
570
|
* ```tsx
|
|
557
571
|
* function WithdrawForm() {
|
|
558
|
-
* const {
|
|
572
|
+
* const { withdraw, isPending, error } = useWithdraw();
|
|
559
573
|
*
|
|
560
574
|
* const handleWithdraw = async () => {
|
|
561
575
|
* const result = await withdraw([
|
|
@@ -572,24 +586,24 @@ declare function useTransfer(): UseOperationMutationResult<TransferInput[], Tran
|
|
|
572
586
|
* }
|
|
573
587
|
* ```
|
|
574
588
|
*/
|
|
575
|
-
declare function useWithdraw():
|
|
589
|
+
declare function useWithdraw(overrides?: SignerOverride): UseWithdrawResult;
|
|
576
590
|
|
|
591
|
+
type UseInteractResult = NamedMutationResult<"interact", SimpleInteractParams, InteractResult>;
|
|
577
592
|
/**
|
|
578
|
-
* Hook for executing private DeFi
|
|
593
|
+
* Hook for executing private DeFi interactions with loading/error state.
|
|
579
594
|
*
|
|
580
595
|
* Performs atomic unshield → DeFi call(s) → reshield flows through an adapter contract.
|
|
581
596
|
*
|
|
582
597
|
* @example
|
|
583
598
|
* ```tsx
|
|
584
599
|
* function SwapButton() {
|
|
585
|
-
* const {
|
|
600
|
+
* const { interact, isPending, error } = useInteract();
|
|
586
601
|
*
|
|
587
602
|
* const handleSwap = async () => {
|
|
588
|
-
* const result = await
|
|
589
|
-
*
|
|
590
|
-
* inputs: [{ token: "0x...", amount: 1000n }],
|
|
603
|
+
* const result = await interact({
|
|
604
|
+
* spend: [{ token: "0x...", amount: 1000n }],
|
|
591
605
|
* calls: [approveCall, swapCall],
|
|
592
|
-
*
|
|
606
|
+
* receive: [{ token: "0x...", minAmount: 500n }],
|
|
593
607
|
* });
|
|
594
608
|
* console.log("Relay ID:", result.relayId);
|
|
595
609
|
* };
|
|
@@ -602,7 +616,7 @@ declare function useWithdraw(): UseOperationMutationResult<WithdrawInput[], With
|
|
|
602
616
|
* }
|
|
603
617
|
* ```
|
|
604
618
|
*/
|
|
605
|
-
declare function
|
|
619
|
+
declare function useInteract(): UseInteractResult;
|
|
606
620
|
|
|
607
621
|
type BurnerSendInput = {
|
|
608
622
|
index: number;
|
|
@@ -634,8 +648,8 @@ type UseBurnerResult = {
|
|
|
634
648
|
* Hook for burner account operations.
|
|
635
649
|
*
|
|
636
650
|
* `exportKey` is intentionally excluded here and can be accessed via
|
|
637
|
-
* `useUnlink().
|
|
651
|
+
* `useUnlink().unlink?.burner.exportKey(index)`.
|
|
638
652
|
*/
|
|
639
653
|
declare function useBurner(): UseBurnerResult;
|
|
640
654
|
|
|
641
|
-
export { type BurnerFundInput, type BurnerSendInput, type BurnerSweepInput, CONFIRMATION_POLL_INTERVAL_MS, DEFAULT_CONFIRMATION_TIMEOUT_MS, type DepositInput, type PendingDepositJob, type
|
|
655
|
+
export { type BurnerFundInput, type BurnerSendInput, type BurnerSweepInput, CONFIRMATION_POLL_INTERVAL_MS, DEFAULT_CONFIRMATION_TIMEOUT_MS, type DepositInput, type NamedMutationResult, type PendingDepositJob, type PendingSendJob, type PendingWithdrawJob, type SendInput, TERMINAL_TX_STATES, TimeoutError, TransactionFailedError, type TxState, type TxStatus, type UnlinkActions, type UnlinkConfig, type UnlinkContextValue, type UnlinkError, type UnlinkErrorCode, type UnlinkErrorOperation, UnlinkProvider, type UnlinkProviderProps, type UnlinkState, type UseBurnerResult, type UseDepositResult, type UseInteractResult, type UseOperationMutationResult, type UseSendResult, type UseTxStatusResult, type UseUnlinkBalanceResult, type UseUnlinkHistoryOptions, type UseUnlinkHistoryResult, type UseWithdrawResult, type WaitForConfirmationOptions, type WalletNote, type WithdrawInput, useBurner, useDeposit, useInteract, useOperationMutation, useSend, useTxStatus, useUnlink, useUnlinkBalance, useUnlinkBalances, useUnlinkHistory, useWithdraw };
|