@dignetwork/chip35-dl-coin-wasm 0.3.0 → 0.5.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.
- package/chip35_dl_coin_wasm.d.ts +101 -0
- package/chip35_dl_coin_wasm.js +1 -1
- package/chip35_dl_coin_wasm_bg.js +284 -0
- package/chip35_dl_coin_wasm_bg.wasm +0 -0
- package/package.json +5 -5
package/chip35_dl_coin_wasm.d.ts
CHANGED
|
@@ -1,8 +1,34 @@
|
|
|
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
|
|
|
12
|
+
/**
|
|
13
|
+
* Build a CHIP-0007 metadata document from a JS object and return its canonical JSON + the
|
|
14
|
+
* `metadata_hash` (sha256 of that JSON). De-dupes the hand-computed badge metadata: callers stop
|
|
15
|
+
* hand-rolling SHA-256. Returns `{ json: string, metadataHash: Uint8Array }`. Validates schema.
|
|
16
|
+
*/
|
|
17
|
+
export function buildChip0007Metadata(metadata: any): any;
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Bulk-mint every item in a parsed traits manifest into a collection, attributed to a DID (#34).
|
|
21
|
+
* `did` is the DID coin + identifiers `{ launcherId, innerPuzzleHash, didCoin }` (e.g. from a prior
|
|
22
|
+
* `createDid`, fetched on-chain). Returns `{ coinSpends, launcherIds }`.
|
|
23
|
+
*/
|
|
24
|
+
export function bulkMint(minter_synthetic_key: Uint8Array, did: any, collection: any, items: any, recipient_puzzle_hash: Uint8Array): any;
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Create a DID (creator identity) singleton. Returns
|
|
28
|
+
* `{ coinSpends, launcherId, innerPuzzleHash, didCoin }`.
|
|
29
|
+
*/
|
|
30
|
+
export function createDid(minter_synthetic_key: Uint8Array, selected_coins: any, fee: bigint): any;
|
|
31
|
+
|
|
6
32
|
/**
|
|
7
33
|
* Reconstruct a DataStore from the coin spend that created its current coin (the launcher
|
|
8
34
|
* spend for an eve store). Lets the app MELT a store it did not mint in-session: fetch the
|
|
@@ -12,6 +38,11 @@ export function addFee(spender_synthetic_key: Uint8Array, selected_coins: any, a
|
|
|
12
38
|
*/
|
|
13
39
|
export function dataStoreFromSpend(coin_spend: any, prev_delegated_puzzles: any): any;
|
|
14
40
|
|
|
41
|
+
/**
|
|
42
|
+
* Decode canonical offer text into its spend bundle `{ coinSpends, aggregatedSignature }`.
|
|
43
|
+
*/
|
|
44
|
+
export function decodeOffer(text: string): any;
|
|
45
|
+
|
|
15
46
|
/**
|
|
16
47
|
* Derive the digstore-scoped owner discovery hint for a 32-byte owner puzzle hash. The app
|
|
17
48
|
* computes the SAME hint to enumerate the wallet's stores via coinset
|
|
@@ -19,6 +50,22 @@ export function dataStoreFromSpend(coin_spend: any, prev_delegated_puzzles: any)
|
|
|
19
50
|
*/
|
|
20
51
|
export function digstoreOwnerHint(owner_puzzle_hash: Uint8Array): Uint8Array;
|
|
21
52
|
|
|
53
|
+
/**
|
|
54
|
+
* Encode a spend bundle (`{coinSpends, aggregatedSignature}`) into canonical offer text.
|
|
55
|
+
*/
|
|
56
|
+
export function encodeOffer(spend_bundle: any): string;
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* Generate per-item CHIP-0007 metadata documents for a collection from a parsed traits manifest
|
|
60
|
+
* (#34). `collection` is `Collection`; `items` is `ManifestItem[]`. Returns
|
|
61
|
+
* `Chip0007Metadata[]` (the off-chain JSON docs; the caller hashes + writes them into each capsule).
|
|
62
|
+
*/
|
|
63
|
+
export function generateItemMetadata(collection: any, items: any): any;
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* Decode a hex-encoded spend bundle into its `CoinSpend[]` (see
|
|
67
|
+
* [`chip35_dl_coin::hex_spend_bundle_to_coin_spends`]).
|
|
68
|
+
*/
|
|
22
69
|
export function hexSpendBundleToCoinSpends(hex: string): any;
|
|
23
70
|
|
|
24
71
|
/**
|
|
@@ -27,14 +74,68 @@ export function hexSpendBundleToCoinSpends(hex: string): any;
|
|
|
27
74
|
*/
|
|
28
75
|
export function init(): void;
|
|
29
76
|
|
|
77
|
+
/**
|
|
78
|
+
* Issue a single-issuance (fixed-supply) CAT. Returns `{ coinSpends, assetId, catCoins }`.
|
|
79
|
+
*/
|
|
80
|
+
export function issueCat(issuer_synthetic_key: Uint8Array, selected_coins: any, amount: bigint, fee: bigint): any;
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* Burn (melt) a store singleton (see [`chip35_dl_coin::melt_store`]). Owner-authorized only.
|
|
84
|
+
* Returns the melt `CoinSpend[]`.
|
|
85
|
+
*/
|
|
30
86
|
export function meltStore(store: any, owner_public_key: Uint8Array): any;
|
|
31
87
|
|
|
88
|
+
/**
|
|
89
|
+
* Mint a single NFT whose media lives in a DIG capsule (`dig://` URN + https gateway fallback URIs,
|
|
90
|
+
* hashes computed from real bytes). `params` is `NftMintParams`. Returns
|
|
91
|
+
* `{ coinSpends, launcherId, nftCoin }`.
|
|
92
|
+
*/
|
|
93
|
+
export function mintNft(minter_synthetic_key: Uint8Array, selected_coins: any, params: any, fee: bigint): any;
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* Build the spend bundle that launches a new DataLayer store singleton (see
|
|
97
|
+
* [`chip35_dl_coin::mint_store`]). `program_hash` is an optional 32-byte size-proof; the rest of
|
|
98
|
+
* the JS values mirror the core builder. Returns a `SuccessResponse` (`coinSpends` + `newStore`).
|
|
99
|
+
*/
|
|
32
100
|
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;
|
|
33
101
|
|
|
102
|
+
/**
|
|
103
|
+
* Exercise a store's oracle delegated puzzle (see [`chip35_dl_coin::oracle_spend`]). The spender
|
|
104
|
+
* pays the oracle fee plus `fee` from `selected_coins`. Returns a `SuccessResponse`.
|
|
105
|
+
*/
|
|
34
106
|
export function oracleSpend(spender_synthetic_key: Uint8Array, selected_coins: any, store: any, fee: bigint): any;
|
|
35
107
|
|
|
108
|
+
/**
|
|
109
|
+
* SHA-256 of arbitrary bytes → 32-byte hash (the one true primitive for `data_hash`/
|
|
110
|
+
* `metadata_hash`/`license_hash`). Returns the raw 32 bytes (`Uint8Array`).
|
|
111
|
+
*/
|
|
112
|
+
export function sha256(bytes: Uint8Array): Uint8Array;
|
|
113
|
+
|
|
114
|
+
/**
|
|
115
|
+
* Serialize a spend bundle (`{coinSpends, aggregatedSignature}`) to its hex wire encoding
|
|
116
|
+
* (see [`chip35_dl_coin::spend_bundle_to_hex`]).
|
|
117
|
+
*/
|
|
36
118
|
export function spendBundleToHex(spend_bundle: any): string;
|
|
37
119
|
|
|
120
|
+
/**
|
|
121
|
+
* Update a store's metadata (see [`chip35_dl_coin::update_store_metadata`]). Exactly one of
|
|
122
|
+
* `owner_public_key`, `admin_public_key`, `writer_public_key` must be provided — it selects the
|
|
123
|
+
* authorizing role. Returns a `SuccessResponse`.
|
|
124
|
+
*/
|
|
38
125
|
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;
|
|
39
126
|
|
|
127
|
+
/**
|
|
128
|
+
* Transfer ownership and/or replace the delegated-puzzle set (see
|
|
129
|
+
* [`chip35_dl_coin::update_store_ownership`]). Omitting `new_owner_puzzle_hash` keeps the
|
|
130
|
+
* current owner. Exactly one of `owner_public_key`/`admin_public_key` must be provided. Returns
|
|
131
|
+
* a `SuccessResponse`.
|
|
132
|
+
*/
|
|
40
133
|
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;
|
|
134
|
+
|
|
135
|
+
/**
|
|
136
|
+
* Validate a CHIP-0007 document's schema, and (when the actual bytes are provided) that each
|
|
137
|
+
* on-chain hash matches `sha256(bytes)` — the URI↔hash agreement check (#36). `assets` is
|
|
138
|
+
* `{ dataBytes?, dataHash?, metadataBytes?, metadataHash?, licenseBytes?, licenseHash? }` (all
|
|
139
|
+
* `Uint8Array`). Returns `{ ok: bool, errors: string[] }`.
|
|
140
|
+
*/
|
|
141
|
+
export function validateChip0007(metadata: any, assets: any): any;
|
package/chip35_dl_coin_wasm.js
CHANGED
|
@@ -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, dataStoreFromSpend, digstoreOwnerHint, hexSpendBundleToCoinSpends, init, meltStore, mintStore, oracleSpend, spendBundleToHex, updateStoreMetadata, updateStoreOwnership
|
|
8
|
+
addFee, buildChip0007Metadata, bulkMint, createDid, dataStoreFromSpend, decodeOffer, digstoreOwnerHint, encodeOffer, generateItemMetadata, hexSpendBundleToCoinSpends, init, issueCat, meltStore, mintNft, mintStore, oracleSpend, sha256, spendBundleToHex, updateStoreMetadata, updateStoreOwnership, validateChip0007
|
|
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
|
|
@@ -23,6 +27,86 @@ export function addFee(spender_synthetic_key, selected_coins, assert_coin_ids, f
|
|
|
23
27
|
}
|
|
24
28
|
}
|
|
25
29
|
|
|
30
|
+
/**
|
|
31
|
+
* Build a CHIP-0007 metadata document from a JS object and return its canonical JSON + the
|
|
32
|
+
* `metadata_hash` (sha256 of that JSON). De-dupes the hand-computed badge metadata: callers stop
|
|
33
|
+
* hand-rolling SHA-256. Returns `{ json: string, metadataHash: Uint8Array }`. Validates schema.
|
|
34
|
+
* @param {any} metadata
|
|
35
|
+
* @returns {any}
|
|
36
|
+
*/
|
|
37
|
+
export function buildChip0007Metadata(metadata) {
|
|
38
|
+
try {
|
|
39
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
40
|
+
wasm.buildChip0007Metadata(retptr, addHeapObject(metadata));
|
|
41
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
42
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
43
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
44
|
+
if (r2) {
|
|
45
|
+
throw takeObject(r1);
|
|
46
|
+
}
|
|
47
|
+
return takeObject(r0);
|
|
48
|
+
} finally {
|
|
49
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Bulk-mint every item in a parsed traits manifest into a collection, attributed to a DID (#34).
|
|
55
|
+
* `did` is the DID coin + identifiers `{ launcherId, innerPuzzleHash, didCoin }` (e.g. from a prior
|
|
56
|
+
* `createDid`, fetched on-chain). Returns `{ coinSpends, launcherIds }`.
|
|
57
|
+
* @param {Uint8Array} minter_synthetic_key
|
|
58
|
+
* @param {any} did
|
|
59
|
+
* @param {any} collection
|
|
60
|
+
* @param {any} items
|
|
61
|
+
* @param {Uint8Array} recipient_puzzle_hash
|
|
62
|
+
* @returns {any}
|
|
63
|
+
*/
|
|
64
|
+
export function bulkMint(minter_synthetic_key, did, collection, items, recipient_puzzle_hash) {
|
|
65
|
+
try {
|
|
66
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
67
|
+
const ptr0 = passArray8ToWasm0(minter_synthetic_key, wasm.__wbindgen_export);
|
|
68
|
+
const len0 = WASM_VECTOR_LEN;
|
|
69
|
+
const ptr1 = passArray8ToWasm0(recipient_puzzle_hash, wasm.__wbindgen_export);
|
|
70
|
+
const len1 = WASM_VECTOR_LEN;
|
|
71
|
+
wasm.bulkMint(retptr, ptr0, len0, addHeapObject(did), addHeapObject(collection), addHeapObject(items), ptr1, len1);
|
|
72
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
73
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
74
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
75
|
+
if (r2) {
|
|
76
|
+
throw takeObject(r1);
|
|
77
|
+
}
|
|
78
|
+
return takeObject(r0);
|
|
79
|
+
} finally {
|
|
80
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* Create a DID (creator identity) singleton. Returns
|
|
86
|
+
* `{ coinSpends, launcherId, innerPuzzleHash, didCoin }`.
|
|
87
|
+
* @param {Uint8Array} minter_synthetic_key
|
|
88
|
+
* @param {any} selected_coins
|
|
89
|
+
* @param {bigint} fee
|
|
90
|
+
* @returns {any}
|
|
91
|
+
*/
|
|
92
|
+
export function createDid(minter_synthetic_key, selected_coins, fee) {
|
|
93
|
+
try {
|
|
94
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
95
|
+
const ptr0 = passArray8ToWasm0(minter_synthetic_key, wasm.__wbindgen_export);
|
|
96
|
+
const len0 = WASM_VECTOR_LEN;
|
|
97
|
+
wasm.createDid(retptr, ptr0, len0, addHeapObject(selected_coins), fee);
|
|
98
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
99
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
100
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
101
|
+
if (r2) {
|
|
102
|
+
throw takeObject(r1);
|
|
103
|
+
}
|
|
104
|
+
return takeObject(r0);
|
|
105
|
+
} finally {
|
|
106
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
|
|
26
110
|
/**
|
|
27
111
|
* Reconstruct a DataStore from the coin spend that created its current coin (the launcher
|
|
28
112
|
* spend for an eve store). Lets the app MELT a store it did not mint in-session: fetch the
|
|
@@ -49,6 +133,29 @@ export function dataStoreFromSpend(coin_spend, prev_delegated_puzzles) {
|
|
|
49
133
|
}
|
|
50
134
|
}
|
|
51
135
|
|
|
136
|
+
/**
|
|
137
|
+
* Decode canonical offer text into its spend bundle `{ coinSpends, aggregatedSignature }`.
|
|
138
|
+
* @param {string} text
|
|
139
|
+
* @returns {any}
|
|
140
|
+
*/
|
|
141
|
+
export function decodeOffer(text) {
|
|
142
|
+
try {
|
|
143
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
144
|
+
const ptr0 = passStringToWasm0(text, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
145
|
+
const len0 = WASM_VECTOR_LEN;
|
|
146
|
+
wasm.decodeOffer(retptr, ptr0, len0);
|
|
147
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
148
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
149
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
150
|
+
if (r2) {
|
|
151
|
+
throw takeObject(r1);
|
|
152
|
+
}
|
|
153
|
+
return takeObject(r0);
|
|
154
|
+
} finally {
|
|
155
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
|
|
52
159
|
/**
|
|
53
160
|
* Derive the digstore-scoped owner discovery hint for a 32-byte owner puzzle hash. The app
|
|
54
161
|
* computes the SAME hint to enumerate the wallet's stores via coinset
|
|
@@ -78,6 +185,62 @@ export function digstoreOwnerHint(owner_puzzle_hash) {
|
|
|
78
185
|
}
|
|
79
186
|
|
|
80
187
|
/**
|
|
188
|
+
* Encode a spend bundle (`{coinSpends, aggregatedSignature}`) into canonical offer text.
|
|
189
|
+
* @param {any} spend_bundle
|
|
190
|
+
* @returns {string}
|
|
191
|
+
*/
|
|
192
|
+
export function encodeOffer(spend_bundle) {
|
|
193
|
+
let deferred2_0;
|
|
194
|
+
let deferred2_1;
|
|
195
|
+
try {
|
|
196
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
197
|
+
wasm.encodeOffer(retptr, addHeapObject(spend_bundle));
|
|
198
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
199
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
200
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
201
|
+
var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
|
|
202
|
+
var ptr1 = r0;
|
|
203
|
+
var len1 = r1;
|
|
204
|
+
if (r3) {
|
|
205
|
+
ptr1 = 0; len1 = 0;
|
|
206
|
+
throw takeObject(r2);
|
|
207
|
+
}
|
|
208
|
+
deferred2_0 = ptr1;
|
|
209
|
+
deferred2_1 = len1;
|
|
210
|
+
return getStringFromWasm0(ptr1, len1);
|
|
211
|
+
} finally {
|
|
212
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
213
|
+
wasm.__wbindgen_export4(deferred2_0, deferred2_1, 1);
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
/**
|
|
218
|
+
* Generate per-item CHIP-0007 metadata documents for a collection from a parsed traits manifest
|
|
219
|
+
* (#34). `collection` is `Collection`; `items` is `ManifestItem[]`. Returns
|
|
220
|
+
* `Chip0007Metadata[]` (the off-chain JSON docs; the caller hashes + writes them into each capsule).
|
|
221
|
+
* @param {any} collection
|
|
222
|
+
* @param {any} items
|
|
223
|
+
* @returns {any}
|
|
224
|
+
*/
|
|
225
|
+
export function generateItemMetadata(collection, items) {
|
|
226
|
+
try {
|
|
227
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
228
|
+
wasm.generateItemMetadata(retptr, addHeapObject(collection), addHeapObject(items));
|
|
229
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
230
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
231
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
232
|
+
if (r2) {
|
|
233
|
+
throw takeObject(r1);
|
|
234
|
+
}
|
|
235
|
+
return takeObject(r0);
|
|
236
|
+
} finally {
|
|
237
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
/**
|
|
242
|
+
* Decode a hex-encoded spend bundle into its `CoinSpend[]` (see
|
|
243
|
+
* [`chip35_dl_coin::hex_spend_bundle_to_coin_spends`]).
|
|
81
244
|
* @param {string} hex
|
|
82
245
|
* @returns {any}
|
|
83
246
|
*/
|
|
@@ -108,6 +271,34 @@ export function init() {
|
|
|
108
271
|
}
|
|
109
272
|
|
|
110
273
|
/**
|
|
274
|
+
* Issue a single-issuance (fixed-supply) CAT. Returns `{ coinSpends, assetId, catCoins }`.
|
|
275
|
+
* @param {Uint8Array} issuer_synthetic_key
|
|
276
|
+
* @param {any} selected_coins
|
|
277
|
+
* @param {bigint} amount
|
|
278
|
+
* @param {bigint} fee
|
|
279
|
+
* @returns {any}
|
|
280
|
+
*/
|
|
281
|
+
export function issueCat(issuer_synthetic_key, selected_coins, amount, fee) {
|
|
282
|
+
try {
|
|
283
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
284
|
+
const ptr0 = passArray8ToWasm0(issuer_synthetic_key, wasm.__wbindgen_export);
|
|
285
|
+
const len0 = WASM_VECTOR_LEN;
|
|
286
|
+
wasm.issueCat(retptr, ptr0, len0, addHeapObject(selected_coins), amount, fee);
|
|
287
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
288
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
289
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
290
|
+
if (r2) {
|
|
291
|
+
throw takeObject(r1);
|
|
292
|
+
}
|
|
293
|
+
return takeObject(r0);
|
|
294
|
+
} finally {
|
|
295
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
/**
|
|
300
|
+
* Burn (melt) a store singleton (see [`chip35_dl_coin::melt_store`]). Owner-authorized only.
|
|
301
|
+
* Returns the melt `CoinSpend[]`.
|
|
111
302
|
* @param {any} store
|
|
112
303
|
* @param {Uint8Array} owner_public_key
|
|
113
304
|
* @returns {any}
|
|
@@ -131,6 +322,37 @@ export function meltStore(store, owner_public_key) {
|
|
|
131
322
|
}
|
|
132
323
|
|
|
133
324
|
/**
|
|
325
|
+
* Mint a single NFT whose media lives in a DIG capsule (`dig://` URN + https gateway fallback URIs,
|
|
326
|
+
* hashes computed from real bytes). `params` is `NftMintParams`. Returns
|
|
327
|
+
* `{ coinSpends, launcherId, nftCoin }`.
|
|
328
|
+
* @param {Uint8Array} minter_synthetic_key
|
|
329
|
+
* @param {any} selected_coins
|
|
330
|
+
* @param {any} params
|
|
331
|
+
* @param {bigint} fee
|
|
332
|
+
* @returns {any}
|
|
333
|
+
*/
|
|
334
|
+
export function mintNft(minter_synthetic_key, selected_coins, params, fee) {
|
|
335
|
+
try {
|
|
336
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
337
|
+
const ptr0 = passArray8ToWasm0(minter_synthetic_key, wasm.__wbindgen_export);
|
|
338
|
+
const len0 = WASM_VECTOR_LEN;
|
|
339
|
+
wasm.mintNft(retptr, ptr0, len0, addHeapObject(selected_coins), addHeapObject(params), fee);
|
|
340
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
341
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
342
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
343
|
+
if (r2) {
|
|
344
|
+
throw takeObject(r1);
|
|
345
|
+
}
|
|
346
|
+
return takeObject(r0);
|
|
347
|
+
} finally {
|
|
348
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
349
|
+
}
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
/**
|
|
353
|
+
* Build the spend bundle that launches a new DataLayer store singleton (see
|
|
354
|
+
* [`chip35_dl_coin::mint_store`]). `program_hash` is an optional 32-byte size-proof; the rest of
|
|
355
|
+
* the JS values mirror the core builder. Returns a `SuccessResponse` (`coinSpends` + `newStore`).
|
|
134
356
|
* @param {Uint8Array} minter_synthetic_key
|
|
135
357
|
* @param {any} selected_coins
|
|
136
358
|
* @param {Uint8Array} root_hash
|
|
@@ -172,6 +394,8 @@ export function mintStore(minter_synthetic_key, selected_coins, root_hash, label
|
|
|
172
394
|
}
|
|
173
395
|
|
|
174
396
|
/**
|
|
397
|
+
* Exercise a store's oracle delegated puzzle (see [`chip35_dl_coin::oracle_spend`]). The spender
|
|
398
|
+
* pays the oracle fee plus `fee` from `selected_coins`. Returns a `SuccessResponse`.
|
|
175
399
|
* @param {Uint8Array} spender_synthetic_key
|
|
176
400
|
* @param {any} selected_coins
|
|
177
401
|
* @param {any} store
|
|
@@ -197,6 +421,30 @@ export function oracleSpend(spender_synthetic_key, selected_coins, store, fee) {
|
|
|
197
421
|
}
|
|
198
422
|
|
|
199
423
|
/**
|
|
424
|
+
* SHA-256 of arbitrary bytes → 32-byte hash (the one true primitive for `data_hash`/
|
|
425
|
+
* `metadata_hash`/`license_hash`). Returns the raw 32 bytes (`Uint8Array`).
|
|
426
|
+
* @param {Uint8Array} bytes
|
|
427
|
+
* @returns {Uint8Array}
|
|
428
|
+
*/
|
|
429
|
+
export function sha256(bytes) {
|
|
430
|
+
try {
|
|
431
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
432
|
+
const ptr0 = passArray8ToWasm0(bytes, wasm.__wbindgen_export);
|
|
433
|
+
const len0 = WASM_VECTOR_LEN;
|
|
434
|
+
wasm.sha256(retptr, ptr0, len0);
|
|
435
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
436
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
437
|
+
var v2 = getArrayU8FromWasm0(r0, r1).slice();
|
|
438
|
+
wasm.__wbindgen_export4(r0, r1 * 1, 1);
|
|
439
|
+
return v2;
|
|
440
|
+
} finally {
|
|
441
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
442
|
+
}
|
|
443
|
+
}
|
|
444
|
+
|
|
445
|
+
/**
|
|
446
|
+
* Serialize a spend bundle (`{coinSpends, aggregatedSignature}`) to its hex wire encoding
|
|
447
|
+
* (see [`chip35_dl_coin::spend_bundle_to_hex`]).
|
|
200
448
|
* @param {any} spend_bundle
|
|
201
449
|
* @returns {string}
|
|
202
450
|
*/
|
|
@@ -226,6 +474,9 @@ export function spendBundleToHex(spend_bundle) {
|
|
|
226
474
|
}
|
|
227
475
|
|
|
228
476
|
/**
|
|
477
|
+
* Update a store's metadata (see [`chip35_dl_coin::update_store_metadata`]). Exactly one of
|
|
478
|
+
* `owner_public_key`, `admin_public_key`, `writer_public_key` must be provided — it selects the
|
|
479
|
+
* authorizing role. Returns a `SuccessResponse`.
|
|
229
480
|
* @param {any} store
|
|
230
481
|
* @param {Uint8Array} new_root_hash
|
|
231
482
|
* @param {string | null} [new_label]
|
|
@@ -268,6 +519,10 @@ export function updateStoreMetadata(store, new_root_hash, new_label, new_descrip
|
|
|
268
519
|
}
|
|
269
520
|
|
|
270
521
|
/**
|
|
522
|
+
* Transfer ownership and/or replace the delegated-puzzle set (see
|
|
523
|
+
* [`chip35_dl_coin::update_store_ownership`]). Omitting `new_owner_puzzle_hash` keeps the
|
|
524
|
+
* current owner. Exactly one of `owner_public_key`/`admin_public_key` must be provided. Returns
|
|
525
|
+
* a `SuccessResponse`.
|
|
271
526
|
* @param {any} store
|
|
272
527
|
* @param {Uint8Array | null | undefined} new_owner_puzzle_hash
|
|
273
528
|
* @param {any} new_delegated_puzzles
|
|
@@ -296,6 +551,31 @@ export function updateStoreOwnership(store, new_owner_puzzle_hash, new_delegated
|
|
|
296
551
|
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
297
552
|
}
|
|
298
553
|
}
|
|
554
|
+
|
|
555
|
+
/**
|
|
556
|
+
* Validate a CHIP-0007 document's schema, and (when the actual bytes are provided) that each
|
|
557
|
+
* on-chain hash matches `sha256(bytes)` — the URI↔hash agreement check (#36). `assets` is
|
|
558
|
+
* `{ dataBytes?, dataHash?, metadataBytes?, metadataHash?, licenseBytes?, licenseHash? }` (all
|
|
559
|
+
* `Uint8Array`). Returns `{ ok: bool, errors: string[] }`.
|
|
560
|
+
* @param {any} metadata
|
|
561
|
+
* @param {any} assets
|
|
562
|
+
* @returns {any}
|
|
563
|
+
*/
|
|
564
|
+
export function validateChip0007(metadata, assets) {
|
|
565
|
+
try {
|
|
566
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
567
|
+
wasm.validateChip0007(retptr, addHeapObject(metadata), addHeapObject(assets));
|
|
568
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
569
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
570
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
571
|
+
if (r2) {
|
|
572
|
+
throw takeObject(r1);
|
|
573
|
+
}
|
|
574
|
+
return takeObject(r0);
|
|
575
|
+
} finally {
|
|
576
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
577
|
+
}
|
|
578
|
+
}
|
|
299
579
|
export function __wbg_Error_ef53bc310eb298a0(arg0, arg1) {
|
|
300
580
|
const ret = Error(getStringFromWasm0(arg0, arg1));
|
|
301
581
|
return addHeapObject(ret);
|
|
@@ -341,6 +621,10 @@ export function __wbg___wbindgen_is_function_754e9f305ff6029e(arg0) {
|
|
|
341
621
|
const ret = typeof(getObject(arg0)) === 'function';
|
|
342
622
|
return ret;
|
|
343
623
|
}
|
|
624
|
+
export function __wbg___wbindgen_is_null_87c3bfe968c6a5ad(arg0) {
|
|
625
|
+
const ret = getObject(arg0) === null;
|
|
626
|
+
return ret;
|
|
627
|
+
}
|
|
344
628
|
export function __wbg___wbindgen_is_object_56732c2bc353f41d(arg0) {
|
|
345
629
|
const val = getObject(arg0);
|
|
346
630
|
const ret = typeof(val) === 'object' && val !== null;
|
|
Binary file
|
package/package.json
CHANGED
|
@@ -2,11 +2,8 @@
|
|
|
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.
|
|
5
|
+
"version": "0.5.0",
|
|
6
6
|
"license": "MIT",
|
|
7
|
-
"publishConfig": {
|
|
8
|
-
"access": "public"
|
|
9
|
-
},
|
|
10
7
|
"repository": {
|
|
11
8
|
"type": "git",
|
|
12
9
|
"url": "https://github.com/DIG-Network/chip35_dl_coin"
|
|
@@ -22,5 +19,8 @@
|
|
|
22
19
|
"sideEffects": [
|
|
23
20
|
"./chip35_dl_coin_wasm.js",
|
|
24
21
|
"./snippets/*"
|
|
25
|
-
]
|
|
22
|
+
],
|
|
23
|
+
"publishConfig": {
|
|
24
|
+
"access": "public"
|
|
25
|
+
}
|
|
26
26
|
}
|