@chainflip/rpc 1.10.0 → 1.10.2
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 +11 -2
- package/dist/Client.d.cts +6 -2
- package/dist/Client.d.ts +6 -2
- package/dist/Client.mjs +11 -2
- package/dist/WsClient.cjs +2 -2
- package/dist/WsClient.d.cts +3 -3
- package/dist/WsClient.d.ts +3 -3
- package/dist/WsClient.mjs +2 -2
- package/package.json +1 -1
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)
|
|
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
|
@@ -18,12 +18,16 @@ type RequestMap = Map<string, {
|
|
|
18
18
|
body: JsonRpcRequest<RpcMethod>;
|
|
19
19
|
method: RpcMethod;
|
|
20
20
|
}>;
|
|
21
|
+
type ClientOpts = {
|
|
22
|
+
archiveNodeUrl?: string;
|
|
23
|
+
};
|
|
21
24
|
declare abstract class Client {
|
|
22
25
|
protected readonly url: string;
|
|
23
26
|
private lastRequestId;
|
|
24
27
|
private timer;
|
|
25
28
|
private requestMap;
|
|
26
|
-
|
|
29
|
+
private readonly archiveNodeUrl?;
|
|
30
|
+
constructor(url: string, opts?: ClientOpts);
|
|
27
31
|
protected abstract send<const T extends RpcMethod>(data: JsonRpcRequest<T>[], clonedMap: RequestMap): Promise<void>;
|
|
28
32
|
private getRequestId;
|
|
29
33
|
private formatRequest;
|
|
@@ -34,4 +38,4 @@ declare abstract class Client {
|
|
|
34
38
|
methods(): RpcMethod[];
|
|
35
39
|
}
|
|
36
40
|
|
|
37
|
-
export { type RequestMap, type Response, Client as default };
|
|
41
|
+
export { type ClientOpts, type RequestMap, type Response, Client as default };
|
package/dist/Client.d.ts
CHANGED
|
@@ -18,12 +18,16 @@ type RequestMap = Map<string, {
|
|
|
18
18
|
body: JsonRpcRequest<RpcMethod>;
|
|
19
19
|
method: RpcMethod;
|
|
20
20
|
}>;
|
|
21
|
+
type ClientOpts = {
|
|
22
|
+
archiveNodeUrl?: string;
|
|
23
|
+
};
|
|
21
24
|
declare abstract class Client {
|
|
22
25
|
protected readonly url: string;
|
|
23
26
|
private lastRequestId;
|
|
24
27
|
private timer;
|
|
25
28
|
private requestMap;
|
|
26
|
-
|
|
29
|
+
private readonly archiveNodeUrl?;
|
|
30
|
+
constructor(url: string, opts?: ClientOpts);
|
|
27
31
|
protected abstract send<const T extends RpcMethod>(data: JsonRpcRequest<T>[], clonedMap: RequestMap): Promise<void>;
|
|
28
32
|
private getRequestId;
|
|
29
33
|
private formatRequest;
|
|
@@ -34,4 +38,4 @@ declare abstract class Client {
|
|
|
34
38
|
methods(): RpcMethod[];
|
|
35
39
|
}
|
|
36
40
|
|
|
37
|
-
export { type RequestMap, type Response, Client as default };
|
|
41
|
+
export { type ClientOpts, type RequestMap, type Response, Client as default };
|
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)
|
|
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/WsClient.cjs
CHANGED
|
@@ -13,8 +13,8 @@ var WsClient = (_class = class extends _Clientcjs2.default {
|
|
|
13
13
|
__init3() {this.inFlightRequestMap = /* @__PURE__ */ new Map()}
|
|
14
14
|
|
|
15
15
|
__init4() {this.shouldConnect = true}
|
|
16
|
-
constructor(url, { timeout = 3e4 } = {}) {
|
|
17
|
-
super(url);_class.prototype.__init.call(this);_class.prototype.__init2.call(this);_class.prototype.__init3.call(this);_class.prototype.__init4.call(this);_class.prototype.__init5.call(this);_class.prototype.__init6.call(this);;
|
|
16
|
+
constructor(url, { timeout = 3e4, ...opts } = {}) {
|
|
17
|
+
super(url, opts);_class.prototype.__init.call(this);_class.prototype.__init2.call(this);_class.prototype.__init3.call(this);_class.prototype.__init4.call(this);_class.prototype.__init5.call(this);_class.prototype.__init6.call(this);;
|
|
18
18
|
this.timeout = timeout;
|
|
19
19
|
}
|
|
20
20
|
async close() {
|
package/dist/WsClient.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import Client, { RequestMap } from './Client.cjs';
|
|
1
|
+
import Client, { ClientOpts, RequestMap } from './Client.cjs';
|
|
2
2
|
import { JsonRpcRequest, RpcMethod } from './common.cjs';
|
|
3
3
|
import '@chainflip/utils/async';
|
|
4
4
|
import '@chainflip/utils/types';
|
|
@@ -12,9 +12,9 @@ declare class WsClient extends Client {
|
|
|
12
12
|
private inFlightRequestMap;
|
|
13
13
|
private readonly timeout;
|
|
14
14
|
private shouldConnect;
|
|
15
|
-
constructor(url: string, { timeout }?: {
|
|
15
|
+
constructor(url: string, { timeout, ...opts }?: {
|
|
16
16
|
timeout?: number;
|
|
17
|
-
});
|
|
17
|
+
} & ClientOpts);
|
|
18
18
|
close(): Promise<void>;
|
|
19
19
|
private connectionReady;
|
|
20
20
|
private handleDisconnect;
|
package/dist/WsClient.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import Client, { RequestMap } from './Client.js';
|
|
1
|
+
import Client, { ClientOpts, RequestMap } from './Client.js';
|
|
2
2
|
import { JsonRpcRequest, RpcMethod } from './common.js';
|
|
3
3
|
import '@chainflip/utils/async';
|
|
4
4
|
import '@chainflip/utils/types';
|
|
@@ -12,9 +12,9 @@ declare class WsClient extends Client {
|
|
|
12
12
|
private inFlightRequestMap;
|
|
13
13
|
private readonly timeout;
|
|
14
14
|
private shouldConnect;
|
|
15
|
-
constructor(url: string, { timeout }?: {
|
|
15
|
+
constructor(url: string, { timeout, ...opts }?: {
|
|
16
16
|
timeout?: number;
|
|
17
|
-
});
|
|
17
|
+
} & ClientOpts);
|
|
18
18
|
close(): Promise<void>;
|
|
19
19
|
private connectionReady;
|
|
20
20
|
private handleDisconnect;
|
package/dist/WsClient.mjs
CHANGED
|
@@ -13,8 +13,8 @@ var WsClient = class extends Client {
|
|
|
13
13
|
inFlightRequestMap = /* @__PURE__ */ new Map();
|
|
14
14
|
timeout;
|
|
15
15
|
shouldConnect = true;
|
|
16
|
-
constructor(url, { timeout = 3e4 } = {}) {
|
|
17
|
-
super(url);
|
|
16
|
+
constructor(url, { timeout = 3e4, ...opts } = {}) {
|
|
17
|
+
super(url, opts);
|
|
18
18
|
this.timeout = timeout;
|
|
19
19
|
}
|
|
20
20
|
async close() {
|