@midcontract/sdk
Version:
Typescript SDK to interact with Midcontract contracts
1,641 lines • 682 kB
JavaScript
var $c = Object.defineProperty;
var Uc = (t, e, n) => e in t ? $c(t, e, { enumerable: !0, configurable: !0, writable: !0, value: n }) : t[e] = n;
var G = (t, e, n) => Uc(t, typeof e != "symbol" ? e + "" : e, n);
const zc = "1.0.8";
let we = class mr extends Error {
constructor(e, n = {}) {
var i;
const a = n.cause instanceof mr ? n.cause.details : (i = n.cause) != null && i.message ? n.cause.message : n.details, r = n.cause instanceof mr && n.cause.docsPath || n.docsPath, s = [
e || "An error occurred.",
"",
...n.metaMessages ? [...n.metaMessages, ""] : [],
...r ? [`Docs: https://abitype.dev${r}`] : [],
...a ? [`Details: ${a}`] : [],
`Version: abitype@${zc}`
].join(`
`);
super(s), Object.defineProperty(this, "details", {
enumerable: !0,
configurable: !0,
writable: !0,
value: void 0
}), Object.defineProperty(this, "docsPath", {
enumerable: !0,
configurable: !0,
writable: !0,
value: void 0
}), Object.defineProperty(this, "metaMessages", {
enumerable: !0,
configurable: !0,
writable: !0,
value: void 0
}), Object.defineProperty(this, "shortMessage", {
enumerable: !0,
configurable: !0,
writable: !0,
value: void 0
}), Object.defineProperty(this, "name", {
enumerable: !0,
configurable: !0,
writable: !0,
value: "AbiTypeError"
}), n.cause && (this.cause = n.cause), this.details = a, this.docsPath = r, this.metaMessages = n.metaMessages, this.shortMessage = e;
}
};
function Ke(t, e) {
const n = t.exec(e);
return n == null ? void 0 : n.groups;
}
const Qi = /^bytes([1-9]|1[0-9]|2[0-9]|3[0-2])?$/, eo = /^u?int(8|16|24|32|40|48|56|64|72|80|88|96|104|112|120|128|136|144|152|160|168|176|184|192|200|208|216|224|232|240|248|256)?$/, to = /^\(.+?\).*?$/, Ws = /^tuple(?<array>(\[(\d*)\])*)$/;
function fr(t) {
let e = t.type;
if (Ws.test(t.type) && "components" in t) {
e = "(";
const n = t.components.length;
for (let r = 0; r < n; r++) {
const s = t.components[r];
e += fr(s), r < n - 1 && (e += ", ");
}
const a = Ke(Ws, t.type);
return e += `)${(a == null ? void 0 : a.array) ?? ""}`, fr({
...t,
type: e
});
}
return "indexed" in t && t.indexed && (e = `${e} indexed`), t.name ? `${e} ${t.name}` : e;
}
function un(t) {
let e = "";
const n = t.length;
for (let a = 0; a < n; a++) {
const r = t[a];
e += fr(r), a !== n - 1 && (e += ", ");
}
return e;
}
function oa(t) {
var e;
return t.type === "function" ? `function ${t.name}(${un(t.inputs)})${t.stateMutability && t.stateMutability !== "nonpayable" ? ` ${t.stateMutability}` : ""}${(e = t.outputs) != null && e.length ? ` returns (${un(t.outputs)})` : ""}` : t.type === "event" ? `event ${t.name}(${un(t.inputs)})` : t.type === "error" ? `error ${t.name}(${un(t.inputs)})` : t.type === "constructor" ? `constructor(${un(t.inputs)})${t.stateMutability === "payable" ? " payable" : ""}` : t.type === "fallback" ? `fallback() external${t.stateMutability === "payable" ? " payable" : ""}` : "receive() external payable";
}
const no = /^error (?<name>[a-zA-Z$_][a-zA-Z0-9$_]*)\((?<parameters>.*?)\)$/;
function Lc(t) {
return no.test(t);
}
function qc(t) {
return Ke(no, t);
}
const ao = /^event (?<name>[a-zA-Z$_][a-zA-Z0-9$_]*)\((?<parameters>.*?)\)$/;
function Hc(t) {
return ao.test(t);
}
function jc(t) {
return Ke(ao, t);
}
const ro = /^function (?<name>[a-zA-Z$_][a-zA-Z0-9$_]*)\((?<parameters>.*?)\)(?: (?<scope>external|public{1}))?(?: (?<stateMutability>pure|view|nonpayable|payable{1}))?(?: returns\s?\((?<returns>.*?)\))?$/;
function Gc(t) {
return ro.test(t);
}
function Wc(t) {
return Ke(ro, t);
}
const so = /^struct (?<name>[a-zA-Z$_][a-zA-Z0-9$_]*) \{(?<properties>.*?)\}$/;
function as(t) {
return so.test(t);
}
function Vc(t) {
return Ke(so, t);
}
const io = /^constructor\((?<parameters>.*?)\)(?:\s(?<stateMutability>payable{1}))?$/;
function Zc(t) {
return io.test(t);
}
function Jc(t) {
return Ke(io, t);
}
const oo = /^fallback\(\) external(?:\s(?<stateMutability>payable{1}))?$/;
function Kc(t) {
return oo.test(t);
}
function Yc(t) {
return Ke(oo, t);
}
const Xc = /^receive\(\) external payable$/;
function Qc(t) {
return Xc.test(t);
}
const ed = /* @__PURE__ */ new Set(["indexed"]), hr = /* @__PURE__ */ new Set([
"calldata",
"memory",
"storage"
]);
class td extends we {
constructor({ signature: e }) {
super("Failed to parse ABI item.", {
details: `parseAbiItem(${JSON.stringify(e, null, 2)})`,
docsPath: "/api/human#parseabiitem-1"
}), Object.defineProperty(this, "name", {
enumerable: !0,
configurable: !0,
writable: !0,
value: "InvalidAbiItemError"
});
}
}
class nd extends we {
constructor({ type: e }) {
super("Unknown type.", {
metaMessages: [
`Type "${e}" is not a valid ABI type. Perhaps you forgot to include a struct signature?`
]
}), Object.defineProperty(this, "name", {
enumerable: !0,
configurable: !0,
writable: !0,
value: "UnknownTypeError"
});
}
}
class ad extends we {
constructor({ type: e }) {
super("Unknown type.", {
metaMessages: [`Type "${e}" is not a valid ABI type.`]
}), Object.defineProperty(this, "name", {
enumerable: !0,
configurable: !0,
writable: !0,
value: "UnknownSolidityTypeError"
});
}
}
class rd extends we {
constructor({ param: e }) {
super("Invalid ABI parameter.", {
details: e
}), Object.defineProperty(this, "name", {
enumerable: !0,
configurable: !0,
writable: !0,
value: "InvalidParameterError"
});
}
}
class sd extends we {
constructor({ param: e, name: n }) {
super("Invalid ABI parameter.", {
details: e,
metaMessages: [
`"${n}" is a protected Solidity keyword. More info: https://docs.soliditylang.org/en/latest/cheatsheet.html`
]
}), Object.defineProperty(this, "name", {
enumerable: !0,
configurable: !0,
writable: !0,
value: "SolidityProtectedKeywordError"
});
}
}
class id extends we {
constructor({ param: e, type: n, modifier: a }) {
super("Invalid ABI parameter.", {
details: e,
metaMessages: [
`Modifier "${a}" not allowed${n ? ` in "${n}" type` : ""}.`
]
}), Object.defineProperty(this, "name", {
enumerable: !0,
configurable: !0,
writable: !0,
value: "InvalidModifierError"
});
}
}
class od extends we {
constructor({ param: e, type: n, modifier: a }) {
super("Invalid ABI parameter.", {
details: e,
metaMessages: [
`Modifier "${a}" not allowed${n ? ` in "${n}" type` : ""}.`,
`Data location can only be specified for array, struct, or mapping types, but "${a}" was given.`
]
}), Object.defineProperty(this, "name", {
enumerable: !0,
configurable: !0,
writable: !0,
value: "InvalidFunctionModifierError"
});
}
}
class ud extends we {
constructor({ abiParameter: e }) {
super("Invalid ABI parameter.", {
details: JSON.stringify(e, null, 2),
metaMessages: ["ABI parameter type is invalid."]
}), Object.defineProperty(this, "name", {
enumerable: !0,
configurable: !0,
writable: !0,
value: "InvalidAbiTypeParameterError"
});
}
}
class Jt extends we {
constructor({ signature: e, type: n }) {
super(`Invalid ${n} signature.`, {
details: e
}), Object.defineProperty(this, "name", {
enumerable: !0,
configurable: !0,
writable: !0,
value: "InvalidSignatureError"
});
}
}
class cd extends we {
constructor({ signature: e }) {
super("Unknown signature.", {
details: e
}), Object.defineProperty(this, "name", {
enumerable: !0,
configurable: !0,
writable: !0,
value: "UnknownSignatureError"
});
}
}
class dd extends we {
constructor({ signature: e }) {
super("Invalid struct signature.", {
details: e,
metaMessages: ["No properties exist."]
}), Object.defineProperty(this, "name", {
enumerable: !0,
configurable: !0,
writable: !0,
value: "InvalidStructSignatureError"
});
}
}
class pd extends we {
constructor({ type: e }) {
super("Circular reference detected.", {
metaMessages: [`Struct "${e}" is a circular reference.`]
}), Object.defineProperty(this, "name", {
enumerable: !0,
configurable: !0,
writable: !0,
value: "CircularReferenceError"
});
}
}
class ld extends we {
constructor({ current: e, depth: n }) {
super("Unbalanced parentheses.", {
metaMessages: [
`"${e.trim()}" has too many ${n > 0 ? "opening" : "closing"} parentheses.`
],
details: `Depth "${n}"`
}), Object.defineProperty(this, "name", {
enumerable: !0,
configurable: !0,
writable: !0,
value: "InvalidParenthesisError"
});
}
}
function yd(t, e, n) {
let a = "";
if (n)
for (const r of Object.entries(n)) {
if (!r)
continue;
let s = "";
for (const i of r[1])
s += `[${i.type}${i.name ? `:${i.name}` : ""}]`;
a += `(${r[0]}{${s}})`;
}
return e ? `${e}:${t}${a}` : t;
}
const Ha = /* @__PURE__ */ new Map([
// Unnamed
["address", { type: "address" }],
["bool", { type: "bool" }],
["bytes", { type: "bytes" }],
["bytes32", { type: "bytes32" }],
["int", { type: "int256" }],
["int256", { type: "int256" }],
["string", { type: "string" }],
["uint", { type: "uint256" }],
["uint8", { type: "uint8" }],
["uint16", { type: "uint16" }],
["uint24", { type: "uint24" }],
["uint32", { type: "uint32" }],
["uint64", { type: "uint64" }],
["uint96", { type: "uint96" }],
["uint112", { type: "uint112" }],
["uint160", { type: "uint160" }],
["uint192", { type: "uint192" }],
["uint256", { type: "uint256" }],
// Named
["address owner", { type: "address", name: "owner" }],
["address to", { type: "address", name: "to" }],
["bool approved", { type: "bool", name: "approved" }],
["bytes _data", { type: "bytes", name: "_data" }],
["bytes data", { type: "bytes", name: "data" }],
["bytes signature", { type: "bytes", name: "signature" }],
["bytes32 hash", { type: "bytes32", name: "hash" }],
["bytes32 r", { type: "bytes32", name: "r" }],
["bytes32 root", { type: "bytes32", name: "root" }],
["bytes32 s", { type: "bytes32", name: "s" }],
["string name", { type: "string", name: "name" }],
["string symbol", { type: "string", name: "symbol" }],
["string tokenURI", { type: "string", name: "tokenURI" }],
["uint tokenId", { type: "uint256", name: "tokenId" }],
["uint8 v", { type: "uint8", name: "v" }],
["uint256 balance", { type: "uint256", name: "balance" }],
["uint256 tokenId", { type: "uint256", name: "tokenId" }],
["uint256 value", { type: "uint256", name: "value" }],
// Indexed
[
"event:address indexed from",
{ type: "address", name: "from", indexed: !0 }
],
["event:address indexed to", { type: "address", name: "to", indexed: !0 }],
[
"event:uint indexed tokenId",
{ type: "uint256", name: "tokenId", indexed: !0 }
],
[
"event:uint256 indexed tokenId",
{ type: "uint256", name: "tokenId", indexed: !0 }
]
]);
function br(t, e = {}) {
if (Gc(t))
return md(t, e);
if (Hc(t))
return fd(t, e);
if (Lc(t))
return hd(t, e);
if (Zc(t))
return bd(t, e);
if (Kc(t))
return wd(t);
if (Qc(t))
return {
type: "receive",
stateMutability: "payable"
};
throw new cd({ signature: t });
}
function md(t, e = {}) {
const n = Wc(t);
if (!n)
throw new Jt({ signature: t, type: "function" });
const a = _e(n.parameters), r = [], s = a.length;
for (let o = 0; o < s; o++)
r.push(ft(a[o], {
modifiers: hr,
structs: e,
type: "function"
}));
const i = [];
if (n.returns) {
const o = _e(n.returns), u = o.length;
for (let c = 0; c < u; c++)
i.push(ft(o[c], {
modifiers: hr,
structs: e,
type: "function"
}));
}
return {
name: n.name,
type: "function",
stateMutability: n.stateMutability ?? "nonpayable",
inputs: r,
outputs: i
};
}
function fd(t, e = {}) {
const n = jc(t);
if (!n)
throw new Jt({ signature: t, type: "event" });
const a = _e(n.parameters), r = [], s = a.length;
for (let i = 0; i < s; i++)
r.push(ft(a[i], {
modifiers: ed,
structs: e,
type: "event"
}));
return { name: n.name, type: "event", inputs: r };
}
function hd(t, e = {}) {
const n = qc(t);
if (!n)
throw new Jt({ signature: t, type: "error" });
const a = _e(n.parameters), r = [], s = a.length;
for (let i = 0; i < s; i++)
r.push(ft(a[i], { structs: e, type: "error" }));
return { name: n.name, type: "error", inputs: r };
}
function bd(t, e = {}) {
const n = Jc(t);
if (!n)
throw new Jt({ signature: t, type: "constructor" });
const a = _e(n.parameters), r = [], s = a.length;
for (let i = 0; i < s; i++)
r.push(ft(a[i], { structs: e, type: "constructor" }));
return {
type: "constructor",
stateMutability: n.stateMutability ?? "nonpayable",
inputs: r
};
}
function wd(t) {
const e = Yc(t);
if (!e)
throw new Jt({ signature: t, type: "fallback" });
return {
type: "fallback",
stateMutability: e.stateMutability ?? "nonpayable"
};
}
const gd = /^(?<type>[a-zA-Z$_][a-zA-Z0-9$_]*)(?<array>(?:\[\d*?\])+?)?(?:\s(?<modifier>calldata|indexed|memory|storage{1}))?(?:\s(?<name>[a-zA-Z$_][a-zA-Z0-9$_]*))?$/, Td = /^\((?<type>.+?)\)(?<array>(?:\[\d*?\])+?)?(?:\s(?<modifier>calldata|indexed|memory|storage{1}))?(?:\s(?<name>[a-zA-Z$_][a-zA-Z0-9$_]*))?$/, xd = /^u?int$/;
function ft(t, e) {
var p, l;
const n = yd(t, e == null ? void 0 : e.type, e == null ? void 0 : e.structs);
if (Ha.has(n))
return Ha.get(n);
const a = to.test(t), r = Ke(a ? Td : gd, t);
if (!r)
throw new rd({ param: t });
if (r.name && Ed(r.name))
throw new sd({ param: t, name: r.name });
const s = r.name ? { name: r.name } : {}, i = r.modifier === "indexed" ? { indexed: !0 } : {}, o = (e == null ? void 0 : e.structs) ?? {};
let u, c = {};
if (a) {
u = "tuple";
const y = _e(r.type), f = [], h = y.length;
for (let m = 0; m < h; m++)
f.push(ft(y[m], { structs: o }));
c = { components: f };
} else if (r.type in o)
u = "tuple", c = { components: o[r.type] };
else if (xd.test(r.type))
u = `${r.type}256`;
else if (u = r.type, (e == null ? void 0 : e.type) !== "struct" && !uo(u))
throw new ad({ type: u });
if (r.modifier) {
if (!((l = (p = e == null ? void 0 : e.modifiers) == null ? void 0 : p.has) != null && l.call(p, r.modifier)))
throw new id({
param: t,
type: e == null ? void 0 : e.type,
modifier: r.modifier
});
if (hr.has(r.modifier) && !_d(u, !!r.array))
throw new od({
param: t,
type: e == null ? void 0 : e.type,
modifier: r.modifier
});
}
const d = {
type: `${u}${r.array ?? ""}`,
...s,
...i,
...c
};
return Ha.set(n, d), d;
}
function _e(t, e = [], n = "", a = 0) {
const r = t.trim().length;
for (let s = 0; s < r; s++) {
const i = t[s], o = t.slice(s + 1);
switch (i) {
case ",":
return a === 0 ? _e(o, [...e, n.trim()]) : _e(o, e, `${n}${i}`, a);
case "(":
return _e(o, e, `${n}${i}`, a + 1);
case ")":
return _e(o, e, `${n}${i}`, a - 1);
default:
return _e(o, e, `${n}${i}`, a);
}
}
if (n === "")
return e;
if (a !== 0)
throw new ld({ current: n, depth: a });
return e.push(n.trim()), e;
}
function uo(t) {
return t === "address" || t === "bool" || t === "function" || t === "string" || Qi.test(t) || eo.test(t);
}
const vd = /^(?:after|alias|anonymous|apply|auto|byte|calldata|case|catch|constant|copyof|default|defined|error|event|external|false|final|function|immutable|implements|in|indexed|inline|internal|let|mapping|match|memory|mutable|null|of|override|partial|private|promise|public|pure|reference|relocatable|return|returns|sizeof|static|storage|struct|super|supports|switch|this|true|try|typedef|typeof|var|view|virtual)$/;
function Ed(t) {
return t === "address" || t === "bool" || t === "function" || t === "string" || t === "tuple" || Qi.test(t) || eo.test(t) || vd.test(t);
}
function _d(t, e) {
return e || t === "bytes" || t === "string" || t === "tuple";
}
function co(t) {
const e = {}, n = t.length;
for (let i = 0; i < n; i++) {
const o = t[i];
if (!as(o))
continue;
const u = Vc(o);
if (!u)
throw new Jt({ signature: o, type: "struct" });
const c = u.properties.split(";"), d = [], p = c.length;
for (let l = 0; l < p; l++) {
const f = c[l].trim();
if (!f)
continue;
const h = ft(f, {
type: "struct"
});
d.push(h);
}
if (!d.length)
throw new dd({ signature: o });
e[u.name] = d;
}
const a = {}, r = Object.entries(e), s = r.length;
for (let i = 0; i < s; i++) {
const [o, u] = r[i];
a[o] = po(u, e);
}
return a;
}
const Ad = /^(?<type>[a-zA-Z$_][a-zA-Z0-9$_]*)(?<array>(?:\[\d*?\])+?)?$/;
function po(t, e, n = /* @__PURE__ */ new Set()) {
const a = [], r = t.length;
for (let s = 0; s < r; s++) {
const i = t[s];
if (to.test(i.type))
a.push(i);
else {
const u = Ke(Ad, i.type);
if (!(u != null && u.type))
throw new ud({ abiParameter: i });
const { array: c, type: d } = u;
if (d in e) {
if (n.has(d))
throw new pd({ type: d });
a.push({
...i,
type: `tuple${c ?? ""}`,
components: po(e[d] ?? [], e, /* @__PURE__ */ new Set([...n, d]))
});
} else if (uo(d))
a.push(i);
else
throw new nd({ type: d });
}
}
return a;
}
function lo(t) {
const e = co(t), n = [], a = t.length;
for (let r = 0; r < a; r++) {
const s = t[r];
as(s) || n.push(br(s, e));
}
return n;
}
function Vs(t) {
let e;
if (typeof t == "string")
e = br(t);
else {
const n = co(t), a = t.length;
for (let r = 0; r < a; r++) {
const s = t[r];
if (!as(s)) {
e = br(s, n);
break;
}
}
}
if (!e)
throw new td({ signature: t });
return e;
}
function F(t, e, n) {
const a = t[e.name];
if (typeof a == "function")
return a;
const r = t[n];
return typeof r == "function" ? r : (s) => e(t, s);
}
function Ne(t, { includeName: e = !1 } = {}) {
if (t.type !== "function" && t.type !== "event" && t.type !== "error")
throw new Od(t.type);
return `${t.name}(${ma(t.inputs, { includeName: e })})`;
}
function ma(t, { includeName: e = !1 } = {}) {
return t ? t.map((n) => Id(n, { includeName: e })).join(e ? ", " : ",") : "";
}
function Id(t, { includeName: e }) {
return t.type.startsWith("tuple") ? `(${ma(t.components, { includeName: e })})${t.type.slice(5)}` : t.type + (e && t.name ? ` ${t.name}` : "");
}
function Be(t, { strict: e = !0 } = {}) {
return !t || typeof t != "string" ? !1 : e ? /^0x[0-9a-fA-F]*$/.test(t) : t.startsWith("0x");
}
function Q(t) {
return Be(t, { strict: !1 }) ? Math.ceil((t.length - 2) / 2) : t.length;
}
const yo = "2.24.1";
let cn = {
getDocsUrl: ({ docsBaseUrl: t, docsPath: e = "", docsSlug: n }) => e ? `${t ?? "https://viem.sh"}${e}${n ? `#${n}` : ""}` : void 0,
version: `viem@${yo}`
}, E = class wr extends Error {
constructor(e, n = {}) {
var o;
const a = (() => {
var u;
return n.cause instanceof wr ? n.cause.details : (u = n.cause) != null && u.message ? n.cause.message : n.details;
})(), r = n.cause instanceof wr && n.cause.docsPath || n.docsPath, s = (o = cn.getDocsUrl) == null ? void 0 : o.call(cn, { ...n, docsPath: r }), i = [
e || "An error occurred.",
"",
...n.metaMessages ? [...n.metaMessages, ""] : [],
...s ? [`Docs: ${s}`] : [],
...a ? [`Details: ${a}`] : [],
...cn.version ? [`Version: ${cn.version}`] : []
].join(`
`);
super(i, n.cause ? { cause: n.cause } : void 0), Object.defineProperty(this, "details", {
enumerable: !0,
configurable: !0,
writable: !0,
value: void 0
}), Object.defineProperty(this, "docsPath", {
enumerable: !0,
configurable: !0,
writable: !0,
value: void 0
}), Object.defineProperty(this, "metaMessages", {
enumerable: !0,
configurable: !0,
writable: !0,
value: void 0
}), Object.defineProperty(this, "shortMessage", {
enumerable: !0,
configurable: !0,
writable: !0,
value: void 0
}), Object.defineProperty(this, "version", {
enumerable: !0,
configurable: !0,
writable: !0,
value: void 0
}), Object.defineProperty(this, "name", {
enumerable: !0,
configurable: !0,
writable: !0,
value: "BaseError"
}), this.details = a, this.docsPath = r, this.metaMessages = n.metaMessages, this.name = n.name ?? this.name, this.shortMessage = e, this.version = yo;
}
walk(e) {
return mo(this, e);
}
};
function mo(t, e) {
return e != null && e(t) ? t : t && typeof t == "object" && "cause" in t && t.cause !== void 0 ? mo(t.cause, e) : e ? null : t;
}
class Md extends E {
constructor({ docsPath: e }) {
super([
"A constructor was not found on the ABI.",
"Make sure you are using the correct ABI and that the constructor exists on it."
].join(`
`), {
docsPath: e,
name: "AbiConstructorNotFoundError"
});
}
}
class Zs extends E {
constructor({ docsPath: e }) {
super([
"Constructor arguments were provided (`args`), but a constructor parameters (`inputs`) were not found on the ABI.",
"Make sure you are using the correct ABI, and that the `inputs` attribute on the constructor exists."
].join(`
`), {
docsPath: e,
name: "AbiConstructorParamsNotFoundError"
});
}
}
class fo extends E {
constructor({ data: e, params: n, size: a }) {
super([`Data size of ${a} bytes is too small for given parameters.`].join(`
`), {
metaMessages: [
`Params: (${ma(n, { includeName: !0 })})`,
`Data: ${e} (${a} bytes)`
],
name: "AbiDecodingDataSizeTooSmallError"
}), Object.defineProperty(this, "data", {
enumerable: !0,
configurable: !0,
writable: !0,
value: void 0
}), Object.defineProperty(this, "params", {
enumerable: !0,
configurable: !0,
writable: !0,
value: void 0
}), Object.defineProperty(this, "size", {
enumerable: !0,
configurable: !0,
writable: !0,
value: void 0
}), this.data = e, this.params = n, this.size = a;
}
}
class Bn extends E {
constructor() {
super('Cannot decode zero data ("0x") with ABI parameters.', {
name: "AbiDecodingZeroDataError"
});
}
}
class Sd extends E {
constructor({ expectedLength: e, givenLength: n, type: a }) {
super([
`ABI encoding array length mismatch for type ${a}.`,
`Expected length: ${e}`,
`Given length: ${n}`
].join(`
`), { name: "AbiEncodingArrayLengthMismatchError" });
}
}
class Cd extends E {
constructor({ expectedSize: e, value: n }) {
super(`Size of bytes "${n}" (bytes${Q(n)}) does not match expected size (bytes${e}).`, { name: "AbiEncodingBytesSizeMismatchError" });
}
}
class ho extends E {
constructor({ expectedLength: e, givenLength: n }) {
super([
"ABI encoding params/values length mismatch.",
`Expected length (params): ${e}`,
`Given length (values): ${n}`
].join(`
`), { name: "AbiEncodingLengthMismatchError" });
}
}
class bo extends E {
constructor(e, { docsPath: n }) {
super([
`Encoded error signature "${e}" not found on ABI.`,
"Make sure you are using the correct ABI and that the error exists on it.",
`You can look up the decoded signature here: https://openchain.xyz/signatures?query=${e}.`
].join(`
`), {
docsPath: n,
name: "AbiErrorSignatureNotFoundError"
}), Object.defineProperty(this, "signature", {
enumerable: !0,
configurable: !0,
writable: !0,
value: void 0
}), this.signature = e;
}
}
class Pd extends E {
constructor({ docsPath: e }) {
super("Cannot extract event signature from empty topics.", {
docsPath: e,
name: "AbiEventSignatureEmptyTopicsError"
});
}
}
class wo extends E {
constructor(e, { docsPath: n }) {
super([
`Encoded event signature "${e}" not found on ABI.`,
"Make sure you are using the correct ABI and that the event exists on it.",
`You can look up the signature here: https://openchain.xyz/signatures?query=${e}.`
].join(`
`), {
docsPath: n,
name: "AbiEventSignatureNotFoundError"
});
}
}
class Js extends E {
constructor(e, { docsPath: n } = {}) {
super([
`Event ${e ? `"${e}" ` : ""}not found on ABI.`,
"Make sure you are using the correct ABI and that the event exists on it."
].join(`
`), {
docsPath: n,
name: "AbiEventNotFoundError"
});
}
}
class ua extends E {
constructor(e, { docsPath: n } = {}) {
super([
`Function ${e ? `"${e}" ` : ""}not found on ABI.`,
"Make sure you are using the correct ABI and that the function exists on it."
].join(`
`), {
docsPath: n,
name: "AbiFunctionNotFoundError"
});
}
}
class Rd extends E {
constructor(e, { docsPath: n }) {
super([
`Function "${e}" does not contain any \`outputs\` on ABI.`,
"Cannot decode function result without knowing what the parameter types are.",
"Make sure you are using the correct ABI and that the function exists on it."
].join(`
`), {
docsPath: n,
name: "AbiFunctionOutputsNotFoundError"
});
}
}
class Nd extends E {
constructor(e, { docsPath: n }) {
super([
`Encoded function signature "${e}" not found on ABI.`,
"Make sure you are using the correct ABI and that the function exists on it.",
`You can look up the signature here: https://openchain.xyz/signatures?query=${e}.`
].join(`
`), {
docsPath: n,
name: "AbiFunctionSignatureNotFoundError"
});
}
}
class Bd extends E {
constructor(e, n) {
super("Found ambiguous types in overloaded ABI items.", {
metaMessages: [
`\`${e.type}\` in \`${Ne(e.abiItem)}\`, and`,
`\`${n.type}\` in \`${Ne(n.abiItem)}\``,
"",
"These types encode differently and cannot be distinguished at runtime.",
"Remove one of the ambiguous items in the ABI."
],
name: "AbiItemAmbiguityError"
});
}
}
let go = class extends E {
constructor({ expectedSize: e, givenSize: n }) {
super(`Expected bytes${e}, got bytes${n}.`, {
name: "BytesSizeMismatchError"
});
}
};
class mn extends E {
constructor({ abiItem: e, data: n, params: a, size: r }) {
super([
`Data size of ${r} bytes is too small for non-indexed event parameters.`
].join(`
`), {
metaMessages: [
`Params: (${ma(a, { includeName: !0 })})`,
`Data: ${n} (${r} bytes)`
],
name: "DecodeLogDataMismatch"
}), Object.defineProperty(this, "abiItem", {
enumerable: !0,
configurable: !0,
writable: !0,
value: void 0
}), Object.defineProperty(this, "data", {
enumerable: !0,
configurable: !0,
writable: !0,
value: void 0
}), Object.defineProperty(this, "params", {
enumerable: !0,
configurable: !0,
writable: !0,
value: void 0
}), Object.defineProperty(this, "size", {
enumerable: !0,
configurable: !0,
writable: !0,
value: void 0
}), this.abiItem = e, this.data = n, this.params = a, this.size = r;
}
}
class fa extends E {
constructor({ abiItem: e, param: n }) {
super([
`Expected a topic for indexed event parameter${n.name ? ` "${n.name}"` : ""} on event "${Ne(e, { includeName: !0 })}".`
].join(`
`), { name: "DecodeLogTopicsMismatch" }), Object.defineProperty(this, "abiItem", {
enumerable: !0,
configurable: !0,
writable: !0,
value: void 0
}), this.abiItem = e;
}
}
class kd extends E {
constructor(e, { docsPath: n }) {
super([
`Type "${e}" is not a valid encoding type.`,
"Please provide a valid ABI type."
].join(`
`), { docsPath: n, name: "InvalidAbiEncodingType" });
}
}
class Fd extends E {
constructor(e, { docsPath: n }) {
super([
`Type "${e}" is not a valid decoding type.`,
"Please provide a valid ABI type."
].join(`
`), { docsPath: n, name: "InvalidAbiDecodingType" });
}
}
let Dd = class extends E {
constructor(e) {
super([`Value "${e}" is not a valid array.`].join(`
`), {
name: "InvalidArrayError"
});
}
};
class Od extends E {
constructor(e) {
super([
`"${e}" is not a valid definition type.`,
'Valid types: "function", "event", "error"'
].join(`
`), { name: "InvalidDefinitionTypeError" });
}
}
class $d extends E {
constructor(e) {
super(`Type "${e}" is not supported for packed encoding.`, {
name: "UnsupportedPackedAbiType"
});
}
}
class Ud extends E {
constructor(e) {
super(`Filter type "${e}" is not supported.`, {
name: "FilterTypeNotSupportedError"
});
}
}
let To = class extends E {
constructor({ offset: e, position: n, size: a }) {
super(`Slice ${n === "start" ? "starting" : "ending"} at offset "${e}" is out-of-bounds (size: ${a}).`, { name: "SliceOffsetOutOfBoundsError" });
}
}, xo = class extends E {
constructor({ size: e, targetSize: n, type: a }) {
super(`${a.charAt(0).toUpperCase()}${a.slice(1).toLowerCase()} size (${e}) exceeds padding size (${n}).`, { name: "SizeExceedsPaddingSizeError" });
}
};
class Ks extends E {
constructor({ size: e, targetSize: n, type: a }) {
super(`${a.charAt(0).toUpperCase()}${a.slice(1).toLowerCase()} is expected to be ${n} ${a} long, but is ${e} ${a} long.`, { name: "InvalidBytesLengthError" });
}
}
function je(t, { dir: e, size: n = 32 } = {}) {
return typeof t == "string" ? tt(t, { dir: e, size: n }) : zd(t, { dir: e, size: n });
}
function tt(t, { dir: e, size: n = 32 } = {}) {
if (n === null)
return t;
const a = t.replace("0x", "");
if (a.length > n * 2)
throw new xo({
size: Math.ceil(a.length / 2),
targetSize: n,
type: "hex"
});
return `0x${a[e === "right" ? "padEnd" : "padStart"](n * 2, "0")}`;
}
function zd(t, { dir: e, size: n = 32 } = {}) {
if (n === null)
return t;
if (t.length > n)
throw new xo({
size: t.length,
targetSize: n,
type: "bytes"
});
const a = new Uint8Array(n);
for (let r = 0; r < n; r++) {
const s = e === "right";
a[s ? r : n - r - 1] = t[s ? r : t.length - r - 1];
}
return a;
}
let vo = class extends E {
constructor({ max: e, min: n, signed: a, size: r, value: s }) {
super(`Number "${s}" is not in safe ${r ? `${r * 8}-bit ${a ? "signed" : "unsigned"} ` : ""}integer range ${e ? `(${n} to ${e})` : `(above ${n})`}`, { name: "IntegerOutOfRangeError" });
}
};
class Ld extends E {
constructor(e) {
super(`Bytes value "${e}" is not a valid boolean. The bytes array must contain a single byte of either a 0 or 1 value.`, {
name: "InvalidBytesBooleanError"
});
}
}
class qd extends E {
constructor(e) {
super(`Hex value "${e}" is not a valid boolean. The hex value must be "0x0" (false) or "0x1" (true).`, { name: "InvalidHexBooleanError" });
}
}
let Hd = class extends E {
constructor({ givenSize: e, maxSize: n }) {
super(`Size cannot exceed ${n} bytes. Given size: ${e} bytes.`, { name: "SizeOverflowError" });
}
};
function ct(t, { dir: e = "left" } = {}) {
let n = typeof t == "string" ? t.replace("0x", "") : t, a = 0;
for (let r = 0; r < n.length - 1 && n[e === "left" ? r : n.length - r - 1].toString() === "0"; r++)
a++;
return n = e === "left" ? n.slice(a) : n.slice(0, n.length - a), typeof t == "string" ? (n.length === 1 && e === "right" && (n = `${n}0`), `0x${n.length % 2 === 1 ? `0${n}` : n}`) : n;
}
function Ie(t, { size: e }) {
if (Q(t) > e)
throw new Hd({
givenSize: Q(t),
maxSize: e
});
}
function ke(t, e = {}) {
const { signed: n } = e;
e.size && Ie(t, { size: e.size });
const a = BigInt(t);
if (!n)
return a;
const r = (t.length - 2) / 2, s = (1n << BigInt(r) * 8n - 1n) - 1n;
return a <= s ? a : a - BigInt(`0x${"f".padStart(r * 2, "f")}`) - 1n;
}
function jd(t, e = {}) {
let n = t;
if (e.size && (Ie(n, { size: e.size }), n = ct(n)), ct(n) === "0x00")
return !1;
if (ct(n) === "0x01")
return !0;
throw new qd(n);
}
function We(t, e = {}) {
return Number(ke(t, e));
}
const Gd = /* @__PURE__ */ Array.from({ length: 256 }, (t, e) => e.toString(16).padStart(2, "0"));
function pe(t, e = {}) {
return typeof t == "number" || typeof t == "bigint" ? k(t, e) : typeof t == "string" ? ht(t, e) : typeof t == "boolean" ? rs(t, e) : te(t, e);
}
function rs(t, e = {}) {
const n = `0x${Number(t)}`;
return typeof e.size == "number" ? (Ie(n, { size: e.size }), je(n, { size: e.size })) : n;
}
function te(t, e = {}) {
let n = "";
for (let r = 0; r < t.length; r++)
n += Gd[t[r]];
const a = `0x${n}`;
return typeof e.size == "number" ? (Ie(a, { size: e.size }), je(a, { dir: "right", size: e.size })) : a;
}
function k(t, e = {}) {
const { signed: n, size: a } = e, r = BigInt(t);
let s;
a ? n ? s = (1n << BigInt(a) * 8n - 1n) - 1n : s = 2n ** (BigInt(a) * 8n) - 1n : typeof t == "number" && (s = BigInt(Number.MAX_SAFE_INTEGER));
const i = typeof s == "bigint" && n ? -s - 1n : 0;
if (s && r > s || r < i) {
const u = typeof t == "bigint" ? "n" : "";
throw new vo({
max: s ? `${s}${u}` : void 0,
min: `${i}${u}`,
signed: n,
size: a,
value: `${t}${u}`
});
}
const o = `0x${(n && r < 0 ? (1n << BigInt(a * 8)) + BigInt(r) : r).toString(16)}`;
return a ? je(o, { size: a }) : o;
}
const Wd = /* @__PURE__ */ new TextEncoder();
function ht(t, e = {}) {
const n = Wd.encode(t);
return te(n, e);
}
const Vd = /* @__PURE__ */ new TextEncoder();
function Kt(t, e = {}) {
return typeof t == "number" || typeof t == "bigint" ? Jd(t, e) : typeof t == "boolean" ? Zd(t, e) : Be(t) ? Ae(t, e) : dt(t, e);
}
function Zd(t, e = {}) {
const n = new Uint8Array(1);
return n[0] = Number(t), typeof e.size == "number" ? (Ie(n, { size: e.size }), je(n, { size: e.size })) : n;
}
const Oe = {
zero: 48,
nine: 57,
A: 65,
F: 70,
a: 97,
f: 102
};
function Ys(t) {
if (t >= Oe.zero && t <= Oe.nine)
return t - Oe.zero;
if (t >= Oe.A && t <= Oe.F)
return t - (Oe.A - 10);
if (t >= Oe.a && t <= Oe.f)
return t - (Oe.a - 10);
}
function Ae(t, e = {}) {
let n = t;
e.size && (Ie(n, { size: e.size }), n = je(n, { dir: "right", size: e.size }));
let a = n.slice(2);
a.length % 2 && (a = `0${a}`);
const r = a.length / 2, s = new Uint8Array(r);
for (let i = 0, o = 0; i < r; i++) {
const u = Ys(a.charCodeAt(o++)), c = Ys(a.charCodeAt(o++));
if (u === void 0 || c === void 0)
throw new E(`Invalid byte sequence ("${a[o - 2]}${a[o - 1]}" in "${a}").`);
s[i] = u * 16 + c;
}
return s;
}
function Jd(t, e) {
const n = k(t, e);
return Ae(n);
}
function dt(t, e = {}) {
const n = Vd.encode(t);
return typeof e.size == "number" ? (Ie(n, { size: e.size }), je(n, { dir: "right", size: e.size })) : n;
}
function ca(t) {
if (!Number.isSafeInteger(t) || t < 0)
throw new Error("positive integer expected, got " + t);
}
function Kd(t) {
return t instanceof Uint8Array || ArrayBuffer.isView(t) && t.constructor.name === "Uint8Array";
}
function kn(t, ...e) {
if (!Kd(t))
throw new Error("Uint8Array expected");
if (e.length > 0 && !e.includes(t.length))
throw new Error("Uint8Array expected of length " + e + ", got length=" + t.length);
}
function Yd(t) {
if (typeof t != "function" || typeof t.create != "function")
throw new Error("Hash should be wrapped by utils.wrapConstructor");
ca(t.outputLen), ca(t.blockLen);
}
function qt(t, e = !0) {
if (t.destroyed)
throw new Error("Hash instance has been destroyed");
if (e && t.finished)
throw new Error("Hash#digest() has already been called");
}
function Eo(t, e) {
kn(t);
const n = e.outputLen;
if (t.length < n)
throw new Error("digestInto() expects output buffer of length at least " + n);
}
const Vn = /* @__PURE__ */ BigInt(2 ** 32 - 1), Xs = /* @__PURE__ */ BigInt(32);
function Xd(t, e = !1) {
return e ? { h: Number(t & Vn), l: Number(t >> Xs & Vn) } : { h: Number(t >> Xs & Vn) | 0, l: Number(t & Vn) | 0 };
}
function Qd(t, e = !1) {
let n = new Uint32Array(t.length), a = new Uint32Array(t.length);
for (let r = 0; r < t.length; r++) {
const { h: s, l: i } = Xd(t[r], e);
[n[r], a[r]] = [s, i];
}
return [n, a];
}
const ep = (t, e, n) => t << n | e >>> 32 - n, tp = (t, e, n) => e << n | t >>> 32 - n, np = (t, e, n) => e << n - 32 | t >>> 64 - n, ap = (t, e, n) => t << n - 32 | e >>> 64 - n, Rt = typeof globalThis == "object" && "crypto" in globalThis ? globalThis.crypto : void 0;
/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */
function rp(t) {
return new Uint32Array(t.buffer, t.byteOffset, Math.floor(t.byteLength / 4));
}
function ja(t) {
return new DataView(t.buffer, t.byteOffset, t.byteLength);
}
function Ce(t, e) {
return t << 32 - e | t >>> e;
}
const Qs = new Uint8Array(new Uint32Array([287454020]).buffer)[0] === 68;
function sp(t) {
return t << 24 & 4278190080 | t << 8 & 16711680 | t >>> 8 & 65280 | t >>> 24 & 255;
}
function ei(t) {
for (let e = 0; e < t.length; e++)
t[e] = sp(t[e]);
}
function ip(t) {
if (typeof t != "string")
throw new Error("utf8ToBytes expected string, got " + typeof t);
return new Uint8Array(new TextEncoder().encode(t));
}
function ha(t) {
return typeof t == "string" && (t = ip(t)), kn(t), t;
}
function op(...t) {
let e = 0;
for (let a = 0; a < t.length; a++) {
const r = t[a];
kn(r), e += r.length;
}
const n = new Uint8Array(e);
for (let a = 0, r = 0; a < t.length; a++) {
const s = t[a];
n.set(s, r), r += s.length;
}
return n;
}
class ss {
// Safe version that clones internal state
clone() {
return this._cloneInto();
}
}
function _o(t) {
const e = (a) => t().update(ha(a)).digest(), n = t();
return e.outputLen = n.outputLen, e.blockLen = n.blockLen, e.create = () => t(), e;
}
function up(t = 32) {
if (Rt && typeof Rt.getRandomValues == "function")
return Rt.getRandomValues(new Uint8Array(t));
if (Rt && typeof Rt.randomBytes == "function")
return Rt.randomBytes(t);
throw new Error("crypto.getRandomValues must be defined");
}
const Ao = [], Io = [], Mo = [], cp = /* @__PURE__ */ BigInt(0), dn = /* @__PURE__ */ BigInt(1), dp = /* @__PURE__ */ BigInt(2), pp = /* @__PURE__ */ BigInt(7), lp = /* @__PURE__ */ BigInt(256), yp = /* @__PURE__ */ BigInt(113);
for (let t = 0, e = dn, n = 1, a = 0; t < 24; t++) {
[n, a] = [a, (2 * n + 3 * a) % 5], Ao.push(2 * (5 * a + n)), Io.push((t + 1) * (t + 2) / 2 % 64);
let r = cp;
for (let s = 0; s < 7; s++)
e = (e << dn ^ (e >> pp) * yp) % lp, e & dp && (r ^= dn << (dn << /* @__PURE__ */ BigInt(s)) - dn);
Mo.push(r);
}
const [mp, fp] = /* @__PURE__ */ Qd(Mo, !0), ti = (t, e, n) => n > 32 ? np(t, e, n) : ep(t, e, n), ni = (t, e, n) => n > 32 ? ap(t, e, n) : tp(t, e, n);
function hp(t, e = 24) {
const n = new Uint32Array(10);
for (let a = 24 - e; a < 24; a++) {
for (let i = 0; i < 10; i++)
n[i] = t[i] ^ t[i + 10] ^ t[i + 20] ^ t[i + 30] ^ t[i + 40];
for (let i = 0; i < 10; i += 2) {
const o = (i + 8) % 10, u = (i + 2) % 10, c = n[u], d = n[u + 1], p = ti(c, d, 1) ^ n[o], l = ni(c, d, 1) ^ n[o + 1];
for (let y = 0; y < 50; y += 10)
t[i + y] ^= p, t[i + y + 1] ^= l;
}
let r = t[2], s = t[3];
for (let i = 0; i < 24; i++) {
const o = Io[i], u = ti(r, s, o), c = ni(r, s, o), d = Ao[i];
r = t[d], s = t[d + 1], t[d] = u, t[d + 1] = c;
}
for (let i = 0; i < 50; i += 10) {
for (let o = 0; o < 10; o++)
n[o] = t[i + o];
for (let o = 0; o < 10; o++)
t[i + o] ^= ~n[(o + 2) % 10] & n[(o + 4) % 10];
}
t[0] ^= mp[a], t[1] ^= fp[a];
}
n.fill(0);
}
class is extends ss {
// NOTE: we accept arguments in bytes instead of bits here.
constructor(e, n, a, r = !1, s = 24) {
if (super(), this.blockLen = e, this.suffix = n, this.outputLen = a, this.enableXOF = r, this.rounds = s, this.pos = 0, this.posOut = 0, this.finished = !1, this.destroyed = !1, ca(a), 0 >= this.blockLen || this.blockLen >= 200)
throw new Error("Sha3 supports only keccak-f1600 function");
this.state = new Uint8Array(200), this.state32 = rp(this.state);
}
keccak() {
Qs || ei(this.state32), hp(this.state32, this.rounds), Qs || ei(this.state32), this.posOut = 0, this.pos = 0;
}
update(e) {
qt(this);
const { blockLen: n, state: a } = this;
e = ha(e);
const r = e.length;
for (let s = 0; s < r; ) {
const i = Math.min(n - this.pos, r - s);
for (let o = 0; o < i; o++)
a[this.pos++] ^= e[s++];
this.pos === n && this.keccak();
}
return this;
}
finish() {
if (this.finished)
return;
this.finished = !0;
const { state: e, suffix: n, pos: a, blockLen: r } = this;
e[a] ^= n, n & 128 && a === r - 1 && this.keccak(), e[r - 1] ^= 128, this.keccak();
}
writeInto(e) {
qt(this, !1), kn(e), this.finish();
const n = this.state, { blockLen: a } = this;
for (let r = 0, s = e.length; r < s; ) {
this.posOut >= a && this.keccak();
const i = Math.min(a - this.posOut, s - r);
e.set(n.subarray(this.posOut, this.posOut + i), r), this.posOut += i, r += i;
}
return e;
}
xofInto(e) {
if (!this.enableXOF)
throw new Error("XOF is not possible for this instance");
return this.writeInto(e);
}
xof(e) {
return ca(e), this.xofInto(new Uint8Array(e));
}
digestInto(e) {
if (Eo(e, this), this.finished)
throw new Error("digest() was already called");
return this.writeInto(e), this.destroy(), e;
}
digest() {
return this.digestInto(new Uint8Array(this.outputLen));
}
destroy() {
this.destroyed = !0, this.state.fill(0);
}
_cloneInto(e) {
const { blockLen: n, suffix: a, outputLen: r, rounds: s, enableXOF: i } = this;
return e || (e = new is(n, a, r, i, s)), e.state32.set(this.state32), e.pos = this.pos, e.posOut = this.posOut, e.finished = this.finished, e.rounds = s, e.suffix = a, e.outputLen = r, e.enableXOF = i, e.destroyed = this.destroyed, e;
}
}
const bp = (t, e, n) => _o(() => new is(e, t, n)), So = /* @__PURE__ */ bp(1, 136, 256 / 8);
function se(t, e) {
const n = e || "hex", a = So(Be(t, { strict: !1 }) ? Kt(t) : t);
return n === "bytes" ? a : pe(a);
}
const wp = (t) => se(Kt(t));
function gp(t) {
return wp(t);
}
function Tp(t) {
let e = !0, n = "", a = 0, r = "", s = !1;
for (let i = 0; i < t.length; i++) {
const o = t[i];
if (["(", ")", ","].includes(o) && (e = !0), o === "(" && a++, o === ")" && a--, !!e) {
if (a === 0) {
if (o === " " && ["event", "function", ""].includes(r))
r = "";
else if (r += o, o === ")") {
s = !0;
break;
}
continue;
}
if (o === " ") {
t[i - 1] !== "," && n !== "," && n !== ",(" && (n = "", e = !1);
continue;
}
r += o, n += o;
}
}
if (!s)
throw new E("Unable to normalize signature.");
return r;
}
const xp = (t) => {
const e = typeof t == "string" ? t : oa(t);
return Tp(e);
};
function Co(t) {
return gp(xp(t));
}
const ba = Co;
let Ve = class extends E {
constructor({ address: e }) {
super(`Address "${e}" is invalid.`, {
metaMessages: [
"- Address must be a hex value of 20 bytes (40 hex characters).",
"- Address must match its checksum counterpart."
],
name: "InvalidAddressError"
});
}
}, wa = class extends Map {
constructor(e) {
super(), Object.defineProperty(this, "maxSize", {
enumerable: !0,
configurable: !0,
writable: !0,
value: void 0
}), this.maxSize = e;
}
get(e) {
const n = super.get(e);
return super.has(e) && n !== void 0 && (this.delete(e), super.set(e, n)), n;
}
set(e, n) {
if (super.set(e, n), this.maxSize && this.size > this.maxSize) {
const a = this.keys().next().value;
a && this.delete(a);
}
return this;
}
};
const Ga = /* @__PURE__ */ new wa(8192);
function Fn(t, e) {
if (Ga.has(`${t}.${e}`))
return Ga.get(`${t}.${e}`);
const n = t.substring(2).toLowerCase(), a = se(dt(n), "bytes"), r = n.split("");
for (let i = 0; i < 40; i += 2)
a[i >> 1] >> 4 >= 8 && r[i] && (r[i] = r[i].toUpperCase()), (a[i >> 1] & 15) >= 8 && r[i + 1] && (r[i + 1] = r[i + 1].toUpperCase());
const s = `0x${r.join("")}`;
return Ga.set(`${t}.${e}`, s), s;
}
function Po(t, e) {
if (!Te(t, { strict: !1 }))
throw new Ve({ address: t });
return Fn(t, e);
}
const vp = /^0x[a-fA-F0-9]{40}$/, Wa = /* @__PURE__ */ new wa(8192);
function Te(t, e) {
const { strict: n = !0 } = e ?? {}, a = `${t}.${n}`;
if (Wa.has(a))
return Wa.get(a);
const r = vp.test(t) ? t.toLowerCase() === t ? !0 : n ? Fn(t) === t : !0 : !1;
return Wa.set(a, r), r;
}
function Ze(t) {
return typeof t[0] == "string" ? _t(t) : Ep(t);
}
function Ep(t) {
let e = 0;
for (const r of t)
e += r.length;
const n = new Uint8Array(e);
let a = 0;
for (const r of t)
n.set(r, a), a += r.length;
return n;
}
function _t(t) {
return `0x${t.reduce((e, n) => e + n.replace("0x", ""), "")}`;
}
function Ht(t, e, n, { strict: a } = {}) {
return Be(t, { strict: !1 }) ? ko(t, e, n, {
strict: a
}) : Bo(t, e, n, {
strict: a
});
}
function Ro(t, e) {
if (typeof e == "number" && e > 0 && e > Q(t) - 1)
throw new To({
offset: e,
position: "start",
size: Q(t)
});
}
function No(t, e, n) {
if (typeof e == "number" && typeof n == "number" && Q(t) !== n - e)
throw new To({
offset: n,
position: "end",
size: Q(t)
});
}
function Bo(t, e, n, { strict: a } = {}) {
Ro(t, e);
const r = t.slice(e, n);
return a && No(r, e, n), r;
}
function ko(t, e, n, { strict: a } = {}) {
Ro(t, e);
const r = `0x${t.replace("0x", "").slice((e ?? 0) * 2, (n ?? t.length) * 2)}`;
return a && No(r, e, n), r;
}
const _p = /^(.*)\[([0-9]*)\]$/, Fo = /^bytes([1-9]|1[0-9]|2[0-9]|3[0-2])?$/, os = /^(u?int)(8|16|24|32|40|48|56|64|72|80|88|96|104|112|120|128|136|144|152|160|168|176|184|192|200|208|216|224|232|240|248|256)?$/;
function Yt(t, e) {
if (t.length !== e.length)
throw new ho({
expectedLength: t.length,
givenLength: e.length
});
const n = Ap({
params: t,
values: e
}), a = cs(n);
return a.length === 0 ? "0x" : a;
}
function Ap({ params: t, values: e }) {
const n = [];
for (let a = 0; a < t.length; a++)
n.push(us({ param: t[a], value: e[a] }));
return n;
}
function us({ param: t, value: e }) {
const n = ds(t.type);
if (n) {
const [a, r] = n;
return Mp(e, { length: a, param: { ...t, type: r } });
}
if (t.type === "tuple")
return Np(e, {
param: t
});
if (t.type === "address")
return Ip(e);
if (t.type === "bool")
return Cp(e);
if (t.type.startsWith("uint") || t.type.startsWith("int")) {
const a = t.type.startsWith("int"), [, , r = "256"] = os.exec(t.type) ?? [];
return Pp(e, {
signed: a,
size: Number(r)
});
}
if (t.type.startsWith("bytes"))
return Sp(e, { param: t });
if (t.type === "string")
return Rp(e);
throw new kd(t.type, {
docsPath: "/docs/contract/encodeAbiParameters"
});
}
function cs(t) {
let e = 0;
for (let s = 0; s < t.length; s++) {
const { dynamic: i, encoded: o } = t[s];
i ? e += 32 : e += Q(o);
}
const n = [], a = [];
let r = 0;
for (let s = 0; s < t.length; s++) {
const { dynamic: i, encoded: o } = t[s];
i ? (n.push(k(e + r, { size: 32 })), a.push(o), r += Q(o)) : n.push(o);
}
return Ze([...n, ...a]);
}
function Ip(t) {
if (!Te(t))
throw new Ve({ address: t });
return { dynamic: !1, encoded: tt(t.toLowerCase()) };
}
function Mp(t, { length: e, param: n }) {
const a = e === null;
if (!Array.isArray(t))
throw new Dd(t);
if (!a && t.length !== e)
throw new Sd({
expectedLength: e,
givenLength: t.length,
type: `${n.type}[${e}]`
});
let r = !1;
const s = [];
for (let i = 0; i < t.length; i++) {
const o = us({ param: n, value: t[i] });
o.dynamic && (r = !0), s.push(o);
}
if (a || r) {
const i = cs(s);
if (a) {
const o = k(s.length, { size: 32 });
return {
dynamic: !0,
encoded: s.length > 0 ? Ze([o, i]) : o
};
}
if (r)
return { dynamic: !0, encoded: i };
}
return {
dynamic: !1,
encoded: Ze(s.map(({ encoded: i }) => i))
};
}
function Sp(t, { param: e }) {
const [, n] = e.type.split("bytes"), a = Q(t);
if (!n) {
let r = t;
return a % 32 !== 0 && (r = tt(r, {
dir: "right",
size: Math.ceil((t.length - 2) / 2 / 32) * 32
})), {
dynamic: !0,
encoded: Ze([tt(k(a, { size: 32 })), r])
};
}
if (a !== Number.parseInt(n))
throw new Cd({
expectedSize: Number.parseInt(n),
value: t
});
return { dynamic: !1, encoded: tt(t, { dir: "right" }) };
}
f