@ckb-lumos/rpc
Advanced tools
Comparing version 0.0.0-canary-ed5dc56-20230901063035 to 0.0.0-canary-ed7c2fa-20240511022143
@@ -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; | ||
}; | ||
@@ -65,9 +66,3 @@ getLiveCell: { | ||
paramsFormatters: ((hash: string) => string)[]; | ||
resultFormatters: (txWithStatus: import("../types/rpc").RPC.TransactionWithStatus) => { | ||
transaction: import("../types/api").CKBComponents.RawTransaction; | ||
txStatus: { | ||
blockHash: string | undefined; | ||
status: import("../types/rpc").RPC.TransactionStatus; | ||
}; | ||
}; | ||
resultFormatters: <Tx>(txWithStatus: import("../types/rpc").RPC.TransactionWithStatus) => import("../types/api").CKBComponents.TransactionWithStatus<Tx>; | ||
}; | ||
@@ -74,0 +69,0 @@ getCellbaseOutputCapacityDetails: { |
@@ -6,2 +6,24 @@ 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 { | ||
(hash: CKBComponents.Hash): Promise<CKBComponents.TransactionWithStatus>; | ||
(hash: CKBComponents.Hash, verbosity: "0x0", onlyCommitted?: boolean): Promise<CKBComponents.TransactionWithStatus<string>>; | ||
(hash: CKBComponents.Hash, verbosity: "0x1", onlyCommitted?: boolean): Promise<CKBComponents.TransactionWithStatus<null>>; | ||
(hash: CKBComponents.Hash, verbosity: "0x2", onlyCommitted?: boolean): Promise<CKBComponents.TransactionWithStatus>; | ||
} | ||
export interface GetHeader<Q> { | ||
(query: Q, verbosity?: "0x1"): Promise<CKBComponents.BlockHeader>; | ||
(query: Q, verbosity: "0x0"): Promise<string>; | ||
} | ||
export interface Base { | ||
@@ -49,6 +71,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>; | ||
/** | ||
@@ -60,3 +84,3 @@ * @method getHeader | ||
*/ | ||
getHeader: (blockHash: CKBComponents.Hash) => Promise<CKBComponents.BlockHeader>; | ||
getHeader: GetHeader<CKBComponents.Hash>; | ||
/** | ||
@@ -68,3 +92,3 @@ * @method getHeaderByNumber | ||
*/ | ||
getHeaderByNumber: (blockNumber: CKBComponents.BlockNumber | bigint) => Promise<CKBComponents.BlockHeader>; | ||
getHeaderByNumber: GetHeader<CKBComponents.BlockNumber | bigint>; | ||
/** | ||
@@ -80,3 +104,3 @@ * @method getLiveCell | ||
getLiveCell: (outPoint: CKBComponents.OutPoint, withData: boolean) => Promise<{ | ||
cell: CKBComponents.LiveCell; | ||
cell: Option<CKBComponents.LiveCell>; | ||
status: CKBComponents.CellStatus; | ||
@@ -91,3 +115,3 @@ }>; | ||
*/ | ||
getTransaction: (hash: CKBComponents.Hash) => Promise<CKBComponents.TransactionWithStatus>; | ||
getTransaction: GetTransaction; | ||
/** | ||
@@ -137,7 +161,9 @@ * @method getCellbaseOutputCapacityDetails | ||
* @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>; | ||
/** | ||
@@ -377,3 +403,4 @@ * @method dryRunTransaction | ||
*/ | ||
getFeeRateStatistics: () => Promise<CKBComponents.FeeRateStatistics>; | ||
getFeeRateStatistics: (target?: CKBComponents.UInt64) => Promise<CKBComponents.FeeRateStatistics>; | ||
getDeploymentsInfo: () => Promise<CKBComponents.DeploymentsInfo>; | ||
} | ||
@@ -384,2 +411,4 @@ export declare class Base { | ||
} | ||
export type Option<T> = T | null; | ||
export {}; | ||
//# sourceMappingURL=index.d.ts.map |
@@ -29,2 +29,8 @@ "use strict"; | ||
}; | ||
// prettier-ignore | ||
// prettier-ignore | ||
// prettier-ignore | ||
exports.rpcProperties = rpcProperties; | ||
@@ -31,0 +37,0 @@ var _rpcProperties = /*#__PURE__*/new WeakMap(); |
@@ -5,6 +5,11 @@ declare const _default: { | ||
paramsFormatters: never[]; | ||
resultFormatters: (info: import("../types/rpc").RPC.BlockchainInfo) => import("@ckb-lumos/base").ChainInfo; | ||
resultFormatters: (info: import("../types/rpc").RPC.ChainInfo) => import("@ckb-lumos/base").ChainInfo; | ||
}; | ||
getDeploymentsInfo: { | ||
method: string; | ||
paramsFormatters: never[]; | ||
resultFormatters: (deploymentInfo: import("../types/rpc").RPC.DeploymentsInfo) => import("@ckb-lumos/base").DeploymentsInfo; | ||
}; | ||
}; | ||
export default _default; | ||
//# sourceMappingURL=stats.d.ts.map |
@@ -15,2 +15,7 @@ "use strict"; | ||
resultFormatters: resultFmts.toBlockchainInfo | ||
}, | ||
getDeploymentsInfo: { | ||
method: "get_deployments_info", | ||
paramsFormatters: [], | ||
resultFormatters: resultFmts.toDeploymentsInfo | ||
} | ||
@@ -17,0 +22,0 @@ }; |
@@ -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; | ||
@@ -46,9 +53,3 @@ declare const toBlockchainInfo: (info: RPC.BlockchainInfo) => CKBComponents.BlockchainInfo; | ||
declare const toCellsIncludingOutPoint: (cells: RPC.CellIncludingOutPoint[]) => CKBComponents.CellIncludingOutPoint[]; | ||
declare const toTransactionWithStatus: (txWithStatus: RPC.TransactionWithStatus) => { | ||
transaction: CKBComponents.RawTransaction; | ||
txStatus: { | ||
blockHash: string | undefined; | ||
status: RPC.TransactionStatus; | ||
}; | ||
}; | ||
declare const toTransactionWithStatus: <Tx>(txWithStatus: RPC.TransactionWithStatus) => CKBComponents.TransactionWithStatus<Tx>; | ||
declare const toEpoch: (epoch: RPC.Epoch) => CKBComponents.Epoch; | ||
@@ -68,5 +69,6 @@ declare const toTransactionPoint: (transactionPoint: RPC.TransactionPoint) => CKBComponents.TransactionPoint; | ||
declare const toTransactionProof: (proof: RPC.TransactionProof) => CKBComponents.TransactionProof; | ||
declare const toDeployment: (deployment: RPC.Deployment) => CKBComponents.Deployment; | ||
declare const toConsensus: (consensus: RPC.Consensus) => CKBComponents.Consensus; | ||
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>; | ||
@@ -79,3 +81,6 @@ declare const toCellsCapacity: (cellsCapacity: RPC.CellsCapacity) => CKBComponents.CellsCapacity; | ||
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, }; | ||
declare const toDeployState: (state: RPC.DeploymentState) => CKBComponents.DeploymentState; | ||
declare const toDeploymentInfo: (deploymentInfo: RPC.DeploymentInfo) => CKBComponents.DeploymentInfo; | ||
declare const toDeploymentsInfo: (deploymentInfo: RPC.DeploymentsInfo) => CKBComponents.DeploymentsInfo; | ||
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, toDeployment, toDeployState, toDeploymentInfo, toDeploymentsInfo, }; | ||
//# sourceMappingURL=resultFormatter.d.ts.map |
@@ -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.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 => { | ||
@@ -126,3 +130,3 @@ if (!script) return script; | ||
function toTransaction(tx) { | ||
if (!tx) return tx; | ||
if (!tx || typeof tx !== "object") return tx; | ||
const { | ||
@@ -162,4 +166,11 @@ cell_deps: cellDeps = [], | ||
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 { | ||
@@ -170,3 +181,3 @@ header, | ||
...rest | ||
} = block; | ||
} = res; | ||
return { | ||
@@ -178,4 +189,3 @@ header: toHeader(header), | ||
}; | ||
}; | ||
exports.toBlock = toBlock; | ||
} | ||
const toAlertMessage = alertMessage => { | ||
@@ -354,3 +364,2 @@ if (!alertMessage) return alertMessage; | ||
}; | ||
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types | ||
exports.toCellsIncludingOutPoint = toCellsIncludingOutPoint; | ||
@@ -365,2 +374,3 @@ const toTransactionWithStatus = txWithStatus => { | ||
}, | ||
time_added_to_pool, | ||
...rest | ||
@@ -372,4 +382,8 @@ } = txWithStatus; | ||
blockHash, | ||
status | ||
status, | ||
...("reason" in txWithStatus.tx_status ? { | ||
reason: txWithStatus.tx_status.reason | ||
} : {}) | ||
}, | ||
timeAddedToPool: time_added_to_pool, | ||
...rest | ||
@@ -563,5 +577,34 @@ }; | ||
exports.toTransactionProof = toTransactionProof; | ||
const toHardforkFeature = feature => { | ||
return { | ||
rfc: feature.rfc, | ||
epochNumber: feature.epoch_number | ||
}; | ||
}; | ||
const toDeployment = deployment => { | ||
return { | ||
bit: deployment.bit, | ||
start: deployment.start, | ||
timeout: deployment.timeout, | ||
minActivationEpoch: deployment.min_activation_epoch, | ||
period: deployment.period, | ||
threshold: deployment.threshold | ||
}; | ||
}; | ||
exports.toDeployment = toDeployment; | ||
const toSoftFork = softFork => { | ||
if ("rfc0043" in softFork) { | ||
return { | ||
status: softFork.status, | ||
rfc0043: toDeployment(softFork.rfc0043) | ||
}; | ||
} | ||
return softFork; | ||
}; | ||
const toConsensus = consensus => { | ||
var _consensus$hardfork_f, _consensus$hardfork_f2; | ||
if (!consensus) return consensus; | ||
const rpcHardforkFeatures = consensus.hardfork_features; | ||
const softforks = consensus.softforks; | ||
const lightClient = softforks.light_client && toSoftFork(softforks.light_client); | ||
const testdummy = softforks.testdummy && toSoftFork(softforks.testdummy); | ||
return { | ||
@@ -590,9 +633,11 @@ blockVersion: consensus.block_version, | ||
typeIdCodeHash: consensus.type_id_code_hash, | ||
hardforkFeatures: (_consensus$hardfork_f = (_consensus$hardfork_f2 = consensus.hardfork_features) === null || _consensus$hardfork_f2 === void 0 ? void 0 : _consensus$hardfork_f2.map(({ | ||
epoch_number: epochNumber, | ||
...rest | ||
}) => ({ | ||
epochNumber, | ||
...rest | ||
}))) !== null && _consensus$hardfork_f !== void 0 ? _consensus$hardfork_f : consensus.hardfork_features | ||
hardforkFeatures: rpcHardforkFeatures.map(toHardforkFeature), | ||
softforks: { | ||
...(lightClient && { | ||
lightClient | ||
}), | ||
...(testdummy && { | ||
testdummy | ||
}) | ||
} | ||
}; | ||
@@ -717,3 +762,4 @@ }; | ||
transactions: result.transactions.map(toTransaction), | ||
proposals: result.proposals | ||
proposals: result.proposals, | ||
extension: result.extension | ||
}; | ||
@@ -727,5 +773,45 @@ }; | ||
}; | ||
exports.toEstimateCycles = toEstimateCycles; | ||
const toDeployState = state => { | ||
if (state === "locked_in") { | ||
return "lockedIn"; | ||
} | ||
return state; | ||
}; | ||
exports.toDeployState = toDeployState; | ||
const toDeploymentInfo = deploymentInfo => { | ||
return { | ||
bit: deploymentInfo.bit, | ||
/// specifies the first epoch in which the bit gains meaning. | ||
start: deploymentInfo.start, | ||
timeout: deploymentInfo.timeout, | ||
minActivationEpoch: deploymentInfo.min_activation_epoch, | ||
period: deploymentInfo.period, | ||
threshold: deploymentInfo.threshold, | ||
since: deploymentInfo.since, | ||
state: toDeployState(deploymentInfo.state) | ||
}; | ||
}; | ||
exports.toDeploymentInfo = toDeploymentInfo; | ||
const toDeploymentsInfo = deploymentInfo => { | ||
const { | ||
light_client, | ||
testdummy | ||
} = deploymentInfo.deployments; | ||
return { | ||
hash: deploymentInfo.hash, | ||
epoch: deploymentInfo.epoch, | ||
deployments: { | ||
...(light_client ? { | ||
lightClient: toDeploymentInfo(light_client) | ||
} : {}), | ||
...(testdummy ? { | ||
testdummy: toDeploymentInfo(testdummy) | ||
} : {}) | ||
} | ||
}; | ||
}; | ||
/* eslint-enable camelcase */ | ||
exports.toEstimateCycles = toEstimateCycles; | ||
exports.toDeploymentsInfo = toDeploymentsInfo; | ||
//# sourceMappingURL=resultFormatter.js.map |
@@ -12,2 +12,3 @@ import type * as api from "@ckb-lumos/base"; | ||
type UInt64 = string; | ||
type U256 = string; | ||
type Index = string; | ||
@@ -29,2 +30,3 @@ type Version = string; | ||
type EpochNumberWithFraction = string; | ||
type EpochNumber = string; | ||
enum TransactionStatus { | ||
@@ -35,3 +37,3 @@ Pending = "pending", | ||
} | ||
type ScriptHashType = "data" | "type" | "data1"; | ||
type ScriptHashType = api.HashType; | ||
type DepType = "code" | "depGroup"; | ||
@@ -48,4 +50,2 @@ type JsonBytes = string; | ||
url: string; | ||
httpAgent?: any; | ||
httpsAgent?: any; | ||
} | ||
@@ -72,4 +72,4 @@ interface Method { | ||
type Transaction = Required<api.Transaction>; | ||
type TransactionWithStatus = api.TransactionWithStatus; | ||
type BlockHeader = api.Header; | ||
type TransactionWithStatus<Tx = Transaction> = api.TransactionWithStatus<Tx>; | ||
type BlockHeader<T = api.Header> = T; | ||
type Block = api.Block; | ||
@@ -94,2 +94,10 @@ type UncleBlock = api.UncleBlock; | ||
type Consensus = api.Consensus; | ||
type HardForks = api.HardForks; | ||
type HardForkFeature = api.HardforkFeature; | ||
type SoftForkStatus = api.SoftForkStatus; | ||
type SoftFork = api.SoftFork; | ||
type Buried = api.Buried; | ||
type Rfc0043 = api.Rfc0043; | ||
type Ratio = api.Ratio; | ||
type Deployment = api.Deployment; | ||
type QueryOptions = api.QueryOptions; | ||
@@ -259,2 +267,3 @@ interface TransactionPoint { | ||
proposals: ProposalShortId[]; | ||
extension: Hash; | ||
} | ||
@@ -269,3 +278,7 @@ type SerializedBlock = api.HexString; | ||
} | ||
type DeploymentPos = api.DeploymentPos; | ||
type DeploymentState = api.DeploymentState; | ||
type DeploymentInfo = api.DeploymentInfo; | ||
type DeploymentsInfo = api.DeploymentsInfo; | ||
} | ||
//# sourceMappingURL=api.d.ts.map |
@@ -0,4 +1,6 @@ | ||
/// <reference lib="dom" /> | ||
export type RPCConfig = { | ||
timeout: number; | ||
fetch: typeof fetch; | ||
}; | ||
//# sourceMappingURL=common.d.ts.map |
@@ -7,34 +7,43 @@ /** | ||
export declare namespace RPC { | ||
type ProposalShortId = CKBComponents.ProposalShortId; | ||
type Number = CKBComponents.Number; | ||
type UInt32 = CKBComponents.UInt32; | ||
type Count = CKBComponents.Count; | ||
type DAO = CKBComponents.DAO; | ||
type Hash = CKBComponents.Hash; | ||
type Hash256 = CKBComponents.Hash256; | ||
type Version = CKBComponents.Version; | ||
type Capacity = CKBComponents.Capacity; | ||
type Witness = CKBComponents.Witness; | ||
type Bytes = CKBComponents.Bytes; | ||
type Index = CKBComponents.Index; | ||
type Since = CKBComponents.Since; | ||
type Timestamp = CKBComponents.Timestamp; | ||
type BlockNumber = CKBComponents.BlockNumber; | ||
type EpochInHeader = string; | ||
type Difficulty = CKBComponents.Difficulty; | ||
type Cycles = CKBComponents.Cycles; | ||
type Size = CKBComponents.Size; | ||
type RationalU256 = CKBComponents.RationalU256; | ||
type ProposalWindow = CKBComponents.ProposalWindow; | ||
type EpochNumberWithFraction = CKBComponents.EpochNumberWithFraction; | ||
type JsonBytes = CKBComponents.JsonBytes; | ||
type IOType = CKBComponents.IOType; | ||
enum TransactionStatus { | ||
export type ProposalShortId = CKBComponents.ProposalShortId; | ||
export type Number = CKBComponents.Number; | ||
export type UInt32 = CKBComponents.UInt32; | ||
export type Uint64 = CKBComponents.UInt64; | ||
export type U256 = CKBComponents.U256; | ||
export type Count = CKBComponents.Count; | ||
export type DAO = CKBComponents.DAO; | ||
export type Hash = CKBComponents.Hash; | ||
export type Hash256 = CKBComponents.Hash256; | ||
export type Version = CKBComponents.Version; | ||
export type Capacity = CKBComponents.Capacity; | ||
export type Witness = CKBComponents.Witness; | ||
export type Bytes = CKBComponents.Bytes; | ||
export type Index = CKBComponents.Index; | ||
export type Since = CKBComponents.Since; | ||
export type Timestamp = CKBComponents.Timestamp; | ||
export type BlockNumber = CKBComponents.BlockNumber; | ||
export type EpochInHeader = string; | ||
export type Difficulty = CKBComponents.Difficulty; | ||
export type Cycles = CKBComponents.Cycles; | ||
export type Size = CKBComponents.Size; | ||
export type RationalU256 = CKBComponents.RationalU256; | ||
export type ProposalWindow = CKBComponents.ProposalWindow; | ||
export type EpochNumberWithFraction = CKBComponents.EpochNumberWithFraction; | ||
export type JsonBytes = CKBComponents.JsonBytes; | ||
export type IOType = CKBComponents.IOType; | ||
export type EpochNumber = CKBComponents.EpochNumber; | ||
type MapLike<K extends string, V> = { | ||
[key in K]?: V; | ||
}; | ||
type Vec<T> = T[]; | ||
export enum TransactionStatus { | ||
Pending = "pending", | ||
Proposed = "proposed", | ||
Committed = "committed" | ||
Committed = "committed", | ||
Unknown = "unknown", | ||
Rejected = "rejected" | ||
} | ||
type ScriptHashType = CKBComponents.ScriptHashType; | ||
type DepType = "code" | "dep_group"; | ||
interface Script { | ||
export type DepType = "code" | "dep_group"; | ||
export type ScriptHashType = CKBComponents.ScriptHashType; | ||
export interface Script { | ||
args: Bytes; | ||
@@ -44,11 +53,11 @@ code_hash: Hash256; | ||
} | ||
interface OutPoint { | ||
export interface OutPoint { | ||
tx_hash: Hash256; | ||
index: Index; | ||
} | ||
interface CellInput { | ||
export interface CellInput { | ||
previous_output: OutPoint; | ||
since: Since; | ||
} | ||
interface CellOutput { | ||
export interface CellOutput { | ||
capacity: Capacity; | ||
@@ -58,4 +67,4 @@ lock: Script; | ||
} | ||
type Cell = CellOutput; | ||
interface LiveCell { | ||
export type Cell = CellOutput; | ||
export interface LiveCell { | ||
data: { | ||
@@ -67,7 +76,7 @@ content: Hash; | ||
} | ||
interface CellDep { | ||
export interface CellDep { | ||
out_point: OutPoint; | ||
dep_type: DepType; | ||
} | ||
interface CellIncludingOutPoint { | ||
export interface CellIncludingOutPoint { | ||
block_hash: Hash256; | ||
@@ -80,3 +89,3 @@ capacity: Capacity; | ||
} | ||
interface RawTransaction { | ||
export interface RawTransaction { | ||
version: Version; | ||
@@ -90,6 +99,6 @@ cell_deps: CellDep[]; | ||
} | ||
interface Transaction extends RawTransaction { | ||
export interface Transaction extends RawTransaction { | ||
hash: Hash256; | ||
} | ||
interface TransactionWithStatus { | ||
export interface TransactionWithStatus { | ||
transaction: Transaction; | ||
@@ -101,6 +110,9 @@ tx_status: { | ||
block_hash: undefined; | ||
status: TransactionStatus.Pending | TransactionStatus.Proposed; | ||
status: TransactionStatus.Pending | TransactionStatus.Proposed | TransactionStatus.Rejected | TransactionStatus.Unknown; | ||
reason?: string; | ||
}; | ||
time_added_to_pool: Uint64 | null; | ||
cycles: Uint64 | null; | ||
} | ||
interface TransactionPoint { | ||
export interface TransactionPoint { | ||
block_number: BlockNumber; | ||
@@ -110,8 +122,8 @@ index: Index; | ||
} | ||
interface TransactionByLockHash { | ||
export interface TransactionByLockHash { | ||
consumed_by: undefined | TransactionPoint; | ||
created_by: TransactionPoint; | ||
} | ||
type TransactionsByLockHash = TransactionByLockHash[]; | ||
interface LiveCellByLockHash { | ||
export type TransactionsByLockHash = TransactionByLockHash[]; | ||
export interface LiveCellByLockHash { | ||
cell_output: CellOutput; | ||
@@ -122,4 +134,4 @@ created_by: TransactionPoint; | ||
} | ||
type LiveCellsByLockHash = LiveCellByLockHash[]; | ||
interface Header { | ||
export type LiveCellsByLockHash = LiveCellByLockHash[]; | ||
export interface Header { | ||
compact_target: Hash; | ||
@@ -138,7 +150,7 @@ dao: DAO; | ||
} | ||
interface UncleBlock { | ||
export interface UncleBlock { | ||
header: Header; | ||
proposals: ProposalShortId[]; | ||
} | ||
interface Block { | ||
export interface Block { | ||
header: Header; | ||
@@ -150,3 +162,3 @@ uncles: UncleBlock[]; | ||
} | ||
interface AlertMessage { | ||
export interface AlertMessage { | ||
id: string; | ||
@@ -157,11 +169,7 @@ priority: string; | ||
} | ||
interface BlockchainInfo { | ||
is_initial_block_download: boolean; | ||
epoch: string; | ||
difficulty: string; | ||
median_time: string; | ||
chain: string; | ||
alerts: AlertMessage[]; | ||
} | ||
interface LocalNodeInfo { | ||
/** | ||
* @deprecated please migrate to {@link ChainInfo} | ||
*/ | ||
export type BlockchainInfo = ChainInfo; | ||
export interface LocalNodeInfo { | ||
active: boolean; | ||
@@ -178,3 +186,3 @@ addresses: Record<"address" | "score", string>[]; | ||
} | ||
interface RemoteNodeInfo { | ||
export interface RemoteNodeInfo { | ||
addresses: Record<"address" | "score", string>[]; | ||
@@ -189,3 +197,3 @@ connected_duration: string; | ||
} | ||
interface PeersState { | ||
export interface PeersState { | ||
last_updated: string; | ||
@@ -195,3 +203,3 @@ blocks_in_flight: string; | ||
} | ||
interface TxPoolInfo { | ||
export interface TxPoolInfo { | ||
last_txs_updated_at: Timestamp; | ||
@@ -207,3 +215,3 @@ min_fee_rate: string; | ||
} | ||
interface Epoch { | ||
export interface Epoch { | ||
compact_target: Hash; | ||
@@ -214,3 +222,3 @@ length: string; | ||
} | ||
interface LockHashIndexState { | ||
export interface LockHashIndexState { | ||
block_hash: Hash256; | ||
@@ -220,4 +228,4 @@ block_number: BlockNumber; | ||
} | ||
type LockHashIndexStates = LockHashIndexState[]; | ||
interface BannedAddress { | ||
export type LockHashIndexStates = LockHashIndexState[]; | ||
export interface BannedAddress { | ||
address: string; | ||
@@ -228,4 +236,4 @@ ban_reason: string; | ||
} | ||
type BannedAddresses = BannedAddress[]; | ||
interface CellbaseOutputCapacityDetails { | ||
export type BannedAddresses = BannedAddress[]; | ||
export interface CellbaseOutputCapacityDetails { | ||
primary: string; | ||
@@ -237,6 +245,6 @@ proposal_reward: string; | ||
} | ||
interface FeeRate { | ||
export interface FeeRate { | ||
fee_rate: string; | ||
} | ||
interface CapacityByLockHash { | ||
export interface CapacityByLockHash { | ||
block_number: BlockNumber; | ||
@@ -246,3 +254,3 @@ capacity: Capacity; | ||
} | ||
interface BlockEconomicState { | ||
export interface BlockEconomicState { | ||
finalized_at: string; | ||
@@ -261,3 +269,3 @@ issuance: { | ||
} | ||
interface SyncState { | ||
export interface SyncState { | ||
best_known_block_number: string; | ||
@@ -272,3 +280,3 @@ best_known_block_timestamp: string; | ||
} | ||
interface TransactionProof { | ||
export interface TransactionProof { | ||
block_hash: Hash; | ||
@@ -281,4 +289,4 @@ proof: { | ||
} | ||
type TxPoolIds = Record<"pending" | "proposed", Array<Hash256>>; | ||
interface TxVerbosity { | ||
export type TxPoolIds = Record<"pending" | "proposed", Array<Hash256>>; | ||
export interface TxVerbosity { | ||
cycles: Cycles; | ||
@@ -291,11 +299,7 @@ size: Size; | ||
} | ||
type TxPoolVerbosity = Record<"pending" | "proposed", Record<Hash256, TxVerbosity>>; | ||
type RawTxPool = TxPoolIds | TxPoolVerbosity; | ||
interface Consensus { | ||
export type TxPoolVerbosity = Record<"pending" | "proposed", Record<Hash256, TxVerbosity>>; | ||
export type RawTxPool = TxPoolIds | TxPoolVerbosity; | ||
export interface Consensus { | ||
id: string; | ||
genesis_hash: Hash256; | ||
hardfork_features: Array<{ | ||
rfc: string; | ||
epoch_number: string | undefined; | ||
}>; | ||
dao_type_hash: Hash256 | undefined; | ||
@@ -321,8 +325,40 @@ secp256k1_blake160_sighash_all_type_hash: Hash256 | undefined; | ||
permanent_difficulty_in_dummy: boolean; | ||
hardfork_features: HardForks; | ||
softforks: { | ||
[key in DeploymentPos]?: SoftFork; | ||
}; | ||
} | ||
interface Tip { | ||
export type HardForks = Array<HardforkFeature>; | ||
export interface HardforkFeature { | ||
rfc: string; | ||
epoch_number: EpochNumber | null; | ||
} | ||
export type SoftFork = Buried | Rfc0043; | ||
export interface Buried { | ||
status: SoftForkStatus; | ||
active: boolean; | ||
epoch: EpochNumber; | ||
} | ||
export interface Rfc0043 { | ||
status: SoftForkStatus; | ||
rfc0043: Deployment; | ||
} | ||
export type SoftForkStatus = "buried" | "rfc0043"; | ||
export interface Ratio { | ||
numer: Uint64; | ||
denom: Uint64; | ||
} | ||
export interface Deployment { | ||
bit: number; | ||
start: EpochNumber; | ||
timeout: EpochNumber; | ||
min_activation_epoch: EpochNumber; | ||
period: EpochNumber; | ||
threshold: Ratio; | ||
} | ||
export interface Tip { | ||
block_hash: Hash256; | ||
block_number: BlockNumber; | ||
} | ||
interface IndexerCell { | ||
export interface IndexerCell { | ||
block_number: BlockNumber; | ||
@@ -334,4 +370,4 @@ out_point: OutPoint; | ||
} | ||
type IndexerTransaction<Goruped extends boolean = false> = Goruped extends true ? GroupedIndexerTransaction : UngroupedIndexerTransaction; | ||
interface UngroupedIndexerTransaction { | ||
export type IndexerTransaction<Goruped extends boolean = false> = Goruped extends true ? GroupedIndexerTransaction : UngroupedIndexerTransaction; | ||
export interface UngroupedIndexerTransaction { | ||
tx_hash: Hash256; | ||
@@ -343,3 +379,3 @@ block_number: BlockNumber; | ||
} | ||
interface GroupedIndexerTransaction { | ||
export interface GroupedIndexerTransaction { | ||
tx_hash: Hash256; | ||
@@ -350,11 +386,11 @@ block_number: BlockNumber; | ||
} | ||
interface GetTransactionsResult<Goruped extends boolean = false> { | ||
export interface GetTransactionsResult<Goruped extends boolean = false> { | ||
last_cursor: Hash256; | ||
objects: IndexerTransaction<Goruped>[]; | ||
} | ||
interface GetLiveCellsResult { | ||
export interface GetLiveCellsResult { | ||
last_cursor: Hash256; | ||
objects: IndexerCell[]; | ||
} | ||
interface CellsCapacity { | ||
export interface CellsCapacity { | ||
capacity: Capacity; | ||
@@ -364,6 +400,6 @@ block_hash: Hash256; | ||
} | ||
type HexadecimalRange = [string, string]; | ||
type ScriptType = "type" | "lock"; | ||
type ScriptSearchMode = "prefix" | "exact"; | ||
interface SearchFilter { | ||
export type HexadecimalRange = [string, string]; | ||
export type ScriptType = "type" | "lock"; | ||
export type ScriptSearchMode = "prefix" | "exact"; | ||
export interface SearchFilter { | ||
script?: Script; | ||
@@ -375,3 +411,3 @@ output_data_len_range?: HexadecimalRange; | ||
} | ||
interface SearchKey { | ||
export interface SearchKey { | ||
script: Script; | ||
@@ -382,13 +418,13 @@ script_type: ScriptType; | ||
} | ||
interface GetCellsSearchKey extends SearchKey { | ||
export interface GetCellsSearchKey extends SearchKey { | ||
with_data?: boolean; | ||
} | ||
interface GetTransactionsSearchKey extends SearchKey { | ||
export interface GetTransactionsSearchKey extends SearchKey { | ||
group_by_transaction?: boolean; | ||
} | ||
interface BlockFilter { | ||
export interface BlockFilter { | ||
data: HexString; | ||
hash: Hash; | ||
} | ||
interface TransactionAndWitnessProof { | ||
export interface TransactionAndWitnessProof { | ||
block_hash: Hash; | ||
@@ -398,17 +434,17 @@ transactions_proof: MerkleProof; | ||
} | ||
interface FeeRateStatistics { | ||
export interface FeeRateStatistics { | ||
mean: HexNumber; | ||
median: HexNumber; | ||
} | ||
type HeaderView = Header & { | ||
export type HeaderView = Header & { | ||
hash: Hash; | ||
}; | ||
interface UncleBlockView { | ||
export interface UncleBlockView { | ||
header: HeaderView; | ||
proposals: ProposalShortId[]; | ||
} | ||
type TransactionView = Transaction & { | ||
export type TransactionView = Transaction & { | ||
hash: Hash; | ||
}; | ||
interface BlockView { | ||
export interface BlockView { | ||
header: HeaderView; | ||
@@ -418,8 +454,35 @@ uncles: UncleBlockView[]; | ||
proposals: ProposalShortId[]; | ||
extension: Hash256; | ||
} | ||
type SerializedBlock = HexString; | ||
interface EstimateCycles { | ||
export type SerializedBlock = HexString; | ||
export interface EstimateCycles { | ||
cycles: HexNumber; | ||
} | ||
export type DeploymentPos = "testdummy" | "light_client"; | ||
export type DeploymentState = "defined" | "started" | "locked_in" | "active" | "failed"; | ||
export interface DeploymentsInfo { | ||
hash: Hash256; | ||
epoch: EpochNumber; | ||
deployments: MapLike<DeploymentPos, DeploymentInfo>; | ||
} | ||
export interface DeploymentInfo { | ||
bit: number; | ||
start: EpochNumber; | ||
timeout: EpochNumber; | ||
min_activation_epoch: EpochNumber; | ||
period: EpochNumber; | ||
threshold: Ratio; | ||
since: EpochNumber; | ||
state: DeploymentState; | ||
} | ||
export interface ChainInfo { | ||
chain: string; | ||
median_time: Timestamp; | ||
epoch: EpochNumberWithFraction; | ||
difficulty: U256; | ||
is_initial_block_download: boolean; | ||
alerts: Vec<AlertMessage>; | ||
} | ||
export {}; | ||
} | ||
//# sourceMappingURL=rpc.d.ts.map |
@@ -12,5 +12,6 @@ "use strict"; | ||
let RPC; | ||
/* eslint-enable camelcase */ | ||
exports.RPC = RPC; | ||
(function (_RPC) { | ||
// this is a type to mapping the `HashMap`, `BTreeMap` in `jsonrpc-types` | ||
// there are some returns of CKB RPC are in this format, like `Softfork` | ||
let TransactionStatus = /*#__PURE__*/function (TransactionStatus) { | ||
@@ -20,6 +21,12 @@ TransactionStatus["Pending"] = "pending"; | ||
TransactionStatus["Committed"] = "committed"; | ||
TransactionStatus["Unknown"] = "unknown"; | ||
TransactionStatus["Rejected"] = "rejected"; | ||
return TransactionStatus; | ||
}({}); | ||
_RPC.TransactionStatus = TransactionStatus; | ||
/** | ||
* @deprecated please migrate to {@link ChainInfo} | ||
*/ | ||
/* https://github.com/nervosnetwork/ckb/blob/develop/util/jsonrpc-types/src/info.rs */ | ||
})(RPC || (exports.RPC = RPC = {})); | ||
//# sourceMappingURL=rpc.js.map |
{ | ||
"name": "@ckb-lumos/rpc", | ||
"version": "0.0.0-canary-ed5dc56-20230901063035", | ||
"version": "0.0.0-canary-ed7c2fa-20240511022143", | ||
"description": "RPC module for CKB", | ||
@@ -29,7 +29,6 @@ "homepage": "https://github.com/ckb-js/lumos#readme", | ||
"dependencies": { | ||
"@ckb-lumos/base": "0.0.0-canary-ed5dc56-20230901063035", | ||
"@ckb-lumos/bi": "0.0.0-canary-ed5dc56-20230901063035", | ||
"@vespaiach/axios-fetch-adapter": "^0.3.1", | ||
"axios": "0.27.2", | ||
"tslib": "2.3.1" | ||
"@ckb-lumos/base": "0.0.0-canary-ed7c2fa-20240511022143", | ||
"@ckb-lumos/bi": "0.0.0-canary-ed7c2fa-20240511022143", | ||
"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
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
344984
4
3489
78
2
+ Addedabort-controller@^3.0.0
+ Addedcross-fetch@^3.1.5
+ Added@ckb-lumos/base@0.0.0-canary-ed7c2fa-20240511022143(transitive)
+ Added@ckb-lumos/bi@0.0.0-canary-ed7c2fa-20240511022143(transitive)
+ Added@ckb-lumos/codec@0.0.0-canary-ed7c2fa-20240511022143(transitive)
+ Added@ckb-lumos/toolkit@0.0.0-canary-ed7c2fa-20240511022143(transitive)
+ Addedabort-controller@3.0.0(transitive)
+ Addedevent-target-shim@5.0.1(transitive)
- Removedaxios@0.27.2
- Removedtslib@2.3.1
- Removed@ckb-lumos/base@0.0.0-canary-ed5dc56-20230901063035(transitive)
- Removed@ckb-lumos/bi@0.0.0-canary-ed5dc56-20230901063035(transitive)
- Removed@ckb-lumos/codec@0.0.0-canary-ed5dc56-20230901063035(transitive)
- Removed@ckb-lumos/toolkit@0.0.0-canary-ed5dc56-20230901063035(transitive)
- Removed@vespaiach/axios-fetch-adapter@0.3.1(transitive)
- Removedasynckit@0.4.0(transitive)
- Removedaxios@0.27.2(transitive)
- Removedcall-bind-apply-helpers@1.0.2(transitive)
- Removedcombined-stream@1.0.8(transitive)
- Removeddelayed-stream@1.0.0(transitive)
- Removeddunder-proto@1.0.1(transitive)
- Removedes-define-property@1.0.1(transitive)
- Removedes-errors@1.3.0(transitive)
- Removedes-object-atoms@1.1.1(transitive)
- Removedes-set-tostringtag@2.1.0(transitive)
- Removedfollow-redirects@1.15.9(transitive)
- Removedform-data@4.0.2(transitive)
- Removedfunction-bind@1.1.2(transitive)
- Removedget-intrinsic@1.3.0(transitive)
- Removedget-proto@1.0.1(transitive)
- Removedgopd@1.2.0(transitive)
- Removedhas-symbols@1.1.0(transitive)
- Removedhas-tostringtag@1.0.2(transitive)
- Removedhasown@2.0.2(transitive)
- Removedmath-intrinsics@1.1.0(transitive)
- Removedmime-db@1.52.0(transitive)
- Removedmime-types@2.1.35(transitive)
- Removedtslib@2.3.1(transitive)