@hardkas/kaspa-rpc 0.9.1-alpha → 0.9.2-alpha

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 (2) hide show
  1. package/dist/index.js +16 -14
  2. package/package.json +3 -3
package/dist/index.js CHANGED
@@ -232,8 +232,8 @@ var KaspaJsonRpcClient = class {
232
232
  reachable: false,
233
233
  rpcUrl: this.url,
234
234
  status: "unavailable",
235
- error: e.message,
236
- lastError: this.lastError || e.message,
235
+ error: e instanceof Error ? e instanceof Error ? e instanceof Error ? e.message : String(e) : String(e) : String(e),
236
+ lastError: this.lastError || (e instanceof Error ? e instanceof Error ? e instanceof Error ? e.message : String(e) : String(e) : String(e)),
237
237
  successRate: this.getSuccessRate(),
238
238
  circuitState: this.circuitState,
239
239
  confidence: resilience.confidence,
@@ -394,7 +394,7 @@ var KaspaJsonRpcClient = class {
394
394
  coreEvents.normalizeAndEmit({
395
395
  kind: "rpc.error",
396
396
  endpoint: this.url,
397
- error: e.message,
397
+ error: e instanceof Error ? e instanceof Error ? e instanceof Error ? e.message : String(e) : String(e) : String(e),
398
398
  retriable: isRetriable
399
399
  });
400
400
  if (attempt < this.retry.maxRetries && isRetriable) {
@@ -404,7 +404,8 @@ var KaspaJsonRpcClient = class {
404
404
  throw e;
405
405
  }
406
406
  if (this.isDeterministicError(e)) {
407
- throw new RpcValidationError(e.message, e.code, e.data);
407
+ const err = e;
408
+ throw new RpcValidationError(err instanceof Error ? err instanceof Error ? err.message : String(err) : String(err), err.code, err.data);
408
409
  }
409
410
  if (attempt === this.retry.maxRetries) break;
410
411
  const delay = Math.min(
@@ -446,7 +447,7 @@ var KaspaJsonRpcClient = class {
446
447
  return body.result;
447
448
  } catch (e) {
448
449
  clearTimeout(id);
449
- if (e.name === "AbortError") throw new RpcTimeoutError();
450
+ if (e instanceof Error && e.name === "AbortError") throw new RpcTimeoutError();
450
451
  throw e;
451
452
  }
452
453
  }
@@ -465,7 +466,7 @@ var KaspaJsonRpcClient = class {
465
466
  this.circuitState = "CLOSED" /* CLOSED */;
466
467
  }
467
468
  onFailure(e) {
468
- this.lastError = e.message;
469
+ this.lastError = e instanceof Error ? e instanceof Error ? e.message : String(e) : String(e);
469
470
  if (e instanceof RpcValidationError || e instanceof RpcError && !e.isRetriable) {
470
471
  return;
471
472
  }
@@ -476,7 +477,7 @@ var KaspaJsonRpcClient = class {
476
477
  }
477
478
  }
478
479
  isDeterministicError(e) {
479
- const msg = (e.message || "").toLowerCase();
480
+ const msg = ((e instanceof Error ? e instanceof Error ? e.message : String(e) : String(e)) || "").toLowerCase();
480
481
  const deterministicMarkers = [
481
482
  "invalid address",
482
483
  "insufficient funds",
@@ -540,7 +541,7 @@ var KaspaWrpcClient = class {
540
541
  });
541
542
  this.ws.on("error", (err) => {
542
543
  clearTimeout(timer);
543
- reject(new Error(`WebSocket error: ${err.message}`));
544
+ reject(new Error(`WebSocket error: ${err instanceof Error ? err instanceof Error ? err.message : String(err) : String(err)}`));
544
545
  });
545
546
  this.ws.on("message", (data) => {
546
547
  try {
@@ -671,8 +672,8 @@ async function checkKaspaRpcHealth(options) {
671
672
  status: "unreachable",
672
673
  ready: false,
673
674
  checkedAt,
674
- error: e.message,
675
- lastError: e.message
675
+ error: e instanceof Error ? e instanceof Error ? e instanceof Error ? e.message : String(e) : String(e) : String(e),
676
+ lastError: e instanceof Error ? e instanceof Error ? e instanceof Error ? e.message : String(e) : String(e) : String(e)
676
677
  };
677
678
  }
678
679
  }
@@ -702,8 +703,8 @@ async function checkKaspaRpcHealth(options) {
702
703
  status: "unreachable",
703
704
  ready: false,
704
705
  checkedAt,
705
- error: e.message,
706
- lastError: e.message
706
+ error: e instanceof Error ? e instanceof Error ? e instanceof Error ? e.message : String(e) : String(e) : String(e),
707
+ lastError: e instanceof Error ? e instanceof Error ? e instanceof Error ? e.message : String(e) : String(e) : String(e)
707
708
  };
708
709
  }
709
710
  }
@@ -834,7 +835,8 @@ var JsonWrpcKaspaClient = class {
834
835
  const res = await this.requestRaw("getServerInfo", {});
835
836
  this.rpcFlavor = "wrpc";
836
837
  } catch (e) {
837
- if (e.message && e.message.includes("Method not found")) {
838
+ const errMsg = e instanceof Error ? e instanceof Error ? e instanceof Error ? e.message : String(e) : String(e) : String(e);
839
+ if (errMsg.includes("Method not found")) {
838
840
  this.rpcFlavor = "legacy";
839
841
  } else {
840
842
  this.rpcFlavor = "wrpc";
@@ -1041,7 +1043,7 @@ var JsonWrpcKaspaClient = class {
1041
1043
  cleanup();
1042
1044
  if (response.error) {
1043
1045
  const err = response.error;
1044
- const msg = err.message || (typeof err === "string" ? err : JSON.stringify(err));
1046
+ const msg = (err instanceof Error ? err instanceof Error ? err.message : String(err) : String(err)) || (typeof err === "string" ? err : JSON.stringify(err));
1045
1047
  reject(new Error(msg));
1046
1048
  } else {
1047
1049
  resolve(response.result !== void 0 ? response.result : response.params);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hardkas/kaspa-rpc",
3
- "version": "0.9.1-alpha",
3
+ "version": "0.9.2-alpha",
4
4
  "type": "module",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",
@@ -13,8 +13,8 @@
13
13
  },
14
14
  "dependencies": {
15
15
  "ws": "^8.18.0",
16
- "@hardkas/core": "0.9.1-alpha",
17
- "@hardkas/tx-builder": "0.9.1-alpha"
16
+ "@hardkas/core": "0.9.2-alpha",
17
+ "@hardkas/tx-builder": "0.9.2-alpha"
18
18
  },
19
19
  "devDependencies": {
20
20
  "@types/ws": "^8.5.13",