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