@pezkuwi/rpc-provider 16.5.5 → 16.5.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.
- package/LICENSE +201 -0
- package/README.md +10 -10
- package/bizinikiwi-connect/Health.js +259 -0
- package/{build/substrate-connect → bizinikiwi-connect}/index.d.ts +3 -3
- package/bizinikiwi-connect/index.js +319 -0
- package/{build/bundle.d.ts → bundle.d.ts} +1 -1
- package/{src/bundle.ts → bundle.js} +1 -4
- package/cjs/bizinikiwi-connect/Health.d.ts +7 -0
- package/cjs/bizinikiwi-connect/Health.js +264 -0
- package/cjs/bizinikiwi-connect/index.d.ts +22 -0
- package/cjs/bizinikiwi-connect/index.js +323 -0
- package/cjs/bizinikiwi-connect/types.d.ts +12 -0
- package/cjs/bizinikiwi-connect/types.js +2 -0
- package/cjs/bundle.d.ts +5 -0
- package/cjs/bundle.js +14 -0
- package/cjs/coder/error.js +53 -0
- package/cjs/coder/index.js +63 -0
- package/cjs/defaults.js +8 -0
- package/{build → cjs}/http/index.d.ts +1 -1
- package/cjs/http/index.js +196 -0
- package/cjs/http/types.js +2 -0
- package/cjs/index.js +5 -0
- package/cjs/lru.js +150 -0
- package/cjs/mock/index.js +196 -0
- package/cjs/mock/mockHttp.js +17 -0
- package/cjs/mock/mockWs.js +47 -0
- package/cjs/mock/types.js +2 -0
- package/cjs/package.json +3 -0
- package/cjs/packageDetect.d.ts +1 -0
- package/cjs/packageDetect.js +6 -0
- package/cjs/packageInfo.js +4 -0
- package/cjs/types.js +2 -0
- package/cjs/ws/errors.js +41 -0
- package/{build → cjs}/ws/index.d.ts +1 -1
- package/cjs/ws/index.js +529 -0
- package/coder/error.d.ts +29 -0
- package/coder/error.js +50 -0
- package/coder/index.d.ts +8 -0
- package/coder/index.js +58 -0
- package/defaults.d.ts +5 -0
- package/defaults.js +6 -0
- package/http/index.d.ts +81 -0
- package/http/index.js +191 -0
- package/http/types.d.ts +7 -0
- package/http/types.js +1 -0
- package/index.d.ts +2 -0
- package/index.js +2 -0
- package/lru.d.ts +15 -0
- package/lru.js +146 -0
- package/mock/index.d.ts +35 -0
- package/mock/index.js +191 -0
- package/mock/mockHttp.d.ts +9 -0
- package/mock/mockHttp.js +12 -0
- package/mock/mockWs.d.ts +26 -0
- package/mock/mockWs.js +43 -0
- package/mock/types.d.ts +23 -0
- package/mock/types.js +1 -0
- package/package.json +316 -15
- package/packageDetect.d.ts +1 -0
- package/packageDetect.js +4 -0
- package/packageInfo.d.ts +6 -0
- package/packageInfo.js +1 -0
- package/types.d.ts +85 -0
- package/types.js +1 -0
- package/ws/errors.d.ts +1 -0
- package/ws/errors.js +38 -0
- package/ws/index.d.ts +121 -0
- package/ws/index.js +524 -0
- package/src/coder/decodeResponse.spec.ts +0 -70
- package/src/coder/encodeJson.spec.ts +0 -20
- package/src/coder/encodeObject.spec.ts +0 -25
- package/src/coder/error.spec.ts +0 -111
- package/src/coder/error.ts +0 -66
- package/src/coder/index.ts +0 -88
- package/src/defaults.ts +0 -10
- package/src/http/index.spec.ts +0 -72
- package/src/http/index.ts +0 -238
- package/src/http/send.spec.ts +0 -61
- package/src/http/types.ts +0 -11
- package/src/index.ts +0 -6
- package/src/lru.spec.ts +0 -74
- package/src/lru.ts +0 -197
- package/src/mock/index.ts +0 -259
- package/src/mock/mockHttp.ts +0 -35
- package/src/mock/mockWs.ts +0 -92
- package/src/mock/on.spec.ts +0 -43
- package/src/mock/send.spec.ts +0 -38
- package/src/mock/subscribe.spec.ts +0 -81
- package/src/mock/types.ts +0 -36
- package/src/mock/unsubscribe.spec.ts +0 -57
- package/src/mod.ts +0 -4
- package/src/packageDetect.ts +0 -12
- package/src/packageInfo.ts +0 -6
- package/src/substrate-connect/Health.ts +0 -325
- package/src/substrate-connect/index.spec.ts +0 -638
- package/src/substrate-connect/index.ts +0 -415
- package/src/substrate-connect/types.ts +0 -16
- package/src/types.ts +0 -101
- package/src/ws/connect.spec.ts +0 -167
- package/src/ws/errors.ts +0 -41
- package/src/ws/index.spec.ts +0 -97
- package/src/ws/index.ts +0 -652
- package/src/ws/send.spec.ts +0 -126
- package/src/ws/state.spec.ts +0 -20
- package/src/ws/subscribe.spec.ts +0 -68
- package/src/ws/unsubscribe.spec.ts +0 -100
- package/tsconfig.build.json +0 -17
- package/tsconfig.build.tsbuildinfo +0 -1
- package/tsconfig.spec.json +0 -18
- /package/{build/substrate-connect → bizinikiwi-connect}/Health.d.ts +0 -0
- /package/{build/substrate-connect → bizinikiwi-connect}/types.d.ts +0 -0
- /package/{build/packageDetect.d.ts → bizinikiwi-connect/types.js} +0 -0
- /package/{build → cjs}/coder/error.d.ts +0 -0
- /package/{build → cjs}/coder/index.d.ts +0 -0
- /package/{build → cjs}/defaults.d.ts +0 -0
- /package/{build → cjs}/http/types.d.ts +0 -0
- /package/{build → cjs}/index.d.ts +0 -0
- /package/{build → cjs}/lru.d.ts +0 -0
- /package/{build → cjs}/mock/index.d.ts +0 -0
- /package/{build → cjs}/mock/mockHttp.d.ts +0 -0
- /package/{build → cjs}/mock/mockWs.d.ts +0 -0
- /package/{build → cjs}/mock/types.d.ts +0 -0
- /package/{build → cjs}/packageInfo.d.ts +0 -0
- /package/{build → cjs}/types.d.ts +0 -0
- /package/{build → cjs}/ws/errors.d.ts +0 -0
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { Mock } from './types.js';
|
|
2
|
+
interface Request {
|
|
3
|
+
code?: number;
|
|
4
|
+
method: string;
|
|
5
|
+
reply?: Record<string, unknown>;
|
|
6
|
+
}
|
|
7
|
+
export declare const TEST_HTTP_URL = "http://localhost:9944";
|
|
8
|
+
export declare function mockHttp(requests: Request[]): Mock;
|
|
9
|
+
export {};
|
package/mock/mockHttp.js
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import nock from 'nock';
|
|
2
|
+
export const TEST_HTTP_URL = 'http://localhost:9944';
|
|
3
|
+
export function mockHttp(requests) {
|
|
4
|
+
nock.cleanAll();
|
|
5
|
+
return requests.reduce((scope, request) => scope
|
|
6
|
+
.post('/')
|
|
7
|
+
.reply(request.code || 200, (_uri, body) => {
|
|
8
|
+
scope.body = scope.body || {};
|
|
9
|
+
scope.body[request.method] = body;
|
|
10
|
+
return Object.assign({ id: body.id, jsonrpc: '2.0' }, request.reply || {});
|
|
11
|
+
}), nock(TEST_HTTP_URL));
|
|
12
|
+
}
|
package/mock/mockWs.d.ts
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { Server } from 'mock-socket';
|
|
2
|
+
interface Scope {
|
|
3
|
+
body: Record<string, Record<string, unknown>>;
|
|
4
|
+
requests: number;
|
|
5
|
+
server: Server;
|
|
6
|
+
done: any;
|
|
7
|
+
}
|
|
8
|
+
interface ErrorDef {
|
|
9
|
+
id: number;
|
|
10
|
+
error: {
|
|
11
|
+
code: number;
|
|
12
|
+
message: string;
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
interface ReplyDef {
|
|
16
|
+
id: number;
|
|
17
|
+
reply: {
|
|
18
|
+
result: unknown;
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
export type Request = {
|
|
22
|
+
method: string;
|
|
23
|
+
} & (ErrorDef | ReplyDef);
|
|
24
|
+
export declare const TEST_WS_URL = "ws://localhost:9955";
|
|
25
|
+
export declare function mockWs(requests: Request[], wsUrl?: string): Scope;
|
|
26
|
+
export {};
|
package/mock/mockWs.js
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { Server, WebSocket } from 'mock-socket';
|
|
2
|
+
import { stringify } from '@pezkuwi/util';
|
|
3
|
+
global.WebSocket = WebSocket;
|
|
4
|
+
export const TEST_WS_URL = 'ws://localhost:9955';
|
|
5
|
+
function createError({ error: { code, message }, id }) {
|
|
6
|
+
return {
|
|
7
|
+
error: {
|
|
8
|
+
code,
|
|
9
|
+
message
|
|
10
|
+
},
|
|
11
|
+
id,
|
|
12
|
+
jsonrpc: '2.0'
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
function createReply({ id, reply: { result } }) {
|
|
16
|
+
return {
|
|
17
|
+
id,
|
|
18
|
+
jsonrpc: '2.0',
|
|
19
|
+
result
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
export function mockWs(requests, wsUrl = TEST_WS_URL) {
|
|
23
|
+
const server = new Server(wsUrl);
|
|
24
|
+
let requestCount = 0;
|
|
25
|
+
const scope = {
|
|
26
|
+
body: {},
|
|
27
|
+
done: () => new Promise((resolve) => server.stop(resolve)),
|
|
28
|
+
requests: 0,
|
|
29
|
+
server
|
|
30
|
+
};
|
|
31
|
+
server.on('connection', (socket) => {
|
|
32
|
+
socket.on('message', (body) => {
|
|
33
|
+
const request = requests[requestCount];
|
|
34
|
+
const response = request.error
|
|
35
|
+
? createError(request)
|
|
36
|
+
: createReply(request);
|
|
37
|
+
scope.body[request.method] = body;
|
|
38
|
+
requestCount++;
|
|
39
|
+
socket.send(stringify(response));
|
|
40
|
+
});
|
|
41
|
+
});
|
|
42
|
+
return scope;
|
|
43
|
+
}
|
package/mock/types.d.ts
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { Server } from 'mock-socket';
|
|
2
|
+
export type Global = typeof globalThis & {
|
|
3
|
+
WebSocket: typeof WebSocket;
|
|
4
|
+
fetch: any;
|
|
5
|
+
};
|
|
6
|
+
export interface Mock {
|
|
7
|
+
body: Record<string, Record<string, unknown>>;
|
|
8
|
+
requests: number;
|
|
9
|
+
server: Server;
|
|
10
|
+
done: () => Promise<void>;
|
|
11
|
+
}
|
|
12
|
+
export type MockStateSubscriptionCallback = (error: Error | null, value: any) => void;
|
|
13
|
+
export interface MockStateSubscription {
|
|
14
|
+
callbacks: Record<number, MockStateSubscriptionCallback>;
|
|
15
|
+
lastValue: any;
|
|
16
|
+
}
|
|
17
|
+
export interface MockStateSubscriptions {
|
|
18
|
+
chain_subscribeNewHead: MockStateSubscription;
|
|
19
|
+
state_subscribeStorage: MockStateSubscription;
|
|
20
|
+
[key: string]: MockStateSubscription;
|
|
21
|
+
}
|
|
22
|
+
export type MockStateDb = Record<string, Uint8Array>;
|
|
23
|
+
export type MockStateRequests = Record<string, (db: MockStateDb, params: any[]) => string>;
|
package/mock/types.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/package.json
CHANGED
|
@@ -15,29 +15,330 @@
|
|
|
15
15
|
},
|
|
16
16
|
"sideEffects": [
|
|
17
17
|
"./packageDetect.js",
|
|
18
|
-
"./packageDetect.
|
|
18
|
+
"./cjs/packageDetect.js"
|
|
19
19
|
],
|
|
20
20
|
"type": "module",
|
|
21
|
-
"version": "16.5.
|
|
22
|
-
"main": "index.js",
|
|
21
|
+
"version": "16.5.6",
|
|
22
|
+
"main": "./cjs/index.js",
|
|
23
|
+
"module": "./index.js",
|
|
24
|
+
"types": "./index.d.ts",
|
|
25
|
+
"exports": {
|
|
26
|
+
"./cjs/package.json": "./cjs/package.json",
|
|
27
|
+
"./cjs/*": "./cjs/*.js",
|
|
28
|
+
".": {
|
|
29
|
+
"module": {
|
|
30
|
+
"types": "./index.d.ts",
|
|
31
|
+
"default": "./index.js"
|
|
32
|
+
},
|
|
33
|
+
"require": {
|
|
34
|
+
"types": "./cjs/index.d.ts",
|
|
35
|
+
"default": "./cjs/index.js"
|
|
36
|
+
},
|
|
37
|
+
"default": {
|
|
38
|
+
"types": "./index.d.ts",
|
|
39
|
+
"default": "./index.js"
|
|
40
|
+
}
|
|
41
|
+
},
|
|
42
|
+
"./bizinikiwi-connect": {
|
|
43
|
+
"module": {
|
|
44
|
+
"types": "./bizinikiwi-connect/index.d.ts",
|
|
45
|
+
"default": "./bizinikiwi-connect/index.js"
|
|
46
|
+
},
|
|
47
|
+
"require": {
|
|
48
|
+
"types": "./cjs/bizinikiwi-connect/index.d.ts",
|
|
49
|
+
"default": "./cjs/bizinikiwi-connect/index.js"
|
|
50
|
+
},
|
|
51
|
+
"default": {
|
|
52
|
+
"types": "./bizinikiwi-connect/index.d.ts",
|
|
53
|
+
"default": "./bizinikiwi-connect/index.js"
|
|
54
|
+
}
|
|
55
|
+
},
|
|
56
|
+
"./bizinikiwi-connect/Health": {
|
|
57
|
+
"module": {
|
|
58
|
+
"types": "./bizinikiwi-connect/Health.d.ts",
|
|
59
|
+
"default": "./bizinikiwi-connect/Health.js"
|
|
60
|
+
},
|
|
61
|
+
"require": {
|
|
62
|
+
"types": "./cjs/bizinikiwi-connect/Health.d.ts",
|
|
63
|
+
"default": "./cjs/bizinikiwi-connect/Health.js"
|
|
64
|
+
},
|
|
65
|
+
"default": {
|
|
66
|
+
"types": "./bizinikiwi-connect/Health.d.ts",
|
|
67
|
+
"default": "./bizinikiwi-connect/Health.js"
|
|
68
|
+
}
|
|
69
|
+
},
|
|
70
|
+
"./bizinikiwi-connect/types": {
|
|
71
|
+
"module": {
|
|
72
|
+
"types": "./bizinikiwi-connect/types.d.ts",
|
|
73
|
+
"default": "./bizinikiwi-connect/types.js"
|
|
74
|
+
},
|
|
75
|
+
"require": {
|
|
76
|
+
"types": "./cjs/bizinikiwi-connect/types.d.ts",
|
|
77
|
+
"default": "./cjs/bizinikiwi-connect/types.js"
|
|
78
|
+
},
|
|
79
|
+
"default": {
|
|
80
|
+
"types": "./bizinikiwi-connect/types.d.ts",
|
|
81
|
+
"default": "./bizinikiwi-connect/types.js"
|
|
82
|
+
}
|
|
83
|
+
},
|
|
84
|
+
"./bundle": {
|
|
85
|
+
"module": {
|
|
86
|
+
"types": "./bundle.d.ts",
|
|
87
|
+
"default": "./bundle.js"
|
|
88
|
+
},
|
|
89
|
+
"require": {
|
|
90
|
+
"types": "./cjs/bundle.d.ts",
|
|
91
|
+
"default": "./cjs/bundle.js"
|
|
92
|
+
},
|
|
93
|
+
"default": {
|
|
94
|
+
"types": "./bundle.d.ts",
|
|
95
|
+
"default": "./bundle.js"
|
|
96
|
+
}
|
|
97
|
+
},
|
|
98
|
+
"./coder": {
|
|
99
|
+
"module": {
|
|
100
|
+
"types": "./coder/index.d.ts",
|
|
101
|
+
"default": "./coder/index.js"
|
|
102
|
+
},
|
|
103
|
+
"require": {
|
|
104
|
+
"types": "./cjs/coder/index.d.ts",
|
|
105
|
+
"default": "./cjs/coder/index.js"
|
|
106
|
+
},
|
|
107
|
+
"default": {
|
|
108
|
+
"types": "./coder/index.d.ts",
|
|
109
|
+
"default": "./coder/index.js"
|
|
110
|
+
}
|
|
111
|
+
},
|
|
112
|
+
"./coder/error": {
|
|
113
|
+
"module": {
|
|
114
|
+
"types": "./coder/error.d.ts",
|
|
115
|
+
"default": "./coder/error.js"
|
|
116
|
+
},
|
|
117
|
+
"require": {
|
|
118
|
+
"types": "./cjs/coder/error.d.ts",
|
|
119
|
+
"default": "./cjs/coder/error.js"
|
|
120
|
+
},
|
|
121
|
+
"default": {
|
|
122
|
+
"types": "./coder/error.d.ts",
|
|
123
|
+
"default": "./coder/error.js"
|
|
124
|
+
}
|
|
125
|
+
},
|
|
126
|
+
"./defaults": {
|
|
127
|
+
"module": {
|
|
128
|
+
"types": "./defaults.d.ts",
|
|
129
|
+
"default": "./defaults.js"
|
|
130
|
+
},
|
|
131
|
+
"require": {
|
|
132
|
+
"types": "./cjs/defaults.d.ts",
|
|
133
|
+
"default": "./cjs/defaults.js"
|
|
134
|
+
},
|
|
135
|
+
"default": {
|
|
136
|
+
"types": "./defaults.d.ts",
|
|
137
|
+
"default": "./defaults.js"
|
|
138
|
+
}
|
|
139
|
+
},
|
|
140
|
+
"./http": {
|
|
141
|
+
"module": {
|
|
142
|
+
"types": "./http/index.d.ts",
|
|
143
|
+
"default": "./http/index.js"
|
|
144
|
+
},
|
|
145
|
+
"require": {
|
|
146
|
+
"types": "./cjs/http/index.d.ts",
|
|
147
|
+
"default": "./cjs/http/index.js"
|
|
148
|
+
},
|
|
149
|
+
"default": {
|
|
150
|
+
"types": "./http/index.d.ts",
|
|
151
|
+
"default": "./http/index.js"
|
|
152
|
+
}
|
|
153
|
+
},
|
|
154
|
+
"./http/types": {
|
|
155
|
+
"module": {
|
|
156
|
+
"types": "./http/types.d.ts",
|
|
157
|
+
"default": "./http/types.js"
|
|
158
|
+
},
|
|
159
|
+
"require": {
|
|
160
|
+
"types": "./cjs/http/types.d.ts",
|
|
161
|
+
"default": "./cjs/http/types.js"
|
|
162
|
+
},
|
|
163
|
+
"default": {
|
|
164
|
+
"types": "./http/types.d.ts",
|
|
165
|
+
"default": "./http/types.js"
|
|
166
|
+
}
|
|
167
|
+
},
|
|
168
|
+
"./lru": {
|
|
169
|
+
"module": {
|
|
170
|
+
"types": "./lru.d.ts",
|
|
171
|
+
"default": "./lru.js"
|
|
172
|
+
},
|
|
173
|
+
"require": {
|
|
174
|
+
"types": "./cjs/lru.d.ts",
|
|
175
|
+
"default": "./cjs/lru.js"
|
|
176
|
+
},
|
|
177
|
+
"default": {
|
|
178
|
+
"types": "./lru.d.ts",
|
|
179
|
+
"default": "./lru.js"
|
|
180
|
+
}
|
|
181
|
+
},
|
|
182
|
+
"./mock": {
|
|
183
|
+
"module": {
|
|
184
|
+
"types": "./mock/index.d.ts",
|
|
185
|
+
"default": "./mock/index.js"
|
|
186
|
+
},
|
|
187
|
+
"require": {
|
|
188
|
+
"types": "./cjs/mock/index.d.ts",
|
|
189
|
+
"default": "./cjs/mock/index.js"
|
|
190
|
+
},
|
|
191
|
+
"default": {
|
|
192
|
+
"types": "./mock/index.d.ts",
|
|
193
|
+
"default": "./mock/index.js"
|
|
194
|
+
}
|
|
195
|
+
},
|
|
196
|
+
"./mock/mockHttp": {
|
|
197
|
+
"module": {
|
|
198
|
+
"types": "./mock/mockHttp.d.ts",
|
|
199
|
+
"default": "./mock/mockHttp.js"
|
|
200
|
+
},
|
|
201
|
+
"require": {
|
|
202
|
+
"types": "./cjs/mock/mockHttp.d.ts",
|
|
203
|
+
"default": "./cjs/mock/mockHttp.js"
|
|
204
|
+
},
|
|
205
|
+
"default": {
|
|
206
|
+
"types": "./mock/mockHttp.d.ts",
|
|
207
|
+
"default": "./mock/mockHttp.js"
|
|
208
|
+
}
|
|
209
|
+
},
|
|
210
|
+
"./mock/mockWs": {
|
|
211
|
+
"module": {
|
|
212
|
+
"types": "./mock/mockWs.d.ts",
|
|
213
|
+
"default": "./mock/mockWs.js"
|
|
214
|
+
},
|
|
215
|
+
"require": {
|
|
216
|
+
"types": "./cjs/mock/mockWs.d.ts",
|
|
217
|
+
"default": "./cjs/mock/mockWs.js"
|
|
218
|
+
},
|
|
219
|
+
"default": {
|
|
220
|
+
"types": "./mock/mockWs.d.ts",
|
|
221
|
+
"default": "./mock/mockWs.js"
|
|
222
|
+
}
|
|
223
|
+
},
|
|
224
|
+
"./mock/types": {
|
|
225
|
+
"module": {
|
|
226
|
+
"types": "./mock/types.d.ts",
|
|
227
|
+
"default": "./mock/types.js"
|
|
228
|
+
},
|
|
229
|
+
"require": {
|
|
230
|
+
"types": "./cjs/mock/types.d.ts",
|
|
231
|
+
"default": "./cjs/mock/types.js"
|
|
232
|
+
},
|
|
233
|
+
"default": {
|
|
234
|
+
"types": "./mock/types.d.ts",
|
|
235
|
+
"default": "./mock/types.js"
|
|
236
|
+
}
|
|
237
|
+
},
|
|
238
|
+
"./package.json": {
|
|
239
|
+
"require": "./cjs/package.json",
|
|
240
|
+
"default": "./package.json"
|
|
241
|
+
},
|
|
242
|
+
"./packageDetect": {
|
|
243
|
+
"module": {
|
|
244
|
+
"types": "./packageDetect.d.ts",
|
|
245
|
+
"default": "./packageDetect.js"
|
|
246
|
+
},
|
|
247
|
+
"require": {
|
|
248
|
+
"types": "./cjs/packageDetect.d.ts",
|
|
249
|
+
"default": "./cjs/packageDetect.js"
|
|
250
|
+
},
|
|
251
|
+
"default": {
|
|
252
|
+
"types": "./packageDetect.d.ts",
|
|
253
|
+
"default": "./packageDetect.js"
|
|
254
|
+
}
|
|
255
|
+
},
|
|
256
|
+
"./packageInfo.js": {
|
|
257
|
+
"module": {
|
|
258
|
+
"types": "./packageInfo.d.ts",
|
|
259
|
+
"default": "./packageInfo.js"
|
|
260
|
+
},
|
|
261
|
+
"require": {
|
|
262
|
+
"types": "./cjs/packageInfo.d.ts",
|
|
263
|
+
"default": "./cjs/packageInfo.js"
|
|
264
|
+
},
|
|
265
|
+
"default": {
|
|
266
|
+
"types": "./packageInfo.d.ts",
|
|
267
|
+
"default": "./packageInfo.js"
|
|
268
|
+
}
|
|
269
|
+
},
|
|
270
|
+
"./packageInfo": {
|
|
271
|
+
"module": {
|
|
272
|
+
"types": "./packageInfo.d.ts",
|
|
273
|
+
"default": "./packageInfo.js"
|
|
274
|
+
},
|
|
275
|
+
"require": {
|
|
276
|
+
"types": "./cjs/packageInfo.d.ts",
|
|
277
|
+
"default": "./cjs/packageInfo.js"
|
|
278
|
+
},
|
|
279
|
+
"default": {
|
|
280
|
+
"types": "./packageInfo.d.ts",
|
|
281
|
+
"default": "./packageInfo.js"
|
|
282
|
+
}
|
|
283
|
+
},
|
|
284
|
+
"./types": {
|
|
285
|
+
"module": {
|
|
286
|
+
"types": "./types.d.ts",
|
|
287
|
+
"default": "./types.js"
|
|
288
|
+
},
|
|
289
|
+
"require": {
|
|
290
|
+
"types": "./cjs/types.d.ts",
|
|
291
|
+
"default": "./cjs/types.js"
|
|
292
|
+
},
|
|
293
|
+
"default": {
|
|
294
|
+
"types": "./types.d.ts",
|
|
295
|
+
"default": "./types.js"
|
|
296
|
+
}
|
|
297
|
+
},
|
|
298
|
+
"./ws": {
|
|
299
|
+
"module": {
|
|
300
|
+
"types": "./ws/index.d.ts",
|
|
301
|
+
"default": "./ws/index.js"
|
|
302
|
+
},
|
|
303
|
+
"require": {
|
|
304
|
+
"types": "./cjs/ws/index.d.ts",
|
|
305
|
+
"default": "./cjs/ws/index.js"
|
|
306
|
+
},
|
|
307
|
+
"default": {
|
|
308
|
+
"types": "./ws/index.d.ts",
|
|
309
|
+
"default": "./ws/index.js"
|
|
310
|
+
}
|
|
311
|
+
},
|
|
312
|
+
"./ws/errors": {
|
|
313
|
+
"module": {
|
|
314
|
+
"types": "./ws/errors.d.ts",
|
|
315
|
+
"default": "./ws/errors.js"
|
|
316
|
+
},
|
|
317
|
+
"require": {
|
|
318
|
+
"types": "./cjs/ws/errors.d.ts",
|
|
319
|
+
"default": "./cjs/ws/errors.js"
|
|
320
|
+
},
|
|
321
|
+
"default": {
|
|
322
|
+
"types": "./ws/errors.d.ts",
|
|
323
|
+
"default": "./ws/errors.js"
|
|
324
|
+
}
|
|
325
|
+
}
|
|
326
|
+
},
|
|
23
327
|
"dependencies": {
|
|
24
|
-
"@pezkuwi/keyring": "14.0.
|
|
25
|
-
"@pezkuwi/types": "16.5.
|
|
26
|
-
"@pezkuwi/types-support": "16.5.
|
|
27
|
-
"@pezkuwi/util": "14.0.
|
|
28
|
-
"@pezkuwi/util-crypto": "14.0.
|
|
29
|
-
"@pezkuwi/x-fetch": "14.0.
|
|
30
|
-
"@pezkuwi/x-global": "14.0.
|
|
31
|
-
"@pezkuwi/x-ws": "14.0.
|
|
328
|
+
"@pezkuwi/keyring": "^14.0.1",
|
|
329
|
+
"@pezkuwi/types": "16.5.4",
|
|
330
|
+
"@pezkuwi/types-support": "16.5.4",
|
|
331
|
+
"@pezkuwi/util": "^14.0.1",
|
|
332
|
+
"@pezkuwi/util-crypto": "^14.0.1",
|
|
333
|
+
"@pezkuwi/x-fetch": "^14.0.1",
|
|
334
|
+
"@pezkuwi/x-global": "^14.0.1",
|
|
335
|
+
"@pezkuwi/x-ws": "^14.0.1",
|
|
32
336
|
"eventemitter3": "^5.0.1",
|
|
33
337
|
"mock-socket": "^9.3.1",
|
|
34
338
|
"nock": "^13.5.5",
|
|
35
339
|
"tslib": "^2.8.1"
|
|
36
340
|
},
|
|
37
|
-
"devDependencies": {
|
|
38
|
-
"@substrate/connect": "0.8.11"
|
|
39
|
-
},
|
|
40
341
|
"optionalDependencies": {
|
|
41
|
-
"@
|
|
342
|
+
"@bizinikiwi/connect": "2.1.9"
|
|
42
343
|
}
|
|
43
344
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/packageDetect.js
ADDED
package/packageInfo.d.ts
ADDED
package/packageInfo.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const packageInfo = { name: '@pezkuwi/rpc-provider', path: (import.meta && import.meta.url) ? new URL(import.meta.url).pathname.substring(0, new URL(import.meta.url).pathname.lastIndexOf('/') + 1) : 'auto', type: 'esm', version: '16.5.4' };
|
package/types.d.ts
ADDED
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
export interface JsonRpcObject {
|
|
2
|
+
id: number;
|
|
3
|
+
jsonrpc: '2.0';
|
|
4
|
+
}
|
|
5
|
+
export interface JsonRpcRequest extends JsonRpcObject {
|
|
6
|
+
method: string;
|
|
7
|
+
params: unknown[];
|
|
8
|
+
}
|
|
9
|
+
export interface JsonRpcResponseBaseError {
|
|
10
|
+
code: number;
|
|
11
|
+
data?: number | string;
|
|
12
|
+
message: string;
|
|
13
|
+
}
|
|
14
|
+
export interface RpcErrorInterface<T> {
|
|
15
|
+
code: number;
|
|
16
|
+
data?: T;
|
|
17
|
+
message: string;
|
|
18
|
+
stack: string;
|
|
19
|
+
}
|
|
20
|
+
interface JsonRpcResponseSingle<T> {
|
|
21
|
+
error?: JsonRpcResponseBaseError;
|
|
22
|
+
result: T;
|
|
23
|
+
}
|
|
24
|
+
interface JsonRpcResponseSubscription<T> {
|
|
25
|
+
method?: string;
|
|
26
|
+
params: {
|
|
27
|
+
error?: JsonRpcResponseBaseError;
|
|
28
|
+
result: T;
|
|
29
|
+
subscription: number | string;
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
export type JsonRpcResponseBase<T> = JsonRpcResponseSingle<T> & JsonRpcResponseSubscription<T>;
|
|
33
|
+
export type JsonRpcResponse<T> = JsonRpcObject & JsonRpcResponseBase<T>;
|
|
34
|
+
export type ProviderInterfaceCallback = (error: Error | null, result: any) => void;
|
|
35
|
+
export type ProviderInterfaceEmitted = 'connected' | 'disconnected' | 'error';
|
|
36
|
+
export type ProviderInterfaceEmitCb = (value?: any) => any;
|
|
37
|
+
export interface ProviderInterface {
|
|
38
|
+
/** true if the provider supports subscriptions (not available for HTTP) */
|
|
39
|
+
readonly hasSubscriptions: boolean;
|
|
40
|
+
/** true if the clone() functionality is available on the provider */
|
|
41
|
+
readonly isClonable: boolean;
|
|
42
|
+
/** true if the provider is currently connected (ws/sc has connection logic) */
|
|
43
|
+
readonly isConnected: boolean;
|
|
44
|
+
/** (optional) stats for the provider with connections/bytes */
|
|
45
|
+
readonly stats?: ProviderStats;
|
|
46
|
+
/** (optional) stats for the provider with connections/bytes */
|
|
47
|
+
readonly ttl?: number | null;
|
|
48
|
+
clone(): ProviderInterface;
|
|
49
|
+
connect(): Promise<void>;
|
|
50
|
+
disconnect(): Promise<void>;
|
|
51
|
+
on(type: ProviderInterfaceEmitted, sub: ProviderInterfaceEmitCb): () => void;
|
|
52
|
+
send<T = any>(method: string, params: unknown[], isCacheable?: boolean): Promise<T>;
|
|
53
|
+
subscribe(type: string, method: string, params: unknown[], cb: ProviderInterfaceCallback): Promise<number | string>;
|
|
54
|
+
unsubscribe(type: string, method: string, id: number | string): Promise<boolean>;
|
|
55
|
+
}
|
|
56
|
+
/** Stats for a specific endpoint */
|
|
57
|
+
export interface EndpointStats {
|
|
58
|
+
/** The total number of bytes sent */
|
|
59
|
+
bytesRecv: number;
|
|
60
|
+
/** The total number of bytes received */
|
|
61
|
+
bytesSent: number;
|
|
62
|
+
/** The number of cached/in-progress requests made */
|
|
63
|
+
cached: number;
|
|
64
|
+
/** The number of errors found */
|
|
65
|
+
errors: number;
|
|
66
|
+
/** The number of requests */
|
|
67
|
+
requests: number;
|
|
68
|
+
/** The number of subscriptions */
|
|
69
|
+
subscriptions: number;
|
|
70
|
+
/** The number of request timeouts */
|
|
71
|
+
timeout: number;
|
|
72
|
+
}
|
|
73
|
+
/** Overall stats for the provider */
|
|
74
|
+
export interface ProviderStats {
|
|
75
|
+
/** Details for the active/open requests */
|
|
76
|
+
active: {
|
|
77
|
+
/** Number of active requests */
|
|
78
|
+
requests: number;
|
|
79
|
+
/** Number of active subscriptions */
|
|
80
|
+
subscriptions: number;
|
|
81
|
+
};
|
|
82
|
+
/** The total requests that have been made */
|
|
83
|
+
total: EndpointStats;
|
|
84
|
+
}
|
|
85
|
+
export {};
|
package/types.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/ws/errors.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function getWSErrorString(code: number): string;
|
package/ws/errors.js
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
const known = {
|
|
2
|
+
1000: 'Normal Closure',
|
|
3
|
+
1001: 'Going Away',
|
|
4
|
+
1002: 'Protocol Error',
|
|
5
|
+
1003: 'Unsupported Data',
|
|
6
|
+
1004: '(For future)',
|
|
7
|
+
1005: 'No Status Received',
|
|
8
|
+
1006: 'Abnormal Closure',
|
|
9
|
+
1007: 'Invalid frame payload data',
|
|
10
|
+
1008: 'Policy Violation',
|
|
11
|
+
1009: 'Message too big',
|
|
12
|
+
1010: 'Missing Extension',
|
|
13
|
+
1011: 'Internal Error',
|
|
14
|
+
1012: 'Service Restart',
|
|
15
|
+
1013: 'Try Again Later',
|
|
16
|
+
1014: 'Bad Gateway',
|
|
17
|
+
1015: 'TLS Handshake'
|
|
18
|
+
};
|
|
19
|
+
export function getWSErrorString(code) {
|
|
20
|
+
if (code >= 0 && code <= 999) {
|
|
21
|
+
return '(Unused)';
|
|
22
|
+
}
|
|
23
|
+
else if (code >= 1016) {
|
|
24
|
+
if (code <= 1999) {
|
|
25
|
+
return '(For WebSocket standard)';
|
|
26
|
+
}
|
|
27
|
+
else if (code <= 2999) {
|
|
28
|
+
return '(For WebSocket extensions)';
|
|
29
|
+
}
|
|
30
|
+
else if (code <= 3999) {
|
|
31
|
+
return '(For libraries and frameworks)';
|
|
32
|
+
}
|
|
33
|
+
else if (code <= 4999) {
|
|
34
|
+
return '(For applications)';
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
return known[code] || '(Unknown)';
|
|
38
|
+
}
|