@arkade-os/sdk 0.4.15 → 0.4.17

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 (197) hide show
  1. package/README.md +102 -96
  2. package/dist/cjs/arkfee/estimator.js +1 -1
  3. package/dist/cjs/arkfee/types.js +2 -1
  4. package/dist/cjs/arknote/index.js +43 -4
  5. package/dist/cjs/bip322/index.js +1 -1
  6. package/dist/cjs/contracts/arkcontract.js +1 -1
  7. package/dist/cjs/contracts/contractManager.js +60 -28
  8. package/dist/cjs/contracts/contractWatcher.js +29 -22
  9. package/dist/cjs/contracts/handlers/default.js +1 -1
  10. package/dist/cjs/contracts/handlers/delegate.js +1 -1
  11. package/dist/cjs/contracts/handlers/helpers.js +1 -1
  12. package/dist/cjs/extension/asset/assetGroup.js +92 -5
  13. package/dist/cjs/extension/asset/assetId.js +67 -3
  14. package/dist/cjs/extension/asset/assetInput.js +18 -0
  15. package/dist/cjs/extension/asset/assetOutput.js +15 -0
  16. package/dist/cjs/extension/asset/assetRef.js +66 -0
  17. package/dist/cjs/extension/asset/metadata.js +15 -0
  18. package/dist/cjs/extension/asset/packet.js +4 -1
  19. package/dist/cjs/extension/index.js +1 -1
  20. package/dist/cjs/forfeit.js +14 -0
  21. package/dist/cjs/identity/seedIdentity.js +2 -2
  22. package/dist/cjs/identity/singleKey.js +4 -0
  23. package/dist/cjs/intent/index.js +28 -12
  24. package/dist/cjs/providers/ark.js +3 -2
  25. package/dist/cjs/providers/delegator.js +20 -1
  26. package/dist/cjs/providers/expoArk.js +2 -2
  27. package/dist/cjs/providers/indexer.js +2 -2
  28. package/dist/cjs/providers/onchain.js +2 -1
  29. package/dist/cjs/repositories/realm/schemas.js +2 -2
  30. package/dist/cjs/repositories/realm/types.js +1 -1
  31. package/dist/cjs/script/address.js +37 -6
  32. package/dist/cjs/script/base.js +70 -1
  33. package/dist/cjs/script/default.js +3 -0
  34. package/dist/cjs/script/delegate.js +4 -0
  35. package/dist/cjs/script/tapscript.js +17 -2
  36. package/dist/cjs/script/vhtlc.js +35 -27
  37. package/dist/cjs/storage/fileSystem.js +1 -1
  38. package/dist/cjs/storage/inMemory.js +1 -1
  39. package/dist/cjs/storage/indexedDB.js +1 -1
  40. package/dist/cjs/storage/localStorage.js +1 -1
  41. package/dist/cjs/tree/validation.js +1 -1
  42. package/dist/cjs/utils/arkTransaction.js +5 -5
  43. package/dist/cjs/utils/bip21.js +16 -3
  44. package/dist/cjs/utils/syncCursors.js +4 -4
  45. package/dist/cjs/utils/transaction.js +1 -1
  46. package/dist/cjs/utils/transactionHistory.js +11 -11
  47. package/dist/cjs/utils/unknownFields.js +3 -3
  48. package/dist/cjs/wallet/asset-manager.js +4 -4
  49. package/dist/cjs/wallet/batch.js +5 -5
  50. package/dist/cjs/wallet/delegator.js +9 -8
  51. package/dist/cjs/wallet/expo/background.js +3 -3
  52. package/dist/cjs/wallet/expo/wallet.js +7 -7
  53. package/dist/cjs/wallet/index.js +43 -0
  54. package/dist/cjs/wallet/onchain.js +43 -5
  55. package/dist/cjs/wallet/ramps.js +44 -14
  56. package/dist/cjs/wallet/serviceWorker/wallet-message-handler.js +22 -22
  57. package/dist/cjs/wallet/serviceWorker/wallet.js +28 -24
  58. package/dist/cjs/wallet/unroll.js +12 -8
  59. package/dist/cjs/wallet/utils.js +1 -1
  60. package/dist/cjs/wallet/vtxo-manager.js +122 -82
  61. package/dist/cjs/wallet/wallet.js +140 -77
  62. package/dist/cjs/worker/expo/asyncStorageTaskQueue.js +1 -1
  63. package/dist/cjs/worker/expo/processors/contractPollProcessor.js +2 -2
  64. package/dist/cjs/worker/expo/taskRunner.js +3 -3
  65. package/dist/cjs/worker/messageBus.js +3 -0
  66. package/dist/esm/arkfee/estimator.js +1 -1
  67. package/dist/esm/arkfee/types.js +2 -1
  68. package/dist/esm/arknote/index.js +43 -4
  69. package/dist/esm/bip322/index.js +1 -1
  70. package/dist/esm/contracts/arkcontract.js +1 -1
  71. package/dist/esm/contracts/contractManager.js +60 -28
  72. package/dist/esm/contracts/contractWatcher.js +29 -22
  73. package/dist/esm/contracts/handlers/default.js +1 -1
  74. package/dist/esm/contracts/handlers/delegate.js +1 -1
  75. package/dist/esm/contracts/handlers/helpers.js +1 -1
  76. package/dist/esm/extension/asset/assetGroup.js +92 -5
  77. package/dist/esm/extension/asset/assetId.js +67 -3
  78. package/dist/esm/extension/asset/assetInput.js +18 -0
  79. package/dist/esm/extension/asset/assetOutput.js +15 -0
  80. package/dist/esm/extension/asset/assetRef.js +66 -0
  81. package/dist/esm/extension/asset/metadata.js +15 -0
  82. package/dist/esm/extension/asset/packet.js +4 -1
  83. package/dist/esm/extension/index.js +1 -1
  84. package/dist/esm/forfeit.js +14 -0
  85. package/dist/esm/identity/seedIdentity.js +2 -2
  86. package/dist/esm/identity/singleKey.js +4 -0
  87. package/dist/esm/index.js +1 -1
  88. package/dist/esm/intent/index.js +28 -12
  89. package/dist/esm/providers/ark.js +3 -2
  90. package/dist/esm/providers/delegator.js +20 -1
  91. package/dist/esm/providers/expoArk.js +2 -2
  92. package/dist/esm/providers/indexer.js +2 -2
  93. package/dist/esm/providers/onchain.js +2 -1
  94. package/dist/esm/repositories/realm/schemas.js +2 -2
  95. package/dist/esm/repositories/realm/types.js +1 -1
  96. package/dist/esm/script/address.js +37 -6
  97. package/dist/esm/script/base.js +70 -1
  98. package/dist/esm/script/default.js +3 -0
  99. package/dist/esm/script/delegate.js +4 -0
  100. package/dist/esm/script/tapscript.js +17 -2
  101. package/dist/esm/script/vhtlc.js +35 -27
  102. package/dist/esm/storage/fileSystem.js +1 -1
  103. package/dist/esm/storage/inMemory.js +1 -1
  104. package/dist/esm/storage/indexedDB.js +1 -1
  105. package/dist/esm/storage/localStorage.js +1 -1
  106. package/dist/esm/tree/validation.js +1 -1
  107. package/dist/esm/utils/arkTransaction.js +5 -5
  108. package/dist/esm/utils/bip21.js +16 -3
  109. package/dist/esm/utils/syncCursors.js +4 -4
  110. package/dist/esm/utils/transaction.js +1 -1
  111. package/dist/esm/utils/transactionHistory.js +11 -11
  112. package/dist/esm/utils/unknownFields.js +3 -3
  113. package/dist/esm/wallet/asset-manager.js +4 -4
  114. package/dist/esm/wallet/batch.js +5 -5
  115. package/dist/esm/wallet/delegator.js +9 -8
  116. package/dist/esm/wallet/expo/background.js +3 -3
  117. package/dist/esm/wallet/expo/wallet.js +7 -7
  118. package/dist/esm/wallet/index.js +43 -0
  119. package/dist/esm/wallet/onchain.js +43 -5
  120. package/dist/esm/wallet/ramps.js +44 -14
  121. package/dist/esm/wallet/serviceWorker/wallet-message-handler.js +22 -22
  122. package/dist/esm/wallet/serviceWorker/wallet.js +28 -24
  123. package/dist/esm/wallet/unroll.js +12 -8
  124. package/dist/esm/wallet/utils.js +1 -1
  125. package/dist/esm/wallet/vtxo-manager.js +121 -81
  126. package/dist/esm/wallet/wallet.js +140 -77
  127. package/dist/esm/worker/expo/asyncStorageTaskQueue.js +1 -1
  128. package/dist/esm/worker/expo/processors/contractPollProcessor.js +2 -2
  129. package/dist/esm/worker/expo/taskRunner.js +3 -3
  130. package/dist/esm/worker/messageBus.js +3 -0
  131. package/dist/types/arkfee/estimator.d.ts +1 -1
  132. package/dist/types/arkfee/types.d.ts +2 -1
  133. package/dist/types/arknote/index.d.ts +44 -4
  134. package/dist/types/bip322/index.d.ts +1 -1
  135. package/dist/types/contracts/arkcontract.d.ts +1 -1
  136. package/dist/types/contracts/contractManager.d.ts +39 -65
  137. package/dist/types/contracts/contractWatcher.d.ts +39 -18
  138. package/dist/types/contracts/handlers/default.d.ts +1 -1
  139. package/dist/types/contracts/handlers/delegate.d.ts +1 -1
  140. package/dist/types/contracts/handlers/helpers.d.ts +1 -1
  141. package/dist/types/contracts/types.d.ts +36 -26
  142. package/dist/types/extension/asset/assetGroup.d.ts +92 -1
  143. package/dist/types/extension/asset/assetId.d.ts +67 -3
  144. package/dist/types/extension/asset/assetInput.d.ts +18 -0
  145. package/dist/types/extension/asset/assetOutput.d.ts +15 -0
  146. package/dist/types/extension/asset/assetRef.d.ts +66 -0
  147. package/dist/types/extension/asset/metadata.d.ts +15 -0
  148. package/dist/types/extension/asset/packet.d.ts +4 -1
  149. package/dist/types/extension/index.d.ts +1 -1
  150. package/dist/types/forfeit.d.ts +14 -0
  151. package/dist/types/identity/index.d.ts +16 -0
  152. package/dist/types/identity/seedIdentity.d.ts +8 -6
  153. package/dist/types/identity/singleKey.d.ts +4 -0
  154. package/dist/types/intent/index.d.ts +19 -6
  155. package/dist/types/providers/ark.d.ts +40 -2
  156. package/dist/types/providers/delegator.d.ts +54 -1
  157. package/dist/types/providers/expoArk.d.ts +2 -2
  158. package/dist/types/providers/indexer.d.ts +105 -2
  159. package/dist/types/providers/onchain.d.ts +62 -1
  160. package/dist/types/repositories/realm/schemas.d.ts +2 -2
  161. package/dist/types/repositories/realm/types.d.ts +2 -2
  162. package/dist/types/repositories/walletRepository.d.ts +16 -0
  163. package/dist/types/script/address.d.ts +35 -2
  164. package/dist/types/script/base.d.ts +66 -1
  165. package/dist/types/script/default.d.ts +3 -0
  166. package/dist/types/script/delegate.d.ts +4 -0
  167. package/dist/types/script/tapscript.d.ts +17 -2
  168. package/dist/types/script/vhtlc.d.ts +35 -27
  169. package/dist/types/storage/fileSystem.d.ts +1 -1
  170. package/dist/types/storage/inMemory.d.ts +1 -1
  171. package/dist/types/storage/index.d.ts +1 -1
  172. package/dist/types/storage/indexedDB.d.ts +1 -1
  173. package/dist/types/storage/localStorage.d.ts +1 -1
  174. package/dist/types/utils/arkTransaction.d.ts +3 -3
  175. package/dist/types/utils/bip21.d.ts +17 -0
  176. package/dist/types/utils/syncCursors.d.ts +4 -4
  177. package/dist/types/utils/transaction.d.ts +1 -1
  178. package/dist/types/utils/transactionHistory.d.ts +3 -3
  179. package/dist/types/utils/unknownFields.d.ts +5 -5
  180. package/dist/types/wallet/asset-manager.d.ts +3 -3
  181. package/dist/types/wallet/batch.d.ts +27 -7
  182. package/dist/types/wallet/delegator.d.ts +10 -0
  183. package/dist/types/wallet/expo/background.d.ts +4 -4
  184. package/dist/types/wallet/expo/wallet.d.ts +10 -10
  185. package/dist/types/wallet/index.d.ts +457 -25
  186. package/dist/types/wallet/onchain.d.ts +42 -4
  187. package/dist/types/wallet/ramps.d.ts +40 -10
  188. package/dist/types/wallet/serviceWorker/wallet-message-handler.d.ts +4 -4
  189. package/dist/types/wallet/serviceWorker/wallet.d.ts +71 -33
  190. package/dist/types/wallet/unroll.d.ts +8 -6
  191. package/dist/types/wallet/vtxo-manager.d.ts +146 -93
  192. package/dist/types/wallet/wallet.d.ts +91 -33
  193. package/dist/types/worker/expo/asyncStorageTaskQueue.d.ts +1 -1
  194. package/dist/types/worker/expo/processors/contractPollProcessor.d.ts +1 -1
  195. package/dist/types/worker/expo/taskRunner.d.ts +6 -6
  196. package/dist/types/worker/messageBus.d.ts +5 -3
  197. package/package.json +1 -1
@@ -5,7 +5,22 @@ import { AssetOutput } from "./assetOutput";
5
5
  import { Metadata } from "./metadata";
6
6
  import { BufferReader, BufferWriter } from "./utils";
7
7
  /**
8
- * An asset group contains inputs/outputs and all data related to a given asset id.
8
+ * An asset group contains inputs, outputs, and all data related to a given asset id.
9
+ *
10
+ * @see Packet
11
+ * @see AssetId
12
+ * @see AssetRef
13
+ *
14
+ * @example
15
+ * ```typescript
16
+ * const group = AssetGroup.create(
17
+ * null, // asset ID: null for new issuance
18
+ * null, // control asset ID: null when reissuance not needed
19
+ * [], // asset inputs: empty for new issuance
20
+ * [AssetOutput.create(0, 1000)], // asset outputs: 1000 units at vout index 0
21
+ * [] // metadata: can be empty
22
+ * )
23
+ * ```
9
24
  */
10
25
  export declare class AssetGroup {
11
26
  readonly assetId: AssetId | null;
@@ -13,16 +28,92 @@ export declare class AssetGroup {
13
28
  readonly inputs: AssetInput[];
14
29
  readonly outputs: AssetOutput[];
15
30
  private readonly metadataList;
31
+ /** @see create */
16
32
  constructor(assetId: AssetId | null, controlAsset: AssetRef | null, inputs: AssetInput[], outputs: AssetOutput[], metadata: Metadata[]);
33
+ /**
34
+ * Create and validate an asset group.
35
+ *
36
+ * @param assetId - Asset id for this group, or `null` for fresh issuance
37
+ * @param controlAsset - Optional control asset reference for (re) issuance
38
+ * @param inputs - Asset inputs in the group
39
+ * @param outputs - Asset outputs in the group
40
+ * @param metadata - Metadata entries associated with the group
41
+ * @returns A validated asset group
42
+ * @throws Error if the group fails validation
43
+ * @see validate
44
+ */
17
45
  static create(assetId: AssetId | null, controlAsset: AssetRef | null, inputs: AssetInput[], outputs: AssetOutput[], metadata: Metadata[]): AssetGroup;
46
+ /**
47
+ * Decode an asset group from its hex string form.
48
+ *
49
+ * @param s - Hex-encoded asset group
50
+ * @returns Decoded asset group
51
+ * @throws Error if the string is not valid hex or does not encode a valid asset group
52
+ * @see toString
53
+ */
18
54
  static fromString(s: string): AssetGroup;
55
+ /**
56
+ * Decode an asset group from its serialized bytes.
57
+ *
58
+ * @param buf - Serialized asset group bytes
59
+ * @returns Decoded asset group
60
+ * @throws Error if the buffer is empty or malformed
61
+ */
19
62
  static fromBytes(buf: Uint8Array): AssetGroup;
63
+ /**
64
+ * Return true when the group represents an issuance.
65
+ *
66
+ * @returns `true` when the group has no asset id
67
+ */
20
68
  isIssuance(): boolean;
69
+ /**
70
+ * Return true when the group represents a reissuance.
71
+ *
72
+ * @returns `true` when the group has an asset id and outputs exceed local inputs
73
+ * @remarks
74
+ * Only local inputs contribute to the comparison; intent-backed inputs contribute `0` here.
75
+ */
21
76
  isReissuance(): boolean;
77
+ /**
78
+ * Serialize the asset group to raw bytes.
79
+ *
80
+ * @returns Serialized asset group bytes
81
+ * @see fromBytes
82
+ */
22
83
  serialize(): Uint8Array;
84
+ /**
85
+ * Validate the asset group and its child structures.
86
+ *
87
+ * @throws Error if the group is empty or violates issuance invariants
88
+ */
23
89
  validate(): void;
90
+ /**
91
+ * Convert the group into its batch-leaf representation for the given intent txid.
92
+ *
93
+ * @param intentTxid - Intent transaction id used to build the leaf input reference
94
+ * @returns Batch-leaf asset group
95
+ * @see AssetInput.createIntent
96
+ */
24
97
  toBatchLeafAssetGroup(intentTxid: Uint8Array): AssetGroup;
98
+ /**
99
+ * Encode the asset group to a hex string.
100
+ *
101
+ * @returns Hex-encoded asset group
102
+ * @see fromString
103
+ */
25
104
  toString(): string;
105
+ /**
106
+ * Decode an asset group from a binary reader.
107
+ *
108
+ * @param reader - Reader positioned at an asset group
109
+ * @returns Decoded asset group
110
+ * @throws Error if the encoded group is malformed
111
+ */
26
112
  static fromReader(reader: BufferReader): AssetGroup;
113
+ /**
114
+ * Serialize the asset group into an existing binary writer.
115
+ *
116
+ * @param writer - Writer to append the asset group to
117
+ */
27
118
  serializeTo(writer: BufferWriter): void;
28
119
  }
@@ -1,19 +1,83 @@
1
1
  import { BufferReader, BufferWriter } from "./utils";
2
2
  /**
3
- * AssetId represents the id of an asset.
4
- * @param txid - the genesis transaction id (decoded from hex)
5
- * @param groupIndex - the asset group index in the genesis transaction
3
+ * AssetId identifies a specific asset.
4
+ *
5
+ * @remarks
6
+ * Asset ids are derived from the genesis transaction id plus the asset group index.
7
+ *
8
+ * @see AssetRef
9
+ *
10
+ * @example
11
+ * ```typescript
12
+ * const assetId = AssetId.create('00'.repeat(32), 0)
13
+ * const encoded = assetId.toString()
14
+ * const decoded = AssetId.fromString(encoded)
15
+ * ```
6
16
  */
7
17
  export declare class AssetId {
8
18
  readonly txid: Uint8Array;
9
19
  readonly groupIndex: number;
10
20
  private constructor();
21
+ /**
22
+ * Create an asset id from a genesis transaction id and group index.
23
+ *
24
+ * @param txid - Hex-encoded genesis transaction id
25
+ * @param groupIndex - Asset group index within the genesis transaction
26
+ * @returns A validated asset id
27
+ * @throws Error if the txid is missing, malformed, or not 32 bytes long
28
+ * @see fromString
29
+ */
11
30
  static create(txid: string, groupIndex: number): AssetId;
31
+ /**
32
+ * Decode an asset id from its hex string representation.
33
+ *
34
+ * @param s - Hex-encoded asset id
35
+ * @returns Decoded asset id
36
+ * @throws Error if the string is not valid hex or does not encode a valid asset id
37
+ * @see toString
38
+ */
12
39
  static fromString(s: string): AssetId;
40
+ /**
41
+ * Decode an asset id from its serialized bytes.
42
+ *
43
+ * @param buf - Serialized asset id bytes
44
+ * @returns Decoded asset id
45
+ * @throws Error if the buffer length is invalid
46
+ */
13
47
  static fromBytes(buf: Uint8Array): AssetId;
48
+ /**
49
+ * Serialize the asset id to raw bytes.
50
+ *
51
+ * @returns Serialized asset id bytes
52
+ * @see fromBytes
53
+ */
14
54
  serialize(): Uint8Array;
55
+ /**
56
+ * Encode the asset id to a hex string.
57
+ *
58
+ * @returns Hex-encoded asset id
59
+ * @see fromString
60
+ */
15
61
  toString(): string;
62
+ /**
63
+ * Validate the asset id fields.
64
+ *
65
+ * @throws Error if the txid is empty or the group index is out of range
66
+ */
16
67
  validate(): void;
68
+ /**
69
+ * Decode an asset id from a binary reader.
70
+ *
71
+ * @param reader - Reader positioned at an asset id
72
+ * @returns Decoded asset id
73
+ * @throws Error if the reader does not contain enough bytes
74
+ */
17
75
  static fromReader(reader: BufferReader): AssetId;
76
+ /**
77
+ * Serialize the asset id into an existing binary writer.
78
+ *
79
+ * @param writer - Writer to append the asset id to
80
+ * @see serialize
81
+ */
18
82
  serializeTo(writer: BufferWriter): void;
19
83
  }
@@ -17,16 +17,27 @@ type AssetInputIntent = Pick<AssetInputLocal, "vin" | "amount"> & {
17
17
  export declare class AssetInput {
18
18
  readonly input: AssetInputLocal | AssetInputIntent;
19
19
  private constructor();
20
+ /** Gets the transaction input index for an asset input, e.g. 0 */
20
21
  get vin(): number;
22
+ /** Gets the amount for an input (in most cases, 330 sats) */
21
23
  get amount(): bigint;
24
+ /** Create a local asset input that points at a transaction input index. */
22
25
  static create(vin: number, amount: bigint | number): AssetInput;
26
+ /** Create an intent-backed asset input referencing an external intent transaction. */
23
27
  static createIntent(txid: string, vin: number, amount: bigint | number): AssetInput;
28
+ /** Decode an asset input from its hex string form. */
24
29
  static fromString(s: string): AssetInput;
30
+ /** Decode an asset input from its serialized bytes. */
25
31
  static fromBytes(buf: Uint8Array): AssetInput;
32
+ /** Serialize the asset input to raw bytes. */
26
33
  serialize(): Uint8Array;
34
+ /** Encode the asset input to a hex string. */
27
35
  toString(): string;
36
+ /** Validate the asset input fields. */
28
37
  validate(): void;
38
+ /** Decode an asset input from a buffer reader. */
29
39
  static fromReader(reader: BufferReader): AssetInput;
40
+ /** Serialize the asset input into an existing buffer writer. */
30
41
  serializeTo(writer: BufferWriter): void;
31
42
  }
32
43
  /**
@@ -35,12 +46,19 @@ export declare class AssetInput {
35
46
  export declare class AssetInputs {
36
47
  readonly inputs: AssetInput[];
37
48
  private constructor();
49
+ /** Create a validated list of asset inputs. */
38
50
  static create(inputs: AssetInput[]): AssetInputs;
51
+ /** Decode an asset input list from its hex string form. */
39
52
  static fromString(s: string): AssetInputs;
53
+ /** Serialize the asset input list to raw bytes. */
40
54
  serialize(): Uint8Array;
55
+ /** Encode the asset input list to a hex string. */
41
56
  toString(): string;
57
+ /** Validate the asset input list. */
42
58
  validate(): void;
59
+ /** Decode an asset input list from a buffer reader. */
43
60
  static fromReader(reader: BufferReader): AssetInputs;
61
+ /** Serialize the asset input list into an existing buffer writer. */
44
62
  serializeTo(writer: BufferWriter): void;
45
63
  }
46
64
  export {};
@@ -11,13 +11,21 @@ export declare class AssetOutput {
11
11
  readonly amount: bigint;
12
12
  static readonly TYPE_LOCAL = 1;
13
13
  private constructor();
14
+ /** Create a local asset output referencing a transaction output index. */
14
15
  static create(vout: number, amount: bigint | number): AssetOutput;
16
+ /** Decode an asset output from its hex string form. */
15
17
  static fromString(s: string): AssetOutput;
18
+ /** Decode an asset output from its serialized bytes. */
16
19
  static fromBytes(buf: Uint8Array): AssetOutput;
20
+ /** Serialize the asset output to raw bytes. */
17
21
  serialize(): Uint8Array;
22
+ /** Encode the asset output to a hex string. */
18
23
  toString(): string;
24
+ /** Validate the asset output fields. */
19
25
  validate(): void;
26
+ /** Decode an asset output from a buffer reader. */
20
27
  static fromReader(reader: BufferReader): AssetOutput;
28
+ /** Serialize the asset output into an existing buffer writer. */
21
29
  serializeTo(writer: BufferWriter): void;
22
30
  }
23
31
  /**
@@ -29,11 +37,18 @@ export declare class AssetOutput {
29
37
  export declare class AssetOutputs {
30
38
  readonly outputs: AssetOutput[];
31
39
  private constructor();
40
+ /** Create a validated list of asset outputs. */
32
41
  static create(outputs: AssetOutput[]): AssetOutputs;
42
+ /** Decode an asset output list from its hex string form. */
33
43
  static fromString(s: string): AssetOutputs;
44
+ /** Serialize the asset output list to raw bytes. */
34
45
  serialize(): Uint8Array;
46
+ /** Encode the asset output list to a hex string. */
35
47
  toString(): string;
48
+ /** Validate the asset output list. */
36
49
  validate(): void;
50
+ /** Decode an asset output list from a buffer reader. */
37
51
  static fromReader(reader: BufferReader): AssetOutputs;
52
+ /** Serialize the asset output list into an existing buffer writer. */
38
53
  serializeTo(writer: BufferWriter): void;
39
54
  }
@@ -9,17 +9,83 @@ type AssetRefByGroup = {
9
9
  type: AssetRefType.ByGroup;
10
10
  groupIndex: number;
11
11
  };
12
+ /**
13
+ * Reference to either an explicit asset id or another asset group in the same packet.
14
+ *
15
+ * @see AssetId
16
+ *
17
+ * @example
18
+ * ```typescript
19
+ * const refById = AssetRef.fromId(assetId)
20
+ * const refByGroup = AssetRef.fromGroupIndex(0)
21
+ * ```
22
+ */
12
23
  export declare class AssetRef {
13
24
  readonly ref: AssetRefByID | AssetRefByGroup;
14
25
  private constructor();
26
+ /** Reference type discriminator. */
15
27
  get type(): AssetRefType;
28
+ /**
29
+ * Create an asset reference that points to a specific asset id.
30
+ *
31
+ * @param assetId - Asset id referenced by this pointer
32
+ * @returns Asset reference by id
33
+ * @see fromGroupIndex
34
+ */
16
35
  static fromId(assetId: AssetId): AssetRef;
36
+ /**
37
+ * Create an asset reference that points to another asset group by index.
38
+ *
39
+ * @param groupIndex - Zero-based asset group index in the packet
40
+ * @returns Asset reference by group index
41
+ * @see fromId
42
+ */
17
43
  static fromGroupIndex(groupIndex: number): AssetRef;
44
+ /**
45
+ * Decode an asset reference from its hex string form.
46
+ *
47
+ * @param s - Hex-encoded asset reference
48
+ * @returns Decoded asset reference
49
+ * @throws Error if the string is not valid hex or does not encode a valid asset reference
50
+ * @see toString
51
+ */
18
52
  static fromString(s: string): AssetRef;
53
+ /**
54
+ * Decode an asset reference from its serialized bytes.
55
+ *
56
+ * @param buf - Serialized asset reference bytes
57
+ * @returns Decoded asset reference
58
+ * @throws Error if the buffer is empty or malformed
59
+ */
19
60
  static fromBytes(buf: Uint8Array): AssetRef;
61
+ /**
62
+ * Serialize the asset reference to raw bytes.
63
+ *
64
+ * @returns Serialized asset reference bytes
65
+ * @see fromBytes
66
+ */
20
67
  serialize(): Uint8Array;
68
+ /**
69
+ * Encode the asset reference to a hex string.
70
+ *
71
+ * @returns Hex-encoded asset reference
72
+ * @see fromString
73
+ */
21
74
  toString(): string;
75
+ /**
76
+ * Decode an asset reference from a binary reader.
77
+ *
78
+ * @param reader - Reader positioned at an asset reference
79
+ * @returns Decoded asset reference
80
+ * @throws Error if the type is unknown or the reader does not contain enough bytes
81
+ */
22
82
  static fromReader(reader: BufferReader): AssetRef;
83
+ /**
84
+ * Serialize the asset reference into an existing binary writer.
85
+ *
86
+ * @param writer - Writer to append the asset reference to
87
+ * @see serialize
88
+ */
23
89
  serializeTo(writer: BufferWriter): void;
24
90
  }
25
91
  export {};
@@ -9,15 +9,23 @@ export declare class Metadata {
9
9
  readonly key: Uint8Array;
10
10
  readonly value: Uint8Array;
11
11
  private constructor();
12
+ /** Create a metadata entry from raw key and value bytes. */
12
13
  static create(key: Bytes, value: Bytes): Metadata;
14
+ /** Decode metadata from its hex string form. */
13
15
  static fromString(s: string): Metadata;
16
+ /** Decode metadata from its serialized bytes. */
14
17
  static fromBytes(buf: Uint8Array): Metadata;
18
+ /** Serialize metadata to raw bytes. */
15
19
  serialize(): Uint8Array;
20
+ /** Encode metadata to a hex string. */
16
21
  toString(): string;
17
22
  get keyString(): string;
18
23
  get valueString(): string;
24
+ /** Validate the metadata key and value. */
19
25
  validate(): void;
26
+ /** Decode metadata from a buffer reader. */
20
27
  static fromReader(reader: BufferReader): Metadata;
28
+ /** Serialize metadata into an existing buffer writer. */
21
29
  serializeTo(writer: BufferWriter): void;
22
30
  }
23
31
  export declare class MetadataList {
@@ -26,12 +34,19 @@ export declare class MetadataList {
26
34
  static readonly ARK_BRANCH_TAG = "ArkadeAssetBranch";
27
35
  static readonly ARK_LEAF_VERSION = 0;
28
36
  constructor(items: Metadata[]);
37
+ /** Create a metadata list from its hex string form. */
29
38
  static fromString(s: string): MetadataList;
39
+ /** Decode a metadata list from its serialized bytes. */
30
40
  static fromBytes(buf: Uint8Array): MetadataList;
41
+ /** Decode a metadata list from a buffer reader. */
31
42
  static fromReader(reader: BufferReader): MetadataList;
43
+ /** Serialize the metadata list into an existing buffer writer. */
32
44
  serializeTo(writer: BufferWriter): void;
45
+ /** Serialize the metadata list to raw bytes. */
33
46
  serialize(): Uint8Array;
47
+ /** Iterate through metadata entries in insertion order. */
34
48
  [Symbol.iterator](): Iterator<Metadata>;
35
49
  get length(): number;
50
+ /** Compute the tagged Merkle root for the metadata list. */
36
51
  hash(): Uint8Array;
37
52
  }
@@ -9,6 +9,7 @@ export declare class Packet implements ExtensionPacket {
9
9
  /** PACKET_TYPE is the 1-byte TLV type tag used in the Extension envelope. */
10
10
  static readonly PACKET_TYPE = 0;
11
11
  private constructor();
12
+ /** Create a validated asset packet from a list of asset groups. */
12
13
  static create(groups: AssetGroup[]): Packet;
13
14
  /**
14
15
  * fromBytes parses a Packet from raw bytes.
@@ -22,10 +23,11 @@ export declare class Packet implements ExtensionPacket {
22
23
  * type returns the TLV packet type tag. Implements ExtensionPacket interface.
23
24
  */
24
25
  type(): number;
26
+ /** Convert the packet into the batch-leaf form for a specific intent transaction id. */
25
27
  leafTxPacket(intentTxid: Uint8Array): Packet;
26
28
  /**
27
29
  * serialize encodes the packet as raw bytes (varint group count + group data).
28
- * Does NOT include OP_RETURN, ARK magic, or TLV type/length those are
30
+ * Does NOT include OP_RETURN, Arkade magic bytes (`ARK`), or TLV type/length; those are
29
31
  * added by the Extension module.
30
32
  */
31
33
  serialize(): Uint8Array;
@@ -33,6 +35,7 @@ export declare class Packet implements ExtensionPacket {
33
35
  * toString returns the hex-encoded raw packet bytes.
34
36
  */
35
37
  toString(): string;
38
+ /** Validate packet structure and cross-group references. */
36
39
  validate(): void;
37
40
  private static fromReader;
38
41
  }
@@ -6,7 +6,7 @@ export type { ExtensionPacket } from "./packet";
6
6
  export { UnknownPacket } from "./packet";
7
7
  /**
8
8
  * ArkadeMagic is the 3-byte magic prefix ("ARK") that identifies an OP_RETURN
9
- * output as an ark extension blob.
9
+ * output as an Arkade extension blob.
10
10
  */
11
11
  export declare const ARKADE_MAGIC: Uint8Array<ArrayBuffer>;
12
12
  /**
@@ -1,4 +1,18 @@
1
1
  import { Transaction } from "./utils/transaction";
2
2
  import { TransactionInputUpdate, TransactionOutput } from "@scure/btc-signer/psbt.js";
3
+ /**
4
+ * Build a forfeit transaction that spends the provided inputs to a single forfeit output.
5
+ *
6
+ * @param inputs - Inputs to include in the forfeit transaction
7
+ * @param forfeitPkScript - ScriptPubKey for the forfeit output
8
+ * @param txLocktime - Optional locktime to apply to the transaction
9
+ */
3
10
  export declare function buildForfeitTx(inputs: TransactionInputUpdate[], forfeitPkScript: Uint8Array, txLocktime?: number): Transaction;
11
+ /**
12
+ * Build a forfeit transaction using an explicit output descriptor (used for delegated renewals)
13
+ *
14
+ * @param inputs - Inputs to include in the forfeit transaction
15
+ * @param output - Primary transaction output
16
+ * @param txLocktime - Optional locktime to apply to the transaction
17
+ */
4
18
  export declare function buildForfeitTxWithOutput(inputs: TransactionInputUpdate[], output: TransactionOutput, txLocktime?: number): Transaction;
@@ -1,12 +1,22 @@
1
1
  import { Transaction } from "../utils/transaction";
2
2
  import { SignerSession } from "../tree/signingSession";
3
3
  export interface Identity extends ReadonlyIdentity {
4
+ /** Returns a signer session used for musig2 tree signing flows. */
4
5
  signerSession(): SignerSession;
6
+ /** Sign an arbitrary message using the requested signature type. */
5
7
  signMessage(message: Uint8Array, signatureType: "schnorr" | "ecdsa"): Promise<Uint8Array>;
8
+ /**
9
+ * Sign the provided transaction inputs.
10
+ *
11
+ * @param tx - Transaction to sign
12
+ * @param inputIndexes - Optional input indexes to sign. When omitted, the implementation should sign every signable input.
13
+ */
6
14
  sign(tx: Transaction, inputIndexes?: number[]): Promise<Transaction>;
7
15
  }
8
16
  export interface ReadonlyIdentity {
17
+ /** Returns the x-only public key used by Taproot scripts. */
9
18
  xOnlyPublicKey(): Promise<Uint8Array>;
19
+ /** Returns the compressed public key for this identity. */
10
20
  compressedPublicKey(): Promise<Uint8Array>;
11
21
  }
12
22
  /** A single PSBT signing request within a batch. */
@@ -25,6 +35,12 @@ export interface SignRequest {
25
35
  * will throw if the lengths do not match.
26
36
  */
27
37
  export interface BatchSignableIdentity extends Identity {
38
+ /**
39
+ * Sign multiple transactions in a single wallet interaction.
40
+ *
41
+ * @param requests - Transactions and optional input indexes to sign
42
+ * @returns Signed transactions in the same order as the input requests
43
+ */
28
44
  signMultiple(requests: SignRequest[]): Promise<Transaction[]>;
29
45
  }
30
46
  /** Type guard for identities that support batch signing. */
@@ -1,21 +1,23 @@
1
1
  import { Identity, ReadonlyIdentity } from ".";
2
2
  import { Transaction } from "../utils/transaction";
3
3
  import { SignerSession } from "../tree/signingSession";
4
- /** Use default BIP86 derivation with network selection. */
4
+ /** Used for default BIP86 derivation with network selection. */
5
5
  export interface NetworkOptions {
6
6
  /**
7
7
  * Mainnet (coin type 0) or testnet (coin type 1).
8
- * @default true
8
+ *
9
+ * @defaultValue `true`
9
10
  */
10
11
  isMainnet?: boolean;
11
12
  }
12
- /** Use a custom output descriptor for derivation. */
13
+ /** Used for custom output descriptor derivation. */
13
14
  export interface DescriptorOptions {
14
15
  /** Custom output descriptor that determines the derivation path. */
15
16
  descriptor: string;
16
17
  }
17
- /** Either default BIP86 derivation (with optional network) or a custom descriptor. */
18
+ /** Either default BIP86 derivation (with optional network selection) or a custom descriptor. */
18
19
  export type SeedIdentityOptions = NetworkOptions | DescriptorOptions;
20
+ /** Used for deriving an identity from a BIP39 mnemonic. */
19
21
  export type MnemonicOptions = SeedIdentityOptions & {
20
22
  /** Optional BIP39 passphrase for additional seed entropy. */
21
23
  passphrase?: string;
@@ -29,7 +31,7 @@ export type MnemonicOptions = SeedIdentityOptions & {
29
31
  * format is HD-ready, allowing future support for multiple addresses
30
32
  * and change derivation.
31
33
  *
32
- * Prefer this (or {@link MnemonicIdentity}) over `SingleKey` for new
34
+ * Prefer this (or @see MnemonicIdentity) over `SingleKey` for new
33
35
  * integrations — `SingleKey` exists for backward compatibility with
34
36
  * raw nsec-style keys.
35
37
  *
@@ -77,7 +79,7 @@ export declare class SeedIdentity implements Identity {
77
79
  *
78
80
  * This is the most user-friendly identity type — recommended for wallet
79
81
  * applications where users manage their own backup phrase. Extends
80
- * {@link SeedIdentity} with mnemonic validation and optional passphrase
82
+ * @see SeedIdentity with mnemonic validation and optional passphrase
81
83
  * support.
82
84
  *
83
85
  * @example
@@ -22,8 +22,11 @@ import { SignerSession } from "../tree/signingSession";
22
22
  export declare class SingleKey implements Identity {
23
23
  private key;
24
24
  private constructor();
25
+ /** Create a signing identity from raw private key bytes. */
25
26
  static fromPrivateKey(privateKey: Uint8Array): SingleKey;
27
+ /** Create a signing identity from a hex-encoded private key. */
26
28
  static fromHex(privateKeyHex: string): SingleKey;
29
+ /** Create a signing identity with a freshly generated random private key. */
27
30
  static fromRandomBytes(): SingleKey;
28
31
  /**
29
32
  * Export the private key as a hex string.
@@ -40,6 +43,7 @@ export declare class SingleKey implements Identity {
40
43
  }
41
44
  export declare class ReadonlySingleKey implements ReadonlyIdentity {
42
45
  private readonly publicKey;
46
+ /** Create a readonly identity from a compressed public key. */
43
47
  constructor(publicKey: Uint8Array);
44
48
  /**
45
49
  * Create a ReadonlySingleKey from a compressed public key.
@@ -5,10 +5,11 @@ import { ExtendedCoin } from "../wallet";
5
5
  * Intent proof implementation for Bitcoin message signing.
6
6
  *
7
7
  * Intent proof defines a standard for signing Bitcoin messages as well as proving
8
- * ownership of coins. This namespace provides utilities for creating and
9
- * validating Intent proof.
8
+ * ownership of outputs.
10
9
  *
11
- * it is greatly inspired by BIP322.
10
+ * This namespace provides utilities for creating and validating Intent proof.
11
+ *
12
+ * It is greatly inspired by BIP322.
12
13
  * @see https://github.com/bitcoin/bips/blob/master/bip-0322.mediawiki
13
14
  *
14
15
  * @example
@@ -30,15 +31,21 @@ export declare namespace Intent {
30
31
  * Creates a new Intent proof unsigned transaction.
31
32
  *
32
33
  * This function constructs a special transaction that can be signed to prove
33
- * ownership of VTXOs and UTXOs. The proof includes the message to be
34
+ * ownership of onchain and virtual outputs. The proof includes the message to be
34
35
  * signed and the inputs/outputs that demonstrate ownership.
35
36
  *
36
37
  * @param message - The Intent message to be signed, either raw string of Message object
37
- * @param inputs - Array of transaction inputs to prove ownership of
38
+ * @param ins - Array of transaction inputs to prove ownership of
38
39
  * @param outputs - Optional array of transaction outputs
39
40
  * @returns An unsigned Intent proof transaction
40
41
  */
41
42
  function create(message: string | Message, ins: (TransactionInput | ExtendedCoin)[], outputs?: TransactionOutput[]): Proof;
43
+ /**
44
+ * Compute the fee paid by an intent proof transaction.
45
+ *
46
+ * @param proof - Intent proof transaction
47
+ * @returns The fee in satoshis
48
+ */
42
49
  function fee(proof: Proof): number;
43
50
  type RegisterMessage = {
44
51
  type: "register";
@@ -56,6 +63,12 @@ export declare namespace Intent {
56
63
  expire_at: number;
57
64
  };
58
65
  type Message = RegisterMessage | DeleteMessage | GetPendingTxMessage;
66
+ /**
67
+ * Serialize an intent message to the canonical JSON string used for signing.
68
+ *
69
+ * @param message - Intent message payload
70
+ * @returns Canonical string form of the message
71
+ */
59
72
  function encodeMessage(message: Message): string;
60
73
  }
61
74
  export declare const OP_RETURN_EMPTY_PKSCRIPT: Uint8Array<ArrayBuffer>;
@@ -68,6 +81,6 @@ export declare const TAG_INTENT_PROOF = "ark-intent-proof-message";
68
81
  *
69
82
  * @param message - The message to embed
70
83
  * @param pkScript - The scriptPubKey of the signer's address
71
- * @param tag - Tagged-hash tag (defaults to the Ark intent proof tag)
84
+ * @param tag - Tagged-hash tag (defaults to the Arkade intent proof tag)
72
85
  */
73
86
  export declare function craftToSpendTx(message: string, pkScript: Uint8Array, tag?: string): Transaction;