tenjin-cli 0.1.0-alpha.0 → 0.1.0-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +39 -7
- package/dist/{ccip-FXWZDDF5.js → ccip-UCLT5VOW.js} +4 -4
- package/dist/{chunk-F5DZJLU3.js → chunk-BRJHUQSY.js} +770 -59
- package/dist/chunk-BRJHUQSY.js.map +1 -0
- package/dist/{chunk-CPUZRZ2A.js → chunk-CUWUHTIL.js} +42 -1
- package/dist/{chunk-CPUZRZ2A.js.map → chunk-CUWUHTIL.js.map} +1 -1
- package/dist/{chunk-376LHMK2.js → chunk-DXPYFVKG.js} +32 -6
- package/dist/chunk-DXPYFVKG.js.map +1 -0
- package/dist/chunk-EXBMF5X7.js +1198 -0
- package/dist/chunk-EXBMF5X7.js.map +1 -0
- package/dist/{chunk-LTTRND4A.js → chunk-EZROUI5U.js} +2 -2
- package/dist/{chunk-PAAL45FJ.js → chunk-IPOWB3G3.js} +123 -133
- package/dist/chunk-IPOWB3G3.js.map +1 -0
- package/dist/{chunk-WOHCAMDQ.js → chunk-LPRVHM7P.js} +14 -697
- package/dist/chunk-LPRVHM7P.js.map +1 -0
- package/dist/{chunk-TX5T3LKJ.js → chunk-Q53IYV2G.js} +3 -2
- package/dist/{chunk-SXQQ2ZSR.js → chunk-T4LKNY7T.js} +24 -11
- package/dist/chunk-T4LKNY7T.js.map +1 -0
- package/dist/chunk-YBMMV4Y4.js +51 -0
- package/dist/chunk-YBMMV4Y4.js.map +1 -0
- package/dist/{chunk-FIYZLITH.js → chunk-YG2DO46P.js} +6 -2
- package/dist/{chunk-FIYZLITH.js.map → chunk-YG2DO46P.js.map} +1 -1
- package/dist/{cli-LMHGCZ5S.js → cli-WA65NP4Y.js} +13 -17
- package/dist/{cli-LMHGCZ5S.js.map → cli-WA65NP4Y.js.map} +1 -1
- package/dist/{config-XVXZ3V2Q.js → config-CEFTL5ZL.js} +9 -51
- package/dist/config-CEFTL5ZL.js.map +1 -0
- package/dist/{doctor-MVLZRVPU.js → doctor-3QBYN46N.js} +7 -7
- package/dist/index.js +1 -1
- package/dist/{secp256k1-35YNNB6F.js → secp256k1-BEZS642W.js} +3 -3
- package/dist/{usdc-OQUOFF6R.js → usdc-44R6XZF2.js} +7 -7
- package/dist/{wallet-QUWK2PA4.js → wallet-ELBTBMXO.js} +8 -10
- package/dist/wallet-XD576HF3.js +173 -0
- package/dist/wallet-XD576HF3.js.map +1 -0
- package/package.json +3 -1
- package/dist/chunk-376LHMK2.js.map +0 -1
- package/dist/chunk-F5DZJLU3.js.map +0 -1
- package/dist/chunk-PAAL45FJ.js.map +0 -1
- package/dist/chunk-QHIEYBLV.js +0 -320
- package/dist/chunk-QHIEYBLV.js.map +0 -1
- package/dist/chunk-SXQQ2ZSR.js.map +0 -1
- package/dist/chunk-WOHCAMDQ.js.map +0 -1
- package/dist/config-XVXZ3V2Q.js.map +0 -1
- package/dist/wallet-NRKWLKHX.js +0 -153
- package/dist/wallet-NRKWLKHX.js.map +0 -1
- /package/dist/{ccip-FXWZDDF5.js.map → ccip-UCLT5VOW.js.map} +0 -0
- /package/dist/{chunk-LTTRND4A.js.map → chunk-EZROUI5U.js.map} +0 -0
- /package/dist/{chunk-TX5T3LKJ.js.map → chunk-Q53IYV2G.js.map} +0 -0
- /package/dist/{doctor-MVLZRVPU.js.map → doctor-3QBYN46N.js.map} +0 -0
- /package/dist/{secp256k1-35YNNB6F.js.map → secp256k1-BEZS642W.js.map} +0 -0
- /package/dist/{usdc-OQUOFF6R.js.map → usdc-44R6XZF2.js.map} +0 -0
- /package/dist/{wallet-QUWK2PA4.js.map → wallet-ELBTBMXO.js.map} +0 -0
|
@@ -7,6 +7,7 @@ import {
|
|
|
7
7
|
aoutput,
|
|
8
8
|
clean,
|
|
9
9
|
createHasher,
|
|
10
|
+
equalBytes,
|
|
10
11
|
rotlBH,
|
|
11
12
|
rotlBL,
|
|
12
13
|
rotlSH,
|
|
@@ -15,7 +16,7 @@ import {
|
|
|
15
16
|
swap32IfBE,
|
|
16
17
|
toBytes,
|
|
17
18
|
u32
|
|
18
|
-
} from "./chunk-
|
|
19
|
+
} from "./chunk-CUWUHTIL.js";
|
|
19
20
|
|
|
20
21
|
// node_modules/.pnpm/viem@2.55.2_typescript@6.0.3_zod@4.4.3/node_modules/viem/_esm/utils/data/isHex.js
|
|
21
22
|
function isHex(value, { strict = true } = {}) {
|
|
@@ -185,11 +186,11 @@ var AbiConstructorParamsNotFoundError = class extends BaseError {
|
|
|
185
186
|
}
|
|
186
187
|
};
|
|
187
188
|
var AbiDecodingDataSizeTooSmallError = class extends BaseError {
|
|
188
|
-
constructor({ data, params, size:
|
|
189
|
-
super([`Data size of ${
|
|
189
|
+
constructor({ data, params, size: size4 }) {
|
|
190
|
+
super([`Data size of ${size4} bytes is too small for given parameters.`].join("\n"), {
|
|
190
191
|
metaMessages: [
|
|
191
192
|
`Params: (${formatAbiParams(params, { includeName: true })})`,
|
|
192
|
-
`Data: ${data} (${
|
|
193
|
+
`Data: ${data} (${size4} bytes)`
|
|
193
194
|
],
|
|
194
195
|
name: "AbiDecodingDataSizeTooSmallError"
|
|
195
196
|
});
|
|
@@ -213,7 +214,7 @@ var AbiDecodingDataSizeTooSmallError = class extends BaseError {
|
|
|
213
214
|
});
|
|
214
215
|
this.data = data;
|
|
215
216
|
this.params = params;
|
|
216
|
-
this.size =
|
|
217
|
+
this.size = size4;
|
|
217
218
|
}
|
|
218
219
|
};
|
|
219
220
|
var AbiDecodingZeroDataError = class extends BaseError {
|
|
@@ -378,13 +379,13 @@ var BytesSizeMismatchError = class extends BaseError {
|
|
|
378
379
|
}
|
|
379
380
|
};
|
|
380
381
|
var DecodeLogDataMismatch = class extends BaseError {
|
|
381
|
-
constructor({ abiItem, data, params, size:
|
|
382
|
+
constructor({ abiItem, data, params, size: size4 }) {
|
|
382
383
|
super([
|
|
383
|
-
`Data size of ${
|
|
384
|
+
`Data size of ${size4} bytes is too small for non-indexed event parameters.`
|
|
384
385
|
].join("\n"), {
|
|
385
386
|
metaMessages: [
|
|
386
387
|
`Params: (${formatAbiParams(params, { includeName: true })})`,
|
|
387
|
-
`Data: ${data} (${
|
|
388
|
+
`Data: ${data} (${size4} bytes)`
|
|
388
389
|
],
|
|
389
390
|
name: "DecodeLogDataMismatch"
|
|
390
391
|
});
|
|
@@ -415,7 +416,7 @@ var DecodeLogDataMismatch = class extends BaseError {
|
|
|
415
416
|
this.abiItem = abiItem;
|
|
416
417
|
this.data = data;
|
|
417
418
|
this.params = params;
|
|
418
|
-
this.size =
|
|
419
|
+
this.size = size4;
|
|
419
420
|
}
|
|
420
421
|
};
|
|
421
422
|
var DecodeLogTopicsMismatch = class extends BaseError {
|
|
@@ -479,8 +480,8 @@ var InvalidAddressError = class extends BaseError {
|
|
|
479
480
|
|
|
480
481
|
// node_modules/.pnpm/viem@2.55.2_typescript@6.0.3_zod@4.4.3/node_modules/viem/_esm/errors/encoding.js
|
|
481
482
|
var IntegerOutOfRangeError = class extends BaseError {
|
|
482
|
-
constructor({ max, min, signed, size:
|
|
483
|
-
super(`Number "${value}" is not in safe ${
|
|
483
|
+
constructor({ max, min, signed, size: size4, value }) {
|
|
484
|
+
super(`Number "${value}" is not in safe ${size4 ? `${size4 * 8}-bit ${signed ? "signed" : "unsigned"} ` : ""}integer range ${max ? `(${min} to ${max})` : `(above ${min})`}`, { name: "IntegerOutOfRangeError" });
|
|
484
485
|
}
|
|
485
486
|
};
|
|
486
487
|
var InvalidBytesBooleanError = class extends BaseError {
|
|
@@ -503,7 +504,7 @@ var SizeOverflowError = class extends BaseError {
|
|
|
503
504
|
|
|
504
505
|
// node_modules/.pnpm/viem@2.55.2_typescript@6.0.3_zod@4.4.3/node_modules/viem/_esm/utils/lru.js
|
|
505
506
|
var LruMap = class extends Map {
|
|
506
|
-
constructor(
|
|
507
|
+
constructor(size4) {
|
|
507
508
|
super();
|
|
508
509
|
Object.defineProperty(this, "maxSize", {
|
|
509
510
|
enumerable: true,
|
|
@@ -511,7 +512,7 @@ var LruMap = class extends Map {
|
|
|
511
512
|
writable: true,
|
|
512
513
|
value: void 0
|
|
513
514
|
});
|
|
514
|
-
this.maxSize =
|
|
515
|
+
this.maxSize = size4;
|
|
515
516
|
}
|
|
516
517
|
get(key) {
|
|
517
518
|
const value = super.get(key);
|
|
@@ -536,52 +537,52 @@ var LruMap = class extends Map {
|
|
|
536
537
|
|
|
537
538
|
// node_modules/.pnpm/viem@2.55.2_typescript@6.0.3_zod@4.4.3/node_modules/viem/_esm/errors/data.js
|
|
538
539
|
var SliceOffsetOutOfBoundsError = class extends BaseError {
|
|
539
|
-
constructor({ offset, position, size:
|
|
540
|
-
super(`Slice ${position === "start" ? "starting" : "ending"} at offset "${offset}" is out-of-bounds (size: ${
|
|
540
|
+
constructor({ offset, position, size: size4 }) {
|
|
541
|
+
super(`Slice ${position === "start" ? "starting" : "ending"} at offset "${offset}" is out-of-bounds (size: ${size4}).`, { name: "SliceOffsetOutOfBoundsError" });
|
|
541
542
|
}
|
|
542
543
|
};
|
|
543
544
|
var SizeExceedsPaddingSizeError = class extends BaseError {
|
|
544
|
-
constructor({ size:
|
|
545
|
-
super(`${type.charAt(0).toUpperCase()}${type.slice(1).toLowerCase()} size (${
|
|
545
|
+
constructor({ size: size4, targetSize, type }) {
|
|
546
|
+
super(`${type.charAt(0).toUpperCase()}${type.slice(1).toLowerCase()} size (${size4}) exceeds padding size (${targetSize}).`, { name: "SizeExceedsPaddingSizeError" });
|
|
546
547
|
}
|
|
547
548
|
};
|
|
548
549
|
var InvalidBytesLengthError = class extends BaseError {
|
|
549
|
-
constructor({ size:
|
|
550
|
-
super(`${type.charAt(0).toUpperCase()}${type.slice(1).toLowerCase()} is expected to be ${targetSize} ${type} long, but is ${
|
|
550
|
+
constructor({ size: size4, targetSize, type }) {
|
|
551
|
+
super(`${type.charAt(0).toUpperCase()}${type.slice(1).toLowerCase()} is expected to be ${targetSize} ${type} long, but is ${size4} ${type} long.`, { name: "InvalidBytesLengthError" });
|
|
551
552
|
}
|
|
552
553
|
};
|
|
553
554
|
|
|
554
555
|
// node_modules/.pnpm/viem@2.55.2_typescript@6.0.3_zod@4.4.3/node_modules/viem/_esm/utils/data/pad.js
|
|
555
|
-
function pad(hexOrBytes, { dir, size:
|
|
556
|
+
function pad(hexOrBytes, { dir, size: size4 = 32 } = {}) {
|
|
556
557
|
if (typeof hexOrBytes === "string")
|
|
557
|
-
return padHex(hexOrBytes, { dir, size:
|
|
558
|
-
return padBytes(hexOrBytes, { dir, size:
|
|
558
|
+
return padHex(hexOrBytes, { dir, size: size4 });
|
|
559
|
+
return padBytes(hexOrBytes, { dir, size: size4 });
|
|
559
560
|
}
|
|
560
|
-
function padHex(hex_, { dir, size:
|
|
561
|
-
if (
|
|
561
|
+
function padHex(hex_, { dir, size: size4 = 32 } = {}) {
|
|
562
|
+
if (size4 === null)
|
|
562
563
|
return hex_;
|
|
563
564
|
const hex = hex_.replace("0x", "");
|
|
564
|
-
if (hex.length >
|
|
565
|
+
if (hex.length > size4 * 2)
|
|
565
566
|
throw new SizeExceedsPaddingSizeError({
|
|
566
567
|
size: Math.ceil(hex.length / 2),
|
|
567
|
-
targetSize:
|
|
568
|
+
targetSize: size4,
|
|
568
569
|
type: "hex"
|
|
569
570
|
});
|
|
570
|
-
return `0x${hex[dir === "right" ? "padEnd" : "padStart"](
|
|
571
|
+
return `0x${hex[dir === "right" ? "padEnd" : "padStart"](size4 * 2, "0")}`;
|
|
571
572
|
}
|
|
572
|
-
function padBytes(bytes, { dir, size:
|
|
573
|
-
if (
|
|
573
|
+
function padBytes(bytes, { dir, size: size4 = 32 } = {}) {
|
|
574
|
+
if (size4 === null)
|
|
574
575
|
return bytes;
|
|
575
|
-
if (bytes.length >
|
|
576
|
+
if (bytes.length > size4)
|
|
576
577
|
throw new SizeExceedsPaddingSizeError({
|
|
577
578
|
size: bytes.length,
|
|
578
|
-
targetSize:
|
|
579
|
+
targetSize: size4,
|
|
579
580
|
type: "bytes"
|
|
580
581
|
});
|
|
581
|
-
const paddedBytes = new Uint8Array(
|
|
582
|
-
for (let i = 0; i <
|
|
582
|
+
const paddedBytes = new Uint8Array(size4);
|
|
583
|
+
for (let i = 0; i < size4; i++) {
|
|
583
584
|
const padEnd = dir === "right";
|
|
584
|
-
paddedBytes[padEnd ? i :
|
|
585
|
+
paddedBytes[padEnd ? i : size4 - i - 1] = bytes[padEnd ? i : bytes.length - i - 1];
|
|
585
586
|
}
|
|
586
587
|
return paddedBytes;
|
|
587
588
|
}
|
|
@@ -606,11 +607,11 @@ function trim(hexOrBytes, { dir = "left" } = {}) {
|
|
|
606
607
|
}
|
|
607
608
|
|
|
608
609
|
// node_modules/.pnpm/viem@2.55.2_typescript@6.0.3_zod@4.4.3/node_modules/viem/_esm/utils/encoding/fromHex.js
|
|
609
|
-
function assertSize(hexOrBytes, { size:
|
|
610
|
-
if (size(hexOrBytes) >
|
|
610
|
+
function assertSize(hexOrBytes, { size: size4 }) {
|
|
611
|
+
if (size(hexOrBytes) > size4)
|
|
611
612
|
throw new SizeOverflowError({
|
|
612
613
|
givenSize: size(hexOrBytes),
|
|
613
|
-
maxSize:
|
|
614
|
+
maxSize: size4
|
|
614
615
|
});
|
|
615
616
|
}
|
|
616
617
|
function hexToBigInt(hex, opts = {}) {
|
|
@@ -620,11 +621,11 @@ function hexToBigInt(hex, opts = {}) {
|
|
|
620
621
|
const value = BigInt(hex);
|
|
621
622
|
if (!signed)
|
|
622
623
|
return value;
|
|
623
|
-
const
|
|
624
|
-
const max = (1n << BigInt(
|
|
624
|
+
const size4 = (hex.length - 2) / 2;
|
|
625
|
+
const max = (1n << BigInt(size4) * 8n - 1n) - 1n;
|
|
625
626
|
if (value <= max)
|
|
626
627
|
return value;
|
|
627
|
-
return value - BigInt(`0x${"f".padStart(
|
|
628
|
+
return value - BigInt(`0x${"f".padStart(size4 * 2, "f")}`) - 1n;
|
|
628
629
|
}
|
|
629
630
|
function hexToBool(hex_, opts = {}) {
|
|
630
631
|
let hex = hex_;
|
|
@@ -685,14 +686,14 @@ function bytesToHex(value, opts = {}) {
|
|
|
685
686
|
return hex;
|
|
686
687
|
}
|
|
687
688
|
function numberToHex(value_, opts = {}) {
|
|
688
|
-
const { signed, size:
|
|
689
|
+
const { signed, size: size4 } = opts;
|
|
689
690
|
const value = BigInt(value_);
|
|
690
691
|
let maxValue;
|
|
691
|
-
if (
|
|
692
|
+
if (size4) {
|
|
692
693
|
if (signed)
|
|
693
|
-
maxValue = (1n << BigInt(
|
|
694
|
+
maxValue = (1n << BigInt(size4) * 8n - 1n) - 1n;
|
|
694
695
|
else
|
|
695
|
-
maxValue = 2n ** (BigInt(
|
|
696
|
+
maxValue = 2n ** (BigInt(size4) * 8n) - 1n;
|
|
696
697
|
} else if (typeof value_ === "number") {
|
|
697
698
|
maxValue = BigInt(Number.MAX_SAFE_INTEGER);
|
|
698
699
|
}
|
|
@@ -703,13 +704,13 @@ function numberToHex(value_, opts = {}) {
|
|
|
703
704
|
max: maxValue ? `${maxValue}${suffix}` : void 0,
|
|
704
705
|
min: `${minValue}${suffix}`,
|
|
705
706
|
signed,
|
|
706
|
-
size:
|
|
707
|
+
size: size4,
|
|
707
708
|
value: `${value_}${suffix}`
|
|
708
709
|
});
|
|
709
710
|
}
|
|
710
|
-
const hex = `0x${(signed && value < 0 ? (1n << BigInt(
|
|
711
|
-
if (
|
|
712
|
-
return pad(hex, { size:
|
|
711
|
+
const hex = `0x${(signed && value < 0 ? (1n << BigInt(size4 * 8)) + BigInt(value) : value).toString(16)}`;
|
|
712
|
+
if (size4)
|
|
713
|
+
return pad(hex, { size: size4 });
|
|
713
714
|
return hex;
|
|
714
715
|
}
|
|
715
716
|
var encoder = /* @__PURE__ */ new TextEncoder();
|
|
@@ -1111,10 +1112,10 @@ function prepareParam({ param, value }) {
|
|
|
1111
1112
|
}
|
|
1112
1113
|
if (param.type.startsWith("uint") || param.type.startsWith("int")) {
|
|
1113
1114
|
const signed = param.type.startsWith("int");
|
|
1114
|
-
const [, ,
|
|
1115
|
+
const [, , size4 = "256"] = integerRegex.exec(param.type) ?? [];
|
|
1115
1116
|
return encodeNumber(value, {
|
|
1116
1117
|
signed,
|
|
1117
|
-
size: Number(
|
|
1118
|
+
size: Number(size4)
|
|
1118
1119
|
});
|
|
1119
1120
|
}
|
|
1120
1121
|
if (param.type.startsWith("bytes")) {
|
|
@@ -1221,16 +1222,16 @@ function encodeBool(value) {
|
|
|
1221
1222
|
throw new BaseError(`Invalid boolean value: "${value}" (type: ${typeof value}). Expected: \`true\` or \`false\`.`);
|
|
1222
1223
|
return { dynamic: false, encoded: padHex(boolToHex(value)) };
|
|
1223
1224
|
}
|
|
1224
|
-
function encodeNumber(value, { signed, size:
|
|
1225
|
-
if (typeof
|
|
1226
|
-
const max = 2n ** (BigInt(
|
|
1225
|
+
function encodeNumber(value, { signed, size: size4 = 256 }) {
|
|
1226
|
+
if (typeof size4 === "number") {
|
|
1227
|
+
const max = 2n ** (BigInt(size4) - (signed ? 1n : 0n)) - 1n;
|
|
1227
1228
|
const min = signed ? -max - 1n : 0n;
|
|
1228
1229
|
if (value > max || value < min)
|
|
1229
1230
|
throw new IntegerOutOfRangeError({
|
|
1230
1231
|
max: max.toString(),
|
|
1231
1232
|
min: min.toString(),
|
|
1232
1233
|
signed,
|
|
1233
|
-
size:
|
|
1234
|
+
size: size4 / 8,
|
|
1234
1235
|
value: value.toString()
|
|
1235
1236
|
});
|
|
1236
1237
|
}
|
|
@@ -1907,11 +1908,11 @@ var staticCursor = {
|
|
|
1907
1908
|
this.position++;
|
|
1908
1909
|
return value;
|
|
1909
1910
|
},
|
|
1910
|
-
readBytes(length,
|
|
1911
|
+
readBytes(length, size4) {
|
|
1911
1912
|
this.assertReadLimit();
|
|
1912
1913
|
this._touch();
|
|
1913
1914
|
const value = this.inspectBytes(length);
|
|
1914
|
-
this.position +=
|
|
1915
|
+
this.position += size4 ?? length;
|
|
1915
1916
|
return value;
|
|
1916
1917
|
},
|
|
1917
1918
|
readUint8() {
|
|
@@ -1969,6 +1970,685 @@ function createCursor(bytes, { recursiveReadLimit = 8192 } = {}) {
|
|
|
1969
1970
|
return cursor;
|
|
1970
1971
|
}
|
|
1971
1972
|
|
|
1973
|
+
// node_modules/.pnpm/ox@0.14.30_typescript@6.0.3_zod@4.4.3/node_modules/ox/_esm/core/version.js
|
|
1974
|
+
var version2 = "0.1.1";
|
|
1975
|
+
|
|
1976
|
+
// node_modules/.pnpm/ox@0.14.30_typescript@6.0.3_zod@4.4.3/node_modules/ox/_esm/core/internal/errors.js
|
|
1977
|
+
function getVersion() {
|
|
1978
|
+
return version2;
|
|
1979
|
+
}
|
|
1980
|
+
|
|
1981
|
+
// node_modules/.pnpm/ox@0.14.30_typescript@6.0.3_zod@4.4.3/node_modules/ox/_esm/core/Errors.js
|
|
1982
|
+
var BaseError2 = class _BaseError extends Error {
|
|
1983
|
+
static setStaticOptions(options) {
|
|
1984
|
+
_BaseError.prototype.docsOrigin = options.docsOrigin;
|
|
1985
|
+
_BaseError.prototype.showVersion = options.showVersion;
|
|
1986
|
+
_BaseError.prototype.version = options.version;
|
|
1987
|
+
}
|
|
1988
|
+
constructor(shortMessage, options = {}) {
|
|
1989
|
+
const details = (() => {
|
|
1990
|
+
if (options.cause instanceof _BaseError) {
|
|
1991
|
+
if (options.cause.details)
|
|
1992
|
+
return options.cause.details;
|
|
1993
|
+
if (options.cause.shortMessage)
|
|
1994
|
+
return options.cause.shortMessage;
|
|
1995
|
+
}
|
|
1996
|
+
if (options.cause && "details" in options.cause && typeof options.cause.details === "string")
|
|
1997
|
+
return options.cause.details;
|
|
1998
|
+
if (options.cause?.message)
|
|
1999
|
+
return options.cause.message;
|
|
2000
|
+
return options.details;
|
|
2001
|
+
})();
|
|
2002
|
+
const docsPath = (() => {
|
|
2003
|
+
if (options.cause instanceof _BaseError)
|
|
2004
|
+
return options.cause.docsPath || options.docsPath;
|
|
2005
|
+
return options.docsPath;
|
|
2006
|
+
})();
|
|
2007
|
+
const docsBaseUrl = options.docsOrigin ?? _BaseError.prototype.docsOrigin;
|
|
2008
|
+
const docs = `${docsBaseUrl}${docsPath ?? ""}`;
|
|
2009
|
+
const showVersion = Boolean(options.version ?? _BaseError.prototype.showVersion);
|
|
2010
|
+
const version3 = options.version ?? _BaseError.prototype.version;
|
|
2011
|
+
const message = [
|
|
2012
|
+
shortMessage || "An error occurred.",
|
|
2013
|
+
...options.metaMessages ? ["", ...options.metaMessages] : [],
|
|
2014
|
+
...details || docsPath || showVersion ? [
|
|
2015
|
+
"",
|
|
2016
|
+
details ? `Details: ${details}` : void 0,
|
|
2017
|
+
docsPath ? `See: ${docs}` : void 0,
|
|
2018
|
+
showVersion ? `Version: ${version3}` : void 0
|
|
2019
|
+
] : []
|
|
2020
|
+
].filter((x) => typeof x === "string").join("\n");
|
|
2021
|
+
super(message, options.cause ? { cause: options.cause } : void 0);
|
|
2022
|
+
Object.defineProperty(this, "details", {
|
|
2023
|
+
enumerable: true,
|
|
2024
|
+
configurable: true,
|
|
2025
|
+
writable: true,
|
|
2026
|
+
value: void 0
|
|
2027
|
+
});
|
|
2028
|
+
Object.defineProperty(this, "docs", {
|
|
2029
|
+
enumerable: true,
|
|
2030
|
+
configurable: true,
|
|
2031
|
+
writable: true,
|
|
2032
|
+
value: void 0
|
|
2033
|
+
});
|
|
2034
|
+
Object.defineProperty(this, "docsOrigin", {
|
|
2035
|
+
enumerable: true,
|
|
2036
|
+
configurable: true,
|
|
2037
|
+
writable: true,
|
|
2038
|
+
value: void 0
|
|
2039
|
+
});
|
|
2040
|
+
Object.defineProperty(this, "docsPath", {
|
|
2041
|
+
enumerable: true,
|
|
2042
|
+
configurable: true,
|
|
2043
|
+
writable: true,
|
|
2044
|
+
value: void 0
|
|
2045
|
+
});
|
|
2046
|
+
Object.defineProperty(this, "shortMessage", {
|
|
2047
|
+
enumerable: true,
|
|
2048
|
+
configurable: true,
|
|
2049
|
+
writable: true,
|
|
2050
|
+
value: void 0
|
|
2051
|
+
});
|
|
2052
|
+
Object.defineProperty(this, "showVersion", {
|
|
2053
|
+
enumerable: true,
|
|
2054
|
+
configurable: true,
|
|
2055
|
+
writable: true,
|
|
2056
|
+
value: void 0
|
|
2057
|
+
});
|
|
2058
|
+
Object.defineProperty(this, "version", {
|
|
2059
|
+
enumerable: true,
|
|
2060
|
+
configurable: true,
|
|
2061
|
+
writable: true,
|
|
2062
|
+
value: void 0
|
|
2063
|
+
});
|
|
2064
|
+
Object.defineProperty(this, "cause", {
|
|
2065
|
+
enumerable: true,
|
|
2066
|
+
configurable: true,
|
|
2067
|
+
writable: true,
|
|
2068
|
+
value: void 0
|
|
2069
|
+
});
|
|
2070
|
+
Object.defineProperty(this, "name", {
|
|
2071
|
+
enumerable: true,
|
|
2072
|
+
configurable: true,
|
|
2073
|
+
writable: true,
|
|
2074
|
+
value: "BaseError"
|
|
2075
|
+
});
|
|
2076
|
+
this.cause = options.cause;
|
|
2077
|
+
this.details = details;
|
|
2078
|
+
this.docs = docs;
|
|
2079
|
+
this.docsOrigin = docsBaseUrl;
|
|
2080
|
+
this.docsPath = docsPath;
|
|
2081
|
+
this.shortMessage = shortMessage;
|
|
2082
|
+
this.showVersion = showVersion;
|
|
2083
|
+
this.version = version3;
|
|
2084
|
+
}
|
|
2085
|
+
walk(fn) {
|
|
2086
|
+
return walk2(this, fn);
|
|
2087
|
+
}
|
|
2088
|
+
};
|
|
2089
|
+
Object.defineProperty(BaseError2, "defaultStaticOptions", {
|
|
2090
|
+
enumerable: true,
|
|
2091
|
+
configurable: true,
|
|
2092
|
+
writable: true,
|
|
2093
|
+
value: {
|
|
2094
|
+
docsOrigin: "https://oxlib.sh",
|
|
2095
|
+
showVersion: false,
|
|
2096
|
+
version: `ox@${getVersion()}`
|
|
2097
|
+
}
|
|
2098
|
+
});
|
|
2099
|
+
(() => {
|
|
2100
|
+
BaseError2.setStaticOptions(BaseError2.defaultStaticOptions);
|
|
2101
|
+
})();
|
|
2102
|
+
function walk2(err, fn) {
|
|
2103
|
+
if (fn?.(err))
|
|
2104
|
+
return err;
|
|
2105
|
+
if (err && typeof err === "object" && "cause" in err && err.cause)
|
|
2106
|
+
return walk2(err.cause, fn);
|
|
2107
|
+
return fn ? null : err;
|
|
2108
|
+
}
|
|
2109
|
+
|
|
2110
|
+
// node_modules/.pnpm/ox@0.14.30_typescript@6.0.3_zod@4.4.3/node_modules/ox/_esm/core/internal/bytes.js
|
|
2111
|
+
function assertSize2(bytes, size_) {
|
|
2112
|
+
if (size2(bytes) > size_)
|
|
2113
|
+
throw new SizeOverflowError2({
|
|
2114
|
+
givenSize: size2(bytes),
|
|
2115
|
+
maxSize: size_
|
|
2116
|
+
});
|
|
2117
|
+
}
|
|
2118
|
+
function assertStartOffset2(value, start) {
|
|
2119
|
+
if (typeof start === "number" && start > 0 && start > size2(value) - 1)
|
|
2120
|
+
throw new SliceOffsetOutOfBoundsError2({
|
|
2121
|
+
offset: start,
|
|
2122
|
+
position: "start",
|
|
2123
|
+
size: size2(value)
|
|
2124
|
+
});
|
|
2125
|
+
}
|
|
2126
|
+
function assertEndOffset2(value, start, end) {
|
|
2127
|
+
if (typeof start === "number" && typeof end === "number" && size2(value) !== end - start) {
|
|
2128
|
+
throw new SliceOffsetOutOfBoundsError2({
|
|
2129
|
+
offset: end,
|
|
2130
|
+
position: "end",
|
|
2131
|
+
size: size2(value)
|
|
2132
|
+
});
|
|
2133
|
+
}
|
|
2134
|
+
}
|
|
2135
|
+
var charCodeMap2 = {
|
|
2136
|
+
zero: 48,
|
|
2137
|
+
nine: 57,
|
|
2138
|
+
A: 65,
|
|
2139
|
+
F: 70,
|
|
2140
|
+
a: 97,
|
|
2141
|
+
f: 102
|
|
2142
|
+
};
|
|
2143
|
+
function charCodeToBase162(char) {
|
|
2144
|
+
if (char >= charCodeMap2.zero && char <= charCodeMap2.nine)
|
|
2145
|
+
return char - charCodeMap2.zero;
|
|
2146
|
+
if (char >= charCodeMap2.A && char <= charCodeMap2.F)
|
|
2147
|
+
return char - (charCodeMap2.A - 10);
|
|
2148
|
+
if (char >= charCodeMap2.a && char <= charCodeMap2.f)
|
|
2149
|
+
return char - (charCodeMap2.a - 10);
|
|
2150
|
+
return void 0;
|
|
2151
|
+
}
|
|
2152
|
+
function pad2(bytes, options = {}) {
|
|
2153
|
+
const { dir, size: size4 = 32 } = options;
|
|
2154
|
+
if (size4 === 0)
|
|
2155
|
+
return bytes;
|
|
2156
|
+
if (bytes.length > size4)
|
|
2157
|
+
throw new SizeExceedsPaddingSizeError2({
|
|
2158
|
+
size: bytes.length,
|
|
2159
|
+
targetSize: size4,
|
|
2160
|
+
type: "Bytes"
|
|
2161
|
+
});
|
|
2162
|
+
const paddedBytes = new Uint8Array(size4);
|
|
2163
|
+
for (let i = 0; i < size4; i++) {
|
|
2164
|
+
const padEnd = dir === "right";
|
|
2165
|
+
paddedBytes[padEnd ? i : size4 - i - 1] = bytes[padEnd ? i : bytes.length - i - 1];
|
|
2166
|
+
}
|
|
2167
|
+
return paddedBytes;
|
|
2168
|
+
}
|
|
2169
|
+
function trim2(value, options = {}) {
|
|
2170
|
+
const { dir = "left" } = options;
|
|
2171
|
+
let data = value;
|
|
2172
|
+
let sliceLength = 0;
|
|
2173
|
+
for (let i = 0; i < data.length - 1; i++) {
|
|
2174
|
+
if (data[dir === "left" ? i : data.length - i - 1].toString() === "0")
|
|
2175
|
+
sliceLength++;
|
|
2176
|
+
else
|
|
2177
|
+
break;
|
|
2178
|
+
}
|
|
2179
|
+
data = dir === "left" ? data.slice(sliceLength) : data.slice(0, data.length - sliceLength);
|
|
2180
|
+
return data;
|
|
2181
|
+
}
|
|
2182
|
+
|
|
2183
|
+
// node_modules/.pnpm/ox@0.14.30_typescript@6.0.3_zod@4.4.3/node_modules/ox/_esm/core/internal/hex.js
|
|
2184
|
+
function assertSize3(hex, size_) {
|
|
2185
|
+
if (size3(hex) > size_)
|
|
2186
|
+
throw new SizeOverflowError3({
|
|
2187
|
+
givenSize: size3(hex),
|
|
2188
|
+
maxSize: size_
|
|
2189
|
+
});
|
|
2190
|
+
}
|
|
2191
|
+
function assertStartOffset3(value, start) {
|
|
2192
|
+
if (typeof start === "number" && start > 0 && start > size3(value) - 1)
|
|
2193
|
+
throw new SliceOffsetOutOfBoundsError3({
|
|
2194
|
+
offset: start,
|
|
2195
|
+
position: "start",
|
|
2196
|
+
size: size3(value)
|
|
2197
|
+
});
|
|
2198
|
+
}
|
|
2199
|
+
function assertEndOffset3(value, start, end) {
|
|
2200
|
+
if (typeof start === "number" && typeof end === "number" && size3(value) !== end - start) {
|
|
2201
|
+
throw new SliceOffsetOutOfBoundsError3({
|
|
2202
|
+
offset: end,
|
|
2203
|
+
position: "end",
|
|
2204
|
+
size: size3(value)
|
|
2205
|
+
});
|
|
2206
|
+
}
|
|
2207
|
+
}
|
|
2208
|
+
function pad3(hex_, options = {}) {
|
|
2209
|
+
const { dir, size: size4 = 32 } = options;
|
|
2210
|
+
if (size4 === 0)
|
|
2211
|
+
return hex_;
|
|
2212
|
+
const hex = hex_.replace("0x", "");
|
|
2213
|
+
if (hex.length > size4 * 2)
|
|
2214
|
+
throw new SizeExceedsPaddingSizeError3({
|
|
2215
|
+
size: Math.ceil(hex.length / 2),
|
|
2216
|
+
targetSize: size4,
|
|
2217
|
+
type: "Hex"
|
|
2218
|
+
});
|
|
2219
|
+
return `0x${hex[dir === "right" ? "padEnd" : "padStart"](size4 * 2, "0")}`;
|
|
2220
|
+
}
|
|
2221
|
+
function trim3(value, options = {}) {
|
|
2222
|
+
const { dir = "left" } = options;
|
|
2223
|
+
let data = value.replace("0x", "");
|
|
2224
|
+
let sliceLength = 0;
|
|
2225
|
+
for (let i = 0; i < data.length - 1; i++) {
|
|
2226
|
+
if (data[dir === "left" ? i : data.length - i - 1].toString() === "0")
|
|
2227
|
+
sliceLength++;
|
|
2228
|
+
else
|
|
2229
|
+
break;
|
|
2230
|
+
}
|
|
2231
|
+
data = dir === "left" ? data.slice(sliceLength) : data.slice(0, data.length - sliceLength);
|
|
2232
|
+
if (data === "0")
|
|
2233
|
+
return "0x";
|
|
2234
|
+
if (dir === "right" && data.length % 2 === 1)
|
|
2235
|
+
return `0x${data}0`;
|
|
2236
|
+
return `0x${data}`;
|
|
2237
|
+
}
|
|
2238
|
+
|
|
2239
|
+
// node_modules/.pnpm/ox@0.14.30_typescript@6.0.3_zod@4.4.3/node_modules/ox/_esm/core/Json.js
|
|
2240
|
+
var bigIntSuffix = "#__bigint";
|
|
2241
|
+
function stringify2(value, replacer, space) {
|
|
2242
|
+
return JSON.stringify(value, (key, value2) => {
|
|
2243
|
+
if (typeof replacer === "function")
|
|
2244
|
+
return replacer(key, value2);
|
|
2245
|
+
if (typeof value2 === "bigint")
|
|
2246
|
+
return value2.toString() + bigIntSuffix;
|
|
2247
|
+
return value2;
|
|
2248
|
+
}, space);
|
|
2249
|
+
}
|
|
2250
|
+
|
|
2251
|
+
// node_modules/.pnpm/ox@0.14.30_typescript@6.0.3_zod@4.4.3/node_modules/ox/_esm/core/Bytes.js
|
|
2252
|
+
var decoder = /* @__PURE__ */ new TextDecoder();
|
|
2253
|
+
var encoder3 = /* @__PURE__ */ new TextEncoder();
|
|
2254
|
+
function assert(value) {
|
|
2255
|
+
if (value instanceof Uint8Array)
|
|
2256
|
+
return;
|
|
2257
|
+
if (!value)
|
|
2258
|
+
throw new InvalidBytesTypeError(value);
|
|
2259
|
+
if (typeof value !== "object")
|
|
2260
|
+
throw new InvalidBytesTypeError(value);
|
|
2261
|
+
if (!("BYTES_PER_ELEMENT" in value))
|
|
2262
|
+
throw new InvalidBytesTypeError(value);
|
|
2263
|
+
if (value.BYTES_PER_ELEMENT !== 1 || value.constructor.name !== "Uint8Array")
|
|
2264
|
+
throw new InvalidBytesTypeError(value);
|
|
2265
|
+
}
|
|
2266
|
+
function concat2(...values) {
|
|
2267
|
+
let length = 0;
|
|
2268
|
+
for (const arr of values) {
|
|
2269
|
+
length += arr.length;
|
|
2270
|
+
}
|
|
2271
|
+
const result = new Uint8Array(length);
|
|
2272
|
+
for (let i = 0, index = 0; i < values.length; i++) {
|
|
2273
|
+
const arr = values[i];
|
|
2274
|
+
result.set(arr, index);
|
|
2275
|
+
index += arr.length;
|
|
2276
|
+
}
|
|
2277
|
+
return result;
|
|
2278
|
+
}
|
|
2279
|
+
function from(value) {
|
|
2280
|
+
if (value instanceof Uint8Array)
|
|
2281
|
+
return value;
|
|
2282
|
+
if (typeof value === "string")
|
|
2283
|
+
return fromHex(value);
|
|
2284
|
+
return fromArray(value);
|
|
2285
|
+
}
|
|
2286
|
+
function fromArray(value) {
|
|
2287
|
+
return value instanceof Uint8Array ? value : new Uint8Array(value);
|
|
2288
|
+
}
|
|
2289
|
+
function fromHex(value, options = {}) {
|
|
2290
|
+
const { size: size4 } = options;
|
|
2291
|
+
let hex = value;
|
|
2292
|
+
if (size4) {
|
|
2293
|
+
assertSize3(value, size4);
|
|
2294
|
+
hex = padRight(value, size4);
|
|
2295
|
+
}
|
|
2296
|
+
let hexString = hex.slice(2);
|
|
2297
|
+
if (hexString.length % 2)
|
|
2298
|
+
hexString = `0${hexString}`;
|
|
2299
|
+
const length = hexString.length / 2;
|
|
2300
|
+
const bytes = new Uint8Array(length);
|
|
2301
|
+
for (let index = 0, j = 0; index < length; index++) {
|
|
2302
|
+
const nibbleLeft = charCodeToBase162(hexString.charCodeAt(j++));
|
|
2303
|
+
const nibbleRight = charCodeToBase162(hexString.charCodeAt(j++));
|
|
2304
|
+
if (nibbleLeft === void 0 || nibbleRight === void 0) {
|
|
2305
|
+
throw new BaseError2(`Invalid byte sequence ("${hexString[j - 2]}${hexString[j - 1]}" in "${hexString}").`);
|
|
2306
|
+
}
|
|
2307
|
+
bytes[index] = nibbleLeft << 4 | nibbleRight;
|
|
2308
|
+
}
|
|
2309
|
+
return bytes;
|
|
2310
|
+
}
|
|
2311
|
+
function fromString(value, options = {}) {
|
|
2312
|
+
const { size: size4 } = options;
|
|
2313
|
+
const bytes = encoder3.encode(value);
|
|
2314
|
+
if (typeof size4 === "number") {
|
|
2315
|
+
assertSize2(bytes, size4);
|
|
2316
|
+
return padRight2(bytes, size4);
|
|
2317
|
+
}
|
|
2318
|
+
return bytes;
|
|
2319
|
+
}
|
|
2320
|
+
function isEqual(bytesA, bytesB) {
|
|
2321
|
+
return equalBytes(bytesA, bytesB);
|
|
2322
|
+
}
|
|
2323
|
+
function padRight2(value, size4) {
|
|
2324
|
+
return pad2(value, { dir: "right", size: size4 });
|
|
2325
|
+
}
|
|
2326
|
+
function random(length) {
|
|
2327
|
+
return crypto.getRandomValues(new Uint8Array(length));
|
|
2328
|
+
}
|
|
2329
|
+
function size2(value) {
|
|
2330
|
+
return value.length;
|
|
2331
|
+
}
|
|
2332
|
+
function slice2(value, start, end, options = {}) {
|
|
2333
|
+
const { strict } = options;
|
|
2334
|
+
assertStartOffset2(value, start);
|
|
2335
|
+
const value_ = value.slice(start, end);
|
|
2336
|
+
if (strict)
|
|
2337
|
+
assertEndOffset2(value_, start, end);
|
|
2338
|
+
return value_;
|
|
2339
|
+
}
|
|
2340
|
+
function toBigInt2(bytes, options = {}) {
|
|
2341
|
+
const { size: size4 } = options;
|
|
2342
|
+
if (typeof size4 !== "undefined")
|
|
2343
|
+
assertSize2(bytes, size4);
|
|
2344
|
+
const hex = fromBytes(bytes, options);
|
|
2345
|
+
return toBigInt(hex, options);
|
|
2346
|
+
}
|
|
2347
|
+
function toBoolean(bytes, options = {}) {
|
|
2348
|
+
const { size: size4 } = options;
|
|
2349
|
+
let bytes_ = bytes;
|
|
2350
|
+
if (typeof size4 !== "undefined") {
|
|
2351
|
+
assertSize2(bytes_, size4);
|
|
2352
|
+
bytes_ = trimLeft(bytes_);
|
|
2353
|
+
}
|
|
2354
|
+
if (bytes_.length > 1 || bytes_[0] > 1)
|
|
2355
|
+
throw new InvalidBytesBooleanError2(bytes_);
|
|
2356
|
+
return Boolean(bytes_[0]);
|
|
2357
|
+
}
|
|
2358
|
+
function toHex2(value, options = {}) {
|
|
2359
|
+
return fromBytes(value, options);
|
|
2360
|
+
}
|
|
2361
|
+
function toNumber2(bytes, options = {}) {
|
|
2362
|
+
const { size: size4 } = options;
|
|
2363
|
+
if (typeof size4 !== "undefined")
|
|
2364
|
+
assertSize2(bytes, size4);
|
|
2365
|
+
const hex = fromBytes(bytes, options);
|
|
2366
|
+
return toNumber(hex, options);
|
|
2367
|
+
}
|
|
2368
|
+
function toString(bytes, options = {}) {
|
|
2369
|
+
const { size: size4 } = options;
|
|
2370
|
+
let bytes_ = bytes;
|
|
2371
|
+
if (typeof size4 !== "undefined") {
|
|
2372
|
+
assertSize2(bytes_, size4);
|
|
2373
|
+
bytes_ = trimRight(bytes_);
|
|
2374
|
+
}
|
|
2375
|
+
return decoder.decode(bytes_);
|
|
2376
|
+
}
|
|
2377
|
+
function trimLeft(value) {
|
|
2378
|
+
return trim2(value, { dir: "left" });
|
|
2379
|
+
}
|
|
2380
|
+
function trimRight(value) {
|
|
2381
|
+
return trim2(value, { dir: "right" });
|
|
2382
|
+
}
|
|
2383
|
+
function validate(value) {
|
|
2384
|
+
try {
|
|
2385
|
+
assert(value);
|
|
2386
|
+
return true;
|
|
2387
|
+
} catch {
|
|
2388
|
+
return false;
|
|
2389
|
+
}
|
|
2390
|
+
}
|
|
2391
|
+
var InvalidBytesBooleanError2 = class extends BaseError2 {
|
|
2392
|
+
constructor(bytes) {
|
|
2393
|
+
super(`Bytes value \`${bytes}\` is not a valid boolean.`, {
|
|
2394
|
+
metaMessages: [
|
|
2395
|
+
"The bytes array must contain a single byte of either a `0` or `1` value."
|
|
2396
|
+
]
|
|
2397
|
+
});
|
|
2398
|
+
Object.defineProperty(this, "name", {
|
|
2399
|
+
enumerable: true,
|
|
2400
|
+
configurable: true,
|
|
2401
|
+
writable: true,
|
|
2402
|
+
value: "Bytes.InvalidBytesBooleanError"
|
|
2403
|
+
});
|
|
2404
|
+
}
|
|
2405
|
+
};
|
|
2406
|
+
var InvalidBytesTypeError = class extends BaseError2 {
|
|
2407
|
+
constructor(value) {
|
|
2408
|
+
super(`Value \`${typeof value === "object" ? stringify2(value) : value}\` of type \`${typeof value}\` is an invalid Bytes value.`, {
|
|
2409
|
+
metaMessages: ["Bytes values must be of type `Bytes`."]
|
|
2410
|
+
});
|
|
2411
|
+
Object.defineProperty(this, "name", {
|
|
2412
|
+
enumerable: true,
|
|
2413
|
+
configurable: true,
|
|
2414
|
+
writable: true,
|
|
2415
|
+
value: "Bytes.InvalidBytesTypeError"
|
|
2416
|
+
});
|
|
2417
|
+
}
|
|
2418
|
+
};
|
|
2419
|
+
var SizeOverflowError2 = class extends BaseError2 {
|
|
2420
|
+
constructor({ givenSize, maxSize }) {
|
|
2421
|
+
super(`Size cannot exceed \`${maxSize}\` bytes. Given size: \`${givenSize}\` bytes.`);
|
|
2422
|
+
Object.defineProperty(this, "name", {
|
|
2423
|
+
enumerable: true,
|
|
2424
|
+
configurable: true,
|
|
2425
|
+
writable: true,
|
|
2426
|
+
value: "Bytes.SizeOverflowError"
|
|
2427
|
+
});
|
|
2428
|
+
}
|
|
2429
|
+
};
|
|
2430
|
+
var SliceOffsetOutOfBoundsError2 = class extends BaseError2 {
|
|
2431
|
+
constructor({ offset, position, size: size4 }) {
|
|
2432
|
+
super(`Slice ${position === "start" ? "starting" : "ending"} at offset \`${offset}\` is out-of-bounds (size: \`${size4}\`).`);
|
|
2433
|
+
Object.defineProperty(this, "name", {
|
|
2434
|
+
enumerable: true,
|
|
2435
|
+
configurable: true,
|
|
2436
|
+
writable: true,
|
|
2437
|
+
value: "Bytes.SliceOffsetOutOfBoundsError"
|
|
2438
|
+
});
|
|
2439
|
+
}
|
|
2440
|
+
};
|
|
2441
|
+
var SizeExceedsPaddingSizeError2 = class extends BaseError2 {
|
|
2442
|
+
constructor({ size: size4, targetSize, type }) {
|
|
2443
|
+
super(`${type.charAt(0).toUpperCase()}${type.slice(1).toLowerCase()} size (\`${size4}\`) exceeds padding size (\`${targetSize}\`).`);
|
|
2444
|
+
Object.defineProperty(this, "name", {
|
|
2445
|
+
enumerable: true,
|
|
2446
|
+
configurable: true,
|
|
2447
|
+
writable: true,
|
|
2448
|
+
value: "Bytes.SizeExceedsPaddingSizeError"
|
|
2449
|
+
});
|
|
2450
|
+
}
|
|
2451
|
+
};
|
|
2452
|
+
|
|
2453
|
+
// node_modules/.pnpm/ox@0.14.30_typescript@6.0.3_zod@4.4.3/node_modules/ox/_esm/core/Hex.js
|
|
2454
|
+
var encoder4 = /* @__PURE__ */ new TextEncoder();
|
|
2455
|
+
var hexes2 = /* @__PURE__ */ Array.from({ length: 256 }, (_v, i) => i.toString(16).padStart(2, "0"));
|
|
2456
|
+
function assert2(value, options = {}) {
|
|
2457
|
+
const { strict = false } = options;
|
|
2458
|
+
if (!value)
|
|
2459
|
+
throw new InvalidHexTypeError(value);
|
|
2460
|
+
if (typeof value !== "string")
|
|
2461
|
+
throw new InvalidHexTypeError(value);
|
|
2462
|
+
if (strict) {
|
|
2463
|
+
if (!/^0x[0-9a-fA-F]*$/.test(value))
|
|
2464
|
+
throw new InvalidHexValueError(value);
|
|
2465
|
+
}
|
|
2466
|
+
if (!value.startsWith("0x"))
|
|
2467
|
+
throw new InvalidHexValueError(value);
|
|
2468
|
+
}
|
|
2469
|
+
function concat3(...values) {
|
|
2470
|
+
return `0x${values.reduce((acc, x) => acc + x.replace("0x", ""), "")}`;
|
|
2471
|
+
}
|
|
2472
|
+
function from2(value) {
|
|
2473
|
+
if (value instanceof Uint8Array)
|
|
2474
|
+
return fromBytes(value);
|
|
2475
|
+
if (Array.isArray(value))
|
|
2476
|
+
return fromBytes(new Uint8Array(value));
|
|
2477
|
+
return value;
|
|
2478
|
+
}
|
|
2479
|
+
function fromBoolean(value, options = {}) {
|
|
2480
|
+
const hex = `0x${Number(value)}`;
|
|
2481
|
+
if (typeof options.size === "number") {
|
|
2482
|
+
assertSize3(hex, options.size);
|
|
2483
|
+
return padLeft(hex, options.size);
|
|
2484
|
+
}
|
|
2485
|
+
return hex;
|
|
2486
|
+
}
|
|
2487
|
+
function fromBytes(value, options = {}) {
|
|
2488
|
+
let string = "";
|
|
2489
|
+
for (let i = 0; i < value.length; i++)
|
|
2490
|
+
string += hexes2[value[i]];
|
|
2491
|
+
const hex = `0x${string}`;
|
|
2492
|
+
if (typeof options.size === "number") {
|
|
2493
|
+
assertSize3(hex, options.size);
|
|
2494
|
+
return padRight(hex, options.size);
|
|
2495
|
+
}
|
|
2496
|
+
return hex;
|
|
2497
|
+
}
|
|
2498
|
+
function fromNumber(value, options = {}) {
|
|
2499
|
+
const { signed, size: size4 } = options;
|
|
2500
|
+
const value_ = BigInt(value);
|
|
2501
|
+
let maxValue;
|
|
2502
|
+
if (size4) {
|
|
2503
|
+
if (signed)
|
|
2504
|
+
maxValue = (1n << BigInt(size4) * 8n - 1n) - 1n;
|
|
2505
|
+
else
|
|
2506
|
+
maxValue = 2n ** (BigInt(size4) * 8n) - 1n;
|
|
2507
|
+
} else if (typeof value === "number") {
|
|
2508
|
+
maxValue = BigInt(Number.MAX_SAFE_INTEGER);
|
|
2509
|
+
}
|
|
2510
|
+
const minValue = typeof maxValue === "bigint" && signed ? -maxValue - 1n : 0;
|
|
2511
|
+
if (maxValue && value_ > maxValue || value_ < minValue) {
|
|
2512
|
+
const suffix = typeof value === "bigint" ? "n" : "";
|
|
2513
|
+
throw new IntegerOutOfRangeError2({
|
|
2514
|
+
max: maxValue ? `${maxValue}${suffix}` : void 0,
|
|
2515
|
+
min: `${minValue}${suffix}`,
|
|
2516
|
+
signed,
|
|
2517
|
+
size: size4,
|
|
2518
|
+
value: `${value}${suffix}`
|
|
2519
|
+
});
|
|
2520
|
+
}
|
|
2521
|
+
const stringValue = (signed && value_ < 0 ? BigInt.asUintN(size4 * 8, BigInt(value_)) : value_).toString(16);
|
|
2522
|
+
const hex = `0x${stringValue}`;
|
|
2523
|
+
if (size4)
|
|
2524
|
+
return padLeft(hex, size4);
|
|
2525
|
+
return hex;
|
|
2526
|
+
}
|
|
2527
|
+
function fromString2(value, options = {}) {
|
|
2528
|
+
return fromBytes(encoder4.encode(value), options);
|
|
2529
|
+
}
|
|
2530
|
+
function padLeft(value, size4) {
|
|
2531
|
+
return pad3(value, { dir: "left", size: size4 });
|
|
2532
|
+
}
|
|
2533
|
+
function padRight(value, size4) {
|
|
2534
|
+
return pad3(value, { dir: "right", size: size4 });
|
|
2535
|
+
}
|
|
2536
|
+
function slice3(value, start, end, options = {}) {
|
|
2537
|
+
const { strict } = options;
|
|
2538
|
+
assertStartOffset3(value, start);
|
|
2539
|
+
const value_ = `0x${value.replace("0x", "").slice((start ?? 0) * 2, (end ?? value.length) * 2)}`;
|
|
2540
|
+
if (strict)
|
|
2541
|
+
assertEndOffset3(value_, start, end);
|
|
2542
|
+
return value_;
|
|
2543
|
+
}
|
|
2544
|
+
function size3(value) {
|
|
2545
|
+
return Math.ceil((value.length - 2) / 2);
|
|
2546
|
+
}
|
|
2547
|
+
function trimLeft2(value) {
|
|
2548
|
+
return trim3(value, { dir: "left" });
|
|
2549
|
+
}
|
|
2550
|
+
function toBigInt(hex, options = {}) {
|
|
2551
|
+
const { signed } = options;
|
|
2552
|
+
if (options.size)
|
|
2553
|
+
assertSize3(hex, options.size);
|
|
2554
|
+
const value = BigInt(hex);
|
|
2555
|
+
if (!signed)
|
|
2556
|
+
return value;
|
|
2557
|
+
const size4 = (hex.length - 2) / 2;
|
|
2558
|
+
const max_unsigned = (1n << BigInt(size4) * 8n) - 1n;
|
|
2559
|
+
const max_signed = max_unsigned >> 1n;
|
|
2560
|
+
if (value <= max_signed)
|
|
2561
|
+
return value;
|
|
2562
|
+
return value - max_unsigned - 1n;
|
|
2563
|
+
}
|
|
2564
|
+
function toNumber(hex, options = {}) {
|
|
2565
|
+
const { signed, size: size4 } = options;
|
|
2566
|
+
if (!signed && !size4)
|
|
2567
|
+
return Number(hex);
|
|
2568
|
+
return Number(toBigInt(hex, options));
|
|
2569
|
+
}
|
|
2570
|
+
function validate2(value, options = {}) {
|
|
2571
|
+
const { strict = false } = options;
|
|
2572
|
+
try {
|
|
2573
|
+
assert2(value, { strict });
|
|
2574
|
+
return true;
|
|
2575
|
+
} catch {
|
|
2576
|
+
return false;
|
|
2577
|
+
}
|
|
2578
|
+
}
|
|
2579
|
+
var IntegerOutOfRangeError2 = class extends BaseError2 {
|
|
2580
|
+
constructor({ max, min, signed, size: size4, value }) {
|
|
2581
|
+
super(`Number \`${value}\` is not in safe${size4 ? ` ${size4 * 8}-bit` : ""}${signed ? " signed" : " unsigned"} integer range ${max ? `(\`${min}\` to \`${max}\`)` : `(above \`${min}\`)`}`);
|
|
2582
|
+
Object.defineProperty(this, "name", {
|
|
2583
|
+
enumerable: true,
|
|
2584
|
+
configurable: true,
|
|
2585
|
+
writable: true,
|
|
2586
|
+
value: "Hex.IntegerOutOfRangeError"
|
|
2587
|
+
});
|
|
2588
|
+
}
|
|
2589
|
+
};
|
|
2590
|
+
var InvalidHexTypeError = class extends BaseError2 {
|
|
2591
|
+
constructor(value) {
|
|
2592
|
+
super(`Value \`${typeof value === "object" ? stringify2(value) : value}\` of type \`${typeof value}\` is an invalid hex type.`, {
|
|
2593
|
+
metaMessages: ['Hex types must be represented as `"0x${string}"`.']
|
|
2594
|
+
});
|
|
2595
|
+
Object.defineProperty(this, "name", {
|
|
2596
|
+
enumerable: true,
|
|
2597
|
+
configurable: true,
|
|
2598
|
+
writable: true,
|
|
2599
|
+
value: "Hex.InvalidHexTypeError"
|
|
2600
|
+
});
|
|
2601
|
+
}
|
|
2602
|
+
};
|
|
2603
|
+
var InvalidHexValueError = class extends BaseError2 {
|
|
2604
|
+
constructor(value) {
|
|
2605
|
+
super(`Value \`${value}\` is an invalid hex value.`, {
|
|
2606
|
+
metaMessages: [
|
|
2607
|
+
'Hex values must start with `"0x"` and contain only hexadecimal characters (0-9, a-f, A-F).'
|
|
2608
|
+
]
|
|
2609
|
+
});
|
|
2610
|
+
Object.defineProperty(this, "name", {
|
|
2611
|
+
enumerable: true,
|
|
2612
|
+
configurable: true,
|
|
2613
|
+
writable: true,
|
|
2614
|
+
value: "Hex.InvalidHexValueError"
|
|
2615
|
+
});
|
|
2616
|
+
}
|
|
2617
|
+
};
|
|
2618
|
+
var SizeOverflowError3 = class extends BaseError2 {
|
|
2619
|
+
constructor({ givenSize, maxSize }) {
|
|
2620
|
+
super(`Size cannot exceed \`${maxSize}\` bytes. Given size: \`${givenSize}\` bytes.`);
|
|
2621
|
+
Object.defineProperty(this, "name", {
|
|
2622
|
+
enumerable: true,
|
|
2623
|
+
configurable: true,
|
|
2624
|
+
writable: true,
|
|
2625
|
+
value: "Hex.SizeOverflowError"
|
|
2626
|
+
});
|
|
2627
|
+
}
|
|
2628
|
+
};
|
|
2629
|
+
var SliceOffsetOutOfBoundsError3 = class extends BaseError2 {
|
|
2630
|
+
constructor({ offset, position, size: size4 }) {
|
|
2631
|
+
super(`Slice ${position === "start" ? "starting" : "ending"} at offset \`${offset}\` is out-of-bounds (size: \`${size4}\`).`);
|
|
2632
|
+
Object.defineProperty(this, "name", {
|
|
2633
|
+
enumerable: true,
|
|
2634
|
+
configurable: true,
|
|
2635
|
+
writable: true,
|
|
2636
|
+
value: "Hex.SliceOffsetOutOfBoundsError"
|
|
2637
|
+
});
|
|
2638
|
+
}
|
|
2639
|
+
};
|
|
2640
|
+
var SizeExceedsPaddingSizeError3 = class extends BaseError2 {
|
|
2641
|
+
constructor({ size: size4, targetSize, type }) {
|
|
2642
|
+
super(`${type.charAt(0).toUpperCase()}${type.slice(1).toLowerCase()} size (\`${size4}\`) exceeds padding size (\`${targetSize}\`).`);
|
|
2643
|
+
Object.defineProperty(this, "name", {
|
|
2644
|
+
enumerable: true,
|
|
2645
|
+
configurable: true,
|
|
2646
|
+
writable: true,
|
|
2647
|
+
value: "Hex.SizeExceedsPaddingSizeError"
|
|
2648
|
+
});
|
|
2649
|
+
}
|
|
2650
|
+
};
|
|
2651
|
+
|
|
1972
2652
|
export {
|
|
1973
2653
|
BaseError,
|
|
1974
2654
|
InvalidBytesBooleanError,
|
|
@@ -2053,6 +2733,37 @@ export {
|
|
|
2053
2733
|
encodeAbiParameters,
|
|
2054
2734
|
getArrayComponents,
|
|
2055
2735
|
stringify,
|
|
2056
|
-
parseAccount
|
|
2057
|
-
|
|
2058
|
-
|
|
2736
|
+
parseAccount,
|
|
2737
|
+
BaseError2,
|
|
2738
|
+
stringify2,
|
|
2739
|
+
concat3 as concat2,
|
|
2740
|
+
from2 as from,
|
|
2741
|
+
fromBoolean,
|
|
2742
|
+
fromBytes,
|
|
2743
|
+
fromNumber,
|
|
2744
|
+
fromString2 as fromString,
|
|
2745
|
+
padLeft,
|
|
2746
|
+
padRight,
|
|
2747
|
+
slice3 as slice2,
|
|
2748
|
+
size3 as size2,
|
|
2749
|
+
trimLeft2 as trimLeft,
|
|
2750
|
+
toNumber,
|
|
2751
|
+
validate2 as validate,
|
|
2752
|
+
IntegerOutOfRangeError2 as IntegerOutOfRangeError,
|
|
2753
|
+
concat2 as concat3,
|
|
2754
|
+
from as from2,
|
|
2755
|
+
fromHex,
|
|
2756
|
+
fromString as fromString2,
|
|
2757
|
+
isEqual,
|
|
2758
|
+
random,
|
|
2759
|
+
size2 as size3,
|
|
2760
|
+
slice2 as slice3,
|
|
2761
|
+
toBigInt2 as toBigInt,
|
|
2762
|
+
toBoolean,
|
|
2763
|
+
toHex2,
|
|
2764
|
+
toNumber2,
|
|
2765
|
+
toString,
|
|
2766
|
+
trimLeft as trimLeft2,
|
|
2767
|
+
validate as validate2
|
|
2768
|
+
};
|
|
2769
|
+
//# sourceMappingURL=chunk-BRJHUQSY.js.map
|