@dignetwork/chip35-dl-coin-wasm 0.6.0 → 0.8.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,40 +1,398 @@
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`. */
237
+ export interface Cat {
238
+ coin: Coin;
239
+ lineageProof?: LineageProof | null;
240
+ info: CatInfo;
241
+ }
242
+
243
+ /** The verifiable description of a payment's on-chain commitment. */
244
+ export interface PaymentReceipt {
245
+ ownerPuzzleHash: Uint8Array;
246
+ amount: bigint;
247
+ asset: PaymentAsset;
248
+ nonce: Uint8Array;
249
+ paymentCoin: Coin;
250
+ }
251
+
252
+ /** Result of `buildPayment` / `buildCatPayment`. */
253
+ export interface PaymentResponse {
254
+ coinSpends: CoinSpend[];
255
+ receipt: PaymentReceipt;
256
+ }
257
+
258
+ /** What an observed payment looks like to the paywall after reading the chain (for `verifyPaymentReceipt`). */
259
+ export interface ObservedPayment {
260
+ paidToPuzzleHash: Uint8Array;
261
+ amount: bigint;
262
+ asset: PaymentAsset;
263
+ nonce?: Uint8Array | null;
264
+ }
265
+
266
+ /**
267
+ * Result of `verifyPaymentReceipt`. On denial, `code` is a stable `PaywallError`
268
+ * code (`WRONG_RECIPIENT` | `INSUFFICIENT_AMOUNT` | `WRONG_ASSET` | `NONCE_MISMATCH`).
269
+ */
270
+ export interface PaywallResult {
271
+ ok: boolean;
272
+ code?: ChipErrorCode;
273
+ error?: string;
274
+ }
275
+
276
+ /** The on-chain ownership facts a gating proof establishes about an NFT. */
277
+ export interface NftOwnershipProof {
278
+ launcherId: Uint8Array;
279
+ ownerPuzzleHash: Uint8Array;
280
+ attributedDid?: Uint8Array | null;
281
+ nftCoinId: Uint8Array;
282
+ }
283
+
284
+ /**
285
+ * Result of the NFT-gating helpers (`proveNftOwnership` / `proveCollectionMembership` /
286
+ * `readNftOwnership`). On failure, `code` is a stable `GatingError` code
287
+ * (`NOT_AN_NFT` | `WRONG_OWNER` | `WRONG_COLLECTION` | `WRONG_NFT`).
288
+ */
289
+ export interface GatingResult {
290
+ ok: boolean;
291
+ proof?: NftOwnershipProof;
292
+ code?: ChipErrorCode;
293
+ error?: string;
294
+ }
295
+
296
+ /**
297
+ * Every stable machine error code this module can surface — thrown as `{ code, message }` from a
298
+ * failing export, or carried as the `code` field of a `{ ok:false, code, error }` result. Branch on
299
+ * the code, never the human `message`/`error` string.
300
+ */
301
+ export type ChipErrorCode =
302
+ | "INVALID_ARGUMENT"
303
+ | "SERDE_ERROR"
304
+ | "DRIVER_ERROR"
305
+ | "PARSE_ERROR"
306
+ | "PERMISSION_DENIED"
307
+ | "METADATA_ERROR"
308
+ | "NOT_AN_NFT"
309
+ | "WRONG_OWNER"
310
+ | "WRONG_COLLECTION"
311
+ | "WRONG_NFT"
312
+ | "WRONG_RECIPIENT"
313
+ | "INSUFFICIENT_AMOUNT"
314
+ | "WRONG_ASSET"
315
+ | "NONCE_MISMATCH";
316
+
317
+ /** The structured error a failing export throws: a stable machine `code` beside the human `message`. */
318
+ export interface ChipError {
319
+ code: ChipErrorCode;
320
+ message: string;
321
+ }
322
+
323
+ /** Runtime self-description returned by `capabilities()`. */
324
+ export interface Capabilities {
325
+ /** The published npm package name. */
326
+ name: string;
327
+ /** The package version (= `version()`). */
328
+ version: string;
329
+ /** Every exported builder/helper (camelCase JS names). */
330
+ builders: string[];
331
+ /** The catalogue of stable machine error codes (see `ChipErrorCode`). */
332
+ errorCodes: ChipErrorCode[];
333
+ }
334
+
335
+
336
+
4
337
  /**
5
338
  * Build coin spends that reserve `fee` mojos from the spender's own coins while asserting
6
339
  * concurrent spend of `assert_coin_ids` (see [`chip35_dl_coin::add_fee`]). Lets a fee-less
7
340
  * singleton op (update/melt) carry a network fee. `selected_coins` is `Coin[]`,
8
341
  * `assert_coin_ids` is `Uint8Array[]` of 32-byte coin ids. Returns `CoinSpend[]`.
9
342
  */
10
- export function addFee(spender_synthetic_key: Uint8Array, selected_coins: any, assert_coin_ids: any, fee: bigint): any;
343
+ export function addFee(spender_synthetic_key: Uint8Array, selected_coins: Coin[], assert_coin_ids: Uint8Array[], fee: bigint): CoinSpend[];
11
344
 
12
345
  /**
13
346
  * Build the **Admin** delegated puzzle for a 48-byte synthetic public key (a hub Teams admin).
14
347
  * An admin may update the store AND change delegation (add/remove writers — i.e. revoke a deploy
15
348
  * token), but cannot transfer ownership. Returns a `DelegatedPuzzle` (`{ adminInnerPuzzleHash }`).
16
349
  */
17
- export function adminDelegatedPuzzleFromKey(synthetic_key: Uint8Array): any;
350
+ export function adminDelegatedPuzzleFromKey(synthetic_key: Uint8Array): DelegatedPuzzle;
351
+
352
+ /**
353
+ * Build the coin spends for a buyer to pay the dapp owner `amount` base units of a **CAT** (incl.
354
+ * DIG) (#46 payment). `selected_cats` is the buyer's `Cat[]` of ONE asset id (as
355
+ * `chip0002_getAssetCoins` returns them); `nonce` is the 32-byte unlock nonce. The CAT ring nets to
356
+ * zero, so carry any XCH network fee with a separate XCH coin via `addFee` asserting the lead CAT
357
+ * coin id. Returns `{ coinSpends, receipt }`.
358
+ */
359
+ export function buildCatPayment(buyer_synthetic_key: Uint8Array, selected_cats: Cat[], owner_puzzle_hash: Uint8Array, amount: bigint, nonce: Uint8Array): PaymentResponse;
18
360
 
19
361
  /**
20
362
  * Build a CHIP-0007 metadata document from a JS object and return its canonical JSON + the
21
363
  * `metadata_hash` (sha256 of that JSON). De-dupes the hand-computed badge metadata: callers stop
22
364
  * hand-rolling SHA-256. Returns `{ json: string, metadataHash: Uint8Array }`. Validates schema.
23
365
  */
24
- export function buildChip0007Metadata(metadata: any): any;
366
+ export function buildChip0007Metadata(metadata: Chip0007Metadata): Chip0007MetadataResult;
367
+
368
+ /**
369
+ * Build the coin spends for a buyer to pay the dapp owner `amount` mojos of **XCH** (#46 payment).
370
+ * `selected_coins` is the buyer's XCH `Coin[]`; `nonce` is the 32-byte unlock nonce. Returns
371
+ * `{ coinSpends, receipt }` where `receipt` is the `PaymentReceipt` the paywall later verifies.
372
+ */
373
+ export function buildPayment(buyer_synthetic_key: Uint8Array, selected_coins: Coin[], owner_puzzle_hash: Uint8Array, amount: bigint, nonce: Uint8Array, fee: bigint): PaymentResponse;
25
374
 
26
375
  /**
27
376
  * Bulk-mint every item in a parsed traits manifest into a collection, attributed to a DID (#34).
28
377
  * `did` is the DID coin + identifiers `{ launcherId, innerPuzzleHash, didCoin }` (e.g. from a prior
29
378
  * `createDid`, fetched on-chain). Returns `{ coinSpends, launcherIds }`.
30
379
  */
31
- export function bulkMint(minter_synthetic_key: Uint8Array, did: any, collection: any, items: any, recipient_puzzle_hash: Uint8Array): any;
380
+ export function bulkMint(minter_synthetic_key: Uint8Array, did: Did, collection: Collection, items: ManifestItem[], recipient_puzzle_hash: Uint8Array): BulkMintResult;
381
+
382
+ /**
383
+ * A machine-readable descriptor of this module's surface, for runtime introspection by an agent or
384
+ * consumer: `{ name, version, builders, errorCodes }`. `builders` is every exported builder/helper
385
+ * (camelCase JS names); `errorCodes` is the catalogue of stable `UPPER_SNAKE` codes a caller may
386
+ * branch on (thrown as `{ code, message }`, or carried as the `code` field of a `{ ok, code?, error? }`
387
+ * result). One call yields the version + the full surface with zero out-of-band knowledge.
388
+ */
389
+ export function capabilities(): Capabilities;
32
390
 
33
391
  /**
34
392
  * Create a DID (creator identity) singleton. Returns
35
393
  * `{ coinSpends, launcherId, innerPuzzleHash, didCoin }`.
36
394
  */
37
- export function createDid(minter_synthetic_key: Uint8Array, selected_coins: any, fee: bigint): any;
395
+ export function createDid(minter_synthetic_key: Uint8Array, selected_coins: Coin[], fee: bigint): CreateDidResult;
38
396
 
39
397
  /**
40
398
  * Reconstruct a DataStore from the coin spend that created its current coin (the launcher
@@ -43,12 +401,12 @@ export function createDid(minter_synthetic_key: Uint8Array, selected_coins: any,
43
401
  * `coin_spend` is the wasm CoinSpend shape (Uint8Array fields); `prev_delegated_puzzles` is
44
402
  * the parent's delegated-puzzle list ([] for an owner-only store).
45
403
  */
46
- export function dataStoreFromSpend(coin_spend: any, prev_delegated_puzzles: any): any;
404
+ export function dataStoreFromSpend(coin_spend: CoinSpend, prev_delegated_puzzles: DelegatedPuzzle[]): DataStore;
47
405
 
48
406
  /**
49
407
  * Decode canonical offer text into its spend bundle `{ coinSpends, aggregatedSignature }`.
50
408
  */
51
- export function decodeOffer(text: string): any;
409
+ export function decodeOffer(text: string): SpendBundle;
52
410
 
53
411
  /**
54
412
  * Derive the digstore-scoped owner discovery hint for a 32-byte owner puzzle hash. The app
@@ -60,20 +418,20 @@ export function digstoreOwnerHint(owner_puzzle_hash: Uint8Array): Uint8Array;
60
418
  /**
61
419
  * Encode a spend bundle (`{coinSpends, aggregatedSignature}`) into canonical offer text.
62
420
  */
63
- export function encodeOffer(spend_bundle: any): string;
421
+ export function encodeOffer(spend_bundle: SpendBundle): string;
64
422
 
65
423
  /**
66
424
  * Generate per-item CHIP-0007 metadata documents for a collection from a parsed traits manifest
67
425
  * (#34). `collection` is `Collection`; `items` is `ManifestItem[]`. Returns
68
426
  * `Chip0007Metadata[]` (the off-chain JSON docs; the caller hashes + writes them into each capsule).
69
427
  */
70
- export function generateItemMetadata(collection: any, items: any): any;
428
+ export function generateItemMetadata(collection: Collection, items: ManifestItem[]): Chip0007Metadata[];
71
429
 
72
430
  /**
73
431
  * Decode a hex-encoded spend bundle into its `CoinSpend[]` (see
74
432
  * [`chip35_dl_coin::hex_spend_bundle_to_coin_spends`]).
75
433
  */
76
- export function hexSpendBundleToCoinSpends(hex: string): any;
434
+ export function hexSpendBundleToCoinSpends(hex: string): CoinSpend[];
77
435
 
78
436
  /**
79
437
  * Initialise the module. Call once at startup. Installs a panic hook (when the
@@ -84,40 +442,69 @@ export function init(): void;
84
442
  /**
85
443
  * Issue a single-issuance (fixed-supply) CAT. Returns `{ coinSpends, assetId, catCoins }`.
86
444
  */
87
- export function issueCat(issuer_synthetic_key: Uint8Array, selected_coins: any, amount: bigint, fee: bigint): any;
445
+ export function issueCat(issuer_synthetic_key: Uint8Array, selected_coins: Coin[], amount: bigint, fee: bigint): IssueCatResult;
88
446
 
89
447
  /**
90
448
  * Burn (melt) a store singleton (see [`chip35_dl_coin::melt_store`]). Owner-authorized only.
91
449
  * Returns the melt `CoinSpend[]`.
92
450
  */
93
- export function meltStore(store: any, owner_public_key: Uint8Array): any;
451
+ export function meltStore(store: DataStore, owner_public_key: Uint8Array): CoinSpend[];
94
452
 
95
453
  /**
96
454
  * Mint a single NFT whose media lives in a DIG capsule (`dig://` URN + https gateway fallback URIs,
97
455
  * hashes computed from real bytes). `params` is `NftMintParams`. Returns
98
456
  * `{ coinSpends, launcherId, nftCoin }`.
99
457
  */
100
- export function mintNft(minter_synthetic_key: Uint8Array, selected_coins: any, params: any, fee: bigint): any;
458
+ export function mintNft(minter_synthetic_key: Uint8Array, selected_coins: Coin[], params: NftMintParams, fee: bigint): NftMintResult;
101
459
 
102
460
  /**
103
461
  * Build the spend bundle that launches a new DataLayer store singleton (see
104
462
  * [`chip35_dl_coin::mint_store`]). `program_hash` is an optional 32-byte size-proof; the rest of
105
463
  * the JS values mirror the core builder. Returns a `SuccessResponse` (`coinSpends` + `newStore`).
106
464
  */
107
- 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;
465
+ 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;
108
466
 
109
467
  /**
110
468
  * Build the **Oracle** delegated puzzle: anyone may spend the store for the fixed `oracle_fee`
111
469
  * (mojos) paid to the 32-byte `oracle_puzzle_hash`. Returns a `DelegatedPuzzle`
112
470
  * (`{ oraclePaymentPuzzleHash, oracleFee }`).
113
471
  */
114
- export function oracleDelegatedPuzzle(oracle_puzzle_hash: Uint8Array, oracle_fee: bigint): any;
472
+ export function oracleDelegatedPuzzle(oracle_puzzle_hash: Uint8Array, oracle_fee: bigint): DelegatedPuzzle;
115
473
 
116
474
  /**
117
475
  * Exercise a store's oracle delegated puzzle (see [`chip35_dl_coin::oracle_spend`]). The spender
118
476
  * pays the oracle fee plus `fee` from `selected_coins`. Returns a `SuccessResponse`.
119
477
  */
120
- export function oracleSpend(spender_synthetic_key: Uint8Array, selected_coins: any, store: any, fee: bigint): any;
478
+ export function oracleSpend(spender_synthetic_key: Uint8Array, selected_coins: Coin[], store: DataStore, fee: bigint): SuccessResponse;
479
+
480
+ /**
481
+ * SHA-256-derive a 32-byte unlock nonce from arbitrary request bytes (`dappId||resource||user`).
482
+ * A dapp issues one nonce per unlock request, embeds it in the payment, and verifies it later. The
483
+ * dapp may instead use any random 32 bytes — this is a deterministic convenience. Returns 32 bytes.
484
+ */
485
+ export function paymentNonce(request_bytes: Uint8Array): Uint8Array;
486
+
487
+ /**
488
+ * Prove an NFT held by `claimed_owner_puzzle_hash` is a member of the collection/creator identified
489
+ * by `required_did` (#46 collection-gating). Returns `{ ok, proof?, error? }`.
490
+ */
491
+ export function proveCollectionMembership(parent_spend: CoinSpend, claimed_owner_puzzle_hash: Uint8Array, required_did: Uint8Array): GatingResult;
492
+
493
+ /**
494
+ * Prove an NFT (reconstructed from `parent_spend`, the coin spend that created its current coin) is
495
+ * owned by `claimed_owner_puzzle_hash`, optionally gating on a specific NFT launcher id (#46 NFT-
496
+ * gating). `parent_spend` is the wasm `CoinSpend` shape. Returns `{ ok, proof?, error? }` — on
497
+ * success `proof` is the `NftOwnershipProof` (launcher id, owner, attributed DID, current coin id);
498
+ * the caller still confirms `proof.nftCoinId` is unspent on-chain for liveness.
499
+ */
500
+ export function proveNftOwnership(parent_spend: CoinSpend, claimed_owner_puzzle_hash: Uint8Array, required_nft?: Uint8Array | null): GatingResult;
501
+
502
+ /**
503
+ * Read an NFT's ownership facts (owner, attributed DID, launcher id, current coin id) from
504
+ * `parent_spend` WITHOUT applying a gate — for dapps that want to decide in their own code.
505
+ * Returns `{ ok, proof?, error? }`.
506
+ */
507
+ export function readNftOwnership(parent_spend: CoinSpend): GatingResult;
121
508
 
122
509
  /**
123
510
  * SHA-256 of arbitrary bytes → 32-byte hash (the one true primitive for `data_hash`/
@@ -129,14 +516,14 @@ export function sha256(bytes: Uint8Array): Uint8Array;
129
516
  * Serialize a spend bundle (`{coinSpends, aggregatedSignature}`) to its hex wire encoding
130
517
  * (see [`chip35_dl_coin::spend_bundle_to_hex`]).
131
518
  */
132
- export function spendBundleToHex(spend_bundle: any): string;
519
+ export function spendBundleToHex(spend_bundle: SpendBundle): string;
133
520
 
134
521
  /**
135
522
  * Update a store's metadata (see [`chip35_dl_coin::update_store_metadata`]). Exactly one of
136
523
  * `owner_public_key`, `admin_public_key`, `writer_public_key` must be provided — it selects the
137
524
  * authorizing role. Returns a `SuccessResponse`.
138
525
  */
139
- 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;
526
+ 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;
140
527
 
141
528
  /**
142
529
  * Transfer ownership and/or replace the delegated-puzzle set (see
@@ -144,7 +531,7 @@ export function updateStoreMetadata(store: any, new_root_hash: Uint8Array, new_l
144
531
  * current owner. Exactly one of `owner_public_key`/`admin_public_key` must be provided. Returns
145
532
  * a `SuccessResponse`.
146
533
  */
147
- 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;
534
+ 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;
148
535
 
149
536
  /**
150
537
  * Validate a CHIP-0007 document's schema, and (when the actual bytes are provided) that each
@@ -152,7 +539,22 @@ export function updateStoreOwnership(store: any, new_owner_puzzle_hash: Uint8Arr
152
539
  * `{ dataBytes?, dataHash?, metadataBytes?, metadataHash?, licenseBytes?, licenseHash? }` (all
153
540
  * `Uint8Array`). Returns `{ ok: bool, errors: string[] }`.
154
541
  */
155
- export function validateChip0007(metadata: any, assets: any): any;
542
+ export function validateChip0007(metadata: Chip0007Metadata, assets: Chip0007Assets): ValidationResult;
543
+
544
+ /**
545
+ * Verify an observed payment unlocks a paywall (#46 pay-to-unlock): it must pay `owner_puzzle_hash`,
546
+ * in `required_asset`, at least `min_amount`, and (when `require_nonce` is a 32-byte value) carry
547
+ * that nonce. `observed` is an `ObservedPayment` the dapp filled in after reading the owner's coin;
548
+ * `required_asset` is a `PaymentAsset` (`{xch:true}` or `{assetId}`). Returns `{ ok, error? }` —
549
+ * `ok:true` grants access, otherwise `error` is the human-readable denial reason.
550
+ */
551
+ export function verifyPaymentReceipt(observed: ObservedPayment, owner_puzzle_hash: Uint8Array, min_amount: bigint, required_asset: PaymentAsset, require_nonce?: Uint8Array | null): PaywallResult;
552
+
553
+ /**
554
+ * The published package version (= the Cargo crate version = the npm package version). Lets a
555
+ * consumer/agent feature-gate on exactly which build is loaded at runtime.
556
+ */
557
+ export function version(): string;
156
558
 
157
559
  /**
158
560
  * Build the **Writer** delegated puzzle for a 48-byte synthetic public key — a revocable deploy
@@ -161,4 +563,4 @@ export function validateChip0007(metadata: any, assets: any): any;
161
563
  * to issue the token; replace the store's delegated set to revoke it. Returns a `DelegatedPuzzle`
162
564
  * (`{ writerInnerPuzzleHash }`).
163
565
  */
164
- export function writerDelegatedPuzzleFromKey(synthetic_key: Uint8Array): any;
566
+ 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, buildChip0007Metadata, bulkMint, createDid, dataStoreFromSpend, decodeOffer, digstoreOwnerHint, encodeOffer, generateItemMetadata, hexSpendBundleToCoinSpends, init, issueCat, meltStore, mintNft, mintStore, oracleDelegatedPuzzle, oracleSpend, sha256, spendBundleToHex, updateStoreMetadata, updateStoreOwnership, validateChip0007, writerDelegatedPuzzleFromKey
8
+ addFee, adminDelegatedPuzzleFromKey, buildCatPayment, buildChip0007Metadata, buildPayment, bulkMint, capabilities, createDid, dataStoreFromSpend, decodeOffer, 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 {
@@ -52,12 +52,47 @@ export function adminDelegatedPuzzleFromKey(synthetic_key) {
52
52
  }
53
53
  }
54
54
 
55
+ /**
56
+ * Build the coin spends for a buyer to pay the dapp owner `amount` base units of a **CAT** (incl.
57
+ * DIG) (#46 payment). `selected_cats` is the buyer's `Cat[]` of ONE asset id (as
58
+ * `chip0002_getAssetCoins` returns them); `nonce` is the 32-byte unlock nonce. The CAT ring nets to
59
+ * zero, so carry any XCH network fee with a separate XCH coin via `addFee` asserting the lead CAT
60
+ * coin id. Returns `{ coinSpends, receipt }`.
61
+ * @param {Uint8Array} buyer_synthetic_key
62
+ * @param {Cat[]} selected_cats
63
+ * @param {Uint8Array} owner_puzzle_hash
64
+ * @param {bigint} amount
65
+ * @param {Uint8Array} nonce
66
+ * @returns {PaymentResponse}
67
+ */
68
+ export function buildCatPayment(buyer_synthetic_key, selected_cats, owner_puzzle_hash, amount, nonce) {
69
+ try {
70
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
71
+ const ptr0 = passArray8ToWasm0(buyer_synthetic_key, wasm.__wbindgen_export);
72
+ const len0 = WASM_VECTOR_LEN;
73
+ const ptr1 = passArray8ToWasm0(owner_puzzle_hash, wasm.__wbindgen_export);
74
+ const len1 = WASM_VECTOR_LEN;
75
+ const ptr2 = passArray8ToWasm0(nonce, wasm.__wbindgen_export);
76
+ const len2 = WASM_VECTOR_LEN;
77
+ wasm.buildCatPayment(retptr, ptr0, len0, addHeapObject(selected_cats), ptr1, len1, amount, ptr2, len2);
78
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
79
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
80
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
81
+ if (r2) {
82
+ throw takeObject(r1);
83
+ }
84
+ return takeObject(r0);
85
+ } finally {
86
+ wasm.__wbindgen_add_to_stack_pointer(16);
87
+ }
88
+ }
89
+
55
90
  /**
56
91
  * Build a CHIP-0007 metadata document from a JS object and return its canonical JSON + the
57
92
  * `metadata_hash` (sha256 of that JSON). De-dupes the hand-computed badge metadata: callers stop
58
93
  * hand-rolling SHA-256. Returns `{ json: string, metadataHash: Uint8Array }`. Validates schema.
59
- * @param {any} metadata
60
- * @returns {any}
94
+ * @param {Chip0007Metadata} metadata
95
+ * @returns {Chip0007MetadataResult}
61
96
  */
62
97
  export function buildChip0007Metadata(metadata) {
63
98
  try {
@@ -75,16 +110,50 @@ export function buildChip0007Metadata(metadata) {
75
110
  }
76
111
  }
77
112
 
113
+ /**
114
+ * Build the coin spends for a buyer to pay the dapp owner `amount` mojos of **XCH** (#46 payment).
115
+ * `selected_coins` is the buyer's XCH `Coin[]`; `nonce` is the 32-byte unlock nonce. Returns
116
+ * `{ coinSpends, receipt }` where `receipt` is the `PaymentReceipt` the paywall later verifies.
117
+ * @param {Uint8Array} buyer_synthetic_key
118
+ * @param {Coin[]} selected_coins
119
+ * @param {Uint8Array} owner_puzzle_hash
120
+ * @param {bigint} amount
121
+ * @param {Uint8Array} nonce
122
+ * @param {bigint} fee
123
+ * @returns {PaymentResponse}
124
+ */
125
+ export function buildPayment(buyer_synthetic_key, selected_coins, owner_puzzle_hash, amount, nonce, fee) {
126
+ try {
127
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
128
+ const ptr0 = passArray8ToWasm0(buyer_synthetic_key, wasm.__wbindgen_export);
129
+ const len0 = WASM_VECTOR_LEN;
130
+ const ptr1 = passArray8ToWasm0(owner_puzzle_hash, wasm.__wbindgen_export);
131
+ const len1 = WASM_VECTOR_LEN;
132
+ const ptr2 = passArray8ToWasm0(nonce, wasm.__wbindgen_export);
133
+ const len2 = WASM_VECTOR_LEN;
134
+ wasm.buildPayment(retptr, ptr0, len0, addHeapObject(selected_coins), ptr1, len1, amount, ptr2, len2, fee);
135
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
136
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
137
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
138
+ if (r2) {
139
+ throw takeObject(r1);
140
+ }
141
+ return takeObject(r0);
142
+ } finally {
143
+ wasm.__wbindgen_add_to_stack_pointer(16);
144
+ }
145
+ }
146
+
78
147
  /**
79
148
  * Bulk-mint every item in a parsed traits manifest into a collection, attributed to a DID (#34).
80
149
  * `did` is the DID coin + identifiers `{ launcherId, innerPuzzleHash, didCoin }` (e.g. from a prior
81
150
  * `createDid`, fetched on-chain). Returns `{ coinSpends, launcherIds }`.
82
151
  * @param {Uint8Array} minter_synthetic_key
83
- * @param {any} did
84
- * @param {any} collection
85
- * @param {any} items
152
+ * @param {Did} did
153
+ * @param {Collection} collection
154
+ * @param {ManifestItem[]} items
86
155
  * @param {Uint8Array} recipient_puzzle_hash
87
- * @returns {any}
156
+ * @returns {BulkMintResult}
88
157
  */
89
158
  export function bulkMint(minter_synthetic_key, did, collection, items, recipient_puzzle_hash) {
90
159
  try {
@@ -106,13 +175,26 @@ export function bulkMint(minter_synthetic_key, did, collection, items, recipient
106
175
  }
107
176
  }
108
177
 
178
+ /**
179
+ * A machine-readable descriptor of this module's surface, for runtime introspection by an agent or
180
+ * consumer: `{ name, version, builders, errorCodes }`. `builders` is every exported builder/helper
181
+ * (camelCase JS names); `errorCodes` is the catalogue of stable `UPPER_SNAKE` codes a caller may
182
+ * branch on (thrown as `{ code, message }`, or carried as the `code` field of a `{ ok, code?, error? }`
183
+ * result). One call yields the version + the full surface with zero out-of-band knowledge.
184
+ * @returns {Capabilities}
185
+ */
186
+ export function capabilities() {
187
+ const ret = wasm.capabilities();
188
+ return takeObject(ret);
189
+ }
190
+
109
191
  /**
110
192
  * Create a DID (creator identity) singleton. Returns
111
193
  * `{ coinSpends, launcherId, innerPuzzleHash, didCoin }`.
112
194
  * @param {Uint8Array} minter_synthetic_key
113
- * @param {any} selected_coins
195
+ * @param {Coin[]} selected_coins
114
196
  * @param {bigint} fee
115
- * @returns {any}
197
+ * @returns {CreateDidResult}
116
198
  */
117
199
  export function createDid(minter_synthetic_key, selected_coins, fee) {
118
200
  try {
@@ -138,9 +220,9 @@ export function createDid(minter_synthetic_key, selected_coins, fee) {
138
220
  * creating spend from a full node, rebuild the DataStore here, then meltStore() it.
139
221
  * `coin_spend` is the wasm CoinSpend shape (Uint8Array fields); `prev_delegated_puzzles` is
140
222
  * the parent's delegated-puzzle list ([] for an owner-only store).
141
- * @param {any} coin_spend
142
- * @param {any} prev_delegated_puzzles
143
- * @returns {any}
223
+ * @param {CoinSpend} coin_spend
224
+ * @param {DelegatedPuzzle[]} prev_delegated_puzzles
225
+ * @returns {DataStore}
144
226
  */
145
227
  export function dataStoreFromSpend(coin_spend, prev_delegated_puzzles) {
146
228
  try {
@@ -161,7 +243,7 @@ export function dataStoreFromSpend(coin_spend, prev_delegated_puzzles) {
161
243
  /**
162
244
  * Decode canonical offer text into its spend bundle `{ coinSpends, aggregatedSignature }`.
163
245
  * @param {string} text
164
- * @returns {any}
246
+ * @returns {SpendBundle}
165
247
  */
166
248
  export function decodeOffer(text) {
167
249
  try {
@@ -211,7 +293,7 @@ export function digstoreOwnerHint(owner_puzzle_hash) {
211
293
 
212
294
  /**
213
295
  * Encode a spend bundle (`{coinSpends, aggregatedSignature}`) into canonical offer text.
214
- * @param {any} spend_bundle
296
+ * @param {SpendBundle} spend_bundle
215
297
  * @returns {string}
216
298
  */
217
299
  export function encodeOffer(spend_bundle) {
@@ -243,9 +325,9 @@ export function encodeOffer(spend_bundle) {
243
325
  * Generate per-item CHIP-0007 metadata documents for a collection from a parsed traits manifest
244
326
  * (#34). `collection` is `Collection`; `items` is `ManifestItem[]`. Returns
245
327
  * `Chip0007Metadata[]` (the off-chain JSON docs; the caller hashes + writes them into each capsule).
246
- * @param {any} collection
247
- * @param {any} items
248
- * @returns {any}
328
+ * @param {Collection} collection
329
+ * @param {ManifestItem[]} items
330
+ * @returns {Chip0007Metadata[]}
249
331
  */
250
332
  export function generateItemMetadata(collection, items) {
251
333
  try {
@@ -267,7 +349,7 @@ export function generateItemMetadata(collection, items) {
267
349
  * Decode a hex-encoded spend bundle into its `CoinSpend[]` (see
268
350
  * [`chip35_dl_coin::hex_spend_bundle_to_coin_spends`]).
269
351
  * @param {string} hex
270
- * @returns {any}
352
+ * @returns {CoinSpend[]}
271
353
  */
272
354
  export function hexSpendBundleToCoinSpends(hex) {
273
355
  try {
@@ -298,10 +380,10 @@ export function init() {
298
380
  /**
299
381
  * Issue a single-issuance (fixed-supply) CAT. Returns `{ coinSpends, assetId, catCoins }`.
300
382
  * @param {Uint8Array} issuer_synthetic_key
301
- * @param {any} selected_coins
383
+ * @param {Coin[]} selected_coins
302
384
  * @param {bigint} amount
303
385
  * @param {bigint} fee
304
- * @returns {any}
386
+ * @returns {IssueCatResult}
305
387
  */
306
388
  export function issueCat(issuer_synthetic_key, selected_coins, amount, fee) {
307
389
  try {
@@ -324,9 +406,9 @@ export function issueCat(issuer_synthetic_key, selected_coins, amount, fee) {
324
406
  /**
325
407
  * Burn (melt) a store singleton (see [`chip35_dl_coin::melt_store`]). Owner-authorized only.
326
408
  * Returns the melt `CoinSpend[]`.
327
- * @param {any} store
409
+ * @param {DataStore} store
328
410
  * @param {Uint8Array} owner_public_key
329
- * @returns {any}
411
+ * @returns {CoinSpend[]}
330
412
  */
331
413
  export function meltStore(store, owner_public_key) {
332
414
  try {
@@ -351,10 +433,10 @@ export function meltStore(store, owner_public_key) {
351
433
  * hashes computed from real bytes). `params` is `NftMintParams`. Returns
352
434
  * `{ coinSpends, launcherId, nftCoin }`.
353
435
  * @param {Uint8Array} minter_synthetic_key
354
- * @param {any} selected_coins
355
- * @param {any} params
436
+ * @param {Coin[]} selected_coins
437
+ * @param {NftMintParams} params
356
438
  * @param {bigint} fee
357
- * @returns {any}
439
+ * @returns {NftMintResult}
358
440
  */
359
441
  export function mintNft(minter_synthetic_key, selected_coins, params, fee) {
360
442
  try {
@@ -379,16 +461,16 @@ export function mintNft(minter_synthetic_key, selected_coins, params, fee) {
379
461
  * [`chip35_dl_coin::mint_store`]). `program_hash` is an optional 32-byte size-proof; the rest of
380
462
  * the JS values mirror the core builder. Returns a `SuccessResponse` (`coinSpends` + `newStore`).
381
463
  * @param {Uint8Array} minter_synthetic_key
382
- * @param {any} selected_coins
464
+ * @param {Coin[]} selected_coins
383
465
  * @param {Uint8Array} root_hash
384
466
  * @param {string | null | undefined} label
385
467
  * @param {string | null | undefined} description
386
468
  * @param {bigint | null | undefined} bytes
387
469
  * @param {Uint8Array | null | undefined} program_hash
388
470
  * @param {Uint8Array} owner_puzzle_hash
389
- * @param {any} delegated_puzzles
471
+ * @param {DelegatedPuzzle[]} delegated_puzzles
390
472
  * @param {bigint} fee
391
- * @returns {any}
473
+ * @returns {SuccessResponse}
392
474
  */
393
475
  export function mintStore(minter_synthetic_key, selected_coins, root_hash, label, description, bytes, program_hash, owner_puzzle_hash, delegated_puzzles, fee) {
394
476
  try {
@@ -424,7 +506,7 @@ export function mintStore(minter_synthetic_key, selected_coins, root_hash, label
424
506
  * (`{ oraclePaymentPuzzleHash, oracleFee }`).
425
507
  * @param {Uint8Array} oracle_puzzle_hash
426
508
  * @param {bigint} oracle_fee
427
- * @returns {any}
509
+ * @returns {DelegatedPuzzle}
428
510
  */
429
511
  export function oracleDelegatedPuzzle(oracle_puzzle_hash, oracle_fee) {
430
512
  try {
@@ -448,10 +530,10 @@ export function oracleDelegatedPuzzle(oracle_puzzle_hash, oracle_fee) {
448
530
  * Exercise a store's oracle delegated puzzle (see [`chip35_dl_coin::oracle_spend`]). The spender
449
531
  * pays the oracle fee plus `fee` from `selected_coins`. Returns a `SuccessResponse`.
450
532
  * @param {Uint8Array} spender_synthetic_key
451
- * @param {any} selected_coins
452
- * @param {any} store
533
+ * @param {Coin[]} selected_coins
534
+ * @param {DataStore} store
453
535
  * @param {bigint} fee
454
- * @returns {any}
536
+ * @returns {SuccessResponse}
455
537
  */
456
538
  export function oracleSpend(spender_synthetic_key, selected_coins, store, fee) {
457
539
  try {
@@ -471,6 +553,111 @@ export function oracleSpend(spender_synthetic_key, selected_coins, store, fee) {
471
553
  }
472
554
  }
473
555
 
556
+ /**
557
+ * SHA-256-derive a 32-byte unlock nonce from arbitrary request bytes (`dappId||resource||user`).
558
+ * A dapp issues one nonce per unlock request, embeds it in the payment, and verifies it later. The
559
+ * dapp may instead use any random 32 bytes — this is a deterministic convenience. Returns 32 bytes.
560
+ * @param {Uint8Array} request_bytes
561
+ * @returns {Uint8Array}
562
+ */
563
+ export function paymentNonce(request_bytes) {
564
+ try {
565
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
566
+ const ptr0 = passArray8ToWasm0(request_bytes, wasm.__wbindgen_export);
567
+ const len0 = WASM_VECTOR_LEN;
568
+ wasm.paymentNonce(retptr, ptr0, len0);
569
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
570
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
571
+ var v2 = getArrayU8FromWasm0(r0, r1).slice();
572
+ wasm.__wbindgen_export4(r0, r1 * 1, 1);
573
+ return v2;
574
+ } finally {
575
+ wasm.__wbindgen_add_to_stack_pointer(16);
576
+ }
577
+ }
578
+
579
+ /**
580
+ * Prove an NFT held by `claimed_owner_puzzle_hash` is a member of the collection/creator identified
581
+ * by `required_did` (#46 collection-gating). Returns `{ ok, proof?, error? }`.
582
+ * @param {CoinSpend} parent_spend
583
+ * @param {Uint8Array} claimed_owner_puzzle_hash
584
+ * @param {Uint8Array} required_did
585
+ * @returns {GatingResult}
586
+ */
587
+ export function proveCollectionMembership(parent_spend, claimed_owner_puzzle_hash, required_did) {
588
+ try {
589
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
590
+ const ptr0 = passArray8ToWasm0(claimed_owner_puzzle_hash, wasm.__wbindgen_export);
591
+ const len0 = WASM_VECTOR_LEN;
592
+ const ptr1 = passArray8ToWasm0(required_did, wasm.__wbindgen_export);
593
+ const len1 = WASM_VECTOR_LEN;
594
+ wasm.proveCollectionMembership(retptr, addHeapObject(parent_spend), ptr0, len0, ptr1, len1);
595
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
596
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
597
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
598
+ if (r2) {
599
+ throw takeObject(r1);
600
+ }
601
+ return takeObject(r0);
602
+ } finally {
603
+ wasm.__wbindgen_add_to_stack_pointer(16);
604
+ }
605
+ }
606
+
607
+ /**
608
+ * Prove an NFT (reconstructed from `parent_spend`, the coin spend that created its current coin) is
609
+ * owned by `claimed_owner_puzzle_hash`, optionally gating on a specific NFT launcher id (#46 NFT-
610
+ * gating). `parent_spend` is the wasm `CoinSpend` shape. Returns `{ ok, proof?, error? }` — on
611
+ * success `proof` is the `NftOwnershipProof` (launcher id, owner, attributed DID, current coin id);
612
+ * the caller still confirms `proof.nftCoinId` is unspent on-chain for liveness.
613
+ * @param {CoinSpend} parent_spend
614
+ * @param {Uint8Array} claimed_owner_puzzle_hash
615
+ * @param {Uint8Array | null} [required_nft]
616
+ * @returns {GatingResult}
617
+ */
618
+ export function proveNftOwnership(parent_spend, claimed_owner_puzzle_hash, required_nft) {
619
+ try {
620
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
621
+ const ptr0 = passArray8ToWasm0(claimed_owner_puzzle_hash, wasm.__wbindgen_export);
622
+ const len0 = WASM_VECTOR_LEN;
623
+ var ptr1 = isLikeNone(required_nft) ? 0 : passArray8ToWasm0(required_nft, wasm.__wbindgen_export);
624
+ var len1 = WASM_VECTOR_LEN;
625
+ wasm.proveNftOwnership(retptr, addHeapObject(parent_spend), ptr0, len0, ptr1, len1);
626
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
627
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
628
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
629
+ if (r2) {
630
+ throw takeObject(r1);
631
+ }
632
+ return takeObject(r0);
633
+ } finally {
634
+ wasm.__wbindgen_add_to_stack_pointer(16);
635
+ }
636
+ }
637
+
638
+ /**
639
+ * Read an NFT's ownership facts (owner, attributed DID, launcher id, current coin id) from
640
+ * `parent_spend` WITHOUT applying a gate — for dapps that want to decide in their own code.
641
+ * Returns `{ ok, proof?, error? }`.
642
+ * @param {CoinSpend} parent_spend
643
+ * @returns {GatingResult}
644
+ */
645
+ export function readNftOwnership(parent_spend) {
646
+ try {
647
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
648
+ wasm.readNftOwnership(retptr, addHeapObject(parent_spend));
649
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
650
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
651
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
652
+ if (r2) {
653
+ throw takeObject(r1);
654
+ }
655
+ return takeObject(r0);
656
+ } finally {
657
+ wasm.__wbindgen_add_to_stack_pointer(16);
658
+ }
659
+ }
660
+
474
661
  /**
475
662
  * SHA-256 of arbitrary bytes → 32-byte hash (the one true primitive for `data_hash`/
476
663
  * `metadata_hash`/`license_hash`). Returns the raw 32 bytes (`Uint8Array`).
@@ -496,7 +683,7 @@ export function sha256(bytes) {
496
683
  /**
497
684
  * Serialize a spend bundle (`{coinSpends, aggregatedSignature}`) to its hex wire encoding
498
685
  * (see [`chip35_dl_coin::spend_bundle_to_hex`]).
499
- * @param {any} spend_bundle
686
+ * @param {SpendBundle} spend_bundle
500
687
  * @returns {string}
501
688
  */
502
689
  export function spendBundleToHex(spend_bundle) {
@@ -528,7 +715,7 @@ export function spendBundleToHex(spend_bundle) {
528
715
  * Update a store's metadata (see [`chip35_dl_coin::update_store_metadata`]). Exactly one of
529
716
  * `owner_public_key`, `admin_public_key`, `writer_public_key` must be provided — it selects the
530
717
  * authorizing role. Returns a `SuccessResponse`.
531
- * @param {any} store
718
+ * @param {DataStore} store
532
719
  * @param {Uint8Array} new_root_hash
533
720
  * @param {string | null} [new_label]
534
721
  * @param {string | null} [new_description]
@@ -537,7 +724,7 @@ export function spendBundleToHex(spend_bundle) {
537
724
  * @param {Uint8Array | null} [owner_public_key]
538
725
  * @param {Uint8Array | null} [admin_public_key]
539
726
  * @param {Uint8Array | null} [writer_public_key]
540
- * @returns {any}
727
+ * @returns {SuccessResponse}
541
728
  */
542
729
  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) {
543
730
  try {
@@ -574,12 +761,12 @@ export function updateStoreMetadata(store, new_root_hash, new_label, new_descrip
574
761
  * [`chip35_dl_coin::update_store_ownership`]). Omitting `new_owner_puzzle_hash` keeps the
575
762
  * current owner. Exactly one of `owner_public_key`/`admin_public_key` must be provided. Returns
576
763
  * a `SuccessResponse`.
577
- * @param {any} store
764
+ * @param {DataStore} store
578
765
  * @param {Uint8Array | null | undefined} new_owner_puzzle_hash
579
- * @param {any} new_delegated_puzzles
766
+ * @param {DelegatedPuzzle[]} new_delegated_puzzles
580
767
  * @param {Uint8Array | null} [owner_public_key]
581
768
  * @param {Uint8Array | null} [admin_public_key]
582
- * @returns {any}
769
+ * @returns {SuccessResponse}
583
770
  */
584
771
  export function updateStoreOwnership(store, new_owner_puzzle_hash, new_delegated_puzzles, owner_public_key, admin_public_key) {
585
772
  try {
@@ -608,9 +795,9 @@ export function updateStoreOwnership(store, new_owner_puzzle_hash, new_delegated
608
795
  * on-chain hash matches `sha256(bytes)` — the URI↔hash agreement check (#36). `assets` is
609
796
  * `{ dataBytes?, dataHash?, metadataBytes?, metadataHash?, licenseBytes?, licenseHash? }` (all
610
797
  * `Uint8Array`). Returns `{ ok: bool, errors: string[] }`.
611
- * @param {any} metadata
612
- * @param {any} assets
613
- * @returns {any}
798
+ * @param {Chip0007Metadata} metadata
799
+ * @param {Chip0007Assets} assets
800
+ * @returns {ValidationResult}
614
801
  */
615
802
  export function validateChip0007(metadata, assets) {
616
803
  try {
@@ -628,6 +815,61 @@ export function validateChip0007(metadata, assets) {
628
815
  }
629
816
  }
630
817
 
818
+ /**
819
+ * Verify an observed payment unlocks a paywall (#46 pay-to-unlock): it must pay `owner_puzzle_hash`,
820
+ * in `required_asset`, at least `min_amount`, and (when `require_nonce` is a 32-byte value) carry
821
+ * that nonce. `observed` is an `ObservedPayment` the dapp filled in after reading the owner's coin;
822
+ * `required_asset` is a `PaymentAsset` (`{xch:true}` or `{assetId}`). Returns `{ ok, error? }` —
823
+ * `ok:true` grants access, otherwise `error` is the human-readable denial reason.
824
+ * @param {ObservedPayment} observed
825
+ * @param {Uint8Array} owner_puzzle_hash
826
+ * @param {bigint} min_amount
827
+ * @param {PaymentAsset} required_asset
828
+ * @param {Uint8Array | null} [require_nonce]
829
+ * @returns {PaywallResult}
830
+ */
831
+ export function verifyPaymentReceipt(observed, owner_puzzle_hash, min_amount, required_asset, require_nonce) {
832
+ try {
833
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
834
+ const ptr0 = passArray8ToWasm0(owner_puzzle_hash, wasm.__wbindgen_export);
835
+ const len0 = WASM_VECTOR_LEN;
836
+ var ptr1 = isLikeNone(require_nonce) ? 0 : passArray8ToWasm0(require_nonce, wasm.__wbindgen_export);
837
+ var len1 = WASM_VECTOR_LEN;
838
+ wasm.verifyPaymentReceipt(retptr, addHeapObject(observed), ptr0, len0, min_amount, addHeapObject(required_asset), ptr1, len1);
839
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
840
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
841
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
842
+ if (r2) {
843
+ throw takeObject(r1);
844
+ }
845
+ return takeObject(r0);
846
+ } finally {
847
+ wasm.__wbindgen_add_to_stack_pointer(16);
848
+ }
849
+ }
850
+
851
+ /**
852
+ * The published package version (= the Cargo crate version = the npm package version). Lets a
853
+ * consumer/agent feature-gate on exactly which build is loaded at runtime.
854
+ * @returns {string}
855
+ */
856
+ export function version() {
857
+ let deferred1_0;
858
+ let deferred1_1;
859
+ try {
860
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
861
+ wasm.version(retptr);
862
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
863
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
864
+ deferred1_0 = r0;
865
+ deferred1_1 = r1;
866
+ return getStringFromWasm0(r0, r1);
867
+ } finally {
868
+ wasm.__wbindgen_add_to_stack_pointer(16);
869
+ wasm.__wbindgen_export4(deferred1_0, deferred1_1, 1);
870
+ }
871
+ }
872
+
631
873
  /**
632
874
  * Build the **Writer** delegated puzzle for a 48-byte synthetic public key — a revocable deploy
633
875
  * token (#17) or a hub Teams writer (#43). A writer may advance the root (deploy a new capsule)
@@ -635,7 +877,7 @@ export function validateChip0007(metadata, assets) {
635
877
  * to issue the token; replace the store's delegated set to revoke it. Returns a `DelegatedPuzzle`
636
878
  * (`{ writerInnerPuzzleHash }`).
637
879
  * @param {Uint8Array} synthetic_key
638
- * @returns {any}
880
+ * @returns {DelegatedPuzzle}
639
881
  */
640
882
  export function writerDelegatedPuzzleFromKey(synthetic_key) {
641
883
  try {
@@ -842,6 +1084,10 @@ export function __wbg_prototypesetcall_3249fc62a0fafa30(arg0, arg1, arg2) {
842
1084
  export function __wbg_set_6be42768c690e380(arg0, arg1, arg2) {
843
1085
  getObject(arg0)[takeObject(arg1)] = takeObject(arg2);
844
1086
  }
1087
+ export function __wbg_set_6e30c9374c26414c() { return handleError(function (arg0, arg1, arg2) {
1088
+ const ret = Reflect.set(getObject(arg0), getObject(arg1), getObject(arg2));
1089
+ return ret;
1090
+ }, arguments); }
845
1091
  export function __wbg_set_dca99999bba88a9a(arg0, arg1, arg2) {
846
1092
  getObject(arg0)[arg1 >>> 0] = takeObject(arg2);
847
1093
  }
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.6.0",
5
+ "version": "0.8.0",
6
6
  "license": "MIT",
7
7
  "repository": {
8
8
  "type": "git",