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.20.0 to 0.21.0-next.0

5

lib/Base/chain.js

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

exports.default = void 0;
var _paramsFormatter = require("../paramsFormatter");
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 = {

@@ -18,0 +13,0 @@ getTipBlockNumber: {

9

lib/Base/experimental.js

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

exports.default = void 0;
var _paramsFormatter = require("../paramsFormatter");
var _default = {

@@ -17,10 +15,13 @@ dryRunTransaction: {

// skip _compute_transaction_hash
calculateDaoMaximumWithdraw: {
method: "calculate_dao_maximum_withdraw",
paramsFormatters: [_paramsFormatter.formatter.toOutPoint, _paramsFormatter.formatter.toHash]
} // skip estimate_fee_rate
}
// skip estimate_fee_rate
// skip _compute_script_hash
};
exports.default = _default;
//# sourceMappingURL=experimental.js.map

@@ -7,18 +7,16 @@ "use strict";

exports.rpcProperties = exports.Base = void 0;
var _chain = _interopRequireDefault(require("./chain"));
var _experimental = _interopRequireDefault(require("./experimental"));
var _net = _interopRequireDefault(require("./net"));
var _pool = _interopRequireDefault(require("./pool"));
var _stats = _interopRequireDefault(require("./stats"));
var _indexer = _interopRequireDefault(require("./indexer"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
const rpcProperties = { ..._chain.default,
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 = {
..._chain.default,
..._experimental.default,

@@ -29,17 +27,19 @@ ..._indexer.default,

..._pool.default,
..._stats.default // skip subscription
..._stats.default
// skip subscription
};
exports.rpcProperties = rpcProperties;
var _rpcProperties = /*#__PURE__*/new WeakMap();
class Base {
#rpcProperties = rpcProperties;
constructor() {
_classPrivateFieldInitSpec(this, _rpcProperties, {
writable: true,
value: rpcProperties
});
}
get rpcProperties() {
return this.#rpcProperties;
return _classPrivateFieldGet(this, _rpcProperties);
}
}
exports.Base = Base;
//# sourceMappingURL=index.js.map

@@ -1,2 +0,2 @@

declare type MethodSchema = {
type MethodSchema = {
method: string;

@@ -3,0 +3,0 @@ paramsFormatters: ((arg: any) => any)[];

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

exports.default = void 0;
var _paramsFormatter = require("../paramsFormatter");
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; }
/* eslint-disable @typescript-eslint/no-explicit-any */

@@ -17,0 +14,0 @@ const schemas = {

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

exports.default = void 0;
var _paramsFormatter = require("../paramsFormatter");
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 = {

@@ -18,0 +13,0 @@ localNodeInfo: {

declare const _default: {
sendTransaction: {
method: string;
paramsFormatters: (((transaction: import("../types/api").CKBComponents.RawTransaction) => import("../types/rpc").RPC.RawTransaction) | ((outputsValidator: import("../types/api").CKBComponents.OutputsValidator) => import("../types/api").CKBComponents.OutputsValidator))[];
paramsFormatters: (((transaction: import("../types/api").CKBComponents.RawTransaction) => import("../types/rpc").RPC.RawTransaction) | ((outputsValidator: import("../types/api").CKBComponents.OutputsValidator) => "default" | "passthrough" | undefined))[];
resultFormatters: (hash: string) => string;

@@ -6,0 +6,0 @@ };

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

exports.default = void 0;
var _paramsFormatter = require("../paramsFormatter");
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 = {

@@ -18,0 +13,0 @@ sendTransaction: {

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

exports.default = void 0;
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 = {

@@ -16,0 +12,0 @@ getBlockchainInfo: {

@@ -7,34 +7,24 @@ "use strict";

exports.default = exports.PayloadInBatchException = exports.MethodInBatchNotFoundException = exports.IdNotMatchedInBatchException = void 0;
var _ErrorCode = _interopRequireDefault(require("./ErrorCode"));
var _rpc = require("./rpc");
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);
}
}
exports.MethodInBatchNotFoundException = MethodInBatchNotFoundException;
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;
}
}
exports.PayloadInBatchException = PayloadInBatchException;
class IdNotMatchedInBatchException extends _rpc.IdNotMatchException {

@@ -46,5 +36,3 @@ constructor(index, requestId, responseId) {

}
}
exports.IdNotMatchedInBatchException = IdNotMatchedInBatchException;

@@ -51,0 +39,0 @@ var _default = {

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

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

@@ -17,6 +14,7 @@ ErrorCode[ErrorCode["IdNotMatch"] = 201] = "IdNotMatch";

ErrorCode[ErrorCode["ResponseMessage"] = 204] = "ResponseMessage";
})(ErrorCode || (exports.ErrorCode = ErrorCode = {}));
return ErrorCode;
}({});
exports.ErrorCode = ErrorCode;
var _default = ErrorCode;
exports.default = _default;
//# sourceMappingURL=ErrorCode.js.map

@@ -7,76 +7,51 @@ "use strict";

exports.default = exports.StringHashTypeException = exports.PageSizeTooSmallException = exports.PageSizeTooLargeException = exports.OutputsValidatorTypeException = exports.HexStringWithout0xException = exports.BigintOrHexStringTypeException = void 0;
var _ErrorCode = _interopRequireDefault(require("./ErrorCode"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
// eslint-disable-next-line import/no-named-as-default
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
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);
}
}
exports.PageSizeTooLargeException = PageSizeTooLargeException;
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);
}
}
exports.PageSizeTooSmallException = PageSizeTooSmallException;
class OutputsValidatorTypeException extends TypeError {
code = _ErrorCode.default.ParameterInvalid;
constructor() {
super(`Expect outputs validator to be 'default' or 'passthrough'`);
_defineProperty(this, "code", _ErrorCode.default.ParameterInvalid);
}
}
}
/* eslint-disable @typescript-eslint/no-explicit-any, @typescript-eslint/explicit-module-boundary-types */
exports.OutputsValidatorTypeException = OutputsValidatorTypeException;
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);
}
}
exports.BigintOrHexStringTypeException = BigintOrHexStringTypeException;
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);
}
}
/* eslint-enable @typescript-eslint/no-explicit-any, @typescript-eslint/explicit-module-boundary-types */
exports.StringHashTypeException = StringHashTypeException;
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;

@@ -83,0 +58,0 @@ var _default = {

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

});
var _formatter = require("./formatter");
Object.keys(_formatter).forEach(function (key) {

@@ -20,5 +18,3 @@ if (key === "default" || key === "__esModule") return;

});
var _rpc = require("./rpc");
Object.keys(_rpc).forEach(function (key) {

@@ -34,5 +30,3 @@ if (key === "default" || key === "__esModule") return;

});
var _batch = require("./batch");
Object.keys(_batch).forEach(function (key) {

@@ -39,0 +33,0 @@ if (key === "default" || key === "__esModule") return;

@@ -7,22 +7,20 @@ "use strict";

exports.default = exports.ResponseException = exports.IdNotMatchException = void 0;
var _ErrorCode = _interopRequireDefault(require("./ErrorCode"));
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);
}
}
exports.IdNotMatchException = IdNotMatchException;
class ResponseException extends Error {
code = _ErrorCode.default.ResponseMessage;
constructor(...args) {
super(...args);
_defineProperty(this, "code", _ErrorCode.default.ResponseMessage);
}
}
exports.ResponseException = ResponseException;

@@ -29,0 +27,0 @@ var _default = {

@@ -16,4 +16,4 @@ import { Base } from "./Base";

toOutput: (output: import("@ckb-lumos/base").Output) => import("./types/rpc").RPC.CellOutput;
toDepType: (type: import("@ckb-lumos/base").DepType) => "code" | "dep_group";
toOrder: (order: "asc" | "desc") => "asc" | "desc";
toDepType: (type: CKBComponents.DepType) => "code" | "dep_group";
toOrder: (order: CKBComponents.Order) => CKBComponents.Order;
toCellDep: (cellDep: import("@ckb-lumos/base").CellDep) => import("./types/rpc").RPC.CellDep;

@@ -24,3 +24,3 @@ toRawTransaction: (transaction: CKBComponents.RawTransaction) => import("./types/rpc").RPC.RawTransaction;

toReverseOrder: (reverse?: boolean) => boolean;
toOutputsValidator: (outputsValidator: CKBComponents.OutputsValidator) => CKBComponents.OutputsValidator;
toOutputsValidator: (outputsValidator: CKBComponents.OutputsValidator) => "default" | "passthrough" | undefined;
toBoolean: (value: boolean) => boolean;

@@ -42,6 +42,6 @@ toTransactionProof: (proof: import("@ckb-lumos/base").TransactionProof) => import("./types/rpc").RPC.TransactionProof;

setNode(node: CKBComponents.Node): CKBComponents.Node;
addMethod: (options: CKBComponents.Method, config?: RPCConfig | undefined) => void;
createBatchRequest: <N extends "getTipBlockNumber" | "getTipHeader" | "getCurrentEpoch" | "getEpochByNumber" | "getBlockHash" | "getBlock" | "getHeader" | "getHeaderByNumber" | "getLiveCell" | "getTransaction" | "getCellbaseOutputCapacityDetails" | "getBlockEconomicState" | "getTransactionProof" | "verifyTransactionProof" | "getConsensus" | "getBlockByNumber" | "dryRunTransaction" | "calculateDaoMaximumWithdraw" | "localNodeInfo" | "getPeers" | "getBannedAddresses" | "clearBannedAddresses" | "setBan" | "syncState" | "setNetworkActive" | "addNode" | "removeNode" | "pingPeers" | "sendTransaction" | "txPoolInfo" | "clearTxPool" | "getRawTxPool" | "getBlockchainInfo" | "getIndexerTip" | "getCells" | "getTransactions" | "getCellsCapacity" | "getBlockFilter" | "getTransactionAndWitnessProof" | "verifyTransactionAndWitnessProof" | "getForkBlock" | "getBlockMedianTime" | "estimateCycles" | "getFeeRateStatics" | "getFeeRateStatistics" | "rpcProperties", P extends (string | number | object)[], R = any[]>(params?: any) => any;
addMethod: (options: CKBComponents.Method, config?: RPCConfig) => void;
createBatchRequest: <N extends keyof Base, P extends (string | number | object)[], R = any[]>(params?: any) => any;
}
export { CKBRPC as RPC };
//# sourceMappingURL=index.d.ts.map

@@ -7,25 +7,23 @@ "use strict";

exports.ResultFormatter = exports.RPC = exports.ParamsFormatter = exports.CKBRPC = void 0;
var _Base = require("./Base");
var _method = require("./method");
var _paramsFormatter = require("./paramsFormatter");
var _paramsFormatter2 = require("./paramsFormatter");
var resultFormatter = _interopRequireWildcard(require("./resultFormatter"));
var _exceptions = require("./exceptions");
var _axios = _interopRequireDefault(require("axios"));
var _initAxiosWebworkerAdapter = require("./initAxiosWebworkerAdapter");
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; }
// import axios from 'axios'
const ParamsFormatter = _paramsFormatter.formatter;
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; } // import axios from 'axios'
const ParamsFormatter = _paramsFormatter2.formatter;
exports.ParamsFormatter = ParamsFormatter;

@@ -35,33 +33,122 @@ const ResultFormatter = resultFormatter;

(0, _initAxiosWebworkerAdapter.initAxiosWebworkerAdapter)();
var _config = /*#__PURE__*/new WeakMap();
var _node = /*#__PURE__*/new WeakMap();
var _paramsFormatter = /*#__PURE__*/new WeakMap();
var _resultFormatter = /*#__PURE__*/new WeakMap();
class CKBRPC extends _Base.Base {
#config;
#node = {
url: ""
};
get node() {
return this.#node;
return _classPrivateFieldGet(this, _node);
}
#paramsFormatter = _paramsFormatter.formatter;
get paramsFormatter() {
return this.#paramsFormatter;
return _classPrivateFieldGet(this, _paramsFormatter);
}
#resultFormatter = resultFormatter;
get resultFormatter() {
return this.#resultFormatter;
return _classPrivateFieldGet(this, _resultFormatter);
}
constructor(url, config = {
constructor(url, _config2 = {
timeout: 30000
}) {
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 batchRes = await (0, _axios.default)({
method: "POST",
headers: {
"content-type": "application/json"
},
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) => {
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({
url
});
this.#config = config;
_classPrivateFieldSet(this, _config, _config2);
Object.defineProperties(this, {

@@ -79,5 +166,6 @@ addMethod: {

configurable: false
} // createBatchRequest: { value: this.createBatchRequest, enumerable: false, writable: false, configurable: false },
}
// createBatchRequest: { value: this.createBatchRequest, enumerable: false, writable: false, configurable: false },
});
});
Object.keys(this.rpcProperties).forEach(name => {

@@ -87,6 +175,5 @@ this.addMethod({

...this.rpcProperties[name]
}, config);
}, _config2);
});
}
setNode(node) {

@@ -96,94 +183,4 @@ Object.assign(this.node, node);

}
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 = ( // 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 batchRes = await (0, _axios.default)({
method: "POST",
headers: {
"content-type": "application/json"
},
data: payload,
url: ctx.#node.url,
httpAgent: ctx.#node.httpAgent,
httpsAgent: ctx.#node.httpsAgent,
timeout: ctx.#config.timeout
});
return batchRes.data.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;
};
}
exports.RPC = exports.CKBRPC = CKBRPC;
//# sourceMappingURL=index.js.map

@@ -7,23 +7,18 @@ "use strict";

exports.initAxiosWebworkerAdapter = initAxiosWebworkerAdapter;
var _axios = _interopRequireDefault(require("axios"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
/* eslint-disable @typescript-eslint/ban-ts-comment */
/* eslint-disable @typescript-eslint/no-var-requires */
/* eslint-disable @typescript-eslint/no-var-requires */
// this is a hack for passing unit tests
/** @internal */
function initAxiosWebworkerAdapter() {
/* istanbul ignore next */
if ( // @ts-ignore
"ServiceWorkerGlobalScope" in globalThis && // @ts-ignore
if (
// @ts-ignore
"ServiceWorkerGlobalScope" in globalThis &&
// @ts-ignore
globalThis instanceof (globalThis === null || globalThis === void 0 ? void 0 : globalThis.ServiceWorkerGlobalScope)) {
/* istanbul ignore next */const fetchAdapter = require("@vespaiach/axios-fetch-adapter");
/* istanbul ignore next */
const fetchAdapter = require("@vespaiach/axios-fetch-adapter");
/* istanbul ignore next */
_axios.default.defaults.adapter = fetchAdapter.default;

@@ -30,0 +25,0 @@ }

@@ -7,36 +7,88 @@ "use strict";

exports.Method = void 0;
var _axios = _interopRequireDefault(require("axios"));
var _exceptions = require("./exceptions");
var _initAxiosWebworkerAdapter = require("./initAxiosWebworkerAdapter");
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; }
(0, _initAxiosWebworkerAdapter.initAxiosWebworkerAdapter)();
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 this.#name;
return _classPrivateFieldGet(this, _name);
}
#options = {
name: "",
method: "",
paramsFormatters: [],
resultFormatters: undefined
};
#node;
constructor(node, options, config = {
timeout: 30000
}) {
this.#node = node;
this.#options = options;
this.#name = options.name;
this.#config = 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", (...params) => {
const payload = this.getPayload(...params);
return (0, _axios.default)({
method: "POST",
headers: {
"content-type": "application/json"
},
data: payload,
url: _classPrivateFieldGet(this, _node).url,
httpAgent: _classPrivateFieldGet(this, _node).httpAgent,
httpsAgent: _classPrivateFieldGet(this, _node).httpsAgent,
timeout: _classPrivateFieldGet(this, _config).timeout
}).then(res => {
var _classPrivateFieldGet2, _classPrivateFieldGet3, _classPrivateFieldGet4;
if (res.data.id !== payload.id) {
throw new _exceptions.IdNotMatchException(payload.id, res.data.id);
}
if (res.data.error) {
throw new _exceptions.ResponseException(JSON.stringify(res.data.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;
});
});
_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);
_classPrivateFieldSet(this, _config, config);
Object.defineProperty(this.call, "name", {

@@ -48,47 +100,5 @@ value: options.name,

}
/* eslint-disable @typescript-eslint/ban-types, @typescript-eslint/explicit-module-boundary-types */
call = (...params) => {
const payload = this.getPayload(...params);
return (0, _axios.default)({
method: "POST",
headers: {
"content-type": "application/json"
},
data: payload,
url: this.#node.url,
httpAgent: this.#node.httpAgent,
httpsAgent: this.#node.httpsAgent,
timeout: this.#config.timeout
}).then(res => {
var _this$options$resultF, _this$options$resultF2, _this$options;
if (res.data.id !== payload.id) {
throw new _exceptions.IdNotMatchException(payload.id, res.data.id);
}
if (res.data.error) {
throw new _exceptions.ResponseException(JSON.stringify(res.data.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.data.result)) !== null && _this$options$resultF !== void 0 ? _this$options$resultF : res.data.result;
});
};
getPayload = (...params) => {
const data = params.map((p, i) => this.#options.paramsFormatters[i] && this.#options.paramsFormatters[i](p) || p);
const id = Math.round(Math.random() * 10000);
const payload = {
id,
method: this.#options.method,
params: data,
jsonrpc: "2.0"
};
return payload;
};
}
/* eslint-enable @typescript-eslint/ban-types, @typescript-eslint/explicit-module-boundary-types */
exports.Method = Method;
//# sourceMappingURL=method.js.map

@@ -13,3 +13,3 @@ import { RPC } from "./types/rpc";

toDepType: (type: CKBComponents.DepType) => "code" | "dep_group";
toOrder: (order: CKBComponents.Order) => "asc" | "desc";
toOrder: (order: CKBComponents.Order) => CKBComponents.Order;
toCellDep: (cellDep: CKBComponents.CellDep) => RPC.CellDep;

@@ -20,3 +20,3 @@ toRawTransaction: (transaction: CKBComponents.RawTransaction) => RPC.RawTransaction;

toReverseOrder: (reverse?: boolean) => boolean;
toOutputsValidator: (outputsValidator: CKBComponents.OutputsValidator) => CKBComponents.OutputsValidator;
toOutputsValidator: (outputsValidator: CKBComponents.OutputsValidator) => "default" | "passthrough" | undefined;
toBoolean: (value: boolean) => boolean;

@@ -23,0 +23,0 @@ toTransactionProof: (proof: CKBComponents.TransactionProof) => RPC.TransactionProof;

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

exports.formatter = void 0;
var _exceptions = require("./exceptions");
var _bi = require("@ckb-lumos/bi");
/* eslint-disable @typescript-eslint/no-explicit-any, @typescript-eslint/explicit-module-boundary-types */

@@ -19,3 +16,2 @@ const formatter = {

}
return format(arg);

@@ -27,3 +23,2 @@ },

}
return arg.map(format);

@@ -35,3 +30,2 @@ },

}
return hash.startsWith("0x") ? hash : `0x${hash}`;

@@ -43,11 +37,8 @@ },

}
if (typeof number !== "string") {
throw new _exceptions.BigintOrHexStringTypeException(number);
}
if (!number.startsWith("0x")) {
throw new _exceptions.HexStringWithout0xException(number);
}
return number;

@@ -111,3 +102,2 @@ },

}
return type;

@@ -159,3 +149,2 @@ },

const size = _bi.BI.from(pageSize);
const MAX_SIZE = 50;

@@ -171,7 +160,5 @@ const MIN_SIZE = 0;

const VALIDATORS = ["default", "passthrough"];
if (VALIDATORS.indexOf(outputsValidator) > -1) {
return outputsValidator;
}
throw new _exceptions.OutputsValidatorTypeException();

@@ -223,3 +210,4 @@ },

if (!data) return data;
return { ...formatter.toSearchKey(data),
return {
...formatter.toSearchKey(data),
with_data: data.withData

@@ -230,3 +218,4 @@ };

if (!data) return data;
return { ...formatter.toSearchKey(data),
return {
...formatter.toSearchKey(data),
group_by_transaction: data.groupByTransaction

@@ -237,4 +226,3 @@ };

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

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

exports.toUncleBlock = exports.toTxPoolInfo = exports.toTransactionsByLockHash = exports.toTransactionWithStatus = exports.toTransactionProof = exports.toTransactionPoint = exports.toTransactionAndWitnessProof = void 0;
/* eslint-disable camelcase, @typescript-eslint/no-explicit-any */
/* eslint-disable camelcase, @typescript-eslint/no-explicit-any */
const isTxPoolIds = rawTxPool => {
return Array.isArray(rawTxPool.pending);
};
const toArray = format => arg => {

@@ -20,8 +19,5 @@ if (typeof format !== "function" || !Array.isArray(arg)) {

}
return arg.map(format);
};
exports.toArray = toArray;
const toNullable = format => origin => {

@@ -31,13 +27,7 @@ if (!format || origin === null) return origin;

};
exports.toNullable = toNullable;
const toNumber = number => number.toString();
exports.toNumber = toNumber;
const toHash = hash => hash;
exports.toHash = toHash;
const toHeader = header => {

@@ -62,5 +52,3 @@ if (!header) return header;

};
exports.toHeader = toHeader;
const toScript = script => {

@@ -79,5 +67,3 @@ if (!script) return script;

};
exports.toScript = toScript;
const toInput = input => {

@@ -94,5 +80,3 @@ if (!input) return input;

};
exports.toInput = toInput;
const toOutput = output => {

@@ -111,5 +95,3 @@ if (!output) return output;

};
exports.toOutput = toOutput;
const toOutPoint = outPoint => {

@@ -125,5 +107,3 @@ const {

};
exports.toOutPoint = toOutPoint;
const toDepType = type => {

@@ -133,8 +113,5 @@ if (type === "dep_group") {

}
return type;
};
exports.toDepType = toDepType;
const toCellDep = cellDep => {

@@ -153,5 +130,3 @@ if (!cellDep) return cellDep;

};
exports.toCellDep = toCellDep;
function toTransaction(tx) {

@@ -176,3 +151,2 @@ if (!tx) return tx;

}
const toUncleBlock = uncleBlock => {

@@ -189,5 +163,3 @@ if (!uncleBlock) return uncleBlock;

};
exports.toUncleBlock = toUncleBlock;
const toTip = tip => ({

@@ -197,5 +169,3 @@ blockHash: tip.block_hash,

});
exports.toTip = toTip;
const toBlock = block => {

@@ -216,5 +186,3 @@ if (!block) return block;

};
exports.toBlock = toBlock;
const toAlertMessage = alertMessage => {

@@ -231,5 +199,3 @@ if (!alertMessage) return alertMessage;

};
exports.toAlertMessage = toAlertMessage;
const toBlockchainInfo = info => {

@@ -250,5 +216,3 @@ if (!info) return info;

};
exports.toBlockchainInfo = toBlockchainInfo;
const toLocalNodeInfo = info => {

@@ -275,5 +239,3 @@ if (!info) return info;

};
exports.toLocalNodeInfo = toLocalNodeInfo;
const toRemoteNodeInfo = info => {

@@ -306,5 +268,3 @@ if (!info) return info;

};
exports.toRemoteNodeInfo = toRemoteNodeInfo;
const toTxPoolInfo = info => {

@@ -331,5 +291,3 @@ if (!info) return info;

};
exports.toTxPoolInfo = toTxPoolInfo;
const toPeers = nodes => {

@@ -339,5 +297,3 @@ if (!Array.isArray(nodes)) return [];

};
exports.toPeers = toPeers;
const toCell = cell => {

@@ -356,5 +312,3 @@ if (!cell) return cell;

};
exports.toCell = toCell;
const toLiveCell = liveCell => {

@@ -373,5 +327,3 @@ if (!liveCell) return liveCell;

};
exports.toLiveCell = toLiveCell;
const toLiveCellWithStatus = cellWithStatus => {

@@ -388,13 +340,9 @@ if (!cellWithStatus) return cellWithStatus;

};
exports.toLiveCellWithStatus = toLiveCellWithStatus;
const toCells = cells => {
if (!Array.isArray(cells)) return [];
return cells.map(toCell);
}; // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
};
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
exports.toCells = toCells;
const toCellIncludingOutPoint = cell => {

@@ -417,13 +365,9 @@ if (!cell) return cell;

};
exports.toCellIncludingOutPoint = toCellIncludingOutPoint;
const toCellsIncludingOutPoint = cells => {
if (!Array.isArray(cells)) return [];
return cells.map(toCellIncludingOutPoint);
}; // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
};
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
exports.toCellsIncludingOutPoint = toCellsIncludingOutPoint;
const toTransactionWithStatus = txWithStatus => {

@@ -448,5 +392,3 @@ if (!txWithStatus) return txWithStatus;

};
exports.toTransactionWithStatus = toTransactionWithStatus;
const toEpoch = epoch => {

@@ -465,5 +407,3 @@ if (!epoch) return epoch;

};
exports.toEpoch = toEpoch;
const toTransactionPoint = transactionPoint => {

@@ -482,5 +422,3 @@ if (!transactionPoint) return transactionPoint;

};
exports.toTransactionPoint = toTransactionPoint;
const toTransactionsByLockHash = transactions => {

@@ -493,5 +431,3 @@ if (!transactions) return transactions;

};
exports.toTransactionsByLockHash = toTransactionsByLockHash;
const toLiveCellsByLockHash = cells => {

@@ -506,5 +442,3 @@ if (!cells) return cells;

};
exports.toLiveCellsByLockHash = toLiveCellsByLockHash;
const toLockHashIndexState = index => {

@@ -525,5 +459,3 @@ if (!index) return index;

};
exports.toLockHashIndexState = toLockHashIndexState;
const toLockHashIndexStates = states => {

@@ -533,5 +465,3 @@ if (!states) return states;

};
exports.toLockHashIndexStates = toLockHashIndexStates;
const toBannedAddress = bannedAddress => {

@@ -552,5 +482,3 @@ if (!bannedAddress) return bannedAddress;

};
exports.toBannedAddress = toBannedAddress;
const toBannedAddresses = bannedAddresses => {

@@ -560,5 +488,3 @@ if (!bannedAddresses) return bannedAddresses;

};
exports.toBannedAddresses = toBannedAddresses;
const toCellbaseOutputCapacityDetails = details => {

@@ -577,5 +503,3 @@ if (!details) return details;

};
exports.toCellbaseOutputCapacityDetails = toCellbaseOutputCapacityDetails;
const toFeeRate = feeRateObj => {

@@ -585,3 +509,2 @@ if (!feeRateObj) {

}
const {

@@ -596,5 +519,3 @@ fee_rate: feeRate,

};
exports.toFeeRate = toFeeRate;
const toCapacityByLockHash = capacityByLockHash => {

@@ -604,3 +525,2 @@ if (!capacityByLockHash) {

}
const {

@@ -619,5 +539,3 @@ cells_count: cellsCount,

};
exports.toCapacityByLockHash = toCapacityByLockHash;
const toBlockEconomicState = blockEconomicState => {

@@ -627,3 +545,2 @@ if (!blockEconomicState) {

}
const {

@@ -642,5 +559,3 @@ finalized_at: finalizedAt,

};
exports.toBlockEconomicState = toBlockEconomicState;
const toSyncState = state => {

@@ -650,3 +565,2 @@ if (!state) {

}
return {

@@ -663,5 +577,3 @@ bestKnownBlockNumber: state.best_known_block_number,

};
exports.toSyncState = toSyncState;
const toTransactionProof = proof => {

@@ -671,3 +583,2 @@ if (!proof) {

}
const {

@@ -684,8 +595,5 @@ block_hash: blockHash,

};
exports.toTransactionProof = toTransactionProof;
const toConsensus = consensus => {
var _consensus$hardfork_f, _consensus$hardfork_f2;
if (!consensus) return consensus;

@@ -724,12 +632,8 @@ return {

};
exports.toConsensus = toConsensus;
const toRawTxPool = rawTxPool => {
if (!rawTxPool) return rawTxPool;
if (isTxPoolIds(rawTxPool)) {
return rawTxPool;
}
const toTxVerbosity = ({

@@ -746,3 +650,2 @@ ancestors_count: ancestorsCount,

});
const proposed = {};

@@ -761,5 +664,3 @@ const pending = {};

};
exports.toRawTxPool = toRawTxPool;
const toIndexerCell = indexerCell => {

@@ -775,3 +676,2 @@ if (!indexerCell) return indexerCell;

};
const toGetCellsResult = getCellsResult => ({

@@ -781,5 +681,3 @@ lastCursor: getCellsResult.last_cursor,

});
exports.toGetCellsResult = toGetCellsResult;
const isUngroupedIndexerTransaction = value => {

@@ -789,9 +687,6 @@ if (value.cells) {

}
return true;
};
const toIndexerTransaction = indexerTransaction => {
if (!indexerTransaction) return indexerTransaction;
if (isUngroupedIndexerTransaction(indexerTransaction)) {

@@ -806,3 +701,2 @@ return {

}
return {

@@ -815,3 +709,2 @@ txHash: indexerTransaction.tx_hash,

};
const toGetTransactionsResult = getTransactionsResult => {

@@ -824,5 +717,3 @@ if (!getTransactionsResult) return getTransactionsResult;

};
exports.toGetTransactionsResult = toGetTransactionsResult;
const toCellsCapacity = cellsCapacity => {

@@ -836,5 +727,3 @@ if (!cellsCapacity) return cellsCapacity;

};
exports.toCellsCapacity = toCellsCapacity;
const toBlockFilter = blockFilter => {

@@ -846,5 +735,3 @@ return {

};
exports.toBlockFilter = toBlockFilter;
const toTransactionAndWitnessProof = proof => {

@@ -857,5 +744,3 @@ return {

};
exports.toTransactionAndWitnessProof = toTransactionAndWitnessProof;
const toFeeRateStatistics = statistics => {

@@ -867,5 +752,3 @@ return {

};
exports.toFeeRateStatistics = toFeeRateStatistics;
const toForkBlockResult = result => {

@@ -875,3 +758,2 @@ if (typeof result === "string") {

}
return {

@@ -884,5 +766,3 @@ header: toHeader(result.header),

};
exports.toForkBlockResult = toForkBlockResult;
const toEstimateCycles = cycle => {

@@ -893,6 +773,5 @@ return {

};
/* eslint-enable camelcase */
exports.toEstimateCycles = toEstimateCycles;
//# sourceMappingURL=resultFormatter.js.map

@@ -7,30 +7,31 @@ "use strict";

exports.CKBComponents = void 0;
/**
* @see https://github.com/nervosnetwork/ckb/blob/develop/protocol/src/protocol.fbs for more infGomation
*/
/* eslint-disable @typescript-eslint/no-namespace, @typescript-eslint/no-explicit-any, @typescript-eslint/ban-types */
let CKBComponents;
exports.CKBComponents = CKBComponents;
(function (_CKBComponents) {
let TransactionStatus;
(function (TransactionStatus) {
let TransactionStatus = /*#__PURE__*/function (TransactionStatus) {
TransactionStatus["Pending"] = "pending";
TransactionStatus["Proposed"] = "proposed";
TransactionStatus["Committed"] = "committed";
})(TransactionStatus || (TransactionStatus = {}));
return TransactionStatus;
}({});
_CKBComponents.TransactionStatus = TransactionStatus;
let CellStatus;
(function (CellStatus) {
/**
* @typedef Bytes, keep consistent with CKB
* @description Bytes will be serialized to string
* @see https://github.com/nervosnetwork/ckb/blob/develop/util/jsonrpc-types/src/blockchain.rs#L19
*/
/**
* RPC Units
*/
let CellStatus = /*#__PURE__*/function (CellStatus) {
CellStatus["Live"] = "live";
CellStatus["Unknown"] = "unknown";
})(CellStatus || (CellStatus = {}));
return CellStatus;
}({});
_CKBComponents.CellStatus = CellStatus;
})(CKBComponents || (exports.CKBComponents = CKBComponents = {}));
//# sourceMappingURL=api.js.map

@@ -1,4 +0,4 @@

export declare type RPCConfig = {
export type RPCConfig = {
timeout: number;
};
//# sourceMappingURL=common.d.ts.map

@@ -7,24 +7,18 @@ "use strict";

exports.RPC = void 0;
/**
* @see https://github.com/nervosnetwork/ckb/blob/develop/util/jsonrpc-types/src/blockchain.rs
*/
/* eslint-disable @typescript-eslint/no-namespace */
let RPC;
/* eslint-enable camelcase */
exports.RPC = RPC;
(function (_RPC) {
let TransactionStatus;
(function (TransactionStatus) {
let TransactionStatus = /*#__PURE__*/function (TransactionStatus) {
TransactionStatus["Pending"] = "pending";
TransactionStatus["Proposed"] = "proposed";
TransactionStatus["Committed"] = "committed";
})(TransactionStatus || (TransactionStatus = {}));
return TransactionStatus;
}({});
_RPC.TransactionStatus = TransactionStatus;
})(RPC || (exports.RPC = RPC = {}));
//# sourceMappingURL=rpc.js.map
{
"name": "@ckb-lumos/rpc",
"version": "0.20.0",
"version": "0.21.0-next.0",
"description": "RPC module for CKB",

@@ -28,17 +28,5 @@ "homepage": "https://github.com/ckb-js/lumos#readme",

},
"scripts": {
"doc": "../../node_modules/.bin/typedoc --out docs --mode modules --includeDeclarations --excludeExternals --ignoreCompilerErrors --theme default",
"fmt": "prettier --write \"{src,tests,examples}/**/*.ts\" package.json",
"lint": "eslint -c ../../.eslintrc.js \"{src,tests,examples}/**/*.ts\"",
"test": "../../node_modules/.bin/jest",
"build": "npm run build:types && npm run build:js",
"build:types": "tsc --declaration --emitDeclarationOnly",
"build:js": "babel --root-mode upward src --out-dir lib --extensions .ts -s",
"clean": "rm -rf lib",
"prepublishOnly": "yarn run clean && yarn run build",
"release": "npm publish"
},
"dependencies": {
"@ckb-lumos/base": "0.20.0",
"@ckb-lumos/bi": "0.20.0",
"@ckb-lumos/base": "0.21.0-next.0",
"@ckb-lumos/bi": "0.21.0-next.0",
"@vespaiach/axios-fetch-adapter": "^0.3.1",

@@ -55,3 +43,12 @@ "axios": "0.27.2",

},
"gitHead": "28756be37c312eca132cac0c00b40510803030e0"
}
"scripts": {
"doc": "npx typedoc --out docs --mode modules --includeDeclarations --excludeExternals --ignoreCompilerErrors --theme default",
"fmt": "prettier --write \"{src,tests,examples}/**/*.ts\" package.json",
"lint": "eslint -c ../../.eslintrc.js \"{src,tests,examples}/**/*.ts\"",
"test": "npx jest",
"build": "pnpm run build:types && pnpm run build:js",
"build:types": "tsc --declaration --emitDeclarationOnly",
"build:js": "babel --root-mode upward src --out-dir lib --extensions .ts -s",
"clean": "rm -rf lib"
}
}

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

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