@arkade-os/sdk 0.4.76 → 0.4.77

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 (87) hide show
  1. package/dist/adapters/expo.cjs +5 -5
  2. package/dist/adapters/expo.d.cts +2 -2
  3. package/dist/adapters/expo.d.ts +2 -2
  4. package/dist/adapters/expo.js +3 -3
  5. package/dist/adapters/indexedDB.cjs +3 -5
  6. package/dist/adapters/indexedDB.cjs.map +1 -1
  7. package/dist/adapters/indexedDB.d.cts +1 -1
  8. package/dist/adapters/indexedDB.d.ts +1 -1
  9. package/dist/adapters/indexedDB.js +3 -5
  10. package/dist/adapters/indexedDB.js.map +1 -1
  11. package/dist/{asyncStorageTaskQueue-DrKbfleJ.d.ts → asyncStorageTaskQueue-DTl0WM7E.d.ts} +1 -1
  12. package/dist/{asyncStorageTaskQueue-D7BU-BdP.d.cts → asyncStorageTaskQueue-MmJyAnu-.d.cts} +1 -1
  13. package/dist/{chunk-2KFXM3N5.cjs → chunk-4LP6XOMW.cjs} +17 -17
  14. package/dist/{chunk-2KFXM3N5.cjs.map → chunk-4LP6XOMW.cjs.map} +1 -1
  15. package/dist/{chunk-F6YOCYWU.js → chunk-52OA3UIC.js} +25 -12
  16. package/dist/chunk-52OA3UIC.js.map +1 -0
  17. package/dist/{chunk-7UJLIZQU.js → chunk-ACPANSOX.js} +43 -11
  18. package/dist/chunk-ACPANSOX.js.map +1 -0
  19. package/dist/{chunk-P53OHGXY.cjs → chunk-CJN4CUEU.cjs} +25 -11
  20. package/dist/chunk-CJN4CUEU.cjs.map +1 -0
  21. package/dist/{chunk-T327OEMV.cjs → chunk-H62OOAS4.cjs} +17 -17
  22. package/dist/{chunk-T327OEMV.cjs.map → chunk-H62OOAS4.cjs.map} +1 -1
  23. package/dist/{chunk-54W6QBXL.js → chunk-HKOFYHZP.js} +3 -3
  24. package/dist/{chunk-54W6QBXL.js.map → chunk-HKOFYHZP.js.map} +1 -1
  25. package/dist/{chunk-CQNX4BTA.cjs → chunk-LUWSY2QO.cjs} +89 -57
  26. package/dist/chunk-LUWSY2QO.cjs.map +1 -0
  27. package/dist/{chunk-WMHELOHH.js → chunk-MLOZHTBN.js} +523 -104
  28. package/dist/chunk-MLOZHTBN.js.map +1 -0
  29. package/dist/{chunk-O2BIWLZC.js → chunk-T6MGH4V4.js} +4 -4
  30. package/dist/{chunk-O2BIWLZC.js.map → chunk-T6MGH4V4.js.map} +1 -1
  31. package/dist/{chunk-LQM6RHNT.cjs → chunk-Y4YK44IM.cjs} +10 -10
  32. package/dist/{chunk-LQM6RHNT.cjs.map → chunk-Y4YK44IM.cjs.map} +1 -1
  33. package/dist/{chunk-LHSVPDFJ.cjs → chunk-YJEWWLOQ.cjs} +959 -541
  34. package/dist/chunk-YJEWWLOQ.cjs.map +1 -0
  35. package/dist/{chunk-MUBPGYUE.js → chunk-YKNTUOUG.js} +4 -4
  36. package/dist/{chunk-MUBPGYUE.js.map → chunk-YKNTUOUG.js.map} +1 -1
  37. package/dist/contracts/handlers/index.cjs +9 -9
  38. package/dist/contracts/handlers/index.d.cts +3 -3
  39. package/dist/contracts/handlers/index.d.ts +3 -3
  40. package/dist/contracts/handlers/index.js +2 -2
  41. package/dist/{delegate-BAYpqkEx.d.ts → delegate-CjcysR7s.d.ts} +1 -1
  42. package/dist/{delegate-CR7msIXK.d.cts → delegate-QPCGaD_z.d.cts} +1 -1
  43. package/dist/{hdWalletCapable-BSF29IjK.d.ts → hdWalletCapable--pMncWbC.d.ts} +6 -4
  44. package/dist/{hdWalletCapable-BbZxCUeZ.d.cts → hdWalletCapable-Bp_p0WLj.d.cts} +6 -4
  45. package/dist/{index-4NF3srcg.d.cts → index-BMY272ns.d.cts} +26 -8
  46. package/dist/{index-B_RYn9rg.d.cts → index-Ie_ak2zY.d.cts} +35 -9
  47. package/dist/{index-B_RYn9rg.d.ts → index-Ie_ak2zY.d.ts} +35 -9
  48. package/dist/{index-Dj2yOhQ2.d.ts → index-m-EM-e8D.d.ts} +26 -8
  49. package/dist/index.cjs +307 -303
  50. package/dist/index.d.cts +75 -13
  51. package/dist/index.d.ts +75 -13
  52. package/dist/index.js +4 -4
  53. package/dist/repositories/realm/index.cjs +36 -19
  54. package/dist/repositories/realm/index.cjs.map +1 -1
  55. package/dist/repositories/realm/index.d.cts +6 -3
  56. package/dist/repositories/realm/index.d.ts +6 -3
  57. package/dist/repositories/realm/index.js +22 -5
  58. package/dist/repositories/realm/index.js.map +1 -1
  59. package/dist/repositories/sqlite/index.cjs +42 -18
  60. package/dist/repositories/sqlite/index.cjs.map +1 -1
  61. package/dist/repositories/sqlite/index.d.cts +5 -2
  62. package/dist/repositories/sqlite/index.d.ts +5 -2
  63. package/dist/repositories/sqlite/index.js +29 -5
  64. package/dist/repositories/sqlite/index.js.map +1 -1
  65. package/dist/{taskRunner-DGxde-YU.d.cts → taskRunner-BgRowCqB.d.cts} +1 -1
  66. package/dist/{taskRunner-TzGUhxP-.d.ts → taskRunner-CqrlrJEt.d.ts} +1 -1
  67. package/dist/wallet/expo/background.cjs +14 -14
  68. package/dist/wallet/expo/background.d.cts +3 -3
  69. package/dist/wallet/expo/background.d.ts +3 -3
  70. package/dist/wallet/expo/background.js +6 -6
  71. package/dist/wallet/expo/index.cjs +14 -14
  72. package/dist/wallet/expo/index.cjs.map +1 -1
  73. package/dist/wallet/expo/index.d.cts +5 -5
  74. package/dist/wallet/expo/index.d.ts +5 -5
  75. package/dist/wallet/expo/index.js +5 -5
  76. package/dist/wallet/expo/index.js.map +1 -1
  77. package/dist/worker/expo/index.cjs +9 -9
  78. package/dist/worker/expo/index.d.cts +4 -4
  79. package/dist/worker/expo/index.d.ts +4 -4
  80. package/dist/worker/expo/index.js +5 -5
  81. package/package.json +1 -1
  82. package/dist/chunk-7UJLIZQU.js.map +0 -1
  83. package/dist/chunk-CQNX4BTA.cjs.map +0 -1
  84. package/dist/chunk-F6YOCYWU.js.map +0 -1
  85. package/dist/chunk-LHSVPDFJ.cjs.map +0 -1
  86. package/dist/chunk-P53OHGXY.cjs.map +0 -1
  87. package/dist/chunk-WMHELOHH.js.map +0 -1
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- var chunkP53OHGXY_cjs = require('./chunk-P53OHGXY.cjs');
3
+ var chunkCJN4CUEU_cjs = require('./chunk-CJN4CUEU.cjs');
4
4
  var chunk5BLDMQED_cjs = require('./chunk-5BLDMQED.cjs');
5
5
  var base = require('@scure/base');
6
6
  var descriptorsScure = require('@bitcoinerlab/descriptors-scure');
@@ -76,14 +76,14 @@ var ContractHandlerRegistry = class {
76
76
  var contractHandlers = new ContractHandlerRegistry();
77
77
  exports.DefaultVtxo = void 0;
78
78
  ((DefaultVtxo2) => {
79
- class Script3 extends chunkP53OHGXY_cjs.VtxoScript {
79
+ class Script3 extends chunkCJN4CUEU_cjs.VtxoScript {
80
80
  /** Create the default virtual output script with one forfeit path and one exit path. */
81
81
  constructor(options) {
82
82
  const { pubKey, serverPubKey, csvTimelock } = options;
83
- const forfeitScript = chunkP53OHGXY_cjs.MultisigTapscript.encode({
83
+ const forfeitScript = chunkCJN4CUEU_cjs.MultisigTapscript.encode({
84
84
  pubkeys: [pubKey, serverPubKey]
85
85
  }).script;
86
- const exitScript = chunkP53OHGXY_cjs.CSVMultisigTapscript.encode({
86
+ const exitScript = chunkCJN4CUEU_cjs.CSVMultisigTapscript.encode({
87
87
  timelock: csvTimelock,
88
88
  pubkeys: [pubKey]
89
89
  }).script;
@@ -288,7 +288,7 @@ function extractPubKeyBytes(value) {
288
288
  return base.hex.decode(extractPubKey(normalizeToDescriptor(value)));
289
289
  }
290
290
  function deserializeCsvTimelock(value) {
291
- return value !== void 0 && value !== "" ? chunkP53OHGXY_cjs.sequenceToTimelock(Number(value)) : exports.DefaultVtxo.Script.DEFAULT_TIMELOCK;
291
+ return value !== void 0 && value !== "" ? chunkCJN4CUEU_cjs.sequenceToTimelock(Number(value)) : exports.DefaultVtxo.Script.DEFAULT_TIMELOCK;
292
292
  }
293
293
  var CLTV_HEIGHT_THRESHOLD = 500000000n;
294
294
  function isCltvSatisfied(context, locktime) {
@@ -330,7 +330,7 @@ function assertVhtlcSpendableNow(contract, context) {
330
330
  function isCsvSpendable(context, sequence) {
331
331
  if (sequence === void 0) return true;
332
332
  if (!context.vtxo) return false;
333
- const timelock = chunkP53OHGXY_cjs.sequenceToTimelock(sequence);
333
+ const timelock = chunkCJN4CUEU_cjs.sequenceToTimelock(sequence);
334
334
  if (timelock.type === "blocks") {
335
335
  if (context.blockHeight === void 0 || context.vtxo.status.block_height === void 0) {
336
336
  return false;
@@ -388,21 +388,21 @@ function forfeitExitSpendablePaths(script, contract, context) {
388
388
  async function detectUsedScripts(indexerProvider, scriptHexes) {
389
389
  const used = /* @__PURE__ */ new Set();
390
390
  const unique = [...new Set(scriptHexes)];
391
- for (let offset = 0; offset < unique.length; offset += chunkP53OHGXY_cjs.SCRIPT_QUERY_CHUNK_SIZE) {
392
- const scripts = unique.slice(offset, offset + chunkP53OHGXY_cjs.SCRIPT_QUERY_CHUNK_SIZE);
391
+ for (let offset = 0; offset < unique.length; offset += chunkCJN4CUEU_cjs.SCRIPT_QUERY_CHUNK_SIZE) {
392
+ const scripts = unique.slice(offset, offset + chunkCJN4CUEU_cjs.SCRIPT_QUERY_CHUNK_SIZE);
393
393
  const remaining = new Set(scripts);
394
394
  let pageIndex = 0;
395
395
  let hasMore = true;
396
396
  while (hasMore && remaining.size > 0) {
397
- const { vtxos, page } = await chunkP53OHGXY_cjs.getNormalizedVtxos(indexerProvider, {
397
+ const { vtxos, page } = await chunkCJN4CUEU_cjs.getNormalizedVtxos(indexerProvider, {
398
398
  scripts,
399
399
  pageIndex,
400
- pageSize: chunkP53OHGXY_cjs.DEFAULT_PAGE_SIZE
400
+ pageSize: chunkCJN4CUEU_cjs.DEFAULT_PAGE_SIZE
401
401
  });
402
402
  for (const vtxo of vtxos) {
403
403
  if (remaining.delete(vtxo.script)) used.add(vtxo.script);
404
404
  }
405
- hasMore = page ? vtxos.length === chunkP53OHGXY_cjs.DEFAULT_PAGE_SIZE : false;
405
+ hasMore = page ? vtxos.length === chunkCJN4CUEU_cjs.DEFAULT_PAGE_SIZE : false;
406
406
  pageIndex++;
407
407
  }
408
408
  }
@@ -463,7 +463,7 @@ var DefaultContractHandler = {
463
463
  return {
464
464
  pubKey: base.hex.encode(params.pubKey),
465
465
  serverPubKey: base.hex.encode(params.serverPubKey),
466
- csvTimelock: chunkP53OHGXY_cjs.timelockToSequence(params.csvTimelock).toString()
466
+ csvTimelock: chunkCJN4CUEU_cjs.timelockToSequence(params.csvTimelock).toString()
467
467
  };
468
468
  },
469
469
  deserializeParams(params) {
@@ -498,7 +498,7 @@ function defaultCandidatesAt(_index, descriptor, deps) {
498
498
  params: {
499
499
  pubKey: base.hex.encode(c.pubKey),
500
500
  serverPubKey: base.hex.encode(c.serverPubKey),
501
- csvTimelock: chunkP53OHGXY_cjs.timelockToSequence(c.csvTimelock).toString()
501
+ csvTimelock: chunkCJN4CUEU_cjs.timelockToSequence(c.csvTimelock).toString()
502
502
  },
503
503
  script: c.scriptHex,
504
504
  address: c.script.address(deps.network.hrp, c.serverPubKey).encode()
@@ -514,12 +514,12 @@ function discoverDefaultRange(entries, deps) {
514
514
  }
515
515
  exports.DelegateVtxo = void 0;
516
516
  ((DelegateVtxo2) => {
517
- class Script3 extends chunkP53OHGXY_cjs.VtxoScript {
517
+ class Script3 extends chunkCJN4CUEU_cjs.VtxoScript {
518
518
  /** Create a delegated virtual output script with forfeit, exit, and delegate paths. */
519
519
  constructor(options) {
520
520
  const defaultVtxo = new exports.DefaultVtxo.Script(options);
521
521
  const { delegatePubKey, pubKey, serverPubKey } = options;
522
- const delegateScript = chunkP53OHGXY_cjs.MultisigTapscript.encode({
522
+ const delegateScript = chunkCJN4CUEU_cjs.MultisigTapscript.encode({
523
523
  pubkeys: [pubKey, delegatePubKey, serverPubKey]
524
524
  }).script;
525
525
  super([...defaultVtxo.scripts, delegateScript]);
@@ -558,7 +558,7 @@ var DelegateContractHandler = {
558
558
  pubKey: base.hex.encode(params.pubKey),
559
559
  serverPubKey: base.hex.encode(params.serverPubKey),
560
560
  delegatePubKey: base.hex.encode(params.delegatePubKey),
561
- csvTimelock: chunkP53OHGXY_cjs.timelockToSequence(params.csvTimelock).toString()
561
+ csvTimelock: chunkCJN4CUEU_cjs.timelockToSequence(params.csvTimelock).toString()
562
562
  };
563
563
  },
564
564
  deserializeParams(params) {
@@ -602,7 +602,7 @@ function delegateCandidatesAt(_index, descriptor, deps) {
602
602
  pubKey: base.hex.encode(c.pubKey),
603
603
  serverPubKey: base.hex.encode(c.serverPubKey),
604
604
  delegatePubKey: base.hex.encode(delegatePubKey),
605
- csvTimelock: chunkP53OHGXY_cjs.timelockToSequence(c.csvTimelock).toString()
605
+ csvTimelock: chunkCJN4CUEU_cjs.timelockToSequence(c.csvTimelock).toString()
606
606
  },
607
607
  script: c.scriptHex,
608
608
  address: c.script.address(deps.network.hrp, c.serverPubKey).encode()
@@ -1161,7 +1161,6 @@ var ARKADE_OP = {
1161
1161
  MODEXP: 218,
1162
1162
  // VTXO Expiry & Emulator Clock (0xdb-0xdc)
1163
1163
  PUSHEXPIRY: 219,
1164
- // compiler artifacts use OP_CHECKTIME.
1165
1164
  CHECKTIME: 220,
1166
1165
  // 0xdd-0xdf are unassigned (OP_UNKNOWN221-223)
1167
1166
  // EC Operations (0xe0-0xe2)
@@ -1452,7 +1451,7 @@ function computeArkadeScriptPublicKey(pubKey, script) {
1452
1451
  // src/script/vhtlc.ts
1453
1452
  exports.VHTLC = void 0;
1454
1453
  ((VHTLC2) => {
1455
- class BaseScript extends chunkP53OHGXY_cjs.VtxoScript {
1454
+ class BaseScript extends chunkCJN4CUEU_cjs.VtxoScript {
1456
1455
  options;
1457
1456
  claimScript;
1458
1457
  refundScript;
@@ -1479,27 +1478,27 @@ exports.VHTLC = void 0;
1479
1478
  unilateralRefundWithoutReceiverDelay
1480
1479
  } = options;
1481
1480
  const conditionScript = preimageCondition(preimageHash);
1482
- const claimScript = chunkP53OHGXY_cjs.ConditionMultisigTapscript.encode({
1481
+ const claimScript = chunkCJN4CUEU_cjs.ConditionMultisigTapscript.encode({
1483
1482
  conditionScript,
1484
1483
  pubkeys: [receiver, server]
1485
1484
  }).script;
1486
- const refundScript = chunkP53OHGXY_cjs.MultisigTapscript.encode({
1485
+ const refundScript = chunkCJN4CUEU_cjs.MultisigTapscript.encode({
1487
1486
  pubkeys: [sender, receiver, server]
1488
1487
  }).script;
1489
- const refundWithoutReceiverScript = chunkP53OHGXY_cjs.CLTVMultisigTapscript.encode({
1488
+ const refundWithoutReceiverScript = chunkCJN4CUEU_cjs.CLTVMultisigTapscript.encode({
1490
1489
  absoluteTimelock: refundLocktime,
1491
1490
  pubkeys: [sender, server]
1492
1491
  }).script;
1493
- const unilateralClaimScript = chunkP53OHGXY_cjs.ConditionCSVMultisigTapscript.encode({
1492
+ const unilateralClaimScript = chunkCJN4CUEU_cjs.ConditionCSVMultisigTapscript.encode({
1494
1493
  conditionScript,
1495
1494
  timelock: unilateralClaimDelay,
1496
1495
  pubkeys: [receiver]
1497
1496
  }).script;
1498
- const unilateralRefundScript = chunkP53OHGXY_cjs.CSVMultisigTapscript.encode({
1497
+ const unilateralRefundScript = chunkCJN4CUEU_cjs.CSVMultisigTapscript.encode({
1499
1498
  timelock: unilateralRefundDelay,
1500
1499
  pubkeys: [sender, receiver]
1501
1500
  }).script;
1502
- const unilateralRefundWithoutReceiverScript = chunkP53OHGXY_cjs.CSVMultisigTapscript.encode({
1501
+ const unilateralRefundWithoutReceiverScript = chunkCJN4CUEU_cjs.CSVMultisigTapscript.encode({
1503
1502
  timelock: unilateralRefundWithoutReceiverDelay,
1504
1503
  pubkeys: [sender]
1505
1504
  }).script;
@@ -1519,7 +1518,7 @@ exports.VHTLC = void 0;
1519
1518
  const covenants = options.nonInteractiveParameters;
1520
1519
  if (covenants) {
1521
1520
  arkadeScriptNic = enforcePayToMaybeAsset(covenants.receiverPkScript, options.asset);
1522
- nonInteractiveClaimScript = chunkP53OHGXY_cjs.ConditionMultisigTapscript.encode({
1521
+ nonInteractiveClaimScript = chunkCJN4CUEU_cjs.ConditionMultisigTapscript.encode({
1523
1522
  conditionScript,
1524
1523
  pubkeys: [
1525
1524
  server,
@@ -1532,12 +1531,12 @@ exports.VHTLC = void 0;
1532
1531
  covenants.emulatorPubkey,
1533
1532
  arkadeScriptNir
1534
1533
  );
1535
- nonInteractiveRefundScript = chunkP53OHGXY_cjs.MultisigTapscript.encode({
1534
+ nonInteractiveRefundScript = chunkCJN4CUEU_cjs.MultisigTapscript.encode({
1536
1535
  pubkeys: [server, receiver, nirCosigner]
1537
1536
  }).script;
1538
1537
  scripts.push(nonInteractiveRefundScript);
1539
1538
  if (covenants.legacy !== "preTimelockedRefund") {
1540
- nonInteractiveRefundWithoutReceiverScript = chunkP53OHGXY_cjs.CLTVMultisigTapscript.encode({
1539
+ nonInteractiveRefundWithoutReceiverScript = chunkCJN4CUEU_cjs.CLTVMultisigTapscript.encode({
1541
1540
  absoluteTimelock: refundLocktime,
1542
1541
  pubkeys: [server, nirCosigner]
1543
1542
  }).script;
@@ -1851,9 +1850,9 @@ var VHTLCContractHandler = {
1851
1850
  server: base.hex.encode(params.server),
1852
1851
  hash: base.hex.encode(params.preimageHash),
1853
1852
  refundLocktime: params.refundLocktime.toString(),
1854
- claimDelay: chunkP53OHGXY_cjs.timelockToSequence(params.unilateralClaimDelay).toString(),
1855
- refundDelay: chunkP53OHGXY_cjs.timelockToSequence(params.unilateralRefundDelay).toString(),
1856
- refundNoReceiverDelay: chunkP53OHGXY_cjs.timelockToSequence(
1853
+ claimDelay: chunkCJN4CUEU_cjs.timelockToSequence(params.unilateralClaimDelay).toString(),
1854
+ refundDelay: chunkCJN4CUEU_cjs.timelockToSequence(params.unilateralRefundDelay).toString(),
1855
+ refundNoReceiverDelay: chunkCJN4CUEU_cjs.timelockToSequence(
1857
1856
  params.unilateralRefundWithoutReceiverDelay
1858
1857
  ).toString()
1859
1858
  };
@@ -1865,9 +1864,9 @@ var VHTLCContractHandler = {
1865
1864
  server: base.hex.decode(params.server),
1866
1865
  preimageHash: base.hex.decode(params.hash),
1867
1866
  refundLocktime: BigInt(params.refundLocktime),
1868
- unilateralClaimDelay: chunkP53OHGXY_cjs.sequenceToTimelock(Number(params.claimDelay)),
1869
- unilateralRefundDelay: chunkP53OHGXY_cjs.sequenceToTimelock(Number(params.refundDelay)),
1870
- unilateralRefundWithoutReceiverDelay: chunkP53OHGXY_cjs.sequenceToTimelock(
1867
+ unilateralClaimDelay: chunkCJN4CUEU_cjs.sequenceToTimelock(Number(params.claimDelay)),
1868
+ unilateralRefundDelay: chunkCJN4CUEU_cjs.sequenceToTimelock(Number(params.refundDelay)),
1869
+ unilateralRefundWithoutReceiverDelay: chunkCJN4CUEU_cjs.sequenceToTimelock(
1871
1870
  Number(params.refundNoReceiverDelay)
1872
1871
  )
1873
1872
  };
@@ -2113,9 +2112,9 @@ var VHTLCV2ContractHandler = {
2113
2112
  server: base.hex.encode(params.server),
2114
2113
  hash: base.hex.encode(params.preimageHash),
2115
2114
  refundLocktime: params.refundLocktime.toString(),
2116
- claimDelay: chunkP53OHGXY_cjs.timelockToSequence(params.unilateralClaimDelay).toString(),
2117
- refundDelay: chunkP53OHGXY_cjs.timelockToSequence(params.unilateralRefundDelay).toString(),
2118
- refundNoReceiverDelay: chunkP53OHGXY_cjs.timelockToSequence(
2115
+ claimDelay: chunkCJN4CUEU_cjs.timelockToSequence(params.unilateralClaimDelay).toString(),
2116
+ refundDelay: chunkCJN4CUEU_cjs.timelockToSequence(params.unilateralRefundDelay).toString(),
2117
+ refundNoReceiverDelay: chunkCJN4CUEU_cjs.timelockToSequence(
2119
2118
  params.unilateralRefundWithoutReceiverDelay
2120
2119
  ).toString(),
2121
2120
  // The on-disk keys keep their per-leaf names even though the typed
@@ -2215,9 +2214,9 @@ var VHTLCV2ContractHandler = {
2215
2214
  preimageHash: base.hex.decode(params.hash),
2216
2215
  refundLocktime: BigInt(params.refundLocktime),
2217
2216
  ...asset && { asset },
2218
- unilateralClaimDelay: chunkP53OHGXY_cjs.sequenceToTimelock(Number(params.claimDelay)),
2219
- unilateralRefundDelay: chunkP53OHGXY_cjs.sequenceToTimelock(Number(params.refundDelay)),
2220
- unilateralRefundWithoutReceiverDelay: chunkP53OHGXY_cjs.sequenceToTimelock(
2217
+ unilateralClaimDelay: chunkCJN4CUEU_cjs.sequenceToTimelock(Number(params.claimDelay)),
2218
+ unilateralRefundDelay: chunkCJN4CUEU_cjs.sequenceToTimelock(Number(params.refundDelay)),
2219
+ unilateralRefundWithoutReceiverDelay: chunkCJN4CUEU_cjs.sequenceToTimelock(
2221
2220
  Number(params.refundNoReceiverDelay)
2222
2221
  ),
2223
2222
  ...claim && refund && {
@@ -2490,7 +2489,7 @@ var BoardingContractHandler = {
2490
2489
  const coins = await deps.onchainProvider.getCoins(onchainAddress);
2491
2490
  if (coins.length === 0) return [];
2492
2491
  const scriptHex = base.hex.encode(script.pkScript);
2493
- const boardingSeq = chunkP53OHGXY_cjs.timelockToSequence(deps.boardingTimelock);
2492
+ const boardingSeq = chunkCJN4CUEU_cjs.timelockToSequence(deps.boardingTimelock);
2494
2493
  return [
2495
2494
  {
2496
2495
  type: "boarding",
@@ -2584,6 +2583,7 @@ function collectParamRefs(program) {
2584
2583
  const collect = (items) => {
2585
2584
  for (const t of items ?? []) {
2586
2585
  if (typeof t === "string" && t.startsWith("$")) refs.add(t.slice(1));
2586
+ else if (isTweakedSigner(t) && t.tweak.startsWith("$")) refs.add(t.tweak.slice(1));
2587
2587
  }
2588
2588
  };
2589
2589
  for (const fn of Object.values(program.functions)) {
@@ -2636,10 +2636,15 @@ function validateProgram(program, args) {
2636
2636
  if (typeof p !== "string") validateParamValue(p, args[p.name]);
2637
2637
  }
2638
2638
  }
2639
+ function isTweakedSigner(ref) {
2640
+ if (typeof ref !== "object" || ref === null || ref instanceof Uint8Array) return false;
2641
+ const { tweak, fn } = ref;
2642
+ return typeof tweak === "string" && typeof fn === "string";
2643
+ }
2639
2644
  function resolveSigner(ref, args) {
2640
2645
  if (ref instanceof Uint8Array) return ref;
2641
- if (!ref.startsWith("$")) {
2642
- throw new Error(`unknown signer reference '${ref}' \u2014 use '$${ref}'`);
2646
+ if (typeof ref !== "string" || !ref.startsWith("$")) {
2647
+ throw new Error(`unknown signer reference '${ref}' \u2014 use a '$param' or key bytes`);
2643
2648
  }
2644
2649
  const v = bindValue(args, ref.slice(1));
2645
2650
  if (!(v instanceof Uint8Array)) {
@@ -2651,27 +2656,27 @@ function encodeTapscriptSegment(seg, pubkeys, args) {
2651
2656
  if (seg.csv) {
2652
2657
  const timelock = { type: seg.csv.type, value: resolveTimelockValue(seg.csv.value, args) };
2653
2658
  if (seg.asm) {
2654
- return chunkP53OHGXY_cjs.ConditionCSVMultisigTapscript.encode({
2659
+ return chunkCJN4CUEU_cjs.ConditionCSVMultisigTapscript.encode({
2655
2660
  conditionScript: resolveAsm(seg.asm, args),
2656
2661
  timelock,
2657
2662
  pubkeys
2658
2663
  });
2659
2664
  }
2660
- return chunkP53OHGXY_cjs.CSVMultisigTapscript.encode({ timelock, pubkeys });
2665
+ return chunkCJN4CUEU_cjs.CSVMultisigTapscript.encode({ timelock, pubkeys });
2661
2666
  }
2662
2667
  if (seg.cltv !== void 0) {
2663
- return chunkP53OHGXY_cjs.CLTVMultisigTapscript.encode({
2668
+ return chunkCJN4CUEU_cjs.CLTVMultisigTapscript.encode({
2664
2669
  absoluteTimelock: resolveTimelockValue(seg.cltv, args),
2665
2670
  pubkeys
2666
2671
  });
2667
2672
  }
2668
2673
  if (seg.asm) {
2669
- return chunkP53OHGXY_cjs.ConditionMultisigTapscript.encode({
2674
+ return chunkCJN4CUEU_cjs.ConditionMultisigTapscript.encode({
2670
2675
  conditionScript: resolveAsm(seg.asm, args),
2671
2676
  pubkeys
2672
2677
  });
2673
2678
  }
2674
- return chunkP53OHGXY_cjs.MultisigTapscript.encode({ pubkeys });
2679
+ return chunkCJN4CUEU_cjs.MultisigTapscript.encode({ pubkeys });
2675
2680
  }
2676
2681
  function compileFunctions(program, args, keys) {
2677
2682
  if (program.version !== SUPPORTED_PROGRAM_VERSION) {
@@ -2694,14 +2699,26 @@ function compileFunctions(program, args, keys) {
2694
2699
  }
2695
2700
  return defs.map((def, i) => {
2696
2701
  validateTapscript(def.tapscript);
2697
- const pubkeys = def.tapscript.signers.map((s) => resolveSigner(s, args));
2702
+ const pubkeys = def.tapscript.signers.map((signer) => {
2703
+ if (!isTweakedSigner(signer)) return resolveSigner(signer, args);
2704
+ const asm = functions[signer.fn]?.arkadeScript?.asm;
2705
+ if (!asm) {
2706
+ throw new Error(
2707
+ `ArkadeContract: function '${names[i]}' tweaks '${signer.fn}', which has no arkade script`
2708
+ );
2709
+ }
2710
+ return computeArkadeScriptPublicKey(
2711
+ resolveSigner(signer.tweak, args),
2712
+ resolveAsm(asm, args)
2713
+ );
2714
+ });
2698
2715
  const arkadeScript = def.arkadeScript ? resolveAsm(def.arkadeScript.asm, args) : void 0;
2699
- const leafPubkeys = arkadeScript ? [...pubkeys, computeArkadeScriptPublicKey(keys.emulatorKey, arkadeScript)] : pubkeys;
2716
+ const leafPubkeys = arkadeScript && def.tapscript.emulator !== null ? [...pubkeys, computeArkadeScriptPublicKey(keys.emulatorKey, arkadeScript)] : pubkeys;
2700
2717
  const leafScript = encodeTapscriptSegment(def.tapscript, leafPubkeys, args).script;
2701
2718
  return { name: names[i], def, leafScript, arkadeScript, signerKeys: pubkeys };
2702
2719
  });
2703
2720
  }
2704
- var ArkadeProgramScript = class extends chunkP53OHGXY_cjs.VtxoScript {
2721
+ var ArkadeProgramScript = class extends chunkCJN4CUEU_cjs.VtxoScript {
2705
2722
  constructor(program, args, keys) {
2706
2723
  const partial = compileFunctions(program, args, keys);
2707
2724
  super(partial.map((p) => p.leafScript));
@@ -2724,17 +2741,31 @@ var ArkadeProgramScript = class extends chunkP53OHGXY_cjs.VtxoScript {
2724
2741
  }
2725
2742
  };
2726
2743
  function parseArtifact(artifact) {
2744
+ if (Array.isArray(artifact.functions)) {
2745
+ throw new Error(
2746
+ "parseArtifact: `functions` is an array, which is the arkadec artifact shape, not an SDK program \u2014 read it with programFromArtifact instead"
2747
+ );
2748
+ }
2749
+ if (typeof artifact.functions !== "object" || artifact.functions === null) {
2750
+ throw new Error("parseArtifact: `functions` must be an object keyed by function name");
2751
+ }
2727
2752
  const hexToken = (t) => typeof t === "string" && t.startsWith("0x") ? base.hex.decode(t.slice(2)) : t;
2753
+ const signerRef = (s) => {
2754
+ if (s instanceof Uint8Array || typeof s === "string") return hexToken(s);
2755
+ if (isTweakedSigner(s)) return { tweak: s.tweak, fn: s.fn };
2756
+ throw new Error("parseArtifact: a tweaked signer needs string `tweak` and `fn`");
2757
+ };
2728
2758
  const timelockValue = (v) => typeof v === "string" && v.startsWith("$") ? v : BigInt(v);
2729
2759
  const functions = {};
2730
2760
  for (const [name, fn] of Object.entries(artifact.functions)) {
2731
2761
  const tap = fn.tapscript ?? {};
2732
2762
  const tapscript = {
2733
- signers: (tap.signers ?? []).map(hexToken),
2763
+ signers: (tap.signers ?? []).map(signerRef),
2734
2764
  ...tap.asm ? { asm: tap.asm.map(hexToken) } : {},
2735
2765
  ...tap.witness ? { witness: tap.witness.map(hexToken) } : {},
2736
2766
  ...tap.csv ? { csv: { type: tap.csv.type, value: timelockValue(tap.csv.value) } } : {},
2737
- ...tap.cltv !== void 0 ? { cltv: timelockValue(tap.cltv) } : {}
2767
+ ...tap.cltv !== void 0 ? { cltv: timelockValue(tap.cltv) } : {},
2768
+ ..."emulator" in tap ? { emulator: tap.emulator } : {}
2738
2769
  };
2739
2770
  const arkadeScript = fn.arkadeScript ? {
2740
2771
  asm: fn.arkadeScript.asm.map(hexToken),
@@ -2774,7 +2805,8 @@ function stringifyArtifact(program) {
2774
2805
  ...tap.asm ? { asm: tap.asm.map(token) } : {},
2775
2806
  ...tap.witness ? { witness: tap.witness.map(token) } : {},
2776
2807
  ...tap.csv ? { csv: { type: tap.csv.type, value: tap.csv.value.toString() } } : {},
2777
- ...tap.cltv !== void 0 ? { cltv: tap.cltv.toString() } : {}
2808
+ ...tap.cltv !== void 0 ? { cltv: tap.cltv.toString() } : {},
2809
+ ...tap.emulator !== void 0 ? { emulator: tap.emulator } : {}
2778
2810
  },
2779
2811
  ...fn.arkadeScript ? {
2780
2812
  arkadeScript: {
@@ -2914,7 +2946,7 @@ function pathsFor(script, context, opts) {
2914
2946
  continue;
2915
2947
  }
2916
2948
  if (requiresServer) continue;
2917
- const sequence = csv ? Number(chunkP53OHGXY_cjs.timelockToSequence(csv)) : void 0;
2949
+ const sequence = csv ? Number(chunkCJN4CUEU_cjs.timelockToSequence(csv)) : void 0;
2918
2950
  if (opts.checkTimelocks && csv && !isCsvSpendable(context, sequence)) continue;
2919
2951
  if (opts.checkTimelocks && cltv !== void 0 && !isCltvSatisfied(context, cltv)) {
2920
2952
  continue;
@@ -3043,5 +3075,5 @@ exports.toASM = toASM;
3043
3075
  exports.toXOnly = toXOnly;
3044
3076
  exports.validateProgram = validateProgram;
3045
3077
  exports.witnessRefToBytes = witnessRefToBytes;
3046
- //# sourceMappingURL=chunk-CQNX4BTA.cjs.map
3047
- //# sourceMappingURL=chunk-CQNX4BTA.cjs.map
3078
+ //# sourceMappingURL=chunk-LUWSY2QO.cjs.map
3079
+ //# sourceMappingURL=chunk-LUWSY2QO.cjs.map