@dignetwork/chip35-dl-coin-wasm 0.4.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 +95 -22
- package/chip35_dl_coin_wasm.js +1 -1
- package/chip35_dl_coin_wasm_bg.js +246 -113
- package/chip35_dl_coin_wasm_bg.wasm +0 -0
- package/package.json +1 -1
package/chip35_dl_coin_wasm.d.ts
CHANGED
|
@@ -1,23 +1,33 @@
|
|
|
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
|
|
8
|
-
* (
|
|
9
|
-
*
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
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 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 }`.
|
|
19
23
|
*/
|
|
20
|
-
export function
|
|
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;
|
|
21
31
|
|
|
22
32
|
/**
|
|
23
33
|
* Reconstruct a DataStore from the coin spend that created its current coin (the launcher
|
|
@@ -29,16 +39,9 @@ export function buildDigPayment(owner_synthetic_key: Uint8Array, owner_puzzle_ha
|
|
|
29
39
|
export function dataStoreFromSpend(coin_spend: any, prev_delegated_puzzles: any): any;
|
|
30
40
|
|
|
31
41
|
/**
|
|
32
|
-
*
|
|
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.
|
|
42
|
+
* Decode canonical offer text into its spend bundle `{ coinSpends, aggregatedSignature }`.
|
|
40
43
|
*/
|
|
41
|
-
export function
|
|
44
|
+
export function decodeOffer(text: string): any;
|
|
42
45
|
|
|
43
46
|
/**
|
|
44
47
|
* Derive the digstore-scoped owner discovery hint for a 32-byte owner puzzle hash. The app
|
|
@@ -47,6 +50,22 @@ export function digTreasuryInnerPuzzleHash(): Uint8Array;
|
|
|
47
50
|
*/
|
|
48
51
|
export function digstoreOwnerHint(owner_puzzle_hash: Uint8Array): Uint8Array;
|
|
49
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
|
+
*/
|
|
50
69
|
export function hexSpendBundleToCoinSpends(hex: string): any;
|
|
51
70
|
|
|
52
71
|
/**
|
|
@@ -55,14 +74,68 @@ export function hexSpendBundleToCoinSpends(hex: string): any;
|
|
|
55
74
|
*/
|
|
56
75
|
export function init(): void;
|
|
57
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
|
+
*/
|
|
58
86
|
export function meltStore(store: any, owner_public_key: Uint8Array): any;
|
|
59
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
|
+
*/
|
|
60
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;
|
|
61
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
|
+
*/
|
|
62
106
|
export function oracleSpend(spender_synthetic_key: Uint8Array, selected_coins: any, store: any, fee: bigint): any;
|
|
63
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
|
+
*/
|
|
64
118
|
export function spendBundleToHex(spend_bundle: any): string;
|
|
65
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
|
+
*/
|
|
66
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;
|
|
67
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
|
+
*/
|
|
68
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,
|
|
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
|
|
@@ -24,36 +28,73 @@ export function addFee(spender_synthetic_key, selected_coins, assert_coin_ids, f
|
|
|
24
28
|
}
|
|
25
29
|
|
|
26
30
|
/**
|
|
27
|
-
* Build
|
|
28
|
-
* (
|
|
29
|
-
*
|
|
30
|
-
*
|
|
31
|
-
*
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
*
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
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
|
|
45
62
|
* @returns {any}
|
|
46
63
|
*/
|
|
47
|
-
export function
|
|
64
|
+
export function bulkMint(minter_synthetic_key, did, collection, items, recipient_puzzle_hash) {
|
|
48
65
|
try {
|
|
49
66
|
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
50
|
-
const ptr0 = passArray8ToWasm0(
|
|
67
|
+
const ptr0 = passArray8ToWasm0(minter_synthetic_key, wasm.__wbindgen_export);
|
|
51
68
|
const len0 = WASM_VECTOR_LEN;
|
|
52
|
-
const ptr1 = passArray8ToWasm0(
|
|
69
|
+
const ptr1 = passArray8ToWasm0(recipient_puzzle_hash, wasm.__wbindgen_export);
|
|
53
70
|
const len1 = WASM_VECTOR_LEN;
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
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);
|
|
57
98
|
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
58
99
|
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
59
100
|
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
@@ -93,17 +134,41 @@ export function dataStoreFromSpend(coin_spend, prev_delegated_puzzles) {
|
|
|
93
134
|
}
|
|
94
135
|
|
|
95
136
|
/**
|
|
96
|
-
*
|
|
97
|
-
*
|
|
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
|
+
|
|
159
|
+
/**
|
|
160
|
+
* Derive the digstore-scoped owner discovery hint for a 32-byte owner puzzle hash. The app
|
|
161
|
+
* computes the SAME hint to enumerate the wallet's stores via coinset
|
|
162
|
+
* get_coin_records_by_hint — it MUST match the hint mint_store emits. Returns 32 bytes.
|
|
98
163
|
* @param {Uint8Array} owner_puzzle_hash
|
|
99
164
|
* @returns {Uint8Array}
|
|
100
165
|
*/
|
|
101
|
-
export function
|
|
166
|
+
export function digstoreOwnerHint(owner_puzzle_hash) {
|
|
102
167
|
try {
|
|
103
168
|
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
104
169
|
const ptr0 = passArray8ToWasm0(owner_puzzle_hash, wasm.__wbindgen_export);
|
|
105
170
|
const len0 = WASM_VECTOR_LEN;
|
|
106
|
-
wasm.
|
|
171
|
+
wasm.digstoreOwnerHint(retptr, ptr0, len0);
|
|
107
172
|
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
108
173
|
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
109
174
|
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
@@ -120,53 +185,62 @@ export function digCatPuzzleHash(owner_puzzle_hash) {
|
|
|
120
185
|
}
|
|
121
186
|
|
|
122
187
|
/**
|
|
123
|
-
*
|
|
124
|
-
*
|
|
125
|
-
* @returns {
|
|
188
|
+
* Encode a spend bundle (`{coinSpends, aggregatedSignature}`) into canonical offer text.
|
|
189
|
+
* @param {any} spend_bundle
|
|
190
|
+
* @returns {string}
|
|
126
191
|
*/
|
|
127
|
-
export function
|
|
192
|
+
export function encodeOffer(spend_bundle) {
|
|
193
|
+
let deferred2_0;
|
|
194
|
+
let deferred2_1;
|
|
128
195
|
try {
|
|
129
196
|
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
130
|
-
wasm.
|
|
197
|
+
wasm.encodeOffer(retptr, addHeapObject(spend_bundle));
|
|
131
198
|
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
132
199
|
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
133
|
-
var
|
|
134
|
-
|
|
135
|
-
|
|
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);
|
|
136
211
|
} finally {
|
|
137
212
|
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
213
|
+
wasm.__wbindgen_export4(deferred2_0, deferred2_1, 1);
|
|
138
214
|
}
|
|
139
215
|
}
|
|
140
216
|
|
|
141
217
|
/**
|
|
142
|
-
*
|
|
143
|
-
*
|
|
144
|
-
*
|
|
145
|
-
* @param {
|
|
146
|
-
* @
|
|
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}
|
|
147
224
|
*/
|
|
148
|
-
export function
|
|
225
|
+
export function generateItemMetadata(collection, items) {
|
|
149
226
|
try {
|
|
150
227
|
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
151
|
-
|
|
152
|
-
const len0 = WASM_VECTOR_LEN;
|
|
153
|
-
wasm.digstoreOwnerHint(retptr, ptr0, len0);
|
|
228
|
+
wasm.generateItemMetadata(retptr, addHeapObject(collection), addHeapObject(items));
|
|
154
229
|
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
155
230
|
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
156
231
|
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
throw takeObject(r2);
|
|
232
|
+
if (r2) {
|
|
233
|
+
throw takeObject(r1);
|
|
160
234
|
}
|
|
161
|
-
|
|
162
|
-
wasm.__wbindgen_export4(r0, r1 * 1, 1);
|
|
163
|
-
return v2;
|
|
235
|
+
return takeObject(r0);
|
|
164
236
|
} finally {
|
|
165
237
|
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
166
238
|
}
|
|
167
239
|
}
|
|
168
240
|
|
|
169
241
|
/**
|
|
242
|
+
* Decode a hex-encoded spend bundle into its `CoinSpend[]` (see
|
|
243
|
+
* [`chip35_dl_coin::hex_spend_bundle_to_coin_spends`]).
|
|
170
244
|
* @param {string} hex
|
|
171
245
|
* @returns {any}
|
|
172
246
|
*/
|
|
@@ -197,6 +271,34 @@ export function init() {
|
|
|
197
271
|
}
|
|
198
272
|
|
|
199
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[]`.
|
|
200
302
|
* @param {any} store
|
|
201
303
|
* @param {Uint8Array} owner_public_key
|
|
202
304
|
* @returns {any}
|
|
@@ -220,6 +322,37 @@ export function meltStore(store, owner_public_key) {
|
|
|
220
322
|
}
|
|
221
323
|
|
|
222
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`).
|
|
223
356
|
* @param {Uint8Array} minter_synthetic_key
|
|
224
357
|
* @param {any} selected_coins
|
|
225
358
|
* @param {Uint8Array} root_hash
|
|
@@ -261,6 +394,8 @@ export function mintStore(minter_synthetic_key, selected_coins, root_hash, label
|
|
|
261
394
|
}
|
|
262
395
|
|
|
263
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`.
|
|
264
399
|
* @param {Uint8Array} spender_synthetic_key
|
|
265
400
|
* @param {any} selected_coins
|
|
266
401
|
* @param {any} store
|
|
@@ -286,6 +421,30 @@ export function oracleSpend(spender_synthetic_key, selected_coins, store, fee) {
|
|
|
286
421
|
}
|
|
287
422
|
|
|
288
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`]).
|
|
289
448
|
* @param {any} spend_bundle
|
|
290
449
|
* @returns {string}
|
|
291
450
|
*/
|
|
@@ -315,6 +474,9 @@ export function spendBundleToHex(spend_bundle) {
|
|
|
315
474
|
}
|
|
316
475
|
|
|
317
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`.
|
|
318
480
|
* @param {any} store
|
|
319
481
|
* @param {Uint8Array} new_root_hash
|
|
320
482
|
* @param {string | null} [new_label]
|
|
@@ -357,6 +519,10 @@ export function updateStoreMetadata(store, new_root_hash, new_label, new_descrip
|
|
|
357
519
|
}
|
|
358
520
|
|
|
359
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`.
|
|
360
526
|
* @param {any} store
|
|
361
527
|
* @param {Uint8Array | null | undefined} new_owner_puzzle_hash
|
|
362
528
|
* @param {any} new_delegated_puzzles
|
|
@@ -385,6 +551,31 @@ export function updateStoreOwnership(store, new_owner_puzzle_hash, new_delegated
|
|
|
385
551
|
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
386
552
|
}
|
|
387
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
|
+
}
|
|
388
579
|
export function __wbg_Error_ef53bc310eb298a0(arg0, arg1) {
|
|
389
580
|
const ret = Error(getStringFromWasm0(arg0, arg1));
|
|
390
581
|
return addHeapObject(ret);
|
|
@@ -430,15 +621,15 @@ export function __wbg___wbindgen_is_function_754e9f305ff6029e(arg0) {
|
|
|
430
621
|
const ret = typeof(getObject(arg0)) === 'function';
|
|
431
622
|
return ret;
|
|
432
623
|
}
|
|
624
|
+
export function __wbg___wbindgen_is_null_87c3bfe968c6a5ad(arg0) {
|
|
625
|
+
const ret = getObject(arg0) === null;
|
|
626
|
+
return ret;
|
|
627
|
+
}
|
|
433
628
|
export function __wbg___wbindgen_is_object_56732c2bc353f41d(arg0) {
|
|
434
629
|
const val = getObject(arg0);
|
|
435
630
|
const ret = typeof(val) === 'object' && val !== null;
|
|
436
631
|
return ret;
|
|
437
632
|
}
|
|
438
|
-
export function __wbg___wbindgen_is_string_c236cabd84a4d769(arg0) {
|
|
439
|
-
const ret = typeof(getObject(arg0)) === 'string';
|
|
440
|
-
return ret;
|
|
441
|
-
}
|
|
442
633
|
export function __wbg___wbindgen_is_undefined_67b456be8673d3d7(arg0) {
|
|
443
634
|
const ret = getObject(arg0) === undefined;
|
|
444
635
|
return ret;
|
|
@@ -472,14 +663,6 @@ export function __wbg_call_8a89609d89f6608a() { return handleError(function (arg
|
|
|
472
663
|
const ret = getObject(arg0).call(getObject(arg1));
|
|
473
664
|
return addHeapObject(ret);
|
|
474
665
|
}, 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
666
|
export function __wbg_done_60cf307fcc680536(arg0) {
|
|
484
667
|
const ret = getObject(arg0).done;
|
|
485
668
|
return ret;
|
|
@@ -499,9 +682,6 @@ export function __wbg_from_d300fe49deab18f5(arg0) {
|
|
|
499
682
|
const ret = Array.from(getObject(arg0));
|
|
500
683
|
return addHeapObject(ret);
|
|
501
684
|
}
|
|
502
|
-
export function __wbg_getRandomValues_c44a50d8cfdaebeb() { return handleError(function (arg0, arg1) {
|
|
503
|
-
getObject(arg0).getRandomValues(getObject(arg1));
|
|
504
|
-
}, arguments); }
|
|
505
685
|
export function __wbg_get_1f8f054ddbaa7db2() { return handleError(function (arg0, arg1) {
|
|
506
686
|
const ret = Reflect.get(getObject(arg0), getObject(arg1));
|
|
507
687
|
return addHeapObject(ret);
|
|
@@ -554,10 +734,6 @@ export function __wbg_length_66f1a4b2e9026940(arg0) {
|
|
|
554
734
|
const ret = getObject(arg0).length;
|
|
555
735
|
return ret;
|
|
556
736
|
}
|
|
557
|
-
export function __wbg_msCrypto_bd5a034af96bcba6(arg0) {
|
|
558
|
-
const ret = getObject(arg0).msCrypto;
|
|
559
|
-
return addHeapObject(ret);
|
|
560
|
-
}
|
|
561
737
|
export function __wbg_new_227d7c05414eb861() {
|
|
562
738
|
const ret = new Error();
|
|
563
739
|
return addHeapObject(ret);
|
|
@@ -574,10 +750,6 @@ export function __wbg_new_d90091b82fdf5b91() {
|
|
|
574
750
|
const ret = new Array();
|
|
575
751
|
return addHeapObject(ret);
|
|
576
752
|
}
|
|
577
|
-
export function __wbg_new_with_length_36a4998e27b014c5(arg0) {
|
|
578
|
-
const ret = new Uint8Array(arg0 >>> 0);
|
|
579
|
-
return addHeapObject(ret);
|
|
580
|
-
}
|
|
581
753
|
export function __wbg_next_9e03acdf51c4960d(arg0) {
|
|
582
754
|
const ret = getObject(arg0).next;
|
|
583
755
|
return addHeapObject(ret);
|
|
@@ -586,24 +758,9 @@ export function __wbg_next_eb8ca7351fa27906() { return handleError(function (arg
|
|
|
586
758
|
const ret = getObject(arg0).next();
|
|
587
759
|
return addHeapObject(ret);
|
|
588
760
|
}, 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
761
|
export function __wbg_prototypesetcall_3249fc62a0fafa30(arg0, arg1, arg2) {
|
|
598
762
|
Uint8Array.prototype.set.call(getArrayU8FromWasm0(arg0, arg1), getObject(arg2));
|
|
599
763
|
}
|
|
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
764
|
export function __wbg_set_6be42768c690e380(arg0, arg1, arg2) {
|
|
608
765
|
getObject(arg0)[takeObject(arg1)] = takeObject(arg2);
|
|
609
766
|
}
|
|
@@ -617,34 +774,10 @@ export function __wbg_stack_3b0d974bbf31e44f(arg0, arg1) {
|
|
|
617
774
|
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
618
775
|
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
619
776
|
}
|
|
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
777
|
export function __wbg_value_f3625092ee4b37f4(arg0) {
|
|
641
778
|
const ret = getObject(arg0).value;
|
|
642
779
|
return addHeapObject(ret);
|
|
643
780
|
}
|
|
644
|
-
export function __wbg_versions_276b2795b1c6a219(arg0) {
|
|
645
|
-
const ret = getObject(arg0).versions;
|
|
646
|
-
return addHeapObject(ret);
|
|
647
|
-
}
|
|
648
781
|
export function __wbindgen_cast_0000000000000001(arg0) {
|
|
649
782
|
// Cast intrinsic for `F64 -> Externref`.
|
|
650
783
|
const ret = arg0;
|
|
Binary file
|
package/package.json
CHANGED