@quicknode/sdk 2.6.0 → 3.0.0-alpha.6

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.
Files changed (47) hide show
  1. package/README.md +3500 -46
  2. package/browser.js +9 -0
  3. package/errors.js +121 -0
  4. package/index.d.ts +2298 -650
  5. package/index.darwin-arm64.node +0 -0
  6. package/index.js +328 -0
  7. package/index.linux-arm64-gnu.node +0 -0
  8. package/index.linux-arm64-musl.node +0 -0
  9. package/index.linux-x64-gnu.node +0 -0
  10. package/index.linux-x64-musl.node +0 -0
  11. package/package.json +47 -54
  12. package/sdk.d.ts +339 -0
  13. package/sdk.js +102 -0
  14. package/sdk.mjs +34 -0
  15. package/cjs/index.js +0 -542
  16. package/cjs/package.json +0 -3
  17. package/esm/client/client.js +0 -9
  18. package/esm/client/index.js +0 -2
  19. package/esm/core/addOns/nftTokenV2/actions.js +0 -107
  20. package/esm/core/addOns/nftTokenV2/types/qn_fetchNFTCollectionDetails.js +0 -10
  21. package/esm/core/addOns/nftTokenV2/types/qn_fetchNFTs.js +0 -13
  22. package/esm/core/addOns/nftTokenV2/types/qn_fetchNFTsByCollection.js +0 -13
  23. package/esm/core/addOns/nftTokenV2/types/qn_getTokenMetadataByContractAddress.js +0 -10
  24. package/esm/core/addOns/nftTokenV2/types/qn_getTokenMetadataBySymbol.js +0 -11
  25. package/esm/core/addOns/nftTokenV2/types/qn_getTransactionsByAddress.js +0 -18
  26. package/esm/core/addOns/nftTokenV2/types/qn_getTransfersByNFT.js +0 -12
  27. package/esm/core/addOns/nftTokenV2/types/qn_getWalletTokenBalance.js +0 -12
  28. package/esm/core/addOns/nftTokenV2/types/qn_getWalletTokenTransactions.js +0 -14
  29. package/esm/core/addOns/nftTokenV2/types/qn_verifyNFTsOwner.js +0 -11
  30. package/esm/core/addOns/shared/helpers.js +0 -10
  31. package/esm/core/chains.js +0 -118
  32. package/esm/core/core.js +0 -30
  33. package/esm/core/index.d.ts +0 -558
  34. package/esm/core/index.js +0 -2
  35. package/esm/index.js +0 -11
  36. package/esm/lib/constants.js +0 -4
  37. package/esm/lib/errors/QNChainNotSupported.js +0 -7
  38. package/esm/lib/errors/QNInputValidationError.js +0 -10
  39. package/esm/lib/errors/QNInvalidEnpointUrl.js +0 -7
  40. package/esm/lib/helpers/getClientHeaders.js +0 -11
  41. package/esm/lib/helpers/globalFetch.js +0 -13
  42. package/esm/lib/validation/ValidateInput.js +0 -16
  43. package/esm/lib/validation/validators.js +0 -15
  44. package/esm/package.json +0 -4
  45. package/esm/solana/index.d.ts +0 -76
  46. package/esm/solana/index.js +0 -2
  47. package/esm/solana/solana.js +0 -111
package/browser.js ADDED
@@ -0,0 +1,9 @@
1
+ // Native Node.js bindings (.node files compiled from Rust) cannot run in
2
+ // browser environments — they are binary extensions that require the Node.js
3
+ // runtime and OS-level dynamic linking. Bundlers (Webpack, Vite, etc.) that
4
+ // encounter this package in a browser target will load this shim instead,
5
+ // producing a clear error rather than a cryptic binary load failure.
6
+ throw new Error(
7
+ '@quicknode/sdk does not support browser environments. ' +
8
+ 'This package requires Node.js.'
9
+ );
package/errors.js ADDED
@@ -0,0 +1,121 @@
1
+ // Typed error classes. The Rust binding throws a plain napi Error whose
2
+ // message is tagged "[<kind>|<status>|<body_len>]<msg>\x1f<body>"; parseAndRethrow
3
+ // decodes that and throws an instance of the matching subclass below.
4
+
5
+ class QuickNodeError extends Error {
6
+ constructor(message) {
7
+ super(message);
8
+ this.name = "QuickNodeError";
9
+ }
10
+ }
11
+
12
+ class ConfigError extends QuickNodeError {
13
+ constructor(message) {
14
+ super(message);
15
+ this.name = "ConfigError";
16
+ }
17
+ }
18
+
19
+ class HttpError extends QuickNodeError {
20
+ constructor(message) {
21
+ super(message);
22
+ this.name = "HttpError";
23
+ }
24
+ }
25
+
26
+ class TimeoutError extends HttpError {
27
+ constructor(message) {
28
+ super(message);
29
+ this.name = "TimeoutError";
30
+ }
31
+ }
32
+
33
+ class ConnectionError extends HttpError {
34
+ constructor(message) {
35
+ super(message);
36
+ this.name = "ConnectionError";
37
+ }
38
+ }
39
+
40
+ class ApiError extends QuickNodeError {
41
+ constructor(message, status, body) {
42
+ super(message);
43
+ this.name = "ApiError";
44
+ this.status = status;
45
+ this.body = body;
46
+ }
47
+ }
48
+
49
+ class DecodeError extends QuickNodeError {
50
+ constructor(message, body) {
51
+ super(message);
52
+ this.name = "DecodeError";
53
+ this.body = body;
54
+ }
55
+ }
56
+
57
+ const TAG_RE = /^\[(Config|Http|Timeout|Connect|Api|Decode)\|([^|]+)\|([^\]]+)\](.*)$/s;
58
+
59
+ function fromNapiError(err) {
60
+ if (!(err instanceof Error)) return err;
61
+ const m = err.message.match(TAG_RE);
62
+ if (!m) return err;
63
+ const [, kind, statusStr, bodyLenStr, rest] = m;
64
+ // rest = "<msg>\x1f<body>". Use body_len (byte length from Rust) to split
65
+ // deterministically — the body may itself contain \x1f, and Api messages
66
+ // embed the body in msg, so scanning for the first separator is unsafe.
67
+ let msg = rest;
68
+ let body = "";
69
+ if (bodyLenStr !== "-") {
70
+ const bodyLen = Number(bodyLenStr);
71
+ const bodyBytes = Buffer.from(rest, "utf8");
72
+ const bodyStart = bodyBytes.length - bodyLen;
73
+ if (bodyStart >= 1 && bodyBytes[bodyStart - 1] === 0x1f) {
74
+ msg = bodyBytes.slice(0, bodyStart - 1).toString("utf8");
75
+ body = bodyBytes.slice(bodyStart).toString("utf8");
76
+ }
77
+ }
78
+ switch (kind) {
79
+ case "Config": return new ConfigError(msg);
80
+ case "Timeout": return new TimeoutError(msg);
81
+ case "Connect": return new ConnectionError(msg);
82
+ case "Http": return new HttpError(msg);
83
+ case "Api": return new ApiError(msg, Number(statusStr), body);
84
+ case "Decode": return new DecodeError(msg, body);
85
+ default: return err;
86
+ }
87
+ }
88
+
89
+ // Wraps an object's methods so thrown napi errors get retagged as typed
90
+ // subclasses. Handles both sync throws and rejected promises.
91
+ function wrapClient(client) {
92
+ return new Proxy(client, {
93
+ get(target, prop) {
94
+ const val = target[prop];
95
+ if (typeof val !== "function") return val;
96
+ return function (...args) {
97
+ try {
98
+ const result = val.apply(target, args);
99
+ if (result && typeof result.then === "function") {
100
+ return result.catch((e) => { throw fromNapiError(e); });
101
+ }
102
+ return result;
103
+ } catch (e) {
104
+ throw fromNapiError(e);
105
+ }
106
+ };
107
+ },
108
+ });
109
+ }
110
+
111
+ module.exports = {
112
+ QuickNodeError,
113
+ ConfigError,
114
+ HttpError,
115
+ TimeoutError,
116
+ ConnectionError,
117
+ ApiError,
118
+ DecodeError,
119
+ fromNapiError,
120
+ wrapClient,
121
+ };