@atomicfinance/jsonrpc-provider 3.5.3 → 3.6.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atomicfinance/jsonrpc-provider",
3
- "version": "3.5.3",
3
+ "version": "3.6.1",
4
4
  "description": "",
5
5
  "module": "dist/index.js",
6
6
  "main": "dist/index.js",
@@ -23,8 +23,8 @@
23
23
  "node": ">=14"
24
24
  },
25
25
  "dependencies": {
26
- "@atomicfinance/errors": "^3.5.3",
27
- "@atomicfinance/node-provider": "^3.5.3",
26
+ "@atomicfinance/errors": "^3.6.1",
27
+ "@atomicfinance/node-provider": "^3.6.1",
28
28
  "@babel/runtime": "^7.12.1",
29
29
  "@types/lodash": "^4.14.168",
30
30
  "json-bigint": "^1.0.0",
@@ -1,52 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- const errors_1 = require("@atomicfinance/errors");
7
- const node_provider_1 = require("@atomicfinance/node-provider");
8
- const json_bigint_1 = __importDefault(require("json-bigint"));
9
- const lodash_1 = require("lodash");
10
- const { parse, stringify } = (0, json_bigint_1.default)({
11
- storeAsString: true,
12
- strict: true,
13
- useNativeBigInt: true,
14
- });
15
- class JsonRpcProvider extends node_provider_1.NodeProvider {
16
- constructor(uri, username, password) {
17
- const config = {
18
- baseURL: uri,
19
- responseType: 'text',
20
- transformResponse: undefined,
21
- validateStatus: () => true,
22
- };
23
- if (username || password) {
24
- config.auth = { username, password };
25
- }
26
- super(config);
27
- }
28
- _prepareRequest(method, params) {
29
- const id = Date.now();
30
- const jsonrpc = '2.0';
31
- const req = { id, method, jsonrpc, params };
32
- return req;
33
- }
34
- _parseResponse(_data) {
35
- const dataString = typeof _data !== 'string' ? stringify(_data) : _data;
36
- const data = parse(dataString);
37
- const { error } = data;
38
- if (error != null) {
39
- throw new errors_1.NodeError(error.message || error);
40
- }
41
- if (!(0, lodash_1.has)(data, 'result')) {
42
- throw new errors_1.NodeError('Missing `result` on the RPC call result');
43
- }
44
- return data.result;
45
- }
46
- async jsonrpc(method, ...params) {
47
- const data = await super.nodePost('', this._prepareRequest(method, params));
48
- return this._parseResponse(data);
49
- }
50
- }
51
- exports.default = JsonRpcProvider;
52
- //# sourceMappingURL=JsonRpcProvider.js.map
package/lib/index.js DELETED
@@ -1,9 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.JsonRpcProvider = void 0;
7
- const JsonRpcProvider_1 = __importDefault(require("./JsonRpcProvider"));
8
- exports.JsonRpcProvider = JsonRpcProvider_1.default;
9
- //# sourceMappingURL=index.js.map