@ckb-lumos/base
Advanced tools
Comparing version 0.0.0-canary-f2fbef5-20240311091511 to 0.0.0-canary-f3acc1f-20240606024131
@@ -75,2 +75,4 @@ import { Hash, Hexadecimal, HexNumber, HexString, PackedSince } from "./primitive"; | ||
cycles: Uint64 | null; | ||
fee: Uint64 | null; | ||
minReplaceFee: Uint64 | null; | ||
} | ||
@@ -270,2 +272,5 @@ export interface Cell { | ||
lastTxsUpdatedAt: HexNumber; | ||
minRbfRate: HexNumber; | ||
maxTxPoolSize: HexNumber; | ||
txSizeLimit: HexNumber; | ||
} | ||
@@ -272,0 +277,0 @@ export interface TxPoolIds { |
@@ -55,17 +55,11 @@ "use strict"; | ||
// vector Bytes <byte> | ||
const Bytes = byteVecOf({ | ||
const Bytes = exports.Bytes = byteVecOf({ | ||
pack: bytify, | ||
unpack: hexify | ||
}); | ||
exports.Bytes = Bytes; | ||
const BytesOpt = option(Bytes); | ||
exports.BytesOpt = BytesOpt; | ||
const BytesVec = vector(Bytes); | ||
exports.BytesVec = BytesVec; | ||
const BytesOptVec = vector(BytesOpt); | ||
exports.BytesOptVec = BytesOptVec; | ||
const Byte32 = createFixedHexBytesCodec(32); | ||
exports.Byte32 = Byte32; | ||
const Byte32Vec = vector(Byte32); | ||
exports.Byte32Vec = Byte32Vec; | ||
const BytesOpt = exports.BytesOpt = option(Bytes); | ||
const BytesVec = exports.BytesVec = vector(Bytes); | ||
const BytesOptVec = exports.BytesOptVec = vector(BytesOpt); | ||
const Byte32 = exports.Byte32 = createFixedHexBytesCodec(32); | ||
const Byte32Vec = exports.Byte32Vec = vector(Byte32); | ||
function WitnessArgsOf(payload) { | ||
@@ -91,3 +85,3 @@ return table({ | ||
*/ | ||
const WitnessArgs = WitnessArgsOf({ | ||
const WitnessArgs = exports.WitnessArgs = WitnessArgsOf({ | ||
lock: HexifyCodec, | ||
@@ -112,4 +106,3 @@ inputType: HexifyCodec, | ||
*/ | ||
exports.WitnessArgs = WitnessArgs; | ||
const HashType = (0, _codec.createFixedBytesCodec)({ | ||
const HashType = exports.HashType = (0, _codec.createFixedBytesCodec)({ | ||
byteLength: 1, | ||
@@ -134,4 +127,3 @@ pack: type => { | ||
}); | ||
exports.HashType = HashType; | ||
const DepType = (0, _codec.createFixedBytesCodec)({ | ||
const DepType = exports.DepType = (0, _codec.createFixedBytesCodec)({ | ||
byteLength: 1, | ||
@@ -150,4 +142,3 @@ pack: type => { | ||
}); | ||
exports.DepType = DepType; | ||
const Script = table({ | ||
const Script = exports.Script = table({ | ||
codeHash: Byte32, | ||
@@ -157,18 +148,13 @@ hashType: HashType, | ||
}, ["codeHash", "hashType", "args"]); | ||
exports.Script = Script; | ||
const ScriptOpt = option(Script); | ||
exports.ScriptOpt = ScriptOpt; | ||
const OutPoint = struct({ | ||
const ScriptOpt = exports.ScriptOpt = option(Script); | ||
const OutPoint = exports.OutPoint = struct({ | ||
txHash: Byte32, | ||
index: Uint32LE | ||
}, ["txHash", "index"]); | ||
exports.OutPoint = OutPoint; | ||
const CellInput = struct({ | ||
const CellInput = exports.CellInput = struct({ | ||
since: Uint64LE, | ||
previousOutput: OutPoint | ||
}, ["since", "previousOutput"]); | ||
exports.CellInput = CellInput; | ||
const CellInputVec = vector(CellInput); | ||
exports.CellInputVec = CellInputVec; | ||
const CellOutput = table({ | ||
const CellInputVec = exports.CellInputVec = vector(CellInput); | ||
const CellOutput = exports.CellOutput = table({ | ||
capacity: Uint64LE, | ||
@@ -178,13 +164,9 @@ lock: Script, | ||
}, ["capacity", "lock", "type"]); | ||
exports.CellOutput = CellOutput; | ||
const CellOutputVec = vector(CellOutput); | ||
exports.CellOutputVec = CellOutputVec; | ||
const CellDep = struct({ | ||
const CellOutputVec = exports.CellOutputVec = vector(CellOutput); | ||
const CellDep = exports.CellDep = struct({ | ||
outPoint: OutPoint, | ||
depType: DepType | ||
}, ["outPoint", "depType"]); | ||
exports.CellDep = CellDep; | ||
const CellDepVec = vector(CellDep); | ||
exports.CellDepVec = CellDepVec; | ||
const RawTransaction = table({ | ||
const CellDepVec = exports.CellDepVec = vector(CellDep); | ||
const RawTransaction = exports.RawTransaction = table({ | ||
version: Uint32LE, | ||
@@ -197,3 +179,2 @@ cellDeps: CellDepVec, | ||
}, ["version", "cellDeps", "headerDeps", "inputs", "outputs", "outputsData"]); | ||
exports.RawTransaction = RawTransaction; | ||
const BaseTransaction = table({ | ||
@@ -203,10 +184,8 @@ raw: RawTransaction, | ||
}, ["raw", "witnesses"]); | ||
const Transaction = (0, _codec.createBytesCodec)({ | ||
const Transaction = exports.Transaction = (0, _codec.createBytesCodec)({ | ||
pack: tx => BaseTransaction.pack(transformTransactionCodecType(tx)), | ||
unpack: buf => deTransformTransactionCodecType(BaseTransaction.unpack(buf)) | ||
}); | ||
exports.Transaction = Transaction; | ||
const TransactionVec = vector(Transaction); | ||
exports.TransactionVec = TransactionVec; | ||
const RawHeader = struct({ | ||
const TransactionVec = exports.TransactionVec = vector(Transaction); | ||
const RawHeader = exports.RawHeader = struct({ | ||
version: Uint32LE, | ||
@@ -223,25 +202,18 @@ compactTarget: Uint32LE, | ||
}, ["version", "compactTarget", "timestamp", "number", "epoch", "parentHash", "transactionsRoot", "proposalsHash", "extraHash", "dao"]); | ||
exports.RawHeader = RawHeader; | ||
const BaseHeader = struct({ | ||
const BaseHeader = exports.BaseHeader = struct({ | ||
raw: RawHeader, | ||
nonce: Uint128LE | ||
}, ["raw", "nonce"]); | ||
exports.BaseHeader = BaseHeader; | ||
const Header = (0, _codec.createBytesCodec)({ | ||
const Header = exports.Header = (0, _codec.createBytesCodec)({ | ||
pack: header => BaseHeader.pack(transformHeaderCodecType(header)), | ||
unpack: buf => deTransformHeaderCodecType(BaseHeader.unpack(buf)) | ||
}); | ||
exports.Header = Header; | ||
const ProposalShortId = createFixedHexBytesCodec(10); | ||
exports.ProposalShortId = ProposalShortId; | ||
const ProposalShortIdVec = vector(ProposalShortId); | ||
exports.ProposalShortIdVec = ProposalShortIdVec; | ||
const UncleBlock = table({ | ||
const ProposalShortId = exports.ProposalShortId = createFixedHexBytesCodec(10); | ||
const ProposalShortIdVec = exports.ProposalShortIdVec = vector(ProposalShortId); | ||
const UncleBlock = exports.UncleBlock = table({ | ||
header: Header, | ||
proposals: ProposalShortIdVec | ||
}, ["header", "proposals"]); | ||
exports.UncleBlock = UncleBlock; | ||
const UncleBlockVec = vector(UncleBlock); | ||
exports.UncleBlockVec = UncleBlockVec; | ||
const Block = table({ | ||
const UncleBlockVec = exports.UncleBlockVec = vector(UncleBlock); | ||
const Block = exports.Block = table({ | ||
header: Header, | ||
@@ -252,4 +224,3 @@ uncles: UncleBlockVec, | ||
}, ["header", "uncles", "transactions", "proposals"]); | ||
exports.Block = Block; | ||
const BlockV1 = table({ | ||
const BlockV1 = exports.BlockV1 = table({ | ||
header: Header, | ||
@@ -261,4 +232,3 @@ uncles: UncleBlockVec, | ||
}, ["header", "uncles", "transactions", "proposals", "extension"]); | ||
exports.BlockV1 = BlockV1; | ||
const CellbaseWitness = table({ | ||
const CellbaseWitness = exports.CellbaseWitness = table({ | ||
lock: Script, | ||
@@ -298,3 +268,2 @@ message: Bytes | ||
*/ | ||
exports.CellbaseWitness = CellbaseWitness; | ||
function transformTransactionCodecType(data) { | ||
@@ -301,0 +270,0 @@ return { |
@@ -65,4 +65,4 @@ "use strict"; | ||
}); | ||
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); } | ||
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; } | ||
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); } | ||
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; } | ||
//# sourceMappingURL=index.js.map |
@@ -132,4 +132,3 @@ "use strict"; | ||
}; | ||
var _default = indexer; | ||
exports.default = _default; | ||
var _default = exports.default = indexer; | ||
//# sourceMappingURL=indexer.js.map |
@@ -17,4 +17,13 @@ /// <reference types="node" /> | ||
} | ||
/** | ||
* create a 32-bytes Blake2b hash with the CKB personalization | ||
* @param data | ||
*/ | ||
declare function ckbHash(data: BytesLike): Hash; | ||
/** | ||
* create a 20-bytes Blake2b hash with the CKB personalization | ||
* @param data | ||
*/ | ||
declare function ckbHash160(data: BytesLike): Hash; | ||
/** | ||
* compute lock/type hash | ||
@@ -74,3 +83,3 @@ * | ||
declare function deepCamelizeTransaction(data: any): any; | ||
export { CKBHasher, ckbHash, deepCamel, deepCamelizeTransaction, toBigUInt64LE, toBigUInt64LECompatible, readBigUInt64LE, readBigUInt64LECompatible, toBigUInt128LE, toBigUInt128LECompatible, readBigUInt128LE, readBigUInt128LECompatible, computeScriptHash, hashCode, assertHexString, assertHexadecimal, isDeepEqual, generateTypeIdScript, }; | ||
export { CKBHasher, ckbHash, ckbHash160, deepCamel, deepCamelizeTransaction, toBigUInt64LE, toBigUInt64LECompatible, readBigUInt64LE, readBigUInt64LECompatible, toBigUInt128LE, toBigUInt128LECompatible, readBigUInt128LE, readBigUInt128LECompatible, computeScriptHash, hashCode, assertHexString, assertHexadecimal, isDeepEqual, generateTypeIdScript, }; | ||
//# sourceMappingURL=utils.d.ts.map |
@@ -10,2 +10,3 @@ "use strict"; | ||
exports.ckbHash = ckbHash; | ||
exports.ckbHash160 = ckbHash160; | ||
exports.computeScriptHash = computeScriptHash; | ||
@@ -29,6 +30,6 @@ exports.deepCamel = deepCamel; | ||
var _codec = require("@ckb-lumos/codec"); | ||
var _bi = require("@ckb-lumos/bi"); | ||
var blockchain = _interopRequireWildcard(require("./blockchain")); | ||
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); } | ||
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; } | ||
var _number = require("@ckb-lumos/codec/lib/number"); | ||
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); } | ||
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; } | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
@@ -58,2 +59,7 @@ const { | ||
} | ||
/** | ||
* create a 32-bytes Blake2b hash with the CKB personalization | ||
* @param data | ||
*/ | ||
exports.CKBHasher = CKBHasher; | ||
@@ -67,2 +73,13 @@ function ckbHash(data) { | ||
/** | ||
* create a 20-bytes Blake2b hash with the CKB personalization | ||
* @param data | ||
*/ | ||
function ckbHash160(data) { | ||
// 2 for prefix 0x | ||
// 40 for 20-bytes hex string | ||
const hash160HexLength = 42; | ||
return ckbHash(data).slice(0, hash160HexLength); | ||
} | ||
/** | ||
* compute lock/type hash | ||
@@ -88,8 +105,3 @@ * | ||
function toBigUInt64LECompatible(num) { | ||
num = _bi.BI.from(num); | ||
const buf = Buffer.alloc(8); | ||
buf.writeUInt32LE(num.and("0xffffffff").toNumber(), 0); | ||
num = num.shr(32); | ||
buf.writeUInt32LE(num.and("0xffffffff").toNumber(), 4); | ||
return `0x${buf.toString("hex")}`; | ||
return _codec.bytes.hexify(_number.Uint64LE.pack(num)); | ||
} | ||
@@ -111,4 +123,3 @@ | ||
function readBigUInt64LECompatible(hex) { | ||
const buf = Buffer.from(hex.slice(2), "hex"); | ||
return _bi.BI.from(buf.readUInt32LE()).add(_bi.BI.from(buf.readUInt32LE(4)).shl(32)); | ||
return _number.Uint64LE.unpack(hex); | ||
} | ||
@@ -127,21 +138,4 @@ | ||
} | ||
const U128_MIN_COMPATIBLE = _bi.BI.from(0); | ||
const U128_MAX_COMPATIBLE = _bi.BI.from("340282366920938463463374607431768211455"); | ||
function toBigUInt128LECompatible(num) { | ||
num = _bi.BI.from(num); | ||
if (num.lt(U128_MIN_COMPATIBLE)) { | ||
throw new Error(`u128 ${num} too small`); | ||
} | ||
if (num.gt(U128_MAX_COMPATIBLE)) { | ||
throw new Error(`u128 ${num} too large`); | ||
} | ||
const buf = Buffer.alloc(16); | ||
buf.writeUInt32LE(num.and(0xffffffff).toNumber(), 0); | ||
num = num.shr(32); | ||
buf.writeUInt32LE(num.and(0xffffffff).toNumber(), 4); | ||
num = num.shr(32); | ||
buf.writeUInt32LE(num.and(0xffffffff).toNumber(), 8); | ||
num = num.shr(32); | ||
buf.writeUInt32LE(num.and(0xffffffff).toNumber(), 12); | ||
return `0x${buf.toString("hex")}`; | ||
return _codec.bytes.hexify(_number.Uint128LE.pack(num)); | ||
} | ||
@@ -163,7 +157,3 @@ | ||
function readBigUInt128LECompatible(leHex) { | ||
if (leHex.length < 34 || !leHex.startsWith("0x")) { | ||
throw new Error(`leHex format error`); | ||
} | ||
const buf = Buffer.from(leHex.slice(2, 34), "hex"); | ||
return _bi.BI.from(buf.readUInt32LE(0)).shl(0).add(_bi.BI.from(buf.readUInt32LE(4)).shl(32)).add(_bi.BI.from(buf.readUInt32LE(8)).shl(64)).add(_bi.BI.from(buf.readUInt32LE(12)).shl(96)); | ||
return _number.Uint128LE.unpack(leHex); | ||
} | ||
@@ -170,0 +160,0 @@ function assertHexString(debugPath, str) { |
@@ -11,4 +11,4 @@ "use strict"; | ||
var blockchain = _interopRequireWildcard(require("./blockchain")); | ||
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); } | ||
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; } | ||
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); } | ||
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; } | ||
// This module provides a ValueObject implementation for CKB related data | ||
@@ -15,0 +15,0 @@ // structures to allow seamless immutable.js integration. |
{ | ||
"name": "@ckb-lumos/base", | ||
"version": "0.0.0-canary-f2fbef5-20240311091511", | ||
"version": "0.0.0-canary-f3acc1f-20240606024131", | ||
"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-f2fbef5-20240311091511", | ||
"@ckb-lumos/codec": "0.0.0-canary-f2fbef5-20240311091511", | ||
"@ckb-lumos/toolkit": "0.0.0-canary-f2fbef5-20240311091511", | ||
"@ckb-lumos/bi": "0.0.0-canary-f3acc1f-20240606024131", | ||
"@ckb-lumos/codec": "0.0.0-canary-f3acc1f-20240606024131", | ||
"@ckb-lumos/toolkit": "0.0.0-canary-f3acc1f-20240606024131", | ||
"@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
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
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
223762
3059
+ Added@ckb-lumos/bi@0.0.0-canary-f3acc1f-20240606024131(transitive)
+ Added@ckb-lumos/codec@0.0.0-canary-f3acc1f-20240606024131(transitive)
+ Added@ckb-lumos/toolkit@0.0.0-canary-f3acc1f-20240606024131(transitive)
- Removed@ckb-lumos/bi@0.0.0-canary-f2fbef5-20240311091511(transitive)
- Removed@ckb-lumos/codec@0.0.0-canary-f2fbef5-20240311091511(transitive)
- Removed@ckb-lumos/toolkit@0.0.0-canary-f2fbef5-20240311091511(transitive)
Updated@ckb-lumos/toolkit@0.0.0-canary-f3acc1f-20240606024131