@unlink-xyz/core 0.1.5 → 0.1.7-canary.252b8ea

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 (38) hide show
  1. package/dist/account/account.d.ts +1 -1
  2. package/dist/account/account.d.ts.map +1 -1
  3. package/dist/browser/index.js +476 -215
  4. package/dist/browser/index.js.map +1 -1
  5. package/dist/browser/wallet/index.js +427 -213
  6. package/dist/browser/wallet/index.js.map +1 -1
  7. package/dist/clients/http.d.ts.map +1 -1
  8. package/dist/config.d.ts +20 -8
  9. package/dist/config.d.ts.map +1 -1
  10. package/dist/index.d.ts +3 -3
  11. package/dist/index.d.ts.map +1 -1
  12. package/dist/index.js +399 -138
  13. package/dist/index.js.map +1 -1
  14. package/dist/transactions/adapter.d.ts +34 -1
  15. package/dist/transactions/adapter.d.ts.map +1 -1
  16. package/dist/transactions/index.d.ts +1 -1
  17. package/dist/transactions/index.d.ts.map +1 -1
  18. package/dist/tsconfig.tsbuildinfo +1 -1
  19. package/dist/utils/async.js.map +1 -1
  20. package/dist/utils/validators.d.ts +1 -1
  21. package/dist/wallet/adapter.d.ts +2 -2
  22. package/dist/wallet/adapter.d.ts.map +1 -1
  23. package/dist/wallet/burner/service.d.ts +1 -0
  24. package/dist/wallet/burner/service.d.ts.map +1 -1
  25. package/dist/wallet/burner/types.d.ts +2 -2
  26. package/dist/wallet/burner/types.d.ts.map +1 -1
  27. package/dist/wallet/index.d.ts +2 -2
  28. package/dist/wallet/index.d.ts.map +1 -1
  29. package/dist/wallet/index.js +350 -136
  30. package/dist/wallet/index.js.map +1 -1
  31. package/dist/wallet/sdk.d.ts +8 -9
  32. package/dist/wallet/sdk.d.ts.map +1 -1
  33. package/dist/wallet/types.d.ts +61 -52
  34. package/dist/wallet/types.d.ts.map +1 -1
  35. package/dist/wallet/{unlink-wallet.d.ts → unlink.d.ts} +44 -38
  36. package/dist/wallet/unlink.d.ts.map +1 -0
  37. package/package.json +1 -1
  38. package/dist/wallet/unlink-wallet.d.ts.map +0 -1
@@ -7512,9 +7512,9 @@ var bech32m = /* @__PURE__ */ genBech32("bech32m");
7512
7512
 
7513
7513
  // keys/address.ts
7514
7514
  var VERSION = 1;
7515
- var LIMIT = 127;
7515
+ var LIMIT = 130;
7516
7516
  var ALL_CHAINS = "ffffffffffffffff";
7517
- var PREFIX = "0zk";
7517
+ var PREFIX = "unlink";
7518
7518
  var SALT = new TextEncoder().encode("unlink");
7519
7519
  function xorWithSalt(hex2) {
7520
7520
  const bytes2 = Hex.toBytes(hex2);
@@ -7660,7 +7660,7 @@ function parseZkAddress(value) {
7660
7660
  };
7661
7661
  } catch (err) {
7662
7662
  throw new ValidationError(
7663
- `Invalid ZK address (expected 0zk1... format): ${err instanceof Error ? err.message : "unknown error"}`
7663
+ `Invalid ZK address (expected unlink1... format): ${err instanceof Error ? err.message : "unknown error"}`
7664
7664
  );
7665
7665
  }
7666
7666
  }
@@ -27209,8 +27209,8 @@ var ContractUnknownEventPayload = class extends EventPayload {
27209
27209
  /**
27210
27210
  * @_event:
27211
27211
  */
27212
- constructor(contract, listener, filter, log) {
27213
- super(contract, listener, filter);
27212
+ constructor(contract2, listener, filter, log) {
27213
+ super(contract2, listener, filter);
27214
27214
  defineProperties(this, { log });
27215
27215
  }
27216
27216
  /**
@@ -27236,9 +27236,9 @@ var ContractEventPayload = class extends ContractUnknownEventPayload {
27236
27236
  /**
27237
27237
  * @_ignore:
27238
27238
  */
27239
- constructor(contract, listener, filter, fragment, _log) {
27240
- super(contract, listener, filter, new EventLog(_log, contract.interface, fragment));
27241
- const args = contract.interface.decodeEventLog(fragment, this.log.data, this.log.topics);
27239
+ constructor(contract2, listener, filter, fragment, _log) {
27240
+ super(contract2, listener, filter, new EventLog(_log, contract2.interface, fragment));
27241
+ const args = contract2.interface.decodeEventLog(fragment, this.log.data, this.log.topics);
27242
27242
  defineProperties(this, { args, fragment });
27243
27243
  }
27244
27244
  /**
@@ -27283,12 +27283,12 @@ function getResolver(value) {
27283
27283
  var PreparedTopicFilter = class {
27284
27284
  #filter;
27285
27285
  fragment;
27286
- constructor(contract, fragment, args) {
27286
+ constructor(contract2, fragment, args) {
27287
27287
  defineProperties(this, { fragment });
27288
27288
  if (fragment.inputs.length < args.length) {
27289
27289
  throw new Error("too many arguments");
27290
27290
  }
27291
- const runner = getRunner(contract.runner, "resolveName");
27291
+ const runner = getRunner(contract2.runner, "resolveName");
27292
27292
  const resolver = canResolve(runner) ? runner : null;
27293
27293
  this.#filter = (async function() {
27294
27294
  const resolvedArgs = await Promise.all(fragment.inputs.map((param, index) => {
@@ -27306,7 +27306,7 @@ var PreparedTopicFilter = class {
27306
27306
  return value;
27307
27307
  });
27308
27308
  }));
27309
- return contract.interface.encodeFilterTopics(fragment, resolvedArgs);
27309
+ return contract2.interface.encodeFilterTopics(fragment, resolvedArgs);
27310
27310
  })();
27311
27311
  }
27312
27312
  getTopicFilter() {
@@ -27355,14 +27355,14 @@ async function resolveArgs(_runner, inputs, args) {
27355
27355
  });
27356
27356
  }));
27357
27357
  }
27358
- function buildWrappedFallback(contract) {
27358
+ function buildWrappedFallback(contract2) {
27359
27359
  const populateTransaction = async function(overrides) {
27360
27360
  const tx = await copyOverrides(overrides, ["data"]);
27361
- tx.to = await contract.getAddress();
27361
+ tx.to = await contract2.getAddress();
27362
27362
  if (tx.from) {
27363
- tx.from = await resolveAddress(tx.from, getResolver(contract.runner));
27363
+ tx.from = await resolveAddress(tx.from, getResolver(contract2.runner));
27364
27364
  }
27365
- const iface = contract.interface;
27365
+ const iface = contract2.interface;
27366
27366
  const noValue = getBigInt(tx.value || BN_09, "overrides.value") === BN_09;
27367
27367
  const noData = (tx.data || "0x") === "0x";
27368
27368
  if (iface.fallback && !iface.fallback.payable && iface.receive && !noData && !noValue) {
@@ -27375,27 +27375,27 @@ function buildWrappedFallback(contract) {
27375
27375
  return tx;
27376
27376
  };
27377
27377
  const staticCall = async function(overrides) {
27378
- const runner = getRunner(contract.runner, "call");
27378
+ const runner = getRunner(contract2.runner, "call");
27379
27379
  assert(canCall(runner), "contract runner does not support calling", "UNSUPPORTED_OPERATION", { operation: "call" });
27380
27380
  const tx = await populateTransaction(overrides);
27381
27381
  try {
27382
27382
  return await runner.call(tx);
27383
27383
  } catch (error) {
27384
27384
  if (isCallException(error) && error.data) {
27385
- throw contract.interface.makeError(error.data, tx);
27385
+ throw contract2.interface.makeError(error.data, tx);
27386
27386
  }
27387
27387
  throw error;
27388
27388
  }
27389
27389
  };
27390
27390
  const send = async function(overrides) {
27391
- const runner = contract.runner;
27391
+ const runner = contract2.runner;
27392
27392
  assert(canSend(runner), "contract runner does not support sending transactions", "UNSUPPORTED_OPERATION", { operation: "sendTransaction" });
27393
27393
  const tx = await runner.sendTransaction(await populateTransaction(overrides));
27394
- const provider = getProvider(contract.runner);
27395
- return new ContractTransactionResponse(contract.interface, provider, tx);
27394
+ const provider = getProvider(contract2.runner);
27395
+ return new ContractTransactionResponse(contract2.interface, provider, tx);
27396
27396
  };
27397
27397
  const estimateGas = async function(overrides) {
27398
- const runner = getRunner(contract.runner, "estimateGas");
27398
+ const runner = getRunner(contract2.runner, "estimateGas");
27399
27399
  assert(canEstimate(runner), "contract runner does not support gas estimation", "UNSUPPORTED_OPERATION", { operation: "estimateGas" });
27400
27400
  return await runner.estimateGas(await populateTransaction(overrides));
27401
27401
  };
@@ -27403,7 +27403,7 @@ function buildWrappedFallback(contract) {
27403
27403
  return await send(overrides);
27404
27404
  };
27405
27405
  defineProperties(method, {
27406
- _contract: contract,
27406
+ _contract: contract2,
27407
27407
  estimateGas,
27408
27408
  populateTransaction,
27409
27409
  send,
@@ -27411,9 +27411,9 @@ function buildWrappedFallback(contract) {
27411
27411
  });
27412
27412
  return method;
27413
27413
  }
27414
- function buildWrappedMethod(contract, key) {
27414
+ function buildWrappedMethod(contract2, key) {
27415
27415
  const getFragment = function(...args) {
27416
- const fragment = contract.interface.getFunction(key, args);
27416
+ const fragment = contract2.interface.getFunction(key, args);
27417
27417
  assert(fragment, "no matching fragment", "UNSUPPORTED_OPERATION", {
27418
27418
  operation: "fragment",
27419
27419
  info: { key, args }
@@ -27426,16 +27426,16 @@ function buildWrappedMethod(contract, key) {
27426
27426
  if (fragment.inputs.length + 1 === args.length) {
27427
27427
  overrides = await copyOverrides(args.pop());
27428
27428
  if (overrides.from) {
27429
- overrides.from = await resolveAddress(overrides.from, getResolver(contract.runner));
27429
+ overrides.from = await resolveAddress(overrides.from, getResolver(contract2.runner));
27430
27430
  }
27431
27431
  }
27432
27432
  if (fragment.inputs.length !== args.length) {
27433
27433
  throw new Error("internal error: fragment inputs doesn't match arguments; should not happen");
27434
27434
  }
27435
- const resolvedArgs = await resolveArgs(contract.runner, fragment.inputs, args);
27435
+ const resolvedArgs = await resolveArgs(contract2.runner, fragment.inputs, args);
27436
27436
  return Object.assign({}, overrides, await resolveProperties({
27437
- to: contract.getAddress(),
27438
- data: contract.interface.encodeFunctionData(fragment, resolvedArgs)
27437
+ to: contract2.getAddress(),
27438
+ data: contract2.interface.encodeFunctionData(fragment, resolvedArgs)
27439
27439
  }));
27440
27440
  };
27441
27441
  const staticCall = async function(...args) {
@@ -27446,19 +27446,19 @@ function buildWrappedMethod(contract, key) {
27446
27446
  return result;
27447
27447
  };
27448
27448
  const send = async function(...args) {
27449
- const runner = contract.runner;
27449
+ const runner = contract2.runner;
27450
27450
  assert(canSend(runner), "contract runner does not support sending transactions", "UNSUPPORTED_OPERATION", { operation: "sendTransaction" });
27451
27451
  const tx = await runner.sendTransaction(await populateTransaction(...args));
27452
- const provider = getProvider(contract.runner);
27453
- return new ContractTransactionResponse(contract.interface, provider, tx);
27452
+ const provider = getProvider(contract2.runner);
27453
+ return new ContractTransactionResponse(contract2.interface, provider, tx);
27454
27454
  };
27455
27455
  const estimateGas = async function(...args) {
27456
- const runner = getRunner(contract.runner, "estimateGas");
27456
+ const runner = getRunner(contract2.runner, "estimateGas");
27457
27457
  assert(canEstimate(runner), "contract runner does not support gas estimation", "UNSUPPORTED_OPERATION", { operation: "estimateGas" });
27458
27458
  return await runner.estimateGas(await populateTransaction(...args));
27459
27459
  };
27460
27460
  const staticCallResult = async function(...args) {
27461
- const runner = getRunner(contract.runner, "call");
27461
+ const runner = getRunner(contract2.runner, "call");
27462
27462
  assert(canCall(runner), "contract runner does not support calling", "UNSUPPORTED_OPERATION", { operation: "call" });
27463
27463
  const tx = await populateTransaction(...args);
27464
27464
  let result = "0x";
@@ -27466,12 +27466,12 @@ function buildWrappedMethod(contract, key) {
27466
27466
  result = await runner.call(tx);
27467
27467
  } catch (error) {
27468
27468
  if (isCallException(error) && error.data) {
27469
- throw contract.interface.makeError(error.data, tx);
27469
+ throw contract2.interface.makeError(error.data, tx);
27470
27470
  }
27471
27471
  throw error;
27472
27472
  }
27473
27473
  const fragment = getFragment(...args);
27474
- return contract.interface.decodeFunctionResult(fragment, result);
27474
+ return contract2.interface.decodeFunctionResult(fragment, result);
27475
27475
  };
27476
27476
  const method = async (...args) => {
27477
27477
  const fragment = getFragment(...args);
@@ -27481,8 +27481,8 @@ function buildWrappedMethod(contract, key) {
27481
27481
  return await send(...args);
27482
27482
  };
27483
27483
  defineProperties(method, {
27484
- name: contract.interface.getFunctionName(key),
27485
- _contract: contract,
27484
+ name: contract2.interface.getFunctionName(key),
27485
+ _contract: contract2,
27486
27486
  _key: key,
27487
27487
  getFragment,
27488
27488
  estimateGas,
@@ -27495,7 +27495,7 @@ function buildWrappedMethod(contract, key) {
27495
27495
  configurable: false,
27496
27496
  enumerable: true,
27497
27497
  get: () => {
27498
- const fragment = contract.interface.getFunction(key);
27498
+ const fragment = contract2.interface.getFunction(key);
27499
27499
  assert(fragment, "no matching fragment", "UNSUPPORTED_OPERATION", {
27500
27500
  operation: "fragment",
27501
27501
  info: { key }
@@ -27505,9 +27505,9 @@ function buildWrappedMethod(contract, key) {
27505
27505
  });
27506
27506
  return method;
27507
27507
  }
27508
- function buildWrappedEvent(contract, key) {
27508
+ function buildWrappedEvent(contract2, key) {
27509
27509
  const getFragment = function(...args) {
27510
- const fragment = contract.interface.getEvent(key, args);
27510
+ const fragment = contract2.interface.getEvent(key, args);
27511
27511
  assert(fragment, "no matching fragment", "UNSUPPORTED_OPERATION", {
27512
27512
  operation: "fragment",
27513
27513
  info: { key, args }
@@ -27515,11 +27515,11 @@ function buildWrappedEvent(contract, key) {
27515
27515
  return fragment;
27516
27516
  };
27517
27517
  const method = function(...args) {
27518
- return new PreparedTopicFilter(contract, getFragment(...args), args);
27518
+ return new PreparedTopicFilter(contract2, getFragment(...args), args);
27519
27519
  };
27520
27520
  defineProperties(method, {
27521
- name: contract.interface.getEventName(key),
27522
- _contract: contract,
27521
+ name: contract2.interface.getEventName(key),
27522
+ _contract: contract2,
27523
27523
  _key: key,
27524
27524
  getFragment
27525
27525
  });
@@ -27527,7 +27527,7 @@ function buildWrappedEvent(contract, key) {
27527
27527
  configurable: false,
27528
27528
  enumerable: true,
27529
27529
  get: () => {
27530
- const fragment = contract.interface.getEvent(key);
27530
+ const fragment = contract2.interface.getEvent(key);
27531
27531
  assert(fragment, "no matching fragment", "UNSUPPORTED_OPERATION", {
27532
27532
  operation: "fragment",
27533
27533
  info: { key }
@@ -27539,16 +27539,16 @@ function buildWrappedEvent(contract, key) {
27539
27539
  }
27540
27540
  var internal2 = /* @__PURE__ */ Symbol.for("_ethersInternal_contract");
27541
27541
  var internalValues = /* @__PURE__ */ new WeakMap();
27542
- function setInternal(contract, values) {
27543
- internalValues.set(contract[internal2], values);
27542
+ function setInternal(contract2, values) {
27543
+ internalValues.set(contract2[internal2], values);
27544
27544
  }
27545
- function getInternal(contract) {
27546
- return internalValues.get(contract[internal2]);
27545
+ function getInternal(contract2) {
27546
+ return internalValues.get(contract2[internal2]);
27547
27547
  }
27548
27548
  function isDeferred(value) {
27549
27549
  return value && typeof value === "object" && "getTopicFilter" in value && typeof value.getTopicFilter === "function" && value.fragment;
27550
27550
  }
27551
- async function getSubInfo(contract, event) {
27551
+ async function getSubInfo(contract2, event) {
27552
27552
  let topics;
27553
27553
  let fragment = null;
27554
27554
  if (Array.isArray(event)) {
@@ -27556,7 +27556,7 @@ async function getSubInfo(contract, event) {
27556
27556
  if (isHexString(name, 32)) {
27557
27557
  return name;
27558
27558
  }
27559
- const fragment2 = contract.interface.getEvent(name);
27559
+ const fragment2 = contract2.interface.getEvent(name);
27560
27560
  assertArgument(fragment2, "unknown fragment", "name", name);
27561
27561
  return fragment2.topicHash;
27562
27562
  };
@@ -27575,7 +27575,7 @@ async function getSubInfo(contract, event) {
27575
27575
  if (isHexString(event, 32)) {
27576
27576
  topics = [event];
27577
27577
  } else {
27578
- fragment = contract.interface.getEvent(event);
27578
+ fragment = contract2.interface.getEvent(event);
27579
27579
  assertArgument(fragment, "unknown fragment", "event", event);
27580
27580
  topics = [fragment.topicHash];
27581
27581
  }
@@ -27612,36 +27612,36 @@ async function getSubInfo(contract, event) {
27612
27612
  }).join("&");
27613
27613
  return { fragment, tag, topics };
27614
27614
  }
27615
- async function hasSub(contract, event) {
27616
- const { subs } = getInternal(contract);
27617
- return subs.get((await getSubInfo(contract, event)).tag) || null;
27615
+ async function hasSub(contract2, event) {
27616
+ const { subs } = getInternal(contract2);
27617
+ return subs.get((await getSubInfo(contract2, event)).tag) || null;
27618
27618
  }
27619
- async function getSub(contract, operation, event) {
27620
- const provider = getProvider(contract.runner);
27619
+ async function getSub(contract2, operation, event) {
27620
+ const provider = getProvider(contract2.runner);
27621
27621
  assert(provider, "contract runner does not support subscribing", "UNSUPPORTED_OPERATION", { operation });
27622
- const { fragment, tag, topics } = await getSubInfo(contract, event);
27623
- const { addr, subs } = getInternal(contract);
27622
+ const { fragment, tag, topics } = await getSubInfo(contract2, event);
27623
+ const { addr, subs } = getInternal(contract2);
27624
27624
  let sub2 = subs.get(tag);
27625
27625
  if (!sub2) {
27626
- const address = addr ? addr : contract;
27626
+ const address = addr ? addr : contract2;
27627
27627
  const filter = { address, topics };
27628
27628
  const listener = (log) => {
27629
27629
  let foundFragment = fragment;
27630
27630
  if (foundFragment == null) {
27631
27631
  try {
27632
- foundFragment = contract.interface.getEvent(log.topics[0]);
27632
+ foundFragment = contract2.interface.getEvent(log.topics[0]);
27633
27633
  } catch (error) {
27634
27634
  }
27635
27635
  }
27636
27636
  if (foundFragment) {
27637
27637
  const _foundFragment = foundFragment;
27638
- const args = fragment ? contract.interface.decodeEventLog(fragment, log.data, log.topics) : [];
27639
- emit2(contract, event, args, (listener2) => {
27640
- return new ContractEventPayload(contract, listener2, event, _foundFragment, log);
27638
+ const args = fragment ? contract2.interface.decodeEventLog(fragment, log.data, log.topics) : [];
27639
+ emit2(contract2, event, args, (listener2) => {
27640
+ return new ContractEventPayload(contract2, listener2, event, _foundFragment, log);
27641
27641
  });
27642
27642
  } else {
27643
- emit2(contract, event, [], (listener2) => {
27644
- return new ContractUnknownEventPayload(contract, listener2, event, log);
27643
+ emit2(contract2, event, [], (listener2) => {
27644
+ return new ContractUnknownEventPayload(contract2, listener2, event, log);
27645
27645
  });
27646
27646
  }
27647
27647
  };
@@ -27667,9 +27667,9 @@ async function getSub(contract, operation, event) {
27667
27667
  return sub2;
27668
27668
  }
27669
27669
  var lastEmit = Promise.resolve();
27670
- async function _emit(contract, event, args, payloadFunc) {
27670
+ async function _emit(contract2, event, args, payloadFunc) {
27671
27671
  await lastEmit;
27672
- const sub2 = await hasSub(contract, event);
27672
+ const sub2 = await hasSub(contract2, event);
27673
27673
  if (!sub2) {
27674
27674
  return false;
27675
27675
  }
@@ -27680,23 +27680,23 @@ async function _emit(contract, event, args, payloadFunc) {
27680
27680
  passArgs.push(payloadFunc(once2 ? null : listener));
27681
27681
  }
27682
27682
  try {
27683
- listener.call(contract, ...passArgs);
27683
+ listener.call(contract2, ...passArgs);
27684
27684
  } catch (error) {
27685
27685
  }
27686
27686
  return !once2;
27687
27687
  });
27688
27688
  if (sub2.listeners.length === 0) {
27689
27689
  sub2.stop();
27690
- getInternal(contract).subs.delete(sub2.tag);
27690
+ getInternal(contract2).subs.delete(sub2.tag);
27691
27691
  }
27692
27692
  return count > 0;
27693
27693
  }
27694
- async function emit2(contract, event, args, payloadFunc) {
27694
+ async function emit2(contract2, event, args, payloadFunc) {
27695
27695
  try {
27696
27696
  await lastEmit;
27697
27697
  } catch (error) {
27698
27698
  }
27699
- const resultPromise = _emit(contract, event, args, payloadFunc);
27699
+ const resultPromise = _emit(contract2, event, args, payloadFunc);
27700
27700
  lastEmit = resultPromise;
27701
27701
  return await resultPromise;
27702
27702
  }
@@ -28122,8 +28122,8 @@ var BaseContract = class _BaseContract {
28122
28122
  if (runner == null) {
28123
28123
  runner = null;
28124
28124
  }
28125
- const contract = new this(target, abi, runner);
28126
- return contract;
28125
+ const contract2 = new this(target, abi, runner);
28126
+ return contract2;
28127
28127
  }
28128
28128
  };
28129
28129
  function _ContractBase() {
@@ -28424,7 +28424,7 @@ var EnsResolver = class _EnsResolver {
28424
28424
  return { url: null, linkage };
28425
28425
  }
28426
28426
  const tokenId = comps[1];
28427
- const contract = new Contract(comps[0], [
28427
+ const contract2 = new Contract(comps[0], [
28428
28428
  // ERC-721
28429
28429
  "function tokenURI(uint) view returns (string)",
28430
28430
  "function ownerOf(uint) view returns (address)",
@@ -28433,21 +28433,21 @@ var EnsResolver = class _EnsResolver {
28433
28433
  "function balanceOf(address, uint256) view returns (uint)"
28434
28434
  ], this.provider);
28435
28435
  if (scheme === "erc721") {
28436
- const tokenOwner = await contract.ownerOf(tokenId);
28436
+ const tokenOwner = await contract2.ownerOf(tokenId);
28437
28437
  if (owner !== tokenOwner) {
28438
28438
  linkage.push({ type: "!owner", value: tokenOwner });
28439
28439
  return { url: null, linkage };
28440
28440
  }
28441
28441
  linkage.push({ type: "owner", value: tokenOwner });
28442
28442
  } else if (scheme === "erc1155") {
28443
- const balance = await contract.balanceOf(owner, tokenId);
28443
+ const balance = await contract2.balanceOf(owner, tokenId);
28444
28444
  if (!balance) {
28445
28445
  linkage.push({ type: "!balance", value: "0" });
28446
28446
  return { url: null, linkage };
28447
28447
  }
28448
28448
  linkage.push({ type: "balance", value: balance.toString() });
28449
28449
  }
28450
- let metadataUrl = await contract[selector](tokenId);
28450
+ let metadataUrl = await contract2[selector](tokenId);
28451
28451
  if (metadataUrl == null || metadataUrl === "0x") {
28452
28452
  linkage.push({ type: "!metadata-url", value: "" });
28453
28453
  return { url: null, linkage };
@@ -28519,10 +28519,10 @@ var EnsResolver = class _EnsResolver {
28519
28519
  static async #getResolver(provider, name) {
28520
28520
  const ensAddr = await _EnsResolver.getEnsAddress(provider);
28521
28521
  try {
28522
- const contract = new Contract(ensAddr, [
28522
+ const contract2 = new Contract(ensAddr, [
28523
28523
  "function resolver(bytes32) view returns (address)"
28524
28524
  ], provider);
28525
- const addr = await contract.resolver(namehash(name), {
28525
+ const addr = await contract2.resolver(namehash(name), {
28526
28526
  enableCcipRead: true
28527
28527
  });
28528
28528
  if (addr === ZeroAddress) {
@@ -34626,29 +34626,41 @@ function createJsonHttpClient(baseUrl, deps) {
34626
34626
  fetch: fetchImpl,
34627
34627
  // Disable ky's automatic error throwing to prevent browser DevTools
34628
34628
  // from logging expected 404s as network errors
34629
- throwHttpErrors: false
34629
+ throwHttpErrors: false,
34630
+ retry: 0
34630
34631
  });
34632
+ const RETRYABLE_STATUSES = [502, 503, 504];
34633
+ const MAX_RETRIES = 3;
34634
+ const BASE_DELAY_MS = 500;
34631
34635
  return {
34632
34636
  async request(opts) {
34633
34637
  let res;
34634
- try {
34635
- res = await api(opts.path.replace(/^\//, ""), {
34636
- method: opts.method,
34637
- searchParams: opts.query,
34638
- json: opts.json,
34639
- body: opts.body,
34640
- headers: opts.headers,
34641
- signal: opts.signal
34642
- });
34643
- } catch (err) {
34644
- if (err instanceof TimeoutError) {
34645
- throw new HttpError("HTTP timeout", 408, null);
34638
+ for (let attempt = 0; attempt <= MAX_RETRIES; attempt++) {
34639
+ try {
34640
+ res = await api(opts.path.replace(/^\//, ""), {
34641
+ method: opts.method,
34642
+ searchParams: opts.query,
34643
+ json: opts.json,
34644
+ body: opts.body,
34645
+ headers: opts.headers,
34646
+ signal: opts.signal
34647
+ });
34648
+ } catch (err) {
34649
+ if (err instanceof TimeoutError) {
34650
+ throw new HttpError("HTTP timeout", 408, null);
34651
+ }
34652
+ throw new HttpError(
34653
+ err instanceof Error ? err.message : "Network error",
34654
+ 0,
34655
+ null
34656
+ );
34646
34657
  }
34647
- throw new HttpError(
34648
- err instanceof Error ? err.message : "Network error",
34649
- 0,
34650
- null
34651
- );
34658
+ if (RETRYABLE_STATUSES.includes(res.status) && attempt < MAX_RETRIES) {
34659
+ const delay2 = BASE_DELAY_MS * 2 ** attempt + Math.random() * 200;
34660
+ await new Promise((r2) => setTimeout(r2, delay2));
34661
+ continue;
34662
+ }
34663
+ break;
34652
34664
  }
34653
34665
  if (!res.ok) {
34654
34666
  const body = await readErrorBodySafe(res);
@@ -34857,64 +34869,115 @@ var Runtime = {
34857
34869
  };
34858
34870
 
34859
34871
  // config.ts
34872
+ var DEFAULT_RPC_URLS = {
34873
+ "monad-testnet": "https://testnet-rpc.monad.xyz",
34874
+ "monad-testnet-staging": "https://testnet-rpc.monad.xyz"
34875
+ };
34860
34876
  var CONFIG_URL = "https://config.unlink.xyz/networks.json";
34861
- function parseRequiredString(env2, field, value) {
34877
+ function parseRequiredString(chain2, field, value) {
34862
34878
  if (typeof value !== "string" || value.trim().length === 0) {
34863
34879
  throw new InitializationError(
34864
- `Invalid SDK config for ${env2}: ${field} must be a non-empty string`
34880
+ `Invalid SDK config for ${chain2}: ${field} must be a non-empty string`
34865
34881
  );
34866
34882
  }
34867
34883
  return value.trim();
34868
34884
  }
34869
- function parseOptionalString(env2, field, value) {
34885
+ function parseOptionalString(chain2, field, value) {
34870
34886
  if (value === void 0) return void 0;
34871
34887
  if (typeof value !== "string" || value.trim().length === 0) {
34872
34888
  throw new InitializationError(
34873
- `Invalid SDK config for ${env2}: ${field} must be a non-empty string when provided`
34889
+ `Invalid SDK config for ${chain2}: ${field} must be a non-empty string when provided`
34874
34890
  );
34875
34891
  }
34876
34892
  return value.trim();
34877
34893
  }
34878
- function parseEnvironmentConfig(env2, value) {
34894
+ function parseRequiredChainId(chain2, value) {
34895
+ if (typeof value !== "number" || !Number.isInteger(value) || value <= 0) {
34896
+ throw new InitializationError(
34897
+ `Invalid SDK config for ${chain2}: chainId must be a positive integer`
34898
+ );
34899
+ }
34900
+ return value;
34901
+ }
34902
+ function parseChainConfig(chain2, value) {
34879
34903
  if (value === null || typeof value !== "object" || Array.isArray(value)) {
34880
34904
  throw new InitializationError(
34881
- `Invalid SDK config for ${env2}: expected object`
34905
+ `Invalid SDK config for ${chain2}: expected object`
34882
34906
  );
34883
34907
  }
34884
34908
  const raw = value;
34909
+ const chainId = parseRequiredChainId(chain2, raw.chainId);
34885
34910
  const gatewayUrl = parseRequiredString(
34886
- env2,
34911
+ chain2,
34887
34912
  "gatewayUrl",
34888
34913
  raw.gatewayUrl
34889
34914
  ).replace(/\/+$/, "");
34890
- const poolAddress = parseRequiredString(env2, "poolAddress", raw.poolAddress);
34915
+ const poolAddress = parseRequiredString(
34916
+ chain2,
34917
+ "poolAddress",
34918
+ raw.poolAddress
34919
+ );
34891
34920
  const artifactVersion = parseRequiredString(
34892
- env2,
34921
+ chain2,
34893
34922
  "artifactVersion",
34894
34923
  raw.artifactVersion
34895
34924
  ).replace(/^\/+|\/+$/g, "");
34925
+ const adapterAddress = parseOptionalString(
34926
+ chain2,
34927
+ "adapterAddress",
34928
+ raw.adapterAddress
34929
+ );
34930
+ const frostUrl = parseOptionalString(
34931
+ chain2,
34932
+ "frostUrl",
34933
+ raw.frostUrl
34934
+ )?.replace(/\/+$/, "");
34896
34935
  const artifactBaseUrl = parseOptionalString(
34897
- env2,
34936
+ chain2,
34898
34937
  "artifactBaseUrl",
34899
34938
  raw.artifactBaseUrl
34900
34939
  )?.replace(/\/+$/, "");
34940
+ let tokenAddresses;
34941
+ if (raw.tokenAddresses !== void 0) {
34942
+ if (raw.tokenAddresses === null || typeof raw.tokenAddresses !== "object" || Array.isArray(raw.tokenAddresses)) {
34943
+ throw new InitializationError(
34944
+ `Invalid SDK config for ${chain2}: tokenAddresses must be an object`
34945
+ );
34946
+ }
34947
+ tokenAddresses = {};
34948
+ for (const [name, addr] of Object.entries(
34949
+ raw.tokenAddresses
34950
+ )) {
34951
+ tokenAddresses[name] = parseRequiredString(
34952
+ chain2,
34953
+ `tokenAddresses.${name}`,
34954
+ addr
34955
+ );
34956
+ }
34957
+ }
34901
34958
  return {
34959
+ chainId,
34902
34960
  gatewayUrl,
34961
+ ...frostUrl !== void 0 ? { frostUrl } : {},
34903
34962
  poolAddress,
34963
+ ...adapterAddress !== void 0 ? { adapterAddress } : {},
34904
34964
  artifactVersion,
34905
- ...artifactBaseUrl !== void 0 ? { artifactBaseUrl } : { artifactBaseUrl: DEFAULT_ARTIFACT_BASE_URL }
34965
+ ...artifactBaseUrl !== void 0 ? { artifactBaseUrl } : { artifactBaseUrl: DEFAULT_ARTIFACT_BASE_URL },
34966
+ ...tokenAddresses !== void 0 ? { tokenAddresses } : {}
34906
34967
  };
34907
34968
  }
34908
- async function fetchEnvironmentConfig(env2) {
34969
+ async function fetchChainConfig(chain2) {
34909
34970
  const res = await fetch(CONFIG_URL);
34910
34971
  if (!res.ok) {
34911
34972
  throw new InitializationError(`Failed to fetch SDK config: ${res.status}`);
34912
34973
  }
34913
34974
  const config2 = await res.json();
34914
- if (!config2[env2]) {
34915
- throw new InitializationError(`Unknown environment: ${env2}`);
34975
+ if (!config2[chain2]) {
34976
+ throw new InitializationError(
34977
+ `Unknown chain: "${chain2}". Supported chains: ${Object.keys(config2).join(", ")}`
34978
+ );
34916
34979
  }
34917
- return parseEnvironmentConfig(env2, config2[env2]);
34980
+ return parseChainConfig(chain2, config2[chain2]);
34918
34981
  }
34919
34982
  function createServiceConfig(gatewayUrl) {
34920
34983
  const baseUrl = gatewayUrl.replace(/\/+$/, "");
@@ -52327,6 +52390,114 @@ var circuits_default = {
52327
52390
  template: "JoinSplit",
52328
52391
  pubs: ["merkleRoot", "boundParamsHash", "nullifiers", "commitmentsOut"],
52329
52392
  params: [5, 2, 16]
52393
+ },
52394
+ joinsplit_1x3_16: {
52395
+ file: "joinsplit",
52396
+ template: "JoinSplit",
52397
+ pubs: ["merkleRoot", "boundParamsHash", "nullifiers", "commitmentsOut"],
52398
+ params: [1, 3, 16]
52399
+ },
52400
+ joinsplit_4x3_16: {
52401
+ file: "joinsplit",
52402
+ template: "JoinSplit",
52403
+ pubs: ["merkleRoot", "boundParamsHash", "nullifiers", "commitmentsOut"],
52404
+ params: [4, 3, 16]
52405
+ },
52406
+ joinsplit_5x3_16: {
52407
+ file: "joinsplit",
52408
+ template: "JoinSplit",
52409
+ pubs: ["merkleRoot", "boundParamsHash", "nullifiers", "commitmentsOut"],
52410
+ params: [5, 3, 16]
52411
+ },
52412
+ joinsplit_6x1_16: {
52413
+ file: "joinsplit",
52414
+ template: "JoinSplit",
52415
+ pubs: ["merkleRoot", "boundParamsHash", "nullifiers", "commitmentsOut"],
52416
+ params: [6, 1, 16]
52417
+ },
52418
+ joinsplit_6x2_16: {
52419
+ file: "joinsplit",
52420
+ template: "JoinSplit",
52421
+ pubs: ["merkleRoot", "boundParamsHash", "nullifiers", "commitmentsOut"],
52422
+ params: [6, 2, 16]
52423
+ },
52424
+ joinsplit_6x3_16: {
52425
+ file: "joinsplit",
52426
+ template: "JoinSplit",
52427
+ pubs: ["merkleRoot", "boundParamsHash", "nullifiers", "commitmentsOut"],
52428
+ params: [6, 3, 16]
52429
+ },
52430
+ joinsplit_7x1_16: {
52431
+ file: "joinsplit",
52432
+ template: "JoinSplit",
52433
+ pubs: ["merkleRoot", "boundParamsHash", "nullifiers", "commitmentsOut"],
52434
+ params: [7, 1, 16]
52435
+ },
52436
+ joinsplit_7x2_16: {
52437
+ file: "joinsplit",
52438
+ template: "JoinSplit",
52439
+ pubs: ["merkleRoot", "boundParamsHash", "nullifiers", "commitmentsOut"],
52440
+ params: [7, 2, 16]
52441
+ },
52442
+ joinsplit_7x3_16: {
52443
+ file: "joinsplit",
52444
+ template: "JoinSplit",
52445
+ pubs: ["merkleRoot", "boundParamsHash", "nullifiers", "commitmentsOut"],
52446
+ params: [7, 3, 16]
52447
+ },
52448
+ joinsplit_8x1_16: {
52449
+ file: "joinsplit",
52450
+ template: "JoinSplit",
52451
+ pubs: ["merkleRoot", "boundParamsHash", "nullifiers", "commitmentsOut"],
52452
+ params: [8, 1, 16]
52453
+ },
52454
+ joinsplit_8x2_16: {
52455
+ file: "joinsplit",
52456
+ template: "JoinSplit",
52457
+ pubs: ["merkleRoot", "boundParamsHash", "nullifiers", "commitmentsOut"],
52458
+ params: [8, 2, 16]
52459
+ },
52460
+ joinsplit_8x3_16: {
52461
+ file: "joinsplit",
52462
+ template: "JoinSplit",
52463
+ pubs: ["merkleRoot", "boundParamsHash", "nullifiers", "commitmentsOut"],
52464
+ params: [8, 3, 16]
52465
+ },
52466
+ joinsplit_9x1_16: {
52467
+ file: "joinsplit",
52468
+ template: "JoinSplit",
52469
+ pubs: ["merkleRoot", "boundParamsHash", "nullifiers", "commitmentsOut"],
52470
+ params: [9, 1, 16]
52471
+ },
52472
+ joinsplit_9x2_16: {
52473
+ file: "joinsplit",
52474
+ template: "JoinSplit",
52475
+ pubs: ["merkleRoot", "boundParamsHash", "nullifiers", "commitmentsOut"],
52476
+ params: [9, 2, 16]
52477
+ },
52478
+ joinsplit_9x3_16: {
52479
+ file: "joinsplit",
52480
+ template: "JoinSplit",
52481
+ pubs: ["merkleRoot", "boundParamsHash", "nullifiers", "commitmentsOut"],
52482
+ params: [9, 3, 16]
52483
+ },
52484
+ joinsplit_10x1_16: {
52485
+ file: "joinsplit",
52486
+ template: "JoinSplit",
52487
+ pubs: ["merkleRoot", "boundParamsHash", "nullifiers", "commitmentsOut"],
52488
+ params: [10, 1, 16]
52489
+ },
52490
+ joinsplit_10x2_16: {
52491
+ file: "joinsplit",
52492
+ template: "JoinSplit",
52493
+ pubs: ["merkleRoot", "boundParamsHash", "nullifiers", "commitmentsOut"],
52494
+ params: [10, 2, 16]
52495
+ },
52496
+ joinsplit_10x3_16: {
52497
+ file: "joinsplit",
52498
+ template: "JoinSplit",
52499
+ pubs: ["merkleRoot", "boundParamsHash", "nullifiers", "commitmentsOut"],
52500
+ params: [10, 3, 16]
52330
52501
  }
52331
52502
  };
52332
52503
 
@@ -52346,7 +52517,7 @@ function getCircuitConfig(inputs, outputs) {
52346
52517
  }
52347
52518
 
52348
52519
  // prover/prover.ts
52349
- var MAX_ARTIFACT_CACHE_ENTRIES = 8;
52520
+ var MAX_ARTIFACT_CACHE_ENTRIES = 16;
52350
52521
  var artifactCache = /* @__PURE__ */ new Map();
52351
52522
  function selectCircuit(inputs, outputs) {
52352
52523
  const config2 = getCircuitConfig(inputs, outputs);
@@ -53203,7 +53374,7 @@ function buildCall(params) {
53203
53374
  }
53204
53375
  return { to, data, value };
53205
53376
  }
53206
- function buildApproveCall(token, spender, amount) {
53377
+ function approve(token, spender, amount) {
53207
53378
  const normalizedToken = ensureAddress("token", token);
53208
53379
  const normalizedSpender = ensureAddress("spender", spender);
53209
53380
  const normalizedAmount = ensureNonNegative("amount", amount);
@@ -53217,6 +53388,44 @@ function buildApproveCall(token, spender, amount) {
53217
53388
  value: 0n
53218
53389
  };
53219
53390
  }
53391
+ function toCall(tx) {
53392
+ if (tx.to == null) {
53393
+ throw new AdapterError("tx.to is required");
53394
+ }
53395
+ const to = ensureAddress("tx.to", tx.to);
53396
+ if (tx.data == null) {
53397
+ throw new AdapterError("tx.data is required");
53398
+ }
53399
+ const data = ensureHexData("tx.data", tx.data);
53400
+ let value;
53401
+ if (tx.value == null) {
53402
+ value = 0n;
53403
+ } else {
53404
+ try {
53405
+ value = BigInt(tx.value);
53406
+ } catch {
53407
+ throw new AdapterError(
53408
+ `tx.value must be convertible to bigint, received: ${String(tx.value)}`
53409
+ );
53410
+ }
53411
+ }
53412
+ return { to, data, value: ensureNonNegative("tx.value", value) };
53413
+ }
53414
+ function contract(address, abi) {
53415
+ const to = ensureAddress("contract.address", address);
53416
+ const iface = new Interface(abi);
53417
+ return new Proxy(
53418
+ {},
53419
+ {
53420
+ get(_, method) {
53421
+ return (...args) => {
53422
+ const data = iface.encodeFunctionData(method, args);
53423
+ return { to, data, value: 0n };
53424
+ };
53425
+ }
53426
+ }
53427
+ );
53428
+ }
53220
53429
  function encodeAdapterExecute(params) {
53221
53430
  const transactCalldata = ensureHexData(
53222
53431
  "transactCalldata",
@@ -53240,6 +53449,7 @@ function encodeAdapterExecute(params) {
53240
53449
  deadline
53241
53450
  ]);
53242
53451
  }
53452
+ var buildApproveCall = approve;
53243
53453
 
53244
53454
  // transactions/transaction-planner.ts
53245
53455
  init_process();
@@ -54357,7 +54567,7 @@ function createNoteSyncService(stateStore, options = {}) {
54357
54567
  };
54358
54568
  }
54359
54569
 
54360
- // wallet/unlink-wallet.ts
54570
+ // wallet/unlink.ts
54361
54571
  init_process();
54362
54572
  init_buffer();
54363
54573
 
@@ -54654,26 +54864,34 @@ function normalizeCall2(call, index) {
54654
54864
  value: call.value
54655
54865
  };
54656
54866
  }
54657
- function normalizeInputSpec(input, index) {
54658
- const token = ensureAddress(`inputs[${index}].token`, input.token);
54867
+ function normalizeSpendInput(input, index) {
54868
+ const token = ensureAddress(`spend[${index}].token`, input.token);
54869
+ if (token.toLowerCase() === ETH_TOKEN.toLowerCase()) {
54870
+ throw new AdapterError(
54871
+ `spend[${index}].token: native ETH is not supported in adapter execution`
54872
+ );
54873
+ }
54659
54874
  if (input.amount <= 0n) {
54660
- throw new AdapterError(`inputs[${index}].amount must be greater than zero`);
54875
+ throw new AdapterError(`spend[${index}].amount must be greater than zero`);
54661
54876
  }
54662
54877
  return {
54663
54878
  token,
54664
54879
  amount: input.amount
54665
54880
  };
54666
54881
  }
54667
- function normalizeReshieldSpec(reshield, index) {
54668
- const token = ensureAddress(`reshields[${index}].token`, reshield.token);
54669
- if (reshield.minAmount < 0n) {
54882
+ function normalizeReceiveInput(receive, index) {
54883
+ const token = ensureAddress(`receive[${index}].token`, receive.token);
54884
+ if (token.toLowerCase() === ETH_TOKEN.toLowerCase()) {
54670
54885
  throw new AdapterError(
54671
- `reshields[${index}].minAmount must be non-negative`
54886
+ `receive[${index}].token: native ETH is not supported in adapter execution`
54672
54887
  );
54673
54888
  }
54889
+ if (receive.minAmount < 0n) {
54890
+ throw new AdapterError(`receive[${index}].minAmount must be non-negative`);
54891
+ }
54674
54892
  return {
54675
54893
  token,
54676
- minAmount: reshield.minAmount
54894
+ minAmount: receive.minAmount
54677
54895
  };
54678
54896
  }
54679
54897
  function randomFieldElement(randomBigintFn) {
@@ -54693,32 +54911,42 @@ function createAdapterService(deps) {
54693
54911
  "adapterAddress",
54694
54912
  params.adapterAddress
54695
54913
  );
54696
- if (!params.inputs.length) {
54697
- throw new AdapterError("at least one input token is required");
54914
+ if (!params.spend.length) {
54915
+ throw new AdapterError("at least one spend token is required");
54698
54916
  }
54699
54917
  if (!params.calls.length) {
54700
54918
  throw new AdapterError("at least one adapter call is required");
54701
54919
  }
54702
- if (!params.reshields.length) {
54703
- throw new AdapterError("at least one reshield output is required");
54920
+ if (!params.receive.length) {
54921
+ throw new AdapterError("at least one receive output is required");
54704
54922
  }
54705
- const inputs = params.inputs.map(
54706
- (input, i) => normalizeInputSpec(input, i)
54923
+ const spendInputs = params.spend.map(
54924
+ (input, i) => normalizeSpendInput(input, i)
54707
54925
  );
54708
54926
  const seenTokens = /* @__PURE__ */ new Set();
54709
- for (const input of inputs) {
54927
+ for (const input of spendInputs) {
54710
54928
  const lower = input.token.toLowerCase();
54711
54929
  if (seenTokens.has(lower)) {
54712
54930
  throw new AdapterError(
54713
- `duplicate input token ${input.token}; combine amounts per token instead`
54931
+ `duplicate spend token ${input.token}; combine amounts per token instead`
54714
54932
  );
54715
54933
  }
54716
54934
  seenTokens.add(lower);
54717
54935
  }
54718
54936
  const calls = params.calls.map((call, i) => normalizeCall2(call, i));
54719
- const reshieldSpecs = params.reshields.map(
54720
- (reshield, i) => normalizeReshieldSpec(reshield, i)
54937
+ const receiveSpecs = params.receive.map(
54938
+ (receive, i) => normalizeReceiveInput(receive, i)
54721
54939
  );
54940
+ const seenReceiveTokens = /* @__PURE__ */ new Set();
54941
+ for (const r2 of receiveSpecs) {
54942
+ const lower = r2.token.toLowerCase();
54943
+ if (seenReceiveTokens.has(lower)) {
54944
+ throw new AdapterError(
54945
+ `duplicate receive token ${r2.token}; each receive must target a unique token`
54946
+ );
54947
+ }
54948
+ seenReceiveTokens.add(lower);
54949
+ }
54722
54950
  const account = overrides?.account ?? await deps.requireActiveAccount();
54723
54951
  const signer = overrides?.signer ?? deps.requireSigner(account);
54724
54952
  const nowSeconds = BigInt(Math.floor(nowImpl() / 1e3));
@@ -54727,19 +54955,19 @@ function createAdapterService(deps) {
54727
54955
  throw new AdapterError("deadline must be in the future");
54728
54956
  }
54729
54957
  const executionCalls = calls;
54730
- const reshields = reshieldSpecs.map(
54731
- (reshield) => {
54958
+ const reshields = receiveSpecs.map(
54959
+ (receive) => {
54732
54960
  const random = randomFieldElement(randomBigintImpl);
54733
54961
  const npk = poseidon([account.masterPublicKey, random]);
54734
54962
  return {
54735
54963
  npk,
54736
54964
  random,
54737
- token: reshield.token,
54738
- minAmount: reshield.minAmount
54965
+ token: receive.token,
54966
+ minAmount: receive.minAmount
54739
54967
  };
54740
54968
  }
54741
54969
  );
54742
- const inputTokens = inputs.map((input) => input.token);
54970
+ const inputTokens = spendInputs.map((input) => input.token);
54743
54971
  const nonce = randomFieldElement(randomBigintImpl);
54744
54972
  const adapterDataHash = computeAdapterDataHash({
54745
54973
  calls: executionCalls,
@@ -54756,7 +54984,7 @@ function createAdapterService(deps) {
54756
54984
  });
54757
54985
  const withdrawalPlans = planWithdrawalsImpl(
54758
54986
  notes,
54759
- inputs.map((input) => ({
54987
+ spendInputs.map((input) => ({
54760
54988
  token: input.token,
54761
54989
  amount: input.amount,
54762
54990
  recipient: adapterAddress
@@ -54839,7 +55067,7 @@ function createAdapterService(deps) {
54839
55067
  adapterCalldata,
54840
55068
  historyPreview: {
54841
55069
  kind: "Withdraw",
54842
- amounts: inputs.map((input) => ({
55070
+ amounts: spendInputs.map((input) => ({
54843
55071
  token: input.token,
54844
55072
  delta: (-input.amount).toString()
54845
55073
  }))
@@ -54861,6 +55089,9 @@ init_process();
54861
55089
  init_buffer();
54862
55090
  var BIP44_ETH_PREFIX = "m/44'/60'/0'/0";
54863
55091
  var ERC20_BALANCE_OF = "function balanceOf(address) view returns (uint256)";
55092
+ function isNativeToken(token) {
55093
+ return token.toLowerCase() === ETH_TOKEN.toLowerCase();
55094
+ }
54864
55095
  function createBurnerService(deps) {
54865
55096
  const { chainRpcUrl, getMasterSeed, withdrawToAddress, requestDeposit } = deps;
54866
55097
  const provider = new JsonRpcProvider(chainRpcUrl);
@@ -54908,8 +55139,8 @@ function createBurnerService(deps) {
54908
55139
  }
54909
55140
  async function getTokenBalance(address, token) {
54910
55141
  const iface = new Interface([ERC20_BALANCE_OF]);
54911
- const contract = new Contract(token, iface, provider);
54912
- const bal = await contract.getFunction("balanceOf")(address);
55142
+ const contract2 = new Contract(token, iface, provider);
55143
+ const bal = await contract2.getFunction("balanceOf")(address);
54913
55144
  return BigInt(bal ?? 0);
54914
55145
  }
54915
55146
  async function getBalance(address) {
@@ -54928,6 +55159,12 @@ function createBurnerService(deps) {
54928
55159
  }
54929
55160
  async function sweepToPool(index, params) {
54930
55161
  const { address } = await addressOf(index);
55162
+ const native = isNativeToken(params.token);
55163
+ if (native && params.amount == null) {
55164
+ throw new Error(
55165
+ "amount is required for native ETH sweeps (needed to reserve gas)"
55166
+ );
55167
+ }
54931
55168
  const amount = params.amount ?? await getTokenBalance(address, params.token);
54932
55169
  if (amount === 0n) {
54933
55170
  throw new Error("No token balance to sweep");
@@ -54938,17 +55175,20 @@ function createBurnerService(deps) {
54938
55175
  depositor: address,
54939
55176
  deposits: [{ token: params.token, amount }]
54940
55177
  });
54941
- const erc20Iface = new Interface([
54942
- "function approve(address spender, uint256 amount)"
54943
- ]);
54944
- const approveData = erc20Iface.encodeFunctionData("approve", [
54945
- params.poolAddress,
54946
- amount
54947
- ]);
54948
- await send(index, { to: params.token, data: approveData });
55178
+ if (!native) {
55179
+ const erc20Iface = new Interface([
55180
+ "function approve(address spender, uint256 amount)"
55181
+ ]);
55182
+ const approveData = erc20Iface.encodeFunctionData("approve", [
55183
+ params.poolAddress,
55184
+ amount
55185
+ ]);
55186
+ await send(index, { to: params.token, data: approveData });
55187
+ }
54949
55188
  const { txHash } = await send(index, {
54950
55189
  to: depositResult.to,
54951
- data: depositResult.calldata
55190
+ data: depositResult.calldata,
55191
+ value: depositResult.value
54952
55192
  });
54953
55193
  return { txHash };
54954
55194
  }
@@ -55604,28 +55844,31 @@ function createWalletSDK(deps, options) {
55604
55844
  return sdk;
55605
55845
  }
55606
55846
  async function createBrowserWalletSDK(options) {
55847
+ let chainId;
55607
55848
  let gatewayUrl;
55608
55849
  let poolAddress;
55609
55850
  let prover = options.prover;
55610
- if ("gatewayUrl" in options) {
55851
+ if ("chain" in options) {
55852
+ const chainConfig = await fetchChainConfig(options.chain);
55853
+ chainId = chainConfig.chainId;
55854
+ gatewayUrl = chainConfig.gatewayUrl;
55855
+ poolAddress = options.poolAddress ?? chainConfig.poolAddress;
55856
+ prover = {
55857
+ artifactSource: {
55858
+ baseUrl: options.prover?.artifactSource?.baseUrl ?? chainConfig.artifactBaseUrl,
55859
+ version: options.prover?.artifactSource?.version ?? chainConfig.artifactVersion,
55860
+ preferLocalFiles: options.prover?.artifactSource?.preferLocalFiles
55861
+ }
55862
+ };
55863
+ } else {
55864
+ chainId = options.chainId;
55611
55865
  gatewayUrl = options.gatewayUrl;
55612
55866
  poolAddress = options.poolAddress;
55613
55867
  if (typeof window !== "undefined" && !options.prover?.artifactSource?.version) {
55614
55868
  throw new InitializationError(
55615
- "prover.artifactSource.version is required in browser when using explicit gatewayUrl mode. Use environment mode or provide a pinned artifact version."
55869
+ "prover.artifactSource.version is required in browser when using explicit gatewayUrl mode. Use chain mode or provide a pinned artifact version."
55616
55870
  );
55617
55871
  }
55618
- } else {
55619
- const envConfig = await fetchEnvironmentConfig(options.environment);
55620
- gatewayUrl = envConfig.gatewayUrl;
55621
- poolAddress = options.poolAddress ?? envConfig.poolAddress;
55622
- prover = {
55623
- artifactSource: {
55624
- baseUrl: options.prover?.artifactSource?.baseUrl ?? envConfig.artifactBaseUrl,
55625
- version: options.prover?.artifactSource?.version ?? envConfig.artifactVersion,
55626
- preferLocalFiles: options.prover?.artifactSource?.preferLocalFiles
55627
- }
55628
- };
55629
55872
  }
55630
55873
  const storage = createIndexedDbStorage({ name: "unlink-wallet" });
55631
55874
  const rng = (n2) => {
@@ -55642,7 +55885,7 @@ async function createBrowserWalletSDK(options) {
55642
55885
  core,
55643
55886
  fetch: globalThis.fetch
55644
55887
  },
55645
- { chainId: options.chainId, gatewayUrl, prover }
55888
+ { chainId, gatewayUrl, prover }
55646
55889
  );
55647
55890
  return {
55648
55891
  sdk,
@@ -55655,51 +55898,63 @@ async function createBrowserWalletSDK(options) {
55655
55898
  };
55656
55899
  }
55657
55900
 
55658
- // wallet/unlink-wallet.ts
55659
- var UnlinkWallet = class _UnlinkWallet {
55901
+ // wallet/unlink.ts
55902
+ var Unlink = class _Unlink {
55660
55903
  /** @internal */
55661
55904
  sdk;
55662
55905
  /** Chain ID this wallet operates on. */
55663
55906
  chainId;
55664
55907
  /** Pool contract address this wallet transacts with. */
55665
55908
  poolAddress;
55666
- constructor(sdk, chainId, poolAddress) {
55909
+ /** Adapter contract address for DeFi operations. */
55910
+ adapterAddress;
55911
+ constructor(sdk, chainId, poolAddress, adapterAddress) {
55667
55912
  this.sdk = sdk;
55668
55913
  this.chainId = chainId;
55669
55914
  this.poolAddress = poolAddress;
55915
+ this.adapterAddress = adapterAddress;
55916
+ this.adapter = {
55917
+ address: adapterAddress
55918
+ };
55670
55919
  }
55671
55920
  /**
55672
- * Create a new UnlinkWallet instance.
55921
+ * Create a new Unlink instance.
55673
55922
  *
55674
55923
  * Handles all initialization internally:
55675
- * - Resolves environment config (if using `environment` instead of explicit URLs)
55924
+ * - Resolves chain config (if using `chain` instead of explicit URLs)
55676
55925
  * - Auto-detects storage (IndexedDB in browser) and rng (crypto.getRandomValues)
55677
55926
  * - Runs schema migration via `initCore()`
55678
55927
  * - Creates the internal SDK
55679
55928
  */
55680
55929
  static async create(config2) {
55930
+ let chainId;
55681
55931
  let gatewayUrl;
55682
55932
  let poolAddress;
55933
+ let adapterAddress;
55683
55934
  let proverConfig = config2.prover;
55684
- if ("gatewayUrl" in config2) {
55935
+ if ("chain" in config2) {
55936
+ const chainConfig = await fetchChainConfig(config2.chain);
55937
+ chainId = chainConfig.chainId;
55938
+ gatewayUrl = chainConfig.gatewayUrl;
55939
+ poolAddress = config2.poolAddress ?? chainConfig.poolAddress;
55940
+ adapterAddress = config2.adapterAddress ?? chainConfig.adapterAddress;
55941
+ proverConfig = {
55942
+ artifactSource: {
55943
+ baseUrl: config2.prover?.artifactSource?.baseUrl ?? chainConfig.artifactBaseUrl,
55944
+ version: config2.prover?.artifactSource?.version ?? chainConfig.artifactVersion,
55945
+ preferLocalFiles: config2.prover?.artifactSource?.preferLocalFiles
55946
+ }
55947
+ };
55948
+ } else {
55949
+ chainId = config2.chainId;
55685
55950
  gatewayUrl = config2.gatewayUrl;
55686
55951
  poolAddress = config2.poolAddress;
55952
+ adapterAddress = config2.adapterAddress;
55687
55953
  if (typeof window !== "undefined" && !config2.prover?.artifactSource?.version) {
55688
55954
  throw new InitializationError(
55689
- "prover.artifactSource.version is required in browser when using explicit gatewayUrl mode. Use environment mode or provide a pinned artifact version."
55955
+ "prover.artifactSource.version is required in browser when using explicit gatewayUrl mode. Use chain mode or provide a pinned artifact version."
55690
55956
  );
55691
55957
  }
55692
- } else {
55693
- const envConfig = await fetchEnvironmentConfig(config2.environment);
55694
- gatewayUrl = envConfig.gatewayUrl;
55695
- poolAddress = config2.poolAddress ?? envConfig.poolAddress;
55696
- proverConfig = {
55697
- artifactSource: {
55698
- baseUrl: config2.prover?.artifactSource?.baseUrl ?? envConfig.artifactBaseUrl,
55699
- version: config2.prover?.artifactSource?.version ?? envConfig.artifactVersion,
55700
- preferLocalFiles: config2.prover?.artifactSource?.preferLocalFiles
55701
- }
55702
- };
55703
55958
  }
55704
55959
  const storage = config2.storage ?? detectStorage();
55705
55960
  const rng = config2.rng ?? defaultRng;
@@ -55708,14 +55963,14 @@ var UnlinkWallet = class _UnlinkWallet {
55708
55963
  const sdk = createWalletSDK(
55709
55964
  { core, fetch: fetchImpl },
55710
55965
  {
55711
- chainId: config2.chainId,
55966
+ chainId,
55712
55967
  gatewayUrl,
55713
55968
  chainRpcUrl: config2.chainRpcUrl,
55714
55969
  prover: proverConfig,
55715
55970
  autoSync: config2.autoSync
55716
55971
  }
55717
55972
  );
55718
- return new _UnlinkWallet(sdk, config2.chainId, poolAddress);
55973
+ return new _Unlink(sdk, chainId, poolAddress, adapterAddress ?? "");
55719
55974
  }
55720
55975
  // ===== Seed Lifecycle =====
55721
55976
  /** Seed management (create, import, export, delete mnemonic). */
@@ -55746,10 +56001,10 @@ var UnlinkWallet = class _UnlinkWallet {
55746
56001
  return this.sdk.deposit.reconcile(relayId);
55747
56002
  }
55748
56003
  /**
55749
- * Execute a private transfer (1 or more recipients).
56004
+ * Send a private transfer (1 or more recipients).
55750
56005
  * Handles note selection, circuit selection, and proof generation automatically.
55751
56006
  */
55752
- async transfer(params, overrides) {
56007
+ async send(params, overrides) {
55753
56008
  return this.sdk.transfer.send(
55754
56009
  {
55755
56010
  chainId: this.chainId,
@@ -55760,9 +56015,9 @@ var UnlinkWallet = class _UnlinkWallet {
55760
56015
  );
55761
56016
  }
55762
56017
  /**
55763
- * Get a transfer plan without executing (for preview/confirmation UIs).
56018
+ * Get a send plan without executing (for preview/confirmation UIs).
55764
56019
  */
55765
- async planTransfer(params, account) {
56020
+ async planSend(params, account) {
55766
56021
  return this.sdk.transfer.plan(
55767
56022
  {
55768
56023
  chainId: this.chainId,
@@ -55772,8 +56027,8 @@ var UnlinkWallet = class _UnlinkWallet {
55772
56027
  account
55773
56028
  );
55774
56029
  }
55775
- /** Execute a pre-built transfer plan. */
55776
- async executeTransfer(plans, overrides) {
56030
+ /** Execute a pre-built send plan. */
56031
+ async executeSend(plans, overrides) {
55777
56032
  return this.sdk.transfer.execute(
55778
56033
  plans,
55779
56034
  { chainId: this.chainId, poolAddress: this.poolAddress },
@@ -55922,31 +56177,31 @@ var UnlinkWallet = class _UnlinkWallet {
55922
56177
  return this.sdk.burner.getBalance(address);
55923
56178
  }
55924
56179
  };
55925
- // ===== Adapter =====
56180
+ // ===== Interact (Private DeFi) =====
55926
56181
  /**
55927
- * Private DeFi adapter operations.
55928
- * chainId/poolAddress are injected automatically.
56182
+ * Adapter contract address (resolved from config).
56183
+ * Use for building DeFi calls that reference the adapter.
55929
56184
  */
55930
- adapter = {
55931
- /**
55932
- * Execute an atomic unshield -> call(s) -> reshield flow through an adapter.
55933
- */
55934
- execute: (params, opts, overrides) => {
55935
- return this.sdk.adapter.execute(
55936
- {
55937
- chainId: this.chainId,
55938
- poolAddress: this.poolAddress,
55939
- adapterAddress: params.adapterAddress,
55940
- inputs: params.inputs,
55941
- calls: params.calls,
55942
- reshields: params.reshields,
55943
- deadline: params.deadline
55944
- },
55945
- opts,
55946
- overrides
55947
- );
55948
- }
55949
- };
56185
+ adapter;
56186
+ /**
56187
+ * Execute an atomic unshield -> DeFi call(s) -> reshield flow through an adapter.
56188
+ * chainId/poolAddress/adapterAddress are injected automatically.
56189
+ */
56190
+ async interact(params, opts, overrides) {
56191
+ return this.sdk.adapter.execute(
56192
+ {
56193
+ chainId: this.chainId,
56194
+ poolAddress: this.poolAddress,
56195
+ adapterAddress: this.adapterAddress,
56196
+ spend: params.spend,
56197
+ calls: params.calls,
56198
+ receive: params.receive,
56199
+ deadline: params.deadline
56200
+ },
56201
+ opts,
56202
+ overrides
56203
+ );
56204
+ }
55950
56205
  // ===== Advanced =====
55951
56206
  /**
55952
56207
  * Advanced escape hatch for raw JoinSplit transaction building.
@@ -55994,12 +56249,14 @@ var defaultRng = (n2) => {
55994
56249
  }
55995
56250
  return globalThis.crypto.getRandomValues(new Uint8Array(n2));
55996
56251
  };
56252
+ var UnlinkWallet = Unlink;
55997
56253
  export {
55998
56254
  ADAPTER_EXECUTE_ABI,
55999
56255
  AdapterError,
56000
56256
  CORE_SCHEMA_VERSION,
56001
56257
  CoreError,
56002
56258
  DEFAULT_JOB_TIMEOUT_MS,
56259
+ DEFAULT_RPC_URLS,
56003
56260
  DEPOSIT_ABI,
56004
56261
  ETH_TOKEN,
56005
56262
  FieldSize,
@@ -56017,8 +56274,10 @@ export {
56017
56274
  ReconcileError,
56018
56275
  SNARK_SCALAR_FIELD,
56019
56276
  SchemaMismatchError,
56277
+ Unlink,
56020
56278
  UnlinkWallet,
56021
56279
  ValidationError,
56280
+ approve,
56022
56281
  assertNonNegative,
56023
56282
  buildApproveCall,
56024
56283
  buildCall,
@@ -56028,6 +56287,7 @@ export {
56028
56287
  computeCommitment,
56029
56288
  computeMasterPublicKey,
56030
56289
  computeNullifyingKey,
56290
+ contract,
56031
56291
  createBroadcasterClient,
56032
56292
  createBrowserWalletSDK,
56033
56293
  createCiphertextStore,
@@ -56069,7 +56329,7 @@ export {
56069
56329
  ensureNoteCommitmentInput,
56070
56330
  ensurePositiveInt,
56071
56331
  ensureWithdrawalInput,
56072
- fetchEnvironmentConfig,
56332
+ fetchChainConfig,
56073
56333
  formatAmount,
56074
56334
  formatUint256,
56075
56335
  generateMasterSeed,
@@ -56100,6 +56360,7 @@ export {
56100
56360
  syncDeposit,
56101
56361
  syncTransact,
56102
56362
  toAccountView,
56363
+ toCall,
56103
56364
  transact,
56104
56365
  validateKey,
56105
56366
  verifySignature,