boing-sdk 0.3.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.
Files changed (186) hide show
  1. package/CHANGELOG.md +26 -0
  2. package/README.md +191 -0
  3. package/dist/accessList.d.ts +22 -0
  4. package/dist/accessList.d.ts.map +1 -0
  5. package/dist/accessList.js +45 -0
  6. package/dist/bincode.d.ts +92 -0
  7. package/dist/bincode.d.ts.map +1 -0
  8. package/dist/bincode.js +154 -0
  9. package/dist/callAbi.d.ts +119 -0
  10. package/dist/callAbi.d.ts.map +1 -0
  11. package/dist/callAbi.js +156 -0
  12. package/dist/calldata.d.ts +35 -0
  13. package/dist/calldata.d.ts.map +1 -0
  14. package/dist/calldata.js +93 -0
  15. package/dist/canonicalDeployArtifacts.d.ts +154 -0
  16. package/dist/canonicalDeployArtifacts.d.ts.map +1 -0
  17. package/dist/canonicalDeployArtifacts.js +271 -0
  18. package/dist/canonicalTestnet.d.ts +15 -0
  19. package/dist/canonicalTestnet.d.ts.map +1 -0
  20. package/dist/canonicalTestnet.js +15 -0
  21. package/dist/canonicalTestnetDex.d.ts +17 -0
  22. package/dist/canonicalTestnetDex.d.ts.map +1 -0
  23. package/dist/canonicalTestnetDex.js +17 -0
  24. package/dist/chainIds.d.ts +18 -0
  25. package/dist/chainIds.d.ts.map +1 -0
  26. package/dist/chainIds.js +56 -0
  27. package/dist/client.d.ts +223 -0
  28. package/dist/client.d.ts.map +1 -0
  29. package/dist/client.js +659 -0
  30. package/dist/connectionMonitor.d.ts +47 -0
  31. package/dist/connectionMonitor.d.ts.map +1 -0
  32. package/dist/connectionMonitor.js +93 -0
  33. package/dist/create2.d.ts +94 -0
  34. package/dist/create2.d.ts.map +1 -0
  35. package/dist/create2.js +225 -0
  36. package/dist/dappDeploy.d.ts +100 -0
  37. package/dist/dappDeploy.d.ts.map +1 -0
  38. package/dist/dappDeploy.js +140 -0
  39. package/dist/dappUiHelpers.d.ts +28 -0
  40. package/dist/dappUiHelpers.d.ts.map +1 -0
  41. package/dist/dappUiHelpers.js +69 -0
  42. package/dist/defaultReferenceFungibleSecuredRuntimeBytecodeHex.d.ts +6 -0
  43. package/dist/defaultReferenceFungibleSecuredRuntimeBytecodeHex.d.ts.map +1 -0
  44. package/dist/defaultReferenceFungibleSecuredRuntimeBytecodeHex.js +5 -0
  45. package/dist/defaultReferenceFungibleSecuredTemplateBytecodeHex.d.ts +6 -0
  46. package/dist/defaultReferenceFungibleSecuredTemplateBytecodeHex.d.ts.map +1 -0
  47. package/dist/defaultReferenceFungibleSecuredTemplateBytecodeHex.js +5 -0
  48. package/dist/defaultReferenceFungibleTemplateBytecodeHex.d.ts +6 -0
  49. package/dist/defaultReferenceFungibleTemplateBytecodeHex.d.ts.map +1 -0
  50. package/dist/defaultReferenceFungibleTemplateBytecodeHex.js +5 -0
  51. package/dist/defaultReferenceNftCollectionTemplateBytecodeHex.d.ts +7 -0
  52. package/dist/defaultReferenceNftCollectionTemplateBytecodeHex.d.ts.map +1 -0
  53. package/dist/defaultReferenceNftCollectionTemplateBytecodeHex.js +6 -0
  54. package/dist/dexIntegration.d.ts +61 -0
  55. package/dist/dexIntegration.d.ts.map +1 -0
  56. package/dist/dexIntegration.js +193 -0
  57. package/dist/erc721Logs.d.ts +21 -0
  58. package/dist/erc721Logs.d.ts.map +1 -0
  59. package/dist/erc721Logs.js +69 -0
  60. package/dist/errors.d.ts +60 -0
  61. package/dist/errors.d.ts.map +1 -0
  62. package/dist/errors.js +153 -0
  63. package/dist/hex.d.ts +27 -0
  64. package/dist/hex.d.ts.map +1 -0
  65. package/dist/hex.js +82 -0
  66. package/dist/index.d.ts +83 -0
  67. package/dist/index.d.ts.map +1 -0
  68. package/dist/index.js +78 -0
  69. package/dist/indexerBatch.d.ts +111 -0
  70. package/dist/indexerBatch.d.ts.map +1 -0
  71. package/dist/indexerBatch.js +253 -0
  72. package/dist/indexerGaps.d.ts +50 -0
  73. package/dist/indexerGaps.d.ts.map +1 -0
  74. package/dist/indexerGaps.js +117 -0
  75. package/dist/indexerSync.d.ts +61 -0
  76. package/dist/indexerSync.d.ts.map +1 -0
  77. package/dist/indexerSync.js +100 -0
  78. package/dist/nativeAmm.d.ts +64 -0
  79. package/dist/nativeAmm.d.ts.map +1 -0
  80. package/dist/nativeAmm.js +174 -0
  81. package/dist/nativeAmmLogs.d.ts +48 -0
  82. package/dist/nativeAmmLogs.d.ts.map +1 -0
  83. package/dist/nativeAmmLogs.js +114 -0
  84. package/dist/nativeAmmLpVault.d.ts +94 -0
  85. package/dist/nativeAmmLpVault.d.ts.map +1 -0
  86. package/dist/nativeAmmLpVault.js +205 -0
  87. package/dist/nativeAmmPool.d.ts +124 -0
  88. package/dist/nativeAmmPool.d.ts.map +1 -0
  89. package/dist/nativeAmmPool.js +245 -0
  90. package/dist/nativeContractSubmit.d.ts +26 -0
  91. package/dist/nativeContractSubmit.d.ts.map +1 -0
  92. package/dist/nativeContractSubmit.js +23 -0
  93. package/dist/nativeDexDirectory.d.ts +83 -0
  94. package/dist/nativeDexDirectory.d.ts.map +1 -0
  95. package/dist/nativeDexDirectory.js +147 -0
  96. package/dist/nativeDexDirectoryApi.d.ts +121 -0
  97. package/dist/nativeDexDirectoryApi.d.ts.map +1 -0
  98. package/dist/nativeDexDirectoryApi.js +408 -0
  99. package/dist/nativeDexFactory.d.ts +25 -0
  100. package/dist/nativeDexFactory.d.ts.map +1 -0
  101. package/dist/nativeDexFactory.js +72 -0
  102. package/dist/nativeDexFactoryLogs.d.ts +19 -0
  103. package/dist/nativeDexFactoryLogs.d.ts.map +1 -0
  104. package/dist/nativeDexFactoryLogs.js +61 -0
  105. package/dist/nativeDexFactoryPool.d.ts +61 -0
  106. package/dist/nativeDexFactoryPool.d.ts.map +1 -0
  107. package/dist/nativeDexFactoryPool.js +120 -0
  108. package/dist/nativeDexIndexerStats.d.ts +96 -0
  109. package/dist/nativeDexIndexerStats.d.ts.map +1 -0
  110. package/dist/nativeDexIndexerStats.js +448 -0
  111. package/dist/nativeDexLedgerRouter.d.ts +67 -0
  112. package/dist/nativeDexLedgerRouter.d.ts.map +1 -0
  113. package/dist/nativeDexLedgerRouter.js +108 -0
  114. package/dist/nativeDexLpPositions.d.ts +39 -0
  115. package/dist/nativeDexLpPositions.d.ts.map +1 -0
  116. package/dist/nativeDexLpPositions.js +69 -0
  117. package/dist/nativeDexNftIndexer.d.ts +26 -0
  118. package/dist/nativeDexNftIndexer.d.ts.map +1 -0
  119. package/dist/nativeDexNftIndexer.js +50 -0
  120. package/dist/nativeDexPoolHistory.d.ts +40 -0
  121. package/dist/nativeDexPoolHistory.d.ts.map +1 -0
  122. package/dist/nativeDexPoolHistory.js +110 -0
  123. package/dist/nativeDexReceiptArchive.d.ts +25 -0
  124. package/dist/nativeDexReceiptArchive.d.ts.map +1 -0
  125. package/dist/nativeDexReceiptArchive.js +47 -0
  126. package/dist/nativeDexRouting.d.ts +160 -0
  127. package/dist/nativeDexRouting.d.ts.map +1 -0
  128. package/dist/nativeDexRouting.js +345 -0
  129. package/dist/nativeDexSeamless.d.ts +86 -0
  130. package/dist/nativeDexSeamless.d.ts.map +1 -0
  131. package/dist/nativeDexSeamless.js +131 -0
  132. package/dist/nativeDexSwap2Router.d.ts +45 -0
  133. package/dist/nativeDexSwap2Router.d.ts.map +1 -0
  134. package/dist/nativeDexSwap2Router.js +276 -0
  135. package/dist/nativeLpShareToken.d.ts +54 -0
  136. package/dist/nativeLpShareToken.d.ts.map +1 -0
  137. package/dist/nativeLpShareToken.js +135 -0
  138. package/dist/nativeTokenSecurity.d.ts +59 -0
  139. package/dist/nativeTokenSecurity.d.ts.map +1 -0
  140. package/dist/nativeTokenSecurity.js +59 -0
  141. package/dist/networkProfile.d.ts +8 -0
  142. package/dist/networkProfile.d.ts.map +1 -0
  143. package/dist/networkProfile.js +29 -0
  144. package/dist/newHeadsWs.d.ts +43 -0
  145. package/dist/newHeadsWs.d.ts.map +1 -0
  146. package/dist/newHeadsWs.js +139 -0
  147. package/dist/preflightGate.d.ts +16 -0
  148. package/dist/preflightGate.d.ts.map +1 -0
  149. package/dist/preflightGate.js +29 -0
  150. package/dist/receiptLogs.d.ts +29 -0
  151. package/dist/receiptLogs.d.ts.map +1 -0
  152. package/dist/receiptLogs.js +66 -0
  153. package/dist/referenceFungibleSecuredDeployBytecode.d.ts +54 -0
  154. package/dist/referenceFungibleSecuredDeployBytecode.d.ts.map +1 -0
  155. package/dist/referenceFungibleSecuredDeployBytecode.js +274 -0
  156. package/dist/referenceNft.d.ts +14 -0
  157. package/dist/referenceNft.d.ts.map +1 -0
  158. package/dist/referenceNft.js +34 -0
  159. package/dist/referenceToken.d.ts +14 -0
  160. package/dist/referenceToken.d.ts.map +1 -0
  161. package/dist/referenceToken.js +29 -0
  162. package/dist/retryAfter.d.ts +6 -0
  163. package/dist/retryAfter.d.ts.map +1 -0
  164. package/dist/retryAfter.js +24 -0
  165. package/dist/rpcCapabilities.d.ts +43 -0
  166. package/dist/rpcCapabilities.d.ts.map +1 -0
  167. package/dist/rpcCapabilities.js +159 -0
  168. package/dist/rpcDoctor.d.ts +27 -0
  169. package/dist/rpcDoctor.d.ts.map +1 -0
  170. package/dist/rpcDoctor.js +66 -0
  171. package/dist/rpcSurfaceUi.d.ts +32 -0
  172. package/dist/rpcSurfaceUi.d.ts.map +1 -0
  173. package/dist/rpcSurfaceUi.js +49 -0
  174. package/dist/submitFlow.d.ts +70 -0
  175. package/dist/submitFlow.d.ts.map +1 -0
  176. package/dist/submitFlow.js +121 -0
  177. package/dist/transactionBuilder.d.ts +55 -0
  178. package/dist/transactionBuilder.d.ts.map +1 -0
  179. package/dist/transactionBuilder.js +100 -0
  180. package/dist/types.d.ts +436 -0
  181. package/dist/types.d.ts.map +1 -0
  182. package/dist/types.js +4 -0
  183. package/dist/walletProvider.d.ts +46 -0
  184. package/dist/walletProvider.d.ts.map +1 -0
  185. package/dist/walletProvider.js +126 -0
  186. package/package.json +44 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client.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;IACG,iBAAiB,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,uBAAuB,CAAC;IAK9E,qGAAqG;IAC/F,mBAAmB,CAAC,WAAW,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,kBAAkB,CAAC;IAO7F,iEAAiE;IAC3D,YAAY,CAAC,eAAe,EAAE,MAAM,GAAG,OAAO,CAAC,kBAAkB,CAAC;IAIxE;;;;;OAKG;IACH,6CAA6C;IACvC,UAAU,IAAI,OAAO,CAAC,gBAAgB,CAAC;IAI7C,oEAAoE;IAC9D,YAAY,IAAI,OAAO,CAAC,kBAAkB,CAAC;IAIjD,8FAA8F;IACxF,aAAa,IAAI,OAAO,CAAC,gBAAgB,CAAC;IAIhD;;;OAGG;IACG,UAAU,CACd,SAAS,EAAE,MAAM,EACjB,QAAQ,EAAE,MAAM,EAChB,IAAI,EAAE,OAAO,GAAG,QAAQ,GAAG,SAAS,GACnC,OAAO,CAAC,gBAAgB,CAAC;IAQ5B;;;;OAIG;IACG,qBAAqB,CAAC,YAAY,EAAE,MAAM,EAAE,gBAAgB,EAAE,MAAM,GAAG,OAAO,CAAC,2BAA2B,CAAC;IAI3G,OAAO,CACX,WAAW,EAAE,MAAM,EACnB,eAAe,CAAC,EAAE,MAAM,EACxB,eAAe,CAAC,EAAE,MAAM,EACxB,SAAS,CAAC,EAAE,MAAM,EAClB,WAAW,CAAC,EAAE,MAAM,GACnB,OAAO,CAAC,eAAe,CAAC;IAgB3B,0IAA0I;IACpI,aAAa,CAAC,YAAY,EAAE,MAAM,GAAG,OAAO,CAAC,YAAY,CAAC;CAIjE"}
package/dist/client.js ADDED
@@ -0,0 +1,659 @@
1
+ /**
2
+ * Boing JSON-RPC client — typed methods for all node RPCs.
3
+ */
4
+ import { BoingRpcError, isRetriableBoingRpcError } from './errors.js';
5
+ import { parseRetryAfterMs } from './retryAfter.js';
6
+ import { ensureHex, validateHex32 } from './hex.js';
7
+ const DEFAULT_RPC_ID = 1;
8
+ const DEFAULT_TIMEOUT_MS = 30000;
9
+ const DEFAULT_RETRY_BASE_MS = 250;
10
+ /**
11
+ * Cloudflare Workers (and some other runtimes) throw "Illegal invocation" if the native `fetch`
12
+ * is stored and called as a plain function — it must be invoked as a bound call.
13
+ */
14
+ function defaultFetchImpl(input, init) {
15
+ return globalThis.fetch(input, init);
16
+ }
17
+ function sleepMs(ms) {
18
+ return new Promise((resolve) => setTimeout(resolve, ms));
19
+ }
20
+ function generateClientRequestId() {
21
+ if (typeof crypto !== 'undefined' && typeof crypto.randomUUID === 'function') {
22
+ return crypto.randomUUID();
23
+ }
24
+ return `boing-${Date.now().toString(36)}-${Math.random().toString(36).slice(2, 12)}`;
25
+ }
26
+ /**
27
+ * HTTP JSON-RPC client for a Boing node.
28
+ * All methods return typed results; on RPC error they throw BoingRpcError (with code, message, method, and optional data).
29
+ */
30
+ export class BoingClient {
31
+ constructor(config) {
32
+ this.id = DEFAULT_RPC_ID;
33
+ if (typeof config === 'string') {
34
+ this.baseUrl = config.replace(/\/$/, '');
35
+ this.fetchImpl = defaultFetchImpl;
36
+ this.timeoutMs = DEFAULT_TIMEOUT_MS;
37
+ this.extraHeaders = {};
38
+ this.maxRetries = 0;
39
+ this.retryBaseDelayMs = DEFAULT_RETRY_BASE_MS;
40
+ this.generateRequestId = false;
41
+ }
42
+ else {
43
+ this.baseUrl = config.baseUrl.replace(/\/$/, '');
44
+ this.fetchImpl = config.fetch ?? defaultFetchImpl;
45
+ this.timeoutMs = config.timeoutMs ?? DEFAULT_TIMEOUT_MS;
46
+ this.extraHeaders = { ...(config.extraHeaders ?? {}) };
47
+ this.maxRetries = Math.max(0, config.maxRetries ?? 0);
48
+ this.retryBaseDelayMs = Math.max(0, config.retryBaseDelayMs ?? DEFAULT_RETRY_BASE_MS);
49
+ this.generateRequestId = config.generateRequestId === true;
50
+ }
51
+ }
52
+ /** Normalized RPC origin (no trailing slash). */
53
+ getBaseUrl() {
54
+ return this.baseUrl;
55
+ }
56
+ /**
57
+ * Correlation id from the most recent JSON-RPC **`POST /`** response (**`x-request-id`**).
58
+ * Useful for support UI when CORS exposes this header on the response.
59
+ */
60
+ getLastXRequestId() {
61
+ return this.lastXRequestId;
62
+ }
63
+ recordRequestIdFromResponse(res) {
64
+ const v = res.headers.get('x-request-id')?.trim();
65
+ this.lastXRequestId = v && v.length > 0 ? v : undefined;
66
+ }
67
+ rpcExtraHeaders() {
68
+ const h = { ...this.extraHeaders };
69
+ if (this.generateRequestId) {
70
+ h['X-Request-Id'] = generateClientRequestId();
71
+ }
72
+ return h;
73
+ }
74
+ async requestOnce(method, params = []) {
75
+ const body = {
76
+ jsonrpc: '2.0',
77
+ id: this.id++,
78
+ method,
79
+ params,
80
+ };
81
+ const controller = this.timeoutMs > 0 ? new AbortController() : null;
82
+ const timeoutId = controller
83
+ ? setTimeout(() => controller.abort(), this.timeoutMs)
84
+ : null;
85
+ try {
86
+ const headers = {
87
+ 'Content-Type': 'application/json',
88
+ ...this.rpcExtraHeaders(),
89
+ };
90
+ const res = await this.fetchImpl(this.baseUrl, {
91
+ method: 'POST',
92
+ headers,
93
+ body: JSON.stringify(body),
94
+ signal: controller?.signal,
95
+ });
96
+ this.recordRequestIdFromResponse(res);
97
+ if (!res.ok) {
98
+ const retryAfterMs = parseRetryAfterMs(res.headers.get('retry-after'));
99
+ let detail = (res.statusText ?? '').trim();
100
+ let bodyText = '';
101
+ try {
102
+ bodyText = (await res.text()).trim().slice(0, 400);
103
+ if (bodyText.length > 0) {
104
+ detail = detail.length > 0 ? `${detail} — ${bodyText}` : bodyText;
105
+ }
106
+ }
107
+ catch {
108
+ /* ignore body read errors */
109
+ }
110
+ let msg = detail.length > 0 ? `HTTP ${res.status}: ${detail}` : `HTTP ${res.status}`;
111
+ if (res.status === 413) {
112
+ msg = `HTTP 413: JSON-RPC body exceeds this node limit (operators can raise BOING_RPC_MAX_BODY_MB). ${msg}`;
113
+ }
114
+ if (res.status === 429 && bodyText.length > 0) {
115
+ try {
116
+ const j = JSON.parse(bodyText);
117
+ if (j.error != null) {
118
+ throw new BoingRpcError(j.error.code, j.error.message, j.error.data, method, retryAfterMs);
119
+ }
120
+ }
121
+ catch (e) {
122
+ if (e instanceof BoingRpcError)
123
+ throw e;
124
+ }
125
+ }
126
+ throw new BoingRpcError(-32000, msg, undefined, method, retryAfterMs);
127
+ }
128
+ const json = (await res.json());
129
+ if (json.error != null) {
130
+ throw new BoingRpcError(json.error.code, json.error.message, json.error.data, method);
131
+ }
132
+ if (!('result' in json)) {
133
+ throw new BoingRpcError(-32000, 'Invalid RPC response: no result or error', undefined, method);
134
+ }
135
+ return json.result;
136
+ }
137
+ catch (err) {
138
+ if (err instanceof BoingRpcError)
139
+ throw err;
140
+ if (err instanceof Error && err.name === 'AbortError') {
141
+ throw new BoingRpcError(-32000, `Request timed out after ${this.timeoutMs}ms`, undefined, method);
142
+ }
143
+ throw new BoingRpcError(-32000, err instanceof Error ? err.message : String(err), undefined, method);
144
+ }
145
+ finally {
146
+ if (timeoutId != null)
147
+ clearTimeout(timeoutId);
148
+ }
149
+ }
150
+ async request(method, params = []) {
151
+ let lastErr;
152
+ const attempts = 1 + this.maxRetries;
153
+ for (let attempt = 0; attempt < attempts; attempt++) {
154
+ try {
155
+ return await this.requestOnce(method, params);
156
+ }
157
+ catch (e) {
158
+ lastErr = e;
159
+ if (attempt >= attempts - 1 || !isRetriableBoingRpcError(e)) {
160
+ throw e;
161
+ }
162
+ const backoff = this.retryBaseDelayMs * Math.pow(2, attempt);
163
+ const ra = e instanceof BoingRpcError ? e.retryAfterMs : undefined;
164
+ const delay = ra != null && ra > 0 ? Math.max(backoff, ra) : backoff;
165
+ if (delay > 0)
166
+ await sleepMs(delay);
167
+ }
168
+ }
169
+ throw lastErr;
170
+ }
171
+ async requestBatchOnce(calls) {
172
+ const BATCH = 'jsonrpc.batch';
173
+ const batchBody = calls.map((c) => ({
174
+ jsonrpc: '2.0',
175
+ id: this.id++,
176
+ method: c.method,
177
+ params: c.params ?? [],
178
+ }));
179
+ const controller = this.timeoutMs > 0 ? new AbortController() : null;
180
+ const timeoutId = controller
181
+ ? setTimeout(() => controller.abort(), this.timeoutMs)
182
+ : null;
183
+ try {
184
+ const headers = {
185
+ 'Content-Type': 'application/json',
186
+ ...this.rpcExtraHeaders(),
187
+ };
188
+ const res = await this.fetchImpl(this.baseUrl, {
189
+ method: 'POST',
190
+ headers,
191
+ body: JSON.stringify(batchBody),
192
+ signal: controller?.signal,
193
+ });
194
+ this.recordRequestIdFromResponse(res);
195
+ if (!res.ok) {
196
+ const retryAfterMs = parseRetryAfterMs(res.headers.get('retry-after'));
197
+ let detail = (res.statusText ?? '').trim();
198
+ let bodyText = '';
199
+ try {
200
+ bodyText = (await res.text()).trim().slice(0, 400);
201
+ if (bodyText.length > 0) {
202
+ detail = detail.length > 0 ? `${detail} — ${bodyText}` : bodyText;
203
+ }
204
+ }
205
+ catch {
206
+ /* ignore body read errors */
207
+ }
208
+ const msg = detail.length > 0 ? `HTTP ${res.status}: ${detail}` : `HTTP ${res.status}`;
209
+ if (res.status === 429 && bodyText.length > 0) {
210
+ try {
211
+ const j = JSON.parse(bodyText);
212
+ if (j.error != null) {
213
+ throw new BoingRpcError(j.error.code, j.error.message, j.error.data, BATCH, retryAfterMs);
214
+ }
215
+ }
216
+ catch (e) {
217
+ if (e instanceof BoingRpcError)
218
+ throw e;
219
+ }
220
+ }
221
+ throw new BoingRpcError(-32000, msg, undefined, BATCH, retryAfterMs);
222
+ }
223
+ const json = await res.json();
224
+ if (!Array.isArray(json)) {
225
+ throw new BoingRpcError(-32000, 'Invalid RPC response: expected JSON array for batch', undefined, BATCH);
226
+ }
227
+ return json;
228
+ }
229
+ catch (err) {
230
+ if (err instanceof BoingRpcError)
231
+ throw err;
232
+ if (err instanceof Error && err.name === 'AbortError') {
233
+ throw new BoingRpcError(-32000, `Request timed out after ${this.timeoutMs}ms`, undefined, BATCH);
234
+ }
235
+ throw new BoingRpcError(-32000, err instanceof Error ? err.message : String(err), undefined, BATCH);
236
+ }
237
+ finally {
238
+ if (timeoutId != null)
239
+ clearTimeout(timeoutId);
240
+ }
241
+ }
242
+ /**
243
+ * POST a JSON-RPC **batch** (JSON array of requests). Assigns monotonic numeric `id`s; returns the response array in order.
244
+ */
245
+ async requestBatch(calls) {
246
+ let lastErr;
247
+ const attempts = 1 + this.maxRetries;
248
+ for (let attempt = 0; attempt < attempts; attempt++) {
249
+ try {
250
+ return await this.requestBatchOnce(calls);
251
+ }
252
+ catch (e) {
253
+ lastErr = e;
254
+ if (attempt >= attempts - 1 || !isRetriableBoingRpcError(e)) {
255
+ throw e;
256
+ }
257
+ const backoff = this.retryBaseDelayMs * Math.pow(2, attempt);
258
+ const ra = e instanceof BoingRpcError ? e.retryAfterMs : undefined;
259
+ const delay = ra != null && ra > 0 ? Math.max(backoff, ra) : backoff;
260
+ if (delay > 0)
261
+ await sleepMs(delay);
262
+ }
263
+ }
264
+ throw lastErr;
265
+ }
266
+ /**
267
+ * `GET {baseUrl}/live` — process is up (no chain read; for orchestrator liveness).
268
+ * Uses the same `extraHeaders` as JSON-RPC (e.g. auth in front of the node).
269
+ */
270
+ async checkHttpLive() {
271
+ try {
272
+ const res = await this.fetchImpl(`${this.baseUrl}/live`, {
273
+ method: 'GET',
274
+ headers: this.rpcExtraHeaders(),
275
+ });
276
+ return res.ok;
277
+ }
278
+ catch {
279
+ return false;
280
+ }
281
+ }
282
+ /**
283
+ * `GET {baseUrl}/ready` — node can serve RPC (read lock on state). Returns false on **503** when
284
+ * the node enforces **`BOING_RPC_READY_MIN_PEERS`** and peer count is too low.
285
+ */
286
+ async checkHttpReady() {
287
+ try {
288
+ const res = await this.fetchImpl(`${this.baseUrl}/ready`, {
289
+ method: 'GET',
290
+ headers: this.rpcExtraHeaders(),
291
+ });
292
+ return res.ok;
293
+ }
294
+ catch {
295
+ return false;
296
+ }
297
+ }
298
+ /**
299
+ * One round-trip sanity check for dashboards and CI: `health`, supported method count,
300
+ * optional catalog size, whether OpenAPI JSON is exposed, plain HTTP `/live` + `/ready`,
301
+ * and a small JSON-RPC **batch** probe (`jsonrpcBatchOk`).
302
+ */
303
+ async preflightRpc() {
304
+ const [health, supported, httpLiveOk, httpReadyOk, httpOpenApiJsonOk, wellKnownBoingRpcOk, httpLiveJsonOk,] = await Promise.all([
305
+ this.health(),
306
+ this.rpcSupportedMethods(),
307
+ this.checkHttpLive(),
308
+ this.checkHttpReady(),
309
+ this.checkHttpOpenApiJson(),
310
+ this.checkWellKnownBoingRpc(),
311
+ this.checkHttpLiveJson(),
312
+ ]);
313
+ let catalogMethodCount = null;
314
+ try {
315
+ const cat = await this.getRpcMethodCatalog();
316
+ catalogMethodCount = cat.methods?.length ?? 0;
317
+ }
318
+ catch {
319
+ catalogMethodCount = null;
320
+ }
321
+ let openApiPresent = false;
322
+ try {
323
+ const oa = await this.getRpcOpenApi();
324
+ openApiPresent = typeof oa === 'object' && oa !== null && 'openapi' in oa;
325
+ }
326
+ catch {
327
+ openApiPresent = false;
328
+ }
329
+ let jsonrpcBatchOk = false;
330
+ try {
331
+ const batch = await this.requestBatch([
332
+ { method: 'boing_chainHeight', params: [] },
333
+ { method: 'boing_clientVersion', params: [] },
334
+ ]);
335
+ jsonrpcBatchOk =
336
+ batch.length === 2 &&
337
+ batch[0]?.error == null &&
338
+ batch[1]?.error == null &&
339
+ typeof batch[0]?.result === 'number' &&
340
+ typeof batch[1]?.result === 'string';
341
+ }
342
+ catch {
343
+ jsonrpcBatchOk = false;
344
+ }
345
+ return {
346
+ health,
347
+ supportedMethodCount: supported.length,
348
+ catalogMethodCount,
349
+ openApiPresent,
350
+ httpLiveOk,
351
+ httpReadyOk,
352
+ jsonrpcBatchOk,
353
+ httpOpenApiJsonOk,
354
+ wellKnownBoingRpcOk,
355
+ httpLiveJsonOk,
356
+ };
357
+ }
358
+ /** `GET {baseUrl}/openapi.json` — same document as `boing_getRpcOpenApi` when the node exposes it. */
359
+ async checkHttpOpenApiJson() {
360
+ try {
361
+ const res = await this.fetchImpl(`${this.baseUrl}/openapi.json`, {
362
+ method: 'GET',
363
+ headers: this.rpcExtraHeaders(),
364
+ });
365
+ if (!res.ok)
366
+ return false;
367
+ const ct = res.headers.get('content-type') ?? '';
368
+ if (!ct.includes('application/json'))
369
+ return false;
370
+ const j = await res.json();
371
+ return typeof j === 'object' && j !== null && 'openapi' in j;
372
+ }
373
+ catch {
374
+ return false;
375
+ }
376
+ }
377
+ /** `GET {baseUrl}/.well-known/boing-rpc` — path hints for HTTP discovery. */
378
+ async checkWellKnownBoingRpc() {
379
+ try {
380
+ const res = await this.fetchImpl(`${this.baseUrl}/.well-known/boing-rpc`, {
381
+ method: 'GET',
382
+ headers: this.rpcExtraHeaders(),
383
+ });
384
+ if (!res.ok)
385
+ return false;
386
+ const j = await res.json();
387
+ return typeof j === 'object' && j !== null && 'schema_version' in j;
388
+ }
389
+ catch {
390
+ return false;
391
+ }
392
+ }
393
+ /** `GET {baseUrl}/live.json` — JSON liveness probe. */
394
+ async checkHttpLiveJson() {
395
+ try {
396
+ const res = await this.fetchImpl(`${this.baseUrl}/live.json`, {
397
+ method: 'GET',
398
+ headers: this.rpcExtraHeaders(),
399
+ });
400
+ if (!res.ok)
401
+ return false;
402
+ const j = await res.json();
403
+ return typeof j === 'object' && j !== null && j.ok === true;
404
+ }
405
+ catch {
406
+ return false;
407
+ }
408
+ }
409
+ /**
410
+ * **`GET {baseUrl}/openapi.json`** — same OpenAPI document as **`boing_getRpcOpenApi`**, without a JSON-RPC round-trip.
411
+ * Prefer this in browser devtools panels; throws **`BoingRpcError`** when the response is not OK or not JSON.
412
+ */
413
+ async fetchOpenApiViaHttp() {
414
+ const res = await this.fetchImpl(`${this.baseUrl}/openapi.json`, {
415
+ method: 'GET',
416
+ headers: this.rpcExtraHeaders(),
417
+ });
418
+ if (!res.ok) {
419
+ throw new BoingRpcError(-32000, `HTTP ${res.status}: could not load OpenAPI from /openapi.json`, undefined, 'GET /openapi.json');
420
+ }
421
+ const ct = res.headers.get('content-type') ?? '';
422
+ if (!ct.includes('application/json')) {
423
+ throw new BoingRpcError(-32000, 'GET /openapi.json: expected application/json Content-Type', undefined, 'GET /openapi.json');
424
+ }
425
+ const j = await res.json();
426
+ if (typeof j !== 'object' || j === null || !('openapi' in j)) {
427
+ throw new BoingRpcError(-32000, 'GET /openapi.json: response is not a valid OpenAPI root object', undefined, 'GET /openapi.json');
428
+ }
429
+ return j;
430
+ }
431
+ /** Current chain height (tip block number). */
432
+ async chainHeight() {
433
+ return this.request('boing_chainHeight', []);
434
+ }
435
+ /** Build identity string for this node (e.g. `boing-node/0.1.0`). Params: `[]`. */
436
+ async clientVersion() {
437
+ return this.request('boing_clientVersion', []);
438
+ }
439
+ /**
440
+ * Alphabetically sorted `boing_*` method names implemented by this binary (discovery). Params: `[]`.
441
+ */
442
+ async rpcSupportedMethods() {
443
+ return this.request('boing_rpcSupportedMethods', []);
444
+ }
445
+ /** Embedded JSON Schema-style catalog for codegen (params `[]`). See `boing_getNetworkInfo.developer`. */
446
+ async getRpcMethodCatalog() {
447
+ return this.request('boing_getRpcMethodCatalog', []);
448
+ }
449
+ /** Minimal OpenAPI 3.1 document for `POST /` JSON-RPC and `GET /ws` (params `[]`). */
450
+ async getRpcOpenApi() {
451
+ return this.request('boing_getRpcOpenApi', []);
452
+ }
453
+ /**
454
+ * Liveness and build identity (params `[]`). Prefer this over `boing_chainHeight` for load balancers:
455
+ * includes `client_version`, optional `chain_id` / `chain_name` from node env, and `head_height`.
456
+ */
457
+ async health() {
458
+ return this.request('boing_health', []);
459
+ }
460
+ /**
461
+ * Committed chain tip: `head_height`, `finalized_height` (same as head today), and tip `latest_block_hash`.
462
+ * See RPC-API-SPEC.md — finality semantics.
463
+ */
464
+ async getSyncState() {
465
+ return this.request('boing_getSyncState', []);
466
+ }
467
+ /**
468
+ * Network + tip snapshot for dApps (params `[]`). Includes `chain_native` (sums over committed accounts) and
469
+ * `rpc.not_available` for capabilities this surface does not expose (e.g. staking APY).
470
+ * See RPC-API-SPEC.md — `chain_id` / `chain_name` require node env `BOING_CHAIN_ID` / `BOING_CHAIN_NAME`.
471
+ */
472
+ async getNetworkInfo() {
473
+ return this.request('boing_getNetworkInfo', []);
474
+ }
475
+ /** Get spendable balance for an account. Params: 32-byte account ID (hex). */
476
+ async getBalance(hexAccountId) {
477
+ const hex = validateHex32(hexAccountId);
478
+ return this.request('boing_getBalance', [hex]);
479
+ }
480
+ /** Get full account state (balance, nonce, stake). Params: 32-byte account ID (hex). */
481
+ async getAccount(hexAccountId) {
482
+ const hex = validateHex32(hexAccountId);
483
+ return this.request('boing_getAccount', [hex]);
484
+ }
485
+ /** Get block by height. Returns null if not found. */
486
+ async getBlockByHeight(height, includeReceipts) {
487
+ const params = includeReceipts === true ? [height, true] : includeReceipts === false ? [height, false] : [height];
488
+ return this.request('boing_getBlockByHeight', params);
489
+ }
490
+ /** Receipt for an included tx (`Transaction.id` hex), or `null` if unknown. */
491
+ async getTransactionReceipt(hexTxId) {
492
+ return this.request('boing_getTransactionReceipt', [validateHex32(hexTxId)]);
493
+ }
494
+ /**
495
+ * Bounded log query over committed blocks (see RPC-API-SPEC — max block span and result cap on the node).
496
+ * Optional `address` is normalized to 32-byte hex when provided.
497
+ */
498
+ async getLogs(filter) {
499
+ const payload = {
500
+ fromBlock: filter.fromBlock,
501
+ toBlock: filter.toBlock,
502
+ };
503
+ if (filter.address != null && filter.address !== '') {
504
+ payload.address = validateHex32(filter.address);
505
+ }
506
+ if (filter.topics != null) {
507
+ payload.topics = filter.topics;
508
+ }
509
+ return this.request('boing_getLogs', [payload]);
510
+ }
511
+ /** Get block by hash. Params: 32-byte block hash (hex). */
512
+ async getBlockByHash(hexBlockHash, includeReceipts) {
513
+ const hex = validateHex32(hexBlockHash);
514
+ const params = includeReceipts === true ? [hex, true] : includeReceipts === false ? [hex, false] : [hex];
515
+ return this.request('boing_getBlockByHash', params);
516
+ }
517
+ /** Get Merkle proof for an account. Params: 32-byte account ID (hex). */
518
+ async getAccountProof(hexAccountId) {
519
+ const hex = validateHex32(hexAccountId);
520
+ return this.request('boing_getAccountProof', [hex]);
521
+ }
522
+ /** Verify an account Merkle proof. Params: hex proof, hex state root. */
523
+ async verifyAccountProof(hexProof, hexStateRoot) {
524
+ return this.request('boing_verifyAccountProof', [
525
+ ensureHex(hexProof),
526
+ ensureHex(hexStateRoot),
527
+ ]);
528
+ }
529
+ /** Read one 32-byte VM storage slot for a contract (`SLOAD` semantics; missing → zero word). */
530
+ async getContractStorage(hexContractId, hexKey32) {
531
+ return this.request('boing_getContractStorage', [
532
+ validateHex32(hexContractId),
533
+ validateHex32(hexKey32),
534
+ ]);
535
+ }
536
+ /**
537
+ * Cursor-paginated native DEX pools (`boing_listDexPools`).
538
+ * Factory: **`params.factory`** (32-byte hex) overrides **`BOING_CANONICAL_NATIVE_DEX_FACTORY`**.
539
+ * Set **`light`** / **`enrich: false`** to skip receipt scan (**`createdAtHeight`** stays null).
540
+ * Each pool row includes **`tokenADecimals`** / **`tokenBDecimals`** (**`BOING_DEX_TOKEN_DECIMALS_JSON`**, default **18**).
541
+ */
542
+ async listDexPoolsPage(params) {
543
+ return this.request('boing_listDexPools', [params ?? {}]);
544
+ }
545
+ /**
546
+ * Cursor-paginated DEX-derived token universe (`boing_listDexTokens`).
547
+ * Optional **`minReserveProduct`** / **`minLiquidityWei`** are decimal digit strings (same as node).
548
+ * **`light`** skips receipt + deploy metadata scans (**`firstSeenHeight`** null, **`metadataSource`** abbrev-only).
549
+ */
550
+ async listDexTokensPage(params) {
551
+ return this.request('boing_listDexTokens', [params ?? {}]);
552
+ }
553
+ /** Single-token lookup in the DEX-derived universe (`boing_getDexToken`). */
554
+ async getDexToken(idHex32, options) {
555
+ const id = validateHex32(idHex32);
556
+ return this.request('boing_getDexToken', [{ id, ...options }]);
557
+ }
558
+ /** Simulate a transaction without applying it. Params: hex-encoded signed transaction. */
559
+ async simulateTransaction(hexSignedTx) {
560
+ const hex = ensureHex(hexSignedTx);
561
+ return this.request('boing_simulateTransaction', [hex]);
562
+ }
563
+ /**
564
+ * Dry-run a `contract_call` without a signed transaction (`boing_simulateContractCall`).
565
+ * Params: `[contract_hex, calldata_hex, sender_hex?, at_block?]` — see `docs/RPC-API-SPEC.md`.
566
+ */
567
+ async simulateContractCall(contractHex, calldataHex, options) {
568
+ const contract = validateHex32(contractHex);
569
+ const calldata = ensureHex(calldataHex);
570
+ const params = [contract, calldata];
571
+ if (options?.senderHex !== undefined || options?.atBlock !== undefined) {
572
+ const sender = options.senderHex === undefined || options.senderHex === null
573
+ ? null
574
+ : validateHex32(options.senderHex);
575
+ params.push(sender);
576
+ if (options.atBlock !== undefined) {
577
+ params.push(options.atBlock === 'latest' ? 'latest' : options.atBlock);
578
+ }
579
+ }
580
+ return this.request('boing_simulateContractCall', params);
581
+ }
582
+ /**
583
+ * Submit a signed transaction to the mempool.
584
+ * The hex_signed_tx must be hex-encoded bincode-serialized SignedTransaction (from Rust/CLI or future signer).
585
+ */
586
+ async submitTransaction(hexSignedTx) {
587
+ const hex = ensureHex(hexSignedTx);
588
+ return this.request('boing_submitTransaction', [hex]);
589
+ }
590
+ /** Register a dApp for incentive tracking. Params: 32-byte hex contract id, 32-byte hex owner id. */
591
+ async registerDappMetrics(hexContract, hexOwner) {
592
+ return this.request('boing_registerDappMetrics', [
593
+ validateHex32(hexContract),
594
+ validateHex32(hexOwner),
595
+ ]);
596
+ }
597
+ /** Submit a signed intent. Params: hex-encoded signed intent. */
598
+ async submitIntent(hexSignedIntent) {
599
+ return this.request('boing_submitIntent', [ensureHex(hexSignedIntent)]);
600
+ }
601
+ /**
602
+ * Pre-flight QA check for a deployment (no submit). Matches node param order:
603
+ * [hex_bytecode, purpose_category?, description_hash?, asset_name?, asset_symbol?].
604
+ * When passing asset_name, include description_hash (or use a 32-byte placeholder) per RPC-API-SPEC.
605
+ * Returns allow | reject | unsure; when reject, rule_id and message are set.
606
+ */
607
+ /** List pending governance QA pool items. */
608
+ async qaPoolList() {
609
+ return this.request('boing_qaPoolList', []);
610
+ }
611
+ /** Read effective QA pool governance config and `pending_count`. */
612
+ async qaPoolConfig() {
613
+ return this.request('boing_qaPoolConfig', []);
614
+ }
615
+ /** Read-only: effective QA rule registry JSON (same shape as `qa_registry.json`). No auth. */
616
+ async getQaRegistry() {
617
+ return this.request('boing_getQaRegistry', []);
618
+ }
619
+ /**
620
+ * Vote on a pooled Unsure deploy. `voter` must be a governance administrator unless the node uses dev_open_voting.
621
+ * Params: tx_hash hex, voter account hex, `allow` | `reject` | `abstain`.
622
+ */
623
+ async qaPoolVote(txHashHex, voterHex, vote) {
624
+ return this.request('boing_qaPoolVote', [
625
+ validateHex32(txHashHex),
626
+ validateHex32(voterHex),
627
+ vote,
628
+ ]);
629
+ }
630
+ /**
631
+ * Apply QA registry and pool governance config on the node (operator RPC).
632
+ * Params are full JSON documents as strings (same format as `qa_registry.json` / `qa_pool_config.json`).
633
+ * Requires `X-Boing-Operator` when the node has `BOING_OPERATOR_RPC_TOKEN` set.
634
+ */
635
+ async operatorApplyQaPolicy(registryJson, qaPoolConfigJson) {
636
+ return this.request('boing_operatorApplyQaPolicy', [registryJson, qaPoolConfigJson]);
637
+ }
638
+ async qaCheck(hexBytecode, purposeCategory, descriptionHash, assetName, assetSymbol) {
639
+ const hex = ensureHex(hexBytecode);
640
+ const params = [hex];
641
+ if (purposeCategory != null) {
642
+ params.push(purposeCategory);
643
+ if (descriptionHash != null) {
644
+ params.push(ensureHex(descriptionHash));
645
+ if (assetName != null) {
646
+ params.push(assetName);
647
+ if (assetSymbol != null)
648
+ params.push(assetSymbol);
649
+ }
650
+ }
651
+ }
652
+ return this.request('boing_qaCheck', params);
653
+ }
654
+ /** Request testnet BOING (only when node is started with --faucet-enable). Params: 32-byte account ID (hex). Rate limited per account. */
655
+ async faucetRequest(hexAccountId) {
656
+ const hex = validateHex32(hexAccountId);
657
+ return this.request('boing_faucetRequest', [hex]);
658
+ }
659
+ }