@ckb-lumos/codec
Advanced tools
Comparing version 0.0.0-canary-f2fbef5-20240311091511 to 0.0.0-canary-f3acc1f-20240606024131
@@ -31,15 +31,10 @@ "use strict"; | ||
// vector Bytes <byte> | ||
const Bytes = (0, _molecule.byteVecOf)({ | ||
const Bytes = exports.Bytes = (0, _molecule.byteVecOf)({ | ||
pack: _bytes.bytify, | ||
unpack: _bytes.hexify | ||
}); | ||
exports.Bytes = Bytes; | ||
const BytesOpt = (0, _molecule.option)(Bytes); | ||
exports.BytesOpt = BytesOpt; | ||
const BytesVec = (0, _molecule.vector)(Bytes); | ||
exports.BytesVec = BytesVec; | ||
const Byte32 = createFixedHexBytesCodec(32); | ||
exports.Byte32 = Byte32; | ||
const Byte32Vec = (0, _molecule.vector)(Byte32); | ||
exports.Byte32Vec = Byte32Vec; | ||
const BytesOpt = exports.BytesOpt = (0, _molecule.option)(Bytes); | ||
const BytesVec = exports.BytesVec = (0, _molecule.vector)(Bytes); | ||
const Byte32 = exports.Byte32 = createFixedHexBytesCodec(32); | ||
const Byte32Vec = exports.Byte32Vec = (0, _molecule.vector)(Byte32); | ||
function WitnessArgsOf(payload) { | ||
@@ -65,3 +60,3 @@ return (0, _molecule.table)({ | ||
*/ | ||
const WitnessArgs = WitnessArgsOf({ | ||
const WitnessArgs = exports.WitnessArgs = WitnessArgsOf({ | ||
lock: HexifyCodec, | ||
@@ -71,3 +66,2 @@ input_type: HexifyCodec, | ||
}); | ||
exports.WitnessArgs = WitnessArgs; | ||
//# sourceMappingURL=blockchain.js.map |
@@ -8,8 +8,4 @@ "use strict"; | ||
exports.isCodecExecuteError = isCodecExecuteError; | ||
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 _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); } | ||
function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); } | ||
// lc for lumos codec | ||
const CODEC_OPTIONAL_PATH = "__lc_option__"; | ||
exports.CODEC_OPTIONAL_PATH = CODEC_OPTIONAL_PATH; | ||
const CODEC_OPTIONAL_PATH = exports.CODEC_OPTIONAL_PATH = "__lc_option__"; | ||
class CodecBaseParseError extends Error { | ||
@@ -32,8 +28,8 @@ constructor(message, expectedType) { | ||
class CodecExecuteError extends Error { | ||
name = CODEC_EXECUTE_ERROR_NAME; | ||
constructor(origin) { | ||
super(); | ||
_defineProperty(this, "name", CODEC_EXECUTE_ERROR_NAME); | ||
_defineProperty(this, "keys", []); | ||
this.origin = origin; | ||
} | ||
keys = []; | ||
updateKey(key) { | ||
@@ -56,3 +52,5 @@ this.keys.push(key); | ||
const path = this.keys.reduceRight(reducer, "input"); | ||
return `Expect type ${this.origin.expectedType} at ${path} but got error: ${this.origin.message} | ||
const text = this.origin instanceof CodecBaseParseError ? `Expect type ${this.origin.expectedType} at ${path} but got error:` : `Error at ${path}:`; // this.origin can be an Error at runtime | ||
return `${text} ${this.origin.message} | ||
${(_this$origin$stack = this.origin.stack) === null || _this$origin$stack === void 0 ? void 0 : _this$origin$stack.replace(/Error:.+?\n/, "")} | ||
@@ -59,0 +57,0 @@ `; |
@@ -53,4 +53,4 @@ "use strict"; | ||
exports.molecule = _molecule; | ||
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 |
@@ -77,58 +77,39 @@ "use strict"; | ||
}; | ||
const Uint8 = createUintNumberCodec(1); | ||
exports.Uint8 = Uint8; | ||
const Uint16LE = createUintNumberCodec(2, true); | ||
exports.Uint16LE = Uint16LE; | ||
const Uint16BE = createUintNumberCodec(2); | ||
const Uint8 = exports.Uint8 = createUintNumberCodec(1); | ||
const Uint16LE = exports.Uint16LE = createUintNumberCodec(2, true); | ||
const Uint16BE = exports.Uint16BE = createUintNumberCodec(2); | ||
/** | ||
* @alias Uint16LE | ||
*/ | ||
exports.Uint16BE = Uint16BE; | ||
const Uint16 = Uint16LE; | ||
exports.Uint16 = Uint16; | ||
const Uint32LE = createUintNumberCodec(4, true); | ||
exports.Uint32LE = Uint32LE; | ||
const Uint32BE = createUintNumberCodec(4); | ||
const Uint16 = exports.Uint16 = Uint16LE; | ||
const Uint32LE = exports.Uint32LE = createUintNumberCodec(4, true); | ||
const Uint32BE = exports.Uint32BE = createUintNumberCodec(4); | ||
/** | ||
* @alias Uint32LE | ||
*/ | ||
exports.Uint32BE = Uint32BE; | ||
const Uint32 = Uint32LE; | ||
exports.Uint32 = Uint32; | ||
const Uint64LE = createUintBICodec(8, true); | ||
exports.Uint64LE = Uint64LE; | ||
const Uint64BE = createUintBICodec(8); | ||
const Uint32 = exports.Uint32 = Uint32LE; | ||
const Uint64LE = exports.Uint64LE = createUintBICodec(8, true); | ||
const Uint64BE = exports.Uint64BE = createUintBICodec(8); | ||
/** | ||
* @alias Uint64LE | ||
*/ | ||
exports.Uint64BE = Uint64BE; | ||
const Uint64 = Uint64LE; | ||
exports.Uint64 = Uint64; | ||
const Uint128LE = createUintBICodec(16, true); | ||
exports.Uint128LE = Uint128LE; | ||
const Uint128BE = createUintBICodec(16); | ||
const Uint64 = exports.Uint64 = Uint64LE; | ||
const Uint128LE = exports.Uint128LE = createUintBICodec(16, true); | ||
const Uint128BE = exports.Uint128BE = createUintBICodec(16); | ||
/** | ||
* @alias Uint128LE | ||
*/ | ||
exports.Uint128BE = Uint128BE; | ||
const Uint128 = Uint128LE; | ||
exports.Uint128 = Uint128; | ||
const Uint256LE = createUintBICodec(32, true); | ||
exports.Uint256LE = Uint256LE; | ||
const Uint256BE = createUintBICodec(32); | ||
const Uint128 = exports.Uint128 = Uint128LE; | ||
const Uint256LE = exports.Uint256LE = createUintBICodec(32, true); | ||
const Uint256BE = exports.Uint256BE = createUintBICodec(32); | ||
/** | ||
* @alias Uint256LE | ||
*/ | ||
exports.Uint256BE = Uint256BE; | ||
const Uint256 = Uint256LE; | ||
exports.Uint256 = Uint256; | ||
const Uint512LE = createUintBICodec(64, true); | ||
exports.Uint512LE = Uint512LE; | ||
const Uint512BE = createUintBICodec(64); | ||
const Uint256 = exports.Uint256 = Uint256LE; | ||
const Uint512LE = exports.Uint512LE = createUintBICodec(64, true); | ||
const Uint512BE = exports.Uint512BE = createUintBICodec(64); | ||
/** | ||
* @alias Uint512LE | ||
*/ | ||
exports.Uint512BE = Uint512BE; | ||
const Uint512 = Uint512LE; | ||
exports.Uint512 = Uint512; | ||
const Uint512 = exports.Uint512 = Uint512LE; | ||
//# sourceMappingURL=uint.js.map |
@@ -23,3 +23,3 @@ "use strict"; | ||
if (!str || !str.startsWith("0x")) { | ||
throw new Error("Invalid hex string"); | ||
throw new Error("Invalid hex string, expect starts with 0x"); | ||
} | ||
@@ -68,2 +68,3 @@ } | ||
const c = str.charCodeAt(i); | ||
/* eslint-disable @typescript-eslint/no-magic-numbers */ | ||
if (c > 0xff) { | ||
@@ -70,0 +71,0 @@ throw new Error("Invalid UTF-8 raw string!"); |
{ | ||
"name": "@ckb-lumos/codec", | ||
"version": "0.0.0-canary-f2fbef5-20240311091511", | ||
"version": "0.0.0-canary-f3acc1f-20240606024131", | ||
"description": "Make your own molecule binding in JavaScript(TypeScript)", | ||
@@ -22,3 +22,3 @@ "author": "", | ||
"dependencies": { | ||
"@ckb-lumos/bi": "0.0.0-canary-f2fbef5-20240311091511" | ||
"@ckb-lumos/bi": "0.0.0-canary-f3acc1f-20240606024131" | ||
}, | ||
@@ -25,0 +25,0 @@ "publishConfig": { |
@@ -49,6 +49,8 @@ // lc for lumos codec | ||
const path = this.keys.reduceRight(reducer, "input"); | ||
const text = | ||
this.origin instanceof CodecBaseParseError | ||
? `Expect type ${this.origin.expectedType} at ${path} but got error:` | ||
: `Error at ${path}:`; // this.origin can be an Error at runtime | ||
return `Expect type ${this.origin.expectedType} at ${path} but got error: ${ | ||
this.origin.message | ||
} | ||
return `${text} ${this.origin.message} | ||
${this.origin.stack?.replace(/Error:.+?\n/, "")} | ||
@@ -55,0 +57,0 @@ `; |
@@ -16,3 +16,3 @@ import { | ||
if (!str || !str.startsWith("0x")) { | ||
throw new Error("Invalid hex string"); | ||
throw new Error("Invalid hex string, expect starts with 0x"); | ||
} | ||
@@ -83,2 +83,3 @@ } | ||
const c = str.charCodeAt(i); | ||
/* eslint-disable @typescript-eslint/no-magic-numbers */ | ||
if (c > 0xff) { | ||
@@ -85,0 +86,0 @@ throw new Error("Invalid UTF-8 raw string!"); |
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
183472
2592
+ Added@ckb-lumos/bi@0.0.0-canary-f3acc1f-20240606024131(transitive)
- Removed@ckb-lumos/bi@0.0.0-canary-f2fbef5-20240311091511(transitive)