@arkade-os/sdk 0.5.0-rc.26 → 0.5.0-rc.28

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 (76) hide show
  1. package/README.md +37 -0
  2. package/dist/adapters/expo.cjs +5 -5
  3. package/dist/adapters/expo.d.cts +4 -4
  4. package/dist/adapters/expo.d.ts +4 -4
  5. package/dist/adapters/expo.js +3 -3
  6. package/dist/{index-BfvbSL0W.d.cts → ark-CgZYyMpf.d.cts} +4369 -4205
  7. package/dist/{index-BfvbSL0W.d.ts → ark-CgZYyMpf.d.ts} +4369 -4205
  8. package/dist/{asyncStorageTaskQueue-CFWscYpG.d.cts → asyncStorageTaskQueue-B099Jii3.d.cts} +1 -1
  9. package/dist/{asyncStorageTaskQueue-DrFapzPg.d.ts → asyncStorageTaskQueue-BeQji1Ee.d.ts} +1 -1
  10. package/dist/{chunk-K2YTDYQF.cjs → chunk-3P7SXAAC.cjs} +16 -16
  11. package/dist/{chunk-K2YTDYQF.cjs.map → chunk-3P7SXAAC.cjs.map} +1 -1
  12. package/dist/{chunk-B2YMUJD5.cjs → chunk-4BT6HBZQ.cjs} +1155 -701
  13. package/dist/chunk-4BT6HBZQ.cjs.map +1 -0
  14. package/dist/{chunk-FEBAG2K2.cjs → chunk-6BJJ47JM.cjs} +18 -18
  15. package/dist/{chunk-FEBAG2K2.cjs.map → chunk-6BJJ47JM.cjs.map} +1 -1
  16. package/dist/{chunk-HPUKFTZV.js → chunk-BDTASM5W.js} +4 -4
  17. package/dist/{chunk-HPUKFTZV.js.map → chunk-BDTASM5W.js.map} +1 -1
  18. package/dist/{chunk-U5ZRDVVB.js → chunk-BIN2DVKS.js} +675 -222
  19. package/dist/chunk-BIN2DVKS.js.map +1 -0
  20. package/dist/{chunk-HTCIPDVW.js → chunk-CG7S6CDR.js} +5 -4
  21. package/dist/chunk-CG7S6CDR.js.map +1 -0
  22. package/dist/{chunk-N2VM6V6K.js → chunk-CR5YHHEM.js} +154 -51
  23. package/dist/chunk-CR5YHHEM.js.map +1 -0
  24. package/dist/{chunk-VVFCCNU2.cjs → chunk-FGKBQH5S.cjs} +5 -3
  25. package/dist/chunk-FGKBQH5S.cjs.map +1 -0
  26. package/dist/{chunk-Y5VSJURH.js → chunk-FSSINCR6.js} +4 -4
  27. package/dist/{chunk-Y5VSJURH.js.map → chunk-FSSINCR6.js.map} +1 -1
  28. package/dist/{chunk-QCD3SJOL.cjs → chunk-HFSC7T5I.cjs} +10 -10
  29. package/dist/{chunk-QCD3SJOL.cjs.map → chunk-HFSC7T5I.cjs.map} +1 -1
  30. package/dist/{chunk-5JQ5EOYE.js → chunk-PHSUZSRH.js} +3 -3
  31. package/dist/{chunk-5JQ5EOYE.js.map → chunk-PHSUZSRH.js.map} +1 -1
  32. package/dist/{chunk-CFOIHLON.cjs → chunk-YFQOJTG3.cjs} +201 -96
  33. package/dist/chunk-YFQOJTG3.cjs.map +1 -0
  34. package/dist/contracts/handlers/index.cjs +9 -9
  35. package/dist/contracts/handlers/index.d.cts +5 -5
  36. package/dist/contracts/handlers/index.d.ts +5 -5
  37. package/dist/contracts/handlers/index.js +2 -2
  38. package/dist/{delegate-Cz8FnLqi.d.ts → delegate-B8KSoeVz.d.ts} +1 -1
  39. package/dist/{delegate-r3jh7UcH.d.cts → delegate-wuf6DBpr.d.cts} +1 -1
  40. package/dist/{index-DOION7Ta.d.cts → index-1pLGuueL.d.ts} +58 -52
  41. package/dist/{index-Chgwl4dO.d.ts → index-CP3v0PVS.d.cts} +58 -52
  42. package/dist/index.cjs +328 -316
  43. package/dist/index.d.cts +332 -286
  44. package/dist/index.d.ts +332 -286
  45. package/dist/index.js +4 -4
  46. package/dist/repositories/realm/index.cjs +35 -35
  47. package/dist/repositories/realm/index.d.cts +4 -4
  48. package/dist/repositories/realm/index.d.ts +4 -4
  49. package/dist/repositories/realm/index.js +5 -5
  50. package/dist/repositories/sqlite/index.cjs +33 -33
  51. package/dist/repositories/sqlite/index.d.cts +4 -4
  52. package/dist/repositories/sqlite/index.d.ts +4 -4
  53. package/dist/repositories/sqlite/index.js +5 -5
  54. package/dist/{taskRunner-CXAcjtdU.d.ts → taskRunner-D4IF7tc8.d.cts} +1 -1
  55. package/dist/{taskRunner-BO8a-SQh.d.cts → taskRunner-DzEg63qV.d.ts} +1 -1
  56. package/dist/wallet/expo/background.cjs +14 -14
  57. package/dist/wallet/expo/background.d.cts +5 -5
  58. package/dist/wallet/expo/background.d.ts +5 -5
  59. package/dist/wallet/expo/background.js +6 -6
  60. package/dist/wallet/expo/index.cjs +15 -15
  61. package/dist/wallet/expo/index.d.cts +4 -4
  62. package/dist/wallet/expo/index.d.ts +4 -4
  63. package/dist/wallet/expo/index.js +5 -5
  64. package/dist/{wallet-CFIfUlQP.d.ts → walletRepository-BA5C6Slk.d.cts} +29 -29
  65. package/dist/{wallet-s90p-vIk.d.cts → walletRepository-BE2yiIHF.d.ts} +29 -29
  66. package/dist/worker/expo/index.cjs +9 -9
  67. package/dist/worker/expo/index.d.cts +6 -6
  68. package/dist/worker/expo/index.d.ts +6 -6
  69. package/dist/worker/expo/index.js +5 -5
  70. package/package.json +1 -1
  71. package/dist/chunk-B2YMUJD5.cjs.map +0 -1
  72. package/dist/chunk-CFOIHLON.cjs.map +0 -1
  73. package/dist/chunk-HTCIPDVW.js.map +0 -1
  74. package/dist/chunk-N2VM6V6K.js.map +0 -1
  75. package/dist/chunk-U5ZRDVVB.js.map +0 -1
  76. package/dist/chunk-VVFCCNU2.cjs.map +0 -1
@@ -1,37 +1,37 @@
1
1
  'use strict';
2
2
 
3
- var chunkCFOIHLON_cjs = require('../../chunk-CFOIHLON.cjs');
4
- require('../../chunk-VVFCCNU2.cjs');
3
+ var chunkYFQOJTG3_cjs = require('../../chunk-YFQOJTG3.cjs');
4
+ require('../../chunk-FGKBQH5S.cjs');
5
5
 
6
6
 
7
7
 
8
8
  Object.defineProperty(exports, "ArkadeContractHandler", {
9
9
  enumerable: true,
10
- get: function () { return chunkCFOIHLON_cjs.ArkadeContractHandler; }
10
+ get: function () { return chunkYFQOJTG3_cjs.ArkadeContractHandler; }
11
11
  });
12
12
  Object.defineProperty(exports, "BoardingContractHandler", {
13
13
  enumerable: true,
14
- get: function () { return chunkCFOIHLON_cjs.BoardingContractHandler; }
14
+ get: function () { return chunkYFQOJTG3_cjs.BoardingContractHandler; }
15
15
  });
16
16
  Object.defineProperty(exports, "DefaultContractHandler", {
17
17
  enumerable: true,
18
- get: function () { return chunkCFOIHLON_cjs.DefaultContractHandler; }
18
+ get: function () { return chunkYFQOJTG3_cjs.DefaultContractHandler; }
19
19
  });
20
20
  Object.defineProperty(exports, "DelegateContractHandler", {
21
21
  enumerable: true,
22
- get: function () { return chunkCFOIHLON_cjs.DelegateContractHandler; }
22
+ get: function () { return chunkYFQOJTG3_cjs.DelegateContractHandler; }
23
23
  });
24
24
  Object.defineProperty(exports, "VHTLCContractHandler", {
25
25
  enumerable: true,
26
- get: function () { return chunkCFOIHLON_cjs.VHTLCContractHandler; }
26
+ get: function () { return chunkYFQOJTG3_cjs.VHTLCContractHandler; }
27
27
  });
28
28
  Object.defineProperty(exports, "VHTLCV2ContractHandler", {
29
29
  enumerable: true,
30
- get: function () { return chunkCFOIHLON_cjs.VHTLCV2ContractHandler; }
30
+ get: function () { return chunkYFQOJTG3_cjs.VHTLCV2ContractHandler; }
31
31
  });
32
32
  Object.defineProperty(exports, "contractHandlers", {
33
33
  enumerable: true,
34
- get: function () { return chunkCFOIHLON_cjs.contractHandlers; }
34
+ get: function () { return chunkYFQOJTG3_cjs.contractHandlers; }
35
35
  });
36
36
  //# sourceMappingURL=index.cjs.map
37
37
  //# sourceMappingURL=index.cjs.map
@@ -1,7 +1,7 @@
1
- export { o as ArkadeContractHandler, B as BoardingContractHandler, q as BoardingContractParams, D as DefaultContractHandler, t as DefaultContractParams, u as DelegateContractHandler, x as DelegateContractParams, y as VHTLCContractHandler, z as VHTLCContractParams, E as VHTLCV2ContractHandler, F as VHTLCV2ContractParams, G as contractHandlers } from '../../index-DOION7Ta.cjs';
2
- import '../../index-BfvbSL0W.cjs';
3
- import '@scure/btc-signer/utils.js';
4
- import '@scure/btc-signer/psbt.js';
1
+ export { o as ArkadeContractHandler, B as BoardingContractHandler, q as BoardingContractParams, D as DefaultContractHandler, t as DefaultContractParams, u as DelegateContractHandler, x as DelegateContractParams, y as VHTLCContractHandler, z as VHTLCContractParams, E as VHTLCV2ContractHandler, F as VHTLCV2ContractParams, G as contractHandlers } from '../../index-CP3v0PVS.cjs';
2
+ import '../../ark-CgZYyMpf.cjs';
5
3
  import '@scure/btc-signer';
6
4
  import '@scure/btc-signer/transaction.js';
7
- import '../../delegate-r3jh7UcH.cjs';
5
+ import '@scure/btc-signer/utils.js';
6
+ import '@scure/btc-signer/psbt.js';
7
+ import '../../delegate-wuf6DBpr.cjs';
@@ -1,7 +1,7 @@
1
- export { o as ArkadeContractHandler, B as BoardingContractHandler, q as BoardingContractParams, D as DefaultContractHandler, t as DefaultContractParams, u as DelegateContractHandler, x as DelegateContractParams, y as VHTLCContractHandler, z as VHTLCContractParams, E as VHTLCV2ContractHandler, F as VHTLCV2ContractParams, G as contractHandlers } from '../../index-Chgwl4dO.js';
2
- import '../../index-BfvbSL0W.js';
3
- import '@scure/btc-signer/utils.js';
4
- import '@scure/btc-signer/psbt.js';
1
+ export { o as ArkadeContractHandler, B as BoardingContractHandler, q as BoardingContractParams, D as DefaultContractHandler, t as DefaultContractParams, u as DelegateContractHandler, x as DelegateContractParams, y as VHTLCContractHandler, z as VHTLCContractParams, E as VHTLCV2ContractHandler, F as VHTLCV2ContractParams, G as contractHandlers } from '../../index-1pLGuueL.js';
2
+ import '../../ark-CgZYyMpf.js';
5
3
  import '@scure/btc-signer';
6
4
  import '@scure/btc-signer/transaction.js';
7
- import '../../delegate-Cz8FnLqi.js';
5
+ import '@scure/btc-signer/utils.js';
6
+ import '@scure/btc-signer/psbt.js';
7
+ import '../../delegate-B8KSoeVz.js';
@@ -1,4 +1,4 @@
1
- export { ArkadeContractHandler, BoardingContractHandler, DefaultContractHandler, DelegateContractHandler, VHTLCContractHandler, VHTLCV2ContractHandler, contractHandlers } from '../../chunk-N2VM6V6K.js';
2
- import '../../chunk-HTCIPDVW.js';
1
+ export { ArkadeContractHandler, BoardingContractHandler, DefaultContractHandler, DelegateContractHandler, VHTLCContractHandler, VHTLCV2ContractHandler, contractHandlers } from '../../chunk-CR5YHHEM.js';
2
+ import '../../chunk-CG7S6CDR.js';
3
3
  //# sourceMappingURL=index.js.map
4
4
  //# sourceMappingURL=index.js.map
@@ -1,5 +1,5 @@
1
1
  import { Bytes } from '@scure/btc-signer/utils.js';
2
- import { w as RelativeTimelock, V as VtxoScript, x as TapLeafScript } from './index-BfvbSL0W.js';
2
+ import { w as RelativeTimelock, V as VtxoScript, x as TapLeafScript } from './ark-CgZYyMpf.js';
3
3
 
4
4
  /**
5
5
  * DefaultVtxo is the default implementation of a VtxoScript.
@@ -1,5 +1,5 @@
1
1
  import { Bytes } from '@scure/btc-signer/utils.js';
2
- import { w as RelativeTimelock, V as VtxoScript, x as TapLeafScript } from './index-BfvbSL0W.cjs';
2
+ import { w as RelativeTimelock, V as VtxoScript, x as TapLeafScript } from './ark-CgZYyMpf.cjs';
3
3
 
4
4
  /**
5
5
  * DefaultVtxo is the default implementation of a VtxoScript.
@@ -1,5 +1,5 @@
1
- import { bw as ContractHandler, w as RelativeTimelock, bI as Discoverable, V as VtxoScript, x as TapLeafScript, dA as TapscriptDeriving } from './index-BfvbSL0W.cjs';
2
- import { D as DefaultVtxo, a as DelegateVtxo } from './delegate-r3jh7UcH.cjs';
1
+ import { bD as ContractHandler, w as RelativeTimelock, bP as Discoverable, V as VtxoScript, x as TapLeafScript, dI as TapscriptDeriving } from './ark-CgZYyMpf.js';
2
+ import { D as DefaultVtxo, a as DelegateVtxo } from './delegate-B8KSoeVz.js';
3
3
  import { Bytes } from '@scure/btc-signer/utils.js';
4
4
 
5
5
  /**
@@ -366,15 +366,15 @@ declare const BoardingContractHandler: ContractHandler<BoardingContractParams, D
366
366
  /**
367
367
  * Arkade Program model & compiler.
368
368
  *
369
- * A {@link Program} is the artifact shape shared with the ArkadeScript
370
- * compiler: named functions, each split into a `tapscript` segment enforced
369
+ * A {@link Program} is the normalized SDK model: named functions, each
370
+ * split into a `tapscript` segment enforced
371
371
  * on-chain and an optional `arkadeScript` segment emulated by the co-signing
372
372
  * service. This module owns everything that is *pure data → script*:
373
373
  *
374
374
  * - the Program/segment/token types,
375
375
  * - `$param` resolution ({@link resolveAsm}), witness and timelock resolution,
376
- * - program validation ({@link validateProgram}) — typed constructor params
377
- * are authoritative when present,
376
+ * - program validation ({@link validateProgram}) — every referenced constructor
377
+ * parameter must be declared and bound,
378
378
  * - {@link ArkadeProgramScript} — a {@link VtxoScript} compiled from a
379
379
  * program, its constructor args and the signer keys,
380
380
  * - artifact JSON (de)serialization ({@link parseArtifact} /
@@ -394,12 +394,20 @@ type AsmToken = string | number | bigint | Uint8Array;
394
394
  type ArkadeParamValue = Uint8Array | bigint | number;
395
395
  /** A function call argument (function input). */
396
396
  type ArkadeArgValue = Uint8Array | bigint | number;
397
- /**
398
- * The declared type of a function input, used to derive the static TS type of
399
- * the corresponding `functions.<name>(...)` argument. Byte-like types map to
400
- * `Uint8Array`; `int` maps to `bigint | number`.
401
- */
402
- type ArkadeArgType = "bytes" | "pubkey" | "sig" | "hash" | "int";
397
+ /** Native scalar types and their compiler witness encodings. */
398
+ declare const ARKADE_TYPE_ENCODINGS: {
399
+ readonly pubkey: "raw";
400
+ readonly signature: "schnorr-64";
401
+ readonly bytes: "raw";
402
+ readonly bytes20: "raw-20";
403
+ readonly bytes32: "raw-32";
404
+ readonly asset: "raw-32";
405
+ readonly int: "scriptnum";
406
+ readonly bool: "scriptnum";
407
+ readonly AssetGroup: "scriptnum";
408
+ };
409
+ /** A native Arkade scalar type for a constructor parameter or call input. */
410
+ type ArkadeArgType = keyof typeof ARKADE_TYPE_ENCODINGS;
403
411
  /**
404
412
  * Maps an {@link ArkadeArgType} to its TypeScript argument type.
405
413
  * @internal
@@ -407,22 +415,21 @@ type ArkadeArgType = "bytes" | "pubkey" | "sig" | "hash" | "int";
407
415
  interface ArkadeValueType {
408
416
  bytes: Uint8Array;
409
417
  pubkey: Uint8Array;
410
- sig: Uint8Array;
411
- hash: Uint8Array;
418
+ signature: Uint8Array;
419
+ bytes20: Uint8Array;
420
+ bytes32: Uint8Array;
421
+ asset: Uint8Array;
412
422
  int: bigint | number;
423
+ bool: bigint | number;
424
+ AssetGroup: bigint | number;
413
425
  }
414
426
  /** A typed function input or constructor param: a name plus its {@link ArkadeArgType}. */
415
427
  interface InputDef {
416
428
  name: string;
417
429
  type: ArkadeArgType;
418
430
  }
419
- /**
420
- * A function input or constructor param declaration: either a typed descriptor
421
- * `{ name, type }` (the argument is statically typed and its bound value is
422
- * validated) or a bare name string (the argument falls back to the loose
423
- * {@link ArkadeArgValue}).
424
- */
425
- type InputRef = string | InputDef;
431
+ /** A typed function input or constructor parameter. */
432
+ type InputRef = InputDef;
426
433
  /** Constructor pubkey `$param` tweaked by `fn`'s covenant. */
427
434
  interface TweakedSigner {
428
435
  tweak: string;
@@ -435,16 +442,20 @@ type WitnessRef = string | number | bigint | Uint8Array;
435
442
  /** Bitcoin Script segment of a spending path — enforced on-chain. */
436
443
  interface TapscriptSegment {
437
444
  /**
438
- * Required signers. A path with `arkadeScript` also appends the emulator
439
- * co-signer, unless `emulator` is `null`.
445
+ * Required signers. A path with `arkadeScript` also inserts the emulator
446
+ * co-signer at `emulatorIndex` (last by default), unless `emulator` is `null`.
440
447
  */
441
448
  signers: SignerRef[];
449
+ /** Caller signature ABI; satisfied through PSBT signing, never ConditionWitness. */
450
+ signatures?: InputDef[];
442
451
  /**
443
452
  * Covenant named by `<EMULATOR_KEY:fn>`. `null` when this leaf belongs to a
444
453
  * covenant but signs with a constructor-key tweak instead. Omitted on
445
454
  * hand-written programs, which still append the co-signer.
446
455
  */
447
456
  emulator?: string | null;
457
+ /** Emulator's position in the full signer list; omitted to append it. */
458
+ emulatorIndex?: number;
448
459
  /**
449
460
  * Optional standard-opcode condition (e.g. a hashlock), encoded into a
450
461
  * ConditionMultisig leaf — or ConditionCSVMultisig when combined with `csv`.
@@ -478,18 +489,26 @@ interface ArkadeSegment {
478
489
  }
479
490
  /** One named spending path. */
480
491
  interface ArkadeFunction {
481
- /**
482
- * The function ABI: an ordered list of call arguments. Each entry is a typed
483
- * descriptor `{ name, type }` (which gives the matching `functions.<name>`
484
- * argument a precise static type) or a bare name string (loose
485
- * {@link ArkadeArgValue}). Absent for nullary paths (e.g. exit/cancel).
486
- */
487
- inputs?: readonly InputRef[];
492
+ /** Compiler spend group, used to resolve named covenant commitments. */
493
+ group?: string;
494
+ /** Ordered typed call arguments; absent for nullary paths. */
495
+ inputs?: readonly InputDef[];
488
496
  tapscript: TapscriptSegment;
489
497
  /** Present for covenant paths; absent for pure-tapscript paths (cancel/exit). */
490
498
  arkadeScript?: ArkadeSegment;
491
499
  }
492
- declare const SUPPORTED_PROGRAM_VERSION = 0;
500
+ /** Supported normalized Program version. */
501
+ declare const SUPPORTED_PROGRAM_VERSION = 1;
502
+ /**
503
+ * A Program written for a version this SDK cannot read. Typed so a stored row in that format is
504
+ * reported as unsupported rather than broken: its script stays unknown until it is recovered with
505
+ * an SDK that reads that version, or re-created from fresh params.
506
+ */
507
+ declare class UnsupportedProgramVersionError extends Error {
508
+ readonly version: unknown;
509
+ readonly name = "UnsupportedProgramVersionError";
510
+ constructor(version: unknown, context: string);
511
+ }
493
512
  /** An Arkade contract program (hand-written or compiler-emitted). */
494
513
  interface Program {
495
514
  version: number;
@@ -498,12 +517,8 @@ interface Program {
498
517
  * artifact JSON, never used in compilation or the taproot tree.
499
518
  */
500
519
  name?: string;
501
- /**
502
- * Ordered constructor parameters. Bare name strings are documentation only
503
- * (the legacy hand-written form); typed descriptors `{ name, type }` make
504
- * the list authoritative — see {@link validateProgram}.
505
- */
506
- params?: readonly InputRef[];
520
+ /** Ordered typed constructor parameters. */
521
+ params?: readonly InputDef[];
507
522
  functions: Record<string, ArkadeFunction>;
508
523
  }
509
524
  /**
@@ -511,8 +526,8 @@ interface Program {
511
526
  * pass everything else (opcode names, numbers, raw byte pushes) through to the
512
527
  * Arkade script encoder. The SDK does not interpret opcodes — this is pure
513
528
  * substitution + encoding. To embed a signer key (server, user, or any
514
- * other), pass it as a `$param` in the constructor args; there is no
515
- * `<SERVER_KEY>`/`<COSIGNER_KEY>` token.
529
+ * other), pass it as a `$param` in the constructor args. Compiler `<...>`
530
+ * placeholders are normalized by {@link programFromArtifact} before this step.
516
531
  */
517
532
  declare function resolveAsm(asm: AsmToken[], bind: Record<string, ArkadeParamValue>): Uint8Array;
518
533
  /**
@@ -525,16 +540,7 @@ declare function resolveAsm(asm: AsmToken[], bind: Record<string, ArkadeParamVal
525
540
  * (throws when the input is unbound — e.g. outside a function call).
526
541
  */
527
542
  declare function witnessRefToBytes(ref: WitnessRef, callArgs: Record<string, ArkadeArgValue>, programArgs: Record<string, ArkadeParamValue>): Uint8Array;
528
- /**
529
- * Validate a program's constructor-parameter declarations against the bound
530
- * args. A `params` list of bare name strings is documentation only (the
531
- * legacy hand-written form — no checks). When at least one entry is a typed
532
- * descriptor (the compiler-emitted form), the list is authoritative: every
533
- * declared param must be bound in `args`, every `"$name"` reference in the
534
- * program must be declared, and typed entries validate their bound value
535
- * (bytes-like types require a Uint8Array — 32 bytes for `pubkey`, 64 for
536
- * `sig`; `int` requires a bigint/number).
537
- */
543
+ /** Validate declared constructor values and reject undeclared references. */
538
544
  declare function validateProgram(program: Program, args: Record<string, ArkadeParamValue>): void;
539
545
  /** The signer keys a program is compiled against. */
540
546
  interface ProgramKeys {
@@ -594,11 +600,11 @@ declare class ArkadeProgramScript extends VtxoScript {
594
600
  declare function parseArtifact(artifact: {
595
601
  version?: number;
596
602
  name?: string;
597
- params?: readonly InputRef[];
603
+ params?: readonly InputDef[];
598
604
  functions: unknown;
599
605
  }): Program;
600
606
  /**
601
- * Serialize a {@link Program} to compiler-artifact JSON — the inverse of
607
+ * Serialize a {@link Program} to normalized Program JSON — the inverse of
602
608
  * {@link parseArtifact}: bytes become `0x`-hex strings; bigint tokens become
603
609
  * plain numbers (or, above `Number.MAX_SAFE_INTEGER`, `0x`-hex of their
604
610
  * minimal script-num bytes, which the script encoder pushes identically);
@@ -636,4 +642,4 @@ declare function deserializeArkadeContractParams(params: Record<string, string>)
636
642
  */
637
643
  declare const ArkadeContractHandler: ContractHandler<ArkadeContractParams, ArkadeProgramScript> & TapscriptDeriving<ArkadeProgramScript>;
638
644
 
639
- export { type ArkadeParamValue as A, BoardingContractHandler as B, type CompiledProgramFunction as C, DefaultContractHandler as D, VHTLCV2ContractHandler as E, type VHTLCV2ContractParams as F, contractHandlers as G, type InputRef as I, type Program as P, SUPPORTED_PROGRAM_VERSION as S, type TapscriptSegment as T, VHTLC as V, type WitnessRef as W, ArkadeProgramScript as a, type ProgramKeys as b, type ArkadeArgValue as c, type ArkadeFunction as d, type InputDef as e, type ArkadeValueType as f, type ArkadeArgType as g, type ArkadeContractParams as h, type ArkadeSegment as i, type AsmToken as j, type SignerRef as k, type TweakedSigner as l, deserializeArkadeContractParams as m, stringifyArtifact as n, ArkadeContractHandler as o, parseArtifact as p, type BoardingContractParams as q, resolveAsm as r, serializeArkadeContractParams as s, type DefaultContractParams as t, DelegateContractHandler as u, validateProgram as v, witnessRefToBytes as w, type DelegateContractParams as x, VHTLCContractHandler as y, type VHTLCContractParams as z };
645
+ export { type ArkadeParamValue as A, BoardingContractHandler as B, type CompiledProgramFunction as C, DefaultContractHandler as D, VHTLCV2ContractHandler as E, type VHTLCV2ContractParams as F, contractHandlers as G, type InputDef as I, type Program as P, SUPPORTED_PROGRAM_VERSION as S, type TapscriptSegment as T, UnsupportedProgramVersionError as U, VHTLC as V, type WitnessRef as W, ArkadeProgramScript as a, type ProgramKeys as b, type ArkadeArgValue as c, type ArkadeFunction as d, type ArkadeValueType as e, type ArkadeArgType as f, type ArkadeContractParams as g, type ArkadeSegment as h, type AsmToken as i, type InputRef as j, type SignerRef as k, type TweakedSigner as l, deserializeArkadeContractParams as m, stringifyArtifact as n, ArkadeContractHandler as o, parseArtifact as p, type BoardingContractParams as q, resolveAsm as r, serializeArkadeContractParams as s, type DefaultContractParams as t, DelegateContractHandler as u, validateProgram as v, witnessRefToBytes as w, type DelegateContractParams as x, VHTLCContractHandler as y, type VHTLCContractParams as z };
@@ -1,5 +1,5 @@
1
- import { bw as ContractHandler, w as RelativeTimelock, bI as Discoverable, V as VtxoScript, x as TapLeafScript, dA as TapscriptDeriving } from './index-BfvbSL0W.js';
2
- import { D as DefaultVtxo, a as DelegateVtxo } from './delegate-Cz8FnLqi.js';
1
+ import { bD as ContractHandler, w as RelativeTimelock, bP as Discoverable, V as VtxoScript, x as TapLeafScript, dI as TapscriptDeriving } from './ark-CgZYyMpf.cjs';
2
+ import { D as DefaultVtxo, a as DelegateVtxo } from './delegate-wuf6DBpr.cjs';
3
3
  import { Bytes } from '@scure/btc-signer/utils.js';
4
4
 
5
5
  /**
@@ -366,15 +366,15 @@ declare const BoardingContractHandler: ContractHandler<BoardingContractParams, D
366
366
  /**
367
367
  * Arkade Program model & compiler.
368
368
  *
369
- * A {@link Program} is the artifact shape shared with the ArkadeScript
370
- * compiler: named functions, each split into a `tapscript` segment enforced
369
+ * A {@link Program} is the normalized SDK model: named functions, each
370
+ * split into a `tapscript` segment enforced
371
371
  * on-chain and an optional `arkadeScript` segment emulated by the co-signing
372
372
  * service. This module owns everything that is *pure data → script*:
373
373
  *
374
374
  * - the Program/segment/token types,
375
375
  * - `$param` resolution ({@link resolveAsm}), witness and timelock resolution,
376
- * - program validation ({@link validateProgram}) — typed constructor params
377
- * are authoritative when present,
376
+ * - program validation ({@link validateProgram}) — every referenced constructor
377
+ * parameter must be declared and bound,
378
378
  * - {@link ArkadeProgramScript} — a {@link VtxoScript} compiled from a
379
379
  * program, its constructor args and the signer keys,
380
380
  * - artifact JSON (de)serialization ({@link parseArtifact} /
@@ -394,12 +394,20 @@ type AsmToken = string | number | bigint | Uint8Array;
394
394
  type ArkadeParamValue = Uint8Array | bigint | number;
395
395
  /** A function call argument (function input). */
396
396
  type ArkadeArgValue = Uint8Array | bigint | number;
397
- /**
398
- * The declared type of a function input, used to derive the static TS type of
399
- * the corresponding `functions.<name>(...)` argument. Byte-like types map to
400
- * `Uint8Array`; `int` maps to `bigint | number`.
401
- */
402
- type ArkadeArgType = "bytes" | "pubkey" | "sig" | "hash" | "int";
397
+ /** Native scalar types and their compiler witness encodings. */
398
+ declare const ARKADE_TYPE_ENCODINGS: {
399
+ readonly pubkey: "raw";
400
+ readonly signature: "schnorr-64";
401
+ readonly bytes: "raw";
402
+ readonly bytes20: "raw-20";
403
+ readonly bytes32: "raw-32";
404
+ readonly asset: "raw-32";
405
+ readonly int: "scriptnum";
406
+ readonly bool: "scriptnum";
407
+ readonly AssetGroup: "scriptnum";
408
+ };
409
+ /** A native Arkade scalar type for a constructor parameter or call input. */
410
+ type ArkadeArgType = keyof typeof ARKADE_TYPE_ENCODINGS;
403
411
  /**
404
412
  * Maps an {@link ArkadeArgType} to its TypeScript argument type.
405
413
  * @internal
@@ -407,22 +415,21 @@ type ArkadeArgType = "bytes" | "pubkey" | "sig" | "hash" | "int";
407
415
  interface ArkadeValueType {
408
416
  bytes: Uint8Array;
409
417
  pubkey: Uint8Array;
410
- sig: Uint8Array;
411
- hash: Uint8Array;
418
+ signature: Uint8Array;
419
+ bytes20: Uint8Array;
420
+ bytes32: Uint8Array;
421
+ asset: Uint8Array;
412
422
  int: bigint | number;
423
+ bool: bigint | number;
424
+ AssetGroup: bigint | number;
413
425
  }
414
426
  /** A typed function input or constructor param: a name plus its {@link ArkadeArgType}. */
415
427
  interface InputDef {
416
428
  name: string;
417
429
  type: ArkadeArgType;
418
430
  }
419
- /**
420
- * A function input or constructor param declaration: either a typed descriptor
421
- * `{ name, type }` (the argument is statically typed and its bound value is
422
- * validated) or a bare name string (the argument falls back to the loose
423
- * {@link ArkadeArgValue}).
424
- */
425
- type InputRef = string | InputDef;
431
+ /** A typed function input or constructor parameter. */
432
+ type InputRef = InputDef;
426
433
  /** Constructor pubkey `$param` tweaked by `fn`'s covenant. */
427
434
  interface TweakedSigner {
428
435
  tweak: string;
@@ -435,16 +442,20 @@ type WitnessRef = string | number | bigint | Uint8Array;
435
442
  /** Bitcoin Script segment of a spending path — enforced on-chain. */
436
443
  interface TapscriptSegment {
437
444
  /**
438
- * Required signers. A path with `arkadeScript` also appends the emulator
439
- * co-signer, unless `emulator` is `null`.
445
+ * Required signers. A path with `arkadeScript` also inserts the emulator
446
+ * co-signer at `emulatorIndex` (last by default), unless `emulator` is `null`.
440
447
  */
441
448
  signers: SignerRef[];
449
+ /** Caller signature ABI; satisfied through PSBT signing, never ConditionWitness. */
450
+ signatures?: InputDef[];
442
451
  /**
443
452
  * Covenant named by `<EMULATOR_KEY:fn>`. `null` when this leaf belongs to a
444
453
  * covenant but signs with a constructor-key tweak instead. Omitted on
445
454
  * hand-written programs, which still append the co-signer.
446
455
  */
447
456
  emulator?: string | null;
457
+ /** Emulator's position in the full signer list; omitted to append it. */
458
+ emulatorIndex?: number;
448
459
  /**
449
460
  * Optional standard-opcode condition (e.g. a hashlock), encoded into a
450
461
  * ConditionMultisig leaf — or ConditionCSVMultisig when combined with `csv`.
@@ -478,18 +489,26 @@ interface ArkadeSegment {
478
489
  }
479
490
  /** One named spending path. */
480
491
  interface ArkadeFunction {
481
- /**
482
- * The function ABI: an ordered list of call arguments. Each entry is a typed
483
- * descriptor `{ name, type }` (which gives the matching `functions.<name>`
484
- * argument a precise static type) or a bare name string (loose
485
- * {@link ArkadeArgValue}). Absent for nullary paths (e.g. exit/cancel).
486
- */
487
- inputs?: readonly InputRef[];
492
+ /** Compiler spend group, used to resolve named covenant commitments. */
493
+ group?: string;
494
+ /** Ordered typed call arguments; absent for nullary paths. */
495
+ inputs?: readonly InputDef[];
488
496
  tapscript: TapscriptSegment;
489
497
  /** Present for covenant paths; absent for pure-tapscript paths (cancel/exit). */
490
498
  arkadeScript?: ArkadeSegment;
491
499
  }
492
- declare const SUPPORTED_PROGRAM_VERSION = 0;
500
+ /** Supported normalized Program version. */
501
+ declare const SUPPORTED_PROGRAM_VERSION = 1;
502
+ /**
503
+ * A Program written for a version this SDK cannot read. Typed so a stored row in that format is
504
+ * reported as unsupported rather than broken: its script stays unknown until it is recovered with
505
+ * an SDK that reads that version, or re-created from fresh params.
506
+ */
507
+ declare class UnsupportedProgramVersionError extends Error {
508
+ readonly version: unknown;
509
+ readonly name = "UnsupportedProgramVersionError";
510
+ constructor(version: unknown, context: string);
511
+ }
493
512
  /** An Arkade contract program (hand-written or compiler-emitted). */
494
513
  interface Program {
495
514
  version: number;
@@ -498,12 +517,8 @@ interface Program {
498
517
  * artifact JSON, never used in compilation or the taproot tree.
499
518
  */
500
519
  name?: string;
501
- /**
502
- * Ordered constructor parameters. Bare name strings are documentation only
503
- * (the legacy hand-written form); typed descriptors `{ name, type }` make
504
- * the list authoritative — see {@link validateProgram}.
505
- */
506
- params?: readonly InputRef[];
520
+ /** Ordered typed constructor parameters. */
521
+ params?: readonly InputDef[];
507
522
  functions: Record<string, ArkadeFunction>;
508
523
  }
509
524
  /**
@@ -511,8 +526,8 @@ interface Program {
511
526
  * pass everything else (opcode names, numbers, raw byte pushes) through to the
512
527
  * Arkade script encoder. The SDK does not interpret opcodes — this is pure
513
528
  * substitution + encoding. To embed a signer key (server, user, or any
514
- * other), pass it as a `$param` in the constructor args; there is no
515
- * `<SERVER_KEY>`/`<COSIGNER_KEY>` token.
529
+ * other), pass it as a `$param` in the constructor args. Compiler `<...>`
530
+ * placeholders are normalized by {@link programFromArtifact} before this step.
516
531
  */
517
532
  declare function resolveAsm(asm: AsmToken[], bind: Record<string, ArkadeParamValue>): Uint8Array;
518
533
  /**
@@ -525,16 +540,7 @@ declare function resolveAsm(asm: AsmToken[], bind: Record<string, ArkadeParamVal
525
540
  * (throws when the input is unbound — e.g. outside a function call).
526
541
  */
527
542
  declare function witnessRefToBytes(ref: WitnessRef, callArgs: Record<string, ArkadeArgValue>, programArgs: Record<string, ArkadeParamValue>): Uint8Array;
528
- /**
529
- * Validate a program's constructor-parameter declarations against the bound
530
- * args. A `params` list of bare name strings is documentation only (the
531
- * legacy hand-written form — no checks). When at least one entry is a typed
532
- * descriptor (the compiler-emitted form), the list is authoritative: every
533
- * declared param must be bound in `args`, every `"$name"` reference in the
534
- * program must be declared, and typed entries validate their bound value
535
- * (bytes-like types require a Uint8Array — 32 bytes for `pubkey`, 64 for
536
- * `sig`; `int` requires a bigint/number).
537
- */
543
+ /** Validate declared constructor values and reject undeclared references. */
538
544
  declare function validateProgram(program: Program, args: Record<string, ArkadeParamValue>): void;
539
545
  /** The signer keys a program is compiled against. */
540
546
  interface ProgramKeys {
@@ -594,11 +600,11 @@ declare class ArkadeProgramScript extends VtxoScript {
594
600
  declare function parseArtifact(artifact: {
595
601
  version?: number;
596
602
  name?: string;
597
- params?: readonly InputRef[];
603
+ params?: readonly InputDef[];
598
604
  functions: unknown;
599
605
  }): Program;
600
606
  /**
601
- * Serialize a {@link Program} to compiler-artifact JSON — the inverse of
607
+ * Serialize a {@link Program} to normalized Program JSON — the inverse of
602
608
  * {@link parseArtifact}: bytes become `0x`-hex strings; bigint tokens become
603
609
  * plain numbers (or, above `Number.MAX_SAFE_INTEGER`, `0x`-hex of their
604
610
  * minimal script-num bytes, which the script encoder pushes identically);
@@ -636,4 +642,4 @@ declare function deserializeArkadeContractParams(params: Record<string, string>)
636
642
  */
637
643
  declare const ArkadeContractHandler: ContractHandler<ArkadeContractParams, ArkadeProgramScript> & TapscriptDeriving<ArkadeProgramScript>;
638
644
 
639
- export { type ArkadeParamValue as A, BoardingContractHandler as B, type CompiledProgramFunction as C, DefaultContractHandler as D, VHTLCV2ContractHandler as E, type VHTLCV2ContractParams as F, contractHandlers as G, type InputRef as I, type Program as P, SUPPORTED_PROGRAM_VERSION as S, type TapscriptSegment as T, VHTLC as V, type WitnessRef as W, ArkadeProgramScript as a, type ProgramKeys as b, type ArkadeArgValue as c, type ArkadeFunction as d, type InputDef as e, type ArkadeValueType as f, type ArkadeArgType as g, type ArkadeContractParams as h, type ArkadeSegment as i, type AsmToken as j, type SignerRef as k, type TweakedSigner as l, deserializeArkadeContractParams as m, stringifyArtifact as n, ArkadeContractHandler as o, parseArtifact as p, type BoardingContractParams as q, resolveAsm as r, serializeArkadeContractParams as s, type DefaultContractParams as t, DelegateContractHandler as u, validateProgram as v, witnessRefToBytes as w, type DelegateContractParams as x, VHTLCContractHandler as y, type VHTLCContractParams as z };
645
+ export { type ArkadeParamValue as A, BoardingContractHandler as B, type CompiledProgramFunction as C, DefaultContractHandler as D, VHTLCV2ContractHandler as E, type VHTLCV2ContractParams as F, contractHandlers as G, type InputDef as I, type Program as P, SUPPORTED_PROGRAM_VERSION as S, type TapscriptSegment as T, UnsupportedProgramVersionError as U, VHTLC as V, type WitnessRef as W, ArkadeProgramScript as a, type ProgramKeys as b, type ArkadeArgValue as c, type ArkadeFunction as d, type ArkadeValueType as e, type ArkadeArgType as f, type ArkadeContractParams as g, type ArkadeSegment as h, type AsmToken as i, type InputRef as j, type SignerRef as k, type TweakedSigner as l, deserializeArkadeContractParams as m, stringifyArtifact as n, ArkadeContractHandler as o, parseArtifact as p, type BoardingContractParams as q, resolveAsm as r, serializeArkadeContractParams as s, type DefaultContractParams as t, DelegateContractHandler as u, validateProgram as v, witnessRefToBytes as w, type DelegateContractParams as x, VHTLCContractHandler as y, type VHTLCContractParams as z };