New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@latticexyz/config

Package Overview
Dependencies
Maintainers
4
Versions
1614
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@latticexyz/config - npm Package Compare versions

Comparing version 2.0.0-alpha.1.19 to 2.0.0-alpha.1.20

1488

dist/index.js

@@ -1,1045 +0,581 @@

import { ZodIssueCode, z, ZodError } from "zod";
import { utils } from "ethers";
import { findUp } from "find-up";
import path from "path";
import chalk from "chalk";
import { fromZodError } from "zod-validation-error";
import esbuild from "esbuild";
import { rmSync } from "fs";
function validateName(name, ctx) {
if (!/^\w+$/.test(name)) {
ctx.addIssue({
code: ZodIssueCode.custom,
message: `Name must contain only alphanumeric & underscore characters`
});
}
import { ZodIssueCode as n, z as Y, ZodError as O } from "zod";
import { utils as M } from "ethers";
import { findUp as Z } from "find-up";
import U from "path";
import V from "chalk";
import { fromZodError as G } from "zod-validation-error";
import q from "esbuild";
import { rmSync as P } from "fs";
function b(A, t) {
/^\w+$/.test(A) || t.addIssue({
code: n.custom,
message: "Name must contain only alphanumeric & underscore characters"
});
}
function validateCapitalizedName(name, ctx) {
validateName(name, ctx);
if (!/^[A-Z]/.test(name)) {
ctx.addIssue({
code: ZodIssueCode.custom,
message: `Name must start with a capital letter`
});
}
function J(A, t) {
b(A, t), /^[A-Z]/.test(A) || t.addIssue({
code: n.custom,
message: "Name must start with a capital letter"
});
}
function validateUncapitalizedName(name, ctx) {
validateName(name, ctx);
if (!/^[a-z]/.test(name)) {
ctx.addIssue({
code: ZodIssueCode.custom,
message: `Name must start with a lowercase letter`
});
}
function H(A, t) {
b(A, t), /^[a-z]/.test(A) || t.addIssue({
code: n.custom,
message: "Name must start with a lowercase letter"
});
}
function validateEnum(members, ctx) {
if (members.length === 0) {
ctx.addIssue({
code: ZodIssueCode.custom,
message: `Enum must not be empty`
});
}
if (members.length >= 256) {
ctx.addIssue({
code: ZodIssueCode.custom,
message: `Length of enum must be < 256`
});
}
const duplicates = getDuplicates(members);
if (duplicates.length > 0) {
ctx.addIssue({
code: ZodIssueCode.custom,
message: `Enum must not have duplicate names for: ${duplicates.join(", ")}`
});
}
function Q(A, t) {
A.length === 0 && t.addIssue({
code: n.custom,
message: "Enum must not be empty"
}), A.length >= 256 && t.addIssue({
code: n.custom,
message: "Length of enum must be < 256"
});
const s = l(A);
s.length > 0 && t.addIssue({
code: n.custom,
message: `Enum must not have duplicate names for: ${s.join(", ")}`
});
}
function _factoryForValidateRoute(requireNonEmpty, requireSingleLevel) {
return (route, ctx) => {
if (route === "") {
if (requireNonEmpty) {
ctx.addIssue({
code: ZodIssueCode.custom,
message: `Route must not be empty`
});
}
function g(A, t) {
return (s, I) => {
if (s === "") {
A && I.addIssue({
code: n.custom,
message: "Route must not be empty"
});
return;
}
if (route[0] !== "/") {
ctx.addIssue({
code: ZodIssueCode.custom,
message: `Route must start with "/"`
s[0] !== "/" && I.addIssue({
code: n.custom,
message: 'Route must start with "/"'
}), s[s.length - 1] === "/" && I.addIssue({
code: n.custom,
message: 'Route must not end with "/"'
});
const i = s.split("/");
t && i.length > 2 && I.addIssue({
code: n.custom,
message: 'Route must only have one level (e.g. "/foo")'
});
for (let o = 1; o < i.length; o++)
i[o] === "" && I.addIssue({
code: n.custom,
message: 'Route must not contain empty route fragments (e.g. "//")'
}), /^\w+$/.test(i[o]) || I.addIssue({
code: n.custom,
message: "Route must contain only alphanumeric & underscore characters"
});
}
if (route[route.length - 1] === "/") {
ctx.addIssue({
code: ZodIssueCode.custom,
message: `Route must not end with "/"`
});
}
const parts = route.split("/");
if (requireSingleLevel && parts.length > 2) {
ctx.addIssue({
code: ZodIssueCode.custom,
message: `Route must only have one level (e.g. "/foo")`
});
}
for (let i = 1; i < parts.length; i++) {
if (parts[i] === "") {
ctx.addIssue({
code: ZodIssueCode.custom,
message: `Route must not contain empty route fragments (e.g. "//")`
});
}
if (!/^\w+$/.test(parts[i])) {
ctx.addIssue({
code: ZodIssueCode.custom,
message: `Route must contain only alphanumeric & underscore characters`
});
}
}
};
}
const validateRoute = _factoryForValidateRoute(true, false);
const validateBaseRoute = _factoryForValidateRoute(false, false);
const validateSingleLevelRoute = _factoryForValidateRoute(true, true);
function validateEthereumAddress(address, ctx) {
if (!utils.isAddress(address)) {
ctx.addIssue({
code: ZodIssueCode.custom,
message: `Address must be a valid Ethereum address`
});
}
const X = g(!0, !1), x = g(!1, !1), a = g(!0, !0);
function S(A, t) {
M.isAddress(A) || t.addIssue({
code: n.custom,
message: "Address must be a valid Ethereum address"
});
}
function getDuplicates(array) {
const checked = /* @__PURE__ */ new Set();
const duplicates = /* @__PURE__ */ new Set();
for (const element of array) {
if (checked.has(element)) {
duplicates.add(element);
}
checked.add(element);
}
return [...duplicates];
function l(A) {
const t = /* @__PURE__ */ new Set(), s = /* @__PURE__ */ new Set();
for (const I of A)
t.has(I) && s.add(I), t.add(I);
return [...s];
}
function validateSelector(name, ctx) {
if (name.length > 16) {
ctx.addIssue({
code: ZodIssueCode.custom,
message: `Selector must be <= 16 characters`
});
}
if (!/^\w*$/.test(name)) {
ctx.addIssue({
code: ZodIssueCode.custom,
message: `Selector must contain only alphanumeric & underscore characters`
});
}
function c(A, t) {
A.length > 16 && t.addIssue({
code: n.custom,
message: "Selector must be <= 16 characters"
}), /^\w*$/.test(A) || t.addIssue({
code: n.custom,
message: "Selector must contain only alphanumeric & underscore characters"
});
}
function parseStaticArray(abiType) {
const matches = abiType.match(/^(\w+)\[(\d+)\]$/);
if (!matches)
return null;
return {
elementType: matches[1],
staticLength: Number.parseInt(matches[2])
};
function m(A) {
const t = A.match(/^(\w+)\[(\d+)\]$/);
return t ? {
elementType: t[1],
staticLength: Number.parseInt(t[2])
} : null;
}
const zObjectName = z.string().superRefine(validateCapitalizedName);
const zValueName = z.string().superRefine(validateUncapitalizedName);
const zAnyCaseName = z.string().superRefine(validateName);
const zUserEnum = z.array(zObjectName).superRefine(validateEnum);
const zOrdinaryRoute = z.string().superRefine(validateRoute);
const zSingleLevelRoute = z.string().superRefine(validateSingleLevelRoute);
const zBaseRoute = z.string().superRefine(validateBaseRoute);
const zEthereumAddress = z.string().superRefine(validateEthereumAddress);
const zSelector = z.string().superRefine(validateSelector);
class MUDError extends Error {
const E = Y.string().superRefine(J), w = Y.string().superRefine(H), PA = Y.string().superRefine(b), y = Y.array(E).superRefine(Q), JA = Y.string().superRefine(X), HA = Y.string().superRefine(a), QA = Y.string().superRefine(x), p = Y.string().superRefine(S), B = Y.string().superRefine(c);
class h extends Error {
constructor() {
super(...arguments);
this.name = "MUDError";
super(...arguments), this.name = "MUDError";
}
}
function fromZodErrorCustom(error, prefix) {
return fromZodError(error, {
prefix: chalk.red(prefix),
prefixSeparator: "\n- ",
issueSeparator: "\n- "
function j(A, t) {
return G(A, {
prefix: V.red(t),
prefixSeparator: `
- `,
issueSeparator: `
- `
});
}
class NotInsideProjectError extends Error {
class AA extends Error {
constructor() {
super(...arguments);
this.name = "NotInsideProjectError";
this.message = "You are not inside a MUD project";
super(...arguments), this.name = "NotInsideProjectError", this.message = "You are not inside a MUD project";
}
}
function UnrecognizedSystemErrorFactory(path2, systemName) {
return new z.ZodError([{ code: ZodIssueCode.custom, path: path2, message: `Unrecognized system: "${systemName}"` }]);
function C(A, t) {
return new Y.ZodError([{ code: n.custom, path: A, message: `Unrecognized system: "${t}"` }]);
}
const configFiles = ["mud.config.js", "mud.config.mjs", "mud.config.ts", "mud.config.mts"];
const TEMP_CONFIG = "mud.config.temp.mjs";
async function loadConfig(configPath) {
configPath = await resolveConfigPath(configPath);
const RA = ["mud.config.js", "mud.config.mjs", "mud.config.ts", "mud.config.mts"], d = "mud.config.temp.mjs";
async function D(A) {
A = await z(A);
try {
await esbuild.build({ entryPoints: [configPath], format: "esm", outfile: TEMP_CONFIG });
configPath = await resolveConfigPath(TEMP_CONFIG);
return (await import(configPath)).default;
return await q.build({ entryPoints: [A], format: "esm", outfile: d }), A = await z(d), (await import(A)).default;
} finally {
rmSync(TEMP_CONFIG);
P(d);
}
}
async function resolveConfigPath(configPath) {
if (configPath === void 0) {
configPath = await getUserConfigPath();
} else {
if (!path.isAbsolute(configPath)) {
configPath = path.join(process.cwd(), configPath);
configPath = path.normalize(configPath);
}
}
return configPath;
async function z(A) {
return A === void 0 ? A = await tA() : U.isAbsolute(A) || (A = U.join(process.cwd(), A), A = U.normalize(A)), A;
}
async function getUserConfigPath() {
const tsConfigPath = await findUp(configFiles);
if (tsConfigPath === void 0) {
throw new NotInsideProjectError();
}
return tsConfigPath;
async function tA() {
const A = await Z(RA);
if (A === void 0)
throw new AA();
return A;
}
var SchemaType;
(function(SchemaType2) {
SchemaType2[SchemaType2["UINT8"] = 0] = "UINT8";
SchemaType2[SchemaType2["UINT16"] = 1] = "UINT16";
SchemaType2[SchemaType2["UINT24"] = 2] = "UINT24";
SchemaType2[SchemaType2["UINT32"] = 3] = "UINT32";
SchemaType2[SchemaType2["UINT40"] = 4] = "UINT40";
SchemaType2[SchemaType2["UINT48"] = 5] = "UINT48";
SchemaType2[SchemaType2["UINT56"] = 6] = "UINT56";
SchemaType2[SchemaType2["UINT64"] = 7] = "UINT64";
SchemaType2[SchemaType2["UINT72"] = 8] = "UINT72";
SchemaType2[SchemaType2["UINT80"] = 9] = "UINT80";
SchemaType2[SchemaType2["UINT88"] = 10] = "UINT88";
SchemaType2[SchemaType2["UINT96"] = 11] = "UINT96";
SchemaType2[SchemaType2["UINT104"] = 12] = "UINT104";
SchemaType2[SchemaType2["UINT112"] = 13] = "UINT112";
SchemaType2[SchemaType2["UINT120"] = 14] = "UINT120";
SchemaType2[SchemaType2["UINT128"] = 15] = "UINT128";
SchemaType2[SchemaType2["UINT136"] = 16] = "UINT136";
SchemaType2[SchemaType2["UINT144"] = 17] = "UINT144";
SchemaType2[SchemaType2["UINT152"] = 18] = "UINT152";
SchemaType2[SchemaType2["UINT160"] = 19] = "UINT160";
SchemaType2[SchemaType2["UINT168"] = 20] = "UINT168";
SchemaType2[SchemaType2["UINT176"] = 21] = "UINT176";
SchemaType2[SchemaType2["UINT184"] = 22] = "UINT184";
SchemaType2[SchemaType2["UINT192"] = 23] = "UINT192";
SchemaType2[SchemaType2["UINT200"] = 24] = "UINT200";
SchemaType2[SchemaType2["UINT208"] = 25] = "UINT208";
SchemaType2[SchemaType2["UINT216"] = 26] = "UINT216";
SchemaType2[SchemaType2["UINT224"] = 27] = "UINT224";
SchemaType2[SchemaType2["UINT232"] = 28] = "UINT232";
SchemaType2[SchemaType2["UINT240"] = 29] = "UINT240";
SchemaType2[SchemaType2["UINT248"] = 30] = "UINT248";
SchemaType2[SchemaType2["UINT256"] = 31] = "UINT256";
SchemaType2[SchemaType2["INT8"] = 32] = "INT8";
SchemaType2[SchemaType2["INT16"] = 33] = "INT16";
SchemaType2[SchemaType2["INT24"] = 34] = "INT24";
SchemaType2[SchemaType2["INT32"] = 35] = "INT32";
SchemaType2[SchemaType2["INT40"] = 36] = "INT40";
SchemaType2[SchemaType2["INT48"] = 37] = "INT48";
SchemaType2[SchemaType2["INT56"] = 38] = "INT56";
SchemaType2[SchemaType2["INT64"] = 39] = "INT64";
SchemaType2[SchemaType2["INT72"] = 40] = "INT72";
SchemaType2[SchemaType2["INT80"] = 41] = "INT80";
SchemaType2[SchemaType2["INT88"] = 42] = "INT88";
SchemaType2[SchemaType2["INT96"] = 43] = "INT96";
SchemaType2[SchemaType2["INT104"] = 44] = "INT104";
SchemaType2[SchemaType2["INT112"] = 45] = "INT112";
SchemaType2[SchemaType2["INT120"] = 46] = "INT120";
SchemaType2[SchemaType2["INT128"] = 47] = "INT128";
SchemaType2[SchemaType2["INT136"] = 48] = "INT136";
SchemaType2[SchemaType2["INT144"] = 49] = "INT144";
SchemaType2[SchemaType2["INT152"] = 50] = "INT152";
SchemaType2[SchemaType2["INT160"] = 51] = "INT160";
SchemaType2[SchemaType2["INT168"] = 52] = "INT168";
SchemaType2[SchemaType2["INT176"] = 53] = "INT176";
SchemaType2[SchemaType2["INT184"] = 54] = "INT184";
SchemaType2[SchemaType2["INT192"] = 55] = "INT192";
SchemaType2[SchemaType2["INT200"] = 56] = "INT200";
SchemaType2[SchemaType2["INT208"] = 57] = "INT208";
SchemaType2[SchemaType2["INT216"] = 58] = "INT216";
SchemaType2[SchemaType2["INT224"] = 59] = "INT224";
SchemaType2[SchemaType2["INT232"] = 60] = "INT232";
SchemaType2[SchemaType2["INT240"] = 61] = "INT240";
SchemaType2[SchemaType2["INT248"] = 62] = "INT248";
SchemaType2[SchemaType2["INT256"] = 63] = "INT256";
SchemaType2[SchemaType2["BYTES1"] = 64] = "BYTES1";
SchemaType2[SchemaType2["BYTES2"] = 65] = "BYTES2";
SchemaType2[SchemaType2["BYTES3"] = 66] = "BYTES3";
SchemaType2[SchemaType2["BYTES4"] = 67] = "BYTES4";
SchemaType2[SchemaType2["BYTES5"] = 68] = "BYTES5";
SchemaType2[SchemaType2["BYTES6"] = 69] = "BYTES6";
SchemaType2[SchemaType2["BYTES7"] = 70] = "BYTES7";
SchemaType2[SchemaType2["BYTES8"] = 71] = "BYTES8";
SchemaType2[SchemaType2["BYTES9"] = 72] = "BYTES9";
SchemaType2[SchemaType2["BYTES10"] = 73] = "BYTES10";
SchemaType2[SchemaType2["BYTES11"] = 74] = "BYTES11";
SchemaType2[SchemaType2["BYTES12"] = 75] = "BYTES12";
SchemaType2[SchemaType2["BYTES13"] = 76] = "BYTES13";
SchemaType2[SchemaType2["BYTES14"] = 77] = "BYTES14";
SchemaType2[SchemaType2["BYTES15"] = 78] = "BYTES15";
SchemaType2[SchemaType2["BYTES16"] = 79] = "BYTES16";
SchemaType2[SchemaType2["BYTES17"] = 80] = "BYTES17";
SchemaType2[SchemaType2["BYTES18"] = 81] = "BYTES18";
SchemaType2[SchemaType2["BYTES19"] = 82] = "BYTES19";
SchemaType2[SchemaType2["BYTES20"] = 83] = "BYTES20";
SchemaType2[SchemaType2["BYTES21"] = 84] = "BYTES21";
SchemaType2[SchemaType2["BYTES22"] = 85] = "BYTES22";
SchemaType2[SchemaType2["BYTES23"] = 86] = "BYTES23";
SchemaType2[SchemaType2["BYTES24"] = 87] = "BYTES24";
SchemaType2[SchemaType2["BYTES25"] = 88] = "BYTES25";
SchemaType2[SchemaType2["BYTES26"] = 89] = "BYTES26";
SchemaType2[SchemaType2["BYTES27"] = 90] = "BYTES27";
SchemaType2[SchemaType2["BYTES28"] = 91] = "BYTES28";
SchemaType2[SchemaType2["BYTES29"] = 92] = "BYTES29";
SchemaType2[SchemaType2["BYTES30"] = 93] = "BYTES30";
SchemaType2[SchemaType2["BYTES31"] = 94] = "BYTES31";
SchemaType2[SchemaType2["BYTES32"] = 95] = "BYTES32";
SchemaType2[SchemaType2["BOOL"] = 96] = "BOOL";
SchemaType2[SchemaType2["ADDRESS"] = 97] = "ADDRESS";
SchemaType2[SchemaType2["UINT8_ARRAY"] = 98] = "UINT8_ARRAY";
SchemaType2[SchemaType2["UINT16_ARRAY"] = 99] = "UINT16_ARRAY";
SchemaType2[SchemaType2["UINT24_ARRAY"] = 100] = "UINT24_ARRAY";
SchemaType2[SchemaType2["UINT32_ARRAY"] = 101] = "UINT32_ARRAY";
SchemaType2[SchemaType2["UINT40_ARRAY"] = 102] = "UINT40_ARRAY";
SchemaType2[SchemaType2["UINT48_ARRAY"] = 103] = "UINT48_ARRAY";
SchemaType2[SchemaType2["UINT56_ARRAY"] = 104] = "UINT56_ARRAY";
SchemaType2[SchemaType2["UINT64_ARRAY"] = 105] = "UINT64_ARRAY";
SchemaType2[SchemaType2["UINT72_ARRAY"] = 106] = "UINT72_ARRAY";
SchemaType2[SchemaType2["UINT80_ARRAY"] = 107] = "UINT80_ARRAY";
SchemaType2[SchemaType2["UINT88_ARRAY"] = 108] = "UINT88_ARRAY";
SchemaType2[SchemaType2["UINT96_ARRAY"] = 109] = "UINT96_ARRAY";
SchemaType2[SchemaType2["UINT104_ARRAY"] = 110] = "UINT104_ARRAY";
SchemaType2[SchemaType2["UINT112_ARRAY"] = 111] = "UINT112_ARRAY";
SchemaType2[SchemaType2["UINT120_ARRAY"] = 112] = "UINT120_ARRAY";
SchemaType2[SchemaType2["UINT128_ARRAY"] = 113] = "UINT128_ARRAY";
SchemaType2[SchemaType2["UINT136_ARRAY"] = 114] = "UINT136_ARRAY";
SchemaType2[SchemaType2["UINT144_ARRAY"] = 115] = "UINT144_ARRAY";
SchemaType2[SchemaType2["UINT152_ARRAY"] = 116] = "UINT152_ARRAY";
SchemaType2[SchemaType2["UINT160_ARRAY"] = 117] = "UINT160_ARRAY";
SchemaType2[SchemaType2["UINT168_ARRAY"] = 118] = "UINT168_ARRAY";
SchemaType2[SchemaType2["UINT176_ARRAY"] = 119] = "UINT176_ARRAY";
SchemaType2[SchemaType2["UINT184_ARRAY"] = 120] = "UINT184_ARRAY";
SchemaType2[SchemaType2["UINT192_ARRAY"] = 121] = "UINT192_ARRAY";
SchemaType2[SchemaType2["UINT200_ARRAY"] = 122] = "UINT200_ARRAY";
SchemaType2[SchemaType2["UINT208_ARRAY"] = 123] = "UINT208_ARRAY";
SchemaType2[SchemaType2["UINT216_ARRAY"] = 124] = "UINT216_ARRAY";
SchemaType2[SchemaType2["UINT224_ARRAY"] = 125] = "UINT224_ARRAY";
SchemaType2[SchemaType2["UINT232_ARRAY"] = 126] = "UINT232_ARRAY";
SchemaType2[SchemaType2["UINT240_ARRAY"] = 127] = "UINT240_ARRAY";
SchemaType2[SchemaType2["UINT248_ARRAY"] = 128] = "UINT248_ARRAY";
SchemaType2[SchemaType2["UINT256_ARRAY"] = 129] = "UINT256_ARRAY";
SchemaType2[SchemaType2["INT8_ARRAY"] = 130] = "INT8_ARRAY";
SchemaType2[SchemaType2["INT16_ARRAY"] = 131] = "INT16_ARRAY";
SchemaType2[SchemaType2["INT24_ARRAY"] = 132] = "INT24_ARRAY";
SchemaType2[SchemaType2["INT32_ARRAY"] = 133] = "INT32_ARRAY";
SchemaType2[SchemaType2["INT40_ARRAY"] = 134] = "INT40_ARRAY";
SchemaType2[SchemaType2["INT48_ARRAY"] = 135] = "INT48_ARRAY";
SchemaType2[SchemaType2["INT56_ARRAY"] = 136] = "INT56_ARRAY";
SchemaType2[SchemaType2["INT64_ARRAY"] = 137] = "INT64_ARRAY";
SchemaType2[SchemaType2["INT72_ARRAY"] = 138] = "INT72_ARRAY";
SchemaType2[SchemaType2["INT80_ARRAY"] = 139] = "INT80_ARRAY";
SchemaType2[SchemaType2["INT88_ARRAY"] = 140] = "INT88_ARRAY";
SchemaType2[SchemaType2["INT96_ARRAY"] = 141] = "INT96_ARRAY";
SchemaType2[SchemaType2["INT104_ARRAY"] = 142] = "INT104_ARRAY";
SchemaType2[SchemaType2["INT112_ARRAY"] = 143] = "INT112_ARRAY";
SchemaType2[SchemaType2["INT120_ARRAY"] = 144] = "INT120_ARRAY";
SchemaType2[SchemaType2["INT128_ARRAY"] = 145] = "INT128_ARRAY";
SchemaType2[SchemaType2["INT136_ARRAY"] = 146] = "INT136_ARRAY";
SchemaType2[SchemaType2["INT144_ARRAY"] = 147] = "INT144_ARRAY";
SchemaType2[SchemaType2["INT152_ARRAY"] = 148] = "INT152_ARRAY";
SchemaType2[SchemaType2["INT160_ARRAY"] = 149] = "INT160_ARRAY";
SchemaType2[SchemaType2["INT168_ARRAY"] = 150] = "INT168_ARRAY";
SchemaType2[SchemaType2["INT176_ARRAY"] = 151] = "INT176_ARRAY";
SchemaType2[SchemaType2["INT184_ARRAY"] = 152] = "INT184_ARRAY";
SchemaType2[SchemaType2["INT192_ARRAY"] = 153] = "INT192_ARRAY";
SchemaType2[SchemaType2["INT200_ARRAY"] = 154] = "INT200_ARRAY";
SchemaType2[SchemaType2["INT208_ARRAY"] = 155] = "INT208_ARRAY";
SchemaType2[SchemaType2["INT216_ARRAY"] = 156] = "INT216_ARRAY";
SchemaType2[SchemaType2["INT224_ARRAY"] = 157] = "INT224_ARRAY";
SchemaType2[SchemaType2["INT232_ARRAY"] = 158] = "INT232_ARRAY";
SchemaType2[SchemaType2["INT240_ARRAY"] = 159] = "INT240_ARRAY";
SchemaType2[SchemaType2["INT248_ARRAY"] = 160] = "INT248_ARRAY";
SchemaType2[SchemaType2["INT256_ARRAY"] = 161] = "INT256_ARRAY";
SchemaType2[SchemaType2["BYTES1_ARRAY"] = 162] = "BYTES1_ARRAY";
SchemaType2[SchemaType2["BYTES2_ARRAY"] = 163] = "BYTES2_ARRAY";
SchemaType2[SchemaType2["BYTES3_ARRAY"] = 164] = "BYTES3_ARRAY";
SchemaType2[SchemaType2["BYTES4_ARRAY"] = 165] = "BYTES4_ARRAY";
SchemaType2[SchemaType2["BYTES5_ARRAY"] = 166] = "BYTES5_ARRAY";
SchemaType2[SchemaType2["BYTES6_ARRAY"] = 167] = "BYTES6_ARRAY";
SchemaType2[SchemaType2["BYTES7_ARRAY"] = 168] = "BYTES7_ARRAY";
SchemaType2[SchemaType2["BYTES8_ARRAY"] = 169] = "BYTES8_ARRAY";
SchemaType2[SchemaType2["BYTES9_ARRAY"] = 170] = "BYTES9_ARRAY";
SchemaType2[SchemaType2["BYTES10_ARRAY"] = 171] = "BYTES10_ARRAY";
SchemaType2[SchemaType2["BYTES11_ARRAY"] = 172] = "BYTES11_ARRAY";
SchemaType2[SchemaType2["BYTES12_ARRAY"] = 173] = "BYTES12_ARRAY";
SchemaType2[SchemaType2["BYTES13_ARRAY"] = 174] = "BYTES13_ARRAY";
SchemaType2[SchemaType2["BYTES14_ARRAY"] = 175] = "BYTES14_ARRAY";
SchemaType2[SchemaType2["BYTES15_ARRAY"] = 176] = "BYTES15_ARRAY";
SchemaType2[SchemaType2["BYTES16_ARRAY"] = 177] = "BYTES16_ARRAY";
SchemaType2[SchemaType2["BYTES17_ARRAY"] = 178] = "BYTES17_ARRAY";
SchemaType2[SchemaType2["BYTES18_ARRAY"] = 179] = "BYTES18_ARRAY";
SchemaType2[SchemaType2["BYTES19_ARRAY"] = 180] = "BYTES19_ARRAY";
SchemaType2[SchemaType2["BYTES20_ARRAY"] = 181] = "BYTES20_ARRAY";
SchemaType2[SchemaType2["BYTES21_ARRAY"] = 182] = "BYTES21_ARRAY";
SchemaType2[SchemaType2["BYTES22_ARRAY"] = 183] = "BYTES22_ARRAY";
SchemaType2[SchemaType2["BYTES23_ARRAY"] = 184] = "BYTES23_ARRAY";
SchemaType2[SchemaType2["BYTES24_ARRAY"] = 185] = "BYTES24_ARRAY";
SchemaType2[SchemaType2["BYTES25_ARRAY"] = 186] = "BYTES25_ARRAY";
SchemaType2[SchemaType2["BYTES26_ARRAY"] = 187] = "BYTES26_ARRAY";
SchemaType2[SchemaType2["BYTES27_ARRAY"] = 188] = "BYTES27_ARRAY";
SchemaType2[SchemaType2["BYTES28_ARRAY"] = 189] = "BYTES28_ARRAY";
SchemaType2[SchemaType2["BYTES29_ARRAY"] = 190] = "BYTES29_ARRAY";
SchemaType2[SchemaType2["BYTES30_ARRAY"] = 191] = "BYTES30_ARRAY";
SchemaType2[SchemaType2["BYTES31_ARRAY"] = 192] = "BYTES31_ARRAY";
SchemaType2[SchemaType2["BYTES32_ARRAY"] = 193] = "BYTES32_ARRAY";
SchemaType2[SchemaType2["BOOL_ARRAY"] = 194] = "BOOL_ARRAY";
SchemaType2[SchemaType2["ADDRESS_ARRAY"] = 195] = "ADDRESS_ARRAY";
SchemaType2[SchemaType2["BYTES"] = 196] = "BYTES";
SchemaType2[SchemaType2["STRING"] = 197] = "STRING";
})(SchemaType || (SchemaType = {}));
function getStaticByteLength(schemaType) {
const val = schemaType.valueOf();
if (val < 32) {
return val + 1;
} else if (val < 64) {
return val + 1 - 32;
} else if (val < 96) {
return val + 1 - 64;
}
if (schemaType == SchemaType.BOOL) {
return 1;
} else if (schemaType == SchemaType.ADDRESS) {
return 20;
}
return 0;
var R;
(function(A) {
A[A.UINT8 = 0] = "UINT8", A[A.UINT16 = 1] = "UINT16", A[A.UINT24 = 2] = "UINT24", A[A.UINT32 = 3] = "UINT32", A[A.UINT40 = 4] = "UINT40", A[A.UINT48 = 5] = "UINT48", A[A.UINT56 = 6] = "UINT56", A[A.UINT64 = 7] = "UINT64", A[A.UINT72 = 8] = "UINT72", A[A.UINT80 = 9] = "UINT80", A[A.UINT88 = 10] = "UINT88", A[A.UINT96 = 11] = "UINT96", A[A.UINT104 = 12] = "UINT104", A[A.UINT112 = 13] = "UINT112", A[A.UINT120 = 14] = "UINT120", A[A.UINT128 = 15] = "UINT128", A[A.UINT136 = 16] = "UINT136", A[A.UINT144 = 17] = "UINT144", A[A.UINT152 = 18] = "UINT152", A[A.UINT160 = 19] = "UINT160", A[A.UINT168 = 20] = "UINT168", A[A.UINT176 = 21] = "UINT176", A[A.UINT184 = 22] = "UINT184", A[A.UINT192 = 23] = "UINT192", A[A.UINT200 = 24] = "UINT200", A[A.UINT208 = 25] = "UINT208", A[A.UINT216 = 26] = "UINT216", A[A.UINT224 = 27] = "UINT224", A[A.UINT232 = 28] = "UINT232", A[A.UINT240 = 29] = "UINT240", A[A.UINT248 = 30] = "UINT248", A[A.UINT256 = 31] = "UINT256", A[A.INT8 = 32] = "INT8", A[A.INT16 = 33] = "INT16", A[A.INT24 = 34] = "INT24", A[A.INT32 = 35] = "INT32", A[A.INT40 = 36] = "INT40", A[A.INT48 = 37] = "INT48", A[A.INT56 = 38] = "INT56", A[A.INT64 = 39] = "INT64", A[A.INT72 = 40] = "INT72", A[A.INT80 = 41] = "INT80", A[A.INT88 = 42] = "INT88", A[A.INT96 = 43] = "INT96", A[A.INT104 = 44] = "INT104", A[A.INT112 = 45] = "INT112", A[A.INT120 = 46] = "INT120", A[A.INT128 = 47] = "INT128", A[A.INT136 = 48] = "INT136", A[A.INT144 = 49] = "INT144", A[A.INT152 = 50] = "INT152", A[A.INT160 = 51] = "INT160", A[A.INT168 = 52] = "INT168", A[A.INT176 = 53] = "INT176", A[A.INT184 = 54] = "INT184", A[A.INT192 = 55] = "INT192", A[A.INT200 = 56] = "INT200", A[A.INT208 = 57] = "INT208", A[A.INT216 = 58] = "INT216", A[A.INT224 = 59] = "INT224", A[A.INT232 = 60] = "INT232", A[A.INT240 = 61] = "INT240", A[A.INT248 = 62] = "INT248", A[A.INT256 = 63] = "INT256", A[A.BYTES1 = 64] = "BYTES1", A[A.BYTES2 = 65] = "BYTES2", A[A.BYTES3 = 66] = "BYTES3", A[A.BYTES4 = 67] = "BYTES4", A[A.BYTES5 = 68] = "BYTES5", A[A.BYTES6 = 69] = "BYTES6", A[A.BYTES7 = 70] = "BYTES7", A[A.BYTES8 = 71] = "BYTES8", A[A.BYTES9 = 72] = "BYTES9", A[A.BYTES10 = 73] = "BYTES10", A[A.BYTES11 = 74] = "BYTES11", A[A.BYTES12 = 75] = "BYTES12", A[A.BYTES13 = 76] = "BYTES13", A[A.BYTES14 = 77] = "BYTES14", A[A.BYTES15 = 78] = "BYTES15", A[A.BYTES16 = 79] = "BYTES16", A[A.BYTES17 = 80] = "BYTES17", A[A.BYTES18 = 81] = "BYTES18", A[A.BYTES19 = 82] = "BYTES19", A[A.BYTES20 = 83] = "BYTES20", A[A.BYTES21 = 84] = "BYTES21", A[A.BYTES22 = 85] = "BYTES22", A[A.BYTES23 = 86] = "BYTES23", A[A.BYTES24 = 87] = "BYTES24", A[A.BYTES25 = 88] = "BYTES25", A[A.BYTES26 = 89] = "BYTES26", A[A.BYTES27 = 90] = "BYTES27", A[A.BYTES28 = 91] = "BYTES28", A[A.BYTES29 = 92] = "BYTES29", A[A.BYTES30 = 93] = "BYTES30", A[A.BYTES31 = 94] = "BYTES31", A[A.BYTES32 = 95] = "BYTES32", A[A.BOOL = 96] = "BOOL", A[A.ADDRESS = 97] = "ADDRESS", A[A.UINT8_ARRAY = 98] = "UINT8_ARRAY", A[A.UINT16_ARRAY = 99] = "UINT16_ARRAY", A[A.UINT24_ARRAY = 100] = "UINT24_ARRAY", A[A.UINT32_ARRAY = 101] = "UINT32_ARRAY", A[A.UINT40_ARRAY = 102] = "UINT40_ARRAY", A[A.UINT48_ARRAY = 103] = "UINT48_ARRAY", A[A.UINT56_ARRAY = 104] = "UINT56_ARRAY", A[A.UINT64_ARRAY = 105] = "UINT64_ARRAY", A[A.UINT72_ARRAY = 106] = "UINT72_ARRAY", A[A.UINT80_ARRAY = 107] = "UINT80_ARRAY", A[A.UINT88_ARRAY = 108] = "UINT88_ARRAY", A[A.UINT96_ARRAY = 109] = "UINT96_ARRAY", A[A.UINT104_ARRAY = 110] = "UINT104_ARRAY", A[A.UINT112_ARRAY = 111] = "UINT112_ARRAY", A[A.UINT120_ARRAY = 112] = "UINT120_ARRAY", A[A.UINT128_ARRAY = 113] = "UINT128_ARRAY", A[A.UINT136_ARRAY = 114] = "UINT136_ARRAY", A[A.UINT144_ARRAY = 115] = "UINT144_ARRAY", A[A.UINT152_ARRAY = 116] = "UINT152_ARRAY", A[A.UINT160_ARRAY = 117] = "UINT160_ARRAY", A[A.UINT168_ARRAY = 118] = "UINT168_ARRAY", A[A.UINT176_ARRAY = 119] = "UINT176_ARRAY", A[A.UINT184_ARRAY = 120] = "UINT184_ARRAY", A[A.UINT192_ARRAY = 121] = "UINT192_ARRAY", A[A.UINT200_ARRAY = 122] = "UINT200_ARRAY", A[A.UINT208_ARRAY = 123] = "UINT208_ARRAY", A[A.UINT216_ARRAY = 124] = "UINT216_ARRAY", A[A.UINT224_ARRAY = 125] = "UINT224_ARRAY", A[A.UINT232_ARRAY = 126] = "UINT232_ARRAY", A[A.UINT240_ARRAY = 127] = "UINT240_ARRAY", A[A.UINT248_ARRAY = 128] = "UINT248_ARRAY", A[A.UINT256_ARRAY = 129] = "UINT256_ARRAY", A[A.INT8_ARRAY = 130] = "INT8_ARRAY", A[A.INT16_ARRAY = 131] = "INT16_ARRAY", A[A.INT24_ARRAY = 132] = "INT24_ARRAY", A[A.INT32_ARRAY = 133] = "INT32_ARRAY", A[A.INT40_ARRAY = 134] = "INT40_ARRAY", A[A.INT48_ARRAY = 135] = "INT48_ARRAY", A[A.INT56_ARRAY = 136] = "INT56_ARRAY", A[A.INT64_ARRAY = 137] = "INT64_ARRAY", A[A.INT72_ARRAY = 138] = "INT72_ARRAY", A[A.INT80_ARRAY = 139] = "INT80_ARRAY", A[A.INT88_ARRAY = 140] = "INT88_ARRAY", A[A.INT96_ARRAY = 141] = "INT96_ARRAY", A[A.INT104_ARRAY = 142] = "INT104_ARRAY", A[A.INT112_ARRAY = 143] = "INT112_ARRAY", A[A.INT120_ARRAY = 144] = "INT120_ARRAY", A[A.INT128_ARRAY = 145] = "INT128_ARRAY", A[A.INT136_ARRAY = 146] = "INT136_ARRAY", A[A.INT144_ARRAY = 147] = "INT144_ARRAY", A[A.INT152_ARRAY = 148] = "INT152_ARRAY", A[A.INT160_ARRAY = 149] = "INT160_ARRAY", A[A.INT168_ARRAY = 150] = "INT168_ARRAY", A[A.INT176_ARRAY = 151] = "INT176_ARRAY", A[A.INT184_ARRAY = 152] = "INT184_ARRAY", A[A.INT192_ARRAY = 153] = "INT192_ARRAY", A[A.INT200_ARRAY = 154] = "INT200_ARRAY", A[A.INT208_ARRAY = 155] = "INT208_ARRAY", A[A.INT216_ARRAY = 156] = "INT216_ARRAY", A[A.INT224_ARRAY = 157] = "INT224_ARRAY", A[A.INT232_ARRAY = 158] = "INT232_ARRAY", A[A.INT240_ARRAY = 159] = "INT240_ARRAY", A[A.INT248_ARRAY = 160] = "INT248_ARRAY", A[A.INT256_ARRAY = 161] = "INT256_ARRAY", A[A.BYTES1_ARRAY = 162] = "BYTES1_ARRAY", A[A.BYTES2_ARRAY = 163] = "BYTES2_ARRAY", A[A.BYTES3_ARRAY = 164] = "BYTES3_ARRAY", A[A.BYTES4_ARRAY = 165] = "BYTES4_ARRAY", A[A.BYTES5_ARRAY = 166] = "BYTES5_ARRAY", A[A.BYTES6_ARRAY = 167] = "BYTES6_ARRAY", A[A.BYTES7_ARRAY = 168] = "BYTES7_ARRAY", A[A.BYTES8_ARRAY = 169] = "BYTES8_ARRAY", A[A.BYTES9_ARRAY = 170] = "BYTES9_ARRAY", A[A.BYTES10_ARRAY = 171] = "BYTES10_ARRAY", A[A.BYTES11_ARRAY = 172] = "BYTES11_ARRAY", A[A.BYTES12_ARRAY = 173] = "BYTES12_ARRAY", A[A.BYTES13_ARRAY = 174] = "BYTES13_ARRAY", A[A.BYTES14_ARRAY = 175] = "BYTES14_ARRAY", A[A.BYTES15_ARRAY = 176] = "BYTES15_ARRAY", A[A.BYTES16_ARRAY = 177] = "BYTES16_ARRAY", A[A.BYTES17_ARRAY = 178] = "BYTES17_ARRAY", A[A.BYTES18_ARRAY = 179] = "BYTES18_ARRAY", A[A.BYTES19_ARRAY = 180] = "BYTES19_ARRAY", A[A.BYTES20_ARRAY = 181] = "BYTES20_ARRAY", A[A.BYTES21_ARRAY = 182] = "BYTES21_ARRAY", A[A.BYTES22_ARRAY = 183] = "BYTES22_ARRAY", A[A.BYTES23_ARRAY = 184] = "BYTES23_ARRAY", A[A.BYTES24_ARRAY = 185] = "BYTES24_ARRAY", A[A.BYTES25_ARRAY = 186] = "BYTES25_ARRAY", A[A.BYTES26_ARRAY = 187] = "BYTES26_ARRAY", A[A.BYTES27_ARRAY = 188] = "BYTES27_ARRAY", A[A.BYTES28_ARRAY = 189] = "BYTES28_ARRAY", A[A.BYTES29_ARRAY = 190] = "BYTES29_ARRAY", A[A.BYTES30_ARRAY = 191] = "BYTES30_ARRAY", A[A.BYTES31_ARRAY = 192] = "BYTES31_ARRAY", A[A.BYTES32_ARRAY = 193] = "BYTES32_ARRAY", A[A.BOOL_ARRAY = 194] = "BOOL_ARRAY", A[A.ADDRESS_ARRAY = 195] = "ADDRESS_ARRAY", A[A.BYTES = 196] = "BYTES", A[A.STRING = 197] = "STRING";
})(R || (R = {}));
function YA(A) {
const t = A.valueOf();
return t < 32 ? t + 1 : t < 64 ? t + 1 - 32 : t < 96 ? t + 1 - 64 : A == R.BOOL ? 1 : A == R.ADDRESS ? 20 : 0;
}
({
[SchemaType.UINT8_ARRAY]: SchemaType.UINT8,
[SchemaType.UINT16_ARRAY]: SchemaType.UINT16,
[SchemaType.UINT24_ARRAY]: SchemaType.UINT24,
[SchemaType.UINT32_ARRAY]: SchemaType.UINT32,
[SchemaType.UINT40_ARRAY]: SchemaType.UINT40,
[SchemaType.UINT48_ARRAY]: SchemaType.UINT48,
[SchemaType.UINT56_ARRAY]: SchemaType.UINT56,
[SchemaType.UINT64_ARRAY]: SchemaType.UINT64,
[SchemaType.UINT72_ARRAY]: SchemaType.UINT72,
[SchemaType.UINT80_ARRAY]: SchemaType.UINT80,
[SchemaType.UINT88_ARRAY]: SchemaType.UINT88,
[SchemaType.UINT96_ARRAY]: SchemaType.UINT96,
[SchemaType.UINT104_ARRAY]: SchemaType.UINT104,
[SchemaType.UINT112_ARRAY]: SchemaType.UINT112,
[SchemaType.UINT120_ARRAY]: SchemaType.UINT120,
[SchemaType.UINT128_ARRAY]: SchemaType.UINT128,
[SchemaType.UINT136_ARRAY]: SchemaType.UINT136,
[SchemaType.UINT144_ARRAY]: SchemaType.UINT144,
[SchemaType.UINT152_ARRAY]: SchemaType.UINT152,
[SchemaType.UINT160_ARRAY]: SchemaType.UINT160,
[SchemaType.UINT168_ARRAY]: SchemaType.UINT168,
[SchemaType.UINT176_ARRAY]: SchemaType.UINT176,
[SchemaType.UINT184_ARRAY]: SchemaType.UINT184,
[SchemaType.UINT192_ARRAY]: SchemaType.UINT192,
[SchemaType.UINT200_ARRAY]: SchemaType.UINT200,
[SchemaType.UINT208_ARRAY]: SchemaType.UINT208,
[SchemaType.UINT216_ARRAY]: SchemaType.UINT216,
[SchemaType.UINT224_ARRAY]: SchemaType.UINT224,
[SchemaType.UINT232_ARRAY]: SchemaType.UINT232,
[SchemaType.UINT240_ARRAY]: SchemaType.UINT240,
[SchemaType.UINT248_ARRAY]: SchemaType.UINT248,
[SchemaType.UINT256_ARRAY]: SchemaType.UINT256,
[SchemaType.INT8_ARRAY]: SchemaType.INT8,
[SchemaType.INT16_ARRAY]: SchemaType.INT16,
[SchemaType.INT24_ARRAY]: SchemaType.INT24,
[SchemaType.INT32_ARRAY]: SchemaType.INT32,
[SchemaType.INT40_ARRAY]: SchemaType.INT40,
[SchemaType.INT48_ARRAY]: SchemaType.INT48,
[SchemaType.INT56_ARRAY]: SchemaType.INT56,
[SchemaType.INT64_ARRAY]: SchemaType.INT64,
[SchemaType.INT72_ARRAY]: SchemaType.INT72,
[SchemaType.INT80_ARRAY]: SchemaType.INT80,
[SchemaType.INT88_ARRAY]: SchemaType.INT88,
[SchemaType.INT96_ARRAY]: SchemaType.INT96,
[SchemaType.INT104_ARRAY]: SchemaType.INT104,
[SchemaType.INT112_ARRAY]: SchemaType.INT112,
[SchemaType.INT120_ARRAY]: SchemaType.INT120,
[SchemaType.INT128_ARRAY]: SchemaType.INT128,
[SchemaType.INT136_ARRAY]: SchemaType.INT136,
[SchemaType.INT144_ARRAY]: SchemaType.INT144,
[SchemaType.INT152_ARRAY]: SchemaType.INT152,
[SchemaType.INT160_ARRAY]: SchemaType.INT160,
[SchemaType.INT168_ARRAY]: SchemaType.INT168,
[SchemaType.INT176_ARRAY]: SchemaType.INT176,
[SchemaType.INT184_ARRAY]: SchemaType.INT184,
[SchemaType.INT192_ARRAY]: SchemaType.INT192,
[SchemaType.INT200_ARRAY]: SchemaType.INT200,
[SchemaType.INT208_ARRAY]: SchemaType.INT208,
[SchemaType.INT216_ARRAY]: SchemaType.INT216,
[SchemaType.INT224_ARRAY]: SchemaType.INT224,
[SchemaType.INT232_ARRAY]: SchemaType.INT232,
[SchemaType.INT240_ARRAY]: SchemaType.INT240,
[SchemaType.INT248_ARRAY]: SchemaType.INT248,
[SchemaType.INT256_ARRAY]: SchemaType.INT256,
[SchemaType.BYTES1_ARRAY]: SchemaType.BYTES1,
[SchemaType.BYTES2_ARRAY]: SchemaType.BYTES2,
[SchemaType.BYTES3_ARRAY]: SchemaType.BYTES3,
[SchemaType.BYTES4_ARRAY]: SchemaType.BYTES4,
[SchemaType.BYTES5_ARRAY]: SchemaType.BYTES5,
[SchemaType.BYTES6_ARRAY]: SchemaType.BYTES6,
[SchemaType.BYTES7_ARRAY]: SchemaType.BYTES7,
[SchemaType.BYTES8_ARRAY]: SchemaType.BYTES8,
[SchemaType.BYTES9_ARRAY]: SchemaType.BYTES9,
[SchemaType.BYTES10_ARRAY]: SchemaType.BYTES10,
[SchemaType.BYTES11_ARRAY]: SchemaType.BYTES11,
[SchemaType.BYTES12_ARRAY]: SchemaType.BYTES12,
[SchemaType.BYTES13_ARRAY]: SchemaType.BYTES13,
[SchemaType.BYTES14_ARRAY]: SchemaType.BYTES14,
[SchemaType.BYTES15_ARRAY]: SchemaType.BYTES15,
[SchemaType.BYTES16_ARRAY]: SchemaType.BYTES16,
[SchemaType.BYTES17_ARRAY]: SchemaType.BYTES17,
[SchemaType.BYTES18_ARRAY]: SchemaType.BYTES18,
[SchemaType.BYTES19_ARRAY]: SchemaType.BYTES19,
[SchemaType.BYTES20_ARRAY]: SchemaType.BYTES20,
[SchemaType.BYTES21_ARRAY]: SchemaType.BYTES21,
[SchemaType.BYTES22_ARRAY]: SchemaType.BYTES22,
[SchemaType.BYTES23_ARRAY]: SchemaType.BYTES23,
[SchemaType.BYTES24_ARRAY]: SchemaType.BYTES24,
[SchemaType.BYTES25_ARRAY]: SchemaType.BYTES25,
[SchemaType.BYTES26_ARRAY]: SchemaType.BYTES26,
[SchemaType.BYTES27_ARRAY]: SchemaType.BYTES27,
[SchemaType.BYTES28_ARRAY]: SchemaType.BYTES28,
[SchemaType.BYTES29_ARRAY]: SchemaType.BYTES29,
[SchemaType.BYTES30_ARRAY]: SchemaType.BYTES30,
[SchemaType.BYTES31_ARRAY]: SchemaType.BYTES31,
[SchemaType.BYTES32_ARRAY]: SchemaType.BYTES32,
[SchemaType.BOOL_ARRAY]: SchemaType.BOOL,
[SchemaType.ADDRESS_ARRAY]: SchemaType.ADDRESS
});
const SchemaTypeToAbiType = {
[SchemaType.UINT8]: "uint8",
[SchemaType.UINT16]: "uint16",
[SchemaType.UINT24]: "uint24",
[SchemaType.UINT32]: "uint32",
[SchemaType.UINT40]: "uint40",
[SchemaType.UINT48]: "uint48",
[SchemaType.UINT56]: "uint56",
[SchemaType.UINT64]: "uint64",
[SchemaType.UINT72]: "uint72",
[SchemaType.UINT80]: "uint80",
[SchemaType.UINT88]: "uint88",
[SchemaType.UINT96]: "uint96",
[SchemaType.UINT104]: "uint104",
[SchemaType.UINT112]: "uint112",
[SchemaType.UINT120]: "uint120",
[SchemaType.UINT128]: "uint128",
[SchemaType.UINT136]: "uint136",
[SchemaType.UINT144]: "uint144",
[SchemaType.UINT152]: "uint152",
[SchemaType.UINT160]: "uint160",
[SchemaType.UINT168]: "uint168",
[SchemaType.UINT176]: "uint176",
[SchemaType.UINT184]: "uint184",
[SchemaType.UINT192]: "uint192",
[SchemaType.UINT200]: "uint200",
[SchemaType.UINT208]: "uint208",
[SchemaType.UINT216]: "uint216",
[SchemaType.UINT224]: "uint224",
[SchemaType.UINT232]: "uint232",
[SchemaType.UINT240]: "uint240",
[SchemaType.UINT248]: "uint248",
[SchemaType.UINT256]: "uint256",
[SchemaType.INT8]: "int8",
[SchemaType.INT16]: "int16",
[SchemaType.INT24]: "int24",
[SchemaType.INT32]: "int32",
[SchemaType.INT40]: "int40",
[SchemaType.INT48]: "int48",
[SchemaType.INT56]: "int56",
[SchemaType.INT64]: "int64",
[SchemaType.INT72]: "int72",
[SchemaType.INT80]: "int80",
[SchemaType.INT88]: "int88",
[SchemaType.INT96]: "int96",
[SchemaType.INT104]: "int104",
[SchemaType.INT112]: "int112",
[SchemaType.INT120]: "int120",
[SchemaType.INT128]: "int128",
[SchemaType.INT136]: "int136",
[SchemaType.INT144]: "int144",
[SchemaType.INT152]: "int152",
[SchemaType.INT160]: "int160",
[SchemaType.INT168]: "int168",
[SchemaType.INT176]: "int176",
[SchemaType.INT184]: "int184",
[SchemaType.INT192]: "int192",
[SchemaType.INT200]: "int200",
[SchemaType.INT208]: "int208",
[SchemaType.INT216]: "int216",
[SchemaType.INT224]: "int224",
[SchemaType.INT232]: "int232",
[SchemaType.INT240]: "int240",
[SchemaType.INT248]: "int248",
[SchemaType.INT256]: "int256",
[SchemaType.BYTES1]: "bytes1",
[SchemaType.BYTES2]: "bytes2",
[SchemaType.BYTES3]: "bytes3",
[SchemaType.BYTES4]: "bytes4",
[SchemaType.BYTES5]: "bytes5",
[SchemaType.BYTES6]: "bytes6",
[SchemaType.BYTES7]: "bytes7",
[SchemaType.BYTES8]: "bytes8",
[SchemaType.BYTES9]: "bytes9",
[SchemaType.BYTES10]: "bytes10",
[SchemaType.BYTES11]: "bytes11",
[SchemaType.BYTES12]: "bytes12",
[SchemaType.BYTES13]: "bytes13",
[SchemaType.BYTES14]: "bytes14",
[SchemaType.BYTES15]: "bytes15",
[SchemaType.BYTES16]: "bytes16",
[SchemaType.BYTES17]: "bytes17",
[SchemaType.BYTES18]: "bytes18",
[SchemaType.BYTES19]: "bytes19",
[SchemaType.BYTES20]: "bytes20",
[SchemaType.BYTES21]: "bytes21",
[SchemaType.BYTES22]: "bytes22",
[SchemaType.BYTES23]: "bytes23",
[SchemaType.BYTES24]: "bytes24",
[SchemaType.BYTES25]: "bytes25",
[SchemaType.BYTES26]: "bytes26",
[SchemaType.BYTES27]: "bytes27",
[SchemaType.BYTES28]: "bytes28",
[SchemaType.BYTES29]: "bytes29",
[SchemaType.BYTES30]: "bytes30",
[SchemaType.BYTES31]: "bytes31",
[SchemaType.BYTES32]: "bytes32",
[SchemaType.BOOL]: "bool",
[SchemaType.ADDRESS]: "address",
[SchemaType.UINT8_ARRAY]: "uint8[]",
[SchemaType.UINT16_ARRAY]: "uint16[]",
[SchemaType.UINT24_ARRAY]: "uint24[]",
[SchemaType.UINT32_ARRAY]: "uint32[]",
[SchemaType.UINT40_ARRAY]: "uint40[]",
[SchemaType.UINT48_ARRAY]: "uint48[]",
[SchemaType.UINT56_ARRAY]: "uint56[]",
[SchemaType.UINT64_ARRAY]: "uint64[]",
[SchemaType.UINT72_ARRAY]: "uint72[]",
[SchemaType.UINT80_ARRAY]: "uint80[]",
[SchemaType.UINT88_ARRAY]: "uint88[]",
[SchemaType.UINT96_ARRAY]: "uint96[]",
[SchemaType.UINT104_ARRAY]: "uint104[]",
[SchemaType.UINT112_ARRAY]: "uint112[]",
[SchemaType.UINT120_ARRAY]: "uint120[]",
[SchemaType.UINT128_ARRAY]: "uint128[]",
[SchemaType.UINT136_ARRAY]: "uint136[]",
[SchemaType.UINT144_ARRAY]: "uint144[]",
[SchemaType.UINT152_ARRAY]: "uint152[]",
[SchemaType.UINT160_ARRAY]: "uint160[]",
[SchemaType.UINT168_ARRAY]: "uint168[]",
[SchemaType.UINT176_ARRAY]: "uint176[]",
[SchemaType.UINT184_ARRAY]: "uint184[]",
[SchemaType.UINT192_ARRAY]: "uint192[]",
[SchemaType.UINT200_ARRAY]: "uint200[]",
[SchemaType.UINT208_ARRAY]: "uint208[]",
[SchemaType.UINT216_ARRAY]: "uint216[]",
[SchemaType.UINT224_ARRAY]: "uint224[]",
[SchemaType.UINT232_ARRAY]: "uint232[]",
[SchemaType.UINT240_ARRAY]: "uint240[]",
[SchemaType.UINT248_ARRAY]: "uint248[]",
[SchemaType.UINT256_ARRAY]: "uint256[]",
[SchemaType.INT8_ARRAY]: "int8[]",
[SchemaType.INT16_ARRAY]: "int16[]",
[SchemaType.INT24_ARRAY]: "int24[]",
[SchemaType.INT32_ARRAY]: "int32[]",
[SchemaType.INT40_ARRAY]: "int40[]",
[SchemaType.INT48_ARRAY]: "int48[]",
[SchemaType.INT56_ARRAY]: "int56[]",
[SchemaType.INT64_ARRAY]: "int64[]",
[SchemaType.INT72_ARRAY]: "int72[]",
[SchemaType.INT80_ARRAY]: "int80[]",
[SchemaType.INT88_ARRAY]: "int88[]",
[SchemaType.INT96_ARRAY]: "int96[]",
[SchemaType.INT104_ARRAY]: "int104[]",
[SchemaType.INT112_ARRAY]: "int112[]",
[SchemaType.INT120_ARRAY]: "int120[]",
[SchemaType.INT128_ARRAY]: "int128[]",
[SchemaType.INT136_ARRAY]: "int136[]",
[SchemaType.INT144_ARRAY]: "int144[]",
[SchemaType.INT152_ARRAY]: "int152[]",
[SchemaType.INT160_ARRAY]: "int160[]",
[SchemaType.INT168_ARRAY]: "int168[]",
[SchemaType.INT176_ARRAY]: "int176[]",
[SchemaType.INT184_ARRAY]: "int184[]",
[SchemaType.INT192_ARRAY]: "int192[]",
[SchemaType.INT200_ARRAY]: "int200[]",
[SchemaType.INT208_ARRAY]: "int208[]",
[SchemaType.INT216_ARRAY]: "int216[]",
[SchemaType.INT224_ARRAY]: "int224[]",
[SchemaType.INT232_ARRAY]: "int232[]",
[SchemaType.INT240_ARRAY]: "int240[]",
[SchemaType.INT248_ARRAY]: "int248[]",
[SchemaType.INT256_ARRAY]: "int256[]",
[SchemaType.BYTES1_ARRAY]: "bytes1[]",
[SchemaType.BYTES2_ARRAY]: "bytes2[]",
[SchemaType.BYTES3_ARRAY]: "bytes3[]",
[SchemaType.BYTES4_ARRAY]: "bytes4[]",
[SchemaType.BYTES5_ARRAY]: "bytes5[]",
[SchemaType.BYTES6_ARRAY]: "bytes6[]",
[SchemaType.BYTES7_ARRAY]: "bytes7[]",
[SchemaType.BYTES8_ARRAY]: "bytes8[]",
[SchemaType.BYTES9_ARRAY]: "bytes9[]",
[SchemaType.BYTES10_ARRAY]: "bytes10[]",
[SchemaType.BYTES11_ARRAY]: "bytes11[]",
[SchemaType.BYTES12_ARRAY]: "bytes12[]",
[SchemaType.BYTES13_ARRAY]: "bytes13[]",
[SchemaType.BYTES14_ARRAY]: "bytes14[]",
[SchemaType.BYTES15_ARRAY]: "bytes15[]",
[SchemaType.BYTES16_ARRAY]: "bytes16[]",
[SchemaType.BYTES17_ARRAY]: "bytes17[]",
[SchemaType.BYTES18_ARRAY]: "bytes18[]",
[SchemaType.BYTES19_ARRAY]: "bytes19[]",
[SchemaType.BYTES20_ARRAY]: "bytes20[]",
[SchemaType.BYTES21_ARRAY]: "bytes21[]",
[SchemaType.BYTES22_ARRAY]: "bytes22[]",
[SchemaType.BYTES23_ARRAY]: "bytes23[]",
[SchemaType.BYTES24_ARRAY]: "bytes24[]",
[SchemaType.BYTES25_ARRAY]: "bytes25[]",
[SchemaType.BYTES26_ARRAY]: "bytes26[]",
[SchemaType.BYTES27_ARRAY]: "bytes27[]",
[SchemaType.BYTES28_ARRAY]: "bytes28[]",
[SchemaType.BYTES29_ARRAY]: "bytes29[]",
[SchemaType.BYTES30_ARRAY]: "bytes30[]",
[SchemaType.BYTES31_ARRAY]: "bytes31[]",
[SchemaType.BYTES32_ARRAY]: "bytes32[]",
[SchemaType.BOOL_ARRAY]: "bool[]",
[SchemaType.ADDRESS_ARRAY]: "address[]",
[SchemaType.BYTES]: "bytes",
[SchemaType.STRING]: "string"
};
const AbiTypeToSchemaType = Object.fromEntries(Object.entries(SchemaTypeToAbiType).map(([schemaType, abiType]) => [abiType, parseInt(schemaType)]));
const AbiTypes = Object.values(SchemaTypeToAbiType);
const StaticAbiTypes = AbiTypes.filter((abiType) => getStaticByteLength(AbiTypeToSchemaType[abiType]) > 0);
const zTableName = zObjectName;
const zKeyName = zValueName;
const zColumnName = zValueName;
const zUserEnumName = zObjectName;
const zFieldData = z.string();
const zPrimaryKey = z.string();
const zPrimaryKeys = z.record(zKeyName, zPrimaryKey).default({ key: "bytes32" });
const zFullSchemaConfig = z.record(zColumnName, zFieldData).refine((arg) => Object.keys(arg).length > 0, "Table schema may not be empty");
const zShorthandSchemaConfig = zFieldData.transform((fieldData) => {
return zFullSchemaConfig.parse({
value: fieldData
});
});
const zSchemaConfig = zFullSchemaConfig.or(zShorthandSchemaConfig);
const zFullTableConfig = z.object({
directory: z.string().default("tables"),
name: zSelector.optional(),
tableIdArgument: z.boolean().default(false),
storeArgument: z.boolean().default(true),
primaryKeys: zPrimaryKeys,
schema: zSchemaConfig,
dataStruct: z.boolean().optional()
}).transform((arg) => {
if (Object.keys(arg.schema).length === 1) {
arg.dataStruct ?? (arg.dataStruct = false);
} else {
arg.dataStruct ?? (arg.dataStruct = true);
R.UINT8_ARRAY + "", R.UINT8, R.UINT16_ARRAY + "", R.UINT16, R.UINT24_ARRAY + "", R.UINT24, R.UINT32_ARRAY + "", R.UINT32, R.UINT40_ARRAY + "", R.UINT40, R.UINT48_ARRAY + "", R.UINT48, R.UINT56_ARRAY + "", R.UINT56, R.UINT64_ARRAY + "", R.UINT64, R.UINT72_ARRAY + "", R.UINT72, R.UINT80_ARRAY + "", R.UINT80, R.UINT88_ARRAY + "", R.UINT88, R.UINT96_ARRAY + "", R.UINT96, R.UINT104_ARRAY + "", R.UINT104, R.UINT112_ARRAY + "", R.UINT112, R.UINT120_ARRAY + "", R.UINT120, R.UINT128_ARRAY + "", R.UINT128, R.UINT136_ARRAY + "", R.UINT136, R.UINT144_ARRAY + "", R.UINT144, R.UINT152_ARRAY + "", R.UINT152, R.UINT160_ARRAY + "", R.UINT160, R.UINT168_ARRAY + "", R.UINT168, R.UINT176_ARRAY + "", R.UINT176, R.UINT184_ARRAY + "", R.UINT184, R.UINT192_ARRAY + "", R.UINT192, R.UINT200_ARRAY + "", R.UINT200, R.UINT208_ARRAY + "", R.UINT208, R.UINT216_ARRAY + "", R.UINT216, R.UINT224_ARRAY + "", R.UINT224, R.UINT232_ARRAY + "", R.UINT232, R.UINT240_ARRAY + "", R.UINT240, R.UINT248_ARRAY + "", R.UINT248, R.UINT256_ARRAY + "", R.UINT256, R.INT8_ARRAY + "", R.INT8, R.INT16_ARRAY + "", R.INT16, R.INT24_ARRAY + "", R.INT24, R.INT32_ARRAY + "", R.INT32, R.INT40_ARRAY + "", R.INT40, R.INT48_ARRAY + "", R.INT48, R.INT56_ARRAY + "", R.INT56, R.INT64_ARRAY + "", R.INT64, R.INT72_ARRAY + "", R.INT72, R.INT80_ARRAY + "", R.INT80, R.INT88_ARRAY + "", R.INT88, R.INT96_ARRAY + "", R.INT96, R.INT104_ARRAY + "", R.INT104, R.INT112_ARRAY + "", R.INT112, R.INT120_ARRAY + "", R.INT120, R.INT128_ARRAY + "", R.INT128, R.INT136_ARRAY + "", R.INT136, R.INT144_ARRAY + "", R.INT144, R.INT152_ARRAY + "", R.INT152, R.INT160_ARRAY + "", R.INT160, R.INT168_ARRAY + "", R.INT168, R.INT176_ARRAY + "", R.INT176, R.INT184_ARRAY + "", R.INT184, R.INT192_ARRAY + "", R.INT192, R.INT200_ARRAY + "", R.INT200, R.INT208_ARRAY + "", R.INT208, R.INT216_ARRAY + "", R.INT216, R.INT224_ARRAY + "", R.INT224, R.INT232_ARRAY + "", R.INT232, R.INT240_ARRAY + "", R.INT240, R.INT248_ARRAY + "", R.INT248, R.INT256_ARRAY + "", R.INT256, R.BYTES1_ARRAY + "", R.BYTES1, R.BYTES2_ARRAY + "", R.BYTES2, R.BYTES3_ARRAY + "", R.BYTES3, R.BYTES4_ARRAY + "", R.BYTES4, R.BYTES5_ARRAY + "", R.BYTES5, R.BYTES6_ARRAY + "", R.BYTES6, R.BYTES7_ARRAY + "", R.BYTES7, R.BYTES8_ARRAY + "", R.BYTES8, R.BYTES9_ARRAY + "", R.BYTES9, R.BYTES10_ARRAY + "", R.BYTES10, R.BYTES11_ARRAY + "", R.BYTES11, R.BYTES12_ARRAY + "", R.BYTES12, R.BYTES13_ARRAY + "", R.BYTES13, R.BYTES14_ARRAY + "", R.BYTES14, R.BYTES15_ARRAY + "", R.BYTES15, R.BYTES16_ARRAY + "", R.BYTES16, R.BYTES17_ARRAY + "", R.BYTES17, R.BYTES18_ARRAY + "", R.BYTES18, R.BYTES19_ARRAY + "", R.BYTES19, R.BYTES20_ARRAY + "", R.BYTES20, R.BYTES21_ARRAY + "", R.BYTES21, R.BYTES22_ARRAY + "", R.BYTES22, R.BYTES23_ARRAY + "", R.BYTES23, R.BYTES24_ARRAY + "", R.BYTES24, R.BYTES25_ARRAY + "", R.BYTES25, R.BYTES26_ARRAY + "", R.BYTES26, R.BYTES27_ARRAY + "", R.BYTES27, R.BYTES28_ARRAY + "", R.BYTES28, R.BYTES29_ARRAY + "", R.BYTES29, R.BYTES30_ARRAY + "", R.BYTES30, R.BYTES31_ARRAY + "", R.BYTES31, R.BYTES32_ARRAY + "", R.BYTES32, R.BOOL_ARRAY + "", R.BOOL, R.ADDRESS_ARRAY + "", R.ADDRESS;
const L = {
[R.UINT8]: "uint8",
[R.UINT16]: "uint16",
[R.UINT24]: "uint24",
[R.UINT32]: "uint32",
[R.UINT40]: "uint40",
[R.UINT48]: "uint48",
[R.UINT56]: "uint56",
[R.UINT64]: "uint64",
[R.UINT72]: "uint72",
[R.UINT80]: "uint80",
[R.UINT88]: "uint88",
[R.UINT96]: "uint96",
[R.UINT104]: "uint104",
[R.UINT112]: "uint112",
[R.UINT120]: "uint120",
[R.UINT128]: "uint128",
[R.UINT136]: "uint136",
[R.UINT144]: "uint144",
[R.UINT152]: "uint152",
[R.UINT160]: "uint160",
[R.UINT168]: "uint168",
[R.UINT176]: "uint176",
[R.UINT184]: "uint184",
[R.UINT192]: "uint192",
[R.UINT200]: "uint200",
[R.UINT208]: "uint208",
[R.UINT216]: "uint216",
[R.UINT224]: "uint224",
[R.UINT232]: "uint232",
[R.UINT240]: "uint240",
[R.UINT248]: "uint248",
[R.UINT256]: "uint256",
[R.INT8]: "int8",
[R.INT16]: "int16",
[R.INT24]: "int24",
[R.INT32]: "int32",
[R.INT40]: "int40",
[R.INT48]: "int48",
[R.INT56]: "int56",
[R.INT64]: "int64",
[R.INT72]: "int72",
[R.INT80]: "int80",
[R.INT88]: "int88",
[R.INT96]: "int96",
[R.INT104]: "int104",
[R.INT112]: "int112",
[R.INT120]: "int120",
[R.INT128]: "int128",
[R.INT136]: "int136",
[R.INT144]: "int144",
[R.INT152]: "int152",
[R.INT160]: "int160",
[R.INT168]: "int168",
[R.INT176]: "int176",
[R.INT184]: "int184",
[R.INT192]: "int192",
[R.INT200]: "int200",
[R.INT208]: "int208",
[R.INT216]: "int216",
[R.INT224]: "int224",
[R.INT232]: "int232",
[R.INT240]: "int240",
[R.INT248]: "int248",
[R.INT256]: "int256",
[R.BYTES1]: "bytes1",
[R.BYTES2]: "bytes2",
[R.BYTES3]: "bytes3",
[R.BYTES4]: "bytes4",
[R.BYTES5]: "bytes5",
[R.BYTES6]: "bytes6",
[R.BYTES7]: "bytes7",
[R.BYTES8]: "bytes8",
[R.BYTES9]: "bytes9",
[R.BYTES10]: "bytes10",
[R.BYTES11]: "bytes11",
[R.BYTES12]: "bytes12",
[R.BYTES13]: "bytes13",
[R.BYTES14]: "bytes14",
[R.BYTES15]: "bytes15",
[R.BYTES16]: "bytes16",
[R.BYTES17]: "bytes17",
[R.BYTES18]: "bytes18",
[R.BYTES19]: "bytes19",
[R.BYTES20]: "bytes20",
[R.BYTES21]: "bytes21",
[R.BYTES22]: "bytes22",
[R.BYTES23]: "bytes23",
[R.BYTES24]: "bytes24",
[R.BYTES25]: "bytes25",
[R.BYTES26]: "bytes26",
[R.BYTES27]: "bytes27",
[R.BYTES28]: "bytes28",
[R.BYTES29]: "bytes29",
[R.BYTES30]: "bytes30",
[R.BYTES31]: "bytes31",
[R.BYTES32]: "bytes32",
[R.BOOL]: "bool",
[R.ADDRESS]: "address",
[R.UINT8_ARRAY]: "uint8[]",
[R.UINT16_ARRAY]: "uint16[]",
[R.UINT24_ARRAY]: "uint24[]",
[R.UINT32_ARRAY]: "uint32[]",
[R.UINT40_ARRAY]: "uint40[]",
[R.UINT48_ARRAY]: "uint48[]",
[R.UINT56_ARRAY]: "uint56[]",
[R.UINT64_ARRAY]: "uint64[]",
[R.UINT72_ARRAY]: "uint72[]",
[R.UINT80_ARRAY]: "uint80[]",
[R.UINT88_ARRAY]: "uint88[]",
[R.UINT96_ARRAY]: "uint96[]",
[R.UINT104_ARRAY]: "uint104[]",
[R.UINT112_ARRAY]: "uint112[]",
[R.UINT120_ARRAY]: "uint120[]",
[R.UINT128_ARRAY]: "uint128[]",
[R.UINT136_ARRAY]: "uint136[]",
[R.UINT144_ARRAY]: "uint144[]",
[R.UINT152_ARRAY]: "uint152[]",
[R.UINT160_ARRAY]: "uint160[]",
[R.UINT168_ARRAY]: "uint168[]",
[R.UINT176_ARRAY]: "uint176[]",
[R.UINT184_ARRAY]: "uint184[]",
[R.UINT192_ARRAY]: "uint192[]",
[R.UINT200_ARRAY]: "uint200[]",
[R.UINT208_ARRAY]: "uint208[]",
[R.UINT216_ARRAY]: "uint216[]",
[R.UINT224_ARRAY]: "uint224[]",
[R.UINT232_ARRAY]: "uint232[]",
[R.UINT240_ARRAY]: "uint240[]",
[R.UINT248_ARRAY]: "uint248[]",
[R.UINT256_ARRAY]: "uint256[]",
[R.INT8_ARRAY]: "int8[]",
[R.INT16_ARRAY]: "int16[]",
[R.INT24_ARRAY]: "int24[]",
[R.INT32_ARRAY]: "int32[]",
[R.INT40_ARRAY]: "int40[]",
[R.INT48_ARRAY]: "int48[]",
[R.INT56_ARRAY]: "int56[]",
[R.INT64_ARRAY]: "int64[]",
[R.INT72_ARRAY]: "int72[]",
[R.INT80_ARRAY]: "int80[]",
[R.INT88_ARRAY]: "int88[]",
[R.INT96_ARRAY]: "int96[]",
[R.INT104_ARRAY]: "int104[]",
[R.INT112_ARRAY]: "int112[]",
[R.INT120_ARRAY]: "int120[]",
[R.INT128_ARRAY]: "int128[]",
[R.INT136_ARRAY]: "int136[]",
[R.INT144_ARRAY]: "int144[]",
[R.INT152_ARRAY]: "int152[]",
[R.INT160_ARRAY]: "int160[]",
[R.INT168_ARRAY]: "int168[]",
[R.INT176_ARRAY]: "int176[]",
[R.INT184_ARRAY]: "int184[]",
[R.INT192_ARRAY]: "int192[]",
[R.INT200_ARRAY]: "int200[]",
[R.INT208_ARRAY]: "int208[]",
[R.INT216_ARRAY]: "int216[]",
[R.INT224_ARRAY]: "int224[]",
[R.INT232_ARRAY]: "int232[]",
[R.INT240_ARRAY]: "int240[]",
[R.INT248_ARRAY]: "int248[]",
[R.INT256_ARRAY]: "int256[]",
[R.BYTES1_ARRAY]: "bytes1[]",
[R.BYTES2_ARRAY]: "bytes2[]",
[R.BYTES3_ARRAY]: "bytes3[]",
[R.BYTES4_ARRAY]: "bytes4[]",
[R.BYTES5_ARRAY]: "bytes5[]",
[R.BYTES6_ARRAY]: "bytes6[]",
[R.BYTES7_ARRAY]: "bytes7[]",
[R.BYTES8_ARRAY]: "bytes8[]",
[R.BYTES9_ARRAY]: "bytes9[]",
[R.BYTES10_ARRAY]: "bytes10[]",
[R.BYTES11_ARRAY]: "bytes11[]",
[R.BYTES12_ARRAY]: "bytes12[]",
[R.BYTES13_ARRAY]: "bytes13[]",
[R.BYTES14_ARRAY]: "bytes14[]",
[R.BYTES15_ARRAY]: "bytes15[]",
[R.BYTES16_ARRAY]: "bytes16[]",
[R.BYTES17_ARRAY]: "bytes17[]",
[R.BYTES18_ARRAY]: "bytes18[]",
[R.BYTES19_ARRAY]: "bytes19[]",
[R.BYTES20_ARRAY]: "bytes20[]",
[R.BYTES21_ARRAY]: "bytes21[]",
[R.BYTES22_ARRAY]: "bytes22[]",
[R.BYTES23_ARRAY]: "bytes23[]",
[R.BYTES24_ARRAY]: "bytes24[]",
[R.BYTES25_ARRAY]: "bytes25[]",
[R.BYTES26_ARRAY]: "bytes26[]",
[R.BYTES27_ARRAY]: "bytes27[]",
[R.BYTES28_ARRAY]: "bytes28[]",
[R.BYTES29_ARRAY]: "bytes29[]",
[R.BYTES30_ARRAY]: "bytes30[]",
[R.BYTES31_ARRAY]: "bytes31[]",
[R.BYTES32_ARRAY]: "bytes32[]",
[R.BOOL_ARRAY]: "bool[]",
[R.ADDRESS_ARRAY]: "address[]",
[R.BYTES]: "bytes",
[R.STRING]: "string"
}, sA = Object.fromEntries(Object.entries(L).map(([A, t]) => [t, parseInt(A)])), k = Object.values(L), IA = k.filter((A) => YA(sA[A]) > 0), nA = E, NA = w, iA = w, oA = E, v = Y.string(), rA = Y.string(), TA = Y.record(NA, rA).default({ key: "bytes32" }), F = Y.record(iA, v).refine((A) => Object.keys(A).length > 0, "Table schema may not be empty"), _A = v.transform((A) => F.parse({
value: A
})), uA = F.or(_A), W = Y.object({
directory: Y.string().default("tables"),
name: B.optional(),
tableIdArgument: Y.boolean().default(!1),
storeArgument: Y.boolean().default(!0),
primaryKeys: TA,
schema: uA,
dataStruct: Y.boolean().optional()
}).transform((A) => (Object.keys(A.schema).length === 1 ? A.dataStruct ??= !1 : A.dataStruct ??= !0, A)), EA = v.transform((A) => W.parse({
schema: {
value: A
}
return arg;
});
const zShorthandTableConfig = zFieldData.transform((fieldData) => {
return zFullTableConfig.parse({
schema: {
value: fieldData
}
});
});
const zTableConfig = zFullTableConfig.or(zShorthandTableConfig);
const zTablesConfig = z.record(zTableName, zTableConfig).transform((tables) => {
for (const tableName of Object.keys(tables)) {
const table = tables[tableName];
table.name ?? (table.name = tableName);
tables[tableName] = table;
})), BA = W.or(EA), UA = Y.record(nA, BA).transform((A) => {
for (const t of Object.keys(A)) {
const s = A[t];
s.name ??= t, A[t] = s;
}
return tables;
return A;
}), dA = Y.object({
enums: Y.record(oA, y).default({})
});
const zEnumsConfig = z.object({
enums: z.record(zUserEnumName, zUserEnum).default({})
});
function storeConfig(config) {
return config;
function XA(A) {
return A;
}
const StoreConfigUnrefined = z.object({
namespace: zSelector.default(""),
storeImportPath: z.string().default("@latticexyz/store/src/"),
tables: zTablesConfig,
userTypesPath: z.string().default("Types"),
codegenDirectory: z.string().default("codegen")
}).merge(zEnumsConfig);
const zStoreConfig = StoreConfigUnrefined.superRefine(validateStoreConfig);
function parseStoreConfig(config) {
return zStoreConfig.parse(config);
const lA = Y.object({
namespace: B.default(""),
storeImportPath: Y.string().default("@latticexyz/store/src/"),
tables: UA,
userTypesPath: Y.string().default("Types"),
codegenDirectory: Y.string().default("codegen")
}).merge(dA), fA = lA.superRefine(gA);
function bA(A) {
return fA.parse(A);
}
function validateStoreConfig(config, ctx) {
for (const table of Object.values(config.tables)) {
const primaryKeyNames = Object.keys(table.primaryKeys);
const fieldNames = Object.keys(table.schema);
const duplicateVariableNames = getDuplicates([...primaryKeyNames, ...fieldNames]);
if (duplicateVariableNames.length > 0) {
ctx.addIssue({
code: ZodIssueCode.custom,
message: `Field and primary key names within one table must be unique: ${duplicateVariableNames.join(", ")}`
});
}
}
const tableNames = Object.keys(config.tables);
const staticUserTypeNames = Object.keys(config.enums);
const userTypeNames = staticUserTypeNames;
const globalNames = [...tableNames, ...userTypeNames];
const duplicateGlobalNames = getDuplicates(globalNames);
if (duplicateGlobalNames.length > 0) {
ctx.addIssue({
code: ZodIssueCode.custom,
message: `Table, enum names must be globally unique: ${duplicateGlobalNames.join(", ")}`
function gA(A, t) {
for (const r of Object.values(A.tables)) {
const T = Object.keys(r.primaryKeys), N = Object.keys(r.schema), u = l([...T, ...N]);
u.length > 0 && t.addIssue({
code: n.custom,
message: `Field and primary key names within one table must be unique: ${u.join(", ")}`
});
}
for (const table of Object.values(config.tables)) {
for (const primaryKeyType of Object.values(table.primaryKeys)) {
validateStaticAbiOrUserType(staticUserTypeNames, primaryKeyType, ctx);
}
for (const fieldType of Object.values(table.schema)) {
validateAbiOrUserType(userTypeNames, staticUserTypeNames, fieldType, ctx);
}
const s = Object.keys(A.tables), I = Object.keys(A.enums), i = I, o = [...s, ...i], _ = l(o);
_.length > 0 && t.addIssue({
code: n.custom,
message: `Table, enum names must be globally unique: ${_.join(", ")}`
});
for (const r of Object.values(A.tables)) {
for (const T of Object.values(r.primaryKeys))
$(I, T, t);
for (const T of Object.values(r.schema))
vA(i, I, T, t);
}
}
function validateAbiOrUserType(userTypeNames, staticUserTypeNames, type, ctx) {
if (!AbiTypes.includes(type) && !userTypeNames.includes(type)) {
const staticArray = parseStaticArray(type);
if (staticArray) {
validateStaticArray(staticUserTypeNames, staticArray.elementType, staticArray.staticLength, ctx);
} else {
ctx.addIssue({
code: ZodIssueCode.custom,
message: `${type} is not a valid abi type, and is not defined in userTypes`
});
}
}
}
function validateStaticAbiOrUserType(staticUserTypeNames, type, ctx) {
if (!StaticAbiTypes.includes(type) && !staticUserTypeNames.includes(type)) {
ctx.addIssue({
code: ZodIssueCode.custom,
message: `${type} is not a static type`
function vA(A, t, s, I) {
if (!k.includes(s) && !A.includes(s)) {
const i = m(s);
i ? zA(t, i.elementType, i.staticLength, I) : I.addIssue({
code: n.custom,
message: `${s} is not a valid abi type, and is not defined in userTypes`
});
}
}
function validateStaticArray(staticUserTypeNames, elementType, staticLength, ctx) {
validateStaticAbiOrUserType(staticUserTypeNames, elementType, ctx);
if (staticLength === 0) {
ctx.addIssue({
code: ZodIssueCode.custom,
message: `Static array length must not be 0`
});
} else if (staticLength >= 2 ** 16) {
ctx.addIssue({
code: ZodIssueCode.custom,
message: `Static array length must be less than 2**16`
});
}
function $(A, t, s) {
!IA.includes(t) && !A.includes(t) && s.addIssue({
code: n.custom,
message: `${t} is not a static type`
});
}
async function loadStoreConfig(configPath) {
const config = await loadConfig(configPath);
function zA(A, t, s, I) {
$(A, t, I), s === 0 ? I.addIssue({
code: n.custom,
message: "Static array length must not be 0"
}) : s >= 2 ** 16 && I.addIssue({
code: n.custom,
message: "Static array length must be less than 2**16"
});
}
async function xA(A) {
const t = await D(A);
try {
return parseStoreConfig(config);
} catch (error) {
if (error instanceof ZodError) {
throw fromZodErrorCustom(error, "StoreConfig Validation Error");
} else {
throw error;
}
return bA(t);
} catch (s) {
throw s instanceof O ? j(s, "StoreConfig Validation Error") : s;
}
}
var DynamicResolutionType = /* @__PURE__ */ ((DynamicResolutionType2) => {
DynamicResolutionType2[DynamicResolutionType2["TABLE_ID"] = 0] = "TABLE_ID";
DynamicResolutionType2[DynamicResolutionType2["SYSTEM_ADDRESS"] = 1] = "SYSTEM_ADDRESS";
return DynamicResolutionType2;
})(DynamicResolutionType || {});
function resolveTableId(tableName) {
var e = /* @__PURE__ */ ((A) => (A[A.TABLE_ID = 0] = "TABLE_ID", A[A.SYSTEM_ADDRESS = 1] = "SYSTEM_ADDRESS", A))(e || {});
function aA(A) {
return {
type: 0,
input: tableName
input: A
};
}
function isDynamicResolution(value) {
return typeof value === "object" && value !== null && "type" in value && "input" in value;
function OA(A) {
return typeof A == "object" && A !== null && "type" in A && "input" in A;
}
async function resolveWithContext(unresolved, context) {
var _a;
if (!isDynamicResolution(unresolved))
return unresolved;
let resolved = void 0;
if (unresolved.type === 0) {
const tableId = (_a = context.tableIds) == null ? void 0 : _a[unresolved.input];
resolved = tableId && { value: tableId, type: "bytes32" };
async function SA(A, t) {
if (!OA(A))
return A;
let s;
if (A.type === 0) {
const I = t.tableIds?.[A.input];
s = I && { value: I, type: "bytes32" };
}
if (resolved === void 0) {
throw new MUDError(`Could not resolve dynamic resolution:
${JSON.stringify(unresolved, null, 2)}`);
}
return resolved;
if (s === void 0)
throw new h(`Could not resolve dynamic resolution:
${JSON.stringify(A, null, 2)}`);
return s;
}
const zSystemName = zObjectName;
const zModuleName = zObjectName;
const zSystemAccessList = z.array(zSystemName.or(zEthereumAddress)).default([]);
const zSystemConfig = z.intersection(
z.object({
name: zSelector,
registerFunctionSelectors: z.boolean().default(true)
const f = E, wA = E, jA = Y.array(f.or(p)).default([]), CA = Y.intersection(
Y.object({
name: B,
registerFunctionSelectors: Y.boolean().default(!0)
}),
z.discriminatedUnion("openAccess", [
z.object({
openAccess: z.literal(true)
Y.discriminatedUnion("openAccess", [
Y.object({
openAccess: Y.literal(!0)
}),
z.object({
openAccess: z.literal(false),
accessList: zSystemAccessList
Y.object({
openAccess: Y.literal(!1),
accessList: jA
})
])
);
const zValueWithType = z.object({
value: z.union([z.string(), z.number(), z.instanceof(Uint8Array)]),
type: z.string()
), DA = Y.object({
value: Y.union([Y.string(), Y.number(), Y.instanceof(Uint8Array)]),
type: Y.string()
}), LA = Y.object({ type: Y.nativeEnum(e), input: Y.string() }), kA = Y.object({
name: wA,
root: Y.boolean().default(!1),
args: Y.array(Y.union([DA, LA])).default([])
}), K = Y.object({
namespace: B.default(""),
worldContractName: Y.string().optional(),
worldInterfaceName: Y.string().default("IWorld"),
overrideSystems: Y.record(f, CA).default({}),
excludeSystems: Y.array(f).default([]),
postDeployScript: Y.string().default("PostDeploy"),
deploysDirectory: Y.string().default("./deploys"),
worldgenDirectory: Y.string().default("world"),
worldImportPath: Y.string().default("@latticexyz/world/src/"),
modules: Y.array(kA).default([])
});
const zDynamicResolution = z.object({ type: z.nativeEnum(DynamicResolutionType), input: z.string() });
const zModuleConfig = z.object({
name: zModuleName,
root: z.boolean().default(false),
args: z.array(z.union([zValueWithType, zDynamicResolution])).default([])
});
const zWorldConfig = z.object({
namespace: zSelector.default(""),
worldContractName: z.string().optional(),
worldInterfaceName: z.string().default("IWorld"),
overrideSystems: z.record(zSystemName, zSystemConfig).default({}),
excludeSystems: z.array(zSystemName).default([]),
postDeployScript: z.string().default("PostDeploy"),
deploysDirectory: z.string().default("./deploys"),
worldgenDirectory: z.string().default("world"),
worldImportPath: z.string().default("@latticexyz/world/src/"),
modules: z.array(zModuleConfig).default([])
});
async function parseWorldConfig(config) {
return zWorldConfig.parse(config);
async function cA(A) {
return K.parse(A);
}
function resolveWorldConfig(config, existingContracts) {
const defaultSystemNames = (existingContracts == null ? void 0 : existingContracts.filter((name) => name.endsWith("System") && name !== "System" && !name.match(/^I[A-Z]/))) ?? [];
const overriddenSystemNames = Object.keys(config.overrideSystems);
if (existingContracts) {
for (const systemName of overriddenSystemNames) {
if (!existingContracts.includes(systemName) || systemName === "World") {
throw UnrecognizedSystemErrorFactory(["overrideSystems", systemName], systemName);
}
}
function FA(A, t) {
const s = t?.filter((N) => N.endsWith("System") && N !== "System" && !N.match(/^I[A-Z]/)) ?? [], I = Object.keys(A.overrideSystems);
if (t) {
for (const N of I)
if (!t.includes(N) || N === "World")
throw C(["overrideSystems", N], N);
}
const systemNames = [.../* @__PURE__ */ new Set([...defaultSystemNames, ...overriddenSystemNames])].filter(
(name) => !config.excludeSystems.includes(name)
);
const resolvedSystems = systemNames.reduce((acc, systemName) => {
return {
...acc,
[systemName]: resolveSystemConfig(systemName, config.overrideSystems[systemName], existingContracts)
};
}, {});
const { overrideSystems, excludeSystems, ...otherConfig } = config;
return { ...otherConfig, systems: resolvedSystems };
const o = [.../* @__PURE__ */ new Set([...s, ...I])].filter(
(N) => !A.excludeSystems.includes(N)
).reduce((N, u) => ({
...N,
[u]: WA(u, A.overrideSystems[u], t)
}), {}), { overrideSystems: _, excludeSystems: r, ...T } = A;
return { ...T, systems: o };
}
function resolveSystemConfig(systemName, config, existingContracts) {
const name = (config == null ? void 0 : config.name) ?? systemName;
const registerFunctionSelectors = (config == null ? void 0 : config.registerFunctionSelectors) ?? true;
const openAccess = (config == null ? void 0 : config.openAccess) ?? true;
const accessListAddresses = [];
const accessListSystems = [];
const accessList = config && !config.openAccess ? config.accessList : [];
for (const accessListItem of accessList) {
if (accessListItem.startsWith("0x")) {
accessListAddresses.push(accessListItem);
} else {
if (existingContracts && !existingContracts.includes(accessListItem)) {
throw UnrecognizedSystemErrorFactory(["overrideSystems", systemName, "accessList"], accessListItem);
}
accessListSystems.push(accessListItem);
function WA(A, t, s) {
const I = t?.name ?? A, i = t?.registerFunctionSelectors ?? !0, o = t?.openAccess ?? !0, _ = [], r = [], T = t && !t.openAccess ? t.accessList : [];
for (const N of T)
if (N.startsWith("0x"))
_.push(N);
else {
if (s && !s.includes(N))
throw C(["overrideSystems", A, "accessList"], N);
r.push(N);
}
}
return { name, registerFunctionSelectors, openAccess, accessListAddresses, accessListSystems };
return { name: I, registerFunctionSelectors: i, openAccess: o, accessListAddresses: _, accessListSystems: r };
}
async function loadWorldConfig(configPath, existingContracts) {
const config = await loadConfig(configPath);
async function mA(A, t) {
const s = await D(A);
try {
const parsedConfig = zWorldConfig.parse(config);
return resolveWorldConfig(parsedConfig, existingContracts);
} catch (error) {
if (error instanceof ZodError) {
throw fromZodErrorCustom(error, "WorldConfig Validation Error");
} else {
throw error;
}
const I = K.parse(s);
return FA(I, t);
} catch (I) {
throw I instanceof O ? j(I, "WorldConfig Validation Error") : I;
}
}
function mudConfig(config) {
return config;
function yA(A) {
return A;
}
export {
DynamicResolutionType,
MUDError,
NotInsideProjectError,
UnrecognizedSystemErrorFactory,
fromZodErrorCustom,
getDuplicates,
isDynamicResolution,
loadConfig,
loadStoreConfig,
loadWorldConfig,
mudConfig,
parseStaticArray,
parseStoreConfig,
parseWorldConfig,
resolveSystemConfig,
resolveTableId,
resolveWithContext,
resolveWorldConfig,
storeConfig,
validateBaseRoute,
validateCapitalizedName,
validateEnum,
validateEthereumAddress,
validateName,
validateRoute,
validateSelector,
validateSingleLevelRoute,
validateUncapitalizedName,
zAnyCaseName,
zBaseRoute,
zEnumsConfig,
zEthereumAddress,
zObjectName,
zOrdinaryRoute,
zSchemaConfig,
zSelector,
zSingleLevelRoute,
zStoreConfig,
zTableConfig,
zTablesConfig,
zUserEnum,
zValueName,
zWorldConfig
e as DynamicResolutionType,
h as MUDError,
AA as NotInsideProjectError,
C as UnrecognizedSystemErrorFactory,
j as fromZodErrorCustom,
l as getDuplicates,
OA as isDynamicResolution,
D as loadConfig,
xA as loadStoreConfig,
mA as loadWorldConfig,
yA as mudConfig,
m as parseStaticArray,
bA as parseStoreConfig,
cA as parseWorldConfig,
WA as resolveSystemConfig,
aA as resolveTableId,
SA as resolveWithContext,
FA as resolveWorldConfig,
XA as storeConfig,
x as validateBaseRoute,
J as validateCapitalizedName,
Q as validateEnum,
S as validateEthereumAddress,
b as validateName,
X as validateRoute,
c as validateSelector,
a as validateSingleLevelRoute,
H as validateUncapitalizedName,
PA as zAnyCaseName,
QA as zBaseRoute,
dA as zEnumsConfig,
p as zEthereumAddress,
E as zObjectName,
JA as zOrdinaryRoute,
uA as zSchemaConfig,
B as zSelector,
HA as zSingleLevelRoute,
fA as zStoreConfig,
BA as zTableConfig,
UA as zTablesConfig,
y as zUserEnum,
w as zValueName,
K as zWorldConfig
};
//# sourceMappingURL=index.js.map
{
"name": "@latticexyz/config",
"version": "2.0.0-alpha.1.19+f5edd0e9",
"version": "2.0.0-alpha.1.20+9f516461",
"description": "Config for Store and World",

@@ -22,3 +22,3 @@ "repository": {

"dependencies": {
"@latticexyz/schema-type": "^2.0.0-alpha.1.19+f5edd0e9",
"@latticexyz/schema-type": "^2.0.0-alpha.1.20+9f516461",
"chalk": "^5.2.0",

@@ -37,3 +37,3 @@ "esbuild": "^0.17.15",

},
"gitHead": "f5edd0e9fa45896f3713f71de6d3406f6e01098c"
"gitHead": "9f5164613e849a89289491979390e8732a24e691"
}

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc