@polkadot-api/json-rpc-provider 0.0.4 → 0.1.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.
- package/dist/esm/index.mjs +5 -0
- package/dist/esm/index.mjs.map +1 -0
- package/dist/index.d.ts +28 -4
- package/dist/index.js +8 -0
- package/dist/index.js.map +1 -0
- package/package.json +25 -3
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.mjs","sources":["../../src/index.ts"],"sourcesContent":["export type JsonRpcId = string | number | null\n\nexport type JsonRpcRequest<T = any> = {\n jsonrpc: \"2.0\"\n method: string\n params?: T\n id?: JsonRpcId\n}\n\nexport type JsonRpcError<T = any> = {\n code: number\n message: string\n data?: T\n}\n\nexport type JsonRpcResponse<T = any> = {\n jsonrpc: \"2.0\"\n id: JsonRpcId\n} & (\n | {\n result: T\n }\n | {\n error: JsonRpcError<T>\n }\n)\n\nexport type JsonRpcMessage<T = any> = JsonRpcRequest<T> | JsonRpcResponse<T>\n\nexport interface JsonRpcConnection<T = any> {\n send: (message: JsonRpcRequest<T>) => void\n disconnect: () => void\n}\n\nexport declare type JsonRpcProvider<T = any> = (\n onMessage: (message: JsonRpcMessage<T>) => void,\n) => JsonRpcConnection\n\nexport const isRequest = <T>(\n msg: JsonRpcMessage<T>,\n): msg is JsonRpcRequest<T> => \"method\" in msg\n\nexport const isResponse = <T>(\n msg: JsonRpcMessage<T>,\n): msg is JsonRpcResponse<T> => !(\"method\" in msg)\n"],"names":[],"mappings":"AAsCO,MAAM,SAAA,GAAY,CACvB,GAAA,KAC6B,QAAA,IAAY;AAEpC,MAAM,UAAA,GAAa,CACxB,GAAA,KAC8B,EAAE,QAAA,IAAY,GAAA;;;;"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,31 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
type JsonRpcId = string | number | null;
|
|
2
|
+
type JsonRpcRequest<T = any> = {
|
|
3
|
+
jsonrpc: "2.0";
|
|
4
|
+
method: string;
|
|
5
|
+
params?: T;
|
|
6
|
+
id?: JsonRpcId;
|
|
7
|
+
};
|
|
8
|
+
type JsonRpcError<T = any> = {
|
|
9
|
+
code: number;
|
|
10
|
+
message: string;
|
|
11
|
+
data?: T;
|
|
12
|
+
};
|
|
13
|
+
type JsonRpcResponse<T = any> = {
|
|
14
|
+
jsonrpc: "2.0";
|
|
15
|
+
id: JsonRpcId;
|
|
16
|
+
} & ({
|
|
17
|
+
result: T;
|
|
18
|
+
} | {
|
|
19
|
+
error: JsonRpcError<T>;
|
|
20
|
+
});
|
|
21
|
+
type JsonRpcMessage<T = any> = JsonRpcRequest<T> | JsonRpcResponse<T>;
|
|
22
|
+
interface JsonRpcConnection<T = any> {
|
|
23
|
+
send: (message: JsonRpcRequest<T>) => void;
|
|
3
24
|
disconnect: () => void;
|
|
4
25
|
}
|
|
5
|
-
declare type JsonRpcProvider = (onMessage: (message:
|
|
26
|
+
declare type JsonRpcProvider<T = any> = (onMessage: (message: JsonRpcMessage<T>) => void) => JsonRpcConnection;
|
|
27
|
+
declare const isRequest: <T>(msg: JsonRpcMessage<T>) => msg is JsonRpcRequest<T>;
|
|
28
|
+
declare const isResponse: <T>(msg: JsonRpcMessage<T>) => msg is JsonRpcResponse<T>;
|
|
6
29
|
|
|
7
|
-
export
|
|
30
|
+
export { isRequest, isResponse };
|
|
31
|
+
export type { JsonRpcConnection, JsonRpcError, JsonRpcId, JsonRpcMessage, JsonRpcProvider, JsonRpcRequest, JsonRpcResponse };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../src/index.ts"],"sourcesContent":["export type JsonRpcId = string | number | null\n\nexport type JsonRpcRequest<T = any> = {\n jsonrpc: \"2.0\"\n method: string\n params?: T\n id?: JsonRpcId\n}\n\nexport type JsonRpcError<T = any> = {\n code: number\n message: string\n data?: T\n}\n\nexport type JsonRpcResponse<T = any> = {\n jsonrpc: \"2.0\"\n id: JsonRpcId\n} & (\n | {\n result: T\n }\n | {\n error: JsonRpcError<T>\n }\n)\n\nexport type JsonRpcMessage<T = any> = JsonRpcRequest<T> | JsonRpcResponse<T>\n\nexport interface JsonRpcConnection<T = any> {\n send: (message: JsonRpcRequest<T>) => void\n disconnect: () => void\n}\n\nexport declare type JsonRpcProvider<T = any> = (\n onMessage: (message: JsonRpcMessage<T>) => void,\n) => JsonRpcConnection\n\nexport const isRequest = <T>(\n msg: JsonRpcMessage<T>,\n): msg is JsonRpcRequest<T> => \"method\" in msg\n\nexport const isResponse = <T>(\n msg: JsonRpcMessage<T>,\n): msg is JsonRpcResponse<T> => !(\"method\" in msg)\n"],"names":[],"mappings":";;AAsCO,MAAM,SAAA,GAAY,CACvB,GAAA,KAC6B,QAAA,IAAY;AAEpC,MAAM,UAAA,GAAa,CACxB,GAAA,KAC8B,EAAE,QAAA,IAAY,GAAA;;;;;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@polkadot-api/json-rpc-provider",
|
|
3
|
-
"version": "0.0
|
|
3
|
+
"version": "0.1.0",
|
|
4
4
|
"author": "Josep M Sobrepere (https://github.com/josepot)",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -8,15 +8,37 @@
|
|
|
8
8
|
},
|
|
9
9
|
"license": "MIT",
|
|
10
10
|
"sideEffects": false,
|
|
11
|
-
"
|
|
11
|
+
"exports": {
|
|
12
|
+
".": {
|
|
13
|
+
"node": {
|
|
14
|
+
"production": {
|
|
15
|
+
"import": "./dist/esm/index.mjs",
|
|
16
|
+
"require": "./dist/min/index.js",
|
|
17
|
+
"default": "./dist/index.js"
|
|
18
|
+
},
|
|
19
|
+
"import": "./dist/esm/index.mjs",
|
|
20
|
+
"require": "./dist/index.js",
|
|
21
|
+
"default": "./dist/index.js"
|
|
22
|
+
},
|
|
23
|
+
"module": "./dist/esm/index.mjs",
|
|
24
|
+
"import": "./dist/esm/index.mjs",
|
|
25
|
+
"require": "./dist/index.js",
|
|
26
|
+
"default": "./dist/index.js"
|
|
27
|
+
},
|
|
28
|
+
"./package.json": "./package.json"
|
|
29
|
+
},
|
|
30
|
+
"main": "./dist/index.js",
|
|
31
|
+
"module": "./dist/esm/index.mjs",
|
|
32
|
+
"browser": "./dist/esm/index.mjs",
|
|
12
33
|
"types": "./dist/index.d.ts",
|
|
13
34
|
"files": [
|
|
14
35
|
"dist"
|
|
15
36
|
],
|
|
16
37
|
"scripts": {
|
|
17
|
-
"build-core": "tsc --noEmit && rollup -c
|
|
38
|
+
"build-core": "tsc --noEmit && rollup -c ../../../rollup.config.js",
|
|
18
39
|
"build": "pnpm build-core",
|
|
19
40
|
"test": "echo 'no tests'",
|
|
41
|
+
"coverage": "vitest run --coverage",
|
|
20
42
|
"lint": "prettier --check README.md \"src/**/*.{js,jsx,ts,tsx,json,md}\"",
|
|
21
43
|
"format": "prettier --write README.md \"src/**/*.{js,jsx,ts,tsx,json,md}\""
|
|
22
44
|
}
|