@dignetwork/chip35-dl-coin-wasm 0.5.0 → 0.7.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
CHANGED
|
@@ -9,6 +9,22 @@
|
|
|
9
9
|
*/
|
|
10
10
|
export function addFee(spender_synthetic_key: Uint8Array, selected_coins: any, assert_coin_ids: any, fee: bigint): any;
|
|
11
11
|
|
|
12
|
+
/**
|
|
13
|
+
* Build the **Admin** delegated puzzle for a 48-byte synthetic public key (a hub Teams admin).
|
|
14
|
+
* An admin may update the store AND change delegation (add/remove writers — i.e. revoke a deploy
|
|
15
|
+
* token), but cannot transfer ownership. Returns a `DelegatedPuzzle` (`{ adminInnerPuzzleHash }`).
|
|
16
|
+
*/
|
|
17
|
+
export function adminDelegatedPuzzleFromKey(synthetic_key: Uint8Array): any;
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Build the coin spends for a buyer to pay the dapp owner `amount` base units of a **CAT** (incl.
|
|
21
|
+
* DIG) (#46 payment). `selected_cats` is the buyer's `Cat[]` of ONE asset id (as
|
|
22
|
+
* `chip0002_getAssetCoins` returns them); `nonce` is the 32-byte unlock nonce. The CAT ring nets to
|
|
23
|
+
* zero, so carry any XCH network fee with a separate XCH coin via `addFee` asserting the lead CAT
|
|
24
|
+
* coin id. Returns `{ coinSpends, receipt }`.
|
|
25
|
+
*/
|
|
26
|
+
export function buildCatPayment(buyer_synthetic_key: Uint8Array, selected_cats: any, owner_puzzle_hash: Uint8Array, amount: bigint, nonce: Uint8Array): any;
|
|
27
|
+
|
|
12
28
|
/**
|
|
13
29
|
* Build a CHIP-0007 metadata document from a JS object and return its canonical JSON + the
|
|
14
30
|
* `metadata_hash` (sha256 of that JSON). De-dupes the hand-computed badge metadata: callers stop
|
|
@@ -16,6 +32,13 @@ export function addFee(spender_synthetic_key: Uint8Array, selected_coins: any, a
|
|
|
16
32
|
*/
|
|
17
33
|
export function buildChip0007Metadata(metadata: any): any;
|
|
18
34
|
|
|
35
|
+
/**
|
|
36
|
+
* Build the coin spends for a buyer to pay the dapp owner `amount` mojos of **XCH** (#46 payment).
|
|
37
|
+
* `selected_coins` is the buyer's XCH `Coin[]`; `nonce` is the 32-byte unlock nonce. Returns
|
|
38
|
+
* `{ coinSpends, receipt }` where `receipt` is the `PaymentReceipt` the paywall later verifies.
|
|
39
|
+
*/
|
|
40
|
+
export function buildPayment(buyer_synthetic_key: Uint8Array, selected_coins: any, owner_puzzle_hash: Uint8Array, amount: bigint, nonce: Uint8Array, fee: bigint): any;
|
|
41
|
+
|
|
19
42
|
/**
|
|
20
43
|
* Bulk-mint every item in a parsed traits manifest into a collection, attributed to a DID (#34).
|
|
21
44
|
* `did` is the DID coin + identifiers `{ launcherId, innerPuzzleHash, didCoin }` (e.g. from a prior
|
|
@@ -99,12 +122,48 @@ export function mintNft(minter_synthetic_key: Uint8Array, selected_coins: any, p
|
|
|
99
122
|
*/
|
|
100
123
|
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;
|
|
101
124
|
|
|
125
|
+
/**
|
|
126
|
+
* Build the **Oracle** delegated puzzle: anyone may spend the store for the fixed `oracle_fee`
|
|
127
|
+
* (mojos) paid to the 32-byte `oracle_puzzle_hash`. Returns a `DelegatedPuzzle`
|
|
128
|
+
* (`{ oraclePaymentPuzzleHash, oracleFee }`).
|
|
129
|
+
*/
|
|
130
|
+
export function oracleDelegatedPuzzle(oracle_puzzle_hash: Uint8Array, oracle_fee: bigint): any;
|
|
131
|
+
|
|
102
132
|
/**
|
|
103
133
|
* Exercise a store's oracle delegated puzzle (see [`chip35_dl_coin::oracle_spend`]). The spender
|
|
104
134
|
* pays the oracle fee plus `fee` from `selected_coins`. Returns a `SuccessResponse`.
|
|
105
135
|
*/
|
|
106
136
|
export function oracleSpend(spender_synthetic_key: Uint8Array, selected_coins: any, store: any, fee: bigint): any;
|
|
107
137
|
|
|
138
|
+
/**
|
|
139
|
+
* SHA-256-derive a 32-byte unlock nonce from arbitrary request bytes (`dappId||resource||user`).
|
|
140
|
+
* A dapp issues one nonce per unlock request, embeds it in the payment, and verifies it later. The
|
|
141
|
+
* dapp may instead use any random 32 bytes — this is a deterministic convenience. Returns 32 bytes.
|
|
142
|
+
*/
|
|
143
|
+
export function paymentNonce(request_bytes: Uint8Array): Uint8Array;
|
|
144
|
+
|
|
145
|
+
/**
|
|
146
|
+
* Prove an NFT held by `claimed_owner_puzzle_hash` is a member of the collection/creator identified
|
|
147
|
+
* by `required_did` (#46 collection-gating). Returns `{ ok, proof?, error? }`.
|
|
148
|
+
*/
|
|
149
|
+
export function proveCollectionMembership(parent_spend: any, claimed_owner_puzzle_hash: Uint8Array, required_did: Uint8Array): any;
|
|
150
|
+
|
|
151
|
+
/**
|
|
152
|
+
* Prove an NFT (reconstructed from `parent_spend`, the coin spend that created its current coin) is
|
|
153
|
+
* owned by `claimed_owner_puzzle_hash`, optionally gating on a specific NFT launcher id (#46 NFT-
|
|
154
|
+
* gating). `parent_spend` is the wasm `CoinSpend` shape. Returns `{ ok, proof?, error? }` — on
|
|
155
|
+
* success `proof` is the `NftOwnershipProof` (launcher id, owner, attributed DID, current coin id);
|
|
156
|
+
* the caller still confirms `proof.nftCoinId` is unspent on-chain for liveness.
|
|
157
|
+
*/
|
|
158
|
+
export function proveNftOwnership(parent_spend: any, claimed_owner_puzzle_hash: Uint8Array, required_nft?: Uint8Array | null): any;
|
|
159
|
+
|
|
160
|
+
/**
|
|
161
|
+
* Read an NFT's ownership facts (owner, attributed DID, launcher id, current coin id) from
|
|
162
|
+
* `parent_spend` WITHOUT applying a gate — for dapps that want to decide in their own code.
|
|
163
|
+
* Returns `{ ok, proof?, error? }`.
|
|
164
|
+
*/
|
|
165
|
+
export function readNftOwnership(parent_spend: any): any;
|
|
166
|
+
|
|
108
167
|
/**
|
|
109
168
|
* SHA-256 of arbitrary bytes → 32-byte hash (the one true primitive for `data_hash`/
|
|
110
169
|
* `metadata_hash`/`license_hash`). Returns the raw 32 bytes (`Uint8Array`).
|
|
@@ -139,3 +198,21 @@ export function updateStoreOwnership(store: any, new_owner_puzzle_hash: Uint8Arr
|
|
|
139
198
|
* `Uint8Array`). Returns `{ ok: bool, errors: string[] }`.
|
|
140
199
|
*/
|
|
141
200
|
export function validateChip0007(metadata: any, assets: any): any;
|
|
201
|
+
|
|
202
|
+
/**
|
|
203
|
+
* Verify an observed payment unlocks a paywall (#46 pay-to-unlock): it must pay `owner_puzzle_hash`,
|
|
204
|
+
* in `required_asset`, at least `min_amount`, and (when `require_nonce` is a 32-byte value) carry
|
|
205
|
+
* that nonce. `observed` is an `ObservedPayment` the dapp filled in after reading the owner's coin;
|
|
206
|
+
* `required_asset` is a `PaymentAsset` (`{xch:true}` or `{assetId}`). Returns `{ ok, error? }` —
|
|
207
|
+
* `ok:true` grants access, otherwise `error` is the human-readable denial reason.
|
|
208
|
+
*/
|
|
209
|
+
export function verifyPaymentReceipt(observed: any, owner_puzzle_hash: Uint8Array, min_amount: bigint, required_asset: any, require_nonce?: Uint8Array | null): any;
|
|
210
|
+
|
|
211
|
+
/**
|
|
212
|
+
* Build the **Writer** delegated puzzle for a 48-byte synthetic public key — a revocable deploy
|
|
213
|
+
* token (#17) or a hub Teams writer (#43). A writer may advance the root (deploy a new capsule)
|
|
214
|
+
* WITHOUT the owner seed, but may NOT change delegation or transfer ownership. Add it to a store
|
|
215
|
+
* to issue the token; replace the store's delegated set to revoke it. Returns a `DelegatedPuzzle`
|
|
216
|
+
* (`{ writerInnerPuzzleHash }`).
|
|
217
|
+
*/
|
|
218
|
+
export function writerDelegatedPuzzleFromKey(synthetic_key: Uint8Array): 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, buildChip0007Metadata, bulkMint, createDid, dataStoreFromSpend, decodeOffer, digstoreOwnerHint, encodeOffer, generateItemMetadata, hexSpendBundleToCoinSpends, init, issueCat, meltStore, mintNft, mintStore, oracleSpend, sha256, spendBundleToHex, updateStoreMetadata, updateStoreOwnership, validateChip0007
|
|
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
|
|
9
9
|
} from "./chip35_dl_coin_wasm_bg.js";
|
|
@@ -27,6 +27,66 @@ export function addFee(spender_synthetic_key, selected_coins, assert_coin_ids, f
|
|
|
27
27
|
}
|
|
28
28
|
}
|
|
29
29
|
|
|
30
|
+
/**
|
|
31
|
+
* Build the **Admin** delegated puzzle for a 48-byte synthetic public key (a hub Teams admin).
|
|
32
|
+
* An admin may update the store AND change delegation (add/remove writers — i.e. revoke a deploy
|
|
33
|
+
* token), but cannot transfer ownership. Returns a `DelegatedPuzzle` (`{ adminInnerPuzzleHash }`).
|
|
34
|
+
* @param {Uint8Array} synthetic_key
|
|
35
|
+
* @returns {any}
|
|
36
|
+
*/
|
|
37
|
+
export function adminDelegatedPuzzleFromKey(synthetic_key) {
|
|
38
|
+
try {
|
|
39
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
40
|
+
const ptr0 = passArray8ToWasm0(synthetic_key, wasm.__wbindgen_export);
|
|
41
|
+
const len0 = WASM_VECTOR_LEN;
|
|
42
|
+
wasm.adminDelegatedPuzzleFromKey(retptr, ptr0, len0);
|
|
43
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
44
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
45
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
46
|
+
if (r2) {
|
|
47
|
+
throw takeObject(r1);
|
|
48
|
+
}
|
|
49
|
+
return takeObject(r0);
|
|
50
|
+
} finally {
|
|
51
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Build the coin spends for a buyer to pay the dapp owner `amount` base units of a **CAT** (incl.
|
|
57
|
+
* DIG) (#46 payment). `selected_cats` is the buyer's `Cat[]` of ONE asset id (as
|
|
58
|
+
* `chip0002_getAssetCoins` returns them); `nonce` is the 32-byte unlock nonce. The CAT ring nets to
|
|
59
|
+
* zero, so carry any XCH network fee with a separate XCH coin via `addFee` asserting the lead CAT
|
|
60
|
+
* coin id. Returns `{ coinSpends, receipt }`.
|
|
61
|
+
* @param {Uint8Array} buyer_synthetic_key
|
|
62
|
+
* @param {any} selected_cats
|
|
63
|
+
* @param {Uint8Array} owner_puzzle_hash
|
|
64
|
+
* @param {bigint} amount
|
|
65
|
+
* @param {Uint8Array} nonce
|
|
66
|
+
* @returns {any}
|
|
67
|
+
*/
|
|
68
|
+
export function buildCatPayment(buyer_synthetic_key, selected_cats, owner_puzzle_hash, amount, nonce) {
|
|
69
|
+
try {
|
|
70
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
71
|
+
const ptr0 = passArray8ToWasm0(buyer_synthetic_key, wasm.__wbindgen_export);
|
|
72
|
+
const len0 = WASM_VECTOR_LEN;
|
|
73
|
+
const ptr1 = passArray8ToWasm0(owner_puzzle_hash, wasm.__wbindgen_export);
|
|
74
|
+
const len1 = WASM_VECTOR_LEN;
|
|
75
|
+
const ptr2 = passArray8ToWasm0(nonce, wasm.__wbindgen_export);
|
|
76
|
+
const len2 = WASM_VECTOR_LEN;
|
|
77
|
+
wasm.buildCatPayment(retptr, ptr0, len0, addHeapObject(selected_cats), ptr1, len1, amount, ptr2, len2);
|
|
78
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
79
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
80
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
81
|
+
if (r2) {
|
|
82
|
+
throw takeObject(r1);
|
|
83
|
+
}
|
|
84
|
+
return takeObject(r0);
|
|
85
|
+
} finally {
|
|
86
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
|
|
30
90
|
/**
|
|
31
91
|
* Build a CHIP-0007 metadata document from a JS object and return its canonical JSON + the
|
|
32
92
|
* `metadata_hash` (sha256 of that JSON). De-dupes the hand-computed badge metadata: callers stop
|
|
@@ -50,6 +110,40 @@ export function buildChip0007Metadata(metadata) {
|
|
|
50
110
|
}
|
|
51
111
|
}
|
|
52
112
|
|
|
113
|
+
/**
|
|
114
|
+
* Build the coin spends for a buyer to pay the dapp owner `amount` mojos of **XCH** (#46 payment).
|
|
115
|
+
* `selected_coins` is the buyer's XCH `Coin[]`; `nonce` is the 32-byte unlock nonce. Returns
|
|
116
|
+
* `{ coinSpends, receipt }` where `receipt` is the `PaymentReceipt` the paywall later verifies.
|
|
117
|
+
* @param {Uint8Array} buyer_synthetic_key
|
|
118
|
+
* @param {any} selected_coins
|
|
119
|
+
* @param {Uint8Array} owner_puzzle_hash
|
|
120
|
+
* @param {bigint} amount
|
|
121
|
+
* @param {Uint8Array} nonce
|
|
122
|
+
* @param {bigint} fee
|
|
123
|
+
* @returns {any}
|
|
124
|
+
*/
|
|
125
|
+
export function buildPayment(buyer_synthetic_key, selected_coins, owner_puzzle_hash, amount, nonce, fee) {
|
|
126
|
+
try {
|
|
127
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
128
|
+
const ptr0 = passArray8ToWasm0(buyer_synthetic_key, wasm.__wbindgen_export);
|
|
129
|
+
const len0 = WASM_VECTOR_LEN;
|
|
130
|
+
const ptr1 = passArray8ToWasm0(owner_puzzle_hash, wasm.__wbindgen_export);
|
|
131
|
+
const len1 = WASM_VECTOR_LEN;
|
|
132
|
+
const ptr2 = passArray8ToWasm0(nonce, wasm.__wbindgen_export);
|
|
133
|
+
const len2 = WASM_VECTOR_LEN;
|
|
134
|
+
wasm.buildPayment(retptr, ptr0, len0, addHeapObject(selected_coins), ptr1, len1, amount, ptr2, len2, fee);
|
|
135
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
136
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
137
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
138
|
+
if (r2) {
|
|
139
|
+
throw takeObject(r1);
|
|
140
|
+
}
|
|
141
|
+
return takeObject(r0);
|
|
142
|
+
} finally {
|
|
143
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
|
|
53
147
|
/**
|
|
54
148
|
* Bulk-mint every item in a parsed traits manifest into a collection, attributed to a DID (#34).
|
|
55
149
|
* `did` is the DID coin + identifiers `{ launcherId, innerPuzzleHash, didCoin }` (e.g. from a prior
|
|
@@ -393,6 +487,32 @@ export function mintStore(minter_synthetic_key, selected_coins, root_hash, label
|
|
|
393
487
|
}
|
|
394
488
|
}
|
|
395
489
|
|
|
490
|
+
/**
|
|
491
|
+
* Build the **Oracle** delegated puzzle: anyone may spend the store for the fixed `oracle_fee`
|
|
492
|
+
* (mojos) paid to the 32-byte `oracle_puzzle_hash`. Returns a `DelegatedPuzzle`
|
|
493
|
+
* (`{ oraclePaymentPuzzleHash, oracleFee }`).
|
|
494
|
+
* @param {Uint8Array} oracle_puzzle_hash
|
|
495
|
+
* @param {bigint} oracle_fee
|
|
496
|
+
* @returns {any}
|
|
497
|
+
*/
|
|
498
|
+
export function oracleDelegatedPuzzle(oracle_puzzle_hash, oracle_fee) {
|
|
499
|
+
try {
|
|
500
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
501
|
+
const ptr0 = passArray8ToWasm0(oracle_puzzle_hash, wasm.__wbindgen_export);
|
|
502
|
+
const len0 = WASM_VECTOR_LEN;
|
|
503
|
+
wasm.oracleDelegatedPuzzle(retptr, ptr0, len0, oracle_fee);
|
|
504
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
505
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
506
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
507
|
+
if (r2) {
|
|
508
|
+
throw takeObject(r1);
|
|
509
|
+
}
|
|
510
|
+
return takeObject(r0);
|
|
511
|
+
} finally {
|
|
512
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
513
|
+
}
|
|
514
|
+
}
|
|
515
|
+
|
|
396
516
|
/**
|
|
397
517
|
* Exercise a store's oracle delegated puzzle (see [`chip35_dl_coin::oracle_spend`]). The spender
|
|
398
518
|
* pays the oracle fee plus `fee` from `selected_coins`. Returns a `SuccessResponse`.
|
|
@@ -420,6 +540,111 @@ export function oracleSpend(spender_synthetic_key, selected_coins, store, fee) {
|
|
|
420
540
|
}
|
|
421
541
|
}
|
|
422
542
|
|
|
543
|
+
/**
|
|
544
|
+
* SHA-256-derive a 32-byte unlock nonce from arbitrary request bytes (`dappId||resource||user`).
|
|
545
|
+
* A dapp issues one nonce per unlock request, embeds it in the payment, and verifies it later. The
|
|
546
|
+
* dapp may instead use any random 32 bytes — this is a deterministic convenience. Returns 32 bytes.
|
|
547
|
+
* @param {Uint8Array} request_bytes
|
|
548
|
+
* @returns {Uint8Array}
|
|
549
|
+
*/
|
|
550
|
+
export function paymentNonce(request_bytes) {
|
|
551
|
+
try {
|
|
552
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
553
|
+
const ptr0 = passArray8ToWasm0(request_bytes, wasm.__wbindgen_export);
|
|
554
|
+
const len0 = WASM_VECTOR_LEN;
|
|
555
|
+
wasm.paymentNonce(retptr, ptr0, len0);
|
|
556
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
557
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
558
|
+
var v2 = getArrayU8FromWasm0(r0, r1).slice();
|
|
559
|
+
wasm.__wbindgen_export4(r0, r1 * 1, 1);
|
|
560
|
+
return v2;
|
|
561
|
+
} finally {
|
|
562
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
563
|
+
}
|
|
564
|
+
}
|
|
565
|
+
|
|
566
|
+
/**
|
|
567
|
+
* Prove an NFT held by `claimed_owner_puzzle_hash` is a member of the collection/creator identified
|
|
568
|
+
* by `required_did` (#46 collection-gating). Returns `{ ok, proof?, error? }`.
|
|
569
|
+
* @param {any} parent_spend
|
|
570
|
+
* @param {Uint8Array} claimed_owner_puzzle_hash
|
|
571
|
+
* @param {Uint8Array} required_did
|
|
572
|
+
* @returns {any}
|
|
573
|
+
*/
|
|
574
|
+
export function proveCollectionMembership(parent_spend, claimed_owner_puzzle_hash, required_did) {
|
|
575
|
+
try {
|
|
576
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
577
|
+
const ptr0 = passArray8ToWasm0(claimed_owner_puzzle_hash, wasm.__wbindgen_export);
|
|
578
|
+
const len0 = WASM_VECTOR_LEN;
|
|
579
|
+
const ptr1 = passArray8ToWasm0(required_did, wasm.__wbindgen_export);
|
|
580
|
+
const len1 = WASM_VECTOR_LEN;
|
|
581
|
+
wasm.proveCollectionMembership(retptr, addHeapObject(parent_spend), ptr0, len0, ptr1, len1);
|
|
582
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
583
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
584
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
585
|
+
if (r2) {
|
|
586
|
+
throw takeObject(r1);
|
|
587
|
+
}
|
|
588
|
+
return takeObject(r0);
|
|
589
|
+
} finally {
|
|
590
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
591
|
+
}
|
|
592
|
+
}
|
|
593
|
+
|
|
594
|
+
/**
|
|
595
|
+
* Prove an NFT (reconstructed from `parent_spend`, the coin spend that created its current coin) is
|
|
596
|
+
* owned by `claimed_owner_puzzle_hash`, optionally gating on a specific NFT launcher id (#46 NFT-
|
|
597
|
+
* gating). `parent_spend` is the wasm `CoinSpend` shape. Returns `{ ok, proof?, error? }` — on
|
|
598
|
+
* success `proof` is the `NftOwnershipProof` (launcher id, owner, attributed DID, current coin id);
|
|
599
|
+
* the caller still confirms `proof.nftCoinId` is unspent on-chain for liveness.
|
|
600
|
+
* @param {any} parent_spend
|
|
601
|
+
* @param {Uint8Array} claimed_owner_puzzle_hash
|
|
602
|
+
* @param {Uint8Array | null} [required_nft]
|
|
603
|
+
* @returns {any}
|
|
604
|
+
*/
|
|
605
|
+
export function proveNftOwnership(parent_spend, claimed_owner_puzzle_hash, required_nft) {
|
|
606
|
+
try {
|
|
607
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
608
|
+
const ptr0 = passArray8ToWasm0(claimed_owner_puzzle_hash, wasm.__wbindgen_export);
|
|
609
|
+
const len0 = WASM_VECTOR_LEN;
|
|
610
|
+
var ptr1 = isLikeNone(required_nft) ? 0 : passArray8ToWasm0(required_nft, wasm.__wbindgen_export);
|
|
611
|
+
var len1 = WASM_VECTOR_LEN;
|
|
612
|
+
wasm.proveNftOwnership(retptr, addHeapObject(parent_spend), ptr0, len0, ptr1, len1);
|
|
613
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
614
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
615
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
616
|
+
if (r2) {
|
|
617
|
+
throw takeObject(r1);
|
|
618
|
+
}
|
|
619
|
+
return takeObject(r0);
|
|
620
|
+
} finally {
|
|
621
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
622
|
+
}
|
|
623
|
+
}
|
|
624
|
+
|
|
625
|
+
/**
|
|
626
|
+
* Read an NFT's ownership facts (owner, attributed DID, launcher id, current coin id) from
|
|
627
|
+
* `parent_spend` WITHOUT applying a gate — for dapps that want to decide in their own code.
|
|
628
|
+
* Returns `{ ok, proof?, error? }`.
|
|
629
|
+
* @param {any} parent_spend
|
|
630
|
+
* @returns {any}
|
|
631
|
+
*/
|
|
632
|
+
export function readNftOwnership(parent_spend) {
|
|
633
|
+
try {
|
|
634
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
635
|
+
wasm.readNftOwnership(retptr, addHeapObject(parent_spend));
|
|
636
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
637
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
638
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
639
|
+
if (r2) {
|
|
640
|
+
throw takeObject(r1);
|
|
641
|
+
}
|
|
642
|
+
return takeObject(r0);
|
|
643
|
+
} finally {
|
|
644
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
645
|
+
}
|
|
646
|
+
}
|
|
647
|
+
|
|
423
648
|
/**
|
|
424
649
|
* SHA-256 of arbitrary bytes → 32-byte hash (the one true primitive for `data_hash`/
|
|
425
650
|
* `metadata_hash`/`license_hash`). Returns the raw 32 bytes (`Uint8Array`).
|
|
@@ -576,6 +801,66 @@ export function validateChip0007(metadata, assets) {
|
|
|
576
801
|
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
577
802
|
}
|
|
578
803
|
}
|
|
804
|
+
|
|
805
|
+
/**
|
|
806
|
+
* Verify an observed payment unlocks a paywall (#46 pay-to-unlock): it must pay `owner_puzzle_hash`,
|
|
807
|
+
* in `required_asset`, at least `min_amount`, and (when `require_nonce` is a 32-byte value) carry
|
|
808
|
+
* that nonce. `observed` is an `ObservedPayment` the dapp filled in after reading the owner's coin;
|
|
809
|
+
* `required_asset` is a `PaymentAsset` (`{xch:true}` or `{assetId}`). Returns `{ ok, error? }` —
|
|
810
|
+
* `ok:true` grants access, otherwise `error` is the human-readable denial reason.
|
|
811
|
+
* @param {any} observed
|
|
812
|
+
* @param {Uint8Array} owner_puzzle_hash
|
|
813
|
+
* @param {bigint} min_amount
|
|
814
|
+
* @param {any} required_asset
|
|
815
|
+
* @param {Uint8Array | null} [require_nonce]
|
|
816
|
+
* @returns {any}
|
|
817
|
+
*/
|
|
818
|
+
export function verifyPaymentReceipt(observed, owner_puzzle_hash, min_amount, required_asset, require_nonce) {
|
|
819
|
+
try {
|
|
820
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
821
|
+
const ptr0 = passArray8ToWasm0(owner_puzzle_hash, wasm.__wbindgen_export);
|
|
822
|
+
const len0 = WASM_VECTOR_LEN;
|
|
823
|
+
var ptr1 = isLikeNone(require_nonce) ? 0 : passArray8ToWasm0(require_nonce, wasm.__wbindgen_export);
|
|
824
|
+
var len1 = WASM_VECTOR_LEN;
|
|
825
|
+
wasm.verifyPaymentReceipt(retptr, addHeapObject(observed), ptr0, len0, min_amount, addHeapObject(required_asset), ptr1, len1);
|
|
826
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
827
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
828
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
829
|
+
if (r2) {
|
|
830
|
+
throw takeObject(r1);
|
|
831
|
+
}
|
|
832
|
+
return takeObject(r0);
|
|
833
|
+
} finally {
|
|
834
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
835
|
+
}
|
|
836
|
+
}
|
|
837
|
+
|
|
838
|
+
/**
|
|
839
|
+
* Build the **Writer** delegated puzzle for a 48-byte synthetic public key — a revocable deploy
|
|
840
|
+
* token (#17) or a hub Teams writer (#43). A writer may advance the root (deploy a new capsule)
|
|
841
|
+
* WITHOUT the owner seed, but may NOT change delegation or transfer ownership. Add it to a store
|
|
842
|
+
* to issue the token; replace the store's delegated set to revoke it. Returns a `DelegatedPuzzle`
|
|
843
|
+
* (`{ writerInnerPuzzleHash }`).
|
|
844
|
+
* @param {Uint8Array} synthetic_key
|
|
845
|
+
* @returns {any}
|
|
846
|
+
*/
|
|
847
|
+
export function writerDelegatedPuzzleFromKey(synthetic_key) {
|
|
848
|
+
try {
|
|
849
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
850
|
+
const ptr0 = passArray8ToWasm0(synthetic_key, wasm.__wbindgen_export);
|
|
851
|
+
const len0 = WASM_VECTOR_LEN;
|
|
852
|
+
wasm.writerDelegatedPuzzleFromKey(retptr, ptr0, len0);
|
|
853
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
854
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
855
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
856
|
+
if (r2) {
|
|
857
|
+
throw takeObject(r1);
|
|
858
|
+
}
|
|
859
|
+
return takeObject(r0);
|
|
860
|
+
} finally {
|
|
861
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
862
|
+
}
|
|
863
|
+
}
|
|
579
864
|
export function __wbg_Error_ef53bc310eb298a0(arg0, arg1) {
|
|
580
865
|
const ret = Error(getStringFromWasm0(arg0, arg1));
|
|
581
866
|
return addHeapObject(ret);
|
|
Binary file
|
package/package.json
CHANGED