@ckb-lumos/base
Advanced tools
Comparing version 0.0.0-canary-93ff1b4-20231109020124 to 0.0.0-canary-9461dd6-20231220080242
@@ -1,2 +0,2 @@ | ||
import { Hash, HexNumber, HexString, PackedSince } from "./primitive"; | ||
import { Hash, Hexadecimal, HexNumber, HexString, PackedSince } from "./primitive"; | ||
export interface Header { | ||
@@ -16,3 +16,3 @@ timestamp: HexNumber; | ||
} | ||
export type HashType = "type" | "data" | "data1"; | ||
export type HashType = "type" | "data" | "data1" | "data2"; | ||
export interface Script { | ||
@@ -65,9 +65,13 @@ codeHash: Hash; | ||
} | ||
type Status = "pending" | "proposed" | "committed" | "unknown" | "rejected"; | ||
export interface TxStatus { | ||
status: Status; | ||
blockHash?: Hash; | ||
status: string; | ||
reason?: string; | ||
} | ||
export interface TransactionWithStatus { | ||
transaction: Transaction; | ||
export interface TransactionWithStatus<Tx = Transaction> { | ||
transaction: Tx; | ||
txStatus: TxStatus; | ||
timeAddedToPool: Uint64 | null; | ||
cycles: Uint64 | null; | ||
} | ||
@@ -147,6 +151,2 @@ export interface Cell { | ||
genesisHash: Hash; | ||
hardforkFeatures: Array<{ | ||
rfc: string; | ||
epochNumber: string | undefined; | ||
}>; | ||
daoTypeHash?: Hash; | ||
@@ -172,3 +172,33 @@ secp256k1Blake160SighashAllTypeHash?: Hash; | ||
permanentDifficultyInDummy: boolean; | ||
hardforkFeatures: HardForks; | ||
softforks: MapLike<DeploymentPos, SoftFork>; | ||
} | ||
export type HardForks = HardforkFeature[]; | ||
export interface HardforkFeature { | ||
rfc: string; | ||
epochNumber: EpochNumber | null; | ||
} | ||
export type SoftForkStatus = "buried" | "rfc0043"; | ||
export type SoftFork = Buried | Rfc0043; | ||
export type Buried = { | ||
status: SoftForkStatus; | ||
active: boolean; | ||
epoch: EpochNumber; | ||
}; | ||
export type Rfc0043 = { | ||
status: SoftForkStatus; | ||
rfc0043: Deployment; | ||
}; | ||
export type Ratio = { | ||
numer: Uint64; | ||
denom: Uint64; | ||
}; | ||
export type Deployment = { | ||
bit: number; | ||
start: EpochNumber; | ||
timeout: EpochNumber; | ||
minActivationEpoch: EpochNumber; | ||
period: EpochNumber; | ||
threshold: Ratio; | ||
}; | ||
export interface DryRunResult { | ||
@@ -265,2 +295,3 @@ cycles: HexNumber; | ||
export type RawTxPool = TxPoolIds | TxPoolVerbosity; | ||
/** https://github.com/nervosnetwork/ckb/blob/develop/util/jsonrpc-types/src/alert.rs **/ | ||
export interface AlertMessage { | ||
@@ -272,10 +303,2 @@ id: HexNumber; | ||
} | ||
export interface ChainInfo { | ||
chain: string; | ||
medianTime: HexNumber; | ||
epoch: HexNumber; | ||
difficulty: HexNumber; | ||
isInitialBlockDownload: boolean; | ||
alerts: AlertMessage[]; | ||
} | ||
export interface Alert { | ||
@@ -291,2 +314,35 @@ id: HexNumber; | ||
} | ||
/** https://github.com/nervosnetwork/ckb/blob/develop/util/jsonrpc-types/src/info.rs **/ | ||
export type DeploymentPos = "testdummy" | "lightClient"; | ||
export type DeploymentState = "defined" | "started" | "lockedIn" | "active" | "failed"; | ||
export type DeploymentsInfo = { | ||
hash: Hash; | ||
epoch: EpochNumber; | ||
deployments: MapLike<DeploymentPos, DeploymentInfo>; | ||
}; | ||
export type DeploymentInfo = { | ||
bit: number; | ||
start: EpochNumber; | ||
timeout: EpochNumber; | ||
minActivationEpoch: EpochNumber; | ||
period: EpochNumber; | ||
threshold: Ratio; | ||
since: EpochNumber; | ||
state: DeploymentState; | ||
}; | ||
export interface ChainInfo { | ||
chain: string; | ||
medianTime: HexNumber; | ||
epoch: EpochNumberWithFraction; | ||
difficulty: HexNumber; | ||
isInitialBlockDownload: boolean; | ||
alerts: AlertMessage[]; | ||
} | ||
type Uint64 = Hexadecimal; | ||
type EpochNumber = Hexadecimal; | ||
type EpochNumberWithFraction = Uint64; | ||
type MapLike<K extends string, V> = { | ||
[key in K]?: V; | ||
}; | ||
export {}; | ||
//# sourceMappingURL=api.d.ts.map |
@@ -23,2 +23,3 @@ import { AnyCodec, BytesLike, PackParam, UnpackResult } from "@ckb-lumos/codec"; | ||
export declare const BytesVec: import("@ckb-lumos/codec/lib/molecule/layout").ArrayCodec<BytesCodec<string, BytesLike>>; | ||
export declare const BytesOptVec: import("@ckb-lumos/codec/lib/molecule/layout").ArrayCodec<import("@ckb-lumos/codec/lib/molecule/layout").OptionCodec<BytesCodec<string, BytesLike>>>; | ||
export declare const Byte32: FixedBytesCodec<string, BytesLike>; | ||
@@ -57,2 +58,12 @@ export declare const Byte32Vec: import("@ckb-lumos/codec/lib/molecule/layout").ArrayCodec<FixedBytesCodec<string, BytesLike>>; | ||
/** | ||
* <pre> | ||
* 0b0000000 0 | ||
* ───┬─── │ | ||
* │ ▼ | ||
* │ type - use the default vm version | ||
* │ | ||
* ▼ | ||
* data* - use a particular vm version | ||
* </pre> | ||
* | ||
* Implementation of blockchain.mol | ||
@@ -59,0 +70,0 @@ * https://github.com/nervosnetwork/ckb/blob/5a7efe7a0b720de79ff3761dc6e8424b8d5b22ea/util/types/schemas/blockchain.mol |
@@ -6,3 +6,3 @@ "use strict"; | ||
}); | ||
exports.WitnessArgs = exports.UncleBlockVec = exports.UncleBlock = exports.TransactionVec = exports.Transaction = exports.ScriptOpt = exports.Script = exports.RawTransaction = exports.RawHeader = exports.ProposalShortIdVec = exports.ProposalShortId = exports.OutPoint = exports.Header = exports.HashType = exports.DepType = exports.CellbaseWitness = exports.CellOutputVec = exports.CellOutput = exports.CellInputVec = exports.CellInput = exports.CellDepVec = exports.CellDep = exports.BytesVec = exports.BytesOpt = exports.Bytes = exports.Byte32Vec = exports.Byte32 = exports.BlockV1 = exports.Block = exports.BaseHeader = void 0; | ||
exports.WitnessArgs = exports.UncleBlockVec = exports.UncleBlock = exports.TransactionVec = exports.Transaction = exports.ScriptOpt = exports.Script = exports.RawTransaction = exports.RawHeader = exports.ProposalShortIdVec = exports.ProposalShortId = exports.OutPoint = exports.Header = exports.HashType = exports.DepType = exports.CellbaseWitness = exports.CellOutputVec = exports.CellOutput = exports.CellInputVec = exports.CellInput = exports.CellDepVec = exports.CellDep = exports.BytesVec = exports.BytesOptVec = exports.BytesOpt = exports.Bytes = exports.Byte32Vec = exports.Byte32 = exports.BlockV1 = exports.Block = exports.BaseHeader = void 0; | ||
exports.WitnessArgsOf = WitnessArgsOf; | ||
@@ -60,2 +60,4 @@ exports.createFixedHexBytesCodec = createFixedHexBytesCodec; | ||
exports.BytesVec = BytesVec; | ||
const BytesOptVec = vector(BytesOpt); | ||
exports.BytesOptVec = BytesOptVec; | ||
const Byte32 = createFixedHexBytesCodec(32); | ||
@@ -92,2 +94,12 @@ exports.Byte32 = Byte32; | ||
/** | ||
* <pre> | ||
* 0b0000000 0 | ||
* ───┬─── │ | ||
* │ ▼ | ||
* │ type - use the default vm version | ||
* │ | ||
* ▼ | ||
* data* - use a particular vm version | ||
* </pre> | ||
* | ||
* Implementation of blockchain.mol | ||
@@ -100,5 +112,8 @@ * https://github.com/nervosnetwork/ckb/blob/5a7efe7a0b720de79ff3761dc6e8424b8d5b22ea/util/types/schemas/blockchain.mol | ||
pack: type => { | ||
if (type === "data") return Uint8.pack(0); | ||
if (type === "type") return Uint8.pack(1); | ||
if (type === "data1") return Uint8.pack(2); | ||
// prettier-ignore | ||
if (type === "type") return Uint8.pack(0b0000000_1); | ||
// prettier-ignore | ||
if (type === "data") return Uint8.pack(0b0000000_0); | ||
if (type === "data1") return Uint8.pack(0b0000001_0); | ||
if (type === "data2") return Uint8.pack(0b0000010_0); | ||
throw new Error(`Invalid hash type: ${type}`); | ||
@@ -108,5 +123,6 @@ }, | ||
const hashTypeBuf = Uint8.unpack(buf); | ||
if (hashTypeBuf === 0) return "data"; | ||
if (hashTypeBuf === 1) return "type"; | ||
if (hashTypeBuf === 2) return "data1"; | ||
if (hashTypeBuf === 0b0000000_1) return "type"; | ||
if (hashTypeBuf === 0b0000000_0) return "data"; | ||
if (hashTypeBuf === 0b0000001_0) return "data1"; | ||
if (hashTypeBuf === 0b0000010_0) return "data2"; | ||
throw new Error(`Invalid hash type: ${hashTypeBuf}`); | ||
@@ -113,0 +129,0 @@ } |
@@ -65,2 +65,7 @@ /// <reference types="node" /> | ||
declare function isDeepEqual(a: any, b: any): boolean; | ||
/** | ||
* Generate a type script for type id {@link https://xuejie.space/2020_02_03_introduction_to_ckb_script_programming_type_id/} | ||
* @param input | ||
* @param outputIndex | ||
*/ | ||
declare function generateTypeIdScript(input: Input, outputIndex?: string): Script; | ||
@@ -67,0 +72,0 @@ declare function deepCamel(data: any): any; |
@@ -187,2 +187,8 @@ "use strict"; | ||
} | ||
/** | ||
* Generate a type script for type id {@link https://xuejie.space/2020_02_03_introduction_to_ckb_script_programming_type_id/} | ||
* @param input | ||
* @param outputIndex | ||
*/ | ||
function generateTypeIdScript(input, outputIndex = "0x0") { | ||
@@ -189,0 +195,0 @@ blockchain.CellInput.pack(input); |
{ | ||
"name": "@ckb-lumos/base", | ||
"version": "0.0.0-canary-93ff1b4-20231109020124", | ||
"version": "0.0.0-canary-9461dd6-20231220080242", | ||
"description": "Base data structures and utilities used in lumos", | ||
@@ -38,5 +38,5 @@ "author": "Xuejie Xiao <xxuejie@gmail.com>", | ||
"dependencies": { | ||
"@ckb-lumos/bi": "0.0.0-canary-93ff1b4-20231109020124", | ||
"@ckb-lumos/codec": "0.0.0-canary-93ff1b4-20231109020124", | ||
"@ckb-lumos/toolkit": "0.0.0-canary-93ff1b4-20231109020124", | ||
"@ckb-lumos/bi": "0.0.0-canary-9461dd6-20231220080242", | ||
"@ckb-lumos/codec": "0.0.0-canary-9461dd6-20231220080242", | ||
"@ckb-lumos/toolkit": "0.0.0-canary-9461dd6-20231220080242", | ||
"@types/blake2b": "^2.1.0", | ||
@@ -43,0 +43,0 @@ "@types/lodash.isequal": "^4.5.5", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
229941
3091
+ Added@ckb-lumos/bi@0.0.0-canary-9461dd6-20231220080242(transitive)
+ Added@ckb-lumos/codec@0.0.0-canary-9461dd6-20231220080242(transitive)
+ Added@ckb-lumos/toolkit@0.0.0-canary-9461dd6-20231220080242(transitive)
- Removed@ckb-lumos/bi@0.0.0-canary-93ff1b4-20231109020124(transitive)
- Removed@ckb-lumos/codec@0.0.0-canary-93ff1b4-20231109020124(transitive)
- Removed@ckb-lumos/toolkit@0.0.0-canary-93ff1b4-20231109020124(transitive)
Updated@ckb-lumos/toolkit@0.0.0-canary-9461dd6-20231220080242