@dignetwork/chip35-dl-coin-wasm 0.8.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.
@@ -233,13 +233,25 @@ export interface CatInfo {
233
233
  p2PuzzleHash: Uint8Array;
234
234
  }
235
235
 
236
- /** A buyer's CAT coin (as `chip0002_getAssetCoins` returns it) for `buildCatPayment`. */
236
+ /** A buyer's CAT coin (as `chip0002_getAssetCoins` returns it) for `buildCatPayment` / `buildDigStorePayment`. */
237
237
  export interface Cat {
238
238
  coin: Coin;
239
239
  lineageProof?: LineageProof | null;
240
240
  info: CatInfo;
241
241
  }
242
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
+
243
255
  /** The verifiable description of a payment's on-chain commitment. */
244
256
  export interface PaymentReceipt {
245
257
  ownerPuzzleHash: Uint8Array;
@@ -365,6 +377,18 @@ export function buildCatPayment(buyer_synthetic_key: Uint8Array, selected_cats:
365
377
  */
366
378
  export function buildChip0007Metadata(metadata: Chip0007Metadata): Chip0007MetadataResult;
367
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[];
391
+
368
392
  /**
369
393
  * Build the coin spends for a buyer to pay the dapp owner `amount` mojos of **XCH** (#46 payment).
370
394
  * `selected_coins` is the buyer's XCH `Coin[]`; `nonce` is the 32-byte unlock nonce. Returns
@@ -408,6 +432,22 @@ export function dataStoreFromSpend(coin_spend: CoinSpend, prev_delegated_puzzles
408
432
  */
409
433
  export function decodeOffer(text: string): SpendBundle;
410
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;
450
+
411
451
  /**
412
452
  * Derive the digstore-scoped owner discovery hint for a 32-byte owner puzzle hash. The app
413
453
  * computes the SAME hint to enumerate the wallet's stores via coinset
@@ -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, 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
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";
@@ -110,6 +110,41 @@ 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
@@ -263,6 +298,43 @@ export function decodeOffer(text) {
263
298
  }
264
299
  }
265
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
+
266
338
  /**
267
339
  * Derive the digstore-scoped owner discovery hint for a 32-byte owner puzzle hash. The app
268
340
  * computes the SAME hint to enumerate the wallet's stores via coinset
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.8.0",
5
+ "version": "0.9.0",
6
6
  "license": "MIT",
7
7
  "repository": {
8
8
  "type": "git",