zcashname-sdk 0.2.2 → 0.2.3

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/package.json CHANGED
@@ -1,16 +1,16 @@
1
1
  {
2
2
  "name": "zcashname-sdk",
3
- "version": "0.2.2",
3
+ "version": "0.2.3",
4
4
  "type": "module",
5
5
  "description": "TypeScript SDK for the Zcash Name System (ZNS) JSON-RPC API",
6
- "main": "dist/index.js",
7
- "module": "dist/index.mjs",
6
+ "main": "dist/index.cjs",
7
+ "module": "dist/index.js",
8
8
  "types": "dist/index.d.ts",
9
9
  "exports": {
10
10
  ".": {
11
11
  "types": "./dist/index.d.ts",
12
- "import": "./dist/index.mjs",
13
- "require": "./dist/index.js"
12
+ "import": "./dist/index.js",
13
+ "require": "./dist/index.cjs"
14
14
  }
15
15
  },
16
16
  "files": [
package/dist/index.d.mts DELETED
@@ -1,46 +0,0 @@
1
- interface Registration {
2
- name: string;
3
- address: string;
4
- txid: string;
5
- height: number;
6
- nonce: number;
7
- signature: string | null;
8
- }
9
- interface Listing {
10
- name: string;
11
- price: number;
12
- txid: string;
13
- height: number;
14
- signature: string;
15
- }
16
- interface ResolveResult extends Registration {
17
- listing: Listing | null;
18
- }
19
- interface ListForSaleResult {
20
- listings: Listing[];
21
- }
22
- interface StatusResult {
23
- synced_height: number;
24
- admin_pubkey: string;
25
- ufvk: string;
26
- registered: number;
27
- listed: number;
28
- }
29
- declare class ZNSError extends Error {
30
- code: number;
31
- constructor(code: number, message: string);
32
- }
33
- declare class ZNSClient {
34
- private url;
35
- private nextId;
36
- constructor(url?: string);
37
- /** Look up a ZNS name or Zcash address. Returns null if not found. */
38
- resolve(query: string): Promise<ResolveResult | null>;
39
- /** Get all names currently listed for sale. */
40
- listForSale(): Promise<Listing[]>;
41
- /** Get indexer status. */
42
- status(): Promise<StatusResult>;
43
- private call;
44
- }
45
-
46
- export { type ListForSaleResult, type Listing, type Registration, type ResolveResult, type StatusResult, ZNSClient, ZNSError, ZNSClient as default };
package/dist/index.mjs DELETED
@@ -1,51 +0,0 @@
1
- // src/index.ts
2
- var ZNSError = class extends Error {
3
- constructor(code, message) {
4
- super(message);
5
- this.code = code;
6
- this.name = "ZNSError";
7
- }
8
- };
9
- var ZNSClient = class {
10
- constructor(url = "http://127.0.0.1:3000") {
11
- this.nextId = 1;
12
- this.url = url;
13
- }
14
- /** Look up a ZNS name or Zcash address. Returns null if not found. */
15
- async resolve(query) {
16
- return this.call("resolve", { query });
17
- }
18
- /** Get all names currently listed for sale. */
19
- async listForSale() {
20
- const result = await this.call("list_for_sale", {});
21
- return result.listings;
22
- }
23
- /** Get indexer status. */
24
- async status() {
25
- return this.call("status", {});
26
- }
27
- // ── JSON-RPC transport ──────────────────────────────────────────────────
28
- async call(method, params) {
29
- const id = this.nextId++;
30
- const body = JSON.stringify({ jsonrpc: "2.0", id, method, params });
31
- const res = await fetch(this.url, {
32
- method: "POST",
33
- headers: { "Content-Type": "application/json" },
34
- body
35
- });
36
- if (!res.ok) {
37
- throw new ZNSError(-1, `HTTP ${res.status}: ${res.statusText}`);
38
- }
39
- const json = await res.json();
40
- if (json.error) {
41
- throw new ZNSError(json.error.code, json.error.message);
42
- }
43
- return json.result;
44
- }
45
- };
46
- var index_default = ZNSClient;
47
- export {
48
- ZNSClient,
49
- ZNSError,
50
- index_default as default
51
- };