@etherspot/remote-signer
Version:
Etherspot Permissioned Signer SDK - signs the UserOp with SessionKey and sends it to the Bundler
1,509 lines (1,477 loc) • 1.26 MB
JavaScript
var __create = Object.create;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __getProtoOf = Object.getPrototypeOf;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __esm = (fn, res) => function __init() {
return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
};
var __commonJS = (cb, mod2) => function __require() {
return mod2 || (0, cb[__getOwnPropNames(cb)[0]])((mod2 = { exports: {} }).exports, mod2), mod2.exports;
};
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toESM = (mod2, isNodeMode, target) => (target = mod2 != null ? __create(__getProtoOf(mod2)) : {}, __copyProps(
// If the importer is in node compatibility mode or this is not an ESM
// file that has been converted to a CommonJS file using a Babel-
// compatible transform (i.e. "__esModule" has not been set), then set
// "default" to the CommonJS "module.exports" for node compatibility.
isNodeMode || !mod2 || !mod2.__esModule ? __defProp(target, "default", { value: mod2, enumerable: true }) : target,
mod2
));
var __toCommonJS = (mod2) => __copyProps(__defProp({}, "__esModule", { value: true }), mod2);
var __decorateClass = (decorators, target, key, kind) => {
var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
for (var i = decorators.length - 1, decorator; i >= 0; i--)
if (decorator = decorators[i])
result = (kind ? decorator(target, key, result) : decorator(result)) || result;
if (kind && result) __defProp(target, key, result);
return result;
};
// node_modules/viem/_esm/errors/version.js
var version;
var init_version = __esm({
"node_modules/viem/_esm/errors/version.js"() {
version = "2.16.3";
}
});
// node_modules/viem/_esm/errors/utils.js
var getContractAddress, getUrl, getVersion;
var init_utils = __esm({
"node_modules/viem/_esm/errors/utils.js"() {
init_version();
getContractAddress = (address) => address;
getUrl = (url) => url;
getVersion = () => `viem@${version}`;
}
});
// node_modules/viem/_esm/errors/base.js
function walk(err, fn) {
if (fn?.(err))
return err;
if (err && typeof err === "object" && "cause" in err)
return walk(err.cause, fn);
return fn ? null : err;
}
var BaseError;
var init_base = __esm({
"node_modules/viem/_esm/errors/base.js"() {
init_utils();
BaseError = class _BaseError extends Error {
constructor(shortMessage, args = {}) {
super();
Object.defineProperty(this, "details", {
enumerable: true,
configurable: true,
writable: true,
value: void 0
});
Object.defineProperty(this, "docsPath", {
enumerable: true,
configurable: true,
writable: true,
value: void 0
});
Object.defineProperty(this, "metaMessages", {
enumerable: true,
configurable: true,
writable: true,
value: void 0
});
Object.defineProperty(this, "shortMessage", {
enumerable: true,
configurable: true,
writable: true,
value: void 0
});
Object.defineProperty(this, "name", {
enumerable: true,
configurable: true,
writable: true,
value: "ViemError"
});
Object.defineProperty(this, "version", {
enumerable: true,
configurable: true,
writable: true,
value: getVersion()
});
const details = args.cause instanceof _BaseError ? args.cause.details : args.cause?.message ? args.cause.message : args.details;
const docsPath6 = args.cause instanceof _BaseError ? args.cause.docsPath || args.docsPath : args.docsPath;
this.message = [
shortMessage || "An error occurred.",
"",
...args.metaMessages ? [...args.metaMessages, ""] : [],
...docsPath6 ? [
`Docs: ${args.docsBaseUrl ?? "https://viem.sh"}${docsPath6}${args.docsSlug ? `#${args.docsSlug}` : ""}`
] : [],
...details ? [`Details: ${details}`] : [],
`Version: ${this.version}`
].join("\n");
if (args.cause)
this.cause = args.cause;
this.details = details;
this.docsPath = docsPath6;
this.metaMessages = args.metaMessages;
this.shortMessage = shortMessage;
}
walk(fn) {
return walk(this, fn);
}
};
}
});
// node_modules/viem/_esm/errors/encoding.js
var IntegerOutOfRangeError, InvalidBytesBooleanError, SizeOverflowError;
var init_encoding = __esm({
"node_modules/viem/_esm/errors/encoding.js"() {
init_base();
IntegerOutOfRangeError = class extends BaseError {
constructor({ max, min, signed, size: size3, value }) {
super(`Number "${value}" is not in safe ${size3 ? `${size3 * 8}-bit ${signed ? "signed" : "unsigned"} ` : ""}integer range ${max ? `(${min} to ${max})` : `(above ${min})`}`);
Object.defineProperty(this, "name", {
enumerable: true,
configurable: true,
writable: true,
value: "IntegerOutOfRangeError"
});
}
};
InvalidBytesBooleanError = class extends BaseError {
constructor(bytes2) {
super(`Bytes value "${bytes2}" is not a valid boolean. The bytes array must contain a single byte of either a 0 or 1 value.`);
Object.defineProperty(this, "name", {
enumerable: true,
configurable: true,
writable: true,
value: "InvalidBytesBooleanError"
});
}
};
SizeOverflowError = class extends BaseError {
constructor({ givenSize, maxSize }) {
super(`Size cannot exceed ${maxSize} bytes. Given size: ${givenSize} bytes.`);
Object.defineProperty(this, "name", {
enumerable: true,
configurable: true,
writable: true,
value: "SizeOverflowError"
});
}
};
}
});
// node_modules/viem/_esm/utils/data/isHex.js
function isHex(value, { strict = true } = {}) {
if (!value)
return false;
if (typeof value !== "string")
return false;
return strict ? /^0x[0-9a-fA-F]*$/.test(value) : value.startsWith("0x");
}
var init_isHex = __esm({
"node_modules/viem/_esm/utils/data/isHex.js"() {
}
});
// node_modules/viem/_esm/utils/data/size.js
function size(value) {
if (isHex(value, { strict: false }))
return Math.ceil((value.length - 2) / 2);
return value.length;
}
var init_size = __esm({
"node_modules/viem/_esm/utils/data/size.js"() {
init_isHex();
}
});
// node_modules/viem/_esm/utils/data/trim.js
function trim(hexOrBytes, { dir = "left" } = {}) {
let data = typeof hexOrBytes === "string" ? hexOrBytes.replace("0x", "") : hexOrBytes;
let sliceLength = 0;
for (let i = 0; i < data.length - 1; i++) {
if (data[dir === "left" ? i : data.length - i - 1].toString() === "0")
sliceLength++;
else
break;
}
data = dir === "left" ? data.slice(sliceLength) : data.slice(0, data.length - sliceLength);
if (typeof hexOrBytes === "string") {
if (data.length === 1 && dir === "right")
data = `${data}0`;
return `0x${data.length % 2 === 1 ? `0${data}` : data}`;
}
return data;
}
var init_trim = __esm({
"node_modules/viem/_esm/utils/data/trim.js"() {
}
});
// node_modules/viem/_esm/errors/data.js
var SliceOffsetOutOfBoundsError, SizeExceedsPaddingSizeError, InvalidBytesLengthError;
var init_data = __esm({
"node_modules/viem/_esm/errors/data.js"() {
init_base();
SliceOffsetOutOfBoundsError = class extends BaseError {
constructor({ offset, position, size: size3 }) {
super(`Slice ${position === "start" ? "starting" : "ending"} at offset "${offset}" is out-of-bounds (size: ${size3}).`);
Object.defineProperty(this, "name", {
enumerable: true,
configurable: true,
writable: true,
value: "SliceOffsetOutOfBoundsError"
});
}
};
SizeExceedsPaddingSizeError = class extends BaseError {
constructor({ size: size3, targetSize, type }) {
super(`${type.charAt(0).toUpperCase()}${type.slice(1).toLowerCase()} size (${size3}) exceeds padding size (${targetSize}).`);
Object.defineProperty(this, "name", {
enumerable: true,
configurable: true,
writable: true,
value: "SizeExceedsPaddingSizeError"
});
}
};
InvalidBytesLengthError = class extends BaseError {
constructor({ size: size3, targetSize, type }) {
super(`${type.charAt(0).toUpperCase()}${type.slice(1).toLowerCase()} is expected to be ${targetSize} ${type} long, but is ${size3} ${type} long.`);
Object.defineProperty(this, "name", {
enumerable: true,
configurable: true,
writable: true,
value: "InvalidBytesLengthError"
});
}
};
}
});
// node_modules/viem/_esm/utils/data/pad.js
function pad(hexOrBytes, { dir, size: size3 = 32 } = {}) {
if (typeof hexOrBytes === "string")
return padHex(hexOrBytes, { dir, size: size3 });
return padBytes(hexOrBytes, { dir, size: size3 });
}
function padHex(hex_, { dir, size: size3 = 32 } = {}) {
if (size3 === null)
return hex_;
const hex = hex_.replace("0x", "");
if (hex.length > size3 * 2)
throw new SizeExceedsPaddingSizeError({
size: Math.ceil(hex.length / 2),
targetSize: size3,
type: "hex"
});
return `0x${hex[dir === "right" ? "padEnd" : "padStart"](size3 * 2, "0")}`;
}
function padBytes(bytes2, { dir, size: size3 = 32 } = {}) {
if (size3 === null)
return bytes2;
if (bytes2.length > size3)
throw new SizeExceedsPaddingSizeError({
size: bytes2.length,
targetSize: size3,
type: "bytes"
});
const paddedBytes = new Uint8Array(size3);
for (let i = 0; i < size3; i++) {
const padEnd = dir === "right";
paddedBytes[padEnd ? i : size3 - i - 1] = bytes2[padEnd ? i : bytes2.length - i - 1];
}
return paddedBytes;
}
var init_pad = __esm({
"node_modules/viem/_esm/utils/data/pad.js"() {
init_data();
}
});
// node_modules/viem/_esm/utils/encoding/toHex.js
function toHex(value, opts = {}) {
if (typeof value === "number" || typeof value === "bigint")
return numberToHex(value, opts);
if (typeof value === "string") {
return stringToHex(value, opts);
}
if (typeof value === "boolean")
return boolToHex(value, opts);
return bytesToHex(value, opts);
}
function boolToHex(value, opts = {}) {
const hex = `0x${Number(value)}`;
if (typeof opts.size === "number") {
assertSize(hex, { size: opts.size });
return pad(hex, { size: opts.size });
}
return hex;
}
function bytesToHex(value, opts = {}) {
let string = "";
for (let i = 0; i < value.length; i++) {
string += hexes[value[i]];
}
const hex = `0x${string}`;
if (typeof opts.size === "number") {
assertSize(hex, { size: opts.size });
return pad(hex, { dir: "right", size: opts.size });
}
return hex;
}
function numberToHex(value_, opts = {}) {
const { signed, size: size3 } = opts;
const value = BigInt(value_);
let maxValue;
if (size3) {
if (signed)
maxValue = (1n << BigInt(size3) * 8n - 1n) - 1n;
else
maxValue = 2n ** (BigInt(size3) * 8n) - 1n;
} else if (typeof value_ === "number") {
maxValue = BigInt(Number.MAX_SAFE_INTEGER);
}
const minValue = typeof maxValue === "bigint" && signed ? -maxValue - 1n : 0;
if (maxValue && value > maxValue || value < minValue) {
const suffix = typeof value_ === "bigint" ? "n" : "";
throw new IntegerOutOfRangeError({
max: maxValue ? `${maxValue}${suffix}` : void 0,
min: `${minValue}${suffix}`,
signed,
size: size3,
value: `${value_}${suffix}`
});
}
const hex = `0x${(signed && value < 0 ? (1n << BigInt(size3 * 8)) + BigInt(value) : value).toString(16)}`;
if (size3)
return pad(hex, { size: size3 });
return hex;
}
function stringToHex(value_, opts = {}) {
const value = encoder.encode(value_);
return bytesToHex(value, opts);
}
var hexes, encoder;
var init_toHex = __esm({
"node_modules/viem/_esm/utils/encoding/toHex.js"() {
init_encoding();
init_pad();
init_fromHex();
hexes = /* @__PURE__ */ Array.from({ length: 256 }, (_v, i) => i.toString(16).padStart(2, "0"));
encoder = /* @__PURE__ */ new TextEncoder();
}
});
// node_modules/viem/_esm/utils/encoding/toBytes.js
function toBytes(value, opts = {}) {
if (typeof value === "number" || typeof value === "bigint")
return numberToBytes(value, opts);
if (typeof value === "boolean")
return boolToBytes(value, opts);
if (isHex(value))
return hexToBytes(value, opts);
return stringToBytes(value, opts);
}
function boolToBytes(value, opts = {}) {
const bytes2 = new Uint8Array(1);
bytes2[0] = Number(value);
if (typeof opts.size === "number") {
assertSize(bytes2, { size: opts.size });
return pad(bytes2, { size: opts.size });
}
return bytes2;
}
function charCodeToBase16(char) {
if (char >= charCodeMap.zero && char <= charCodeMap.nine)
return char - charCodeMap.zero;
if (char >= charCodeMap.A && char <= charCodeMap.F)
return char - (charCodeMap.A - 10);
if (char >= charCodeMap.a && char <= charCodeMap.f)
return char - (charCodeMap.a - 10);
return void 0;
}
function hexToBytes(hex_, opts = {}) {
let hex = hex_;
if (opts.size) {
assertSize(hex, { size: opts.size });
hex = pad(hex, { dir: "right", size: opts.size });
}
let hexString = hex.slice(2);
if (hexString.length % 2)
hexString = `0${hexString}`;
const length = hexString.length / 2;
const bytes2 = new Uint8Array(length);
for (let index2 = 0, j = 0; index2 < length; index2++) {
const nibbleLeft = charCodeToBase16(hexString.charCodeAt(j++));
const nibbleRight = charCodeToBase16(hexString.charCodeAt(j++));
if (nibbleLeft === void 0 || nibbleRight === void 0) {
throw new BaseError(`Invalid byte sequence ("${hexString[j - 2]}${hexString[j - 1]}" in "${hexString}").`);
}
bytes2[index2] = nibbleLeft * 16 + nibbleRight;
}
return bytes2;
}
function numberToBytes(value, opts) {
const hex = numberToHex(value, opts);
return hexToBytes(hex);
}
function stringToBytes(value, opts = {}) {
const bytes2 = encoder2.encode(value);
if (typeof opts.size === "number") {
assertSize(bytes2, { size: opts.size });
return pad(bytes2, { dir: "right", size: opts.size });
}
return bytes2;
}
var encoder2, charCodeMap;
var init_toBytes = __esm({
"node_modules/viem/_esm/utils/encoding/toBytes.js"() {
init_base();
init_isHex();
init_pad();
init_fromHex();
init_toHex();
encoder2 = /* @__PURE__ */ new TextEncoder();
charCodeMap = {
zero: 48,
nine: 57,
A: 65,
F: 70,
a: 97,
f: 102
};
}
});
// node_modules/viem/_esm/utils/encoding/fromHex.js
function assertSize(hexOrBytes, { size: size3 }) {
if (size(hexOrBytes) > size3)
throw new SizeOverflowError({
givenSize: size(hexOrBytes),
maxSize: size3
});
}
function hexToBigInt(hex, opts = {}) {
const { signed } = opts;
if (opts.size)
assertSize(hex, { size: opts.size });
const value = BigInt(hex);
if (!signed)
return value;
const size3 = (hex.length - 2) / 2;
const max = (1n << BigInt(size3) * 8n - 1n) - 1n;
if (value <= max)
return value;
return value - BigInt(`0x${"f".padStart(size3 * 2, "f")}`) - 1n;
}
function hexToNumber(hex, opts = {}) {
return Number(hexToBigInt(hex, opts));
}
var init_fromHex = __esm({
"node_modules/viem/_esm/utils/encoding/fromHex.js"() {
init_encoding();
init_size();
}
});
// node_modules/viem/_esm/utils/formatters/formatter.js
function defineFormatter(type, format) {
return ({ exclude, format: overrides }) => {
return {
exclude,
format: (args) => {
const formatted = format(args);
if (exclude) {
for (const key of exclude) {
delete formatted[key];
}
}
return {
...formatted,
...overrides(args)
};
},
type
};
};
}
var init_formatter = __esm({
"node_modules/viem/_esm/utils/formatters/formatter.js"() {
}
});
// node_modules/viem/_esm/errors/address.js
var InvalidAddressError;
var init_address = __esm({
"node_modules/viem/_esm/errors/address.js"() {
init_base();
InvalidAddressError = class extends BaseError {
constructor({ address }) {
super(`Address "${address}" is invalid.`, {
metaMessages: [
"- Address must be a hex value of 20 bytes (40 hex characters).",
"- Address must match its checksum counterpart."
]
});
Object.defineProperty(this, "name", {
enumerable: true,
configurable: true,
writable: true,
value: "InvalidAddressError"
});
}
};
}
});
// node_modules/viem/_esm/utils/lru.js
var LruMap;
var init_lru = __esm({
"node_modules/viem/_esm/utils/lru.js"() {
LruMap = class extends Map {
constructor(size3) {
super();
Object.defineProperty(this, "maxSize", {
enumerable: true,
configurable: true,
writable: true,
value: void 0
});
this.maxSize = size3;
}
set(key, value) {
super.set(key, value);
if (this.maxSize && this.size > this.maxSize)
this.delete(this.keys().next().value);
return this;
}
};
}
});
// node_modules/@noble/hashes/esm/_assert.js
function number(n) {
if (!Number.isSafeInteger(n) || n < 0)
throw new Error(`Wrong positive integer: ${n}`);
}
function bytes(b, ...lengths) {
if (!(b instanceof Uint8Array))
throw new Error("Expected Uint8Array");
if (lengths.length > 0 && !lengths.includes(b.length))
throw new Error(`Expected Uint8Array of length ${lengths}, not of length=${b.length}`);
}
function hash(hash3) {
if (typeof hash3 !== "function" || typeof hash3.create !== "function")
throw new Error("Hash should be wrapped by utils.wrapConstructor");
number(hash3.outputLen);
number(hash3.blockLen);
}
function exists(instance, checkFinished = true) {
if (instance.destroyed)
throw new Error("Hash instance has been destroyed");
if (checkFinished && instance.finished)
throw new Error("Hash#digest() has already been called");
}
function output(out, instance) {
bytes(out);
const min = instance.outputLen;
if (out.length < min) {
throw new Error(`digestInto() expects output buffer of length at least ${min}`);
}
}
var init_assert = __esm({
"node_modules/@noble/hashes/esm/_assert.js"() {
}
});
// node_modules/@noble/hashes/esm/_u64.js
function fromBig(n, le = false) {
if (le)
return { h: Number(n & U32_MASK64), l: Number(n >> _32n & U32_MASK64) };
return { h: Number(n >> _32n & U32_MASK64) | 0, l: Number(n & U32_MASK64) | 0 };
}
function split(lst, le = false) {
let Ah = new Uint32Array(lst.length);
let Al = new Uint32Array(lst.length);
for (let i = 0; i < lst.length; i++) {
const { h, l } = fromBig(lst[i], le);
[Ah[i], Al[i]] = [h, l];
}
return [Ah, Al];
}
var U32_MASK64, _32n, rotlSH, rotlSL, rotlBH, rotlBL;
var init_u64 = __esm({
"node_modules/@noble/hashes/esm/_u64.js"() {
U32_MASK64 = /* @__PURE__ */ BigInt(2 ** 32 - 1);
_32n = /* @__PURE__ */ BigInt(32);
rotlSH = (h, l, s) => h << s | l >>> 32 - s;
rotlSL = (h, l, s) => l << s | h >>> 32 - s;
rotlBH = (h, l, s) => l << s - 32 | h >>> 64 - s;
rotlBL = (h, l, s) => h << s - 32 | l >>> 64 - s;
}
});
// node_modules/@noble/hashes/esm/cryptoNode.js
var nc, crypto;
var init_cryptoNode = __esm({
"node_modules/@noble/hashes/esm/cryptoNode.js"() {
nc = __toESM(require("crypto"), 1);
crypto = nc && typeof nc === "object" && "webcrypto" in nc ? nc.webcrypto : void 0;
}
});
// node_modules/@noble/hashes/esm/utils.js
function utf8ToBytes(str) {
if (typeof str !== "string")
throw new Error(`utf8ToBytes expected string, got ${typeof str}`);
return new Uint8Array(new TextEncoder().encode(str));
}
function toBytes2(data) {
if (typeof data === "string")
data = utf8ToBytes(data);
if (!u8a(data))
throw new Error(`expected Uint8Array, got ${typeof data}`);
return data;
}
function concatBytes(...arrays) {
const r = new Uint8Array(arrays.reduce((sum, a) => sum + a.length, 0));
let pad2 = 0;
arrays.forEach((a) => {
if (!u8a(a))
throw new Error("Uint8Array expected");
r.set(a, pad2);
pad2 += a.length;
});
return r;
}
function wrapConstructor(hashCons) {
const hashC = (msg) => hashCons().update(toBytes2(msg)).digest();
const tmp = hashCons();
hashC.outputLen = tmp.outputLen;
hashC.blockLen = tmp.blockLen;
hashC.create = () => hashCons();
return hashC;
}
function wrapXOFConstructorWithOpts(hashCons) {
const hashC = (msg, opts) => hashCons(opts).update(toBytes2(msg)).digest();
const tmp = hashCons({});
hashC.outputLen = tmp.outputLen;
hashC.blockLen = tmp.blockLen;
hashC.create = (opts) => hashCons(opts);
return hashC;
}
function randomBytes(bytesLength = 32) {
if (crypto && typeof crypto.getRandomValues === "function") {
return crypto.getRandomValues(new Uint8Array(bytesLength));
}
throw new Error("crypto.getRandomValues must be defined");
}
var u8a, u32, createView, rotr, isLE, Hash, toStr;
var init_utils2 = __esm({
"node_modules/@noble/hashes/esm/utils.js"() {
init_cryptoNode();
u8a = (a) => a instanceof Uint8Array;
u32 = (arr) => new Uint32Array(arr.buffer, arr.byteOffset, Math.floor(arr.byteLength / 4));
createView = (arr) => new DataView(arr.buffer, arr.byteOffset, arr.byteLength);
rotr = (word, shift) => word << 32 - shift | word >>> shift;
isLE = new Uint8Array(new Uint32Array([287454020]).buffer)[0] === 68;
if (!isLE)
throw new Error("Non little-endian hardware is not supported");
Hash = class {
// Safe version that clones internal state
clone() {
return this._cloneInto();
}
};
toStr = {}.toString;
}
});
// node_modules/@noble/hashes/esm/sha3.js
function keccakP(s, rounds = 24) {
const B = new Uint32Array(5 * 2);
for (let round = 24 - rounds; round < 24; round++) {
for (let x = 0; x < 10; x++)
B[x] = s[x] ^ s[x + 10] ^ s[x + 20] ^ s[x + 30] ^ s[x + 40];
for (let x = 0; x < 10; x += 2) {
const idx1 = (x + 8) % 10;
const idx0 = (x + 2) % 10;
const B0 = B[idx0];
const B1 = B[idx0 + 1];
const Th = rotlH(B0, B1, 1) ^ B[idx1];
const Tl = rotlL(B0, B1, 1) ^ B[idx1 + 1];
for (let y = 0; y < 50; y += 10) {
s[x + y] ^= Th;
s[x + y + 1] ^= Tl;
}
}
let curH = s[2];
let curL = s[3];
for (let t = 0; t < 24; t++) {
const shift = SHA3_ROTL[t];
const Th = rotlH(curH, curL, shift);
const Tl = rotlL(curH, curL, shift);
const PI = SHA3_PI[t];
curH = s[PI];
curL = s[PI + 1];
s[PI] = Th;
s[PI + 1] = Tl;
}
for (let y = 0; y < 50; y += 10) {
for (let x = 0; x < 10; x++)
B[x] = s[y + x];
for (let x = 0; x < 10; x++)
s[y + x] ^= ~B[(x + 2) % 10] & B[(x + 4) % 10];
}
s[0] ^= SHA3_IOTA_H[round];
s[1] ^= SHA3_IOTA_L[round];
}
B.fill(0);
}
var SHA3_PI, SHA3_ROTL, _SHA3_IOTA, _0n, _1n, _2n, _7n, _256n, _0x71n, SHA3_IOTA_H, SHA3_IOTA_L, rotlH, rotlL, Keccak, gen, sha3_224, sha3_256, sha3_384, sha3_512, keccak_224, keccak_256, keccak_384, keccak_512, genShake, shake128, shake256;
var init_sha3 = __esm({
"node_modules/@noble/hashes/esm/sha3.js"() {
init_assert();
init_u64();
init_utils2();
[SHA3_PI, SHA3_ROTL, _SHA3_IOTA] = [[], [], []];
_0n = /* @__PURE__ */ BigInt(0);
_1n = /* @__PURE__ */ BigInt(1);
_2n = /* @__PURE__ */ BigInt(2);
_7n = /* @__PURE__ */ BigInt(7);
_256n = /* @__PURE__ */ BigInt(256);
_0x71n = /* @__PURE__ */ BigInt(113);
for (let round = 0, R = _1n, x = 1, y = 0; round < 24; round++) {
[x, y] = [y, (2 * x + 3 * y) % 5];
SHA3_PI.push(2 * (5 * y + x));
SHA3_ROTL.push((round + 1) * (round + 2) / 2 % 64);
let t = _0n;
for (let j = 0; j < 7; j++) {
R = (R << _1n ^ (R >> _7n) * _0x71n) % _256n;
if (R & _2n)
t ^= _1n << (_1n << /* @__PURE__ */ BigInt(j)) - _1n;
}
_SHA3_IOTA.push(t);
}
[SHA3_IOTA_H, SHA3_IOTA_L] = /* @__PURE__ */ split(_SHA3_IOTA, true);
rotlH = (h, l, s) => s > 32 ? rotlBH(h, l, s) : rotlSH(h, l, s);
rotlL = (h, l, s) => s > 32 ? rotlBL(h, l, s) : rotlSL(h, l, s);
Keccak = class _Keccak extends Hash {
// NOTE: we accept arguments in bytes instead of bits here.
constructor(blockLen, suffix, outputLen, enableXOF = false, rounds = 24) {
super();
this.blockLen = blockLen;
this.suffix = suffix;
this.outputLen = outputLen;
this.enableXOF = enableXOF;
this.rounds = rounds;
this.pos = 0;
this.posOut = 0;
this.finished = false;
this.destroyed = false;
number(outputLen);
if (0 >= this.blockLen || this.blockLen >= 200)
throw new Error("Sha3 supports only keccak-f1600 function");
this.state = new Uint8Array(200);
this.state32 = u32(this.state);
}
keccak() {
keccakP(this.state32, this.rounds);
this.posOut = 0;
this.pos = 0;
}
update(data) {
exists(this);
const { blockLen, state } = this;
data = toBytes2(data);
const len = data.length;
for (let pos = 0; pos < len; ) {
const take = Math.min(blockLen - this.pos, len - pos);
for (let i = 0; i < take; i++)
state[this.pos++] ^= data[pos++];
if (this.pos === blockLen)
this.keccak();
}
return this;
}
finish() {
if (this.finished)
return;
this.finished = true;
const { state, suffix, pos, blockLen } = this;
state[pos] ^= suffix;
if ((suffix & 128) !== 0 && pos === blockLen - 1)
this.keccak();
state[blockLen - 1] ^= 128;
this.keccak();
}
writeInto(out) {
exists(this, false);
bytes(out);
this.finish();
const bufferOut = this.state;
const { blockLen } = this;
for (let pos = 0, len = out.length; pos < len; ) {
if (this.posOut >= blockLen)
this.keccak();
const take = Math.min(blockLen - this.posOut, len - pos);
out.set(bufferOut.subarray(this.posOut, this.posOut + take), pos);
this.posOut += take;
pos += take;
}
return out;
}
xofInto(out) {
if (!this.enableXOF)
throw new Error("XOF is not possible for this instance");
return this.writeInto(out);
}
xof(bytes2) {
number(bytes2);
return this.xofInto(new Uint8Array(bytes2));
}
digestInto(out) {
output(out, this);
if (this.finished)
throw new Error("digest() was already called");
this.writeInto(out);
this.destroy();
return out;
}
digest() {
return this.digestInto(new Uint8Array(this.outputLen));
}
destroy() {
this.destroyed = true;
this.state.fill(0);
}
_cloneInto(to) {
const { blockLen, suffix, outputLen, rounds, enableXOF } = this;
to || (to = new _Keccak(blockLen, suffix, outputLen, enableXOF, rounds));
to.state32.set(this.state32);
to.pos = this.pos;
to.posOut = this.posOut;
to.finished = this.finished;
to.rounds = rounds;
to.suffix = suffix;
to.outputLen = outputLen;
to.enableXOF = enableXOF;
to.destroyed = this.destroyed;
return to;
}
};
gen = (suffix, blockLen, outputLen) => wrapConstructor(() => new Keccak(blockLen, suffix, outputLen));
sha3_224 = /* @__PURE__ */ gen(6, 144, 224 / 8);
sha3_256 = /* @__PURE__ */ gen(6, 136, 256 / 8);
sha3_384 = /* @__PURE__ */ gen(6, 104, 384 / 8);
sha3_512 = /* @__PURE__ */ gen(6, 72, 512 / 8);
keccak_224 = /* @__PURE__ */ gen(1, 144, 224 / 8);
keccak_256 = /* @__PURE__ */ gen(1, 136, 256 / 8);
keccak_384 = /* @__PURE__ */ gen(1, 104, 384 / 8);
keccak_512 = /* @__PURE__ */ gen(1, 72, 512 / 8);
genShake = (suffix, blockLen, outputLen) => wrapXOFConstructorWithOpts((opts = {}) => new Keccak(blockLen, suffix, opts.dkLen === void 0 ? outputLen : opts.dkLen, true));
shake128 = /* @__PURE__ */ genShake(31, 168, 128 / 8);
shake256 = /* @__PURE__ */ genShake(31, 136, 256 / 8);
}
});
// node_modules/viem/_esm/utils/hash/keccak256.js
function keccak256(value, to_) {
const to = to_ || "hex";
const bytes2 = keccak_256(isHex(value, { strict: false }) ? toBytes(value) : value);
if (to === "bytes")
return bytes2;
return toHex(bytes2);
}
var init_keccak256 = __esm({
"node_modules/viem/_esm/utils/hash/keccak256.js"() {
init_sha3();
init_isHex();
init_toBytes();
init_toHex();
}
});
// node_modules/viem/_esm/utils/address/getAddress.js
function checksumAddress(address_, chainId) {
if (checksumAddressCache.has(`${address_}.${chainId}`))
return checksumAddressCache.get(`${address_}.${chainId}`);
const hexAddress = chainId ? `${chainId}${address_.toLowerCase()}` : address_.substring(2).toLowerCase();
const hash3 = keccak256(stringToBytes(hexAddress), "bytes");
const address = (chainId ? hexAddress.substring(`${chainId}0x`.length) : hexAddress).split("");
for (let i = 0; i < 40; i += 2) {
if (hash3[i >> 1] >> 4 >= 8 && address[i]) {
address[i] = address[i].toUpperCase();
}
if ((hash3[i >> 1] & 15) >= 8 && address[i + 1]) {
address[i + 1] = address[i + 1].toUpperCase();
}
}
const result = `0x${address.join("")}`;
checksumAddressCache.set(`${address_}.${chainId}`, result);
return result;
}
function getAddress(address, chainId) {
if (!isAddress(address, { strict: false }))
throw new InvalidAddressError({ address });
return checksumAddress(address, chainId);
}
var checksumAddressCache;
var init_getAddress = __esm({
"node_modules/viem/_esm/utils/address/getAddress.js"() {
init_address();
init_toBytes();
init_keccak256();
init_lru();
init_isAddress();
checksumAddressCache = /* @__PURE__ */ new LruMap(8192);
}
});
// node_modules/viem/_esm/utils/address/isAddress.js
function isAddress(address, options) {
const { strict = true } = options ?? {};
const cacheKey2 = `${address}.${strict}`;
if (isAddressCache.has(cacheKey2))
return isAddressCache.get(cacheKey2);
const result = (() => {
if (!addressRegex.test(address))
return false;
if (address.toLowerCase() === address)
return true;
if (strict)
return checksumAddress(address) === address;
return true;
})();
isAddressCache.set(cacheKey2, result);
return result;
}
var addressRegex, isAddressCache;
var init_isAddress = __esm({
"node_modules/viem/_esm/utils/address/isAddress.js"() {
init_lru();
init_getAddress();
addressRegex = /^0x[a-fA-F0-9]{40}$/;
isAddressCache = /* @__PURE__ */ new LruMap(8192);
}
});
// node_modules/viem/_esm/utils/data/concat.js
function concat(values) {
if (typeof values[0] === "string")
return concatHex(values);
return concatBytes2(values);
}
function concatBytes2(values) {
let length = 0;
for (const arr of values) {
length += arr.length;
}
const result = new Uint8Array(length);
let offset = 0;
for (const arr of values) {
result.set(arr, offset);
offset += arr.length;
}
return result;
}
function concatHex(values) {
return `0x${values.reduce((acc, x) => acc + x.replace("0x", ""), "")}`;
}
var init_concat = __esm({
"node_modules/viem/_esm/utils/data/concat.js"() {
}
});
// node_modules/viem/_esm/errors/cursor.js
var NegativeOffsetError, PositionOutOfBoundsError, RecursiveReadLimitExceededError;
var init_cursor = __esm({
"node_modules/viem/_esm/errors/cursor.js"() {
init_base();
NegativeOffsetError = class extends BaseError {
constructor({ offset }) {
super(`Offset \`${offset}\` cannot be negative.`);
Object.defineProperty(this, "name", {
enumerable: true,
configurable: true,
writable: true,
value: "NegativeOffsetError"
});
}
};
PositionOutOfBoundsError = class extends BaseError {
constructor({ length, position }) {
super(`Position \`${position}\` is out of bounds (\`0 < position < ${length}\`).`);
Object.defineProperty(this, "name", {
enumerable: true,
configurable: true,
writable: true,
value: "PositionOutOfBoundsError"
});
}
};
RecursiveReadLimitExceededError = class extends BaseError {
constructor({ count, limit }) {
super(`Recursive read limit of \`${limit}\` exceeded (recursive read count: \`${count}\`).`);
Object.defineProperty(this, "name", {
enumerable: true,
configurable: true,
writable: true,
value: "RecursiveReadLimitExceededError"
});
}
};
}
});
// node_modules/viem/_esm/utils/cursor.js
function createCursor(bytes2, { recursiveReadLimit = 8192 } = {}) {
const cursor = Object.create(staticCursor);
cursor.bytes = bytes2;
cursor.dataView = new DataView(bytes2.buffer, bytes2.byteOffset, bytes2.byteLength);
cursor.positionReadCount = /* @__PURE__ */ new Map();
cursor.recursiveReadLimit = recursiveReadLimit;
return cursor;
}
var staticCursor;
var init_cursor2 = __esm({
"node_modules/viem/_esm/utils/cursor.js"() {
init_cursor();
staticCursor = {
bytes: new Uint8Array(),
dataView: new DataView(new ArrayBuffer(0)),
position: 0,
positionReadCount: /* @__PURE__ */ new Map(),
recursiveReadCount: 0,
recursiveReadLimit: Number.POSITIVE_INFINITY,
assertReadLimit() {
if (this.recursiveReadCount >= this.recursiveReadLimit)
throw new RecursiveReadLimitExceededError({
count: this.recursiveReadCount + 1,
limit: this.recursiveReadLimit
});
},
assertPosition(position) {
if (position < 0 || position > this.bytes.length - 1)
throw new PositionOutOfBoundsError({
length: this.bytes.length,
position
});
},
decrementPosition(offset) {
if (offset < 0)
throw new NegativeOffsetError({ offset });
const position = this.position - offset;
this.assertPosition(position);
this.position = position;
},
getReadCount(position) {
return this.positionReadCount.get(position || this.position) || 0;
},
incrementPosition(offset) {
if (offset < 0)
throw new NegativeOffsetError({ offset });
const position = this.position + offset;
this.assertPosition(position);
this.position = position;
},
inspectByte(position_) {
const position = position_ ?? this.position;
this.assertPosition(position);
return this.bytes[position];
},
inspectBytes(length, position_) {
const position = position_ ?? this.position;
this.assertPosition(position + length - 1);
return this.bytes.subarray(position, position + length);
},
inspectUint8(position_) {
const position = position_ ?? this.position;
this.assertPosition(position);
return this.bytes[position];
},
inspectUint16(position_) {
const position = position_ ?? this.position;
this.assertPosition(position + 1);
return this.dataView.getUint16(position);
},
inspectUint24(position_) {
const position = position_ ?? this.position;
this.assertPosition(position + 2);
return (this.dataView.getUint16(position) << 8) + this.dataView.getUint8(position + 2);
},
inspectUint32(position_) {
const position = position_ ?? this.position;
this.assertPosition(position + 3);
return this.dataView.getUint32(position);
},
pushByte(byte) {
this.assertPosition(this.position);
this.bytes[this.position] = byte;
this.position++;
},
pushBytes(bytes2) {
this.assertPosition(this.position + bytes2.length - 1);
this.bytes.set(bytes2, this.position);
this.position += bytes2.length;
},
pushUint8(value) {
this.assertPosition(this.position);
this.bytes[this.position] = value;
this.position++;
},
pushUint16(value) {
this.assertPosition(this.position + 1);
this.dataView.setUint16(this.position, value);
this.position += 2;
},
pushUint24(value) {
this.assertPosition(this.position + 2);
this.dataView.setUint16(this.position, value >> 8);
this.dataView.setUint8(this.position + 2, value & ~4294967040);
this.position += 3;
},
pushUint32(value) {
this.assertPosition(this.position + 3);
this.dataView.setUint32(this.position, value);
this.position += 4;
},
readByte() {
this.assertReadLimit();
this._touch();
const value = this.inspectByte();
this.position++;
return value;
},
readBytes(length, size3) {
this.assertReadLimit();
this._touch();
const value = this.inspectBytes(length);
this.position += size3 ?? length;
return value;
},
readUint8() {
this.assertReadLimit();
this._touch();
const value = this.inspectUint8();
this.position += 1;
return value;
},
readUint16() {
this.assertReadLimit();
this._touch();
const value = this.inspectUint16();
this.position += 2;
return value;
},
readUint24() {
this.assertReadLimit();
this._touch();
const value = this.inspectUint24();
this.position += 3;
return value;
},
readUint32() {
this.assertReadLimit();
this._touch();
const value = this.inspectUint32();
this.position += 4;
return value;
},
get remaining() {
return this.bytes.length - this.position;
},
setPosition(position) {
const oldPosition = this.position;
this.assertPosition(position);
this.position = position;
return () => this.position = oldPosition;
},
_touch() {
if (this.recursiveReadLimit === Number.POSITIVE_INFINITY)
return;
const count = this.getReadCount();
this.positionReadCount.set(this.position, count + 1);
if (count > 0)
this.recursiveReadCount++;
}
};
}
});
// node_modules/viem/_esm/constants/unit.js
var etherUnits, gweiUnits;
var init_unit = __esm({
"node_modules/viem/_esm/constants/unit.js"() {
etherUnits = {
gwei: 9,
wei: 18
};
gweiUnits = {
ether: -9,
wei: 9
};
}
});
// node_modules/viem/_esm/utils/unit/formatUnits.js
function formatUnits(value, decimals) {
let display = value.toString();
const negative = display.startsWith("-");
if (negative)
display = display.slice(1);
display = display.padStart(decimals, "0");
let [integer, fraction] = [
display.slice(0, display.length - decimals),
display.slice(display.length - decimals)
];
fraction = fraction.replace(/(0+)$/, "");
return `${negative ? "-" : ""}${integer || "0"}${fraction ? `.${fraction}` : ""}`;
}
var init_formatUnits = __esm({
"node_modules/viem/_esm/utils/unit/formatUnits.js"() {
}
});
// node_modules/viem/_esm/utils/unit/formatEther.js
function formatEther(wei, unit = "wei") {
return formatUnits(wei, etherUnits[unit]);
}
var init_formatEther = __esm({
"node_modules/viem/_esm/utils/unit/formatEther.js"() {
init_unit();
init_formatUnits();
}
});
// node_modules/viem/_esm/utils/unit/formatGwei.js
function formatGwei(wei, unit = "wei") {
return formatUnits(wei, gweiUnits[unit]);
}
var init_formatGwei = __esm({
"node_modules/viem/_esm/utils/unit/formatGwei.js"() {
init_unit();
init_formatUnits();
}
});
// node_modules/viem/_esm/errors/transaction.js
function prettyPrint(args) {
const entries = Object.entries(args).map(([key, value]) => {
if (value === void 0 || value === false)
return null;
return [key, value];
}).filter(Boolean);
const maxLength = entries.reduce((acc, [key]) => Math.max(acc, key.length), 0);
return entries.map(([key, value]) => ` ${`${key}:`.padEnd(maxLength + 1)} ${value}`).join("\n");
}
var FeeConflictError, InvalidLegacyVError, InvalidSerializableTransactionError, InvalidStorageKeySizeError, TransactionExecutionError, TransactionNotFoundError, TransactionReceiptNotFoundError, WaitForTransactionReceiptTimeoutError;
var init_transaction = __esm({
"node_modules/viem/_esm/errors/transaction.js"() {
init_formatEther();
init_formatGwei();
init_base();
FeeConflictError = class extends BaseError {
constructor() {
super([
"Cannot specify both a `gasPrice` and a `maxFeePerGas`/`maxPriorityFeePerGas`.",
"Use `maxFeePerGas`/`maxPriorityFeePerGas` for EIP-1559 compatible networks, and `gasPrice` for others."
].join("\n"));
Object.defineProperty(this, "name", {
enumerable: true,
configurable: true,
writable: true,
value: "FeeConflictError"
});
}
};
InvalidLegacyVError = class extends BaseError {
constructor({ v }) {
super(`Invalid \`v\` value "${v}". Expected 27 or 28.`);
Object.defineProperty(this, "name", {
enumerable: true,
configurable: true,
writable: true,
value: "InvalidLegacyVError"
});
}
};
InvalidSerializableTransactionError = class extends BaseError {
constructor({ transaction }) {
super("Cannot infer a transaction type from provided transaction.", {
metaMessages: [
"Provided Transaction:",
"{",
prettyPrint(transaction),
"}",
"",
"To infer the type, either provide:",
"- a `type` to the Transaction, or",
"- an EIP-1559 Transaction with `maxFeePerGas`, or",
"- an EIP-2930 Transaction with `gasPrice` & `accessList`, or",
"- an EIP-4844 Transaction with `blobs`, `blobVersionedHashes`, `sidecars`, or",
"- a Legacy Transaction with `gasPrice`"
]
});
Object.defineProperty(this, "name", {
enumerable: true,
configurable: true,
writable: true,
value: "InvalidSerializableTransactionError"
});
}
};
InvalidStorageKeySizeError = class extends BaseError {
constructor({ storageKey }) {
super(`Size for storage key "${storageKey}" is invalid. Expected 32 bytes. Got ${Math.floor((storageKey.length - 2) / 2)} bytes.`);
Object.defineProperty(this, "name", {
enumerable: true,
configurable: true,
writable: true,
value: "InvalidStorageKeySizeError"
});
}
};
TransactionExecutionError = class extends BaseError {
constructor(cause, { account, docsPath: docsPath6, chain, data, gas, gasPrice, maxFeePerGas, maxPriorityFeePerGas, nonce, to, value }) {
const prettyArgs = prettyPrint({
chain: chain && `${chain?.name} (id: ${chain?.id})`,
from: account?.address,
to,
value: typeof value !== "undefined" && `${formatEther(value)} ${chain?.nativeCurrency?.symbol || "ETH"}`,
data,
gas,
gasPrice: typeof gasPrice !== "undefined" && `${formatGwei(gasPrice)} gwei`,
maxFeePerGas: typeof maxFeePerGas !== "undefined" && `${formatGwei(maxFeePerGas)} gwei`,
maxPriorityFeePerGas: typeof maxPriorityFeePerGas !== "undefined" && `${formatGwei(maxPriorityFeePerGas)} gwei`,
nonce
});
super(cause.shortMessage, {
cause,
docsPath: docsPath6,
metaMessages: [
...cause.metaMessages ? [...cause.metaMessages, " "] : [],
"Request Arguments:",
prettyArgs
].filter(Boolean)
});
Object.defineProperty(this, "cause", {
enumerable: true,
configurable: true,
writable: true,
value: void 0
});
Object.defineProperty(this, "name", {
enumerable: true,
configurable: true,
writable: true,
value: "TransactionExecutionError"
});
this.cause = cause;
}
};
TransactionNotFoundError = class extends BaseError {
constructor({ blockHash, blockNumber, blockTag, hash: hash3, index: index2 }) {
let identifier = "Transaction";
if (blockTag && index2 !== void 0)
identifier = `Transaction at block time "${blockTag}" at index "${index2}"`;
if (blockHash && index2 !== void 0)
identifier = `Transaction at block hash "${blockHash}" at index "${index2}"`;
if (blockNumber && index2 !== void 0)
identifier = `Transaction at block number "${blockNumber}" at index "${index2}"`;
if (hash3)
identifier = `Transaction with hash "${hash3}"`;
super(`${identifier} could not be found.`);
Object.defineProperty(this, "name", {
enumerable: true,
configurable: true,
writable: true,
value: "TransactionNotFoundError"
});
}
};
TransactionReceiptNotFoundError = class extends BaseError {
constructor({ hash: hash3 }) {
super(`Transaction receipt with hash "${hash3}" could not be found. The Transaction may not be processed on a block yet.`);
Object.defineProperty(this, "name", {
enumerable: true,
configurable: true,
writable: true,
value: "TransactionReceiptNotFoundError"
});
}
};
WaitForTransactionReceiptTimeoutError = class extends BaseError {
constructor({ hash: hash3 }) {
super(`Timed out while waiting for transaction with hash "${hash3}" to be confirmed.`);
Object.defineProperty(this, "name", {
enumerable: true,
configurable: true,
writable: true,
value: "WaitForTransactionReceiptTimeoutError"
});
}
};
}
});
// node_modules/@noble/hashes/esm/_sha2.js
function setBigUint64(view, byteOffset, value, isLE2) {
if (typeof view.setBigUint64 === "function")
return view.setBigUint64(byteOffset, value, isLE2);
const _32n2 = BigInt(32);
const _u32_max = BigInt(4294967295);
const wh = Number(value >> _32n2 & _u32_max);
const wl = Number(value & _u32_max);
const h = isLE2 ? 4 : 0;
const l = isLE2 ? 0 : 4;
view.setUint32(byteOffset + h, wh, isLE2);
view.setUint32(byteOffset + l, wl, isLE2);
}
var SHA2;
var init_sha2 = __esm({
"node_modules/@noble/hashes/esm/_sha2.js"() {
init_assert();
init_utils2();
SHA2 = class extends Hash {
constructor(blockLen, outputLen, padOffset, isLE2) {
super();
this.blockLen = blockLen;
this.outputLen = outputLen;
this.padOffset = padOffset;
this.isLE = isLE2;
this.finished = false;
this.length = 0;
this.pos = 0;
this.destroyed = false;
this.buffer = new Uint8Array(blockLen);
this.view = createView(this.buffer);
}
update(data) {
exists(this);
const { view, buffer: buffer2, blockLen } = this;
data = toBytes2(data);
const len = data.length;
for (let pos = 0; pos < len; ) {
const take = Math.min(blockLen - this.pos, len - pos);
if (take === blockLen) {
const dataView = createView(data);
for (; blockLen <= len - pos; pos += blockLen)
this.process(dataView, pos);
continue;
}
buffer2.set(data.subarray(pos, pos + take), this.pos);
this.pos += take;
pos += take;
if (this.pos === blockLen) {
this.process(view, 0);
this.pos = 0;
}
}
this.length += data.length;
this.roundClean();
return this;
}
digestInto(out) {
exists(this);
output(out, this);
this.finished = true;
const { buffer: buffer2, view, blockLen, isLE: isLE2 } = this;
let { pos } = this;
buffer2[pos++] = 128;
this.buffer.subarray(pos).fill(0);
if (this.padOffset > blockLen - pos) {
this.process(view, 0);
pos = 0;
}
for (let i = pos; i < blockLen; i++)
buffer2[i] = 0;
setBigUint64(view, blockLen - 8, BigInt(this.length * 8), isLE2);
this.process(view, 0);
const o