@unlink-xyz/react 0.1.3-canary.d1872f5 → 0.1.3-canary.d8d7aa3

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.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 = 127;
9045
+ var LIMIT = 130;
9046
9046
  var ALL_CHAINS = "ffffffffffffffff";
9047
- var PREFIX = "0zk";
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 0zk1... format): ${err instanceof Error ? err.message : "unknown error"}`
9165
+ `Invalid ZK address (expected unlink1... format): ${err instanceof Error ? err.message : "unknown error"}`
9166
9166
  );
9167
9167
  }
9168
9168
  }
@@ -35871,63 +35871,79 @@ var Runtime = {
35871
35871
  }
35872
35872
  };
35873
35873
  var CONFIG_URL = "https://config.unlink.xyz/networks.json";
35874
- function parseRequiredString(env22, field, value) {
35874
+ function parseRequiredString(chain2, field, value) {
35875
35875
  if (typeof value !== "string" || value.trim().length === 0) {
35876
35876
  throw new InitializationError(
35877
- `Invalid SDK config for ${env22}: ${field} must be a non-empty string`
35877
+ `Invalid SDK config for ${chain2}: ${field} must be a non-empty string`
35878
35878
  );
35879
35879
  }
35880
35880
  return value.trim();
35881
35881
  }
35882
- function parseOptionalString(env22, field, value) {
35882
+ function parseOptionalString(chain2, field, value) {
35883
35883
  if (value === void 0) return void 0;
35884
35884
  if (typeof value !== "string" || value.trim().length === 0) {
35885
35885
  throw new InitializationError(
35886
- `Invalid SDK config for ${env22}: ${field} must be a non-empty string when provided`
35886
+ `Invalid SDK config for ${chain2}: ${field} must be a non-empty string when provided`
35887
35887
  );
35888
35888
  }
35889
35889
  return value.trim();
35890
35890
  }
35891
- function parseEnvironmentConfig(env22, value) {
35891
+ function parseRequiredChainId(chain2, value) {
35892
+ if (typeof value !== "number" || !Number.isInteger(value) || value <= 0) {
35893
+ throw new InitializationError(
35894
+ `Invalid SDK config for ${chain2}: chainId must be a positive integer`
35895
+ );
35896
+ }
35897
+ return value;
35898
+ }
35899
+ function parseChainConfig(chain2, value) {
35892
35900
  if (value === null || typeof value !== "object" || Array.isArray(value)) {
35893
35901
  throw new InitializationError(
35894
- `Invalid SDK config for ${env22}: expected object`
35902
+ `Invalid SDK config for ${chain2}: expected object`
35895
35903
  );
35896
35904
  }
35897
35905
  const raw = value;
35906
+ const chainId = parseRequiredChainId(chain2, raw.chainId);
35898
35907
  const gatewayUrl = parseRequiredString(
35899
- env22,
35908
+ chain2,
35900
35909
  "gatewayUrl",
35901
35910
  raw.gatewayUrl
35902
35911
  ).replace(/\/+$/, "");
35903
- const poolAddress = parseRequiredString(env22, "poolAddress", raw.poolAddress);
35912
+ const poolAddress = parseRequiredString(
35913
+ chain2,
35914
+ "poolAddress",
35915
+ raw.poolAddress
35916
+ );
35904
35917
  const artifactVersion = parseRequiredString(
35905
- env22,
35918
+ chain2,
35906
35919
  "artifactVersion",
35907
35920
  raw.artifactVersion
35908
35921
  ).replace(/^\/+|\/+$/g, "");
35909
35922
  const artifactBaseUrl = parseOptionalString(
35910
- env22,
35923
+ chain2,
35911
35924
  "artifactBaseUrl",
35912
35925
  raw.artifactBaseUrl
35913
35926
  )?.replace(/\/+$/, "");
35914
35927
  return {
35928
+ chainId,
35915
35929
  gatewayUrl,
35916
35930
  poolAddress,
35917
35931
  artifactVersion,
35918
35932
  ...artifactBaseUrl !== void 0 ? { artifactBaseUrl } : { artifactBaseUrl: DEFAULT_ARTIFACT_BASE_URL }
35919
35933
  };
35920
35934
  }
35921
- async function fetchEnvironmentConfig(env22) {
35935
+ async function fetchChainConfig(chain2) {
35922
35936
  const res = await fetch(CONFIG_URL);
35923
35937
  if (!res.ok) {
35924
35938
  throw new InitializationError(`Failed to fetch SDK config: ${res.status}`);
35925
35939
  }
35926
35940
  const config22 = await res.json();
35927
- if (!config22[env22]) {
35928
- throw new InitializationError(`Unknown environment: ${env22}`);
35941
+ if (!config22[chain2]) {
35942
+ throw new InitializationError(
35943
+ `Unknown chain: "${chain2}". Supported chains: ${Object.keys(config22).join(", ")}`
35944
+ );
35929
35945
  }
35930
- return parseEnvironmentConfig(env22, config22[env22]);
35946
+ return parseChainConfig(chain2, config22[chain2]);
35931
35947
  }
35932
35948
  function createServiceConfig(gatewayUrl) {
35933
35949
  const baseUrl = gatewayUrl.replace(/\/+$/, "");
@@ -53316,6 +53332,114 @@ var circuits_default = {
53316
53332
  template: "JoinSplit",
53317
53333
  pubs: ["merkleRoot", "boundParamsHash", "nullifiers", "commitmentsOut"],
53318
53334
  params: [5, 2, 16]
53335
+ },
53336
+ joinsplit_1x3_16: {
53337
+ file: "joinsplit",
53338
+ template: "JoinSplit",
53339
+ pubs: ["merkleRoot", "boundParamsHash", "nullifiers", "commitmentsOut"],
53340
+ params: [1, 3, 16]
53341
+ },
53342
+ joinsplit_4x3_16: {
53343
+ file: "joinsplit",
53344
+ template: "JoinSplit",
53345
+ pubs: ["merkleRoot", "boundParamsHash", "nullifiers", "commitmentsOut"],
53346
+ params: [4, 3, 16]
53347
+ },
53348
+ joinsplit_5x3_16: {
53349
+ file: "joinsplit",
53350
+ template: "JoinSplit",
53351
+ pubs: ["merkleRoot", "boundParamsHash", "nullifiers", "commitmentsOut"],
53352
+ params: [5, 3, 16]
53353
+ },
53354
+ joinsplit_6x1_16: {
53355
+ file: "joinsplit",
53356
+ template: "JoinSplit",
53357
+ pubs: ["merkleRoot", "boundParamsHash", "nullifiers", "commitmentsOut"],
53358
+ params: [6, 1, 16]
53359
+ },
53360
+ joinsplit_6x2_16: {
53361
+ file: "joinsplit",
53362
+ template: "JoinSplit",
53363
+ pubs: ["merkleRoot", "boundParamsHash", "nullifiers", "commitmentsOut"],
53364
+ params: [6, 2, 16]
53365
+ },
53366
+ joinsplit_6x3_16: {
53367
+ file: "joinsplit",
53368
+ template: "JoinSplit",
53369
+ pubs: ["merkleRoot", "boundParamsHash", "nullifiers", "commitmentsOut"],
53370
+ params: [6, 3, 16]
53371
+ },
53372
+ joinsplit_7x1_16: {
53373
+ file: "joinsplit",
53374
+ template: "JoinSplit",
53375
+ pubs: ["merkleRoot", "boundParamsHash", "nullifiers", "commitmentsOut"],
53376
+ params: [7, 1, 16]
53377
+ },
53378
+ joinsplit_7x2_16: {
53379
+ file: "joinsplit",
53380
+ template: "JoinSplit",
53381
+ pubs: ["merkleRoot", "boundParamsHash", "nullifiers", "commitmentsOut"],
53382
+ params: [7, 2, 16]
53383
+ },
53384
+ joinsplit_7x3_16: {
53385
+ file: "joinsplit",
53386
+ template: "JoinSplit",
53387
+ pubs: ["merkleRoot", "boundParamsHash", "nullifiers", "commitmentsOut"],
53388
+ params: [7, 3, 16]
53389
+ },
53390
+ joinsplit_8x1_16: {
53391
+ file: "joinsplit",
53392
+ template: "JoinSplit",
53393
+ pubs: ["merkleRoot", "boundParamsHash", "nullifiers", "commitmentsOut"],
53394
+ params: [8, 1, 16]
53395
+ },
53396
+ joinsplit_8x2_16: {
53397
+ file: "joinsplit",
53398
+ template: "JoinSplit",
53399
+ pubs: ["merkleRoot", "boundParamsHash", "nullifiers", "commitmentsOut"],
53400
+ params: [8, 2, 16]
53401
+ },
53402
+ joinsplit_8x3_16: {
53403
+ file: "joinsplit",
53404
+ template: "JoinSplit",
53405
+ pubs: ["merkleRoot", "boundParamsHash", "nullifiers", "commitmentsOut"],
53406
+ params: [8, 3, 16]
53407
+ },
53408
+ joinsplit_9x1_16: {
53409
+ file: "joinsplit",
53410
+ template: "JoinSplit",
53411
+ pubs: ["merkleRoot", "boundParamsHash", "nullifiers", "commitmentsOut"],
53412
+ params: [9, 1, 16]
53413
+ },
53414
+ joinsplit_9x2_16: {
53415
+ file: "joinsplit",
53416
+ template: "JoinSplit",
53417
+ pubs: ["merkleRoot", "boundParamsHash", "nullifiers", "commitmentsOut"],
53418
+ params: [9, 2, 16]
53419
+ },
53420
+ joinsplit_9x3_16: {
53421
+ file: "joinsplit",
53422
+ template: "JoinSplit",
53423
+ pubs: ["merkleRoot", "boundParamsHash", "nullifiers", "commitmentsOut"],
53424
+ params: [9, 3, 16]
53425
+ },
53426
+ joinsplit_10x1_16: {
53427
+ file: "joinsplit",
53428
+ template: "JoinSplit",
53429
+ pubs: ["merkleRoot", "boundParamsHash", "nullifiers", "commitmentsOut"],
53430
+ params: [10, 1, 16]
53431
+ },
53432
+ joinsplit_10x2_16: {
53433
+ file: "joinsplit",
53434
+ template: "JoinSplit",
53435
+ pubs: ["merkleRoot", "boundParamsHash", "nullifiers", "commitmentsOut"],
53436
+ params: [10, 2, 16]
53437
+ },
53438
+ joinsplit_10x3_16: {
53439
+ file: "joinsplit",
53440
+ template: "JoinSplit",
53441
+ pubs: ["merkleRoot", "boundParamsHash", "nullifiers", "commitmentsOut"],
53442
+ params: [10, 3, 16]
53319
53443
  }
53320
53444
  };
53321
53445
  var registry = {};
@@ -53331,7 +53455,7 @@ var SUPPORTED_CIRCUITS = Object.keys(CIRCUIT_REGISTRY);
53331
53455
  function getCircuitConfig(inputs, outputs) {
53332
53456
  return CIRCUIT_REGISTRY[`${inputs}x${outputs}`];
53333
53457
  }
53334
- var MAX_ARTIFACT_CACHE_ENTRIES = 8;
53458
+ var MAX_ARTIFACT_CACHE_ENTRIES = 16;
53335
53459
  var artifactCache = /* @__PURE__ */ new Map();
53336
53460
  function selectCircuit(inputs, outputs) {
53337
53461
  const config22 = getCircuitConfig(inputs, outputs);
@@ -55640,6 +55764,16 @@ function createAdapterService(deps) {
55640
55764
  const reshieldSpecs = params.reshields.map(
55641
55765
  (reshield, i) => normalizeReshieldSpec(reshield, i)
55642
55766
  );
55767
+ const seenReshieldTokens = /* @__PURE__ */ new Set();
55768
+ for (const r2 of reshieldSpecs) {
55769
+ const lower = r2.token.toLowerCase();
55770
+ if (seenReshieldTokens.has(lower)) {
55771
+ throw new AdapterError(
55772
+ `duplicate reshield token ${r2.token}; each reshield must target a unique token`
55773
+ );
55774
+ }
55775
+ seenReshieldTokens.add(lower);
55776
+ }
55643
55777
  const account = overrides?.account ?? await deps.requireActiveAccount();
55644
55778
  const signer = overrides?.signer ?? deps.requireSigner(account);
55645
55779
  const nowSeconds = BigInt(Math.floor(nowImpl() / 1e3));
@@ -56536,34 +56670,37 @@ var UnlinkWallet = class _UnlinkWallet {
56536
56670
  * Create a new UnlinkWallet instance.
56537
56671
  *
56538
56672
  * Handles all initialization internally:
56539
- * - Resolves environment config (if using `environment` instead of explicit URLs)
56673
+ * - Resolves chain config (if using `chain` instead of explicit URLs)
56540
56674
  * - Auto-detects storage (IndexedDB in browser) and rng (crypto.getRandomValues)
56541
56675
  * - Runs schema migration via `initCore()`
56542
56676
  * - Creates the internal SDK
56543
56677
  */
56544
56678
  static async create(config22) {
56679
+ let chainId;
56545
56680
  let gatewayUrl;
56546
56681
  let poolAddress;
56547
56682
  let proverConfig = config22.prover;
56548
- if ("gatewayUrl" in config22) {
56683
+ if ("chain" in config22) {
56684
+ const chainConfig = await fetchChainConfig(config22.chain);
56685
+ chainId = chainConfig.chainId;
56686
+ gatewayUrl = chainConfig.gatewayUrl;
56687
+ poolAddress = config22.poolAddress ?? chainConfig.poolAddress;
56688
+ proverConfig = {
56689
+ artifactSource: {
56690
+ baseUrl: config22.prover?.artifactSource?.baseUrl ?? chainConfig.artifactBaseUrl,
56691
+ version: config22.prover?.artifactSource?.version ?? chainConfig.artifactVersion,
56692
+ preferLocalFiles: config22.prover?.artifactSource?.preferLocalFiles
56693
+ }
56694
+ };
56695
+ } else {
56696
+ chainId = config22.chainId;
56549
56697
  gatewayUrl = config22.gatewayUrl;
56550
56698
  poolAddress = config22.poolAddress;
56551
56699
  if (typeof window !== "undefined" && !config22.prover?.artifactSource?.version) {
56552
56700
  throw new InitializationError(
56553
- "prover.artifactSource.version is required in browser when using explicit gatewayUrl mode. Use environment mode or provide a pinned artifact version."
56701
+ "prover.artifactSource.version is required in browser when using explicit gatewayUrl mode. Use chain mode or provide a pinned artifact version."
56554
56702
  );
56555
56703
  }
56556
- } else {
56557
- const envConfig = await fetchEnvironmentConfig(config22.environment);
56558
- gatewayUrl = envConfig.gatewayUrl;
56559
- poolAddress = config22.poolAddress ?? envConfig.poolAddress;
56560
- proverConfig = {
56561
- artifactSource: {
56562
- baseUrl: config22.prover?.artifactSource?.baseUrl ?? envConfig.artifactBaseUrl,
56563
- version: config22.prover?.artifactSource?.version ?? envConfig.artifactVersion,
56564
- preferLocalFiles: config22.prover?.artifactSource?.preferLocalFiles
56565
- }
56566
- };
56567
56704
  }
56568
56705
  const storage = config22.storage ?? detectStorage();
56569
56706
  const rng = config22.rng ?? defaultRng;
@@ -56572,14 +56709,14 @@ var UnlinkWallet = class _UnlinkWallet {
56572
56709
  const sdk = createWalletSDK(
56573
56710
  { core, fetch: fetchImpl },
56574
56711
  {
56575
- chainId: config22.chainId,
56712
+ chainId,
56576
56713
  gatewayUrl,
56577
56714
  chainRpcUrl: config22.chainRpcUrl,
56578
56715
  prover: proverConfig,
56579
56716
  autoSync: config22.autoSync
56580
56717
  }
56581
56718
  );
56582
- return new _UnlinkWallet(sdk, config22.chainId, poolAddress);
56719
+ return new _UnlinkWallet(sdk, chainId, poolAddress);
56583
56720
  }
56584
56721
  // ===== Seed Lifecycle =====
56585
56722
  /** Seed management (create, import, export, delete mnemonic). */
@@ -56935,8 +57072,10 @@ var initialState = {
56935
57072
  accounts: [],
56936
57073
  activeAccount: null,
56937
57074
  activeAccountIndex: null,
57075
+ chainId: null,
56938
57076
  notes: [],
56939
57077
  balances: {},
57078
+ burners: [],
56940
57079
  pendingDeposits: [],
56941
57080
  pendingTransfers: [],
56942
57081
  pendingWithdrawals: [],
@@ -56954,14 +57093,15 @@ function convertNotes(noteRecords) {
56954
57093
  }
56955
57094
  function UnlinkProvider({
56956
57095
  children,
56957
- chainId,
56958
57096
  poolAddress,
56959
57097
  syncInterval = 5e3,
56960
57098
  autoSync = true,
56961
- gatewayUrl,
56962
- environment,
56963
- prover
57099
+ prover,
57100
+ ...configProps
56964
57101
  }) {
57102
+ const chain2 = "chain" in configProps ? configProps.chain : void 0;
57103
+ const chainId = "chainId" in configProps ? configProps.chainId : void 0;
57104
+ const gatewayUrl = "gatewayUrl" in configProps ? configProps.gatewayUrl : void 0;
56965
57105
  const [state, setState] = useState(initialState);
56966
57106
  const walletRef = useRef(null);
56967
57107
  const proverKey = JSON.stringify(prover ?? null);
@@ -56991,13 +57131,13 @@ function UnlinkProvider({
56991
57131
  }
56992
57132
  }, []);
56993
57133
  useEffect(() => {
56994
- if (!gatewayUrl && !environment) {
57134
+ if (!chain2 && !gatewayUrl) {
56995
57135
  const configError = new ValidationError(
56996
- "Either gatewayUrl or environment is required"
57136
+ "Either chain or gatewayUrl is required"
56997
57137
  );
56998
57138
  setState((prev2) => ({
56999
57139
  ...prev2,
57000
- status: "Error: Either gatewayUrl or environment is required",
57140
+ status: "Error: Either chain or gatewayUrl is required",
57001
57141
  error: createUnlinkError(configError, "init")
57002
57142
  }));
57003
57143
  return;
@@ -57011,14 +57151,13 @@ function UnlinkProvider({
57011
57151
  status: "Initializing SDK..."
57012
57152
  }));
57013
57153
  const wallet = await UnlinkWallet.create(
57014
- gatewayUrl ? {
57015
- chainId,
57016
- gatewayUrl,
57154
+ chain2 ? {
57155
+ chain: chain2,
57017
57156
  poolAddress,
57018
57157
  ...prover ? { prover } : {}
57019
57158
  } : {
57020
57159
  chainId,
57021
- environment,
57160
+ gatewayUrl,
57022
57161
  poolAddress,
57023
57162
  ...prover ? { prover } : {}
57024
57163
  }
@@ -57059,6 +57198,7 @@ function UnlinkProvider({
57059
57198
  accounts,
57060
57199
  activeAccount,
57061
57200
  activeAccountIndex,
57201
+ chainId: wallet.chainId,
57062
57202
  notes,
57063
57203
  balances,
57064
57204
  ready: true,
@@ -57069,7 +57209,7 @@ function UnlinkProvider({
57069
57209
  wallet.startAutoSync(syncInterval);
57070
57210
  }
57071
57211
  unsubscribe = wallet.on((event) => {
57072
- if (event.type === "notes-updated" && event.chainId === chainId) {
57212
+ if (event.type === "notes-updated" && event.chainId === wallet.chainId) {
57073
57213
  setState((prev2) => ({ ...prev2, syncError: null }));
57074
57214
  void refreshState(wallet);
57075
57215
  }
@@ -57103,13 +57243,13 @@ function UnlinkProvider({
57103
57243
  walletRef.current?.stopAutoSync();
57104
57244
  };
57105
57245
  }, [
57246
+ chain2,
57106
57247
  chainId,
57107
57248
  autoSync,
57108
57249
  syncInterval,
57109
57250
  refreshState,
57110
57251
  refreshAccounts,
57111
57252
  gatewayUrl,
57112
- environment,
57113
57253
  poolAddress,
57114
57254
  proverKey
57115
57255
  ]);
@@ -57157,6 +57297,7 @@ function UnlinkProvider({
57157
57297
  accounts,
57158
57298
  activeAccount,
57159
57299
  activeAccountIndex,
57300
+ burners: [],
57160
57301
  busy: false,
57161
57302
  status: accounts.length > 0 ? "Wallet imported" : "Wallet imported - create an account",
57162
57303
  syncError: null,
@@ -57191,6 +57332,7 @@ function UnlinkProvider({
57191
57332
  activeAccountIndex: null,
57192
57333
  notes: [],
57193
57334
  balances: {},
57335
+ burners: [],
57194
57336
  busy: false,
57195
57337
  status: "Wallet cleared",
57196
57338
  syncError: null,
@@ -57283,54 +57425,60 @@ function UnlinkProvider({
57283
57425
  throw err;
57284
57426
  }
57285
57427
  }, []);
57286
- const send = useCallback(async (params) => {
57287
- const wallet = walletRef.current;
57288
- if (!wallet) throw new Error("SDK not initialized");
57289
- if (params.length === 0) {
57290
- throw new Error("At least one transfer is required");
57291
- }
57292
- setState((prev2) => ({
57293
- ...prev2,
57294
- busy: true,
57295
- status: params.length > 1 ? `Sending (${params.length} transfers)...` : "Sending..."
57296
- }));
57297
- try {
57298
- const result = await wallet.transfer({
57299
- transfers: params.map((t) => ({
57300
- token: t.token,
57301
- recipient: t.recipient,
57302
- amount: t.amount
57303
- }))
57304
- });
57305
- setState((prev2) => ({
57306
- ...prev2,
57307
- busy: false,
57308
- status: params.length > 1 ? `Transfer submitted (${params.length} transfers)` : "Transfer submitted",
57309
- pendingTransfers: [
57310
- ...prev2.pendingTransfers,
57311
- ...params.map((t, i) => ({
57312
- txId: `${result.relayId}-${i}`,
57313
- status: "pending",
57314
- chainId: wallet.chainId,
57315
- token: t.token,
57316
- amount: t.amount,
57317
- recipient: t.recipient,
57318
- startedAt: Date.now()
57319
- }))
57320
- ],
57321
- error: null
57322
- }));
57323
- return result;
57324
- } catch (err) {
57428
+ const send = useCallback(
57429
+ async (params, overrides) => {
57430
+ const wallet = walletRef.current;
57431
+ if (!wallet) throw new Error("SDK not initialized");
57432
+ if (params.length === 0) {
57433
+ throw new Error("At least one transfer is required");
57434
+ }
57325
57435
  setState((prev2) => ({
57326
57436
  ...prev2,
57327
- busy: false,
57328
- status: `Error: ${err instanceof Error ? err.message : "Unknown"}`,
57329
- error: createUnlinkError(err, "send")
57437
+ busy: true,
57438
+ status: params.length > 1 ? `Sending (${params.length} transfers)...` : "Sending..."
57330
57439
  }));
57331
- throw err;
57332
- }
57333
- }, []);
57440
+ try {
57441
+ const result = await wallet.transfer(
57442
+ {
57443
+ transfers: params.map((t) => ({
57444
+ token: t.token,
57445
+ recipient: t.recipient,
57446
+ amount: t.amount
57447
+ }))
57448
+ },
57449
+ overrides
57450
+ );
57451
+ setState((prev2) => ({
57452
+ ...prev2,
57453
+ busy: false,
57454
+ status: params.length > 1 ? `Transfer submitted (${params.length} transfers)` : "Transfer submitted",
57455
+ pendingTransfers: [
57456
+ ...prev2.pendingTransfers,
57457
+ ...params.map((t, i) => ({
57458
+ txId: `${result.relayId}-${i}`,
57459
+ status: "pending",
57460
+ chainId: wallet.chainId,
57461
+ token: t.token,
57462
+ amount: t.amount,
57463
+ recipient: t.recipient,
57464
+ startedAt: Date.now()
57465
+ }))
57466
+ ],
57467
+ error: null
57468
+ }));
57469
+ return result;
57470
+ } catch (err) {
57471
+ setState((prev2) => ({
57472
+ ...prev2,
57473
+ busy: false,
57474
+ status: `Error: ${err instanceof Error ? err.message : "Unknown"}`,
57475
+ error: createUnlinkError(err, "send")
57476
+ }));
57477
+ throw err;
57478
+ }
57479
+ },
57480
+ []
57481
+ );
57334
57482
  const planTransfer = useCallback(async (params) => {
57335
57483
  const wallet = walletRef.current;
57336
57484
  if (!wallet) throw new Error("SDK not initialized");
@@ -57342,33 +57490,36 @@ function UnlinkProvider({
57342
57490
  }))
57343
57491
  });
57344
57492
  }, []);
57345
- const executeTransfer = useCallback(async (plans) => {
57346
- const wallet = walletRef.current;
57347
- if (!wallet) throw new Error("SDK not initialized");
57348
- setState((prev2) => ({
57349
- ...prev2,
57350
- busy: true,
57351
- status: "Executing transfer..."
57352
- }));
57353
- try {
57354
- const result = await wallet.executeTransfer(plans);
57355
- setState((prev2) => ({
57356
- ...prev2,
57357
- busy: false,
57358
- status: "Transfer executed",
57359
- error: null
57360
- }));
57361
- return result;
57362
- } catch (err) {
57493
+ const executeTransfer = useCallback(
57494
+ async (plans, overrides) => {
57495
+ const wallet = walletRef.current;
57496
+ if (!wallet) throw new Error("SDK not initialized");
57363
57497
  setState((prev2) => ({
57364
57498
  ...prev2,
57365
- busy: false,
57366
- status: `Error: ${err instanceof Error ? err.message : "Unknown"}`,
57367
- error: createUnlinkError(err, "executeTransfer")
57499
+ busy: true,
57500
+ status: "Executing transfer..."
57368
57501
  }));
57369
- throw err;
57370
- }
57371
- }, []);
57502
+ try {
57503
+ const result = await wallet.executeTransfer(plans, overrides);
57504
+ setState((prev2) => ({
57505
+ ...prev2,
57506
+ busy: false,
57507
+ status: "Transfer executed",
57508
+ error: null
57509
+ }));
57510
+ return result;
57511
+ } catch (err) {
57512
+ setState((prev2) => ({
57513
+ ...prev2,
57514
+ busy: false,
57515
+ status: `Error: ${err instanceof Error ? err.message : "Unknown"}`,
57516
+ error: createUnlinkError(err, "executeTransfer")
57517
+ }));
57518
+ throw err;
57519
+ }
57520
+ },
57521
+ []
57522
+ );
57372
57523
  const requestDeposit = useCallback(
57373
57524
  async (params) => {
57374
57525
  const wallet = walletRef.current;
@@ -57425,7 +57576,7 @@ function UnlinkProvider({
57425
57576
  []
57426
57577
  );
57427
57578
  const requestWithdraw = useCallback(
57428
- async (params) => {
57579
+ async (params, overrides) => {
57429
57580
  const wallet = walletRef.current;
57430
57581
  if (!wallet) throw new Error("SDK not initialized");
57431
57582
  if (params.length === 0) {
@@ -57437,13 +57588,16 @@ function UnlinkProvider({
57437
57588
  status: params.length > 1 ? `Processing withdrawal (${params.length} tokens)...` : "Withdrawing..."
57438
57589
  }));
57439
57590
  try {
57440
- const result = await wallet.withdraw({
57441
- withdrawals: params.map((w) => ({
57442
- token: w.token,
57443
- amount: w.amount,
57444
- recipient: w.recipient
57445
- }))
57446
- });
57591
+ const result = await wallet.withdraw(
57592
+ {
57593
+ withdrawals: params.map((w) => ({
57594
+ token: w.token,
57595
+ amount: w.amount,
57596
+ recipient: w.recipient
57597
+ }))
57598
+ },
57599
+ overrides
57600
+ );
57447
57601
  setState((prev2) => ({
57448
57602
  ...prev2,
57449
57603
  busy: false,
@@ -57475,6 +57629,36 @@ function UnlinkProvider({
57475
57629
  },
57476
57630
  []
57477
57631
  );
57632
+ const executeAdapter = useCallback(
57633
+ async (params) => {
57634
+ const wallet = walletRef.current;
57635
+ if (!wallet) throw new Error("SDK not initialized");
57636
+ setState((prev2) => ({
57637
+ ...prev2,
57638
+ busy: true,
57639
+ status: "Executing adapter..."
57640
+ }));
57641
+ try {
57642
+ const result = await wallet.adapter.execute(params);
57643
+ setState((prev2) => ({
57644
+ ...prev2,
57645
+ busy: false,
57646
+ status: "Adapter execution submitted",
57647
+ error: null
57648
+ }));
57649
+ return result;
57650
+ } catch (err) {
57651
+ setState((prev2) => ({
57652
+ ...prev2,
57653
+ busy: false,
57654
+ status: `Error: ${err instanceof Error ? err.message : "Unknown"}`,
57655
+ error: createUnlinkError(err, "executeAdapter")
57656
+ }));
57657
+ throw err;
57658
+ }
57659
+ },
57660
+ []
57661
+ );
57478
57662
  const planWithdraw = useCallback(
57479
57663
  async (params) => {
57480
57664
  const wallet = walletRef.current;
@@ -57489,33 +57673,179 @@ function UnlinkProvider({
57489
57673
  },
57490
57674
  []
57491
57675
  );
57492
- const executeWithdraw = useCallback(async (plans) => {
57676
+ const executeWithdraw = useCallback(
57677
+ async (plans, overrides) => {
57678
+ const wallet = walletRef.current;
57679
+ if (!wallet) throw new Error("SDK not initialized");
57680
+ setState((prev2) => ({
57681
+ ...prev2,
57682
+ busy: true,
57683
+ status: plans.length > 1 ? `Executing withdrawal (${plans.length} tokens)...` : "Executing withdrawal..."
57684
+ }));
57685
+ try {
57686
+ const result = await wallet.executeWithdraw(plans, overrides);
57687
+ setState((prev2) => ({
57688
+ ...prev2,
57689
+ busy: false,
57690
+ status: plans.length > 1 ? `Withdrawal executed (${plans.length} tokens)` : "Withdrawal executed",
57691
+ error: null
57692
+ }));
57693
+ return result;
57694
+ } catch (err) {
57695
+ setState((prev2) => ({
57696
+ ...prev2,
57697
+ busy: false,
57698
+ status: `Error: ${err instanceof Error ? err.message : "Unknown"}`,
57699
+ error: createUnlinkError(err, "executeWithdraw")
57700
+ }));
57701
+ throw err;
57702
+ }
57703
+ },
57704
+ []
57705
+ );
57706
+ const createBurner = useCallback(async (index) => {
57493
57707
  const wallet = walletRef.current;
57494
57708
  if (!wallet) throw new Error("SDK not initialized");
57495
57709
  setState((prev2) => ({
57496
57710
  ...prev2,
57497
57711
  busy: true,
57498
- status: plans.length > 1 ? `Executing withdrawal (${plans.length} tokens)...` : "Executing withdrawal..."
57712
+ status: `Creating burner ${index}...`
57499
57713
  }));
57500
57714
  try {
57501
- const result = await wallet.executeWithdraw(plans);
57715
+ const burner = await wallet.burner.addressOf(index);
57502
57716
  setState((prev2) => ({
57503
57717
  ...prev2,
57718
+ burners: [
57719
+ ...prev2.burners.filter((existing) => existing.index !== burner.index),
57720
+ burner
57721
+ ],
57504
57722
  busy: false,
57505
- status: plans.length > 1 ? `Withdrawal executed (${plans.length} tokens)` : "Withdrawal executed",
57723
+ status: `Burner ${index} ready`,
57506
57724
  error: null
57507
57725
  }));
57508
- return result;
57726
+ return burner;
57509
57727
  } catch (err) {
57510
57728
  setState((prev2) => ({
57511
57729
  ...prev2,
57512
57730
  busy: false,
57513
57731
  status: `Error: ${err instanceof Error ? err.message : "Unknown"}`,
57514
- error: createUnlinkError(err, "executeWithdraw")
57732
+ error: createUnlinkError(err, "createBurner")
57515
57733
  }));
57516
57734
  throw err;
57517
57735
  }
57518
57736
  }, []);
57737
+ const removeBurner = useCallback((index) => {
57738
+ setState((prev2) => ({
57739
+ ...prev2,
57740
+ burners: prev2.burners.filter((burner) => burner.index !== index)
57741
+ }));
57742
+ }, []);
57743
+ const burnerSend = useCallback(
57744
+ async (index, tx) => {
57745
+ const wallet = walletRef.current;
57746
+ if (!wallet) throw new Error("SDK not initialized");
57747
+ setState((prev2) => ({
57748
+ ...prev2,
57749
+ busy: true,
57750
+ status: "Sending burner transaction..."
57751
+ }));
57752
+ try {
57753
+ const result = await wallet.burner.send(index, tx);
57754
+ setState((prev2) => ({
57755
+ ...prev2,
57756
+ busy: false,
57757
+ status: "Burner transaction sent",
57758
+ error: null
57759
+ }));
57760
+ return result;
57761
+ } catch (err) {
57762
+ setState((prev2) => ({
57763
+ ...prev2,
57764
+ busy: false,
57765
+ status: `Error: ${err instanceof Error ? err.message : "Unknown"}`,
57766
+ error: createUnlinkError(err, "burnerSend")
57767
+ }));
57768
+ throw err;
57769
+ }
57770
+ },
57771
+ []
57772
+ );
57773
+ const burnerFund = useCallback(
57774
+ async (index, params) => {
57775
+ const wallet = walletRef.current;
57776
+ if (!wallet) throw new Error("SDK not initialized");
57777
+ setState((prev2) => ({
57778
+ ...prev2,
57779
+ busy: true,
57780
+ status: "Funding burner..."
57781
+ }));
57782
+ try {
57783
+ const result = await wallet.burner.fund(index, params);
57784
+ setState((prev2) => ({
57785
+ ...prev2,
57786
+ busy: false,
57787
+ status: "Burner funded",
57788
+ error: null
57789
+ }));
57790
+ return result;
57791
+ } catch (err) {
57792
+ setState((prev2) => ({
57793
+ ...prev2,
57794
+ busy: false,
57795
+ status: `Error: ${err instanceof Error ? err.message : "Unknown"}`,
57796
+ error: createUnlinkError(err, "burnerFund")
57797
+ }));
57798
+ throw err;
57799
+ }
57800
+ },
57801
+ []
57802
+ );
57803
+ const burnerSweepToPool = useCallback(
57804
+ async (index, params) => {
57805
+ const wallet = walletRef.current;
57806
+ if (!wallet) throw new Error("SDK not initialized");
57807
+ setState((prev2) => ({
57808
+ ...prev2,
57809
+ busy: true,
57810
+ status: "Sweeping burner to pool..."
57811
+ }));
57812
+ try {
57813
+ const result = await wallet.burner.sweepToPool(index, params);
57814
+ setState((prev2) => ({
57815
+ ...prev2,
57816
+ busy: false,
57817
+ status: "Burner sweep submitted",
57818
+ error: null
57819
+ }));
57820
+ return result;
57821
+ } catch (err) {
57822
+ setState((prev2) => ({
57823
+ ...prev2,
57824
+ busy: false,
57825
+ status: `Error: ${err instanceof Error ? err.message : "Unknown"}`,
57826
+ error: createUnlinkError(err, "burnerSweepToPool")
57827
+ }));
57828
+ throw err;
57829
+ }
57830
+ },
57831
+ []
57832
+ );
57833
+ const burnerGetTokenBalance = useCallback(
57834
+ async (address, token) => {
57835
+ const wallet = walletRef.current;
57836
+ if (!wallet) throw new Error("SDK not initialized");
57837
+ return wallet.burner.getTokenBalance(address, token);
57838
+ },
57839
+ []
57840
+ );
57841
+ const burnerGetBalance = useCallback(
57842
+ async (address) => {
57843
+ const wallet = walletRef.current;
57844
+ if (!wallet) throw new Error("SDK not initialized");
57845
+ return wallet.burner.getBalance(address);
57846
+ },
57847
+ []
57848
+ );
57519
57849
  const refresh = useCallback(async () => {
57520
57850
  const wallet = walletRef.current;
57521
57851
  if (!wallet) return;
@@ -57631,7 +57961,6 @@ function UnlinkProvider({
57631
57961
  const value = useMemo(
57632
57962
  () => ({
57633
57963
  ...state,
57634
- chainId,
57635
57964
  // Wallet actions
57636
57965
  createWallet,
57637
57966
  importWallet,
@@ -57648,8 +57977,18 @@ function UnlinkProvider({
57648
57977
  requestDeposit,
57649
57978
  // Withdraw actions
57650
57979
  requestWithdraw,
57980
+ // Adapter actions
57981
+ executeAdapter,
57651
57982
  planWithdraw,
57652
57983
  executeWithdraw,
57984
+ // Burner actions
57985
+ createBurner,
57986
+ removeBurner,
57987
+ burnerSend,
57988
+ burnerFund,
57989
+ burnerSweepToPool,
57990
+ burnerGetTokenBalance,
57991
+ burnerGetBalance,
57653
57992
  // Sync actions
57654
57993
  refresh,
57655
57994
  forceResync,
@@ -57661,7 +58000,6 @@ function UnlinkProvider({
57661
58000
  }),
57662
58001
  [
57663
58002
  state,
57664
- chainId,
57665
58003
  createWallet,
57666
58004
  importWallet,
57667
58005
  exportMnemonic,
@@ -57673,8 +58011,16 @@ function UnlinkProvider({
57673
58011
  executeTransfer,
57674
58012
  requestDeposit,
57675
58013
  requestWithdraw,
58014
+ executeAdapter,
57676
58015
  planWithdraw,
57677
58016
  executeWithdraw,
58017
+ createBurner,
58018
+ removeBurner,
58019
+ burnerSend,
58020
+ burnerFund,
58021
+ burnerSweepToPool,
58022
+ burnerGetTokenBalance,
58023
+ burnerGetBalance,
57678
58024
  refresh,
57679
58025
  forceResync,
57680
58026
  clearError,
@@ -57894,22 +58240,76 @@ function useDeposit() {
57894
58240
 
57895
58241
  // src/useTransfer.ts
57896
58242
  import { useCallback as useCallback6 } from "react";
57897
- function useTransfer() {
58243
+ function useTransfer(overrides) {
57898
58244
  const { send } = useUnlink();
57899
- const op = useCallback6((params) => send(params), [send]);
58245
+ const op = useCallback6(
58246
+ (params) => send(params, overrides),
58247
+ [send, overrides]
58248
+ );
57900
58249
  return useOperationMutation(op);
57901
58250
  }
57902
58251
 
57903
58252
  // src/useWithdraw.ts
57904
58253
  import { useCallback as useCallback7 } from "react";
57905
- function useWithdraw() {
58254
+ function useWithdraw(overrides) {
57906
58255
  const { requestWithdraw } = useUnlink();
57907
58256
  const op = useCallback7(
57908
- (params) => requestWithdraw(params),
57909
- [requestWithdraw]
58257
+ (params) => requestWithdraw(params, overrides),
58258
+ [requestWithdraw, overrides]
58259
+ );
58260
+ return useOperationMutation(op);
58261
+ }
58262
+
58263
+ // src/useAdapter.ts
58264
+ import { useCallback as useCallback8 } from "react";
58265
+ function useAdapter() {
58266
+ const { executeAdapter } = useUnlink();
58267
+ const op = useCallback8(
58268
+ (params) => executeAdapter(params),
58269
+ [executeAdapter]
57910
58270
  );
57911
58271
  return useOperationMutation(op);
57912
58272
  }
58273
+
58274
+ // src/useBurner.ts
58275
+ import { useCallback as useCallback9 } from "react";
58276
+ function useBurner() {
58277
+ const {
58278
+ burners,
58279
+ createBurner,
58280
+ removeBurner,
58281
+ burnerSend,
58282
+ burnerFund,
58283
+ burnerSweepToPool,
58284
+ burnerGetTokenBalance,
58285
+ burnerGetBalance
58286
+ } = useUnlink();
58287
+ const sendOp = useCallback9(
58288
+ (input) => burnerSend(input.index, input.tx),
58289
+ [burnerSend]
58290
+ );
58291
+ const fundOp = useCallback9(
58292
+ (input) => burnerFund(input.index, input.params),
58293
+ [burnerFund]
58294
+ );
58295
+ const sweepOp = useCallback9(
58296
+ (input) => burnerSweepToPool(input.index, input.params),
58297
+ [burnerSweepToPool]
58298
+ );
58299
+ const send = useOperationMutation(sendOp);
58300
+ const fund = useOperationMutation(fundOp);
58301
+ const sweepToPool = useOperationMutation(sweepOp);
58302
+ return {
58303
+ burners,
58304
+ createBurner,
58305
+ removeBurner,
58306
+ send,
58307
+ fund,
58308
+ sweepToPool,
58309
+ getTokenBalance: burnerGetTokenBalance,
58310
+ getBalance: burnerGetBalance
58311
+ };
58312
+ }
57913
58313
  export {
57914
58314
  CONFIRMATION_POLL_INTERVAL_MS,
57915
58315
  DEFAULT_CONFIRMATION_TIMEOUT_MS,
@@ -57926,6 +58326,8 @@ export {
57926
58326
  parseZkAddress,
57927
58327
  randomHex,
57928
58328
  shortenHex,
58329
+ useAdapter,
58330
+ useBurner,
57929
58331
  useDeposit,
57930
58332
  useOperationMutation,
57931
58333
  useTransfer,