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-ckb2023-fe6c0e5-20230925085931 to 0.0.0-experimental-joyid-0855d00-20240319125140

11

lib/Base/chain.d.ts

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

import * as resultFmts from "../resultFormatter";
declare const _default: {

@@ -10,3 +11,3 @@ getTipBlockNumber: {

paramsFormatters: never[];
resultFormatters: (header: import("../types/rpc").RPC.Header) => import("@ckb-lumos/base").Header;
resultFormatters: typeof resultFmts.toHeader;
};

@@ -30,3 +31,3 @@ getCurrentEpoch: {

paramsFormatters: ((hash: string) => string)[];
resultFormatters: (block: import("../types/rpc").RPC.Block) => import("@ckb-lumos/base").Block;
resultFormatters: typeof resultFmts.toBlock;
};

@@ -36,3 +37,3 @@ getBlockByNumber: {

paramsFormatters: ((number: string | bigint) => string)[];
resultFormatters: (block: import("../types/rpc").RPC.Block) => import("@ckb-lumos/base").Block;
resultFormatters: typeof resultFmts.toBlock;
};

@@ -42,3 +43,3 @@ getHeader: {

paramsFormatters: ((hash: string) => string)[];
resultFormatters: (header: import("../types/rpc").RPC.Header) => import("@ckb-lumos/base").Header;
resultFormatters: typeof resultFmts.toHeader;
};

@@ -48,3 +49,3 @@ getHeaderByNumber: {

paramsFormatters: ((number: string | bigint) => string)[];
resultFormatters: (header: import("../types/rpc").RPC.Header) => import("@ckb-lumos/base").Header;
resultFormatters: typeof resultFmts.toHeader;
};

@@ -51,0 +52,0 @@ getLiveCell: {

@@ -6,2 +6,14 @@ import { CKBComponents } from "../types/api";

export declare const rpcProperties: RpcPropertes;
interface GetBlock<Q> {
(query: Q, verbosity?: '0x2', withCycle?: false): Promise<CKBComponents.BlockView>;
(query: Q, verbosity: '0x0', withCycle?: false): Promise<string>;
(query: Q, verbosity: '0x0', withCycle: true): Promise<{
block: string;
cycles: CKBComponents.UInt64;
}>;
(query: Q, verbosity: '0x2', withCycle: true): Promise<{
block: CKBComponents.BlockView;
cycles: CKBComponents.UInt64;
}>;
}
export interface GetTransaction {

@@ -13,2 +25,6 @@ (hash: CKBComponents.Hash): Promise<CKBComponents.TransactionWithStatus>;

}
export interface GetHeader<Q> {
(query: Q, verbosity?: "0x1"): Promise<CKBComponents.BlockHeader>;
(query: Q, verbosity: "0x0"): Promise<string>;
}
export interface Base {

@@ -56,6 +72,8 @@ /**

* @description rpc to get block by its hash
* @param {string} hash - the block hash of the target block
* @returns {Promise<object>} block object
* @param {string} hash
* @param {string} verbosity
* @param {boolean} withCycle
* @return {Promise<GetBlock | null>}
*/
getBlock: (hash: CKBComponents.Hash) => Promise<CKBComponents.Block>;
getBlock: GetBlock<CKBComponents.Hash>;
/**

@@ -67,3 +85,3 @@ * @method getHeader

*/
getHeader: (blockHash: CKBComponents.Hash) => Promise<CKBComponents.BlockHeader>;
getHeader: GetHeader<CKBComponents.Hash>;
/**

@@ -75,3 +93,3 @@ * @method getHeaderByNumber

*/
getHeaderByNumber: (blockNumber: CKBComponents.BlockNumber | bigint) => Promise<CKBComponents.BlockHeader>;
getHeaderByNumber: GetHeader<CKBComponents.BlockNumber | bigint>;
/**

@@ -87,3 +105,3 @@ * @method getLiveCell

getLiveCell: (outPoint: CKBComponents.OutPoint, withData: boolean) => Promise<{
cell: CKBComponents.LiveCell;
cell: Option<CKBComponents.LiveCell>;
status: CKBComponents.CellStatus;

@@ -143,7 +161,9 @@ }>;

* @memberof DefaultRPC
* @description rpc to get block by its number
* @param {string} number - the block number of the target block
* @returns {Promise<object>} block object
* @description rpc to get block by its hash
* @param {CKBComponents.BlockNumber | bigint} number
* @param {string} verbosity
* @param {boolean} withCycle
* @return {Promise<GetBlock | null>}
*/
getBlockByNumber: (number: CKBComponents.BlockNumber | bigint) => Promise<CKBComponents.Block>;
getBlockByNumber: GetBlock<CKBComponents.BlockNumber | bigint>;
/**

@@ -390,2 +410,4 @@ * @method dryRunTransaction

}
export type Option<T> = T | null;
export {};
//# sourceMappingURL=index.d.ts.map

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

// prettier-ignore
// prettier-ignore
// prettier-ignore
exports.rpcProperties = rpcProperties;

@@ -33,0 +37,0 @@ var _rpcProperties = /*#__PURE__*/new WeakMap();

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

get resultFormatter(): typeof resultFormatter;
constructor(url: string, config?: RPCConfig);
constructor(url: string, config?: Partial<RPCConfig>);
setNode(node: CKBComponents.Node): CKBComponents.Node;

@@ -41,0 +41,0 @@ addMethod: (options: CKBComponents.Method, config?: RPCConfig) => void;

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

var _exceptions = require("./exceptions");
var _axios = _interopRequireDefault(require("axios"));
var _initAxiosWebworkerAdapter = require("./initAxiosWebworkerAdapter");
var _crossFetch = _interopRequireDefault(require("cross-fetch"));
var _abortController = _interopRequireDefault(require("abort-controller"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

@@ -27,3 +27,3 @@ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }

function _classExtractFieldDescriptor(receiver, privateMap, action) { if (!privateMap.has(receiver)) { throw new TypeError("attempted to " + action + " private field on non-instance"); } return privateMap.get(receiver); }
function _classApplyDescriptorGet(receiver, descriptor) { if (descriptor.get) { return descriptor.get.call(receiver); } return descriptor.value; } // import axios from 'axios'
function _classApplyDescriptorGet(receiver, descriptor) { if (descriptor.get) { return descriptor.get.call(receiver); } return descriptor.value; }
const ParamsFormatter = _paramsFormatter2.formatter;

@@ -33,3 +33,2 @@ exports.ParamsFormatter = ParamsFormatter;

exports.ResultFormatter = ResultFormatter;
(0, _initAxiosWebworkerAdapter.initAxiosWebworkerAdapter)();
var _config = /*#__PURE__*/new WeakMap();

@@ -49,5 +48,3 @@ var _node = /*#__PURE__*/new WeakMap();

}
constructor(url, _config2 = {
timeout: 30000
}) {
constructor(url, _config2 = {}) {
super();

@@ -127,3 +124,6 @@ _classPrivateFieldInitSpec(this, _config, {

});
const batchRes = await (0, _axios.default)({
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",

@@ -133,9 +133,7 @@ headers: {

},
data: payload,
url: _classPrivateFieldGet(ctx, _node).url,
httpAgent: _classPrivateFieldGet(ctx, _node).httpAgent,
httpsAgent: _classPrivateFieldGet(ctx, _node).httpsAgent,
timeout: _classPrivateFieldGet(ctx, _config).timeout
});
return batchRes.data.map((res, i) => {
body: JSON.stringify(payload),
signal
}).then(res => res.json());
clearTimeout(timeout);
return batchRes.map((res, i) => {
var _ctx$rpcProperties$pr, _ctx$rpcProperties$pr2, _ctx$rpcProperties$pr3;

@@ -157,3 +155,10 @@ if (res.id !== payload[i].id) {

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

@@ -179,3 +184,3 @@ addMethod: {

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

@@ -182,0 +187,0 @@ }

@@ -6,3 +6,3 @@ import { CKBComponents } from "./types/api";

get name(): string;
constructor(node: CKBComponents.Node, options: CKBComponents.Method, config?: RPCConfig);
constructor(node: CKBComponents.Node, options: CKBComponents.Method, config?: Partial<RPCConfig>);
call: (...params: (string | number | object)[]) => Promise<any>;

@@ -9,0 +9,0 @@ getPayload: (...params: (string | number | object)[]) => {

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

exports.Method = void 0;
var _axios = _interopRequireDefault(require("axios"));
var _exceptions = require("./exceptions");
var _initAxiosWebworkerAdapter = require("./initAxiosWebworkerAdapter");
var _abortController = _interopRequireDefault(require("abort-controller"));
var _crossFetch = _interopRequireDefault(require("cross-fetch"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

@@ -22,3 +22,2 @@ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }

function _classApplyDescriptorGet(receiver, descriptor) { if (descriptor.get) { return descriptor.get.call(receiver); } return descriptor.value; }
(0, _initAxiosWebworkerAdapter.initAxiosWebworkerAdapter)();
var _name = /*#__PURE__*/new WeakMap();

@@ -32,5 +31,3 @@ var _config = /*#__PURE__*/new WeakMap();

}
constructor(node, options, config = {
timeout: 30000
}) {
constructor(node, options, config = {}) {
_classPrivateFieldInitSpec(this, _name, {

@@ -58,5 +55,8 @@ writable: true,

/* eslint-disable @typescript-eslint/ban-types, @typescript-eslint/explicit-module-boundary-types */
_defineProperty(this, "call", (...params) => {
_defineProperty(this, "call", async (...params) => {
const payload = this.getPayload(...params);
return (0, _axios.default)({
const controller = new _abortController.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",

@@ -66,17 +66,16 @@ headers: {

},
data: payload,
url: _classPrivateFieldGet(this, _node).url,
httpAgent: _classPrivateFieldGet(this, _node).httpAgent,
httpsAgent: _classPrivateFieldGet(this, _node).httpsAgent,
timeout: _classPrivateFieldGet(this, _config).timeout
}).then(res => {
body: JSON.stringify(payload),
signal
}).then(res => res.json()).then(res => {
var _classPrivateFieldGet2, _classPrivateFieldGet3, _classPrivateFieldGet4;
if (res.data.id !== payload.id) {
throw new _exceptions.IdNotMatchException(payload.id, res.data.id);
if (res.id !== payload.id) {
throw new _exceptions.IdNotMatchException(payload.id, res.id);
}
if (res.data.error) {
throw new _exceptions.ResponseException(JSON.stringify(res.data.error));
if (res.error) {
throw new _exceptions.ResponseException(JSON.stringify(res.error));
}
return (_classPrivateFieldGet2 = (_classPrivateFieldGet3 = (_classPrivateFieldGet4 = _classPrivateFieldGet(this, _options)).resultFormatters) === null || _classPrivateFieldGet3 === void 0 ? void 0 : _classPrivateFieldGet3.call(_classPrivateFieldGet4, res.data.result)) !== null && _classPrivateFieldGet2 !== void 0 ? _classPrivateFieldGet2 : res.data.result;
return (_classPrivateFieldGet2 = (_classPrivateFieldGet3 = (_classPrivateFieldGet4 = _classPrivateFieldGet(this, _options)).resultFormatters) === null || _classPrivateFieldGet3 === void 0 ? void 0 : _classPrivateFieldGet3.call(_classPrivateFieldGet4, res.result)) !== null && _classPrivateFieldGet2 !== void 0 ? _classPrivateFieldGet2 : res.result;
});
clearTimeout(timeout);
return res;
});

@@ -97,3 +96,10 @@ _defineProperty(this, "getPayload", (...params) => {

_classPrivateFieldSet(this, _name, options.name);
_classPrivateFieldSet(this, _config, config);
const {
timeout: _timeout = 30000,
fetch = _crossFetch.default
} = config;
_classPrivateFieldSet(this, _config, {
timeout: _timeout,
fetch
});
Object.defineProperty(this.call, "name", {

@@ -100,0 +106,0 @@ value: options.name,

@@ -7,3 +7,4 @@ import { CKBComponents } from "./types/api";

declare const toHash: (hash: RPC.Hash256) => CKBComponents.Hash256;
declare const toHeader: (header: RPC.Header) => CKBComponents.BlockHeader;
declare function toHeader(header: RPC.Header): CKBComponents.BlockHeader;
declare function toHeader(header: string): string;
declare const toScript: (script: RPC.Script) => CKBComponents.Script;

@@ -19,3 +20,9 @@ declare const toInput: (input: RPC.CellInput) => CKBComponents.CellInput;

declare const toTip: (tip: RPC.Tip) => CKBComponents.Tip;
declare const toBlock: (block: RPC.Block) => CKBComponents.Block;
type BlockWithCycles = {
block: RPC.Block | string;
cycles: string[];
};
declare function toBlock(block: string): string;
declare function toBlock(block: RPC.Block): CKBComponents.Block;
declare function toBlock<T extends BlockWithCycles>(block: T): T;
declare const toAlertMessage: (alertMessage: RPC.AlertMessage) => CKBComponents.AlertMessage;

@@ -64,3 +71,3 @@ declare const toBlockchainInfo: (info: RPC.BlockchainInfo) => CKBComponents.BlockchainInfo;

declare const toRawTxPool: (rawTxPool: RPC.RawTxPool) => CKBComponents.RawTxPool;
declare const toGetCellsResult: (getCellsResult: RPC.GetLiveCellsResult) => CKBComponents.GetLiveCellsResult;
declare const toGetCellsResult: <WithData extends boolean = true>(getCellsResult: RPC.GetLiveCellsResult) => CKBComponents.GetLiveCellsResult<WithData>;
declare const toGetTransactionsResult: <Goruped extends boolean = false>(getTransactionsResult: RPC.GetTransactionsResult<Goruped>) => CKBComponents.GetTransactionsResult<Goruped>;

@@ -67,0 +74,0 @@ declare const toCellsCapacity: (cellsCapacity: RPC.CellsCapacity) => CKBComponents.CellsCapacity;

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

});
exports.toTip = exports.toSyncState = exports.toScript = exports.toRemoteNodeInfo = exports.toRawTxPool = exports.toPeers = exports.toOutput = exports.toOutPoint = exports.toNumber = exports.toNullable = exports.toLockHashIndexStates = exports.toLockHashIndexState = exports.toLocalNodeInfo = exports.toLiveCellsByLockHash = exports.toLiveCellWithStatus = exports.toLiveCell = exports.toInput = exports.toHeader = exports.toHash = exports.toGetTransactionsResult = exports.toGetCellsResult = exports.toForkBlockResult = exports.toFeeRateStatistics = exports.toFeeRate = exports.toEstimateCycles = exports.toEpoch = exports.toDeploymentsInfo = exports.toDeploymentInfo = exports.toDeployment = exports.toDeployState = exports.toDepType = exports.toConsensus = exports.toCellsIncludingOutPoint = exports.toCellsCapacity = exports.toCells = exports.toCellbaseOutputCapacityDetails = exports.toCellIncludingOutPoint = exports.toCellDep = exports.toCell = exports.toCapacityByLockHash = exports.toBlockchainInfo = exports.toBlockFilter = exports.toBlockEconomicState = exports.toBlock = exports.toBannedAddresses = exports.toBannedAddress = exports.toArray = exports.toAlertMessage = void 0;
exports.toBannedAddresses = exports.toBannedAddress = exports.toArray = exports.toAlertMessage = void 0;
exports.toBlock = toBlock;
exports.toHash = exports.toGetTransactionsResult = exports.toGetCellsResult = exports.toForkBlockResult = exports.toFeeRateStatistics = exports.toFeeRate = exports.toEstimateCycles = exports.toEpoch = exports.toDeploymentsInfo = exports.toDeploymentInfo = exports.toDeployment = exports.toDeployState = exports.toDepType = exports.toConsensus = exports.toCellsIncludingOutPoint = exports.toCellsCapacity = exports.toCells = exports.toCellbaseOutputCapacityDetails = exports.toCellIncludingOutPoint = exports.toCellDep = exports.toCell = exports.toCapacityByLockHash = exports.toBlockchainInfo = exports.toBlockFilter = exports.toBlockEconomicState = void 0;
exports.toHeader = toHeader;
exports.toTip = exports.toSyncState = exports.toScript = exports.toRemoteNodeInfo = exports.toRawTxPool = exports.toPeers = exports.toOutput = exports.toOutPoint = exports.toNumber = exports.toNullable = exports.toLockHashIndexStates = exports.toLockHashIndexState = exports.toLocalNodeInfo = exports.toLiveCellsByLockHash = exports.toLiveCellWithStatus = exports.toLiveCell = exports.toInput = void 0;
exports.toTransaction = toTransaction;

@@ -31,3 +35,4 @@ exports.toUncleBlock = exports.toTxPoolInfo = exports.toTransactionsByLockHash = exports.toTransactionWithStatus = exports.toTransactionProof = exports.toTransactionPoint = exports.toTransactionAndWitnessProof = void 0;

exports.toHash = toHash;
const toHeader = header => {
function toHeader(header) {
if (typeof header === "string") return header;
if (!header) return header;

@@ -50,4 +55,3 @@ const {

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

@@ -161,4 +165,11 @@ if (!script) return script;

exports.toTip = toTip;
const toBlock = block => {
if (!block) return block;
function toBlock(res) {
if (!res) return res;
if (typeof res === "string") return res;
if ("block" in res && "cycles" in res) {
return {
cycles: res.cycles,
block: toBlock(res.block)
};
}
const {

@@ -169,3 +180,3 @@ header,

...rest
} = block;
} = res;
return {

@@ -177,4 +188,3 @@ header: toHeader(header),

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

@@ -369,3 +379,6 @@ if (!alertMessage) return alertMessage;

blockHash,
status
status,
...("reason" in txWithStatus.tx_status ? {
reason: txWithStatus.tx_status.reason
} : {})
},

@@ -744,3 +757,4 @@ timeAddedToPool: time_added_to_pool,

transactions: result.transactions.map(toTransaction),
proposals: result.proposals
proposals: result.proposals,
extension: result.extension
};

@@ -747,0 +761,0 @@ };

@@ -47,4 +47,2 @@ import type * as api from "@ckb-lumos/base";

url: string;
httpAgent?: any;
httpsAgent?: any;
}

@@ -72,3 +70,3 @@ interface Method {

type TransactionWithStatus<Tx = Transaction> = api.TransactionWithStatus<Tx>;
type BlockHeader = api.Header;
type BlockHeader<T = api.Header> = T;
type Block = api.Block;

@@ -265,2 +263,3 @@ type UncleBlock = api.UncleBlock;

proposals: ProposalShortId[];
extension: Hash;
}

@@ -267,0 +266,0 @@ type SerializedBlock = api.HexString;

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

/// <reference lib="dom" />
export type RPCConfig = {
timeout: number;
fetch: typeof fetch;
};
//# sourceMappingURL=common.d.ts.map

@@ -41,3 +41,5 @@ /**

Proposed = "proposed",
Committed = "committed"
Committed = "committed",
Unknown = "unknown",
Rejected = "rejected"
}

@@ -103,3 +105,4 @@ export type DepType = "code" | "dep_group";

block_hash: undefined;
status: TransactionStatus.Pending | TransactionStatus.Proposed;
status: TransactionStatus.Pending | TransactionStatus.Proposed | TransactionStatus.Rejected | TransactionStatus.Unknown;
reason?: string;
};

@@ -420,2 +423,3 @@ time_added_to_pool: Uint64 | null;

proposals: ProposalShortId[];
extension: Hash256;
}

@@ -422,0 +426,0 @@ export type SerializedBlock = HexString;

@@ -20,2 +20,4 @@ "use strict";

TransactionStatus["Committed"] = "committed";
TransactionStatus["Unknown"] = "unknown";
TransactionStatus["Rejected"] = "rejected";
return TransactionStatus;

@@ -22,0 +24,0 @@ }({});

{
"name": "@ckb-lumos/rpc",
"version": "0.0.0-ckb2023-fe6c0e5-20230925085931",
"version": "0.0.0-experimental-joyid-0855d00-20240319125140",
"description": "RPC module for CKB",

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

"dependencies": {
"@ckb-lumos/base": "0.0.0-ckb2023-fe6c0e5-20230925085931",
"@ckb-lumos/bi": "0.0.0-ckb2023-fe6c0e5-20230925085931",
"@vespaiach/axios-fetch-adapter": "^0.3.1",
"axios": "0.27.2",
"tslib": "2.3.1"
"@ckb-lumos/base": "0.0.0-experimental-joyid-0855d00-20240319125140",
"@ckb-lumos/bi": "0.0.0-experimental-joyid-0855d00-20240319125140",
"abort-controller": "^3.0.0",
"cross-fetch": "^3.1.5"
},

@@ -36,0 +35,0 @@ "devDependencies": {

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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