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