@dignetwork/chip35-dl-coin-wasm 0.7.0 → 0.9.0

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.
@@ -1,20 +1,365 @@
1
1
  /* tslint:disable */
2
2
  /* eslint-disable */
3
3
 
4
+ /** A Chia coin. `amount` is mojos (XCH) or base units (CAT). */
5
+ export interface Coin {
6
+ parentCoinInfo: Uint8Array;
7
+ puzzleHash: Uint8Array;
8
+ amount: bigint;
9
+ }
10
+
11
+ /** A coin spend: the coin plus its CLVM puzzle reveal + solution (raw program bytes). */
12
+ export interface CoinSpend {
13
+ coin: Coin;
14
+ puzzleReveal: Uint8Array;
15
+ solution: Uint8Array;
16
+ }
17
+
18
+ /** A singleton lineage proof (the coin descends from a prior singleton coin). */
19
+ export interface LineageProof {
20
+ parentParentCoinInfo: Uint8Array;
21
+ parentInnerPuzzleHash: Uint8Array;
22
+ parentAmount: bigint;
23
+ }
24
+
25
+ /** An eve proof (the coin descends directly from its launcher). */
26
+ export interface EveProof {
27
+ parentParentCoinInfo: Uint8Array;
28
+ parentAmount: bigint;
29
+ }
30
+
31
+ /**
32
+ * A singleton proof. Exactly one of `lineageProof` / `eveProof` is set
33
+ * (a discriminated "exactly one of" pair).
34
+ */
35
+ export type Proof =
36
+ | { lineageProof: LineageProof; eveProof?: undefined }
37
+ | { lineageProof?: undefined; eveProof: EveProof };
38
+
39
+ /** A DataStore's metadata (root hash + optional human label/description + size). */
40
+ export interface DataStoreMetadata {
41
+ rootHash: Uint8Array;
42
+ label?: string | null;
43
+ description?: string | null;
44
+ bytes?: bigint | null;
45
+ /** 32-byte CLVM program (size-proof) hash, if any. */
46
+ programHash?: Uint8Array | null;
47
+ }
48
+
49
+ /**
50
+ * A delegated puzzle entry on a store's delegated-puzzle set. Exactly one role is populated:
51
+ * `adminInnerPuzzleHash` (admin), `writerInnerPuzzleHash` (writer / deploy token), or the
52
+ * `oraclePaymentPuzzleHash` + `oracleFee` pair (oracle).
53
+ */
54
+ export type DelegatedPuzzle =
55
+ | { adminInnerPuzzleHash: Uint8Array }
56
+ | { writerInnerPuzzleHash: Uint8Array }
57
+ | { oraclePaymentPuzzleHash: Uint8Array; oracleFee: bigint };
58
+
59
+ /** A CHIP-0035 DataLayer store singleton. */
60
+ export interface DataStore {
61
+ coin: Coin;
62
+ launcherId: Uint8Array;
63
+ proof: Proof;
64
+ metadata: DataStoreMetadata;
65
+ ownerPuzzleHash: Uint8Array;
66
+ delegatedPuzzles: DelegatedPuzzle[];
67
+ }
68
+
69
+ /** The result of a store spend builder: the coin spends to sign + the resulting store state. */
70
+ export interface SuccessResponse {
71
+ coinSpends: CoinSpend[];
72
+ newStore: DataStore;
73
+ }
74
+
75
+ /** A spend bundle: coin spends + the aggregated BLS signature (96 bytes). */
76
+ export interface SpendBundle {
77
+ coinSpends: CoinSpend[];
78
+ aggregatedSignature: Uint8Array;
79
+ }
80
+
81
+ /** A CHIP-0007 attribute (trait). */
82
+ export interface Attribute {
83
+ traitType: string;
84
+ value: string;
85
+ }
86
+
87
+ /** A CHIP-0007 collection reference embedded in item metadata. */
88
+ export interface CollectionRef {
89
+ id: string;
90
+ name: string;
91
+ attributes?: Attribute[];
92
+ }
93
+
94
+ /** A CHIP-0007 metadata document (off-chain JSON). */
95
+ export interface Chip0007Metadata {
96
+ format?: string;
97
+ name: string;
98
+ description?: string | null;
99
+ sensitiveContent?: boolean;
100
+ collection?: CollectionRef | null;
101
+ attributes?: Attribute[];
102
+ seriesNumber?: bigint | null;
103
+ seriesTotal?: bigint | null;
104
+ mintingTool?: string | null;
105
+ }
106
+
107
+ /** Result of `buildChip0007Metadata`. */
108
+ export interface Chip0007MetadataResult {
109
+ json: string;
110
+ metadataHash: Uint8Array;
111
+ }
112
+
113
+ /** The actual bytes (and claimed hashes) `validateChip0007` checks URI↔hash agreement against. */
114
+ export interface Chip0007Assets {
115
+ dataBytes?: Uint8Array;
116
+ dataHash?: Uint8Array;
117
+ metadataBytes?: Uint8Array;
118
+ metadataHash?: Uint8Array;
119
+ licenseBytes?: Uint8Array;
120
+ licenseHash?: Uint8Array;
121
+ }
122
+
123
+ /** Result of `validateChip0007`. */
124
+ export interface ValidationResult {
125
+ ok: boolean;
126
+ errors: string[];
127
+ }
128
+
129
+ /** A DID attribution (the creator identity a mint is attributed to). */
130
+ export interface DidAttribution {
131
+ launcherId: Uint8Array;
132
+ innerPuzzleHash: Uint8Array;
133
+ }
134
+
135
+ /** On-chain NFT media metadata (dig:// + https fallback URIs + computed hashes). */
136
+ export interface NftMediaMetadata {
137
+ dataUris?: string[];
138
+ dataHash?: Uint8Array;
139
+ metadataUris?: string[];
140
+ metadataHash?: Uint8Array;
141
+ licenseUris?: string[];
142
+ licenseHash?: Uint8Array;
143
+ editionNumber?: bigint;
144
+ editionTotal?: bigint;
145
+ }
146
+
147
+ /** Parameters to mint a single NFT. */
148
+ export interface NftMintParams {
149
+ metadata: NftMediaMetadata;
150
+ p2PuzzleHash: Uint8Array;
151
+ royaltyPuzzleHash: Uint8Array;
152
+ royaltyBasisPoints: number;
153
+ did?: DidAttribution | null;
154
+ }
155
+
156
+ /** Result of `mintNft`. */
157
+ export interface NftMintResult {
158
+ coinSpends: CoinSpend[];
159
+ launcherId: Uint8Array;
160
+ nftCoin: Coin;
161
+ }
162
+
163
+ /** Result of `createDid`. */
164
+ export interface CreateDidResult {
165
+ coinSpends: CoinSpend[];
166
+ launcherId: Uint8Array;
167
+ innerPuzzleHash: Uint8Array;
168
+ didCoin: Coin;
169
+ }
170
+
171
+ /** Result of `issueCat`. */
172
+ export interface IssueCatResult {
173
+ coinSpends: CoinSpend[];
174
+ assetId: Uint8Array;
175
+ catCoins: Coin[];
176
+ }
177
+
178
+ /** A collection definition (for `generateItemMetadata` / `bulkMint`). */
179
+ export interface Collection {
180
+ id: string;
181
+ name: string;
182
+ attributes?: Attribute[];
183
+ royaltyPuzzleHash: Uint8Array;
184
+ royaltyBasisPoints: number;
185
+ }
186
+
187
+ /** One item's on-chain media in a parsed traits manifest. */
188
+ export interface ManifestMedia {
189
+ dataUris?: string[];
190
+ dataHash?: Uint8Array;
191
+ metadataUris?: string[];
192
+ metadataHash?: Uint8Array;
193
+ licenseUris?: string[];
194
+ licenseHash?: Uint8Array;
195
+ }
196
+
197
+ /** One item in a parsed traits manifest. */
198
+ export interface ManifestItem {
199
+ name: string;
200
+ description?: string | null;
201
+ attributes?: Attribute[];
202
+ media: ManifestMedia;
203
+ }
204
+
205
+ /** A DID coin + identifiers (for `bulkMint`). Simple DIDs use `numVerificationsRequired: 1`. */
206
+ export interface Did {
207
+ didCoin: Coin;
208
+ proof: Proof;
209
+ launcherId: Uint8Array;
210
+ innerPuzzleHash: Uint8Array;
211
+ recoveryListHash?: Uint8Array | null;
212
+ numVerificationsRequired?: bigint;
213
+ }
214
+
215
+ /** Result of `bulkMint`. */
216
+ export interface BulkMintResult {
217
+ coinSpends: CoinSpend[];
218
+ launcherIds: Uint8Array[];
219
+ }
220
+
221
+ /**
222
+ * Which asset a payment settles in. Exactly one of `xch` / `assetId` is set
223
+ * (a discriminated "exactly one of" pair).
224
+ */
225
+ export type PaymentAsset =
226
+ | { xch: true; assetId?: undefined }
227
+ | { xch?: false; assetId: Uint8Array };
228
+
229
+ /** A CAT's on-chain info. */
230
+ export interface CatInfo {
231
+ assetId: Uint8Array;
232
+ hiddenPuzzleHash?: Uint8Array | null;
233
+ p2PuzzleHash: Uint8Array;
234
+ }
235
+
236
+ /** A buyer's CAT coin (as `chip0002_getAssetCoins` returns it) for `buildCatPayment` / `buildDigStorePayment`. */
237
+ export interface Cat {
238
+ coin: Coin;
239
+ lineageProof?: LineageProof | null;
240
+ info: CatInfo;
241
+ }
242
+
243
+ /**
244
+ * The cross-system $DIG-payment constants (mainnet), returned by `digConstants()`. Minting a store is
245
+ * FREE of $DIG; a CAPSULE (commit / root-advance) pays the per-capsule price in $DIG to
246
+ * `treasuryInnerPuzzleHash`. Byte-identical across the ecosystem (digstore-chain / hub).
247
+ */
248
+ export interface DigConstants {
249
+ /** The DIG CAT asset id (TAIL hash), 32 bytes. */
250
+ assetId: Uint8Array;
251
+ /** The DIG treasury's inner (standard) puzzle hash every per-capsule payment settles to, 32 bytes. */
252
+ treasuryInnerPuzzleHash: Uint8Array;
253
+ }
254
+
255
+ /** The verifiable description of a payment's on-chain commitment. */
256
+ export interface PaymentReceipt {
257
+ ownerPuzzleHash: Uint8Array;
258
+ amount: bigint;
259
+ asset: PaymentAsset;
260
+ nonce: Uint8Array;
261
+ paymentCoin: Coin;
262
+ }
263
+
264
+ /** Result of `buildPayment` / `buildCatPayment`. */
265
+ export interface PaymentResponse {
266
+ coinSpends: CoinSpend[];
267
+ receipt: PaymentReceipt;
268
+ }
269
+
270
+ /** What an observed payment looks like to the paywall after reading the chain (for `verifyPaymentReceipt`). */
271
+ export interface ObservedPayment {
272
+ paidToPuzzleHash: Uint8Array;
273
+ amount: bigint;
274
+ asset: PaymentAsset;
275
+ nonce?: Uint8Array | null;
276
+ }
277
+
278
+ /**
279
+ * Result of `verifyPaymentReceipt`. On denial, `code` is a stable `PaywallError`
280
+ * code (`WRONG_RECIPIENT` | `INSUFFICIENT_AMOUNT` | `WRONG_ASSET` | `NONCE_MISMATCH`).
281
+ */
282
+ export interface PaywallResult {
283
+ ok: boolean;
284
+ code?: ChipErrorCode;
285
+ error?: string;
286
+ }
287
+
288
+ /** The on-chain ownership facts a gating proof establishes about an NFT. */
289
+ export interface NftOwnershipProof {
290
+ launcherId: Uint8Array;
291
+ ownerPuzzleHash: Uint8Array;
292
+ attributedDid?: Uint8Array | null;
293
+ nftCoinId: Uint8Array;
294
+ }
295
+
296
+ /**
297
+ * Result of the NFT-gating helpers (`proveNftOwnership` / `proveCollectionMembership` /
298
+ * `readNftOwnership`). On failure, `code` is a stable `GatingError` code
299
+ * (`NOT_AN_NFT` | `WRONG_OWNER` | `WRONG_COLLECTION` | `WRONG_NFT`).
300
+ */
301
+ export interface GatingResult {
302
+ ok: boolean;
303
+ proof?: NftOwnershipProof;
304
+ code?: ChipErrorCode;
305
+ error?: string;
306
+ }
307
+
308
+ /**
309
+ * Every stable machine error code this module can surface — thrown as `{ code, message }` from a
310
+ * failing export, or carried as the `code` field of a `{ ok:false, code, error }` result. Branch on
311
+ * the code, never the human `message`/`error` string.
312
+ */
313
+ export type ChipErrorCode =
314
+ | "INVALID_ARGUMENT"
315
+ | "SERDE_ERROR"
316
+ | "DRIVER_ERROR"
317
+ | "PARSE_ERROR"
318
+ | "PERMISSION_DENIED"
319
+ | "METADATA_ERROR"
320
+ | "NOT_AN_NFT"
321
+ | "WRONG_OWNER"
322
+ | "WRONG_COLLECTION"
323
+ | "WRONG_NFT"
324
+ | "WRONG_RECIPIENT"
325
+ | "INSUFFICIENT_AMOUNT"
326
+ | "WRONG_ASSET"
327
+ | "NONCE_MISMATCH";
328
+
329
+ /** The structured error a failing export throws: a stable machine `code` beside the human `message`. */
330
+ export interface ChipError {
331
+ code: ChipErrorCode;
332
+ message: string;
333
+ }
334
+
335
+ /** Runtime self-description returned by `capabilities()`. */
336
+ export interface Capabilities {
337
+ /** The published npm package name. */
338
+ name: string;
339
+ /** The package version (= `version()`). */
340
+ version: string;
341
+ /** Every exported builder/helper (camelCase JS names). */
342
+ builders: string[];
343
+ /** The catalogue of stable machine error codes (see `ChipErrorCode`). */
344
+ errorCodes: ChipErrorCode[];
345
+ }
346
+
347
+
348
+
4
349
  /**
5
350
  * Build coin spends that reserve `fee` mojos from the spender's own coins while asserting
6
351
  * concurrent spend of `assert_coin_ids` (see [`chip35_dl_coin::add_fee`]). Lets a fee-less
7
352
  * singleton op (update/melt) carry a network fee. `selected_coins` is `Coin[]`,
8
353
  * `assert_coin_ids` is `Uint8Array[]` of 32-byte coin ids. Returns `CoinSpend[]`.
9
354
  */
10
- export function addFee(spender_synthetic_key: Uint8Array, selected_coins: any, assert_coin_ids: any, fee: bigint): any;
355
+ export function addFee(spender_synthetic_key: Uint8Array, selected_coins: Coin[], assert_coin_ids: Uint8Array[], fee: bigint): CoinSpend[];
11
356
 
12
357
  /**
13
358
  * Build the **Admin** delegated puzzle for a 48-byte synthetic public key (a hub Teams admin).
14
359
  * An admin may update the store AND change delegation (add/remove writers — i.e. revoke a deploy
15
360
  * token), but cannot transfer ownership. Returns a `DelegatedPuzzle` (`{ adminInnerPuzzleHash }`).
16
361
  */
17
- export function adminDelegatedPuzzleFromKey(synthetic_key: Uint8Array): any;
362
+ export function adminDelegatedPuzzleFromKey(synthetic_key: Uint8Array): DelegatedPuzzle;
18
363
 
19
364
  /**
20
365
  * Build the coin spends for a buyer to pay the dapp owner `amount` base units of a **CAT** (incl.
@@ -23,34 +368,55 @@ export function adminDelegatedPuzzleFromKey(synthetic_key: Uint8Array): any;
23
368
  * zero, so carry any XCH network fee with a separate XCH coin via `addFee` asserting the lead CAT
24
369
  * coin id. Returns `{ coinSpends, receipt }`.
25
370
  */
26
- export function buildCatPayment(buyer_synthetic_key: Uint8Array, selected_cats: any, owner_puzzle_hash: Uint8Array, amount: bigint, nonce: Uint8Array): any;
371
+ export function buildCatPayment(buyer_synthetic_key: Uint8Array, selected_cats: Cat[], owner_puzzle_hash: Uint8Array, amount: bigint, nonce: Uint8Array): PaymentResponse;
27
372
 
28
373
  /**
29
374
  * Build a CHIP-0007 metadata document from a JS object and return its canonical JSON + the
30
375
  * `metadata_hash` (sha256 of that JSON). De-dupes the hand-computed badge metadata: callers stop
31
376
  * hand-rolling SHA-256. Returns `{ json: string, metadataHash: Uint8Array }`. Validates schema.
32
377
  */
33
- export function buildChip0007Metadata(metadata: any): any;
378
+ export function buildChip0007Metadata(metadata: Chip0007Metadata): Chip0007MetadataResult;
379
+
380
+ /**
381
+ * Build the (UNSIGNED) DIG-CAT coin spends that pay `amount` base units of $DIG to the DIG treasury
382
+ * for a capsule (commit) — the canonical per-capsule store payment (see
383
+ * [`chip35_dl_coin::build_dig_store_payment`]). `dig_cats` is the buyer's `Cat[]` of the DIG asset
384
+ * (as `chip0002_getAssetCoins` returns them); `store_id` is the capsule's launcher id (= store id);
385
+ * `amount` is the dynamic, USD-pegged per-capsule price in DIG base units (an INPUT — never
386
+ * hardcoded). The caller concatenates the returned `CoinSpend[]` with the commit's
387
+ * `updateStoreMetadata` spends and signs the whole bundle. MINT does NOT call this (mint is free of
388
+ * $DIG). Returns `CoinSpend[]`.
389
+ */
390
+ export function buildDigStorePayment(buyer_synthetic_key: Uint8Array, dig_cats: Cat[], store_id: Uint8Array, amount: bigint): CoinSpend[];
34
391
 
35
392
  /**
36
393
  * Build the coin spends for a buyer to pay the dapp owner `amount` mojos of **XCH** (#46 payment).
37
394
  * `selected_coins` is the buyer's XCH `Coin[]`; `nonce` is the 32-byte unlock nonce. Returns
38
395
  * `{ coinSpends, receipt }` where `receipt` is the `PaymentReceipt` the paywall later verifies.
39
396
  */
40
- export function buildPayment(buyer_synthetic_key: Uint8Array, selected_coins: any, owner_puzzle_hash: Uint8Array, amount: bigint, nonce: Uint8Array, fee: bigint): any;
397
+ export function buildPayment(buyer_synthetic_key: Uint8Array, selected_coins: Coin[], owner_puzzle_hash: Uint8Array, amount: bigint, nonce: Uint8Array, fee: bigint): PaymentResponse;
41
398
 
42
399
  /**
43
400
  * Bulk-mint every item in a parsed traits manifest into a collection, attributed to a DID (#34).
44
401
  * `did` is the DID coin + identifiers `{ launcherId, innerPuzzleHash, didCoin }` (e.g. from a prior
45
402
  * `createDid`, fetched on-chain). Returns `{ coinSpends, launcherIds }`.
46
403
  */
47
- export function bulkMint(minter_synthetic_key: Uint8Array, did: any, collection: any, items: any, recipient_puzzle_hash: Uint8Array): any;
404
+ export function bulkMint(minter_synthetic_key: Uint8Array, did: Did, collection: Collection, items: ManifestItem[], recipient_puzzle_hash: Uint8Array): BulkMintResult;
405
+
406
+ /**
407
+ * A machine-readable descriptor of this module's surface, for runtime introspection by an agent or
408
+ * consumer: `{ name, version, builders, errorCodes }`. `builders` is every exported builder/helper
409
+ * (camelCase JS names); `errorCodes` is the catalogue of stable `UPPER_SNAKE` codes a caller may
410
+ * branch on (thrown as `{ code, message }`, or carried as the `code` field of a `{ ok, code?, error? }`
411
+ * result). One call yields the version + the full surface with zero out-of-band knowledge.
412
+ */
413
+ export function capabilities(): Capabilities;
48
414
 
49
415
  /**
50
416
  * Create a DID (creator identity) singleton. Returns
51
417
  * `{ coinSpends, launcherId, innerPuzzleHash, didCoin }`.
52
418
  */
53
- export function createDid(minter_synthetic_key: Uint8Array, selected_coins: any, fee: bigint): any;
419
+ export function createDid(minter_synthetic_key: Uint8Array, selected_coins: Coin[], fee: bigint): CreateDidResult;
54
420
 
55
421
  /**
56
422
  * Reconstruct a DataStore from the coin spend that created its current coin (the launcher
@@ -59,12 +425,28 @@ export function createDid(minter_synthetic_key: Uint8Array, selected_coins: any,
59
425
  * `coin_spend` is the wasm CoinSpend shape (Uint8Array fields); `prev_delegated_puzzles` is
60
426
  * the parent's delegated-puzzle list ([] for an owner-only store).
61
427
  */
62
- export function dataStoreFromSpend(coin_spend: any, prev_delegated_puzzles: any): any;
428
+ export function dataStoreFromSpend(coin_spend: CoinSpend, prev_delegated_puzzles: DelegatedPuzzle[]): DataStore;
63
429
 
64
430
  /**
65
431
  * Decode canonical offer text into its spend bundle `{ coinSpends, aggregatedSignature }`.
66
432
  */
67
- export function decodeOffer(text: string): any;
433
+ export function decodeOffer(text: string): SpendBundle;
434
+
435
+ /**
436
+ * The cross-system $DIG-payment constants (mainnet): the DIG CAT `assetId` and the treasury INNER
437
+ * `puzzleHash` every per-capsule payment settles to. Byte-identical across the ecosystem
438
+ * (digstore-chain / hub). Lets an agent/consumer read them at runtime instead of hardcoding. Returns
439
+ * `{ assetId: Uint8Array, treasuryInnerPuzzleHash: Uint8Array }`.
440
+ */
441
+ export function digConstants(): DigConstants;
442
+
443
+ /**
444
+ * The DIG-CAT payment coin a capsule (commit) pays to the treasury — what `buildDigStorePayment`
445
+ * emits (see [`chip35_dl_coin::dig_treasury_payment_coin`]). `lead_dig_cat` is the lead DIG `Cat`
446
+ * (its id is the new coin's parent); `amount` is the payment in DIG base units. Lets a caller pin /
447
+ * verify the exact expected treasury coin without re-deriving the CAT wrap. Returns a `Coin`.
448
+ */
449
+ export function digTreasuryPaymentCoin(lead_dig_cat: Cat, amount: bigint): Coin;
68
450
 
69
451
  /**
70
452
  * Derive the digstore-scoped owner discovery hint for a 32-byte owner puzzle hash. The app
@@ -76,20 +458,20 @@ export function digstoreOwnerHint(owner_puzzle_hash: Uint8Array): Uint8Array;
76
458
  /**
77
459
  * Encode a spend bundle (`{coinSpends, aggregatedSignature}`) into canonical offer text.
78
460
  */
79
- export function encodeOffer(spend_bundle: any): string;
461
+ export function encodeOffer(spend_bundle: SpendBundle): string;
80
462
 
81
463
  /**
82
464
  * Generate per-item CHIP-0007 metadata documents for a collection from a parsed traits manifest
83
465
  * (#34). `collection` is `Collection`; `items` is `ManifestItem[]`. Returns
84
466
  * `Chip0007Metadata[]` (the off-chain JSON docs; the caller hashes + writes them into each capsule).
85
467
  */
86
- export function generateItemMetadata(collection: any, items: any): any;
468
+ export function generateItemMetadata(collection: Collection, items: ManifestItem[]): Chip0007Metadata[];
87
469
 
88
470
  /**
89
471
  * Decode a hex-encoded spend bundle into its `CoinSpend[]` (see
90
472
  * [`chip35_dl_coin::hex_spend_bundle_to_coin_spends`]).
91
473
  */
92
- export function hexSpendBundleToCoinSpends(hex: string): any;
474
+ export function hexSpendBundleToCoinSpends(hex: string): CoinSpend[];
93
475
 
94
476
  /**
95
477
  * Initialise the module. Call once at startup. Installs a panic hook (when the
@@ -100,40 +482,40 @@ export function init(): void;
100
482
  /**
101
483
  * Issue a single-issuance (fixed-supply) CAT. Returns `{ coinSpends, assetId, catCoins }`.
102
484
  */
103
- export function issueCat(issuer_synthetic_key: Uint8Array, selected_coins: any, amount: bigint, fee: bigint): any;
485
+ export function issueCat(issuer_synthetic_key: Uint8Array, selected_coins: Coin[], amount: bigint, fee: bigint): IssueCatResult;
104
486
 
105
487
  /**
106
488
  * Burn (melt) a store singleton (see [`chip35_dl_coin::melt_store`]). Owner-authorized only.
107
489
  * Returns the melt `CoinSpend[]`.
108
490
  */
109
- export function meltStore(store: any, owner_public_key: Uint8Array): any;
491
+ export function meltStore(store: DataStore, owner_public_key: Uint8Array): CoinSpend[];
110
492
 
111
493
  /**
112
494
  * Mint a single NFT whose media lives in a DIG capsule (`dig://` URN + https gateway fallback URIs,
113
495
  * hashes computed from real bytes). `params` is `NftMintParams`. Returns
114
496
  * `{ coinSpends, launcherId, nftCoin }`.
115
497
  */
116
- export function mintNft(minter_synthetic_key: Uint8Array, selected_coins: any, params: any, fee: bigint): any;
498
+ export function mintNft(minter_synthetic_key: Uint8Array, selected_coins: Coin[], params: NftMintParams, fee: bigint): NftMintResult;
117
499
 
118
500
  /**
119
501
  * Build the spend bundle that launches a new DataLayer store singleton (see
120
502
  * [`chip35_dl_coin::mint_store`]). `program_hash` is an optional 32-byte size-proof; the rest of
121
503
  * the JS values mirror the core builder. Returns a `SuccessResponse` (`coinSpends` + `newStore`).
122
504
  */
123
- export function mintStore(minter_synthetic_key: Uint8Array, selected_coins: any, root_hash: Uint8Array, label: string | null | undefined, description: string | null | undefined, bytes: bigint | null | undefined, program_hash: Uint8Array | null | undefined, owner_puzzle_hash: Uint8Array, delegated_puzzles: any, fee: bigint): any;
505
+ export function mintStore(minter_synthetic_key: Uint8Array, selected_coins: Coin[], root_hash: Uint8Array, label: string | null | undefined, description: string | null | undefined, bytes: bigint | null | undefined, program_hash: Uint8Array | null | undefined, owner_puzzle_hash: Uint8Array, delegated_puzzles: DelegatedPuzzle[], fee: bigint): SuccessResponse;
124
506
 
125
507
  /**
126
508
  * Build the **Oracle** delegated puzzle: anyone may spend the store for the fixed `oracle_fee`
127
509
  * (mojos) paid to the 32-byte `oracle_puzzle_hash`. Returns a `DelegatedPuzzle`
128
510
  * (`{ oraclePaymentPuzzleHash, oracleFee }`).
129
511
  */
130
- export function oracleDelegatedPuzzle(oracle_puzzle_hash: Uint8Array, oracle_fee: bigint): any;
512
+ export function oracleDelegatedPuzzle(oracle_puzzle_hash: Uint8Array, oracle_fee: bigint): DelegatedPuzzle;
131
513
 
132
514
  /**
133
515
  * Exercise a store's oracle delegated puzzle (see [`chip35_dl_coin::oracle_spend`]). The spender
134
516
  * pays the oracle fee plus `fee` from `selected_coins`. Returns a `SuccessResponse`.
135
517
  */
136
- export function oracleSpend(spender_synthetic_key: Uint8Array, selected_coins: any, store: any, fee: bigint): any;
518
+ export function oracleSpend(spender_synthetic_key: Uint8Array, selected_coins: Coin[], store: DataStore, fee: bigint): SuccessResponse;
137
519
 
138
520
  /**
139
521
  * SHA-256-derive a 32-byte unlock nonce from arbitrary request bytes (`dappId||resource||user`).
@@ -146,7 +528,7 @@ export function paymentNonce(request_bytes: Uint8Array): Uint8Array;
146
528
  * Prove an NFT held by `claimed_owner_puzzle_hash` is a member of the collection/creator identified
147
529
  * by `required_did` (#46 collection-gating). Returns `{ ok, proof?, error? }`.
148
530
  */
149
- export function proveCollectionMembership(parent_spend: any, claimed_owner_puzzle_hash: Uint8Array, required_did: Uint8Array): any;
531
+ export function proveCollectionMembership(parent_spend: CoinSpend, claimed_owner_puzzle_hash: Uint8Array, required_did: Uint8Array): GatingResult;
150
532
 
151
533
  /**
152
534
  * Prove an NFT (reconstructed from `parent_spend`, the coin spend that created its current coin) is
@@ -155,14 +537,14 @@ export function proveCollectionMembership(parent_spend: any, claimed_owner_puzzl
155
537
  * success `proof` is the `NftOwnershipProof` (launcher id, owner, attributed DID, current coin id);
156
538
  * the caller still confirms `proof.nftCoinId` is unspent on-chain for liveness.
157
539
  */
158
- export function proveNftOwnership(parent_spend: any, claimed_owner_puzzle_hash: Uint8Array, required_nft?: Uint8Array | null): any;
540
+ export function proveNftOwnership(parent_spend: CoinSpend, claimed_owner_puzzle_hash: Uint8Array, required_nft?: Uint8Array | null): GatingResult;
159
541
 
160
542
  /**
161
543
  * Read an NFT's ownership facts (owner, attributed DID, launcher id, current coin id) from
162
544
  * `parent_spend` WITHOUT applying a gate — for dapps that want to decide in their own code.
163
545
  * Returns `{ ok, proof?, error? }`.
164
546
  */
165
- export function readNftOwnership(parent_spend: any): any;
547
+ export function readNftOwnership(parent_spend: CoinSpend): GatingResult;
166
548
 
167
549
  /**
168
550
  * SHA-256 of arbitrary bytes → 32-byte hash (the one true primitive for `data_hash`/
@@ -174,14 +556,14 @@ export function sha256(bytes: Uint8Array): Uint8Array;
174
556
  * Serialize a spend bundle (`{coinSpends, aggregatedSignature}`) to its hex wire encoding
175
557
  * (see [`chip35_dl_coin::spend_bundle_to_hex`]).
176
558
  */
177
- export function spendBundleToHex(spend_bundle: any): string;
559
+ export function spendBundleToHex(spend_bundle: SpendBundle): string;
178
560
 
179
561
  /**
180
562
  * Update a store's metadata (see [`chip35_dl_coin::update_store_metadata`]). Exactly one of
181
563
  * `owner_public_key`, `admin_public_key`, `writer_public_key` must be provided — it selects the
182
564
  * authorizing role. Returns a `SuccessResponse`.
183
565
  */
184
- export function updateStoreMetadata(store: any, new_root_hash: Uint8Array, new_label?: string | null, new_description?: string | null, new_bytes?: bigint | null, new_program_hash?: Uint8Array | null, owner_public_key?: Uint8Array | null, admin_public_key?: Uint8Array | null, writer_public_key?: Uint8Array | null): any;
566
+ export function updateStoreMetadata(store: DataStore, new_root_hash: Uint8Array, new_label?: string | null, new_description?: string | null, new_bytes?: bigint | null, new_program_hash?: Uint8Array | null, owner_public_key?: Uint8Array | null, admin_public_key?: Uint8Array | null, writer_public_key?: Uint8Array | null): SuccessResponse;
185
567
 
186
568
  /**
187
569
  * Transfer ownership and/or replace the delegated-puzzle set (see
@@ -189,7 +571,7 @@ export function updateStoreMetadata(store: any, new_root_hash: Uint8Array, new_l
189
571
  * current owner. Exactly one of `owner_public_key`/`admin_public_key` must be provided. Returns
190
572
  * a `SuccessResponse`.
191
573
  */
192
- export function updateStoreOwnership(store: any, new_owner_puzzle_hash: Uint8Array | null | undefined, new_delegated_puzzles: any, owner_public_key?: Uint8Array | null, admin_public_key?: Uint8Array | null): any;
574
+ export function updateStoreOwnership(store: DataStore, new_owner_puzzle_hash: Uint8Array | null | undefined, new_delegated_puzzles: DelegatedPuzzle[], owner_public_key?: Uint8Array | null, admin_public_key?: Uint8Array | null): SuccessResponse;
193
575
 
194
576
  /**
195
577
  * Validate a CHIP-0007 document's schema, and (when the actual bytes are provided) that each
@@ -197,7 +579,7 @@ export function updateStoreOwnership(store: any, new_owner_puzzle_hash: Uint8Arr
197
579
  * `{ dataBytes?, dataHash?, metadataBytes?, metadataHash?, licenseBytes?, licenseHash? }` (all
198
580
  * `Uint8Array`). Returns `{ ok: bool, errors: string[] }`.
199
581
  */
200
- export function validateChip0007(metadata: any, assets: any): any;
582
+ export function validateChip0007(metadata: Chip0007Metadata, assets: Chip0007Assets): ValidationResult;
201
583
 
202
584
  /**
203
585
  * Verify an observed payment unlocks a paywall (#46 pay-to-unlock): it must pay `owner_puzzle_hash`,
@@ -206,7 +588,13 @@ export function validateChip0007(metadata: any, assets: any): any;
206
588
  * `required_asset` is a `PaymentAsset` (`{xch:true}` or `{assetId}`). Returns `{ ok, error? }` —
207
589
  * `ok:true` grants access, otherwise `error` is the human-readable denial reason.
208
590
  */
209
- export function verifyPaymentReceipt(observed: any, owner_puzzle_hash: Uint8Array, min_amount: bigint, required_asset: any, require_nonce?: Uint8Array | null): any;
591
+ export function verifyPaymentReceipt(observed: ObservedPayment, owner_puzzle_hash: Uint8Array, min_amount: bigint, required_asset: PaymentAsset, require_nonce?: Uint8Array | null): PaywallResult;
592
+
593
+ /**
594
+ * The published package version (= the Cargo crate version = the npm package version). Lets a
595
+ * consumer/agent feature-gate on exactly which build is loaded at runtime.
596
+ */
597
+ export function version(): string;
210
598
 
211
599
  /**
212
600
  * Build the **Writer** delegated puzzle for a 48-byte synthetic public key — a revocable deploy
@@ -215,4 +603,4 @@ export function verifyPaymentReceipt(observed: any, owner_puzzle_hash: Uint8Arra
215
603
  * to issue the token; replace the store's delegated set to revoke it. Returns a `DelegatedPuzzle`
216
604
  * (`{ writerInnerPuzzleHash }`).
217
605
  */
218
- export function writerDelegatedPuzzleFromKey(synthetic_key: Uint8Array): any;
606
+ export function writerDelegatedPuzzleFromKey(synthetic_key: Uint8Array): DelegatedPuzzle;
@@ -5,5 +5,5 @@ import { __wbg_set_wasm } from "./chip35_dl_coin_wasm_bg.js";
5
5
  __wbg_set_wasm(wasm);
6
6
 
7
7
  export {
8
- addFee, adminDelegatedPuzzleFromKey, buildCatPayment, buildChip0007Metadata, buildPayment, bulkMint, createDid, dataStoreFromSpend, decodeOffer, digstoreOwnerHint, encodeOffer, generateItemMetadata, hexSpendBundleToCoinSpends, init, issueCat, meltStore, mintNft, mintStore, oracleDelegatedPuzzle, oracleSpend, paymentNonce, proveCollectionMembership, proveNftOwnership, readNftOwnership, sha256, spendBundleToHex, updateStoreMetadata, updateStoreOwnership, validateChip0007, verifyPaymentReceipt, writerDelegatedPuzzleFromKey
8
+ addFee, adminDelegatedPuzzleFromKey, buildCatPayment, buildChip0007Metadata, buildDigStorePayment, buildPayment, bulkMint, capabilities, createDid, dataStoreFromSpend, decodeOffer, digConstants, digTreasuryPaymentCoin, digstoreOwnerHint, encodeOffer, generateItemMetadata, hexSpendBundleToCoinSpends, init, issueCat, meltStore, mintNft, mintStore, oracleDelegatedPuzzle, oracleSpend, paymentNonce, proveCollectionMembership, proveNftOwnership, readNftOwnership, sha256, spendBundleToHex, updateStoreMetadata, updateStoreOwnership, validateChip0007, verifyPaymentReceipt, version, writerDelegatedPuzzleFromKey
9
9
  } from "./chip35_dl_coin_wasm_bg.js";
@@ -4,10 +4,10 @@
4
4
  * singleton op (update/melt) carry a network fee. `selected_coins` is `Coin[]`,
5
5
  * `assert_coin_ids` is `Uint8Array[]` of 32-byte coin ids. Returns `CoinSpend[]`.
6
6
  * @param {Uint8Array} spender_synthetic_key
7
- * @param {any} selected_coins
8
- * @param {any} assert_coin_ids
7
+ * @param {Coin[]} selected_coins
8
+ * @param {Uint8Array[]} assert_coin_ids
9
9
  * @param {bigint} fee
10
- * @returns {any}
10
+ * @returns {CoinSpend[]}
11
11
  */
12
12
  export function addFee(spender_synthetic_key, selected_coins, assert_coin_ids, fee) {
13
13
  try {
@@ -32,7 +32,7 @@ export function addFee(spender_synthetic_key, selected_coins, assert_coin_ids, f
32
32
  * An admin may update the store AND change delegation (add/remove writers — i.e. revoke a deploy
33
33
  * token), but cannot transfer ownership. Returns a `DelegatedPuzzle` (`{ adminInnerPuzzleHash }`).
34
34
  * @param {Uint8Array} synthetic_key
35
- * @returns {any}
35
+ * @returns {DelegatedPuzzle}
36
36
  */
37
37
  export function adminDelegatedPuzzleFromKey(synthetic_key) {
38
38
  try {
@@ -59,11 +59,11 @@ export function adminDelegatedPuzzleFromKey(synthetic_key) {
59
59
  * zero, so carry any XCH network fee with a separate XCH coin via `addFee` asserting the lead CAT
60
60
  * coin id. Returns `{ coinSpends, receipt }`.
61
61
  * @param {Uint8Array} buyer_synthetic_key
62
- * @param {any} selected_cats
62
+ * @param {Cat[]} selected_cats
63
63
  * @param {Uint8Array} owner_puzzle_hash
64
64
  * @param {bigint} amount
65
65
  * @param {Uint8Array} nonce
66
- * @returns {any}
66
+ * @returns {PaymentResponse}
67
67
  */
68
68
  export function buildCatPayment(buyer_synthetic_key, selected_cats, owner_puzzle_hash, amount, nonce) {
69
69
  try {
@@ -91,8 +91,8 @@ export function buildCatPayment(buyer_synthetic_key, selected_cats, owner_puzzle
91
91
  * Build a CHIP-0007 metadata document from a JS object and return its canonical JSON + the
92
92
  * `metadata_hash` (sha256 of that JSON). De-dupes the hand-computed badge metadata: callers stop
93
93
  * hand-rolling SHA-256. Returns `{ json: string, metadataHash: Uint8Array }`. Validates schema.
94
- * @param {any} metadata
95
- * @returns {any}
94
+ * @param {Chip0007Metadata} metadata
95
+ * @returns {Chip0007MetadataResult}
96
96
  */
97
97
  export function buildChip0007Metadata(metadata) {
98
98
  try {
@@ -110,17 +110,52 @@ export function buildChip0007Metadata(metadata) {
110
110
  }
111
111
  }
112
112
 
113
+ /**
114
+ * Build the (UNSIGNED) DIG-CAT coin spends that pay `amount` base units of $DIG to the DIG treasury
115
+ * for a capsule (commit) — the canonical per-capsule store payment (see
116
+ * [`chip35_dl_coin::build_dig_store_payment`]). `dig_cats` is the buyer's `Cat[]` of the DIG asset
117
+ * (as `chip0002_getAssetCoins` returns them); `store_id` is the capsule's launcher id (= store id);
118
+ * `amount` is the dynamic, USD-pegged per-capsule price in DIG base units (an INPUT — never
119
+ * hardcoded). The caller concatenates the returned `CoinSpend[]` with the commit's
120
+ * `updateStoreMetadata` spends and signs the whole bundle. MINT does NOT call this (mint is free of
121
+ * $DIG). Returns `CoinSpend[]`.
122
+ * @param {Uint8Array} buyer_synthetic_key
123
+ * @param {Cat[]} dig_cats
124
+ * @param {Uint8Array} store_id
125
+ * @param {bigint} amount
126
+ * @returns {CoinSpend[]}
127
+ */
128
+ export function buildDigStorePayment(buyer_synthetic_key, dig_cats, store_id, amount) {
129
+ try {
130
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
131
+ const ptr0 = passArray8ToWasm0(buyer_synthetic_key, wasm.__wbindgen_export);
132
+ const len0 = WASM_VECTOR_LEN;
133
+ const ptr1 = passArray8ToWasm0(store_id, wasm.__wbindgen_export);
134
+ const len1 = WASM_VECTOR_LEN;
135
+ wasm.buildDigStorePayment(retptr, ptr0, len0, addHeapObject(dig_cats), ptr1, len1, amount);
136
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
137
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
138
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
139
+ if (r2) {
140
+ throw takeObject(r1);
141
+ }
142
+ return takeObject(r0);
143
+ } finally {
144
+ wasm.__wbindgen_add_to_stack_pointer(16);
145
+ }
146
+ }
147
+
113
148
  /**
114
149
  * Build the coin spends for a buyer to pay the dapp owner `amount` mojos of **XCH** (#46 payment).
115
150
  * `selected_coins` is the buyer's XCH `Coin[]`; `nonce` is the 32-byte unlock nonce. Returns
116
151
  * `{ coinSpends, receipt }` where `receipt` is the `PaymentReceipt` the paywall later verifies.
117
152
  * @param {Uint8Array} buyer_synthetic_key
118
- * @param {any} selected_coins
153
+ * @param {Coin[]} selected_coins
119
154
  * @param {Uint8Array} owner_puzzle_hash
120
155
  * @param {bigint} amount
121
156
  * @param {Uint8Array} nonce
122
157
  * @param {bigint} fee
123
- * @returns {any}
158
+ * @returns {PaymentResponse}
124
159
  */
125
160
  export function buildPayment(buyer_synthetic_key, selected_coins, owner_puzzle_hash, amount, nonce, fee) {
126
161
  try {
@@ -149,11 +184,11 @@ export function buildPayment(buyer_synthetic_key, selected_coins, owner_puzzle_h
149
184
  * `did` is the DID coin + identifiers `{ launcherId, innerPuzzleHash, didCoin }` (e.g. from a prior
150
185
  * `createDid`, fetched on-chain). Returns `{ coinSpends, launcherIds }`.
151
186
  * @param {Uint8Array} minter_synthetic_key
152
- * @param {any} did
153
- * @param {any} collection
154
- * @param {any} items
187
+ * @param {Did} did
188
+ * @param {Collection} collection
189
+ * @param {ManifestItem[]} items
155
190
  * @param {Uint8Array} recipient_puzzle_hash
156
- * @returns {any}
191
+ * @returns {BulkMintResult}
157
192
  */
158
193
  export function bulkMint(minter_synthetic_key, did, collection, items, recipient_puzzle_hash) {
159
194
  try {
@@ -175,13 +210,26 @@ export function bulkMint(minter_synthetic_key, did, collection, items, recipient
175
210
  }
176
211
  }
177
212
 
213
+ /**
214
+ * A machine-readable descriptor of this module's surface, for runtime introspection by an agent or
215
+ * consumer: `{ name, version, builders, errorCodes }`. `builders` is every exported builder/helper
216
+ * (camelCase JS names); `errorCodes` is the catalogue of stable `UPPER_SNAKE` codes a caller may
217
+ * branch on (thrown as `{ code, message }`, or carried as the `code` field of a `{ ok, code?, error? }`
218
+ * result). One call yields the version + the full surface with zero out-of-band knowledge.
219
+ * @returns {Capabilities}
220
+ */
221
+ export function capabilities() {
222
+ const ret = wasm.capabilities();
223
+ return takeObject(ret);
224
+ }
225
+
178
226
  /**
179
227
  * Create a DID (creator identity) singleton. Returns
180
228
  * `{ coinSpends, launcherId, innerPuzzleHash, didCoin }`.
181
229
  * @param {Uint8Array} minter_synthetic_key
182
- * @param {any} selected_coins
230
+ * @param {Coin[]} selected_coins
183
231
  * @param {bigint} fee
184
- * @returns {any}
232
+ * @returns {CreateDidResult}
185
233
  */
186
234
  export function createDid(minter_synthetic_key, selected_coins, fee) {
187
235
  try {
@@ -207,9 +255,9 @@ export function createDid(minter_synthetic_key, selected_coins, fee) {
207
255
  * creating spend from a full node, rebuild the DataStore here, then meltStore() it.
208
256
  * `coin_spend` is the wasm CoinSpend shape (Uint8Array fields); `prev_delegated_puzzles` is
209
257
  * the parent's delegated-puzzle list ([] for an owner-only store).
210
- * @param {any} coin_spend
211
- * @param {any} prev_delegated_puzzles
212
- * @returns {any}
258
+ * @param {CoinSpend} coin_spend
259
+ * @param {DelegatedPuzzle[]} prev_delegated_puzzles
260
+ * @returns {DataStore}
213
261
  */
214
262
  export function dataStoreFromSpend(coin_spend, prev_delegated_puzzles) {
215
263
  try {
@@ -230,7 +278,7 @@ export function dataStoreFromSpend(coin_spend, prev_delegated_puzzles) {
230
278
  /**
231
279
  * Decode canonical offer text into its spend bundle `{ coinSpends, aggregatedSignature }`.
232
280
  * @param {string} text
233
- * @returns {any}
281
+ * @returns {SpendBundle}
234
282
  */
235
283
  export function decodeOffer(text) {
236
284
  try {
@@ -250,6 +298,43 @@ export function decodeOffer(text) {
250
298
  }
251
299
  }
252
300
 
301
+ /**
302
+ * The cross-system $DIG-payment constants (mainnet): the DIG CAT `assetId` and the treasury INNER
303
+ * `puzzleHash` every per-capsule payment settles to. Byte-identical across the ecosystem
304
+ * (digstore-chain / hub). Lets an agent/consumer read them at runtime instead of hardcoding. Returns
305
+ * `{ assetId: Uint8Array, treasuryInnerPuzzleHash: Uint8Array }`.
306
+ * @returns {DigConstants}
307
+ */
308
+ export function digConstants() {
309
+ const ret = wasm.digConstants();
310
+ return takeObject(ret);
311
+ }
312
+
313
+ /**
314
+ * The DIG-CAT payment coin a capsule (commit) pays to the treasury — what `buildDigStorePayment`
315
+ * emits (see [`chip35_dl_coin::dig_treasury_payment_coin`]). `lead_dig_cat` is the lead DIG `Cat`
316
+ * (its id is the new coin's parent); `amount` is the payment in DIG base units. Lets a caller pin /
317
+ * verify the exact expected treasury coin without re-deriving the CAT wrap. Returns a `Coin`.
318
+ * @param {Cat} lead_dig_cat
319
+ * @param {bigint} amount
320
+ * @returns {Coin}
321
+ */
322
+ export function digTreasuryPaymentCoin(lead_dig_cat, amount) {
323
+ try {
324
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
325
+ wasm.digTreasuryPaymentCoin(retptr, addHeapObject(lead_dig_cat), amount);
326
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
327
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
328
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
329
+ if (r2) {
330
+ throw takeObject(r1);
331
+ }
332
+ return takeObject(r0);
333
+ } finally {
334
+ wasm.__wbindgen_add_to_stack_pointer(16);
335
+ }
336
+ }
337
+
253
338
  /**
254
339
  * Derive the digstore-scoped owner discovery hint for a 32-byte owner puzzle hash. The app
255
340
  * computes the SAME hint to enumerate the wallet's stores via coinset
@@ -280,7 +365,7 @@ export function digstoreOwnerHint(owner_puzzle_hash) {
280
365
 
281
366
  /**
282
367
  * Encode a spend bundle (`{coinSpends, aggregatedSignature}`) into canonical offer text.
283
- * @param {any} spend_bundle
368
+ * @param {SpendBundle} spend_bundle
284
369
  * @returns {string}
285
370
  */
286
371
  export function encodeOffer(spend_bundle) {
@@ -312,9 +397,9 @@ export function encodeOffer(spend_bundle) {
312
397
  * Generate per-item CHIP-0007 metadata documents for a collection from a parsed traits manifest
313
398
  * (#34). `collection` is `Collection`; `items` is `ManifestItem[]`. Returns
314
399
  * `Chip0007Metadata[]` (the off-chain JSON docs; the caller hashes + writes them into each capsule).
315
- * @param {any} collection
316
- * @param {any} items
317
- * @returns {any}
400
+ * @param {Collection} collection
401
+ * @param {ManifestItem[]} items
402
+ * @returns {Chip0007Metadata[]}
318
403
  */
319
404
  export function generateItemMetadata(collection, items) {
320
405
  try {
@@ -336,7 +421,7 @@ export function generateItemMetadata(collection, items) {
336
421
  * Decode a hex-encoded spend bundle into its `CoinSpend[]` (see
337
422
  * [`chip35_dl_coin::hex_spend_bundle_to_coin_spends`]).
338
423
  * @param {string} hex
339
- * @returns {any}
424
+ * @returns {CoinSpend[]}
340
425
  */
341
426
  export function hexSpendBundleToCoinSpends(hex) {
342
427
  try {
@@ -367,10 +452,10 @@ export function init() {
367
452
  /**
368
453
  * Issue a single-issuance (fixed-supply) CAT. Returns `{ coinSpends, assetId, catCoins }`.
369
454
  * @param {Uint8Array} issuer_synthetic_key
370
- * @param {any} selected_coins
455
+ * @param {Coin[]} selected_coins
371
456
  * @param {bigint} amount
372
457
  * @param {bigint} fee
373
- * @returns {any}
458
+ * @returns {IssueCatResult}
374
459
  */
375
460
  export function issueCat(issuer_synthetic_key, selected_coins, amount, fee) {
376
461
  try {
@@ -393,9 +478,9 @@ export function issueCat(issuer_synthetic_key, selected_coins, amount, fee) {
393
478
  /**
394
479
  * Burn (melt) a store singleton (see [`chip35_dl_coin::melt_store`]). Owner-authorized only.
395
480
  * Returns the melt `CoinSpend[]`.
396
- * @param {any} store
481
+ * @param {DataStore} store
397
482
  * @param {Uint8Array} owner_public_key
398
- * @returns {any}
483
+ * @returns {CoinSpend[]}
399
484
  */
400
485
  export function meltStore(store, owner_public_key) {
401
486
  try {
@@ -420,10 +505,10 @@ export function meltStore(store, owner_public_key) {
420
505
  * hashes computed from real bytes). `params` is `NftMintParams`. Returns
421
506
  * `{ coinSpends, launcherId, nftCoin }`.
422
507
  * @param {Uint8Array} minter_synthetic_key
423
- * @param {any} selected_coins
424
- * @param {any} params
508
+ * @param {Coin[]} selected_coins
509
+ * @param {NftMintParams} params
425
510
  * @param {bigint} fee
426
- * @returns {any}
511
+ * @returns {NftMintResult}
427
512
  */
428
513
  export function mintNft(minter_synthetic_key, selected_coins, params, fee) {
429
514
  try {
@@ -448,16 +533,16 @@ export function mintNft(minter_synthetic_key, selected_coins, params, fee) {
448
533
  * [`chip35_dl_coin::mint_store`]). `program_hash` is an optional 32-byte size-proof; the rest of
449
534
  * the JS values mirror the core builder. Returns a `SuccessResponse` (`coinSpends` + `newStore`).
450
535
  * @param {Uint8Array} minter_synthetic_key
451
- * @param {any} selected_coins
536
+ * @param {Coin[]} selected_coins
452
537
  * @param {Uint8Array} root_hash
453
538
  * @param {string | null | undefined} label
454
539
  * @param {string | null | undefined} description
455
540
  * @param {bigint | null | undefined} bytes
456
541
  * @param {Uint8Array | null | undefined} program_hash
457
542
  * @param {Uint8Array} owner_puzzle_hash
458
- * @param {any} delegated_puzzles
543
+ * @param {DelegatedPuzzle[]} delegated_puzzles
459
544
  * @param {bigint} fee
460
- * @returns {any}
545
+ * @returns {SuccessResponse}
461
546
  */
462
547
  export function mintStore(minter_synthetic_key, selected_coins, root_hash, label, description, bytes, program_hash, owner_puzzle_hash, delegated_puzzles, fee) {
463
548
  try {
@@ -493,7 +578,7 @@ export function mintStore(minter_synthetic_key, selected_coins, root_hash, label
493
578
  * (`{ oraclePaymentPuzzleHash, oracleFee }`).
494
579
  * @param {Uint8Array} oracle_puzzle_hash
495
580
  * @param {bigint} oracle_fee
496
- * @returns {any}
581
+ * @returns {DelegatedPuzzle}
497
582
  */
498
583
  export function oracleDelegatedPuzzle(oracle_puzzle_hash, oracle_fee) {
499
584
  try {
@@ -517,10 +602,10 @@ export function oracleDelegatedPuzzle(oracle_puzzle_hash, oracle_fee) {
517
602
  * Exercise a store's oracle delegated puzzle (see [`chip35_dl_coin::oracle_spend`]). The spender
518
603
  * pays the oracle fee plus `fee` from `selected_coins`. Returns a `SuccessResponse`.
519
604
  * @param {Uint8Array} spender_synthetic_key
520
- * @param {any} selected_coins
521
- * @param {any} store
605
+ * @param {Coin[]} selected_coins
606
+ * @param {DataStore} store
522
607
  * @param {bigint} fee
523
- * @returns {any}
608
+ * @returns {SuccessResponse}
524
609
  */
525
610
  export function oracleSpend(spender_synthetic_key, selected_coins, store, fee) {
526
611
  try {
@@ -566,10 +651,10 @@ export function paymentNonce(request_bytes) {
566
651
  /**
567
652
  * Prove an NFT held by `claimed_owner_puzzle_hash` is a member of the collection/creator identified
568
653
  * by `required_did` (#46 collection-gating). Returns `{ ok, proof?, error? }`.
569
- * @param {any} parent_spend
654
+ * @param {CoinSpend} parent_spend
570
655
  * @param {Uint8Array} claimed_owner_puzzle_hash
571
656
  * @param {Uint8Array} required_did
572
- * @returns {any}
657
+ * @returns {GatingResult}
573
658
  */
574
659
  export function proveCollectionMembership(parent_spend, claimed_owner_puzzle_hash, required_did) {
575
660
  try {
@@ -597,10 +682,10 @@ export function proveCollectionMembership(parent_spend, claimed_owner_puzzle_has
597
682
  * gating). `parent_spend` is the wasm `CoinSpend` shape. Returns `{ ok, proof?, error? }` — on
598
683
  * success `proof` is the `NftOwnershipProof` (launcher id, owner, attributed DID, current coin id);
599
684
  * the caller still confirms `proof.nftCoinId` is unspent on-chain for liveness.
600
- * @param {any} parent_spend
685
+ * @param {CoinSpend} parent_spend
601
686
  * @param {Uint8Array} claimed_owner_puzzle_hash
602
687
  * @param {Uint8Array | null} [required_nft]
603
- * @returns {any}
688
+ * @returns {GatingResult}
604
689
  */
605
690
  export function proveNftOwnership(parent_spend, claimed_owner_puzzle_hash, required_nft) {
606
691
  try {
@@ -626,8 +711,8 @@ export function proveNftOwnership(parent_spend, claimed_owner_puzzle_hash, requi
626
711
  * Read an NFT's ownership facts (owner, attributed DID, launcher id, current coin id) from
627
712
  * `parent_spend` WITHOUT applying a gate — for dapps that want to decide in their own code.
628
713
  * Returns `{ ok, proof?, error? }`.
629
- * @param {any} parent_spend
630
- * @returns {any}
714
+ * @param {CoinSpend} parent_spend
715
+ * @returns {GatingResult}
631
716
  */
632
717
  export function readNftOwnership(parent_spend) {
633
718
  try {
@@ -670,7 +755,7 @@ export function sha256(bytes) {
670
755
  /**
671
756
  * Serialize a spend bundle (`{coinSpends, aggregatedSignature}`) to its hex wire encoding
672
757
  * (see [`chip35_dl_coin::spend_bundle_to_hex`]).
673
- * @param {any} spend_bundle
758
+ * @param {SpendBundle} spend_bundle
674
759
  * @returns {string}
675
760
  */
676
761
  export function spendBundleToHex(spend_bundle) {
@@ -702,7 +787,7 @@ export function spendBundleToHex(spend_bundle) {
702
787
  * Update a store's metadata (see [`chip35_dl_coin::update_store_metadata`]). Exactly one of
703
788
  * `owner_public_key`, `admin_public_key`, `writer_public_key` must be provided — it selects the
704
789
  * authorizing role. Returns a `SuccessResponse`.
705
- * @param {any} store
790
+ * @param {DataStore} store
706
791
  * @param {Uint8Array} new_root_hash
707
792
  * @param {string | null} [new_label]
708
793
  * @param {string | null} [new_description]
@@ -711,7 +796,7 @@ export function spendBundleToHex(spend_bundle) {
711
796
  * @param {Uint8Array | null} [owner_public_key]
712
797
  * @param {Uint8Array | null} [admin_public_key]
713
798
  * @param {Uint8Array | null} [writer_public_key]
714
- * @returns {any}
799
+ * @returns {SuccessResponse}
715
800
  */
716
801
  export function updateStoreMetadata(store, new_root_hash, new_label, new_description, new_bytes, new_program_hash, owner_public_key, admin_public_key, writer_public_key) {
717
802
  try {
@@ -748,12 +833,12 @@ export function updateStoreMetadata(store, new_root_hash, new_label, new_descrip
748
833
  * [`chip35_dl_coin::update_store_ownership`]). Omitting `new_owner_puzzle_hash` keeps the
749
834
  * current owner. Exactly one of `owner_public_key`/`admin_public_key` must be provided. Returns
750
835
  * a `SuccessResponse`.
751
- * @param {any} store
836
+ * @param {DataStore} store
752
837
  * @param {Uint8Array | null | undefined} new_owner_puzzle_hash
753
- * @param {any} new_delegated_puzzles
838
+ * @param {DelegatedPuzzle[]} new_delegated_puzzles
754
839
  * @param {Uint8Array | null} [owner_public_key]
755
840
  * @param {Uint8Array | null} [admin_public_key]
756
- * @returns {any}
841
+ * @returns {SuccessResponse}
757
842
  */
758
843
  export function updateStoreOwnership(store, new_owner_puzzle_hash, new_delegated_puzzles, owner_public_key, admin_public_key) {
759
844
  try {
@@ -782,9 +867,9 @@ export function updateStoreOwnership(store, new_owner_puzzle_hash, new_delegated
782
867
  * on-chain hash matches `sha256(bytes)` — the URI↔hash agreement check (#36). `assets` is
783
868
  * `{ dataBytes?, dataHash?, metadataBytes?, metadataHash?, licenseBytes?, licenseHash? }` (all
784
869
  * `Uint8Array`). Returns `{ ok: bool, errors: string[] }`.
785
- * @param {any} metadata
786
- * @param {any} assets
787
- * @returns {any}
870
+ * @param {Chip0007Metadata} metadata
871
+ * @param {Chip0007Assets} assets
872
+ * @returns {ValidationResult}
788
873
  */
789
874
  export function validateChip0007(metadata, assets) {
790
875
  try {
@@ -808,12 +893,12 @@ export function validateChip0007(metadata, assets) {
808
893
  * that nonce. `observed` is an `ObservedPayment` the dapp filled in after reading the owner's coin;
809
894
  * `required_asset` is a `PaymentAsset` (`{xch:true}` or `{assetId}`). Returns `{ ok, error? }` —
810
895
  * `ok:true` grants access, otherwise `error` is the human-readable denial reason.
811
- * @param {any} observed
896
+ * @param {ObservedPayment} observed
812
897
  * @param {Uint8Array} owner_puzzle_hash
813
898
  * @param {bigint} min_amount
814
- * @param {any} required_asset
899
+ * @param {PaymentAsset} required_asset
815
900
  * @param {Uint8Array | null} [require_nonce]
816
- * @returns {any}
901
+ * @returns {PaywallResult}
817
902
  */
818
903
  export function verifyPaymentReceipt(observed, owner_puzzle_hash, min_amount, required_asset, require_nonce) {
819
904
  try {
@@ -835,6 +920,28 @@ export function verifyPaymentReceipt(observed, owner_puzzle_hash, min_amount, re
835
920
  }
836
921
  }
837
922
 
923
+ /**
924
+ * The published package version (= the Cargo crate version = the npm package version). Lets a
925
+ * consumer/agent feature-gate on exactly which build is loaded at runtime.
926
+ * @returns {string}
927
+ */
928
+ export function version() {
929
+ let deferred1_0;
930
+ let deferred1_1;
931
+ try {
932
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
933
+ wasm.version(retptr);
934
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
935
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
936
+ deferred1_0 = r0;
937
+ deferred1_1 = r1;
938
+ return getStringFromWasm0(r0, r1);
939
+ } finally {
940
+ wasm.__wbindgen_add_to_stack_pointer(16);
941
+ wasm.__wbindgen_export4(deferred1_0, deferred1_1, 1);
942
+ }
943
+ }
944
+
838
945
  /**
839
946
  * Build the **Writer** delegated puzzle for a 48-byte synthetic public key — a revocable deploy
840
947
  * token (#17) or a hub Teams writer (#43). A writer may advance the root (deploy a new capsule)
@@ -842,7 +949,7 @@ export function verifyPaymentReceipt(observed, owner_puzzle_hash, min_amount, re
842
949
  * to issue the token; replace the store's delegated set to revoke it. Returns a `DelegatedPuzzle`
843
950
  * (`{ writerInnerPuzzleHash }`).
844
951
  * @param {Uint8Array} synthetic_key
845
- * @returns {any}
952
+ * @returns {DelegatedPuzzle}
846
953
  */
847
954
  export function writerDelegatedPuzzleFromKey(synthetic_key) {
848
955
  try {
@@ -1049,6 +1156,10 @@ export function __wbg_prototypesetcall_3249fc62a0fafa30(arg0, arg1, arg2) {
1049
1156
  export function __wbg_set_6be42768c690e380(arg0, arg1, arg2) {
1050
1157
  getObject(arg0)[takeObject(arg1)] = takeObject(arg2);
1051
1158
  }
1159
+ export function __wbg_set_6e30c9374c26414c() { return handleError(function (arg0, arg1, arg2) {
1160
+ const ret = Reflect.set(getObject(arg0), getObject(arg1), getObject(arg2));
1161
+ return ret;
1162
+ }, arguments); }
1052
1163
  export function __wbg_set_dca99999bba88a9a(arg0, arg1, arg2) {
1053
1164
  getObject(arg0)[arg1 >>> 0] = takeObject(arg2);
1054
1165
  }
Binary file
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@dignetwork/chip35-dl-coin-wasm",
3
3
  "type": "module",
4
4
  "description": "WebAssembly bindings for the isolated CHIP-0035 DataLayer store coin driver.",
5
- "version": "0.7.0",
5
+ "version": "0.9.0",
6
6
  "license": "MIT",
7
7
  "repository": {
8
8
  "type": "git",