@chainflip/rpc 1.10.0 → 1.10.1

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/dist/Client.cjs CHANGED
@@ -4,12 +4,14 @@ var _async = require('@chainflip/utils/async');
4
4
 
5
5
  var _commoncjs = require('./common.cjs');
6
6
  var Client = (_class = class {
7
- constructor(url) {;_class.prototype.__init.call(this);_class.prototype.__init2.call(this);_class.prototype.__init3.call(this);
7
+ constructor(url, opts = {}) {;_class.prototype.__init.call(this);_class.prototype.__init2.call(this);_class.prototype.__init3.call(this);
8
8
  this.url = url;
9
+ this.archiveNodeUrl = opts.archiveNodeUrl;
9
10
  }
10
11
  __init() {this.lastRequestId = 0}
11
12
  __init2() {this.timer = null}
12
13
  __init3() {this.requestMap = /* @__PURE__ */ new Map()}
14
+
13
15
  getRequestId() {
14
16
  try {
15
17
  return crypto.randomUUID();
@@ -67,7 +69,14 @@ var Client = (_class = class {
67
69
  }, 0);
68
70
  }
69
71
  return deferred.promise.catch((error) => {
70
- if (error instanceof Error) Error.captureStackTrace(error);
72
+ if (error instanceof Error) {
73
+ if (this.archiveNodeUrl && error.message.includes("Unknown block: State already discarded")) {
74
+ return new this.constructor(
75
+ this.archiveNodeUrl
76
+ ).sendRequest(method, ...params);
77
+ }
78
+ Error.captureStackTrace(error);
79
+ }
71
80
  throw error;
72
81
  });
73
82
  }
package/dist/Client.d.cts CHANGED
@@ -23,7 +23,10 @@ declare abstract class Client {
23
23
  private lastRequestId;
24
24
  private timer;
25
25
  private requestMap;
26
- constructor(url: string);
26
+ private readonly archiveNodeUrl?;
27
+ constructor(url: string, opts?: {
28
+ archiveNodeUrl?: string;
29
+ });
27
30
  protected abstract send<const T extends RpcMethod>(data: JsonRpcRequest<T>[], clonedMap: RequestMap): Promise<void>;
28
31
  private getRequestId;
29
32
  private formatRequest;
package/dist/Client.d.ts CHANGED
@@ -23,7 +23,10 @@ declare abstract class Client {
23
23
  private lastRequestId;
24
24
  private timer;
25
25
  private requestMap;
26
- constructor(url: string);
26
+ private readonly archiveNodeUrl?;
27
+ constructor(url: string, opts?: {
28
+ archiveNodeUrl?: string;
29
+ });
27
30
  protected abstract send<const T extends RpcMethod>(data: JsonRpcRequest<T>[], clonedMap: RequestMap): Promise<void>;
28
31
  private getRequestId;
29
32
  private formatRequest;
package/dist/Client.mjs CHANGED
@@ -4,12 +4,14 @@ import {
4
4
  rpcResult
5
5
  } from "./common.mjs";
6
6
  var Client = class {
7
- constructor(url) {
7
+ constructor(url, opts = {}) {
8
8
  this.url = url;
9
+ this.archiveNodeUrl = opts.archiveNodeUrl;
9
10
  }
10
11
  lastRequestId = 0;
11
12
  timer = null;
12
13
  requestMap = /* @__PURE__ */ new Map();
14
+ archiveNodeUrl;
13
15
  getRequestId() {
14
16
  try {
15
17
  return crypto.randomUUID();
@@ -67,7 +69,14 @@ var Client = class {
67
69
  }, 0);
68
70
  }
69
71
  return deferred.promise.catch((error) => {
70
- if (error instanceof Error) Error.captureStackTrace(error);
72
+ if (error instanceof Error) {
73
+ if (this.archiveNodeUrl && error.message.includes("Unknown block: State already discarded")) {
74
+ return new this.constructor(
75
+ this.archiveNodeUrl
76
+ ).sendRequest(method, ...params);
77
+ }
78
+ Error.captureStackTrace(error);
79
+ }
71
80
  throw error;
72
81
  });
73
82
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@chainflip/rpc",
3
- "version": "1.10.0",
3
+ "version": "1.10.1",
4
4
  "type": "module",
5
5
  "dependencies": {
6
6
  "@chainflip/utils": "0.8.6",