New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@ckb-lumos/rpc

Package Overview
Dependencies
Maintainers
3
Versions
160
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@ckb-lumos/rpc - npm Package Compare versions

Comparing version 0.0.0-canary-aef7250-20240506034257 to 0.0.0-canary-b370502-20240612030640

7

lib/Base/chain.js

@@ -9,5 +9,5 @@ "use strict";

var resultFmts = _interopRequireWildcard(require("../resultFormatter"));
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 _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
var _default = {
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
var _default = exports.default = {
getTipBlockNumber: {

@@ -92,3 +92,2 @@ method: "get_tip_block_number",

};
exports.default = _default;
//# sourceMappingURL=chain.js.map

@@ -8,3 +8,3 @@ "use strict";

var _paramsFormatter = require("../paramsFormatter");
var _default = {
var _default = exports.default = {
dryRunTransaction: {

@@ -25,3 +25,2 @@ method: "dry_run_transaction",

};
exports.default = _default;
//# sourceMappingURL=experimental.js.map

@@ -14,8 +14,3 @@ "use strict";

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _classPrivateFieldInitSpec(obj, privateMap, value) { _checkPrivateRedeclaration(obj, privateMap); privateMap.set(obj, value); }
function _checkPrivateRedeclaration(obj, privateCollection) { if (privateCollection.has(obj)) { throw new TypeError("Cannot initialize the same private elements twice on an object"); } }
function _classPrivateFieldGet(receiver, privateMap) { var descriptor = _classExtractFieldDescriptor(receiver, privateMap, "get"); return _classApplyDescriptorGet(receiver, descriptor); }
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; }
const rpcProperties = {
const rpcProperties = exports.rpcProperties = {
..._chain.default,

@@ -36,13 +31,7 @@ ..._experimental.default,

// prettier-ignore
exports.rpcProperties = rpcProperties;
var _rpcProperties = /*#__PURE__*/new WeakMap();
class Base {
constructor() {
_classPrivateFieldInitSpec(this, _rpcProperties, {
writable: true,
value: rpcProperties
});
}
#rpcProperties = rpcProperties;
get rpcProperties() {
return _classPrivateFieldGet(this, _rpcProperties);
return this.#rpcProperties;
}

@@ -49,0 +38,0 @@ }

@@ -9,4 +9,4 @@ "use strict";

var resultFmts = _interopRequireWildcard(require("../resultFormatter"));
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 _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
/* eslint-disable @typescript-eslint/no-explicit-any */

@@ -76,4 +76,3 @@

};
var _default = schemas;
exports.default = _default;
var _default = exports.default = schemas;
//# sourceMappingURL=indexer.js.map

@@ -9,5 +9,5 @@ "use strict";

var resultFmts = _interopRequireWildcard(require("../resultFormatter"));
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 _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
var _default = {
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
var _default = exports.default = {
localNodeInfo: {

@@ -58,3 +58,2 @@ method: "local_node_info",

};
exports.default = _default;
//# sourceMappingURL=net.js.map

@@ -9,5 +9,5 @@ "use strict";

var resultFmts = _interopRequireWildcard(require("../resultFormatter"));
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 _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
var _default = {
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
var _default = exports.default = {
sendTransaction: {

@@ -33,3 +33,2 @@ method: "send_transaction",

};
exports.default = _default;
//# sourceMappingURL=pool.js.map

@@ -8,5 +8,5 @@ "use strict";

var resultFmts = _interopRequireWildcard(require("../resultFormatter"));
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 _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
var _default = {
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
var _default = exports.default = {
getBlockchainInfo: {

@@ -23,3 +23,2 @@ method: "get_blockchain_info",

};
exports.default = _default;
//# sourceMappingURL=stats.js.map

@@ -10,10 +10,7 @@ "use strict";

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
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 _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
const ERROR_LABEL = "Batch Request";
class MethodInBatchNotFoundException extends Error {
code = _ErrorCode.default.MethodNotFound;
constructor(name) {
super(`[${ERROR_LABEL}]: Method ${name} is not found`);
_defineProperty(this, "code", _ErrorCode.default.MethodNotFound);
}

@@ -23,5 +20,5 @@ }

class PayloadInBatchException extends Error {
code = _ErrorCode.default.PayloadMessage;
constructor(index, message) {
super(`[${ERROR_LABEL} ${index}]: ${message}`);
_defineProperty(this, "code", _ErrorCode.default.PayloadMessage);
this.index = index;

@@ -39,3 +36,3 @@ }

exports.IdNotMatchedInBatchException = IdNotMatchedInBatchException;
var _default = {
var _default = exports.default = {
MethodInBatchNotFoundException,

@@ -45,3 +42,2 @@ PayloadInBatchException,

};
exports.default = _default;
//# sourceMappingURL=batch.js.map

@@ -7,3 +7,3 @@ "use strict";

exports.default = exports.ErrorCode = void 0;
let ErrorCode = /*#__PURE__*/function (ErrorCode) {
let ErrorCode = exports.ErrorCode = /*#__PURE__*/function (ErrorCode) {
ErrorCode[ErrorCode["ParameterInvalid"] = 101] = "ParameterInvalid";

@@ -16,5 +16,3 @@ ErrorCode[ErrorCode["IdNotMatch"] = 201] = "IdNotMatch";

}({});
exports.ErrorCode = ErrorCode;
var _default = ErrorCode;
exports.default = _default;
var _default = exports.default = ErrorCode;
//# sourceMappingURL=ErrorCode.js.map

@@ -9,9 +9,8 @@ "use strict";

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
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 _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); } // eslint-disable-next-line import/no-named-as-default
// eslint-disable-next-line import/no-named-as-default
class PageSizeTooLargeException extends RangeError {
code = _ErrorCode.default.ParameterInvalid;
constructor(pageSize, maxSize) {
super(`Expect page size to be at most ${maxSize}, but ${pageSize} received`);
_defineProperty(this, "code", _ErrorCode.default.ParameterInvalid);
}

@@ -21,5 +20,5 @@ }

class PageSizeTooSmallException extends RangeError {
code = _ErrorCode.default.ParameterInvalid;
constructor(pageSize, minSize) {
super(`Expect page size to be at least ${minSize}, but ${pageSize} received`);
_defineProperty(this, "code", _ErrorCode.default.ParameterInvalid);
}

@@ -29,5 +28,5 @@ }

class OutputsValidatorTypeException extends TypeError {
code = _ErrorCode.default.ParameterInvalid;
constructor() {
super(`Expect outputs validator to be 'default' or 'passthrough'`);
_defineProperty(this, "code", _ErrorCode.default.ParameterInvalid);
}

@@ -39,5 +38,5 @@ }

class BigintOrHexStringTypeException extends TypeError {
code = _ErrorCode.default.ParameterInvalid;
constructor(value) {
super(`Expect number to be bigint or hex string, but ${value} received`);
_defineProperty(this, "code", _ErrorCode.default.ParameterInvalid);
}

@@ -47,5 +46,5 @@ }

class StringHashTypeException extends TypeError {
code = _ErrorCode.default.ParameterInvalid;
constructor(hash) {
super(`Expect hash to be string, but ${hash} received`);
_defineProperty(this, "code", _ErrorCode.default.ParameterInvalid);
}

@@ -56,9 +55,9 @@ }

class HexStringWithout0xException extends Error {
code = _ErrorCode.default.ParameterInvalid;
constructor(hex) {
super(`Hex string ${hex} should start with 0x`);
_defineProperty(this, "code", _ErrorCode.default.ParameterInvalid);
}
}
exports.HexStringWithout0xException = HexStringWithout0xException;
var _default = {
var _default = exports.default = {
PageSizeTooLargeException,

@@ -71,3 +70,2 @@ PageSizeTooSmallException,

};
exports.default = _default;
//# sourceMappingURL=formatter.js.map

@@ -9,9 +9,6 @@ "use strict";

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
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 _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
class IdNotMatchException extends Error {
code = _ErrorCode.default.IdNotMatch;
constructor(requestId, responseId) {
super(`Expect json rpc id to be ${requestId}, but ${responseId} received`);
_defineProperty(this, "code", _ErrorCode.default.IdNotMatch);
}

@@ -21,13 +18,9 @@ }

class ResponseException extends Error {
constructor(...args) {
super(...args);
_defineProperty(this, "code", _ErrorCode.default.ResponseMessage);
}
code = _ErrorCode.default.ResponseMessage;
}
exports.ResponseException = ResponseException;
var _default = {
var _default = exports.default = {
IdNotMatchException,
ResponseException
};
exports.default = _default;
//# sourceMappingURL=rpc.js.map

@@ -33,2 +33,3 @@ import { Base } from "./Base";

export declare const ResultFormatter: typeof resultFormatter;
export declare const DEFAULT_RPC_TIMEOUT = 30000;
export declare class CKBRPC extends Base {

@@ -42,5 +43,9 @@ #private;

addMethod: (options: CKBComponents.Method, config?: RPCConfig) => void;
createBatchRequest: <N extends keyof Base, P extends (string | number | object)[], R = any[]>(params?: any) => any;
createBatchRequest: <N extends keyof Base, P extends (string | number | object)[], R = any[]>(params?: [method: N, ...rest: P][]) => [method: N, ...rest: P][] & {
add: (n: N, ...p: P) => [method: N, ...rest: P][];
remove: (index: number) => [method: N, ...rest: P][];
exec: () => Promise<R>;
};
}
export { CKBRPC as RPC };
//# sourceMappingURL=index.d.ts.map

@@ -6,6 +6,6 @@ "use strict";

});
exports.ResultFormatter = exports.RPC = exports.ParamsFormatter = exports.CKBRPC = void 0;
exports.ResultFormatter = exports.RPC = exports.ParamsFormatter = exports.DEFAULT_RPC_TIMEOUT = exports.CKBRPC = void 0;
var _Base = require("./Base");
var _method = require("./method");
var _paramsFormatter2 = require("./paramsFormatter");
var _paramsFormatter = require("./paramsFormatter");
var resultFormatter = _interopRequireWildcard(require("./resultFormatter"));

@@ -16,133 +16,25 @@ var _exceptions = require("./exceptions");

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
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 _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
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 _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
function _classPrivateFieldInitSpec(obj, privateMap, value) { _checkPrivateRedeclaration(obj, privateMap); privateMap.set(obj, value); }
function _checkPrivateRedeclaration(obj, privateCollection) { if (privateCollection.has(obj)) { throw new TypeError("Cannot initialize the same private elements twice on an object"); } }
function _classPrivateFieldSet(receiver, privateMap, value) { var descriptor = _classExtractFieldDescriptor(receiver, privateMap, "set"); _classApplyDescriptorSet(receiver, descriptor, value); return value; }
function _classApplyDescriptorSet(receiver, descriptor, value) { if (descriptor.set) { descriptor.set.call(receiver, value); } else { if (!descriptor.writable) { throw new TypeError("attempted to set read only private field"); } descriptor.value = value; } }
function _classPrivateFieldGet(receiver, privateMap) { var descriptor = _classExtractFieldDescriptor(receiver, privateMap, "get"); return _classApplyDescriptorGet(receiver, descriptor); }
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; }
const ParamsFormatter = _paramsFormatter2.formatter;
exports.ParamsFormatter = ParamsFormatter;
const ResultFormatter = resultFormatter;
exports.ResultFormatter = ResultFormatter;
var _config = /*#__PURE__*/new WeakMap();
var _node = /*#__PURE__*/new WeakMap();
var _paramsFormatter = /*#__PURE__*/new WeakMap();
var _resultFormatter = /*#__PURE__*/new WeakMap();
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
const ParamsFormatter = exports.ParamsFormatter = _paramsFormatter.formatter;
const ResultFormatter = exports.ResultFormatter = resultFormatter;
const DEFAULT_RPC_TIMEOUT = exports.DEFAULT_RPC_TIMEOUT = 30000;
class CKBRPC extends _Base.Base {
#config;
#node = {
url: ""
};
get node() {
return _classPrivateFieldGet(this, _node);
return this.#node;
}
#paramsFormatter = _paramsFormatter.formatter;
get paramsFormatter() {
return _classPrivateFieldGet(this, _paramsFormatter);
return this.#paramsFormatter;
}
#resultFormatter = resultFormatter;
get resultFormatter() {
return _classPrivateFieldGet(this, _resultFormatter);
return this.#resultFormatter;
}
constructor(url, _config2 = {}) {
constructor(url, config = {}) {
super();
_classPrivateFieldInitSpec(this, _config, {
writable: true,
value: void 0
});
_classPrivateFieldInitSpec(this, _node, {
writable: true,
value: {
url: ""
}
});
_classPrivateFieldInitSpec(this, _paramsFormatter, {
writable: true,
value: _paramsFormatter2.formatter
});
_classPrivateFieldInitSpec(this, _resultFormatter, {
writable: true,
value: resultFormatter
});
_defineProperty(this, "addMethod", (options, config) => {
const method = new _method.Method(this.node, options, config);
Object.defineProperty(this, options.name, {
value: method.call,
enumerable: true
});
});
/* eslint-disable */
_defineProperty(this, "createBatchRequest", (
// TODO fix me
// params: [method: N, ...rest: P][] = [],
params = []) => {
const ctx = this;
// TODO fix me
const proxied = new Proxy([], {
set(...p) {
const methods = Object.keys(ctx);
if (p[1] !== "length") {
var _p$;
const name = p === null || p === void 0 ? void 0 : (_p$ = p[2]) === null || _p$ === void 0 ? void 0 : _p$[0];
if (methods.indexOf(name) === -1) {
throw new _exceptions.MethodInBatchNotFoundException(name);
}
}
return Reflect.set(...p);
}
});
Object.defineProperties(proxied, {
add: {
value(...args) {
this.push(args);
return this;
}
},
remove: {
value(i) {
this.splice(i, 1);
return this;
}
},
exec: {
async value() {
// TODO fix me
const payload = proxied.map(([f, ...p], i) => {
try {
const method = new _method.Method(ctx.node, {
...ctx.rpcProperties[f],
name: f
});
return method.getPayload(...p);
} catch (err) {
throw new _exceptions.PayloadInBatchException(i, err.message);
}
});
const controller = new _abortController.default();
const signal = controller.signal;
const timeout = setTimeout(() => controller.abort(), _classPrivateFieldGet(ctx, _config).timeout);
const batchRes = await _classPrivateFieldGet(ctx, _config).fetch(_classPrivateFieldGet(ctx, _node).url, {
method: "POST",
headers: {
"content-type": "application/json"
},
body: JSON.stringify(payload),
signal
}).then(res => res.json());
clearTimeout(timeout);
return batchRes.map((res, i) => {
var _ctx$rpcProperties$pr, _ctx$rpcProperties$pr2, _ctx$rpcProperties$pr3;
if (res.id !== payload[i].id) {
return new _exceptions.IdNotMatchedInBatchException(i, payload[i].id, res.id);
}
return (_ctx$rpcProperties$pr = (_ctx$rpcProperties$pr2 = (_ctx$rpcProperties$pr3 = ctx.rpcProperties[proxied[i][0]]).resultFormatters) === null || _ctx$rpcProperties$pr2 === void 0 ? void 0 : _ctx$rpcProperties$pr2.call(_ctx$rpcProperties$pr3, res.result)) !== null && _ctx$rpcProperties$pr !== void 0 ? _ctx$rpcProperties$pr : res.result;
});
}
}
});
// TODO fix me
params.forEach(p => proxied.push(p));
return proxied;
});
this.setNode({

@@ -152,9 +44,9 @@ url

const {
timeout: _timeout = 30000,
timeout = DEFAULT_RPC_TIMEOUT,
fetch = _crossFetch.default
} = _config2;
_classPrivateFieldSet(this, _config, {
timeout: _timeout,
} = config;
this.#config = {
timeout,
fetch
});
};
Object.defineProperties(this, {

@@ -175,3 +67,2 @@ addMethod: {

});
Object.keys(this.rpcProperties).forEach(name => {

@@ -181,3 +72,3 @@ this.addMethod({

...this.rpcProperties[name]
}, _classPrivateFieldGet(this, _config));
}, this.#config);
});

@@ -189,4 +80,78 @@ }

}
addMethod = (options, config) => {
const method = new _method.Method(this.node, options, config);
Object.defineProperty(this, options.name, {
value: method.call,
enumerable: true
});
};
/* eslint-disable */
createBatchRequest = (params = []) => {
const ctx = this;
const proxied = new Proxy([], {
set(...p) {
const methods = Object.keys(ctx);
if (p[1] !== "length") {
var _p$;
const name = p === null || p === void 0 || (_p$ = p[2]) === null || _p$ === void 0 ? void 0 : _p$[0];
if (methods.indexOf(name) === -1) {
throw new _exceptions.MethodInBatchNotFoundException(name);
}
}
return Reflect.set(...p);
}
});
Object.defineProperties(proxied, {
add: {
value(...args) {
this.push(args);
return this;
}
},
remove: {
value(i) {
this.splice(i, 1);
return this;
}
},
exec: {
async value() {
const payload = proxied.map(([f, ...p], i) => {
try {
const method = new _method.Method(ctx.node, {
...ctx.rpcProperties[f],
name: f
});
return method.getPayload(...p);
} catch (err) {
throw new _exceptions.PayloadInBatchException(i, err.message);
}
});
const controller = new _abortController.default();
const signal = controller.signal;
const timeout = setTimeout(() => controller.abort(), ctx.#config.timeout);
const batchRes = await ctx.#config.fetch(ctx.#node.url, {
method: "POST",
headers: {
"content-type": "application/json"
},
body: JSON.stringify(payload),
signal
}).then(res => res.json());
clearTimeout(timeout);
return batchRes.map((res, i) => {
var _ctx$rpcProperties$pr, _ctx$rpcProperties$pr2, _ctx$rpcProperties$pr3;
if (res.id !== payload[i].id) {
return new _exceptions.IdNotMatchedInBatchException(i, payload[i].id, res.id);
}
return (_ctx$rpcProperties$pr = (_ctx$rpcProperties$pr2 = (_ctx$rpcProperties$pr3 = ctx.rpcProperties[proxied[i][0]]).resultFormatters) === null || _ctx$rpcProperties$pr2 === void 0 ? void 0 : _ctx$rpcProperties$pr2.call(_ctx$rpcProperties$pr3, res.result)) !== null && _ctx$rpcProperties$pr !== void 0 ? _ctx$rpcProperties$pr : res.result;
});
}
}
});
params.forEach(p => proxied.push(p));
return proxied;
};
}
exports.RPC = exports.CKBRPC = CKBRPC;
//# sourceMappingURL=index.js.map

@@ -8,93 +8,31 @@ "use strict";

var _exceptions = require("./exceptions");
var _ = require(".");
var _abortController = _interopRequireDefault(require("abort-controller"));
var _crossFetch = _interopRequireDefault(require("cross-fetch"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
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 _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
function _classPrivateFieldInitSpec(obj, privateMap, value) { _checkPrivateRedeclaration(obj, privateMap); privateMap.set(obj, value); }
function _checkPrivateRedeclaration(obj, privateCollection) { if (privateCollection.has(obj)) { throw new TypeError("Cannot initialize the same private elements twice on an object"); } }
function _classPrivateFieldSet(receiver, privateMap, value) { var descriptor = _classExtractFieldDescriptor(receiver, privateMap, "set"); _classApplyDescriptorSet(receiver, descriptor, value); return value; }
function _classApplyDescriptorSet(receiver, descriptor, value) { if (descriptor.set) { descriptor.set.call(receiver, value); } else { if (!descriptor.writable) { throw new TypeError("attempted to set read only private field"); } descriptor.value = value; } }
function _classPrivateFieldGet(receiver, privateMap) { var descriptor = _classExtractFieldDescriptor(receiver, privateMap, "get"); return _classApplyDescriptorGet(receiver, descriptor); }
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; }
var _name = /*#__PURE__*/new WeakMap();
var _config = /*#__PURE__*/new WeakMap();
var _options = /*#__PURE__*/new WeakMap();
var _node = /*#__PURE__*/new WeakMap();
class Method {
#name;
#config;
get name() {
return _classPrivateFieldGet(this, _name);
return this.#name;
}
#options = {
name: "",
method: "",
paramsFormatters: [],
resultFormatters: undefined
};
#node;
constructor(node, options, config = {}) {
_classPrivateFieldInitSpec(this, _name, {
writable: true,
value: void 0
});
_classPrivateFieldInitSpec(this, _config, {
writable: true,
value: void 0
});
_classPrivateFieldInitSpec(this, _options, {
writable: true,
value: {
name: "",
method: "",
paramsFormatters: [],
resultFormatters: undefined
}
});
_classPrivateFieldInitSpec(this, _node, {
writable: true,
value: void 0
});
/* eslint-disable @typescript-eslint/ban-types, @typescript-eslint/explicit-module-boundary-types */
_defineProperty(this, "call", async (...params) => {
const payload = this.getPayload(...params);
const controller = new _abortController.default();
const signal = controller.signal;
const timeout = setTimeout(() => controller.abort(), _classPrivateFieldGet(this, _config).timeout);
const res = await _classPrivateFieldGet(this, _config).fetch(_classPrivateFieldGet(this, _node).url, {
method: "POST",
headers: {
"content-type": "application/json"
},
body: JSON.stringify(payload),
signal
}).then(res => res.json()).then(res => {
var _classPrivateFieldGet2, _classPrivateFieldGet3, _classPrivateFieldGet4;
if (res.id !== payload.id) {
throw new _exceptions.IdNotMatchException(payload.id, res.id);
}
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.result)) !== null && _classPrivateFieldGet2 !== void 0 ? _classPrivateFieldGet2 : res.result;
});
clearTimeout(timeout);
return res;
});
_defineProperty(this, "getPayload", (...params) => {
const data = params.map((p, i) => _classPrivateFieldGet(this, _options).paramsFormatters[i] && _classPrivateFieldGet(this, _options).paramsFormatters[i](p) || p);
const id = Math.round(Math.random() * 10000);
const payload = {
id,
method: _classPrivateFieldGet(this, _options).method,
params: data,
jsonrpc: "2.0"
};
return payload;
});
_classPrivateFieldSet(this, _node, node);
_classPrivateFieldSet(this, _options, options);
_classPrivateFieldSet(this, _name, options.name);
this.#node = node;
this.#options = options;
this.#name = options.name;
const {
timeout: _timeout = 30000,
timeout = _.DEFAULT_RPC_TIMEOUT,
fetch = _crossFetch.default
} = config;
_classPrivateFieldSet(this, _config, {
timeout: _timeout,
this.#config = {
timeout,
fetch
});
};
Object.defineProperty(this.call, "name", {

@@ -106,2 +44,41 @@ value: options.name,

}
/* eslint-disable @typescript-eslint/ban-types, @typescript-eslint/explicit-module-boundary-types */
call = async (...params) => {
const payload = this.getPayload(...params);
const controller = new _abortController.default();
const signal = controller.signal;
const timeout = setTimeout(() => controller.abort(), this.#config.timeout);
const res = await this.#config.fetch(this.#node.url, {
method: "POST",
headers: {
"content-type": "application/json"
},
body: JSON.stringify(payload),
signal
}).then(res => res.json()).then(res => {
var _this$options$resultF, _this$options$resultF2, _this$options;
if (res.id !== payload.id) {
throw new _exceptions.IdNotMatchException(payload.id, res.id);
}
if (res.error) {
throw new _exceptions.ResponseException(JSON.stringify(res.error));
}
return (_this$options$resultF = (_this$options$resultF2 = (_this$options = this.#options).resultFormatters) === null || _this$options$resultF2 === void 0 ? void 0 : _this$options$resultF2.call(_this$options, res.result)) !== null && _this$options$resultF !== void 0 ? _this$options$resultF : res.result;
});
clearTimeout(timeout);
return res;
};
getPayload = (...params) => {
const data = params.map((p, i) => this.#options.paramsFormatters[i] && this.#options.paramsFormatters[i](p) || p);
/* eslint-disable @typescript-eslint/no-magic-numbers */
const id = Math.round(Math.random() * 10000);
const payload = {
id,
method: this.#options.method,
params: data,
jsonrpc: "2.0"
};
return payload;
};
}

@@ -108,0 +85,0 @@ /* eslint-enable @typescript-eslint/ban-types, @typescript-eslint/explicit-module-boundary-types */

@@ -10,3 +10,3 @@ "use strict";

/* eslint-disable @typescript-eslint/no-explicit-any, @typescript-eslint/explicit-module-boundary-types */
const formatter = {
const formatter = exports.formatter = {
toOptional: format => arg => {

@@ -217,3 +217,2 @@ if (!format || arg === undefined || arg === null) {

/* eslint-enable camelcase, @typescript-eslint/no-explicit-any, @typescript-eslint/explicit-module-boundary-types */
exports.formatter = formatter;
//# sourceMappingURL=paramsFormatter.js.map

@@ -271,2 +271,5 @@ "use strict";

min_fee_rate: minFeeRate,
min_rbf_rate: minRbfRate,
tx_size_limit: txSizeLimit,
max_tx_pool_size: maxTxPoolSize,
...rest

@@ -281,2 +284,5 @@ } = info;

minFeeRate,
minRbfRate,
txSizeLimit,
maxTxPoolSize,
...rest

@@ -369,2 +375,4 @@ };

time_added_to_pool,
min_replace_fee,
fee,
...rest

@@ -382,2 +390,4 @@ } = txWithStatus;

timeAddedToPool: time_added_to_pool,
minReplaceFee: min_replace_fee,
fee,
...rest

@@ -384,0 +394,0 @@ };

@@ -11,4 +11,3 @@ "use strict";

/* eslint-disable @typescript-eslint/no-namespace, @typescript-eslint/no-explicit-any, @typescript-eslint/ban-types */
let CKBComponents;
exports.CKBComponents = CKBComponents;
let CKBComponents = exports.CKBComponents = void 0;
(function (_CKBComponents) {

@@ -15,0 +14,0 @@ let TransactionStatus = /*#__PURE__*/function (TransactionStatus) {

@@ -109,2 +109,4 @@ /**

cycles: Uint64 | null;
fee: Capacity | null;
min_replace_fee: Capacity | null;
}

@@ -200,2 +202,5 @@ export interface TransactionPoint {

total_tx_size: Size;
min_rbf_rate: Uint64;
tx_size_limit: Uint64;
max_tx_pool_size: Uint64;
}

@@ -202,0 +207,0 @@ export interface Epoch {

@@ -11,4 +11,3 @@ "use strict";

/* eslint-disable @typescript-eslint/no-namespace */
let RPC;
exports.RPC = RPC;
let RPC = exports.RPC = void 0;
(function (_RPC) {

@@ -15,0 +14,0 @@ // this is a type to mapping the `HashMap`, `BTreeMap` in `jsonrpc-types`

{
"name": "@ckb-lumos/rpc",
"version": "0.0.0-canary-aef7250-20240506034257",
"version": "0.0.0-canary-b370502-20240612030640",
"description": "RPC module for CKB",

@@ -29,4 +29,4 @@ "homepage": "https://github.com/ckb-js/lumos#readme",

"dependencies": {
"@ckb-lumos/base": "0.0.0-canary-aef7250-20240506034257",
"@ckb-lumos/bi": "0.0.0-canary-aef7250-20240506034257",
"@ckb-lumos/base": "0.0.0-canary-b370502-20240612030640",
"@ckb-lumos/bi": "0.0.0-canary-b370502-20240612030640",
"abort-controller": "^3.0.0",

@@ -33,0 +33,0 @@ "cross-fetch": "^3.1.5"

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

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

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

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

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc