@unlink-xyz/react 0.1.3-canary.f8763d3 → 0.1.3-canary.fa60920
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 +18 -14
- package/dist/index.js +274 -130
- 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, UnlinkWallet, AccountInfo, Account, NoteRecord, BurnerAccount, HistoryStatus, TransferResult, TransferPlanResult, DepositRelayResult, WithdrawalInput, WithdrawResult, WithdrawPlanResult, BurnerSendParams, SimpleBurnerFundParams, SimpleBurnerSweepToPoolParams, SimpleAdapterExecuteParams, AdapterExecuteResult, RelayState, HistoryEntry } from '@unlink-xyz/core';
|
|
4
|
-
export { Account, AccountInfo, AdapterExecuteResult, AdapterExecutionCall, BurnerAccount, BurnerSendParams, Chain, HistoryEntry, InputTokenSpec, NoteRecord, ParsedZkAddress, ReshieldInput, SimpleAdapterExecuteParams, SimpleBurnerFundParams, SimpleBurnerSweepToPoolParams, SupportedChain, 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, BurnerAccount, HistoryStatus, SignerOverride, TransferResult, TransferPlanResult, DepositRelayResult, WithdrawalInput, WithdrawResult, WithdrawPlanResult, BurnerSendParams, SimpleBurnerFundParams, SimpleBurnerSweepToPoolParams, SimpleAdapterExecuteParams, AdapterExecuteResult, RelayState, HistoryEntry } from '@unlink-xyz/core';
|
|
4
|
+
export { Account, AccountInfo, AdapterExecuteResult, AdapterExecutionCall, BurnerAccount, BurnerSendParams, Chain, HistoryEntry, InputTokenSpec, NoteRecord, ParsedZkAddress, ReshieldInput, SignerOverride, SimpleAdapterExecuteParams, SimpleBurnerFundParams, SimpleBurnerSweepToPoolParams, 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.
|
|
@@ -103,7 +103,7 @@ type UnlinkState = {
|
|
|
103
103
|
*/
|
|
104
104
|
type TransferInput = {
|
|
105
105
|
token: string;
|
|
106
|
-
/** Unlink address (
|
|
106
|
+
/** Unlink address (unlink1... bech32m) */
|
|
107
107
|
recipient: string;
|
|
108
108
|
amount: bigint;
|
|
109
109
|
};
|
|
@@ -145,7 +145,7 @@ type UnlinkActions = {
|
|
|
145
145
|
* @param params - Array of transfers (token + amount + recipient)
|
|
146
146
|
* @returns TransferResult with array of plans
|
|
147
147
|
*/
|
|
148
|
-
send(params: TransferInput[]): Promise<TransferResult>;
|
|
148
|
+
send(params: TransferInput[], overrides?: SignerOverride): Promise<TransferResult>;
|
|
149
149
|
/**
|
|
150
150
|
* Get a transfer plan without executing (for preview).
|
|
151
151
|
* Validates balances and returns plans for each transfer.
|
|
@@ -155,7 +155,7 @@ type UnlinkActions = {
|
|
|
155
155
|
*/
|
|
156
156
|
planTransfer(params: TransferInput[]): Promise<TransferPlanResult>;
|
|
157
157
|
/** Execute a pre-built transfer plan */
|
|
158
|
-
executeTransfer(plans: TransferPlanResult): Promise<TransferResult>;
|
|
158
|
+
executeTransfer(plans: TransferPlanResult, overrides?: SignerOverride): Promise<TransferResult>;
|
|
159
159
|
/**
|
|
160
160
|
* Request a deposit (1 or more tokens).
|
|
161
161
|
* Returns calldata that the user must submit on-chain via their EOA.
|
|
@@ -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
|
-
requestWithdraw(params: WithdrawInput[]): Promise<WithdrawResult>;
|
|
176
|
+
requestWithdraw(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) */
|
|
@@ -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 */
|
|
@@ -487,10 +487,10 @@ type UseOperationMutationResult<TInput, TOutput> = {
|
|
|
487
487
|
* ```tsx
|
|
488
488
|
* function DepositButton() {
|
|
489
489
|
* const { requestDeposit } = useUnlink();
|
|
490
|
-
* const {
|
|
490
|
+
* const { execute, isPending, error } = useOperationMutation(requestDeposit);
|
|
491
491
|
*
|
|
492
492
|
* return (
|
|
493
|
-
* <button onClick={() =>
|
|
493
|
+
* <button onClick={() => execute(params)} disabled={isPending}>
|
|
494
494
|
* {isPending ? "Depositing..." : "Deposit"}
|
|
495
495
|
* </button>
|
|
496
496
|
* );
|
|
@@ -527,6 +527,8 @@ declare function useDeposit(): UseOperationMutationResult<DepositInput[], Deposi
|
|
|
527
527
|
/**
|
|
528
528
|
* Hook for sending private transfers with loading/error state.
|
|
529
529
|
*
|
|
530
|
+
* @param overrides - Optional signer override for multisig transactions
|
|
531
|
+
*
|
|
530
532
|
* @example
|
|
531
533
|
* ```tsx
|
|
532
534
|
* function SendForm() {
|
|
@@ -534,7 +536,7 @@ declare function useDeposit(): UseOperationMutationResult<DepositInput[], Deposi
|
|
|
534
536
|
*
|
|
535
537
|
* const handleSend = async () => {
|
|
536
538
|
* const result = await send([
|
|
537
|
-
* { token: "0x...", recipient: "
|
|
539
|
+
* { token: "0x...", recipient: "unlink1...", amount: 100n },
|
|
538
540
|
* ]);
|
|
539
541
|
* console.log("Relay ID:", result.relayId);
|
|
540
542
|
* };
|
|
@@ -547,11 +549,13 @@ declare function useDeposit(): UseOperationMutationResult<DepositInput[], Deposi
|
|
|
547
549
|
* }
|
|
548
550
|
* ```
|
|
549
551
|
*/
|
|
550
|
-
declare function useTransfer(): UseOperationMutationResult<TransferInput[], TransferResult>;
|
|
552
|
+
declare function useTransfer(overrides?: SignerOverride): UseOperationMutationResult<TransferInput[], TransferResult>;
|
|
551
553
|
|
|
552
554
|
/**
|
|
553
555
|
* Hook for requesting withdrawals with loading/error state.
|
|
554
556
|
*
|
|
557
|
+
* @param overrides - Optional signer override for multisig transactions
|
|
558
|
+
*
|
|
555
559
|
* @example
|
|
556
560
|
* ```tsx
|
|
557
561
|
* function WithdrawForm() {
|
|
@@ -572,7 +576,7 @@ declare function useTransfer(): UseOperationMutationResult<TransferInput[], Tran
|
|
|
572
576
|
* }
|
|
573
577
|
* ```
|
|
574
578
|
*/
|
|
575
|
-
declare function useWithdraw(): UseOperationMutationResult<WithdrawInput[], WithdrawResult>;
|
|
579
|
+
declare function useWithdraw(overrides?: SignerOverride): UseOperationMutationResult<WithdrawInput[], WithdrawResult>;
|
|
576
580
|
|
|
577
581
|
/**
|
|
578
582
|
* Hook for executing private DeFi adapter operations with loading/error state.
|
package/dist/index.js
CHANGED
|
@@ -9042,9 +9042,9 @@ function genBech32(encoding) {
|
|
|
9042
9042
|
}
|
|
9043
9043
|
var bech32m = /* @__PURE__ */ genBech32("bech32m");
|
|
9044
9044
|
var VERSION = 1;
|
|
9045
|
-
var LIMIT =
|
|
9045
|
+
var LIMIT = 130;
|
|
9046
9046
|
var ALL_CHAINS = "ffffffffffffffff";
|
|
9047
|
-
var PREFIX = "
|
|
9047
|
+
var PREFIX = "unlink";
|
|
9048
9048
|
var SALT = new TextEncoder().encode("unlink");
|
|
9049
9049
|
function xorWithSalt(hex2) {
|
|
9050
9050
|
const bytes2 = Hex.toBytes(hex2);
|
|
@@ -9162,7 +9162,7 @@ function parseZkAddress(value) {
|
|
|
9162
9162
|
};
|
|
9163
9163
|
} catch (err) {
|
|
9164
9164
|
throw new ValidationError(
|
|
9165
|
-
`Invalid ZK address (expected
|
|
9165
|
+
`Invalid ZK address (expected unlink1... format): ${err instanceof Error ? err.message : "unknown error"}`
|
|
9166
9166
|
);
|
|
9167
9167
|
}
|
|
9168
9168
|
}
|
|
@@ -35647,29 +35647,41 @@ function createJsonHttpClient(baseUrl, deps) {
|
|
|
35647
35647
|
fetch: fetchImpl,
|
|
35648
35648
|
// Disable ky's automatic error throwing to prevent browser DevTools
|
|
35649
35649
|
// from logging expected 404s as network errors
|
|
35650
|
-
throwHttpErrors: false
|
|
35650
|
+
throwHttpErrors: false,
|
|
35651
|
+
retry: 0
|
|
35651
35652
|
});
|
|
35653
|
+
const RETRYABLE_STATUSES = [502, 503, 504];
|
|
35654
|
+
const MAX_RETRIES = 3;
|
|
35655
|
+
const BASE_DELAY_MS = 500;
|
|
35652
35656
|
return {
|
|
35653
35657
|
async request(opts) {
|
|
35654
35658
|
let res;
|
|
35655
|
-
|
|
35656
|
-
|
|
35657
|
-
|
|
35658
|
-
|
|
35659
|
-
|
|
35660
|
-
|
|
35661
|
-
|
|
35662
|
-
|
|
35663
|
-
|
|
35664
|
-
|
|
35665
|
-
|
|
35666
|
-
|
|
35659
|
+
for (let attempt = 0; attempt <= MAX_RETRIES; attempt++) {
|
|
35660
|
+
try {
|
|
35661
|
+
res = await api(opts.path.replace(/^\//, ""), {
|
|
35662
|
+
method: opts.method,
|
|
35663
|
+
searchParams: opts.query,
|
|
35664
|
+
json: opts.json,
|
|
35665
|
+
body: opts.body,
|
|
35666
|
+
headers: opts.headers,
|
|
35667
|
+
signal: opts.signal
|
|
35668
|
+
});
|
|
35669
|
+
} catch (err) {
|
|
35670
|
+
if (err instanceof TimeoutError) {
|
|
35671
|
+
throw new HttpError("HTTP timeout", 408, null);
|
|
35672
|
+
}
|
|
35673
|
+
throw new HttpError(
|
|
35674
|
+
err instanceof Error ? err.message : "Network error",
|
|
35675
|
+
0,
|
|
35676
|
+
null
|
|
35677
|
+
);
|
|
35667
35678
|
}
|
|
35668
|
-
|
|
35669
|
-
|
|
35670
|
-
|
|
35671
|
-
|
|
35672
|
-
|
|
35679
|
+
if (RETRYABLE_STATUSES.includes(res.status) && attempt < MAX_RETRIES) {
|
|
35680
|
+
const delay2 = BASE_DELAY_MS * 2 ** attempt + Math.random() * 200;
|
|
35681
|
+
await new Promise((r2) => setTimeout(r2, delay2));
|
|
35682
|
+
continue;
|
|
35683
|
+
}
|
|
35684
|
+
break;
|
|
35673
35685
|
}
|
|
35674
35686
|
if (!res.ok) {
|
|
35675
35687
|
const body = await readErrorBodySafe(res);
|
|
@@ -35919,6 +35931,11 @@ function parseChainConfig(chain2, value) {
|
|
|
35919
35931
|
"artifactVersion",
|
|
35920
35932
|
raw.artifactVersion
|
|
35921
35933
|
).replace(/^\/+|\/+$/g, "");
|
|
35934
|
+
const frostUrl = parseOptionalString(
|
|
35935
|
+
chain2,
|
|
35936
|
+
"frostUrl",
|
|
35937
|
+
raw.frostUrl
|
|
35938
|
+
)?.replace(/\/+$/, "");
|
|
35922
35939
|
const artifactBaseUrl = parseOptionalString(
|
|
35923
35940
|
chain2,
|
|
35924
35941
|
"artifactBaseUrl",
|
|
@@ -35927,6 +35944,7 @@ function parseChainConfig(chain2, value) {
|
|
|
35927
35944
|
return {
|
|
35928
35945
|
chainId,
|
|
35929
35946
|
gatewayUrl,
|
|
35947
|
+
...frostUrl !== void 0 ? { frostUrl } : {},
|
|
35930
35948
|
poolAddress,
|
|
35931
35949
|
artifactVersion,
|
|
35932
35950
|
...artifactBaseUrl !== void 0 ? { artifactBaseUrl } : { artifactBaseUrl: DEFAULT_ARTIFACT_BASE_URL }
|
|
@@ -53332,6 +53350,114 @@ var circuits_default = {
|
|
|
53332
53350
|
template: "JoinSplit",
|
|
53333
53351
|
pubs: ["merkleRoot", "boundParamsHash", "nullifiers", "commitmentsOut"],
|
|
53334
53352
|
params: [5, 2, 16]
|
|
53353
|
+
},
|
|
53354
|
+
joinsplit_1x3_16: {
|
|
53355
|
+
file: "joinsplit",
|
|
53356
|
+
template: "JoinSplit",
|
|
53357
|
+
pubs: ["merkleRoot", "boundParamsHash", "nullifiers", "commitmentsOut"],
|
|
53358
|
+
params: [1, 3, 16]
|
|
53359
|
+
},
|
|
53360
|
+
joinsplit_4x3_16: {
|
|
53361
|
+
file: "joinsplit",
|
|
53362
|
+
template: "JoinSplit",
|
|
53363
|
+
pubs: ["merkleRoot", "boundParamsHash", "nullifiers", "commitmentsOut"],
|
|
53364
|
+
params: [4, 3, 16]
|
|
53365
|
+
},
|
|
53366
|
+
joinsplit_5x3_16: {
|
|
53367
|
+
file: "joinsplit",
|
|
53368
|
+
template: "JoinSplit",
|
|
53369
|
+
pubs: ["merkleRoot", "boundParamsHash", "nullifiers", "commitmentsOut"],
|
|
53370
|
+
params: [5, 3, 16]
|
|
53371
|
+
},
|
|
53372
|
+
joinsplit_6x1_16: {
|
|
53373
|
+
file: "joinsplit",
|
|
53374
|
+
template: "JoinSplit",
|
|
53375
|
+
pubs: ["merkleRoot", "boundParamsHash", "nullifiers", "commitmentsOut"],
|
|
53376
|
+
params: [6, 1, 16]
|
|
53377
|
+
},
|
|
53378
|
+
joinsplit_6x2_16: {
|
|
53379
|
+
file: "joinsplit",
|
|
53380
|
+
template: "JoinSplit",
|
|
53381
|
+
pubs: ["merkleRoot", "boundParamsHash", "nullifiers", "commitmentsOut"],
|
|
53382
|
+
params: [6, 2, 16]
|
|
53383
|
+
},
|
|
53384
|
+
joinsplit_6x3_16: {
|
|
53385
|
+
file: "joinsplit",
|
|
53386
|
+
template: "JoinSplit",
|
|
53387
|
+
pubs: ["merkleRoot", "boundParamsHash", "nullifiers", "commitmentsOut"],
|
|
53388
|
+
params: [6, 3, 16]
|
|
53389
|
+
},
|
|
53390
|
+
joinsplit_7x1_16: {
|
|
53391
|
+
file: "joinsplit",
|
|
53392
|
+
template: "JoinSplit",
|
|
53393
|
+
pubs: ["merkleRoot", "boundParamsHash", "nullifiers", "commitmentsOut"],
|
|
53394
|
+
params: [7, 1, 16]
|
|
53395
|
+
},
|
|
53396
|
+
joinsplit_7x2_16: {
|
|
53397
|
+
file: "joinsplit",
|
|
53398
|
+
template: "JoinSplit",
|
|
53399
|
+
pubs: ["merkleRoot", "boundParamsHash", "nullifiers", "commitmentsOut"],
|
|
53400
|
+
params: [7, 2, 16]
|
|
53401
|
+
},
|
|
53402
|
+
joinsplit_7x3_16: {
|
|
53403
|
+
file: "joinsplit",
|
|
53404
|
+
template: "JoinSplit",
|
|
53405
|
+
pubs: ["merkleRoot", "boundParamsHash", "nullifiers", "commitmentsOut"],
|
|
53406
|
+
params: [7, 3, 16]
|
|
53407
|
+
},
|
|
53408
|
+
joinsplit_8x1_16: {
|
|
53409
|
+
file: "joinsplit",
|
|
53410
|
+
template: "JoinSplit",
|
|
53411
|
+
pubs: ["merkleRoot", "boundParamsHash", "nullifiers", "commitmentsOut"],
|
|
53412
|
+
params: [8, 1, 16]
|
|
53413
|
+
},
|
|
53414
|
+
joinsplit_8x2_16: {
|
|
53415
|
+
file: "joinsplit",
|
|
53416
|
+
template: "JoinSplit",
|
|
53417
|
+
pubs: ["merkleRoot", "boundParamsHash", "nullifiers", "commitmentsOut"],
|
|
53418
|
+
params: [8, 2, 16]
|
|
53419
|
+
},
|
|
53420
|
+
joinsplit_8x3_16: {
|
|
53421
|
+
file: "joinsplit",
|
|
53422
|
+
template: "JoinSplit",
|
|
53423
|
+
pubs: ["merkleRoot", "boundParamsHash", "nullifiers", "commitmentsOut"],
|
|
53424
|
+
params: [8, 3, 16]
|
|
53425
|
+
},
|
|
53426
|
+
joinsplit_9x1_16: {
|
|
53427
|
+
file: "joinsplit",
|
|
53428
|
+
template: "JoinSplit",
|
|
53429
|
+
pubs: ["merkleRoot", "boundParamsHash", "nullifiers", "commitmentsOut"],
|
|
53430
|
+
params: [9, 1, 16]
|
|
53431
|
+
},
|
|
53432
|
+
joinsplit_9x2_16: {
|
|
53433
|
+
file: "joinsplit",
|
|
53434
|
+
template: "JoinSplit",
|
|
53435
|
+
pubs: ["merkleRoot", "boundParamsHash", "nullifiers", "commitmentsOut"],
|
|
53436
|
+
params: [9, 2, 16]
|
|
53437
|
+
},
|
|
53438
|
+
joinsplit_9x3_16: {
|
|
53439
|
+
file: "joinsplit",
|
|
53440
|
+
template: "JoinSplit",
|
|
53441
|
+
pubs: ["merkleRoot", "boundParamsHash", "nullifiers", "commitmentsOut"],
|
|
53442
|
+
params: [9, 3, 16]
|
|
53443
|
+
},
|
|
53444
|
+
joinsplit_10x1_16: {
|
|
53445
|
+
file: "joinsplit",
|
|
53446
|
+
template: "JoinSplit",
|
|
53447
|
+
pubs: ["merkleRoot", "boundParamsHash", "nullifiers", "commitmentsOut"],
|
|
53448
|
+
params: [10, 1, 16]
|
|
53449
|
+
},
|
|
53450
|
+
joinsplit_10x2_16: {
|
|
53451
|
+
file: "joinsplit",
|
|
53452
|
+
template: "JoinSplit",
|
|
53453
|
+
pubs: ["merkleRoot", "boundParamsHash", "nullifiers", "commitmentsOut"],
|
|
53454
|
+
params: [10, 2, 16]
|
|
53455
|
+
},
|
|
53456
|
+
joinsplit_10x3_16: {
|
|
53457
|
+
file: "joinsplit",
|
|
53458
|
+
template: "JoinSplit",
|
|
53459
|
+
pubs: ["merkleRoot", "boundParamsHash", "nullifiers", "commitmentsOut"],
|
|
53460
|
+
params: [10, 3, 16]
|
|
53335
53461
|
}
|
|
53336
53462
|
};
|
|
53337
53463
|
var registry = {};
|
|
@@ -53347,7 +53473,7 @@ var SUPPORTED_CIRCUITS = Object.keys(CIRCUIT_REGISTRY);
|
|
|
53347
53473
|
function getCircuitConfig(inputs, outputs) {
|
|
53348
53474
|
return CIRCUIT_REGISTRY[`${inputs}x${outputs}`];
|
|
53349
53475
|
}
|
|
53350
|
-
var MAX_ARTIFACT_CACHE_ENTRIES =
|
|
53476
|
+
var MAX_ARTIFACT_CACHE_ENTRIES = 16;
|
|
53351
53477
|
var artifactCache = /* @__PURE__ */ new Map();
|
|
53352
53478
|
function selectCircuit(inputs, outputs) {
|
|
53353
53479
|
const config22 = getCircuitConfig(inputs, outputs);
|
|
@@ -57317,54 +57443,60 @@ function UnlinkProvider({
|
|
|
57317
57443
|
throw err;
|
|
57318
57444
|
}
|
|
57319
57445
|
}, []);
|
|
57320
|
-
const send = useCallback(
|
|
57321
|
-
|
|
57322
|
-
|
|
57323
|
-
|
|
57324
|
-
|
|
57325
|
-
|
|
57326
|
-
|
|
57327
|
-
...prev2,
|
|
57328
|
-
busy: true,
|
|
57329
|
-
status: params.length > 1 ? `Sending (${params.length} transfers)...` : "Sending..."
|
|
57330
|
-
}));
|
|
57331
|
-
try {
|
|
57332
|
-
const result = await wallet.transfer({
|
|
57333
|
-
transfers: params.map((t) => ({
|
|
57334
|
-
token: t.token,
|
|
57335
|
-
recipient: t.recipient,
|
|
57336
|
-
amount: t.amount
|
|
57337
|
-
}))
|
|
57338
|
-
});
|
|
57339
|
-
setState((prev2) => ({
|
|
57340
|
-
...prev2,
|
|
57341
|
-
busy: false,
|
|
57342
|
-
status: params.length > 1 ? `Transfer submitted (${params.length} transfers)` : "Transfer submitted",
|
|
57343
|
-
pendingTransfers: [
|
|
57344
|
-
...prev2.pendingTransfers,
|
|
57345
|
-
...params.map((t, i) => ({
|
|
57346
|
-
txId: `${result.relayId}-${i}`,
|
|
57347
|
-
status: "pending",
|
|
57348
|
-
chainId: wallet.chainId,
|
|
57349
|
-
token: t.token,
|
|
57350
|
-
amount: t.amount,
|
|
57351
|
-
recipient: t.recipient,
|
|
57352
|
-
startedAt: Date.now()
|
|
57353
|
-
}))
|
|
57354
|
-
],
|
|
57355
|
-
error: null
|
|
57356
|
-
}));
|
|
57357
|
-
return result;
|
|
57358
|
-
} catch (err) {
|
|
57446
|
+
const send = useCallback(
|
|
57447
|
+
async (params, overrides) => {
|
|
57448
|
+
const wallet = walletRef.current;
|
|
57449
|
+
if (!wallet) throw new Error("SDK not initialized");
|
|
57450
|
+
if (params.length === 0) {
|
|
57451
|
+
throw new Error("At least one transfer is required");
|
|
57452
|
+
}
|
|
57359
57453
|
setState((prev2) => ({
|
|
57360
57454
|
...prev2,
|
|
57361
|
-
busy:
|
|
57362
|
-
status:
|
|
57363
|
-
error: createUnlinkError(err, "send")
|
|
57455
|
+
busy: true,
|
|
57456
|
+
status: params.length > 1 ? `Sending (${params.length} transfers)...` : "Sending..."
|
|
57364
57457
|
}));
|
|
57365
|
-
|
|
57366
|
-
|
|
57367
|
-
|
|
57458
|
+
try {
|
|
57459
|
+
const result = await wallet.transfer(
|
|
57460
|
+
{
|
|
57461
|
+
transfers: params.map((t) => ({
|
|
57462
|
+
token: t.token,
|
|
57463
|
+
recipient: t.recipient,
|
|
57464
|
+
amount: t.amount
|
|
57465
|
+
}))
|
|
57466
|
+
},
|
|
57467
|
+
overrides
|
|
57468
|
+
);
|
|
57469
|
+
setState((prev2) => ({
|
|
57470
|
+
...prev2,
|
|
57471
|
+
busy: false,
|
|
57472
|
+
status: params.length > 1 ? `Transfer submitted (${params.length} transfers)` : "Transfer submitted",
|
|
57473
|
+
pendingTransfers: [
|
|
57474
|
+
...prev2.pendingTransfers,
|
|
57475
|
+
...params.map((t, i) => ({
|
|
57476
|
+
txId: `${result.relayId}-${i}`,
|
|
57477
|
+
status: "pending",
|
|
57478
|
+
chainId: wallet.chainId,
|
|
57479
|
+
token: t.token,
|
|
57480
|
+
amount: t.amount,
|
|
57481
|
+
recipient: t.recipient,
|
|
57482
|
+
startedAt: Date.now()
|
|
57483
|
+
}))
|
|
57484
|
+
],
|
|
57485
|
+
error: null
|
|
57486
|
+
}));
|
|
57487
|
+
return result;
|
|
57488
|
+
} catch (err) {
|
|
57489
|
+
setState((prev2) => ({
|
|
57490
|
+
...prev2,
|
|
57491
|
+
busy: false,
|
|
57492
|
+
status: `Error: ${err instanceof Error ? err.message : "Unknown"}`,
|
|
57493
|
+
error: createUnlinkError(err, "send")
|
|
57494
|
+
}));
|
|
57495
|
+
throw err;
|
|
57496
|
+
}
|
|
57497
|
+
},
|
|
57498
|
+
[]
|
|
57499
|
+
);
|
|
57368
57500
|
const planTransfer = useCallback(async (params) => {
|
|
57369
57501
|
const wallet = walletRef.current;
|
|
57370
57502
|
if (!wallet) throw new Error("SDK not initialized");
|
|
@@ -57376,33 +57508,36 @@ function UnlinkProvider({
|
|
|
57376
57508
|
}))
|
|
57377
57509
|
});
|
|
57378
57510
|
}, []);
|
|
57379
|
-
const executeTransfer = useCallback(
|
|
57380
|
-
|
|
57381
|
-
|
|
57382
|
-
|
|
57383
|
-
...prev2,
|
|
57384
|
-
busy: true,
|
|
57385
|
-
status: "Executing transfer..."
|
|
57386
|
-
}));
|
|
57387
|
-
try {
|
|
57388
|
-
const result = await wallet.executeTransfer(plans);
|
|
57389
|
-
setState((prev2) => ({
|
|
57390
|
-
...prev2,
|
|
57391
|
-
busy: false,
|
|
57392
|
-
status: "Transfer executed",
|
|
57393
|
-
error: null
|
|
57394
|
-
}));
|
|
57395
|
-
return result;
|
|
57396
|
-
} catch (err) {
|
|
57511
|
+
const executeTransfer = useCallback(
|
|
57512
|
+
async (plans, overrides) => {
|
|
57513
|
+
const wallet = walletRef.current;
|
|
57514
|
+
if (!wallet) throw new Error("SDK not initialized");
|
|
57397
57515
|
setState((prev2) => ({
|
|
57398
57516
|
...prev2,
|
|
57399
|
-
busy:
|
|
57400
|
-
status:
|
|
57401
|
-
error: createUnlinkError(err, "executeTransfer")
|
|
57517
|
+
busy: true,
|
|
57518
|
+
status: "Executing transfer..."
|
|
57402
57519
|
}));
|
|
57403
|
-
|
|
57404
|
-
|
|
57405
|
-
|
|
57520
|
+
try {
|
|
57521
|
+
const result = await wallet.executeTransfer(plans, overrides);
|
|
57522
|
+
setState((prev2) => ({
|
|
57523
|
+
...prev2,
|
|
57524
|
+
busy: false,
|
|
57525
|
+
status: "Transfer executed",
|
|
57526
|
+
error: null
|
|
57527
|
+
}));
|
|
57528
|
+
return result;
|
|
57529
|
+
} catch (err) {
|
|
57530
|
+
setState((prev2) => ({
|
|
57531
|
+
...prev2,
|
|
57532
|
+
busy: false,
|
|
57533
|
+
status: `Error: ${err instanceof Error ? err.message : "Unknown"}`,
|
|
57534
|
+
error: createUnlinkError(err, "executeTransfer")
|
|
57535
|
+
}));
|
|
57536
|
+
throw err;
|
|
57537
|
+
}
|
|
57538
|
+
},
|
|
57539
|
+
[]
|
|
57540
|
+
);
|
|
57406
57541
|
const requestDeposit = useCallback(
|
|
57407
57542
|
async (params) => {
|
|
57408
57543
|
const wallet = walletRef.current;
|
|
@@ -57459,7 +57594,7 @@ function UnlinkProvider({
|
|
|
57459
57594
|
[]
|
|
57460
57595
|
);
|
|
57461
57596
|
const requestWithdraw = useCallback(
|
|
57462
|
-
async (params) => {
|
|
57597
|
+
async (params, overrides) => {
|
|
57463
57598
|
const wallet = walletRef.current;
|
|
57464
57599
|
if (!wallet) throw new Error("SDK not initialized");
|
|
57465
57600
|
if (params.length === 0) {
|
|
@@ -57471,13 +57606,16 @@ function UnlinkProvider({
|
|
|
57471
57606
|
status: params.length > 1 ? `Processing withdrawal (${params.length} tokens)...` : "Withdrawing..."
|
|
57472
57607
|
}));
|
|
57473
57608
|
try {
|
|
57474
|
-
const result = await wallet.withdraw(
|
|
57475
|
-
|
|
57476
|
-
|
|
57477
|
-
|
|
57478
|
-
|
|
57479
|
-
|
|
57480
|
-
|
|
57609
|
+
const result = await wallet.withdraw(
|
|
57610
|
+
{
|
|
57611
|
+
withdrawals: params.map((w) => ({
|
|
57612
|
+
token: w.token,
|
|
57613
|
+
amount: w.amount,
|
|
57614
|
+
recipient: w.recipient
|
|
57615
|
+
}))
|
|
57616
|
+
},
|
|
57617
|
+
overrides
|
|
57618
|
+
);
|
|
57481
57619
|
setState((prev2) => ({
|
|
57482
57620
|
...prev2,
|
|
57483
57621
|
busy: false,
|
|
@@ -57553,33 +57691,36 @@ function UnlinkProvider({
|
|
|
57553
57691
|
},
|
|
57554
57692
|
[]
|
|
57555
57693
|
);
|
|
57556
|
-
const executeWithdraw = useCallback(
|
|
57557
|
-
|
|
57558
|
-
|
|
57559
|
-
|
|
57560
|
-
...prev2,
|
|
57561
|
-
busy: true,
|
|
57562
|
-
status: plans.length > 1 ? `Executing withdrawal (${plans.length} tokens)...` : "Executing withdrawal..."
|
|
57563
|
-
}));
|
|
57564
|
-
try {
|
|
57565
|
-
const result = await wallet.executeWithdraw(plans);
|
|
57566
|
-
setState((prev2) => ({
|
|
57567
|
-
...prev2,
|
|
57568
|
-
busy: false,
|
|
57569
|
-
status: plans.length > 1 ? `Withdrawal executed (${plans.length} tokens)` : "Withdrawal executed",
|
|
57570
|
-
error: null
|
|
57571
|
-
}));
|
|
57572
|
-
return result;
|
|
57573
|
-
} catch (err) {
|
|
57694
|
+
const executeWithdraw = useCallback(
|
|
57695
|
+
async (plans, overrides) => {
|
|
57696
|
+
const wallet = walletRef.current;
|
|
57697
|
+
if (!wallet) throw new Error("SDK not initialized");
|
|
57574
57698
|
setState((prev2) => ({
|
|
57575
57699
|
...prev2,
|
|
57576
|
-
busy:
|
|
57577
|
-
status:
|
|
57578
|
-
error: createUnlinkError(err, "executeWithdraw")
|
|
57700
|
+
busy: true,
|
|
57701
|
+
status: plans.length > 1 ? `Executing withdrawal (${plans.length} tokens)...` : "Executing withdrawal..."
|
|
57579
57702
|
}));
|
|
57580
|
-
|
|
57581
|
-
|
|
57582
|
-
|
|
57703
|
+
try {
|
|
57704
|
+
const result = await wallet.executeWithdraw(plans, overrides);
|
|
57705
|
+
setState((prev2) => ({
|
|
57706
|
+
...prev2,
|
|
57707
|
+
busy: false,
|
|
57708
|
+
status: plans.length > 1 ? `Withdrawal executed (${plans.length} tokens)` : "Withdrawal executed",
|
|
57709
|
+
error: null
|
|
57710
|
+
}));
|
|
57711
|
+
return result;
|
|
57712
|
+
} catch (err) {
|
|
57713
|
+
setState((prev2) => ({
|
|
57714
|
+
...prev2,
|
|
57715
|
+
busy: false,
|
|
57716
|
+
status: `Error: ${err instanceof Error ? err.message : "Unknown"}`,
|
|
57717
|
+
error: createUnlinkError(err, "executeWithdraw")
|
|
57718
|
+
}));
|
|
57719
|
+
throw err;
|
|
57720
|
+
}
|
|
57721
|
+
},
|
|
57722
|
+
[]
|
|
57723
|
+
);
|
|
57583
57724
|
const createBurner = useCallback(async (index) => {
|
|
57584
57725
|
const wallet = walletRef.current;
|
|
57585
57726
|
if (!wallet) throw new Error("SDK not initialized");
|
|
@@ -58059,7 +58200,7 @@ function useOperationMutation(operation) {
|
|
|
58059
58200
|
const [isError2, setIsError] = useState4(false);
|
|
58060
58201
|
const pendingRef = useRef3(false);
|
|
58061
58202
|
const generationRef = useRef3(0);
|
|
58062
|
-
const
|
|
58203
|
+
const execute = useCallback4(
|
|
58063
58204
|
async (input) => {
|
|
58064
58205
|
if (pendingRef.current) {
|
|
58065
58206
|
throw new Error("Operation already in progress");
|
|
@@ -58102,7 +58243,7 @@ function useOperationMutation(operation) {
|
|
|
58102
58243
|
setIsSuccess(false);
|
|
58103
58244
|
setIsError(false);
|
|
58104
58245
|
}, []);
|
|
58105
|
-
return {
|
|
58246
|
+
return { execute, data, isPending, isSuccess, isError: isError2, error, reset };
|
|
58106
58247
|
}
|
|
58107
58248
|
|
|
58108
58249
|
// src/useDeposit.ts
|
|
@@ -58117,19 +58258,22 @@ function useDeposit() {
|
|
|
58117
58258
|
|
|
58118
58259
|
// src/useTransfer.ts
|
|
58119
58260
|
import { useCallback as useCallback6 } from "react";
|
|
58120
|
-
function useTransfer() {
|
|
58261
|
+
function useTransfer(overrides) {
|
|
58121
58262
|
const { send } = useUnlink();
|
|
58122
|
-
const op = useCallback6(
|
|
58263
|
+
const op = useCallback6(
|
|
58264
|
+
(params) => send(params, overrides),
|
|
58265
|
+
[send, overrides]
|
|
58266
|
+
);
|
|
58123
58267
|
return useOperationMutation(op);
|
|
58124
58268
|
}
|
|
58125
58269
|
|
|
58126
58270
|
// src/useWithdraw.ts
|
|
58127
58271
|
import { useCallback as useCallback7 } from "react";
|
|
58128
|
-
function useWithdraw() {
|
|
58272
|
+
function useWithdraw(overrides) {
|
|
58129
58273
|
const { requestWithdraw } = useUnlink();
|
|
58130
58274
|
const op = useCallback7(
|
|
58131
|
-
(params) => requestWithdraw(params),
|
|
58132
|
-
[requestWithdraw]
|
|
58275
|
+
(params) => requestWithdraw(params, overrides),
|
|
58276
|
+
[requestWithdraw, overrides]
|
|
58133
58277
|
);
|
|
58134
58278
|
return useOperationMutation(op);
|
|
58135
58279
|
}
|