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-alpha.2 to 0.20.0-alpha.3

63

lib/Base/index.d.ts

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

getCellsCapacity: (searchKey: CKBComponents.SearchKey) => Promise<CKBComponents.CellsCapacity>;
/**
* @method getBlockFilter
* @param blockHash the block hash.
* @returns The block filter by block hash.
*/
getBlockFilter: (blockHash: CKBComponents.Hash256) => Promise<CKBComponents.BlockFilter | null>;
/**
* @method getTransactionAndWitnessProof
* @param txHashes Transaction hashes, all transactions must be in the same block
* @param blockHash An optional parameter, if specified, looks for transactions in the block with this hash
* @returns a Merkle proof of transactions’ witness included in a block
*/
getTransactionAndWitnessProof: (txHashes: CKBComponents.Hash256[], blockHash?: CKBComponents.Hash256) => Promise<CKBComponents.TransactionAndWitnessProof>;
/**
* @method verifyTransactionAndWitnessProof
* @description Verifies that a proof points to transactions in a block
* @param txProof proof generated by {@link Base.getTransactionAndWitnessProof}
* @returns the transaction hashes it commits to
*/
verifyTransactionAndWitnessProof: (txProof: CKBComponents.TransactionAndWitnessProof) => Promise<CKBComponents.Hash256[]>;
/**
* @method getForkBlock
* @param blockHash the fork block hash.
* @param verbosity result format which allows 0 and 2. (Optional, the default is 2.)
* @returns a fork block or null. When the RPC returns a block, the block hash must equal to the parameter `blockHash`.
* Please note that due to the technical nature of the peer to peer sync, the RPC may return null or a fork block result on different nodes with same `block_hash` even they are fully synced to the canonical chain.
* And because of chain reorganization, for the same `block_hash`, the RPC may sometimes return null and sometimes return the fork block.
* When verbosity is 2, it returns a JSON object as the result. See BlockView for the schema.
* When verbosity is 0, it returns a 0x-prefixed hex string as the result. The string encodes the block serialized by molecule using schema table Block.
*/
getForkBlock(blockHash: CKBComponents.Hash256, verbosity?: 2n | "0x2"): Promise<CKBComponents.BlockView | null>;
getForkBlock(blockHash: CKBComponents.Hash256, verbosity: 0n | "0x0"): Promise<CKBComponents.SerializedBlock | null>;
/**
* @method getBlockMedianTime
* @param blockHash A median time is calculated for a consecutive block sequence. `blockHash` indicates the highest block of the sequence.
* @returns the past median time by block hash.
* When the given block hash is not on the current canonical chain, this RPC returns null;
* otherwise returns the median time of the consecutive 37 blocks where the given block_hash has the highest height.
* Note that the given block is included in the median time.
* The included block number range is `[MAX(block - 36, 0), block]`.
*/
getBlockMedianTime: (blockHash: CKBComponents.Hash256) => Promise<CKBComponents.Timestamp | null>;
/**
* @method estimateCycles
* run a transaction and return the execution consumed cycles
* This method will not check the transaction validity, but only run the lock script and type script and then return the execution cycles.
* @param tx
* @returns how many cycles the scripts consume.
*/
estimateCycles: (tx: CKBComponents.Transaction) => Promise<CKBComponents.EstimateCycles>;
/**
* @method getFeeRateStatics
* @deprecated Please use {@link Base.getFeeRateStatistics} instead
* @param target Specify the number (1 - 101) of confirmed blocks to be counted. If the number is even, automatically add one. If not specified, defaults to 2
* @returns the feeRate statistics of confirmed blocks on the chain
*/
getFeeRateStatics: (target?: CKBComponents.UInt64) => Promise<CKBComponents.FeeRateStatistics>;
/**
* @method getFeeRateStatistics
* @param target Specify the number (1 - 101) of confirmed blocks to be counted. If the number is even, automatically add one. If not specified, defaults to 2
* @returns the feeRate statistics of confirmed blocks on the chain If the query finds the corresponding historical data, the corresponding statistics are returned, containing the mean and median, in shannons per kilo-weight. If not, it returns null.
*/
getFeeRateStatistics: () => Promise<CKBComponents.FeeRateStatistics>;
}

@@ -310,0 +373,0 @@ export declare class Base {

28

lib/Base/indexer.d.ts

@@ -1,24 +0,8 @@

declare const _default: {
getIndexerTip: {
method: string;
paramsFormatters: never[];
resultFormatters: (tip: import("../types/rpc").RPC.Tip) => import("../types/api").CKBComponents.Tip;
};
getCells: {
method: string;
paramsFormatters: (((number: string | bigint) => string) | ((order: "asc" | "desc") => "asc" | "desc") | ((data: import("../types/api").CKBComponents.GetCellsSearchKey<boolean>) => import("../types/rpc").RPC.GetCellsSearchKey) | ((arg: any) => any))[];
resultFormatters: (getCellsResult: import("../types/rpc").RPC.GetLiveCellsResult) => import("../types/api").CKBComponents.GetLiveCellsResult<true>;
};
getTransactions: {
method: string;
paramsFormatters: (((number: string | bigint) => string) | ((order: "asc" | "desc") => "asc" | "desc") | ((data: import("../types/api").CKBComponents.GetTransactionsSearchKey<boolean>) => import("../types/rpc").RPC.GetTransactionsSearchKey) | ((arg: any) => any))[];
resultFormatters: <Goruped extends boolean = false>(getTransactionsResult: import("../types/rpc").RPC.GetTransactionsResult<Goruped>) => import("../types/api").CKBComponents.GetTransactionsResult<Goruped>;
};
getCellsCapacity: {
method: string;
paramsFormatters: ((data: import("../types/api").CKBComponents.SearchKey) => import("../types/rpc").RPC.SearchKey)[];
resultFormatters: (cellsCapacity: import("../types/rpc").RPC.CellsCapacity) => import("../types/api").CKBComponents.CellsCapacity;
};
declare type MethodSchema = {
method: string;
paramsFormatters: ((arg: any) => any)[];
resultFormatters: (arg: any) => any;
};
export default _default;
declare const schemas: Record<string, MethodSchema>;
export default schemas;
//# sourceMappingURL=indexer.d.ts.map

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

var _default = {
const schemas = {
getIndexerTip: {

@@ -37,5 +37,46 @@ method: "get_indexer_tip",

resultFormatters: resultFmts.toCellsCapacity
},
getBlockFilter: {
method: "get_block_filter",
paramsFormatters: [_paramsFormatter.formatter.toHash],
resultFormatters: resultFmts.toNullable(resultFmts.toBlockFilter)
},
getTransactionAndWitnessProof: {
method: "get_transaction_and_witness_proof",
paramsFormatters: [_paramsFormatter.formatter.toArray(_paramsFormatter.formatter.toHash), _paramsFormatter.formatter.toOptional(_paramsFormatter.formatter.toHash)],
resultFormatters: resultFmts.toTransactionAndWitnessProof
},
verifyTransactionAndWitnessProof: {
method: "verify_transaction_and_witness_proof",
paramsFormatters: [_paramsFormatter.formatter.toTransactionAndWitnessProof],
resultFormatters: resultFmts.toArray(resultFmts.toHash)
},
getForkBlock: {
method: "get_fork_block",
paramsFormatters: [_paramsFormatter.formatter.toHash, _paramsFormatter.formatter.toOptional(_paramsFormatter.formatter.toNumber)],
resultFormatters: resultFmts.toNullable(resultFmts.toForkBlockResult)
},
getBlockMedianTime: {
method: "get_block_median_time",
paramsFormatters: [_paramsFormatter.formatter.toHash],
resultFormatters: resultFmts.toNullable(resultFmts.toNumber)
},
estimateCycles: {
method: "estimate_cycles",
paramsFormatters: [_paramsFormatter.formatter.toRawTransaction],
resultFormatters: resultFmts.toEstimateCycles
},
getFeeRateStatistics: {
method: "get_fee_rate_statistics",
paramsFormatters: [_paramsFormatter.formatter.toOptional(_paramsFormatter.formatter.toNumber)],
resultFormatters: resultFmts.toNullable(resultFmts.toFeeRateStatistics)
},
getFeeRateStatics: {
method: "get_fee_rate_statics",
paramsFormatters: [_paramsFormatter.formatter.toOptional(_paramsFormatter.formatter.toNumber)],
resultFormatters: resultFmts.toNullable(resultFmts.toFeeRateStatistics)
}
};
var _default = schemas;
exports.default = _default;
//# sourceMappingURL=indexer.js.map

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

toTransactionProof: (proof: import("@ckb-lumos/base").TransactionProof) => import("./types/rpc").RPC.TransactionProof;
toTransactionAndWitnessProof: (proof: CKBComponents.TransactionAndWitnessProof) => import("./types/rpc").RPC.TransactionAndWitnessProof;
toSearchFilter: (data: CKBComponents.SearchFilter) => import("./types/rpc").RPC.SearchFilter;

@@ -41,5 +42,5 @@ toSearchKey: (data: CKBComponents.SearchKey) => import("./types/rpc").RPC.SearchKey;

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" | "rpcProperties", P extends (string | number | object)[], R = any[]>(params?: any) => any;
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;
}
export { CKBRPC as RPC };
//# sourceMappingURL=index.d.ts.map

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

/** @internal */
export declare function initAxiosWebworkerAdapter(): void;
export {};
//# sourceMappingURL=initAxiosWebworkerAdapter.d.ts.map

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

toTransactionProof: (proof: CKBComponents.TransactionProof) => RPC.TransactionProof;
toTransactionAndWitnessProof: (proof: CKBComponents.TransactionAndWitnessProof) => RPC.TransactionAndWitnessProof;
toSearchFilter: (data: CKBComponents.SearchFilter) => RPC.SearchFilter;

@@ -24,0 +25,0 @@ toSearchKey: (data: CKBComponents.SearchKey) => RPC.SearchKey;

@@ -187,2 +187,9 @@ "use strict";

},
toTransactionAndWitnessProof: proof => {
return {
block_hash: proof.blockHash,
witnesses_proof: proof.witnessesProof,
transactions_proof: proof.transactionsProof
};
},
toSearchFilter: data => {

@@ -189,0 +196,0 @@ if (!data) return data;

import { CKBComponents } from "./types/api";
import { RPC } from "./types/rpc";
declare const toArray: <I, O>(format?: ((args: I) => O) | undefined) => (arg: I[]) => I[] | O[];
declare const toNullable: <I, O>(format?: ((args: I) => O) | undefined) => (origin: I | null) => I | O | null;
declare const toNumber: (number: RPC.BlockNumber) => CKBComponents.BlockNumber;

@@ -68,3 +70,8 @@ declare const toHash: (hash: RPC.Hash256) => CKBComponents.Hash256;

declare const toCellsCapacity: (cellsCapacity: RPC.CellsCapacity) => CKBComponents.CellsCapacity;
export { toNumber, toHash, toHeader, toScript, toInput, toOutput, toOutPoint, toDepType, toCellDep, toTransaction, toUncleBlock, toBlock, toTip, toAlertMessage, toBlockchainInfo, toLocalNodeInfo, toRemoteNodeInfo, toTxPoolInfo, toPeers, toLiveCell, toLiveCellWithStatus, toCell, toCells, toCellIncludingOutPoint, toCellsIncludingOutPoint, toTransactionWithStatus, toEpoch, toTransactionPoint, toTransactionsByLockHash, toLiveCellsByLockHash, toLockHashIndexState, toLockHashIndexStates, toBannedAddress, toBannedAddresses, toCellbaseOutputCapacityDetails, toFeeRate, toCapacityByLockHash, toBlockEconomicState, toSyncState, toTransactionProof, toConsensus, toRawTxPool, toCellsCapacity, toGetCellsResult, toGetTransactionsResult, };
declare const toBlockFilter: (blockFilter: RPC.BlockFilter) => CKBComponents.BlockFilter;
declare const toTransactionAndWitnessProof: (proof: RPC.TransactionAndWitnessProof) => CKBComponents.TransactionAndWitnessProof;
declare const toFeeRateStatistics: (statistics: RPC.FeeRateStatistics) => CKBComponents.FeeRateStatistics;
declare const toForkBlockResult: (result: RPC.BlockView | RPC.SerializedBlock) => CKBComponents.BlockView | CKBComponents.SerializedBlock;
declare const toEstimateCycles: (cycle: RPC.EstimateCycles) => CKBComponents.EstimateCycles;
export { toNumber, toHash, toArray, toNullable, toHeader, toScript, toInput, toOutput, toOutPoint, toDepType, toCellDep, toTransaction, toUncleBlock, toBlock, toTip, toAlertMessage, toBlockchainInfo, toLocalNodeInfo, toRemoteNodeInfo, toTxPoolInfo, toPeers, toLiveCell, toLiveCellWithStatus, toCell, toCells, toCellIncludingOutPoint, toCellsIncludingOutPoint, toTransactionWithStatus, toEpoch, toTransactionPoint, toTransactionsByLockHash, toLiveCellsByLockHash, toLockHashIndexState, toLockHashIndexStates, toBannedAddress, toBannedAddresses, toCellbaseOutputCapacityDetails, toFeeRate, toCapacityByLockHash, toBlockEconomicState, toSyncState, toTransactionProof, toConsensus, toRawTxPool, toCellsCapacity, toGetCellsResult, toGetTransactionsResult, toBlockFilter, toTransactionAndWitnessProof, toFeeRateStatistics, toForkBlockResult, toEstimateCycles, };
//# sourceMappingURL=resultFormatter.d.ts.map

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

});
exports.toTip = exports.toSyncState = exports.toScript = exports.toRemoteNodeInfo = exports.toRawTxPool = exports.toPeers = exports.toOutput = exports.toOutPoint = exports.toNumber = exports.toLockHashIndexStates = exports.toLockHashIndexState = exports.toLocalNodeInfo = exports.toLiveCellsByLockHash = exports.toLiveCellWithStatus = exports.toLiveCell = exports.toInput = exports.toHeader = exports.toHash = exports.toGetTransactionsResult = exports.toGetCellsResult = exports.toFeeRate = exports.toEpoch = exports.toDepType = exports.toConsensus = exports.toCellsIncludingOutPoint = exports.toCellsCapacity = exports.toCells = exports.toCellbaseOutputCapacityDetails = exports.toCellIncludingOutPoint = exports.toCellDep = exports.toCell = exports.toCapacityByLockHash = exports.toBlockchainInfo = exports.toBlockEconomicState = exports.toBlock = exports.toBannedAddresses = exports.toBannedAddress = exports.toAlertMessage = void 0;
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.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.toTransaction = toTransaction;
exports.toUncleBlock = exports.toTxPoolInfo = exports.toTransactionsByLockHash = exports.toTransactionWithStatus = exports.toTransactionProof = exports.toTransactionPoint = void 0;
exports.toUncleBlock = exports.toTxPoolInfo = exports.toTransactionsByLockHash = exports.toTransactionWithStatus = exports.toTransactionProof = exports.toTransactionPoint = exports.toTransactionAndWitnessProof = void 0;
/* eslint-disable camelcase, @typescript-eslint/no-explicit-any */
const isTxPoolIds = rawTxPool => {
return Array.isArray(rawTxPool.pending);
};
/* eslint-disable camelcase */
const toArray = format => arg => {
if (typeof format !== "function" || !Array.isArray(arg)) {
return arg;
}
return arg.map(format);
};
exports.toArray = toArray;
const toNullable = format => origin => {
if (!format || origin === null) return origin;
return format(origin);
};
exports.toNullable = toNullable;
const toNumber = number => number.toString();

@@ -768,6 +784,57 @@

};
exports.toCellsCapacity = toCellsCapacity;
const toBlockFilter = blockFilter => {
return {
hash: blockFilter.hash,
data: blockFilter.data
};
};
exports.toBlockFilter = toBlockFilter;
const toTransactionAndWitnessProof = proof => {
return {
blockHash: proof.block_hash,
transactionsProof: proof.transactions_proof,
witnessesProof: proof.witnesses_proof
};
};
exports.toTransactionAndWitnessProof = toTransactionAndWitnessProof;
const toFeeRateStatistics = statistics => {
return {
mean: statistics.mean,
median: statistics.median
};
};
exports.toFeeRateStatistics = toFeeRateStatistics;
const toForkBlockResult = result => {
if (typeof result === "string") {
return result;
}
return {
header: toHeader(result.header),
uncles: result.uncles.map(toUncleBlock),
transactions: result.transactions.map(toTransaction),
proposals: result.proposals
};
};
exports.toForkBlockResult = toForkBlockResult;
const toEstimateCycles = cycle => {
return {
cycles: cycle.cycles
};
};
/* eslint-enable camelcase */
exports.toCellsCapacity = toCellsCapacity;
exports.toEstimateCycles = toEstimateCycles;
//# sourceMappingURL=resultFormatter.js.map

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

type Hash256 = string;
type UInt32 = number;
type UInt32 = string;
type UInt64 = string;
type Index = string;

@@ -236,3 +237,29 @@ type Version = string;

}
interface BlockFilter {
data: api.HexString;
hash: api.Hash;
}
interface TransactionAndWitnessProof {
blockHash: Hash256;
transactionsProof: api.MerkleProof;
witnessesProof: api.MerkleProof;
}
type TransactionView = api.Transaction & {
hash: api.Hash;
};
interface BlockView {
header: BlockHeader;
uncles: UncleBlock[];
transactions: TransactionView[];
proposals: ProposalShortId[];
}
type SerializedBlock = api.HexString;
interface FeeRateStatistics {
mean: UInt64;
median: UInt64;
}
interface EstimateCycles {
cycles: UInt64;
}
}
//# sourceMappingURL=api.d.ts.map
/**
* @see https://github.com/nervosnetwork/ckb/blob/develop/util/jsonrpc-types/src/blockchain.rs
*/
import { HexNumber, HexString, MerkleProof } from "@ckb-lumos/base";
import { CKBComponents } from "./api";

@@ -356,3 +357,36 @@ export declare namespace RPC {

}
interface BlockFilter {
data: HexString;
hash: Hash;
}
interface TransactionAndWitnessProof {
block_hash: Hash;
transactions_proof: MerkleProof;
witnesses_proof: MerkleProof;
}
interface FeeRateStatistics {
mean: HexNumber;
median: HexNumber;
}
type HeaderView = Header & {
hash: Hash;
};
interface UncleBlockView {
header: HeaderView;
proposals: ProposalShortId[];
}
type TransactionView = Transaction & {
hash: Hash;
};
interface BlockView {
header: HeaderView;
uncles: UncleBlockView[];
transactions: TransactionView[];
proposals: ProposalShortId[];
}
type SerializedBlock = HexString;
interface EstimateCycles {
cycles: HexNumber;
}
}
//# sourceMappingURL=rpc.d.ts.map
{
"name": "@ckb-lumos/rpc",
"version": "0.20.0-alpha.2",
"version": "0.20.0-alpha.3",
"description": "RPC module for CKB",

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

"dependencies": {
"@ckb-lumos/base": "0.20.0-alpha.2",
"@ckb-lumos/bi": "0.20.0-alpha.2",
"@ckb-lumos/base": "0.20.0-alpha.3",
"@ckb-lumos/bi": "0.20.0-alpha.3",
"@vespaiach/axios-fetch-adapter": "^0.3.1",

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

},
"gitHead": "f41d9ce46a27d778f009d5645a4407240dbc50c8"
"gitHead": "2fec01107cc42d21ce81434b72abf21fdfaf3377"
}

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