@ckb-lumos/rpc
Advanced tools
Comparing version 0.21.0-next.1 to 0.21.0-next.2
@@ -12,4 +12,4 @@ "use strict"; | ||
var _exceptions = require("./exceptions"); | ||
var _axios = _interopRequireDefault(require("axios")); | ||
var _initAxiosWebworkerAdapter = require("./initAxiosWebworkerAdapter"); | ||
var _crossFetch = _interopRequireDefault(require("cross-fetch")); | ||
var _abortController = require("abort-controller"); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
@@ -27,3 +27,3 @@ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); } | ||
function _classExtractFieldDescriptor(receiver, privateMap, action) { if (!privateMap.has(receiver)) { throw new TypeError("attempted to " + action + " private field on non-instance"); } return privateMap.get(receiver); } | ||
function _classApplyDescriptorGet(receiver, descriptor) { if (descriptor.get) { return descriptor.get.call(receiver); } return descriptor.value; } // import axios from 'axios' | ||
function _classApplyDescriptorGet(receiver, descriptor) { if (descriptor.get) { return descriptor.get.call(receiver); } return descriptor.value; } | ||
const ParamsFormatter = _paramsFormatter2.formatter; | ||
@@ -33,3 +33,2 @@ exports.ParamsFormatter = ParamsFormatter; | ||
exports.ResultFormatter = ResultFormatter; | ||
(0, _initAxiosWebworkerAdapter.initAxiosWebworkerAdapter)(); | ||
var _config = /*#__PURE__*/new WeakMap(); | ||
@@ -126,3 +125,6 @@ var _node = /*#__PURE__*/new WeakMap(); | ||
}); | ||
const batchRes = await (0, _axios.default)({ | ||
const controller = new _abortController.AbortController(); | ||
const signal = controller.signal; | ||
const timeout = setTimeout(() => controller.abort(), _classPrivateFieldGet(ctx, _config).timeout); | ||
const batchRes = await (0, _crossFetch.default)(_classPrivateFieldGet(ctx, _node).url, { | ||
method: "POST", | ||
@@ -132,9 +134,7 @@ headers: { | ||
}, | ||
data: payload, | ||
url: _classPrivateFieldGet(ctx, _node).url, | ||
httpAgent: _classPrivateFieldGet(ctx, _node).httpAgent, | ||
httpsAgent: _classPrivateFieldGet(ctx, _node).httpsAgent, | ||
timeout: _classPrivateFieldGet(ctx, _config).timeout | ||
}); | ||
return batchRes.data.map((res, i) => { | ||
body: JSON.stringify(payload), | ||
signal: signal | ||
}).then(res => res.json()); | ||
clearTimeout(timeout); | ||
return batchRes.map((res, i) => { | ||
var _ctx$rpcProperties$pr, _ctx$rpcProperties$pr2, _ctx$rpcProperties$pr3; | ||
@@ -141,0 +141,0 @@ if (res.id !== payload[i].id) { |
@@ -7,5 +7,5 @@ "use strict"; | ||
exports.Method = void 0; | ||
var _axios = _interopRequireDefault(require("axios")); | ||
var _exceptions = require("./exceptions"); | ||
var _initAxiosWebworkerAdapter = require("./initAxiosWebworkerAdapter"); | ||
var _crossFetch = _interopRequireDefault(require("cross-fetch")); | ||
var _abortController = require("abort-controller"); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
@@ -22,3 +22,2 @@ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } | ||
function _classApplyDescriptorGet(receiver, descriptor) { if (descriptor.get) { return descriptor.get.call(receiver); } return descriptor.value; } | ||
(0, _initAxiosWebworkerAdapter.initAxiosWebworkerAdapter)(); | ||
var _name = /*#__PURE__*/new WeakMap(); | ||
@@ -57,5 +56,8 @@ var _config = /*#__PURE__*/new WeakMap(); | ||
/* eslint-disable @typescript-eslint/ban-types, @typescript-eslint/explicit-module-boundary-types */ | ||
_defineProperty(this, "call", (...params) => { | ||
_defineProperty(this, "call", async (...params) => { | ||
const payload = this.getPayload(...params); | ||
return (0, _axios.default)({ | ||
const controller = new _abortController.AbortController(); | ||
const signal = controller.signal; | ||
const timeout = setTimeout(() => controller.abort(), _classPrivateFieldGet(this, _config).timeout); | ||
const res = await (0, _crossFetch.default)(_classPrivateFieldGet(this, _node).url, { | ||
method: "POST", | ||
@@ -65,17 +67,16 @@ headers: { | ||
}, | ||
data: payload, | ||
url: _classPrivateFieldGet(this, _node).url, | ||
httpAgent: _classPrivateFieldGet(this, _node).httpAgent, | ||
httpsAgent: _classPrivateFieldGet(this, _node).httpsAgent, | ||
timeout: _classPrivateFieldGet(this, _config).timeout | ||
}).then(res => { | ||
body: JSON.stringify(payload), | ||
signal | ||
}).then(res => res.json()).then(res => { | ||
var _classPrivateFieldGet2, _classPrivateFieldGet3, _classPrivateFieldGet4; | ||
if (res.data.id !== payload.id) { | ||
throw new _exceptions.IdNotMatchException(payload.id, res.data.id); | ||
if (res.id !== payload.id) { | ||
throw new _exceptions.IdNotMatchException(payload.id, res.id); | ||
} | ||
if (res.data.error) { | ||
throw new _exceptions.ResponseException(JSON.stringify(res.data.error)); | ||
if (res.error) { | ||
throw new _exceptions.ResponseException(JSON.stringify(res.error)); | ||
} | ||
return (_classPrivateFieldGet2 = (_classPrivateFieldGet3 = (_classPrivateFieldGet4 = _classPrivateFieldGet(this, _options)).resultFormatters) === null || _classPrivateFieldGet3 === void 0 ? void 0 : _classPrivateFieldGet3.call(_classPrivateFieldGet4, res.data.result)) !== null && _classPrivateFieldGet2 !== void 0 ? _classPrivateFieldGet2 : res.data.result; | ||
return (_classPrivateFieldGet2 = (_classPrivateFieldGet3 = (_classPrivateFieldGet4 = _classPrivateFieldGet(this, _options)).resultFormatters) === null || _classPrivateFieldGet3 === void 0 ? void 0 : _classPrivateFieldGet3.call(_classPrivateFieldGet4, res.result)) !== null && _classPrivateFieldGet2 !== void 0 ? _classPrivateFieldGet2 : res.result; | ||
}); | ||
clearTimeout(timeout); | ||
return res; | ||
}); | ||
@@ -82,0 +83,0 @@ _defineProperty(this, "getPayload", (...params) => { |
{ | ||
"name": "@ckb-lumos/rpc", | ||
"version": "0.21.0-next.1", | ||
"version": "0.21.0-next.2", | ||
"description": "RPC module for CKB", | ||
@@ -29,7 +29,6 @@ "homepage": "https://github.com/ckb-js/lumos#readme", | ||
"dependencies": { | ||
"@ckb-lumos/base": "0.21.0-next.1", | ||
"@ckb-lumos/bi": "0.21.0-next.1", | ||
"@vespaiach/axios-fetch-adapter": "^0.3.1", | ||
"axios": "0.27.2", | ||
"tslib": "2.3.1" | ||
"@ckb-lumos/base": "0.21.0-next.2", | ||
"@ckb-lumos/bi": "0.21.0-next.2", | ||
"abort-controller": "^3.0.0", | ||
"cross-fetch": "^3.1.5" | ||
}, | ||
@@ -36,0 +35,0 @@ "devDependencies": { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
4
321994
78
3266
+ Addedabort-controller@^3.0.0
+ Addedcross-fetch@^3.1.5
+ Added@ckb-lumos/base@0.21.0-next.2(transitive)
+ Added@ckb-lumos/bi@0.21.0-next.2(transitive)
+ Added@ckb-lumos/codec@0.21.0-next.2(transitive)
+ Added@ckb-lumos/toolkit@0.21.0-next.2(transitive)
+ Addedabort-controller@3.0.0(transitive)
+ Addedcross-fetch@3.2.0(transitive)
+ Addedevent-target-shim@5.0.1(transitive)
+ Addednode-fetch@2.7.0(transitive)
+ Addedtr46@0.0.3(transitive)
+ Addedwebidl-conversions@3.0.1(transitive)
+ Addedwhatwg-url@5.0.0(transitive)
- Removedaxios@0.27.2
- Removedtslib@2.3.1
- Removed@ckb-lumos/base@0.21.0-next.1(transitive)
- Removed@ckb-lumos/bi@0.21.0-next.1(transitive)
- Removed@ckb-lumos/codec@0.21.0-next.1(transitive)
- Removed@ckb-lumos/toolkit@0.21.0-next.1(transitive)
- Removed@vespaiach/axios-fetch-adapter@0.3.1(transitive)
- Removedasynckit@0.4.0(transitive)
- Removedaxios@0.27.2(transitive)
- Removedcall-bind-apply-helpers@1.0.2(transitive)
- Removedcombined-stream@1.0.8(transitive)
- Removeddelayed-stream@1.0.0(transitive)
- Removeddunder-proto@1.0.1(transitive)
- Removedes-define-property@1.0.1(transitive)
- Removedes-errors@1.3.0(transitive)
- Removedes-object-atoms@1.1.1(transitive)
- Removedes-set-tostringtag@2.1.0(transitive)
- Removedfollow-redirects@1.15.9(transitive)
- Removedform-data@4.0.2(transitive)
- Removedfunction-bind@1.1.2(transitive)
- Removedget-intrinsic@1.3.0(transitive)
- Removedget-proto@1.0.1(transitive)
- Removedgopd@1.2.0(transitive)
- Removedhas-symbols@1.1.0(transitive)
- Removedhas-tostringtag@1.0.2(transitive)
- Removedhasown@2.0.2(transitive)
- Removedmath-intrinsics@1.1.0(transitive)
- Removedmime-db@1.52.0(transitive)
- Removedmime-types@2.1.35(transitive)
- Removedtslib@2.3.1(transitive)
Updated@ckb-lumos/bi@0.21.0-next.2