zcashname-sdk 0.7.2 → 0.8.1
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/README.md +1 -0
- package/dist/zns.cjs +40 -8
- package/dist/zns.d.cts +31 -3
- package/dist/zns.d.ts +31 -3
- package/dist/zns.js +38 -8
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -67,6 +67,7 @@ console.log("Memo:", memo);
|
|
|
67
67
|
| `prepareUpdate(name, newAddress, nonce, registryAddress)` | Change address |
|
|
68
68
|
| `prepareBuy(name, buyerAddress, registryAddress)` | Buy a listed name |
|
|
69
69
|
| `prepareRelease(name, nonce, registryAddress)` | Release name (burn) |
|
|
70
|
+
| `prepareSetPrice(prices, nonce, registryAddress)` | Admin: set pricing tiers |
|
|
70
71
|
|
|
71
72
|
## Reading Data
|
|
72
73
|
|
package/dist/zns.cjs
CHANGED
|
@@ -30,7 +30,9 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
30
30
|
// src/zns.ts
|
|
31
31
|
var zns_exports = {};
|
|
32
32
|
__export(zns_exports, {
|
|
33
|
+
BUY_COMMISSION: () => BUY_COMMISSION,
|
|
33
34
|
DEFAULT_URL: () => DEFAULT_URL,
|
|
35
|
+
LIST_COMMISSION: () => LIST_COMMISSION,
|
|
34
36
|
MAINNET_UIVK: () => MAINNET_UIVK,
|
|
35
37
|
TESTNET_UIVK: () => TESTNET_UIVK,
|
|
36
38
|
ZNS: () => ZNS
|
|
@@ -38,6 +40,12 @@ __export(zns_exports, {
|
|
|
38
40
|
module.exports = __toCommonJS(zns_exports);
|
|
39
41
|
var ed25519 = __toESM(require("@noble/ed25519"), 1);
|
|
40
42
|
var import_bech32 = require("bech32");
|
|
43
|
+
|
|
44
|
+
// src/types.ts
|
|
45
|
+
var BUY_COMMISSION = 1e4;
|
|
46
|
+
var LIST_COMMISSION = 1e6;
|
|
47
|
+
|
|
48
|
+
// src/zns.ts
|
|
41
49
|
var DEFAULT_URL = "https://light.zcash.me/zns-testnet";
|
|
42
50
|
var TESTNET_UIVK = "uivktest1hzw7wyadutvzfgpna80yftsk5l7jeyu2p5me5quvp28tytxueta00cx4068wnlzcv7tx9n3t3gfhsy83pe4y6jrhxtzaq0hj6xtg5zrk2dn7zen3vns2a5pgs4fxdjlletmqrhfa42";
|
|
43
51
|
var MAINNET_UIVK = "uivk1gl26qy0xjja7lqhyg3pf0x4j4j66kqwewrjkdcg28eqq4wgtzjmujpee7x9cs2ec9xhnlgrm8ptlw8z80j2aryw8nqtssser2ys778a0s00uvgkdjnfr58sndhfvc3f4zqjs6ywva6";
|
|
@@ -154,7 +162,7 @@ var ZNS = class {
|
|
|
154
162
|
*/
|
|
155
163
|
async verifyListing(listing, adminPubkey) {
|
|
156
164
|
const pubkey = listing.pubkey ?? adminPubkey;
|
|
157
|
-
const payload = `LIST:${listing.name}:${listing.price}:${listing.nonce}`;
|
|
165
|
+
const payload = `LIST:${listing.name}:${listing.price}:${listing.pay_taddr}:${listing.nonce}`;
|
|
158
166
|
return this.verifyEd25519(payload, listing.signature, pubkey);
|
|
159
167
|
}
|
|
160
168
|
/**
|
|
@@ -185,6 +193,15 @@ var ZNS = class {
|
|
|
185
193
|
const idx = Math.min(Math.max(nameLength - 1, 0), pricing.tiers.length - 1);
|
|
186
194
|
return pricing.tiers[idx];
|
|
187
195
|
}
|
|
196
|
+
/**
|
|
197
|
+
* Get the listing commission in zatoshis (10% of the minimum pricing tier).
|
|
198
|
+
* @param pricing The pricing configuration - obtain from {@link status}
|
|
199
|
+
* @returns The commission in zatoshis, or null if pricing is unavailable
|
|
200
|
+
*/
|
|
201
|
+
listCommission(pricing) {
|
|
202
|
+
if (pricing.tiers.length === 0) return null;
|
|
203
|
+
return Math.min(...pricing.tiers) * 0.1;
|
|
204
|
+
}
|
|
188
205
|
/** Parse a ZIP-321 URI into its components. */
|
|
189
206
|
parseZip321Uri(uri) {
|
|
190
207
|
const withoutScheme = String(uri ?? "").replace(/^zcash:/i, "");
|
|
@@ -221,16 +238,17 @@ var ZNS = class {
|
|
|
221
238
|
}
|
|
222
239
|
};
|
|
223
240
|
}
|
|
224
|
-
prepareList(name, price, nonce) {
|
|
241
|
+
prepareList(name, price, pay_taddr, nonce) {
|
|
225
242
|
this.requireValidName(name);
|
|
226
243
|
return {
|
|
227
244
|
name,
|
|
228
245
|
price,
|
|
246
|
+
pay_taddr,
|
|
229
247
|
nonce,
|
|
230
|
-
payload: `LIST:${name}:${price}:${nonce}`,
|
|
248
|
+
payload: `LIST:${name}:${price}:${pay_taddr}:${nonce}`,
|
|
231
249
|
complete: (signature, userPubkey) => {
|
|
232
|
-
const memo = userPubkey ? `ZNS:LIST:${name}:${price}:${nonce}:${signature}:${userPubkey}` : `ZNS:LIST:${name}:${price}:${nonce}:${signature}`;
|
|
233
|
-
return { memo, uri: this.buildZcashUri(this.registryAddress,
|
|
250
|
+
const memo = userPubkey ? `ZNS:LIST:${name}:${price}:${pay_taddr}:${nonce}:${signature}:${userPubkey}` : `ZNS:LIST:${name}:${price}:${pay_taddr}:${nonce}:${signature}`;
|
|
251
|
+
return { memo, uri: this.buildZcashUri(this.registryAddress, LIST_COMMISSION, memo) };
|
|
234
252
|
}
|
|
235
253
|
};
|
|
236
254
|
}
|
|
@@ -262,7 +280,7 @@ var ZNS = class {
|
|
|
262
280
|
}
|
|
263
281
|
};
|
|
264
282
|
}
|
|
265
|
-
prepareBuy(name, buyerAddress) {
|
|
283
|
+
prepareBuy(name, buyerAddress, price) {
|
|
266
284
|
this.requireValidName(name);
|
|
267
285
|
if (!this.isValidUnifiedAddress(buyerAddress)) {
|
|
268
286
|
throw new Error(`Invalid Zcash Unified Address: ${buyerAddress}`);
|
|
@@ -270,10 +288,11 @@ var ZNS = class {
|
|
|
270
288
|
return {
|
|
271
289
|
name,
|
|
272
290
|
buyerAddress,
|
|
291
|
+
price,
|
|
273
292
|
payload: `BUY:${name}:${buyerAddress}`,
|
|
274
293
|
complete: (signature, userPubkey) => {
|
|
275
|
-
const memo = userPubkey ? `ZNS:BUY:${name}:${buyerAddress}:${signature}:${userPubkey}` : `ZNS:BUY:${name}:${buyerAddress}:${signature}`;
|
|
276
|
-
return { memo, uri: this.buildZcashUri(this.registryAddress,
|
|
294
|
+
const memo = userPubkey ? `ZNS:BUY:${name}:${buyerAddress}:${price}:${signature}:${userPubkey}` : `ZNS:BUY:${name}:${buyerAddress}:${price}:${signature}`;
|
|
295
|
+
return { memo, uri: this.buildZcashUri(this.registryAddress, BUY_COMMISSION, memo) };
|
|
277
296
|
}
|
|
278
297
|
};
|
|
279
298
|
}
|
|
@@ -289,6 +308,17 @@ var ZNS = class {
|
|
|
289
308
|
}
|
|
290
309
|
};
|
|
291
310
|
}
|
|
311
|
+
prepareSetPrice(prices, nonce) {
|
|
312
|
+
return {
|
|
313
|
+
prices,
|
|
314
|
+
nonce,
|
|
315
|
+
payload: `SETPRICE:${prices.length}:${prices.join(":")}:${nonce}`,
|
|
316
|
+
complete: (signature) => {
|
|
317
|
+
const memo = `ZNS:SETPRICE:${prices.length}:${prices.join(":")}:${nonce}:${signature}`;
|
|
318
|
+
return { memo, uri: this.buildZcashUri(this.registryAddress, void 0, memo) };
|
|
319
|
+
}
|
|
320
|
+
};
|
|
321
|
+
}
|
|
292
322
|
// ── Private helpers ────────────────────────────────────────────────────────
|
|
293
323
|
registrationPayload(reg) {
|
|
294
324
|
switch (reg.last_action) {
|
|
@@ -381,7 +411,9 @@ var ZNS = class {
|
|
|
381
411
|
};
|
|
382
412
|
// Annotate the CommonJS export names for ESM import in node:
|
|
383
413
|
0 && (module.exports = {
|
|
414
|
+
BUY_COMMISSION,
|
|
384
415
|
DEFAULT_URL,
|
|
416
|
+
LIST_COMMISSION,
|
|
385
417
|
MAINNET_UIVK,
|
|
386
418
|
TESTNET_UIVK,
|
|
387
419
|
ZNS
|
package/dist/zns.d.cts
CHANGED
|
@@ -2,6 +2,11 @@
|
|
|
2
2
|
* All monetary values in ZNS are denominated in zats.
|
|
3
3
|
* Note: JavaScript number precision degrades above 2^53 (~9e15 zats, or ~90M ZEC) */
|
|
4
4
|
type Zats = number;
|
|
5
|
+
/** Commission sent with a BUY claim memo (0.0001 ZEC = 10,000 zats). */
|
|
6
|
+
declare const BUY_COMMISSION: Zats;
|
|
7
|
+
/** Listing commission sent with a LIST memo (0.01 ZEC = 1,000,000 zats).
|
|
8
|
+
* Mirrors the indexer's formula: min_tier × 1000. */
|
|
9
|
+
declare const LIST_COMMISSION: Zats;
|
|
5
10
|
interface Registration {
|
|
6
11
|
name: string;
|
|
7
12
|
address: string;
|
|
@@ -20,11 +25,20 @@ type EventAction = "CLAIM" | "LIST" | "DELIST" | "RELEASE" | "UPDATE" | "BUY" |
|
|
|
20
25
|
interface Listing {
|
|
21
26
|
name: string;
|
|
22
27
|
price: Zats;
|
|
28
|
+
pay_taddr: string;
|
|
23
29
|
nonce: number;
|
|
24
30
|
txid: string;
|
|
25
31
|
height: number;
|
|
26
32
|
signature: string;
|
|
27
33
|
pubkey: string | null;
|
|
34
|
+
pending_buy: PendingBuy | null;
|
|
35
|
+
}
|
|
36
|
+
interface PendingBuy {
|
|
37
|
+
buyer_ua: string;
|
|
38
|
+
price: Zats;
|
|
39
|
+
claim_height: number;
|
|
40
|
+
expires_at: number;
|
|
41
|
+
txid: string;
|
|
28
42
|
}
|
|
29
43
|
interface Pricing {
|
|
30
44
|
nonce: number;
|
|
@@ -89,6 +103,7 @@ interface PreparedClaim extends PreparedAction {
|
|
|
89
103
|
interface PreparedList extends PreparedAction {
|
|
90
104
|
readonly name: string;
|
|
91
105
|
readonly price: Zats;
|
|
106
|
+
readonly pay_taddr: string;
|
|
92
107
|
readonly nonce: number;
|
|
93
108
|
}
|
|
94
109
|
/** Prepared DELIST action */
|
|
@@ -106,12 +121,18 @@ interface PreparedUpdate extends PreparedAction {
|
|
|
106
121
|
interface PreparedBuy extends PreparedAction {
|
|
107
122
|
readonly name: string;
|
|
108
123
|
readonly buyerAddress: string;
|
|
124
|
+
readonly price: Zats;
|
|
109
125
|
}
|
|
110
126
|
/** Prepared RELEASE action */
|
|
111
127
|
interface PreparedRelease extends PreparedAction {
|
|
112
128
|
readonly name: string;
|
|
113
129
|
readonly nonce: number;
|
|
114
130
|
}
|
|
131
|
+
/** Prepared SETPRICE action (admin only) */
|
|
132
|
+
interface PreparedSetPrice extends PreparedAction {
|
|
133
|
+
readonly prices: readonly Zats[];
|
|
134
|
+
readonly nonce: number;
|
|
135
|
+
}
|
|
115
136
|
|
|
116
137
|
declare const DEFAULT_URL = "https://light.zcash.me/zns-testnet";
|
|
117
138
|
declare const TESTNET_UIVK = "uivktest1hzw7wyadutvzfgpna80yftsk5l7jeyu2p5me5quvp28tytxueta00cx4068wnlzcv7tx9n3t3gfhsy83pe4y6jrhxtzaq0hj6xtg5zrk2dn7zen3vns2a5pgs4fxdjlletmqrhfa42";
|
|
@@ -187,6 +208,12 @@ declare class ZNS {
|
|
|
187
208
|
* @returns The cost in zatoshis, or null if pricing is unavailable
|
|
188
209
|
*/
|
|
189
210
|
claimCost(nameLength: number, pricing: Pricing): Zats | null;
|
|
211
|
+
/**
|
|
212
|
+
* Get the listing commission in zatoshis (10% of the minimum pricing tier).
|
|
213
|
+
* @param pricing The pricing configuration - obtain from {@link status}
|
|
214
|
+
* @returns The commission in zatoshis, or null if pricing is unavailable
|
|
215
|
+
*/
|
|
216
|
+
listCommission(pricing: Pricing): Zats | null;
|
|
190
217
|
/** Parse a ZIP-321 URI into its components. */
|
|
191
218
|
parseZip321Uri(uri: string): {
|
|
192
219
|
address: string;
|
|
@@ -202,11 +229,12 @@ declare class ZNS {
|
|
|
202
229
|
* @returns Prepared claim ready for signature completion
|
|
203
230
|
*/
|
|
204
231
|
prepareClaim(name: string, address: string, cost: Zats): PreparedClaim;
|
|
205
|
-
prepareList(name: string, price: Zats, nonce: number): PreparedList;
|
|
232
|
+
prepareList(name: string, price: Zats, pay_taddr: string, nonce: number): PreparedList;
|
|
206
233
|
prepareDelist(name: string, nonce: number): PreparedDelist;
|
|
207
234
|
prepareUpdate(name: string, newAddress: string, nonce: number): PreparedUpdate;
|
|
208
|
-
prepareBuy(name: string, buyerAddress: string): PreparedBuy;
|
|
235
|
+
prepareBuy(name: string, buyerAddress: string, price: Zats): PreparedBuy;
|
|
209
236
|
prepareRelease(name: string, nonce: number): PreparedRelease;
|
|
237
|
+
prepareSetPrice(prices: Zats[], nonce: number): PreparedSetPrice;
|
|
210
238
|
private registrationPayload;
|
|
211
239
|
private verifyEd25519;
|
|
212
240
|
private requireValidName;
|
|
@@ -218,4 +246,4 @@ declare class ZNS {
|
|
|
218
246
|
private rpc;
|
|
219
247
|
}
|
|
220
248
|
|
|
221
|
-
export { type CompletedAction, DEFAULT_URL, type Event, type EventAction, type EventsFilter, type EventsResult, type LastAction, type Listing, MAINNET_UIVK, type Network, type PreparedBuy, type PreparedClaim, type PreparedDelist, type PreparedList, type PreparedRelease, type PreparedUpdate, type Pricing, type Registration, type Status, TESTNET_UIVK, ZNS, type Zats };
|
|
249
|
+
export { BUY_COMMISSION, type CompletedAction, DEFAULT_URL, type Event, type EventAction, type EventsFilter, type EventsResult, LIST_COMMISSION, type LastAction, type Listing, MAINNET_UIVK, type Network, type PendingBuy, type PreparedBuy, type PreparedClaim, type PreparedDelist, type PreparedList, type PreparedRelease, type PreparedSetPrice, type PreparedUpdate, type Pricing, type Registration, type Status, TESTNET_UIVK, ZNS, type Zats };
|
package/dist/zns.d.ts
CHANGED
|
@@ -2,6 +2,11 @@
|
|
|
2
2
|
* All monetary values in ZNS are denominated in zats.
|
|
3
3
|
* Note: JavaScript number precision degrades above 2^53 (~9e15 zats, or ~90M ZEC) */
|
|
4
4
|
type Zats = number;
|
|
5
|
+
/** Commission sent with a BUY claim memo (0.0001 ZEC = 10,000 zats). */
|
|
6
|
+
declare const BUY_COMMISSION: Zats;
|
|
7
|
+
/** Listing commission sent with a LIST memo (0.01 ZEC = 1,000,000 zats).
|
|
8
|
+
* Mirrors the indexer's formula: min_tier × 1000. */
|
|
9
|
+
declare const LIST_COMMISSION: Zats;
|
|
5
10
|
interface Registration {
|
|
6
11
|
name: string;
|
|
7
12
|
address: string;
|
|
@@ -20,11 +25,20 @@ type EventAction = "CLAIM" | "LIST" | "DELIST" | "RELEASE" | "UPDATE" | "BUY" |
|
|
|
20
25
|
interface Listing {
|
|
21
26
|
name: string;
|
|
22
27
|
price: Zats;
|
|
28
|
+
pay_taddr: string;
|
|
23
29
|
nonce: number;
|
|
24
30
|
txid: string;
|
|
25
31
|
height: number;
|
|
26
32
|
signature: string;
|
|
27
33
|
pubkey: string | null;
|
|
34
|
+
pending_buy: PendingBuy | null;
|
|
35
|
+
}
|
|
36
|
+
interface PendingBuy {
|
|
37
|
+
buyer_ua: string;
|
|
38
|
+
price: Zats;
|
|
39
|
+
claim_height: number;
|
|
40
|
+
expires_at: number;
|
|
41
|
+
txid: string;
|
|
28
42
|
}
|
|
29
43
|
interface Pricing {
|
|
30
44
|
nonce: number;
|
|
@@ -89,6 +103,7 @@ interface PreparedClaim extends PreparedAction {
|
|
|
89
103
|
interface PreparedList extends PreparedAction {
|
|
90
104
|
readonly name: string;
|
|
91
105
|
readonly price: Zats;
|
|
106
|
+
readonly pay_taddr: string;
|
|
92
107
|
readonly nonce: number;
|
|
93
108
|
}
|
|
94
109
|
/** Prepared DELIST action */
|
|
@@ -106,12 +121,18 @@ interface PreparedUpdate extends PreparedAction {
|
|
|
106
121
|
interface PreparedBuy extends PreparedAction {
|
|
107
122
|
readonly name: string;
|
|
108
123
|
readonly buyerAddress: string;
|
|
124
|
+
readonly price: Zats;
|
|
109
125
|
}
|
|
110
126
|
/** Prepared RELEASE action */
|
|
111
127
|
interface PreparedRelease extends PreparedAction {
|
|
112
128
|
readonly name: string;
|
|
113
129
|
readonly nonce: number;
|
|
114
130
|
}
|
|
131
|
+
/** Prepared SETPRICE action (admin only) */
|
|
132
|
+
interface PreparedSetPrice extends PreparedAction {
|
|
133
|
+
readonly prices: readonly Zats[];
|
|
134
|
+
readonly nonce: number;
|
|
135
|
+
}
|
|
115
136
|
|
|
116
137
|
declare const DEFAULT_URL = "https://light.zcash.me/zns-testnet";
|
|
117
138
|
declare const TESTNET_UIVK = "uivktest1hzw7wyadutvzfgpna80yftsk5l7jeyu2p5me5quvp28tytxueta00cx4068wnlzcv7tx9n3t3gfhsy83pe4y6jrhxtzaq0hj6xtg5zrk2dn7zen3vns2a5pgs4fxdjlletmqrhfa42";
|
|
@@ -187,6 +208,12 @@ declare class ZNS {
|
|
|
187
208
|
* @returns The cost in zatoshis, or null if pricing is unavailable
|
|
188
209
|
*/
|
|
189
210
|
claimCost(nameLength: number, pricing: Pricing): Zats | null;
|
|
211
|
+
/**
|
|
212
|
+
* Get the listing commission in zatoshis (10% of the minimum pricing tier).
|
|
213
|
+
* @param pricing The pricing configuration - obtain from {@link status}
|
|
214
|
+
* @returns The commission in zatoshis, or null if pricing is unavailable
|
|
215
|
+
*/
|
|
216
|
+
listCommission(pricing: Pricing): Zats | null;
|
|
190
217
|
/** Parse a ZIP-321 URI into its components. */
|
|
191
218
|
parseZip321Uri(uri: string): {
|
|
192
219
|
address: string;
|
|
@@ -202,11 +229,12 @@ declare class ZNS {
|
|
|
202
229
|
* @returns Prepared claim ready for signature completion
|
|
203
230
|
*/
|
|
204
231
|
prepareClaim(name: string, address: string, cost: Zats): PreparedClaim;
|
|
205
|
-
prepareList(name: string, price: Zats, nonce: number): PreparedList;
|
|
232
|
+
prepareList(name: string, price: Zats, pay_taddr: string, nonce: number): PreparedList;
|
|
206
233
|
prepareDelist(name: string, nonce: number): PreparedDelist;
|
|
207
234
|
prepareUpdate(name: string, newAddress: string, nonce: number): PreparedUpdate;
|
|
208
|
-
prepareBuy(name: string, buyerAddress: string): PreparedBuy;
|
|
235
|
+
prepareBuy(name: string, buyerAddress: string, price: Zats): PreparedBuy;
|
|
209
236
|
prepareRelease(name: string, nonce: number): PreparedRelease;
|
|
237
|
+
prepareSetPrice(prices: Zats[], nonce: number): PreparedSetPrice;
|
|
210
238
|
private registrationPayload;
|
|
211
239
|
private verifyEd25519;
|
|
212
240
|
private requireValidName;
|
|
@@ -218,4 +246,4 @@ declare class ZNS {
|
|
|
218
246
|
private rpc;
|
|
219
247
|
}
|
|
220
248
|
|
|
221
|
-
export { type CompletedAction, DEFAULT_URL, type Event, type EventAction, type EventsFilter, type EventsResult, type LastAction, type Listing, MAINNET_UIVK, type Network, type PreparedBuy, type PreparedClaim, type PreparedDelist, type PreparedList, type PreparedRelease, type PreparedUpdate, type Pricing, type Registration, type Status, TESTNET_UIVK, ZNS, type Zats };
|
|
249
|
+
export { BUY_COMMISSION, type CompletedAction, DEFAULT_URL, type Event, type EventAction, type EventsFilter, type EventsResult, LIST_COMMISSION, type LastAction, type Listing, MAINNET_UIVK, type Network, type PendingBuy, type PreparedBuy, type PreparedClaim, type PreparedDelist, type PreparedList, type PreparedRelease, type PreparedSetPrice, type PreparedUpdate, type Pricing, type Registration, type Status, TESTNET_UIVK, ZNS, type Zats };
|
package/dist/zns.js
CHANGED
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
// src/zns.ts
|
|
2
2
|
import * as ed25519 from "@noble/ed25519";
|
|
3
3
|
import { bech32m } from "bech32";
|
|
4
|
+
|
|
5
|
+
// src/types.ts
|
|
6
|
+
var BUY_COMMISSION = 1e4;
|
|
7
|
+
var LIST_COMMISSION = 1e6;
|
|
8
|
+
|
|
9
|
+
// src/zns.ts
|
|
4
10
|
var DEFAULT_URL = "https://light.zcash.me/zns-testnet";
|
|
5
11
|
var TESTNET_UIVK = "uivktest1hzw7wyadutvzfgpna80yftsk5l7jeyu2p5me5quvp28tytxueta00cx4068wnlzcv7tx9n3t3gfhsy83pe4y6jrhxtzaq0hj6xtg5zrk2dn7zen3vns2a5pgs4fxdjlletmqrhfa42";
|
|
6
12
|
var MAINNET_UIVK = "uivk1gl26qy0xjja7lqhyg3pf0x4j4j66kqwewrjkdcg28eqq4wgtzjmujpee7x9cs2ec9xhnlgrm8ptlw8z80j2aryw8nqtssser2ys778a0s00uvgkdjnfr58sndhfvc3f4zqjs6ywva6";
|
|
@@ -117,7 +123,7 @@ var ZNS = class {
|
|
|
117
123
|
*/
|
|
118
124
|
async verifyListing(listing, adminPubkey) {
|
|
119
125
|
const pubkey = listing.pubkey ?? adminPubkey;
|
|
120
|
-
const payload = `LIST:${listing.name}:${listing.price}:${listing.nonce}`;
|
|
126
|
+
const payload = `LIST:${listing.name}:${listing.price}:${listing.pay_taddr}:${listing.nonce}`;
|
|
121
127
|
return this.verifyEd25519(payload, listing.signature, pubkey);
|
|
122
128
|
}
|
|
123
129
|
/**
|
|
@@ -148,6 +154,15 @@ var ZNS = class {
|
|
|
148
154
|
const idx = Math.min(Math.max(nameLength - 1, 0), pricing.tiers.length - 1);
|
|
149
155
|
return pricing.tiers[idx];
|
|
150
156
|
}
|
|
157
|
+
/**
|
|
158
|
+
* Get the listing commission in zatoshis (10% of the minimum pricing tier).
|
|
159
|
+
* @param pricing The pricing configuration - obtain from {@link status}
|
|
160
|
+
* @returns The commission in zatoshis, or null if pricing is unavailable
|
|
161
|
+
*/
|
|
162
|
+
listCommission(pricing) {
|
|
163
|
+
if (pricing.tiers.length === 0) return null;
|
|
164
|
+
return Math.min(...pricing.tiers) * 0.1;
|
|
165
|
+
}
|
|
151
166
|
/** Parse a ZIP-321 URI into its components. */
|
|
152
167
|
parseZip321Uri(uri) {
|
|
153
168
|
const withoutScheme = String(uri ?? "").replace(/^zcash:/i, "");
|
|
@@ -184,16 +199,17 @@ var ZNS = class {
|
|
|
184
199
|
}
|
|
185
200
|
};
|
|
186
201
|
}
|
|
187
|
-
prepareList(name, price, nonce) {
|
|
202
|
+
prepareList(name, price, pay_taddr, nonce) {
|
|
188
203
|
this.requireValidName(name);
|
|
189
204
|
return {
|
|
190
205
|
name,
|
|
191
206
|
price,
|
|
207
|
+
pay_taddr,
|
|
192
208
|
nonce,
|
|
193
|
-
payload: `LIST:${name}:${price}:${nonce}`,
|
|
209
|
+
payload: `LIST:${name}:${price}:${pay_taddr}:${nonce}`,
|
|
194
210
|
complete: (signature, userPubkey) => {
|
|
195
|
-
const memo = userPubkey ? `ZNS:LIST:${name}:${price}:${nonce}:${signature}:${userPubkey}` : `ZNS:LIST:${name}:${price}:${nonce}:${signature}`;
|
|
196
|
-
return { memo, uri: this.buildZcashUri(this.registryAddress,
|
|
211
|
+
const memo = userPubkey ? `ZNS:LIST:${name}:${price}:${pay_taddr}:${nonce}:${signature}:${userPubkey}` : `ZNS:LIST:${name}:${price}:${pay_taddr}:${nonce}:${signature}`;
|
|
212
|
+
return { memo, uri: this.buildZcashUri(this.registryAddress, LIST_COMMISSION, memo) };
|
|
197
213
|
}
|
|
198
214
|
};
|
|
199
215
|
}
|
|
@@ -225,7 +241,7 @@ var ZNS = class {
|
|
|
225
241
|
}
|
|
226
242
|
};
|
|
227
243
|
}
|
|
228
|
-
prepareBuy(name, buyerAddress) {
|
|
244
|
+
prepareBuy(name, buyerAddress, price) {
|
|
229
245
|
this.requireValidName(name);
|
|
230
246
|
if (!this.isValidUnifiedAddress(buyerAddress)) {
|
|
231
247
|
throw new Error(`Invalid Zcash Unified Address: ${buyerAddress}`);
|
|
@@ -233,10 +249,11 @@ var ZNS = class {
|
|
|
233
249
|
return {
|
|
234
250
|
name,
|
|
235
251
|
buyerAddress,
|
|
252
|
+
price,
|
|
236
253
|
payload: `BUY:${name}:${buyerAddress}`,
|
|
237
254
|
complete: (signature, userPubkey) => {
|
|
238
|
-
const memo = userPubkey ? `ZNS:BUY:${name}:${buyerAddress}:${signature}:${userPubkey}` : `ZNS:BUY:${name}:${buyerAddress}:${signature}`;
|
|
239
|
-
return { memo, uri: this.buildZcashUri(this.registryAddress,
|
|
255
|
+
const memo = userPubkey ? `ZNS:BUY:${name}:${buyerAddress}:${price}:${signature}:${userPubkey}` : `ZNS:BUY:${name}:${buyerAddress}:${price}:${signature}`;
|
|
256
|
+
return { memo, uri: this.buildZcashUri(this.registryAddress, BUY_COMMISSION, memo) };
|
|
240
257
|
}
|
|
241
258
|
};
|
|
242
259
|
}
|
|
@@ -252,6 +269,17 @@ var ZNS = class {
|
|
|
252
269
|
}
|
|
253
270
|
};
|
|
254
271
|
}
|
|
272
|
+
prepareSetPrice(prices, nonce) {
|
|
273
|
+
return {
|
|
274
|
+
prices,
|
|
275
|
+
nonce,
|
|
276
|
+
payload: `SETPRICE:${prices.length}:${prices.join(":")}:${nonce}`,
|
|
277
|
+
complete: (signature) => {
|
|
278
|
+
const memo = `ZNS:SETPRICE:${prices.length}:${prices.join(":")}:${nonce}:${signature}`;
|
|
279
|
+
return { memo, uri: this.buildZcashUri(this.registryAddress, void 0, memo) };
|
|
280
|
+
}
|
|
281
|
+
};
|
|
282
|
+
}
|
|
255
283
|
// ── Private helpers ────────────────────────────────────────────────────────
|
|
256
284
|
registrationPayload(reg) {
|
|
257
285
|
switch (reg.last_action) {
|
|
@@ -343,7 +371,9 @@ var ZNS = class {
|
|
|
343
371
|
}
|
|
344
372
|
};
|
|
345
373
|
export {
|
|
374
|
+
BUY_COMMISSION,
|
|
346
375
|
DEFAULT_URL,
|
|
376
|
+
LIST_COMMISSION,
|
|
347
377
|
MAINNET_UIVK,
|
|
348
378
|
TESTNET_UIVK,
|
|
349
379
|
ZNS
|