@dignetwork/chip35-dl-coin-wasm 0.4.0 → 0.6.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,23 +1,40 @@
1
1
  /* tslint:disable */
2
2
  /* eslint-disable */
3
3
 
4
+ /**
5
+ * Build coin spends that reserve `fee` mojos from the spender's own coins while asserting
6
+ * concurrent spend of `assert_coin_ids` (see [`chip35_dl_coin::add_fee`]). Lets a fee-less
7
+ * singleton op (update/melt) carry a network fee. `selected_coins` is `Coin[]`,
8
+ * `assert_coin_ids` is `Uint8Array[]` of 32-byte coin ids. Returns `CoinSpend[]`.
9
+ */
4
10
  export function addFee(spender_synthetic_key: Uint8Array, selected_coins: any, assert_coin_ids: any, fee: bigint): any;
5
11
 
6
12
  /**
7
- * Build the (UNSIGNED) DIG CAT coin spends paying `amount` base units of DIG to the treasury
8
- * (100 DIG = 100000n to mint, 10 DIG = 10000n per update), returning change to the owner. The
9
- * app concatenates these with the singleton mint/update spends and has the wallet sign the WHOLE
10
- * bundle in ONE call — the single aggregated signature makes the store creation and the DIG
11
- * payment atomic (all-or-nothing in the mempool).
12
- *
13
- * `owner_synthetic_key` (48 bytes) is the wallet's synthetic public key — the SAME key used for
14
- * mintStore (the CAT inner puzzle is its standard puzzle). `owner_puzzle_hash` (32) is that key's
15
- * standard puzzle hash. `parent_spends` are the spends that created the candidate DIG coins (wasm
16
- * CoinSpend shape), and `child_coin_ids` (Uint8Array[] of 32 bytes) are those coins' ids in the
17
- * SAME order — each parent spend is parsed to reconstruct its DIG child's lineage proof.
18
- * `store_id` (32) is the launcher id, carried as a memo. Returns CoinSpend[] (UNSIGNED).
13
+ * Build the **Admin** delegated puzzle for a 48-byte synthetic public key (a hub Teams admin).
14
+ * An admin may update the store AND change delegation (add/remove writers i.e. revoke a deploy
15
+ * token), but cannot transfer ownership. Returns a `DelegatedPuzzle` (`{ adminInnerPuzzleHash }`).
19
16
  */
20
- export function buildDigPayment(owner_synthetic_key: Uint8Array, owner_puzzle_hash: Uint8Array, parent_spends: any, child_coin_ids: any, amount: bigint, store_id: Uint8Array): any;
17
+ export function adminDelegatedPuzzleFromKey(synthetic_key: Uint8Array): any;
18
+
19
+ /**
20
+ * Build a CHIP-0007 metadata document from a JS object and return its canonical JSON + the
21
+ * `metadata_hash` (sha256 of that JSON). De-dupes the hand-computed badge metadata: callers stop
22
+ * hand-rolling SHA-256. Returns `{ json: string, metadataHash: Uint8Array }`. Validates schema.
23
+ */
24
+ export function buildChip0007Metadata(metadata: any): any;
25
+
26
+ /**
27
+ * Bulk-mint every item in a parsed traits manifest into a collection, attributed to a DID (#34).
28
+ * `did` is the DID coin + identifiers `{ launcherId, innerPuzzleHash, didCoin }` (e.g. from a prior
29
+ * `createDid`, fetched on-chain). Returns `{ coinSpends, launcherIds }`.
30
+ */
31
+ export function bulkMint(minter_synthetic_key: Uint8Array, did: any, collection: any, items: any, recipient_puzzle_hash: Uint8Array): any;
32
+
33
+ /**
34
+ * Create a DID (creator identity) singleton. Returns
35
+ * `{ coinSpends, launcherId, innerPuzzleHash, didCoin }`.
36
+ */
37
+ export function createDid(minter_synthetic_key: Uint8Array, selected_coins: any, fee: bigint): any;
21
38
 
22
39
  /**
23
40
  * Reconstruct a DataStore from the coin spend that created its current coin (the launcher
@@ -29,16 +46,9 @@ export function buildDigPayment(owner_synthetic_key: Uint8Array, owner_puzzle_ha
29
46
  export function dataStoreFromSpend(coin_spend: any, prev_delegated_puzzles: any): any;
30
47
 
31
48
  /**
32
- * The DIG CAT outer puzzle hash for a 32-byte owner puzzle hash — where the wallet's DIG
33
- * coins live on-chain. The app uses it to read DIG balance + select DIG coins. 32 bytes.
34
- */
35
- export function digCatPuzzleHash(owner_puzzle_hash: Uint8Array): Uint8Array;
36
-
37
- /**
38
- * The DIG treasury inner (standard) puzzle hash — the fixed recipient of every DIG payment.
39
- * Returned so the app can pin it as a golden constant. 32 bytes.
49
+ * Decode canonical offer text into its spend bundle `{ coinSpends, aggregatedSignature }`.
40
50
  */
41
- export function digTreasuryInnerPuzzleHash(): Uint8Array;
51
+ export function decodeOffer(text: string): any;
42
52
 
43
53
  /**
44
54
  * Derive the digstore-scoped owner discovery hint for a 32-byte owner puzzle hash. The app
@@ -47,6 +57,22 @@ export function digTreasuryInnerPuzzleHash(): Uint8Array;
47
57
  */
48
58
  export function digstoreOwnerHint(owner_puzzle_hash: Uint8Array): Uint8Array;
49
59
 
60
+ /**
61
+ * Encode a spend bundle (`{coinSpends, aggregatedSignature}`) into canonical offer text.
62
+ */
63
+ export function encodeOffer(spend_bundle: any): string;
64
+
65
+ /**
66
+ * Generate per-item CHIP-0007 metadata documents for a collection from a parsed traits manifest
67
+ * (#34). `collection` is `Collection`; `items` is `ManifestItem[]`. Returns
68
+ * `Chip0007Metadata[]` (the off-chain JSON docs; the caller hashes + writes them into each capsule).
69
+ */
70
+ export function generateItemMetadata(collection: any, items: any): any;
71
+
72
+ /**
73
+ * Decode a hex-encoded spend bundle into its `CoinSpend[]` (see
74
+ * [`chip35_dl_coin::hex_spend_bundle_to_coin_spends`]).
75
+ */
50
76
  export function hexSpendBundleToCoinSpends(hex: string): any;
51
77
 
52
78
  /**
@@ -55,14 +81,84 @@ export function hexSpendBundleToCoinSpends(hex: string): any;
55
81
  */
56
82
  export function init(): void;
57
83
 
84
+ /**
85
+ * Issue a single-issuance (fixed-supply) CAT. Returns `{ coinSpends, assetId, catCoins }`.
86
+ */
87
+ export function issueCat(issuer_synthetic_key: Uint8Array, selected_coins: any, amount: bigint, fee: bigint): any;
88
+
89
+ /**
90
+ * Burn (melt) a store singleton (see [`chip35_dl_coin::melt_store`]). Owner-authorized only.
91
+ * Returns the melt `CoinSpend[]`.
92
+ */
58
93
  export function meltStore(store: any, owner_public_key: Uint8Array): any;
59
94
 
95
+ /**
96
+ * Mint a single NFT whose media lives in a DIG capsule (`dig://` URN + https gateway fallback URIs,
97
+ * hashes computed from real bytes). `params` is `NftMintParams`. Returns
98
+ * `{ coinSpends, launcherId, nftCoin }`.
99
+ */
100
+ export function mintNft(minter_synthetic_key: Uint8Array, selected_coins: any, params: any, fee: bigint): any;
101
+
102
+ /**
103
+ * Build the spend bundle that launches a new DataLayer store singleton (see
104
+ * [`chip35_dl_coin::mint_store`]). `program_hash` is an optional 32-byte size-proof; the rest of
105
+ * the JS values mirror the core builder. Returns a `SuccessResponse` (`coinSpends` + `newStore`).
106
+ */
60
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;
61
108
 
109
+ /**
110
+ * Build the **Oracle** delegated puzzle: anyone may spend the store for the fixed `oracle_fee`
111
+ * (mojos) paid to the 32-byte `oracle_puzzle_hash`. Returns a `DelegatedPuzzle`
112
+ * (`{ oraclePaymentPuzzleHash, oracleFee }`).
113
+ */
114
+ export function oracleDelegatedPuzzle(oracle_puzzle_hash: Uint8Array, oracle_fee: bigint): any;
115
+
116
+ /**
117
+ * Exercise a store's oracle delegated puzzle (see [`chip35_dl_coin::oracle_spend`]). The spender
118
+ * pays the oracle fee plus `fee` from `selected_coins`. Returns a `SuccessResponse`.
119
+ */
62
120
  export function oracleSpend(spender_synthetic_key: Uint8Array, selected_coins: any, store: any, fee: bigint): any;
63
121
 
122
+ /**
123
+ * SHA-256 of arbitrary bytes → 32-byte hash (the one true primitive for `data_hash`/
124
+ * `metadata_hash`/`license_hash`). Returns the raw 32 bytes (`Uint8Array`).
125
+ */
126
+ export function sha256(bytes: Uint8Array): Uint8Array;
127
+
128
+ /**
129
+ * Serialize a spend bundle (`{coinSpends, aggregatedSignature}`) to its hex wire encoding
130
+ * (see [`chip35_dl_coin::spend_bundle_to_hex`]).
131
+ */
64
132
  export function spendBundleToHex(spend_bundle: any): string;
65
133
 
134
+ /**
135
+ * Update a store's metadata (see [`chip35_dl_coin::update_store_metadata`]). Exactly one of
136
+ * `owner_public_key`, `admin_public_key`, `writer_public_key` must be provided — it selects the
137
+ * authorizing role. Returns a `SuccessResponse`.
138
+ */
66
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;
67
140
 
141
+ /**
142
+ * Transfer ownership and/or replace the delegated-puzzle set (see
143
+ * [`chip35_dl_coin::update_store_ownership`]). Omitting `new_owner_puzzle_hash` keeps the
144
+ * current owner. Exactly one of `owner_public_key`/`admin_public_key` must be provided. Returns
145
+ * a `SuccessResponse`.
146
+ */
68
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;
148
+
149
+ /**
150
+ * Validate a CHIP-0007 document's schema, and (when the actual bytes are provided) that each
151
+ * on-chain hash matches `sha256(bytes)` — the URI↔hash agreement check (#36). `assets` is
152
+ * `{ dataBytes?, dataHash?, metadataBytes?, metadataHash?, licenseBytes?, licenseHash? }` (all
153
+ * `Uint8Array`). Returns `{ ok: bool, errors: string[] }`.
154
+ */
155
+ export function validateChip0007(metadata: any, assets: any): any;
156
+
157
+ /**
158
+ * Build the **Writer** delegated puzzle for a 48-byte synthetic public key — a revocable deploy
159
+ * token (#17) or a hub Teams writer (#43). A writer may advance the root (deploy a new capsule)
160
+ * WITHOUT the owner seed, but may NOT change delegation or transfer ownership. Add it to a store
161
+ * to issue the token; replace the store's delegated set to revoke it. Returns a `DelegatedPuzzle`
162
+ * (`{ writerInnerPuzzleHash }`).
163
+ */
164
+ export function writerDelegatedPuzzleFromKey(synthetic_key: Uint8Array): any;
@@ -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, buildDigPayment, dataStoreFromSpend, digCatPuzzleHash, digTreasuryInnerPuzzleHash, digstoreOwnerHint, hexSpendBundleToCoinSpends, init, meltStore, mintStore, oracleSpend, spendBundleToHex, updateStoreMetadata, updateStoreOwnership
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
9
9
  } from "./chip35_dl_coin_wasm_bg.js";
@@ -1,4 +1,8 @@
1
1
  /**
2
+ * Build coin spends that reserve `fee` mojos from the spender's own coins while asserting
3
+ * concurrent spend of `assert_coin_ids` (see [`chip35_dl_coin::add_fee`]). Lets a fee-less
4
+ * singleton op (update/melt) carry a network fee. `selected_coins` is `Coin[]`,
5
+ * `assert_coin_ids` is `Uint8Array[]` of 32-byte coin ids. Returns `CoinSpend[]`.
2
6
  * @param {Uint8Array} spender_synthetic_key
3
7
  * @param {any} selected_coins
4
8
  * @param {any} assert_coin_ids
@@ -24,36 +28,98 @@ export function addFee(spender_synthetic_key, selected_coins, assert_coin_ids, f
24
28
  }
25
29
 
26
30
  /**
27
- * Build the (UNSIGNED) DIG CAT coin spends paying `amount` base units of DIG to the treasury
28
- * (100 DIG = 100000n to mint, 10 DIG = 10000n per update), returning change to the owner. The
29
- * app concatenates these with the singleton mint/update spends and has the wallet sign the WHOLE
30
- * bundle in ONE call — the single aggregated signature makes the store creation and the DIG
31
- * payment atomic (all-or-nothing in the mempool).
32
- *
33
- * `owner_synthetic_key` (48 bytes) is the wallet's synthetic public key — the SAME key used for
34
- * mintStore (the CAT inner puzzle is its standard puzzle). `owner_puzzle_hash` (32) is that key's
35
- * standard puzzle hash. `parent_spends` are the spends that created the candidate DIG coins (wasm
36
- * CoinSpend shape), and `child_coin_ids` (Uint8Array[] of 32 bytes) are those coins' ids in the
37
- * SAME order — each parent spend is parsed to reconstruct its DIG child's lineage proof.
38
- * `store_id` (32) is the launcher id, carried as a memo. Returns CoinSpend[] (UNSIGNED).
39
- * @param {Uint8Array} owner_synthetic_key
40
- * @param {Uint8Array} owner_puzzle_hash
41
- * @param {any} parent_spends
42
- * @param {any} child_coin_ids
43
- * @param {bigint} amount
44
- * @param {Uint8Array} store_id
31
+ * Build the **Admin** delegated puzzle for a 48-byte synthetic public key (a hub Teams admin).
32
+ * An admin may update the store AND change delegation (add/remove writers i.e. revoke a deploy
33
+ * token), but cannot transfer ownership. Returns a `DelegatedPuzzle` (`{ adminInnerPuzzleHash }`).
34
+ * @param {Uint8Array} synthetic_key
35
+ * @returns {any}
36
+ */
37
+ export function adminDelegatedPuzzleFromKey(synthetic_key) {
38
+ try {
39
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
40
+ const ptr0 = passArray8ToWasm0(synthetic_key, wasm.__wbindgen_export);
41
+ const len0 = WASM_VECTOR_LEN;
42
+ wasm.adminDelegatedPuzzleFromKey(retptr, ptr0, len0);
43
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
44
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
45
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
46
+ if (r2) {
47
+ throw takeObject(r1);
48
+ }
49
+ return takeObject(r0);
50
+ } finally {
51
+ wasm.__wbindgen_add_to_stack_pointer(16);
52
+ }
53
+ }
54
+
55
+ /**
56
+ * Build a CHIP-0007 metadata document from a JS object and return its canonical JSON + the
57
+ * `metadata_hash` (sha256 of that JSON). De-dupes the hand-computed badge metadata: callers stop
58
+ * hand-rolling SHA-256. Returns `{ json: string, metadataHash: Uint8Array }`. Validates schema.
59
+ * @param {any} metadata
60
+ * @returns {any}
61
+ */
62
+ export function buildChip0007Metadata(metadata) {
63
+ try {
64
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
65
+ wasm.buildChip0007Metadata(retptr, addHeapObject(metadata));
66
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
67
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
68
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
69
+ if (r2) {
70
+ throw takeObject(r1);
71
+ }
72
+ return takeObject(r0);
73
+ } finally {
74
+ wasm.__wbindgen_add_to_stack_pointer(16);
75
+ }
76
+ }
77
+
78
+ /**
79
+ * Bulk-mint every item in a parsed traits manifest into a collection, attributed to a DID (#34).
80
+ * `did` is the DID coin + identifiers `{ launcherId, innerPuzzleHash, didCoin }` (e.g. from a prior
81
+ * `createDid`, fetched on-chain). Returns `{ coinSpends, launcherIds }`.
82
+ * @param {Uint8Array} minter_synthetic_key
83
+ * @param {any} did
84
+ * @param {any} collection
85
+ * @param {any} items
86
+ * @param {Uint8Array} recipient_puzzle_hash
45
87
  * @returns {any}
46
88
  */
47
- export function buildDigPayment(owner_synthetic_key, owner_puzzle_hash, parent_spends, child_coin_ids, amount, store_id) {
89
+ export function bulkMint(minter_synthetic_key, did, collection, items, recipient_puzzle_hash) {
48
90
  try {
49
91
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
50
- const ptr0 = passArray8ToWasm0(owner_synthetic_key, wasm.__wbindgen_export);
92
+ const ptr0 = passArray8ToWasm0(minter_synthetic_key, wasm.__wbindgen_export);
51
93
  const len0 = WASM_VECTOR_LEN;
52
- const ptr1 = passArray8ToWasm0(owner_puzzle_hash, wasm.__wbindgen_export);
94
+ const ptr1 = passArray8ToWasm0(recipient_puzzle_hash, wasm.__wbindgen_export);
53
95
  const len1 = WASM_VECTOR_LEN;
54
- const ptr2 = passArray8ToWasm0(store_id, wasm.__wbindgen_export);
55
- const len2 = WASM_VECTOR_LEN;
56
- wasm.buildDigPayment(retptr, ptr0, len0, ptr1, len1, addHeapObject(parent_spends), addHeapObject(child_coin_ids), amount, ptr2, len2);
96
+ wasm.bulkMint(retptr, ptr0, len0, addHeapObject(did), addHeapObject(collection), addHeapObject(items), ptr1, len1);
97
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
98
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
99
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
100
+ if (r2) {
101
+ throw takeObject(r1);
102
+ }
103
+ return takeObject(r0);
104
+ } finally {
105
+ wasm.__wbindgen_add_to_stack_pointer(16);
106
+ }
107
+ }
108
+
109
+ /**
110
+ * Create a DID (creator identity) singleton. Returns
111
+ * `{ coinSpends, launcherId, innerPuzzleHash, didCoin }`.
112
+ * @param {Uint8Array} minter_synthetic_key
113
+ * @param {any} selected_coins
114
+ * @param {bigint} fee
115
+ * @returns {any}
116
+ */
117
+ export function createDid(minter_synthetic_key, selected_coins, fee) {
118
+ try {
119
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
120
+ const ptr0 = passArray8ToWasm0(minter_synthetic_key, wasm.__wbindgen_export);
121
+ const len0 = WASM_VECTOR_LEN;
122
+ wasm.createDid(retptr, ptr0, len0, addHeapObject(selected_coins), fee);
57
123
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
58
124
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
59
125
  var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
@@ -93,17 +159,41 @@ export function dataStoreFromSpend(coin_spend, prev_delegated_puzzles) {
93
159
  }
94
160
 
95
161
  /**
96
- * The DIG CAT outer puzzle hash for a 32-byte owner puzzle hash — where the wallet's DIG
97
- * coins live on-chain. The app uses it to read DIG balance + select DIG coins. 32 bytes.
162
+ * Decode canonical offer text into its spend bundle `{ coinSpends, aggregatedSignature }`.
163
+ * @param {string} text
164
+ * @returns {any}
165
+ */
166
+ export function decodeOffer(text) {
167
+ try {
168
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
169
+ const ptr0 = passStringToWasm0(text, wasm.__wbindgen_export, wasm.__wbindgen_export2);
170
+ const len0 = WASM_VECTOR_LEN;
171
+ wasm.decodeOffer(retptr, ptr0, len0);
172
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
173
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
174
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
175
+ if (r2) {
176
+ throw takeObject(r1);
177
+ }
178
+ return takeObject(r0);
179
+ } finally {
180
+ wasm.__wbindgen_add_to_stack_pointer(16);
181
+ }
182
+ }
183
+
184
+ /**
185
+ * Derive the digstore-scoped owner discovery hint for a 32-byte owner puzzle hash. The app
186
+ * computes the SAME hint to enumerate the wallet's stores via coinset
187
+ * get_coin_records_by_hint — it MUST match the hint mint_store emits. Returns 32 bytes.
98
188
  * @param {Uint8Array} owner_puzzle_hash
99
189
  * @returns {Uint8Array}
100
190
  */
101
- export function digCatPuzzleHash(owner_puzzle_hash) {
191
+ export function digstoreOwnerHint(owner_puzzle_hash) {
102
192
  try {
103
193
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
104
194
  const ptr0 = passArray8ToWasm0(owner_puzzle_hash, wasm.__wbindgen_export);
105
195
  const len0 = WASM_VECTOR_LEN;
106
- wasm.digCatPuzzleHash(retptr, ptr0, len0);
196
+ wasm.digstoreOwnerHint(retptr, ptr0, len0);
107
197
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
108
198
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
109
199
  var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
@@ -120,53 +210,62 @@ export function digCatPuzzleHash(owner_puzzle_hash) {
120
210
  }
121
211
 
122
212
  /**
123
- * The DIG treasury inner (standard) puzzle hash the fixed recipient of every DIG payment.
124
- * Returned so the app can pin it as a golden constant. 32 bytes.
125
- * @returns {Uint8Array}
213
+ * Encode a spend bundle (`{coinSpends, aggregatedSignature}`) into canonical offer text.
214
+ * @param {any} spend_bundle
215
+ * @returns {string}
126
216
  */
127
- export function digTreasuryInnerPuzzleHash() {
217
+ export function encodeOffer(spend_bundle) {
218
+ let deferred2_0;
219
+ let deferred2_1;
128
220
  try {
129
221
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
130
- wasm.digTreasuryInnerPuzzleHash(retptr);
222
+ wasm.encodeOffer(retptr, addHeapObject(spend_bundle));
131
223
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
132
224
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
133
- var v1 = getArrayU8FromWasm0(r0, r1).slice();
134
- wasm.__wbindgen_export4(r0, r1 * 1, 1);
135
- return v1;
225
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
226
+ var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
227
+ var ptr1 = r0;
228
+ var len1 = r1;
229
+ if (r3) {
230
+ ptr1 = 0; len1 = 0;
231
+ throw takeObject(r2);
232
+ }
233
+ deferred2_0 = ptr1;
234
+ deferred2_1 = len1;
235
+ return getStringFromWasm0(ptr1, len1);
136
236
  } finally {
137
237
  wasm.__wbindgen_add_to_stack_pointer(16);
238
+ wasm.__wbindgen_export4(deferred2_0, deferred2_1, 1);
138
239
  }
139
240
  }
140
241
 
141
242
  /**
142
- * Derive the digstore-scoped owner discovery hint for a 32-byte owner puzzle hash. The app
143
- * computes the SAME hint to enumerate the wallet's stores via coinset
144
- * get_coin_records_by_hint it MUST match the hint mint_store emits. Returns 32 bytes.
145
- * @param {Uint8Array} owner_puzzle_hash
146
- * @returns {Uint8Array}
243
+ * Generate per-item CHIP-0007 metadata documents for a collection from a parsed traits manifest
244
+ * (#34). `collection` is `Collection`; `items` is `ManifestItem[]`. Returns
245
+ * `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}
147
249
  */
148
- export function digstoreOwnerHint(owner_puzzle_hash) {
250
+ export function generateItemMetadata(collection, items) {
149
251
  try {
150
252
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
151
- const ptr0 = passArray8ToWasm0(owner_puzzle_hash, wasm.__wbindgen_export);
152
- const len0 = WASM_VECTOR_LEN;
153
- wasm.digstoreOwnerHint(retptr, ptr0, len0);
253
+ wasm.generateItemMetadata(retptr, addHeapObject(collection), addHeapObject(items));
154
254
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
155
255
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
156
256
  var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
157
- var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
158
- if (r3) {
159
- throw takeObject(r2);
257
+ if (r2) {
258
+ throw takeObject(r1);
160
259
  }
161
- var v2 = getArrayU8FromWasm0(r0, r1).slice();
162
- wasm.__wbindgen_export4(r0, r1 * 1, 1);
163
- return v2;
260
+ return takeObject(r0);
164
261
  } finally {
165
262
  wasm.__wbindgen_add_to_stack_pointer(16);
166
263
  }
167
264
  }
168
265
 
169
266
  /**
267
+ * Decode a hex-encoded spend bundle into its `CoinSpend[]` (see
268
+ * [`chip35_dl_coin::hex_spend_bundle_to_coin_spends`]).
170
269
  * @param {string} hex
171
270
  * @returns {any}
172
271
  */
@@ -197,6 +296,34 @@ export function init() {
197
296
  }
198
297
 
199
298
  /**
299
+ * Issue a single-issuance (fixed-supply) CAT. Returns `{ coinSpends, assetId, catCoins }`.
300
+ * @param {Uint8Array} issuer_synthetic_key
301
+ * @param {any} selected_coins
302
+ * @param {bigint} amount
303
+ * @param {bigint} fee
304
+ * @returns {any}
305
+ */
306
+ export function issueCat(issuer_synthetic_key, selected_coins, amount, fee) {
307
+ try {
308
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
309
+ const ptr0 = passArray8ToWasm0(issuer_synthetic_key, wasm.__wbindgen_export);
310
+ const len0 = WASM_VECTOR_LEN;
311
+ wasm.issueCat(retptr, ptr0, len0, addHeapObject(selected_coins), amount, fee);
312
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
313
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
314
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
315
+ if (r2) {
316
+ throw takeObject(r1);
317
+ }
318
+ return takeObject(r0);
319
+ } finally {
320
+ wasm.__wbindgen_add_to_stack_pointer(16);
321
+ }
322
+ }
323
+
324
+ /**
325
+ * Burn (melt) a store singleton (see [`chip35_dl_coin::melt_store`]). Owner-authorized only.
326
+ * Returns the melt `CoinSpend[]`.
200
327
  * @param {any} store
201
328
  * @param {Uint8Array} owner_public_key
202
329
  * @returns {any}
@@ -220,6 +347,37 @@ export function meltStore(store, owner_public_key) {
220
347
  }
221
348
 
222
349
  /**
350
+ * Mint a single NFT whose media lives in a DIG capsule (`dig://` URN + https gateway fallback URIs,
351
+ * hashes computed from real bytes). `params` is `NftMintParams`. Returns
352
+ * `{ coinSpends, launcherId, nftCoin }`.
353
+ * @param {Uint8Array} minter_synthetic_key
354
+ * @param {any} selected_coins
355
+ * @param {any} params
356
+ * @param {bigint} fee
357
+ * @returns {any}
358
+ */
359
+ export function mintNft(minter_synthetic_key, selected_coins, params, fee) {
360
+ try {
361
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
362
+ const ptr0 = passArray8ToWasm0(minter_synthetic_key, wasm.__wbindgen_export);
363
+ const len0 = WASM_VECTOR_LEN;
364
+ wasm.mintNft(retptr, ptr0, len0, addHeapObject(selected_coins), addHeapObject(params), fee);
365
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
366
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
367
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
368
+ if (r2) {
369
+ throw takeObject(r1);
370
+ }
371
+ return takeObject(r0);
372
+ } finally {
373
+ wasm.__wbindgen_add_to_stack_pointer(16);
374
+ }
375
+ }
376
+
377
+ /**
378
+ * Build the spend bundle that launches a new DataLayer store singleton (see
379
+ * [`chip35_dl_coin::mint_store`]). `program_hash` is an optional 32-byte size-proof; the rest of
380
+ * the JS values mirror the core builder. Returns a `SuccessResponse` (`coinSpends` + `newStore`).
223
381
  * @param {Uint8Array} minter_synthetic_key
224
382
  * @param {any} selected_coins
225
383
  * @param {Uint8Array} root_hash
@@ -261,6 +419,34 @@ export function mintStore(minter_synthetic_key, selected_coins, root_hash, label
261
419
  }
262
420
 
263
421
  /**
422
+ * Build the **Oracle** delegated puzzle: anyone may spend the store for the fixed `oracle_fee`
423
+ * (mojos) paid to the 32-byte `oracle_puzzle_hash`. Returns a `DelegatedPuzzle`
424
+ * (`{ oraclePaymentPuzzleHash, oracleFee }`).
425
+ * @param {Uint8Array} oracle_puzzle_hash
426
+ * @param {bigint} oracle_fee
427
+ * @returns {any}
428
+ */
429
+ export function oracleDelegatedPuzzle(oracle_puzzle_hash, oracle_fee) {
430
+ try {
431
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
432
+ const ptr0 = passArray8ToWasm0(oracle_puzzle_hash, wasm.__wbindgen_export);
433
+ const len0 = WASM_VECTOR_LEN;
434
+ wasm.oracleDelegatedPuzzle(retptr, ptr0, len0, oracle_fee);
435
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
436
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
437
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
438
+ if (r2) {
439
+ throw takeObject(r1);
440
+ }
441
+ return takeObject(r0);
442
+ } finally {
443
+ wasm.__wbindgen_add_to_stack_pointer(16);
444
+ }
445
+ }
446
+
447
+ /**
448
+ * Exercise a store's oracle delegated puzzle (see [`chip35_dl_coin::oracle_spend`]). The spender
449
+ * pays the oracle fee plus `fee` from `selected_coins`. Returns a `SuccessResponse`.
264
450
  * @param {Uint8Array} spender_synthetic_key
265
451
  * @param {any} selected_coins
266
452
  * @param {any} store
@@ -286,6 +472,30 @@ export function oracleSpend(spender_synthetic_key, selected_coins, store, fee) {
286
472
  }
287
473
 
288
474
  /**
475
+ * SHA-256 of arbitrary bytes → 32-byte hash (the one true primitive for `data_hash`/
476
+ * `metadata_hash`/`license_hash`). Returns the raw 32 bytes (`Uint8Array`).
477
+ * @param {Uint8Array} bytes
478
+ * @returns {Uint8Array}
479
+ */
480
+ export function sha256(bytes) {
481
+ try {
482
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
483
+ const ptr0 = passArray8ToWasm0(bytes, wasm.__wbindgen_export);
484
+ const len0 = WASM_VECTOR_LEN;
485
+ wasm.sha256(retptr, ptr0, len0);
486
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
487
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
488
+ var v2 = getArrayU8FromWasm0(r0, r1).slice();
489
+ wasm.__wbindgen_export4(r0, r1 * 1, 1);
490
+ return v2;
491
+ } finally {
492
+ wasm.__wbindgen_add_to_stack_pointer(16);
493
+ }
494
+ }
495
+
496
+ /**
497
+ * Serialize a spend bundle (`{coinSpends, aggregatedSignature}`) to its hex wire encoding
498
+ * (see [`chip35_dl_coin::spend_bundle_to_hex`]).
289
499
  * @param {any} spend_bundle
290
500
  * @returns {string}
291
501
  */
@@ -315,6 +525,9 @@ export function spendBundleToHex(spend_bundle) {
315
525
  }
316
526
 
317
527
  /**
528
+ * Update a store's metadata (see [`chip35_dl_coin::update_store_metadata`]). Exactly one of
529
+ * `owner_public_key`, `admin_public_key`, `writer_public_key` must be provided — it selects the
530
+ * authorizing role. Returns a `SuccessResponse`.
318
531
  * @param {any} store
319
532
  * @param {Uint8Array} new_root_hash
320
533
  * @param {string | null} [new_label]
@@ -357,6 +570,10 @@ export function updateStoreMetadata(store, new_root_hash, new_label, new_descrip
357
570
  }
358
571
 
359
572
  /**
573
+ * Transfer ownership and/or replace the delegated-puzzle set (see
574
+ * [`chip35_dl_coin::update_store_ownership`]). Omitting `new_owner_puzzle_hash` keeps the
575
+ * current owner. Exactly one of `owner_public_key`/`admin_public_key` must be provided. Returns
576
+ * a `SuccessResponse`.
360
577
  * @param {any} store
361
578
  * @param {Uint8Array | null | undefined} new_owner_puzzle_hash
362
579
  * @param {any} new_delegated_puzzles
@@ -385,6 +602,58 @@ export function updateStoreOwnership(store, new_owner_puzzle_hash, new_delegated
385
602
  wasm.__wbindgen_add_to_stack_pointer(16);
386
603
  }
387
604
  }
605
+
606
+ /**
607
+ * Validate a CHIP-0007 document's schema, and (when the actual bytes are provided) that each
608
+ * on-chain hash matches `sha256(bytes)` — the URI↔hash agreement check (#36). `assets` is
609
+ * `{ dataBytes?, dataHash?, metadataBytes?, metadataHash?, licenseBytes?, licenseHash? }` (all
610
+ * `Uint8Array`). Returns `{ ok: bool, errors: string[] }`.
611
+ * @param {any} metadata
612
+ * @param {any} assets
613
+ * @returns {any}
614
+ */
615
+ export function validateChip0007(metadata, assets) {
616
+ try {
617
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
618
+ wasm.validateChip0007(retptr, addHeapObject(metadata), addHeapObject(assets));
619
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
620
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
621
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
622
+ if (r2) {
623
+ throw takeObject(r1);
624
+ }
625
+ return takeObject(r0);
626
+ } finally {
627
+ wasm.__wbindgen_add_to_stack_pointer(16);
628
+ }
629
+ }
630
+
631
+ /**
632
+ * Build the **Writer** delegated puzzle for a 48-byte synthetic public key — a revocable deploy
633
+ * token (#17) or a hub Teams writer (#43). A writer may advance the root (deploy a new capsule)
634
+ * WITHOUT the owner seed, but may NOT change delegation or transfer ownership. Add it to a store
635
+ * to issue the token; replace the store's delegated set to revoke it. Returns a `DelegatedPuzzle`
636
+ * (`{ writerInnerPuzzleHash }`).
637
+ * @param {Uint8Array} synthetic_key
638
+ * @returns {any}
639
+ */
640
+ export function writerDelegatedPuzzleFromKey(synthetic_key) {
641
+ try {
642
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
643
+ const ptr0 = passArray8ToWasm0(synthetic_key, wasm.__wbindgen_export);
644
+ const len0 = WASM_VECTOR_LEN;
645
+ wasm.writerDelegatedPuzzleFromKey(retptr, ptr0, len0);
646
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
647
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
648
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
649
+ if (r2) {
650
+ throw takeObject(r1);
651
+ }
652
+ return takeObject(r0);
653
+ } finally {
654
+ wasm.__wbindgen_add_to_stack_pointer(16);
655
+ }
656
+ }
388
657
  export function __wbg_Error_ef53bc310eb298a0(arg0, arg1) {
389
658
  const ret = Error(getStringFromWasm0(arg0, arg1));
390
659
  return addHeapObject(ret);
@@ -430,15 +699,15 @@ export function __wbg___wbindgen_is_function_754e9f305ff6029e(arg0) {
430
699
  const ret = typeof(getObject(arg0)) === 'function';
431
700
  return ret;
432
701
  }
702
+ export function __wbg___wbindgen_is_null_87c3bfe968c6a5ad(arg0) {
703
+ const ret = getObject(arg0) === null;
704
+ return ret;
705
+ }
433
706
  export function __wbg___wbindgen_is_object_56732c2bc353f41d(arg0) {
434
707
  const val = getObject(arg0);
435
708
  const ret = typeof(val) === 'object' && val !== null;
436
709
  return ret;
437
710
  }
438
- export function __wbg___wbindgen_is_string_c236cabd84a4d769(arg0) {
439
- const ret = typeof(getObject(arg0)) === 'string';
440
- return ret;
441
- }
442
711
  export function __wbg___wbindgen_is_undefined_67b456be8673d3d7(arg0) {
443
712
  const ret = getObject(arg0) === undefined;
444
713
  return ret;
@@ -472,14 +741,6 @@ export function __wbg_call_8a89609d89f6608a() { return handleError(function (arg
472
741
  const ret = getObject(arg0).call(getObject(arg1));
473
742
  return addHeapObject(ret);
474
743
  }, arguments); }
475
- export function __wbg_call_9c758de292015997() { return handleError(function (arg0, arg1, arg2) {
476
- const ret = getObject(arg0).call(getObject(arg1), getObject(arg2));
477
- return addHeapObject(ret);
478
- }, arguments); }
479
- export function __wbg_crypto_38df2bab126b63dc(arg0) {
480
- const ret = getObject(arg0).crypto;
481
- return addHeapObject(ret);
482
- }
483
744
  export function __wbg_done_60cf307fcc680536(arg0) {
484
745
  const ret = getObject(arg0).done;
485
746
  return ret;
@@ -499,9 +760,6 @@ export function __wbg_from_d300fe49deab18f5(arg0) {
499
760
  const ret = Array.from(getObject(arg0));
500
761
  return addHeapObject(ret);
501
762
  }
502
- export function __wbg_getRandomValues_c44a50d8cfdaebeb() { return handleError(function (arg0, arg1) {
503
- getObject(arg0).getRandomValues(getObject(arg1));
504
- }, arguments); }
505
763
  export function __wbg_get_1f8f054ddbaa7db2() { return handleError(function (arg0, arg1) {
506
764
  const ret = Reflect.get(getObject(arg0), getObject(arg1));
507
765
  return addHeapObject(ret);
@@ -554,10 +812,6 @@ export function __wbg_length_66f1a4b2e9026940(arg0) {
554
812
  const ret = getObject(arg0).length;
555
813
  return ret;
556
814
  }
557
- export function __wbg_msCrypto_bd5a034af96bcba6(arg0) {
558
- const ret = getObject(arg0).msCrypto;
559
- return addHeapObject(ret);
560
- }
561
815
  export function __wbg_new_227d7c05414eb861() {
562
816
  const ret = new Error();
563
817
  return addHeapObject(ret);
@@ -574,10 +828,6 @@ export function __wbg_new_d90091b82fdf5b91() {
574
828
  const ret = new Array();
575
829
  return addHeapObject(ret);
576
830
  }
577
- export function __wbg_new_with_length_36a4998e27b014c5(arg0) {
578
- const ret = new Uint8Array(arg0 >>> 0);
579
- return addHeapObject(ret);
580
- }
581
831
  export function __wbg_next_9e03acdf51c4960d(arg0) {
582
832
  const ret = getObject(arg0).next;
583
833
  return addHeapObject(ret);
@@ -586,24 +836,9 @@ export function __wbg_next_eb8ca7351fa27906() { return handleError(function (arg
586
836
  const ret = getObject(arg0).next();
587
837
  return addHeapObject(ret);
588
838
  }, arguments); }
589
- export function __wbg_node_84ea875411254db1(arg0) {
590
- const ret = getObject(arg0).node;
591
- return addHeapObject(ret);
592
- }
593
- export function __wbg_process_44c7a14e11e9f69e(arg0) {
594
- const ret = getObject(arg0).process;
595
- return addHeapObject(ret);
596
- }
597
839
  export function __wbg_prototypesetcall_3249fc62a0fafa30(arg0, arg1, arg2) {
598
840
  Uint8Array.prototype.set.call(getArrayU8FromWasm0(arg0, arg1), getObject(arg2));
599
841
  }
600
- export function __wbg_randomFillSync_6c25eac9869eb53c() { return handleError(function (arg0, arg1) {
601
- getObject(arg0).randomFillSync(takeObject(arg1));
602
- }, arguments); }
603
- export function __wbg_require_b4edbdcf3e2a1ef0() { return handleError(function () {
604
- const ret = module.require;
605
- return addHeapObject(ret);
606
- }, arguments); }
607
842
  export function __wbg_set_6be42768c690e380(arg0, arg1, arg2) {
608
843
  getObject(arg0)[takeObject(arg1)] = takeObject(arg2);
609
844
  }
@@ -617,34 +852,10 @@ export function __wbg_stack_3b0d974bbf31e44f(arg0, arg1) {
617
852
  getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
618
853
  getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
619
854
  }
620
- export function __wbg_static_accessor_GLOBAL_9d53f2689e622ca1() {
621
- const ret = typeof global === 'undefined' ? null : global;
622
- return isLikeNone(ret) ? 0 : addHeapObject(ret);
623
- }
624
- export function __wbg_static_accessor_GLOBAL_THIS_a1a35cec07001a8a() {
625
- const ret = typeof globalThis === 'undefined' ? null : globalThis;
626
- return isLikeNone(ret) ? 0 : addHeapObject(ret);
627
- }
628
- export function __wbg_static_accessor_SELF_4c59f6c7ea29a144() {
629
- const ret = typeof self === 'undefined' ? null : self;
630
- return isLikeNone(ret) ? 0 : addHeapObject(ret);
631
- }
632
- export function __wbg_static_accessor_WINDOW_e70ae9f2eb052253() {
633
- const ret = typeof window === 'undefined' ? null : window;
634
- return isLikeNone(ret) ? 0 : addHeapObject(ret);
635
- }
636
- export function __wbg_subarray_4aa221f6a4f5ab22(arg0, arg1, arg2) {
637
- const ret = getObject(arg0).subarray(arg1 >>> 0, arg2 >>> 0);
638
- return addHeapObject(ret);
639
- }
640
855
  export function __wbg_value_f3625092ee4b37f4(arg0) {
641
856
  const ret = getObject(arg0).value;
642
857
  return addHeapObject(ret);
643
858
  }
644
- export function __wbg_versions_276b2795b1c6a219(arg0) {
645
- const ret = getObject(arg0).versions;
646
- return addHeapObject(ret);
647
- }
648
859
  export function __wbindgen_cast_0000000000000001(arg0) {
649
860
  // Cast intrinsic for `F64 -> Externref`.
650
861
  const ret = arg0;
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.4.0",
5
+ "version": "0.6.0",
6
6
  "license": "MIT",
7
7
  "repository": {
8
8
  "type": "git",