@latticexyz/world 3.0.0-main-560fd6a0c → 3.0.0-main-69e23a36b
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/chunk-BH75YTBY.js +2 -0
- package/dist/chunk-BH75YTBY.js.map +1 -0
- package/dist/chunk-DK3XOTC2.js +2 -0
- package/dist/chunk-DK3XOTC2.js.map +1 -0
- package/dist/{chunk-236CU3CY.js → chunk-OZBNK257.js} +2 -2
- package/dist/config/v2.d.ts +3 -2
- package/dist/config/v2.js +1 -1
- package/dist/{dynamicResolution-b1bf86e3.d.ts → dynamicResolution-34391fca.d.ts} +17 -1
- package/dist/index.d.ts +6 -14
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/internal.d.ts +1 -1
- package/dist/internal.js +1 -1
- package/dist/mud.config.d.ts +386 -38
- package/dist/mud.config.js +1 -1
- package/dist/node.d.ts +2 -5
- package/dist/node.js +3 -3
- package/dist/node.js.map +1 -1
- package/dist/{world-95f49fc0.d.ts → world-6e8198d8.d.ts} +91 -52
- package/package.json +8 -8
- package/dist/chunk-JEHHYC6A.js +0 -2
- package/dist/chunk-JEHHYC6A.js.map +0 -1
- package/dist/chunk-QWCOI4NR.js +0 -2
- package/dist/chunk-QWCOI4NR.js.map +0 -1
- /package/dist/{chunk-236CU3CY.js.map → chunk-OZBNK257.js.map} +0 -0
@@ -0,0 +1,2 @@
|
|
1
|
+
import{h as c,i as p,j as l,k as r,l as i,m as y}from"./chunk-DK3XOTC2.js";import{extendedScope as k,get as j,resolveTable as L,validateTable as F,mergeIfUndefined as a,resolveStore as $,hasOwnKey as S,validateStore as C}from"@latticexyz/store/config/v2";import{isObject as w}from"@latticexyz/store/config/v2";function f(e){if(w(e)){for(let s of Object.values(e))i(s,{inNamespace:!0});return}throw new Error(`Expected system config, received ${JSON.stringify(e)}`)}function v(e,s){return Object.fromEntries(Object.entries(e).map(([o,n])=>[o,y({...n,label:o,namespace:s})]))}import{validateTables as I,isObject as N,hasOwnKey as O}from"@latticexyz/store/config/v2";function D(e,s){O(e,"tables")&&I(e.tables,s)}function b(e,s){if(!N(e))throw new Error(`Expected namespaces, received ${JSON.stringify(e)}`);for(let o of Object.values(e))D(o,s)}import{isObject as U,mergeIfUndefined as W}from"@latticexyz/store/config/v2";function u(e){return U(e)?W(e,p):p}import{mergeIfUndefined as _,isObject as A}from"@latticexyz/store/config/v2";function x(e){return A(e)?_(e,l):l}function h(e){let s=k(e);C(e),S(e,"systems")&&f(e.systems),S(e,"namespaces")&&b(e.namespaces,s)}function M(e){let s=k(e),o=$(e),n=e.namespaces??{},g=Object.fromEntries(Object.entries(n).map(([t,T])=>Object.entries(T.tables??{}).map(([m,d])=>(F(d,s),[`${t}__${m}`,L(a(d,{namespace:t,name:m}),s)]))).flat()),E=(e.modules??r.modules).map(t=>a(t,c));return a({...o,tables:{...o.tables,...g},codegen:a(o.codegen,u(e.codegen)),deploy:x(e.deploy),systems:v(e.systems??r.systems,o.namespace),excludeSystems:j(e,"excludeSystems"),modules:E},r)}function ye(e){return h(e),M(e)}export{h as a,M as b,ye as c};
|
2
|
+
//# sourceMappingURL=chunk-BH75YTBY.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"sources":["../ts/config/v2/world.ts","../ts/config/v2/systems.ts","../ts/config/v2/namespaces.ts","../ts/config/v2/codegen.ts","../ts/config/v2/deploy.ts"],"sourcesContent":["import { ErrorMessage, conform, narrow, type withJsDoc } from \"@arktype/util\";\nimport {\n UserTypes,\n extendedScope,\n get,\n resolveTable,\n validateTable,\n mergeIfUndefined,\n validateTables,\n resolveStore,\n Store,\n hasOwnKey,\n validateStore,\n} from \"@latticexyz/store/config/v2\";\nimport { SystemsInput, WorldInput } from \"./input\";\nimport { CONFIG_DEFAULTS, MODULE_DEFAULTS } from \"./defaults\";\nimport { Tables } from \"@latticexyz/store/internal\";\nimport { resolveSystems, validateSystems } from \"./systems\";\nimport { resolveNamespacedTables, validateNamespaces } from \"./namespaces\";\nimport { resolveCodegen } from \"./codegen\";\nimport { resolveDeploy } from \"./deploy\";\nimport type { World } from \"./output.js\";\n\nexport type validateWorld<world> = {\n readonly [key in keyof world]: key extends \"tables\"\n ? validateTables<world[key], extendedScope<world>>\n : key extends \"userTypes\"\n ? UserTypes\n : key extends \"enums\"\n ? narrow<world[key]>\n : key extends \"systems\"\n ? validateSystems<world[key]>\n : key extends \"namespaces\"\n ? // ? validateNamespaces<world[key], extendedScope<world>>\n ErrorMessage<`Namespaces config will be enabled soon.`>\n : key extends keyof WorldInput\n ? conform<world[key], WorldInput[key]>\n : ErrorMessage<`\\`${key & string}\\` is not a valid World config option.`>;\n};\n\nexport function validateWorld(world: unknown): asserts world is WorldInput {\n const scope = extendedScope(world);\n validateStore(world);\n\n if (hasOwnKey(world, \"systems\")) {\n validateSystems(world.systems);\n }\n if (hasOwnKey(world, \"namespaces\")) {\n validateNamespaces(world.namespaces, scope);\n }\n}\n\nexport type resolveWorld<world, namespace = resolveStore<world>[\"namespace\"]> = withJsDoc<\n resolveStore<world> &\n mergeIfUndefined<\n { readonly tables: resolveNamespacedTables<world> } & {\n [key in Exclude<keyof world, keyof Store>]: key extends \"systems\"\n ? resolveSystems<world[key] & SystemsInput, namespace & string>\n : key extends \"deploy\"\n ? resolveDeploy<world[key]>\n : key extends \"codegen\"\n ? resolveCodegen<world[key]>\n : world[key];\n },\n CONFIG_DEFAULTS\n >,\n World\n>;\n\nexport function resolveWorld<const world extends WorldInput>(world: world): resolveWorld<world> {\n const scope = extendedScope(world);\n const resolvedStore = resolveStore(world);\n const namespaces = world.namespaces ?? {};\n\n const resolvedNamespacedTables = Object.fromEntries(\n Object.entries(namespaces)\n .map(([namespaceKey, namespace]) =>\n Object.entries(namespace.tables ?? {}).map(([tableKey, table]) => {\n validateTable(table, scope);\n return [\n `${namespaceKey}__${tableKey}`,\n resolveTable(mergeIfUndefined(table, { namespace: namespaceKey, name: tableKey }), scope),\n ];\n }),\n )\n .flat(),\n ) as Tables;\n\n const modules = (world.modules ?? CONFIG_DEFAULTS.modules).map((mod) => mergeIfUndefined(mod, MODULE_DEFAULTS));\n\n return mergeIfUndefined(\n {\n ...resolvedStore,\n tables: { ...resolvedStore.tables, ...resolvedNamespacedTables },\n codegen: mergeIfUndefined(resolvedStore.codegen, resolveCodegen(world.codegen)),\n deploy: resolveDeploy(world.deploy),\n systems: resolveSystems(world.systems ?? CONFIG_DEFAULTS.systems, resolvedStore.namespace),\n excludeSystems: get(world, \"excludeSystems\"),\n modules,\n },\n CONFIG_DEFAULTS,\n ) as never;\n}\n\nexport function defineWorld<const input>(input: validateWorld<input>): resolveWorld<input> {\n validateWorld(input);\n return resolveWorld(input) as never;\n}\n","import { ErrorMessage } from \"@arktype/util\";\nimport { isObject } from \"@latticexyz/store/config/v2\";\nimport { SystemsInput } from \"./input\";\nimport { resolveSystem, validateSystem } from \"./system\";\n\n// TODO: add nuance between \"in namespace\" (namespace provided in context) and \"in systems\" (label provided in context)\n\nexport type validateSystems<input> = {\n [label in keyof input]: input[label] extends object\n ? validateSystem<input[label], { inNamespace: true }>\n : ErrorMessage<`Expected a system config for ${label & string}.`>;\n};\n\nexport function validateSystems(input: unknown): asserts input is SystemsInput {\n if (isObject(input)) {\n for (const table of Object.values(input)) {\n validateSystem(table, { inNamespace: true });\n }\n return;\n }\n throw new Error(`Expected system config, received ${JSON.stringify(input)}`);\n}\n\nexport type resolveSystems<systems extends SystemsInput, namespace extends string> = {\n [label in keyof systems]: resolveSystem<systems[label] & { label: label; namespace: namespace }>;\n};\n\nexport function resolveSystems<systems extends SystemsInput, namespace extends string>(\n systems: systems,\n namespace: namespace,\n): resolveSystems<systems, namespace> {\n return Object.fromEntries(\n Object.entries(systems).map(([label, system]) => {\n return [label, resolveSystem({ ...system, label, namespace })];\n }),\n ) as never;\n}\n","import {\n Scope,\n AbiTypeScope,\n validateTables,\n isObject,\n hasOwnKey,\n resolveTable,\n mergeIfUndefined,\n extendedScope,\n getPath,\n} from \"@latticexyz/store/config/v2\";\nimport { NamespaceInput, NamespacesInput } from \"./input\";\nimport { ErrorMessage, conform } from \"@arktype/util\";\n\nexport type namespacedTableKeys<world> = world extends { namespaces: infer namespaces }\n ? {\n [k in keyof namespaces]: namespaces[k] extends { tables: infer tables }\n ? `${k & string}__${keyof tables & string}`\n : never;\n }[keyof namespaces]\n : never;\n\nexport type validateNamespace<namespace, scope extends Scope = AbiTypeScope> = {\n readonly [key in keyof namespace]: key extends \"tables\"\n ? validateTables<namespace[key], scope>\n : key extends keyof NamespaceInput\n ? conform<namespace[key], NamespaceInput[key]>\n : ErrorMessage<`\\`${key & string}\\` is not a valid namespace config option.`>;\n};\n\nexport function validateNamespace<scope extends Scope = AbiTypeScope>(\n namespace: unknown,\n scope: scope,\n): asserts namespace is NamespaceInput {\n if (hasOwnKey(namespace, \"tables\")) {\n validateTables(namespace.tables, scope);\n }\n}\n\nexport type validateNamespaces<namespaces, scope extends Scope = AbiTypeScope> = {\n [label in keyof namespaces]: validateNamespace<namespaces[label], scope>;\n};\n\nexport function validateNamespaces<scope extends Scope = AbiTypeScope>(\n namespaces: unknown,\n scope: scope,\n): asserts namespaces is NamespacesInput {\n if (!isObject(namespaces)) {\n throw new Error(`Expected namespaces, received ${JSON.stringify(namespaces)}`);\n }\n for (const namespace of Object.values(namespaces)) {\n validateNamespace(namespace, scope);\n }\n}\n\nexport type resolveNamespacedTables<world> = \"namespaces\" extends keyof world\n ? {\n readonly [key in namespacedTableKeys<world>]: key extends `${infer namespace}__${infer table}`\n ? resolveTable<\n mergeIfUndefined<\n getPath<world, [\"namespaces\", namespace, \"tables\", table]>,\n { name: table; namespace: namespace }\n >,\n extendedScope<world>\n >\n : never;\n }\n : {};\n","import { isObject, mergeIfUndefined } from \"@latticexyz/store/config/v2\";\nimport { CODEGEN_DEFAULTS } from \"./defaults\";\n\nexport type resolveCodegen<codegen> = codegen extends {}\n ? mergeIfUndefined<codegen, CODEGEN_DEFAULTS>\n : CODEGEN_DEFAULTS;\n\nexport function resolveCodegen<codegen>(codegen: codegen): resolveCodegen<codegen> {\n return (isObject(codegen) ? mergeIfUndefined(codegen, CODEGEN_DEFAULTS) : CODEGEN_DEFAULTS) as never;\n}\n","import { mergeIfUndefined, isObject } from \"@latticexyz/store/config/v2\";\nimport { DEPLOY_DEFAULTS } from \"./defaults\";\n\nexport type resolveDeploy<deploy> = deploy extends {} ? mergeIfUndefined<deploy, DEPLOY_DEFAULTS> : DEPLOY_DEFAULTS;\n\nexport function resolveDeploy<deploy>(deploy: deploy): resolveDeploy<deploy> {\n return (isObject(deploy) ? mergeIfUndefined(deploy, DEPLOY_DEFAULTS) : DEPLOY_DEFAULTS) as never;\n}\n"],"mappings":"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","names":["extendedScope","get","resolveTable","validateTable","mergeIfUndefined","resolveStore","hasOwnKey","validateStore","isObject","validateSystems","input","isObject","table","validateSystem","resolveSystems","systems","namespace","label","system","resolveSystem","validateTables","isObject","hasOwnKey","validateNamespace","namespace","scope","validateNamespaces","namespaces","isObject","mergeIfUndefined","resolveCodegen","codegen","isObject","mergeIfUndefined","CODEGEN_DEFAULTS","mergeIfUndefined","isObject","resolveDeploy","deploy","isObject","mergeIfUndefined","DEPLOY_DEFAULTS","validateWorld","world","scope","extendedScope","validateStore","hasOwnKey","validateSystems","validateNamespaces","resolveWorld","resolvedStore","resolveStore","namespaces","resolvedNamespacedTables","namespaceKey","namespace","tableKey","table","validateTable","resolveTable","mergeIfUndefined","modules","CONFIG_DEFAULTS","mod","MODULE_DEFAULTS","resolveCodegen","resolveDeploy","resolveSystems","get","defineWorld","input"]}
|
@@ -0,0 +1,2 @@
|
|
1
|
+
var c=Object.create;var a=Object.defineProperty;var m=Object.getOwnPropertyDescriptor;var y=Object.getOwnPropertyNames;var l=Object.getPrototypeOf,d=Object.prototype.hasOwnProperty;var u=(e,t,s)=>t in e?a(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s;var L=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports);var S=(e,t,s,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of y(t))!d.call(e,o)&&o!==s&&a(e,o,{get:()=>t[o],enumerable:!(n=m(t,o))||n.enumerable});return e};var F=(e,t,s)=>(s=e!=null?c(l(e)):{},S(t||!e||!e.__esModule?a(s,"default",{value:e,enumerable:!0}):s,e));var T=(e,t,s)=>(u(e,typeof t!="symbol"?t+"":t,s),s),p=(e,t,s)=>{if(!t.has(e))throw TypeError("Cannot "+s)};var I=(e,t,s)=>(p(e,t,"read from private field"),s?s.call(e):t.get(e)),g=(e,t,s)=>{if(t.has(e))throw TypeError("Cannot add the same private member more than once");t instanceof WeakSet?t.add(e):t.set(e,s)},A=(e,t,s,n)=>(p(e,t,"write to private field"),n?n.call(e,s):t.set(e,s),s);var U=(e,t,s)=>(p(e,t,"access private method"),s);var i={namespace:"",registerFunctionSelectors:!0,openAccess:!0,accessList:[]},w={root:!1,args:[],artifactPath:void 0},f={worldInterfaceName:"IWorld",worldgenDirectory:"world",worldImportPath:"@latticexyz/world/src/"},E={customWorldContract:void 0,postDeployScript:"PostDeploy",deploysDirectory:"./deploys",worldsFile:"./worlds.json",upgradeableWorldImplementation:!1},_={systems:{},tables:{},excludeSystems:[],modules:[],codegen:f,deploy:E};import{hasOwnKey as r,mergeIfUndefined as x}from"@latticexyz/store/config/v2";import{resourceToHex as D}from"@latticexyz/common";function h(e,t={}){if(typeof e!="object"||e==null)throw new Error(`Expected full system config, got \`${JSON.stringify(e)}\``);if(t.inNamespace&&(r(e,"label")||r(e,"namespace")))throw new Error("Overrides of `label` and `namespace` are not allowed for systems in this context.");if(r(e,"namespace")&&typeof e.namespace=="string"&&e.namespace.length>14)throw new Error(`System \`namespace\` must fit into a \`bytes14\`, but "${e.namespace}" is too long.`);if(r(e,"name")&&typeof e.name=="string"&&e.name.length>16)throw new Error(`System \`name\` must fit into a \`bytes16\`, but "${e.name}" is too long.`)}function k(e){let t=e.label,s=e.namespace??i.namespace,n=e.name??t.slice(0,16),o=D({type:"system",namespace:s,name:n});return x({...e,label:t,namespace:s,name:n,systemId:o},i)}export{L as a,F as b,T as c,I as d,g as e,A as f,U as g,w as h,f as i,E as j,_ as k,h as l,k as m};
|
2
|
+
//# sourceMappingURL=chunk-DK3XOTC2.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"sources":["../ts/config/v2/defaults.ts","../ts/config/v2/system.ts"],"sourcesContent":["import { CodegenInput, DeployInput, ModuleInput, SystemInput, WorldInput } from \"./input\";\n\nexport const SYSTEM_DEFAULTS = {\n namespace: \"\",\n registerFunctionSelectors: true,\n openAccess: true,\n accessList: [],\n} as const satisfies Omit<Required<SystemInput>, \"label\" | \"name\">;\n\nexport type SYSTEM_DEFAULTS = typeof SYSTEM_DEFAULTS;\n\nexport const MODULE_DEFAULTS = {\n root: false,\n args: [],\n artifactPath: undefined,\n} as const satisfies Pick<ModuleInput, \"root\" | \"args\" | \"artifactPath\">;\n\nexport type MODULE_DEFAULTS = typeof MODULE_DEFAULTS;\n\nexport const CODEGEN_DEFAULTS = {\n worldInterfaceName: \"IWorld\",\n worldgenDirectory: \"world\",\n worldImportPath: \"@latticexyz/world/src/\",\n} as const satisfies CodegenInput;\n\nexport type CODEGEN_DEFAULTS = typeof CODEGEN_DEFAULTS;\n\nexport const DEPLOY_DEFAULTS = {\n customWorldContract: undefined,\n postDeployScript: \"PostDeploy\",\n deploysDirectory: \"./deploys\",\n worldsFile: \"./worlds.json\",\n upgradeableWorldImplementation: false,\n} as const satisfies DeployInput;\n\nexport type DEPLOY_DEFAULTS = typeof DEPLOY_DEFAULTS;\n\nexport const CONFIG_DEFAULTS = {\n systems: {},\n tables: {},\n excludeSystems: [],\n modules: [],\n codegen: CODEGEN_DEFAULTS,\n deploy: DEPLOY_DEFAULTS,\n} as const satisfies WorldInput;\n\nexport type CONFIG_DEFAULTS = typeof CONFIG_DEFAULTS;\n","import { SYSTEM_DEFAULTS } from \"./defaults\";\nimport { SystemInput } from \"./input\";\nimport { hasOwnKey, mergeIfUndefined } from \"@latticexyz/store/config/v2\";\nimport { ErrorMessage, narrow, requiredKeyOf } from \"@arktype/util\";\nimport { Hex } from \"viem\";\nimport { resourceToHex } from \"@latticexyz/common\";\n\nexport type ValidateSystemOptions = { readonly inNamespace?: true };\n\nexport type requiredSystemKey<inNamespace extends true | undefined> = Exclude<\n requiredKeyOf<SystemInput>,\n inNamespace extends true ? \"label\" | \"namespace\" : never\n>;\n\nexport type validateSystem<input, options extends ValidateSystemOptions = {}> = {\n [key in keyof input | requiredSystemKey<options[\"inNamespace\"]>]: key extends keyof SystemInput\n ? key extends \"label\" | \"namespace\"\n ? options[\"inNamespace\"] extends true\n ? ErrorMessage<\"Overrides of `label` and `namespace` are not allowed for systems in this context.\">\n : key extends keyof input\n ? narrow<input[key]>\n : never\n : SystemInput[key]\n : ErrorMessage<`Key \\`${key & string}\\` does not exist in SystemInput`>;\n};\n\nexport function validateSystem<input>(\n input: input,\n options: ValidateSystemOptions = {},\n): asserts input is SystemInput & input {\n if (typeof input !== \"object\" || input == null) {\n throw new Error(`Expected full system config, got \\`${JSON.stringify(input)}\\``);\n }\n\n if (options.inNamespace && (hasOwnKey(input, \"label\") || hasOwnKey(input, \"namespace\"))) {\n throw new Error(\"Overrides of `label` and `namespace` are not allowed for systems in this context.\");\n }\n\n if (hasOwnKey(input, \"namespace\") && typeof input.namespace === \"string\" && input.namespace.length > 14) {\n throw new Error(`System \\`namespace\\` must fit into a \\`bytes14\\`, but \"${input.namespace}\" is too long.`);\n }\n if (hasOwnKey(input, \"name\") && typeof input.name === \"string\" && input.name.length > 16) {\n throw new Error(`System \\`name\\` must fit into a \\`bytes16\\`, but \"${input.name}\" is too long.`);\n }\n}\n\nexport type resolveSystem<input> = input extends SystemInput\n ? {\n readonly label: input[\"label\"];\n readonly namespace: undefined extends input[\"namespace\"] ? SYSTEM_DEFAULTS[\"namespace\"] : input[\"namespace\"];\n readonly name: string;\n readonly systemId: Hex;\n readonly registerFunctionSelectors: undefined extends input[\"registerFunctionSelectors\"]\n ? SYSTEM_DEFAULTS[\"registerFunctionSelectors\"]\n : input[\"registerFunctionSelectors\"];\n readonly openAccess: undefined extends input[\"openAccess\"] ? SYSTEM_DEFAULTS[\"openAccess\"] : input[\"openAccess\"];\n readonly accessList: undefined extends input[\"accessList\"] ? SYSTEM_DEFAULTS[\"accessList\"] : input[\"accessList\"];\n }\n : never;\n\nexport function resolveSystem<input extends SystemInput>(input: input): resolveSystem<input> {\n const label = input.label;\n const namespace = input.namespace ?? SYSTEM_DEFAULTS.namespace;\n const name = input.name ?? label.slice(0, 16);\n const systemId = resourceToHex({ type: \"system\", namespace, name });\n\n return mergeIfUndefined(\n {\n ...input,\n label,\n namespace,\n name,\n systemId,\n },\n SYSTEM_DEFAULTS,\n ) as never;\n}\n\nexport function defineSystem<input>(input: validateSystem<input>): resolveSystem<input> {\n validateSystem(input);\n return resolveSystem(input) as never;\n}\n"],"mappings":"shCAEO,IAAMA,EAAkB,CAC7B,UAAW,GACX,0BAA2B,GAC3B,WAAY,GACZ,WAAY,CAAC,CACf,EAIaC,EAAkB,CAC7B,KAAM,GACN,KAAM,CAAC,EACP,aAAc,MAChB,EAIaC,EAAmB,CAC9B,mBAAoB,SACpB,kBAAmB,QACnB,gBAAiB,wBACnB,EAIaC,EAAkB,CAC7B,oBAAqB,OACrB,iBAAkB,aAClB,iBAAkB,YAClB,WAAY,gBACZ,+BAAgC,EAClC,EAIaC,EAAkB,CAC7B,QAAS,CAAC,EACV,OAAQ,CAAC,EACT,eAAgB,CAAC,EACjB,QAAS,CAAC,EACV,QAASF,EACT,OAAQC,CACV,EC1CA,OAAS,aAAAE,EAAW,oBAAAC,MAAwB,8BAG5C,OAAS,iBAAAC,MAAqB,qBAqBvB,SAASC,EACdC,EACAC,EAAiC,CAAC,EACI,CACtC,GAAI,OAAOD,GAAU,UAAYA,GAAS,KACxC,MAAM,IAAI,MAAM,sCAAsC,KAAK,UAAUA,CAAK,KAAK,EAGjF,GAAIC,EAAQ,cAAgBL,EAAUI,EAAO,OAAO,GAAKJ,EAAUI,EAAO,WAAW,GACnF,MAAM,IAAI,MAAM,mFAAmF,EAGrG,GAAIJ,EAAUI,EAAO,WAAW,GAAK,OAAOA,EAAM,WAAc,UAAYA,EAAM,UAAU,OAAS,GACnG,MAAM,IAAI,MAAM,0DAA0DA,EAAM,yBAAyB,EAE3G,GAAIJ,EAAUI,EAAO,MAAM,GAAK,OAAOA,EAAM,MAAS,UAAYA,EAAM,KAAK,OAAS,GACpF,MAAM,IAAI,MAAM,qDAAqDA,EAAM,oBAAoB,CAEnG,CAgBO,SAASE,EAAyCF,EAAoC,CAC3F,IAAMG,EAAQH,EAAM,MACdI,EAAYJ,EAAM,WAAaK,EAAgB,UAC/CC,EAAON,EAAM,MAAQG,EAAM,MAAM,EAAG,EAAE,EACtCI,EAAWT,EAAc,CAAE,KAAM,SAAU,UAAAM,EAAW,KAAAE,CAAK,CAAC,EAElE,OAAOT,EACL,CACE,GAAGG,EACH,MAAAG,EACA,UAAAC,EACA,KAAAE,EACA,SAAAC,CACF,EACAF,CACF,CACF","names":["SYSTEM_DEFAULTS","MODULE_DEFAULTS","CODEGEN_DEFAULTS","DEPLOY_DEFAULTS","CONFIG_DEFAULTS","hasOwnKey","mergeIfUndefined","resourceToHex","validateSystem","input","options","resolveSystem","label","namespace","SYSTEM_DEFAULTS","name","systemId"]}
|
@@ -1,2 +1,2 @@
|
|
1
|
-
import{c as e}from"./chunk-
|
2
|
-
//# sourceMappingURL=chunk-
|
1
|
+
import{c as e}from"./chunk-BH75YTBY.js";var a=e({codegen:{worldImportPath:"../../",worldgenDirectory:"interfaces",worldInterfaceName:"IBaseWorld"},namespace:"world",userTypes:{ResourceId:{filePath:"@latticexyz/store/src/ResourceId.sol",type:"bytes32"}},tables:{NamespaceOwner:{schema:{namespaceId:"ResourceId",owner:"address"},key:["namespaceId"]},ResourceAccess:{schema:{resourceId:"ResourceId",caller:"address",access:"bool"},key:["resourceId","caller"]},InstalledModules:{schema:{moduleAddress:"address",argumentsHash:"bytes32",isInstalled:"bool"},key:["moduleAddress","argumentsHash"]},UserDelegationControl:{schema:{delegator:"address",delegatee:"address",delegationControlId:"ResourceId"},key:["delegator","delegatee"]},NamespaceDelegationControl:{schema:{namespaceId:"ResourceId",delegationControlId:"ResourceId"},key:["namespaceId"]},Balances:{schema:{namespaceId:"ResourceId",balance:"uint256"},key:["namespaceId"]},Systems:{schema:{systemId:"ResourceId",system:"address",publicAccess:"bool"},key:["systemId"],codegen:{dataStruct:!1}},SystemRegistry:{schema:{system:"address",systemId:"ResourceId"},key:["system"]},SystemHooks:{schema:{systemId:"ResourceId",value:"bytes21[]"},key:["systemId"]},FunctionSelectors:{schema:{worldFunctionSelector:"bytes4",systemId:"ResourceId",systemFunctionSelector:"bytes4"},key:["worldFunctionSelector"],codegen:{dataStruct:!1}},FunctionSignatures:{type:"offchainTable",schema:{functionSelector:"bytes4",functionSignature:"string"},key:["functionSelector"]},InitModuleAddress:{schema:{value:"address"},key:[]}},excludeSystems:["StoreRegistrationSystem"]});export{a};
|
2
|
+
//# sourceMappingURL=chunk-OZBNK257.js.map
|
package/dist/config/v2.d.ts
CHANGED
@@ -1,5 +1,6 @@
|
|
1
|
-
export { d as defineWorld, r as resolveWorld, v as validateWorld } from '../world-
|
2
|
-
export { C as Codegen, D as Deploy, M as Module, S as System, b as Systems, W as World } from '../dynamicResolution-
|
1
|
+
export { d as defineWorld, r as resolveWorld, v as validateWorld } from '../world-6e8198d8.js';
|
2
|
+
export { C as Codegen, D as Deploy, M as Module, S as System, b as Systems, W as World } from '../dynamicResolution-34391fca.js';
|
3
3
|
import '@arktype/util';
|
4
4
|
import '@latticexyz/store/config/v2';
|
5
|
+
import 'viem';
|
5
6
|
import '@latticexyz/store';
|
package/dist/config/v2.js
CHANGED
@@ -1,2 +1,2 @@
|
|
1
|
-
import{a as o,b as r,c as e}from"../chunk-
|
1
|
+
import{a as o,b as r,c as e}from"../chunk-BH75YTBY.js";import"../chunk-DK3XOTC2.js";export{e as defineWorld,r as resolveWorld,o as validateWorld};
|
2
2
|
//# sourceMappingURL=v2.js.map
|
@@ -1,4 +1,5 @@
|
|
1
1
|
import { Store } from '@latticexyz/store';
|
2
|
+
import { Hex } from 'viem';
|
2
3
|
|
3
4
|
type Module = {
|
4
5
|
/**
|
@@ -22,8 +23,23 @@ type Module = {
|
|
22
23
|
readonly artifactPath: string | undefined;
|
23
24
|
};
|
24
25
|
type System = {
|
25
|
-
/**
|
26
|
+
/**
|
27
|
+
* Human-readable system label. Used as config keys, interface names, and filenames.
|
28
|
+
* Labels are not length constrained like resource names, but special characters should be avoided to be compatible with the filesystem, Solidity compiler, etc.
|
29
|
+
*/
|
30
|
+
readonly label: string;
|
31
|
+
/**
|
32
|
+
* System namespace used in system's resource ID and determines access control.
|
33
|
+
*/
|
34
|
+
readonly namespace: string;
|
35
|
+
/**
|
36
|
+
* System name used in system's resource ID.
|
37
|
+
*/
|
26
38
|
readonly name: string;
|
39
|
+
/**
|
40
|
+
* System's resource ID.
|
41
|
+
*/
|
42
|
+
readonly systemId: Hex;
|
27
43
|
/**
|
28
44
|
* Register function selectors for the system in the World.
|
29
45
|
* Defaults to true.
|
package/dist/index.d.ts
CHANGED
@@ -1,26 +1,18 @@
|
|
1
|
-
import { validateTablesWithShorthands, extendedScope,
|
2
|
-
import { v as validateWorld,
|
3
|
-
export { W as World } from './dynamicResolution-
|
1
|
+
import { validateTablesWithShorthands, extendedScope, resolveTablesWithShorthands } from '@latticexyz/store/config/v2';
|
2
|
+
import { v as validateWorld, r as resolveWorld, W as WorldWithShorthandsInput } from './world-6e8198d8.js';
|
3
|
+
export { W as World } from './dynamicResolution-34391fca.js';
|
4
4
|
import '@arktype/util';
|
5
|
+
import 'viem';
|
5
6
|
import '@latticexyz/store';
|
6
7
|
|
7
8
|
declare const worldDeployedEvent = "event WorldDeployed(address indexed newContract, uint256 salt)";
|
8
9
|
declare const helloWorldEvent = "event HelloWorld(bytes32 indexed worldVersion)";
|
9
10
|
|
10
11
|
type validateWorldWithShorthands<world> = {
|
11
|
-
[key in keyof world]: key extends "tables" ? validateTablesWithShorthands<world[key], extendedScope<world>> :
|
12
|
-
};
|
13
|
-
type validateNamespacesWithShorthands<namespaces, scope extends Scope = AbiTypeScope> = {
|
14
|
-
[namespace in keyof namespaces]: {
|
15
|
-
[key in keyof namespaces[namespace]]: key extends "tables" ? validateTablesWithShorthands<namespaces[namespace][key], scope> : validateNamespace<namespaces[namespace], scope>[key];
|
16
|
-
};
|
12
|
+
[key in keyof world]: key extends "tables" ? validateTablesWithShorthands<world[key], extendedScope<world>> : validateWorld<world>[key];
|
17
13
|
};
|
18
14
|
type resolveWorldWithShorthands<world> = resolveWorld<{
|
19
|
-
[key in keyof world]: key extends "tables" ? resolveTablesWithShorthands<world[key], extendedScope<world>> : key
|
20
|
-
[namespaceKey in keyof world[key]]: {
|
21
|
-
[namespaceProp in keyof world[key][namespaceKey]]: namespaceProp extends "tables" ? resolveTablesWithShorthands<world[key][namespaceKey][namespaceProp], extendedScope<world>> : world[key][namespaceKey][namespaceProp];
|
22
|
-
};
|
23
|
-
} : world[key];
|
15
|
+
readonly [key in keyof world]: key extends "tables" ? resolveTablesWithShorthands<world[key], extendedScope<world>> : world[key];
|
24
16
|
}>;
|
25
17
|
declare function resolveWorldWithShorthands<world extends WorldWithShorthandsInput>(world: world): resolveWorldWithShorthands<world>;
|
26
18
|
declare function defineWorldWithShorthands<world>(world: validateWorldWithShorthands<world>): resolveWorldWithShorthands<world>;
|
package/dist/index.js
CHANGED
@@ -1,2 +1,2 @@
|
|
1
|
-
import{a as
|
1
|
+
import{a as n,b as l}from"./chunk-BH75YTBY.js";import"./chunk-DK3XOTC2.js";var i="event WorldDeployed(address indexed newContract, uint256 salt)",W="event HelloWorld(bytes32 indexed worldVersion)";import{mapObject as p}from"@latticexyz/common/utils";import{extendedScope as h,getPath as c,hasOwnKey as s,isObject as v,isTableShorthandInput as f,resolveTableShorthand as y,validateTablesWithShorthands as a}from"@latticexyz/store/config/v2";function S(e){let o=h(e);if(s(e,"tables")&&a(e.tables,o),s(e,"namespaces")&&v(e.namespaces))for(let t of Object.keys(e.namespaces))a(c(e.namespaces,[t,"tables"])??{},o)}function m(e){let o=h(e),t=p(e.tables??{},r=>f(r)?y(r,o):r),d={...e,tables:t};return n(d),l(d)}function x(e){return S(e),m(e)}export{x as defineWorld,W as helloWorldEvent,i as worldDeployedEvent};
|
2
2
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../ts/worldEvents.ts","../ts/config/v2/worldWithShorthands.ts"],"sourcesContent":["// from WorldFactory\nexport const worldDeployedEvent = \"event WorldDeployed(address indexed newContract, uint256 salt)\";\n\n// from World\nexport const helloWorldEvent = \"event HelloWorld(bytes32 indexed worldVersion)\";\n","import { mapObject } from \"@latticexyz/common/utils\";\nimport {\n
|
1
|
+
{"version":3,"sources":["../ts/worldEvents.ts","../ts/config/v2/worldWithShorthands.ts"],"sourcesContent":["// from WorldFactory\nexport const worldDeployedEvent = \"event WorldDeployed(address indexed newContract, uint256 salt)\";\n\n// from World\nexport const helloWorldEvent = \"event HelloWorld(bytes32 indexed worldVersion)\";\n","import { mapObject } from \"@latticexyz/common/utils\";\nimport {\n extendedScope,\n getPath,\n hasOwnKey,\n isObject,\n isTableShorthandInput,\n resolveTableShorthand,\n resolveTablesWithShorthands,\n validateTablesWithShorthands,\n} from \"@latticexyz/store/config/v2\";\nimport { WorldWithShorthandsInput } from \"./input\";\nimport { resolveWorld, validateWorld } from \"./world\";\n\nexport type validateWorldWithShorthands<world> = {\n [key in keyof world]: key extends \"tables\"\n ? validateTablesWithShorthands<world[key], extendedScope<world>>\n : validateWorld<world>[key];\n};\n\nfunction validateWorldWithShorthands(world: unknown): asserts world is WorldWithShorthandsInput {\n const scope = extendedScope(world);\n if (hasOwnKey(world, \"tables\")) {\n validateTablesWithShorthands(world.tables, scope);\n }\n\n if (hasOwnKey(world, \"namespaces\") && isObject(world.namespaces)) {\n for (const namespaceKey of Object.keys(world.namespaces)) {\n validateTablesWithShorthands(getPath(world.namespaces, [namespaceKey, \"tables\"]) ?? {}, scope);\n }\n }\n}\n\nexport type resolveWorldWithShorthands<world> = resolveWorld<{\n readonly [key in keyof world]: key extends \"tables\"\n ? resolveTablesWithShorthands<world[key], extendedScope<world>>\n : world[key];\n}>;\n\nexport function resolveWorldWithShorthands<world extends WorldWithShorthandsInput>(\n world: world,\n): resolveWorldWithShorthands<world> {\n const scope = extendedScope(world);\n const tables = mapObject(world.tables ?? {}, (table) => {\n return isTableShorthandInput(table) ? resolveTableShorthand(table, scope) : table;\n });\n\n const fullConfig = { ...world, tables };\n validateWorld(fullConfig);\n\n return resolveWorld(fullConfig) as never;\n}\n\nexport function defineWorldWithShorthands<world>(\n world: validateWorldWithShorthands<world>,\n): resolveWorldWithShorthands<world> {\n validateWorldWithShorthands(world);\n return resolveWorldWithShorthands(world) as never;\n}\n"],"mappings":"2EACO,IAAMA,EAAqB,iEAGrBC,EAAkB,iDCJ/B,OAAS,aAAAC,MAAiB,2BAC1B,OACE,iBAAAC,EACA,WAAAC,EACA,aAAAC,EACA,YAAAC,EACA,yBAAAC,EACA,yBAAAC,EAEA,gCAAAC,MACK,8BAUP,SAASC,EAA4BC,EAA2D,CAC9F,IAAMC,EAAQC,EAAcF,CAAK,EAKjC,GAJIG,EAAUH,EAAO,QAAQ,GAC3BI,EAA6BJ,EAAM,OAAQC,CAAK,EAG9CE,EAAUH,EAAO,YAAY,GAAKK,EAASL,EAAM,UAAU,EAC7D,QAAWM,KAAgB,OAAO,KAAKN,EAAM,UAAU,EACrDI,EAA6BG,EAAQP,EAAM,WAAY,CAACM,EAAc,QAAQ,CAAC,GAAK,CAAC,EAAGL,CAAK,CAGnG,CAQO,SAASO,EACdR,EACmC,CACnC,IAAMC,EAAQC,EAAcF,CAAK,EAC3BS,EAASC,EAAUV,EAAM,QAAU,CAAC,EAAIW,GACrCC,EAAsBD,CAAK,EAAIE,EAAsBF,EAAOV,CAAK,EAAIU,CAC7E,EAEKG,EAAa,CAAE,GAAGd,EAAO,OAAAS,CAAO,EACtC,OAAAM,EAAcD,CAAU,EAEjBE,EAAaF,CAAU,CAChC,CAEO,SAASG,EACdjB,EACmC,CACnC,OAAAD,EAA4BC,CAAK,EAC1BQ,EAA2BR,CAAK,CACzC","names":["worldDeployedEvent","helloWorldEvent","mapObject","extendedScope","getPath","hasOwnKey","isObject","isTableShorthandInput","resolveTableShorthand","validateTablesWithShorthands","validateWorldWithShorthands","world","scope","extendedScope","hasOwnKey","validateTablesWithShorthands","isObject","namespaceKey","getPath","resolveWorldWithShorthands","tables","mapObject","table","isTableShorthandInput","resolveTableShorthand","fullConfig","validateWorld","resolveWorld","defineWorldWithShorthands"]}
|
package/dist/internal.d.ts
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
import { Abi, ContractFunctionName, EncodeFunctionDataParameters, Hex, Address, Chain, Account, Client, Transport, WalletActions, PublicClient } from 'viem';
|
2
2
|
import { AbiParametersToPrimitiveTypes, ExtractAbiFunction } from 'abitype';
|
3
|
-
export { r as resolveTableId, a as resolveWithContext } from './dynamicResolution-
|
3
|
+
export { r as resolveTableId, a as resolveWithContext } from './dynamicResolution-34391fca.js';
|
4
4
|
import '@latticexyz/store';
|
5
5
|
|
6
6
|
declare const abi: [
|
package/dist/internal.js
CHANGED
@@ -1,3 +1,3 @@
|
|
1
|
-
import{a as m}from"./chunk-
|
1
|
+
import{a as m}from"./chunk-OZBNK257.js";import"./chunk-BH75YTBY.js";import"./chunk-DK3XOTC2.js";import{encodeFunctionData as C}from"viem";function c({abi:e,systemId:a,functionName:t,args:n}){return[a,C({abi:e,functionName:t,args:n})]}import{encodeFunctionData as x}from"viem";function u({abi:e,from:a,systemId:t,functionName:n,args:i}){return[a,t,x({abi:e,functionName:n,args:i})]}function z(e,a){return a.map(t=>c({...t,abi:e}))}function Y(e,a,t){return t.map(n=>u({...n,abi:e,from:a}))}import{slice as S,concat as F}from"viem";import{getAction as d,encodeFunctionData as A}from"viem/utils";import{writeContract as b}from"viem/actions";import{readHex as g}from"@latticexyz/common";import{getKeySchema as h,getValueSchema as P,getSchemaTypes as f,decodeValueArgs as w,encodeKey as N}from"@latticexyz/protocol-parser/internal";var p=[{type:"function",name:"getDynamicField",inputs:[{name:"tableId",type:"bytes32",internalType:"ResourceId"},{name:"keyTuple",type:"bytes32[]",internalType:"bytes32[]"},{name:"dynamicFieldIndex",type:"uint8",internalType:"uint8"}],outputs:[{name:"",type:"bytes",internalType:"bytes"}],stateMutability:"view"},{type:"function",name:"getDynamicFieldLength",inputs:[{name:"tableId",type:"bytes32",internalType:"ResourceId"},{name:"keyTuple",type:"bytes32[]",internalType:"bytes32[]"},{name:"dynamicFieldIndex",type:"uint8",internalType:"uint8"}],outputs:[{name:"",type:"uint256",internalType:"uint256"}],stateMutability:"view"},{type:"function",name:"getDynamicFieldSlice",inputs:[{name:"tableId",type:"bytes32",internalType:"ResourceId"},{name:"keyTuple",type:"bytes32[]",internalType:"bytes32[]"},{name:"dynamicFieldIndex",type:"uint8",internalType:"uint8"},{name:"start",type:"uint256",internalType:"uint256"},{name:"end",type:"uint256",internalType:"uint256"}],outputs:[{name:"data",type:"bytes",internalType:"bytes"}],stateMutability:"view"},{type:"function",name:"getField",inputs:[{name:"tableId",type:"bytes32",internalType:"ResourceId"},{name:"keyTuple",type:"bytes32[]",internalType:"bytes32[]"},{name:"fieldIndex",type:"uint8",internalType:"uint8"},{name:"fieldLayout",type:"bytes32",internalType:"FieldLayout"}],outputs:[{name:"data",type:"bytes",internalType:"bytes"}],stateMutability:"view"},{type:"function",name:"getField",inputs:[{name:"tableId",type:"bytes32",internalType:"ResourceId"},{name:"keyTuple",type:"bytes32[]",internalType:"bytes32[]"},{name:"fieldIndex",type:"uint8",internalType:"uint8"}],outputs:[{name:"data",type:"bytes",internalType:"bytes"}],stateMutability:"view"},{type:"function",name:"getFieldLayout",inputs:[{name:"tableId",type:"bytes32",internalType:"ResourceId"}],outputs:[{name:"fieldLayout",type:"bytes32",internalType:"FieldLayout"}],stateMutability:"view"},{type:"function",name:"getFieldLength",inputs:[{name:"tableId",type:"bytes32",internalType:"ResourceId"},{name:"keyTuple",type:"bytes32[]",internalType:"bytes32[]"},{name:"fieldIndex",type:"uint8",internalType:"uint8"},{name:"fieldLayout",type:"bytes32",internalType:"FieldLayout"}],outputs:[{name:"",type:"uint256",internalType:"uint256"}],stateMutability:"view"},{type:"function",name:"getFieldLength",inputs:[{name:"tableId",type:"bytes32",internalType:"ResourceId"},{name:"keyTuple",type:"bytes32[]",internalType:"bytes32[]"},{name:"fieldIndex",type:"uint8",internalType:"uint8"}],outputs:[{name:"",type:"uint256",internalType:"uint256"}],stateMutability:"view"},{type:"function",name:"getKeySchema",inputs:[{name:"tableId",type:"bytes32",internalType:"ResourceId"}],outputs:[{name:"keySchema",type:"bytes32",internalType:"Schema"}],stateMutability:"view"},{type:"function",name:"getRecord",inputs:[{name:"tableId",type:"bytes32",internalType:"ResourceId"},{name:"keyTuple",type:"bytes32[]",internalType:"bytes32[]"},{name:"fieldLayout",type:"bytes32",internalType:"FieldLayout"}],outputs:[{name:"staticData",type:"bytes",internalType:"bytes"},{name:"encodedLengths",type:"bytes32",internalType:"EncodedLengths"},{name:"dynamicData",type:"bytes",internalType:"bytes"}],stateMutability:"view"},{type:"function",name:"getRecord",inputs:[{name:"tableId",type:"bytes32",internalType:"ResourceId"},{name:"keyTuple",type:"bytes32[]",internalType:"bytes32[]"}],outputs:[{name:"staticData",type:"bytes",internalType:"bytes"},{name:"encodedLengths",type:"bytes32",internalType:"EncodedLengths"},{name:"dynamicData",type:"bytes",internalType:"bytes"}],stateMutability:"view"},{type:"function",name:"getStaticField",inputs:[{name:"tableId",type:"bytes32",internalType:"ResourceId"},{name:"keyTuple",type:"bytes32[]",internalType:"bytes32[]"},{name:"fieldIndex",type:"uint8",internalType:"uint8"},{name:"fieldLayout",type:"bytes32",internalType:"FieldLayout"}],outputs:[{name:"",type:"bytes32",internalType:"bytes32"}],stateMutability:"view"},{type:"function",name:"getValueSchema",inputs:[{name:"tableId",type:"bytes32",internalType:"ResourceId"}],outputs:[{name:"valueSchema",type:"bytes32",internalType:"Schema"}],stateMutability:"view"}];function le(e){return a=>({writeContract:async t=>{if(t.address!==e.worldAddress||t.functionName==="call"||t.functionName==="callFrom"||t.functionName==="callWithSignature")return d(a,b,"writeContract")(t);let n=A({abi:t.abi,functionName:t.functionName,args:t.args}),i=S(n,0,4),{systemId:o,systemFunctionSelector:r}=await v(e,i),y=F([r,g(n,4)]),s={...t,functionName:"callFrom",args:[e.delegatorAddress,o,y]};return d(a,b,"writeContract")(s)}})}var T=new Map;async function v(e,a){let t=F([e.worldAddress,a]),n=T.get(t);if(n)return n;let i=e.worldFunctionToSystemFunction?await e.worldFunctionToSystemFunction(a):await D(e.publicClient,e.worldAddress,a);return T.set(t,i),i}async function D(e,a,t){let n=m.tables.world__FunctionSelectors,i=f(h(n)),o=f(P(n)),[r,y,s]=await e.readContract({address:a,abi:p,functionName:"getRecord",args:[n.tableId,N(i,{worldFunctionSelector:t})]}),l=w(o,{staticData:r,encodedLengths:y,dynamicData:s});return{systemId:l.systemId,systemFunctionSelector:l.systemFunctionSelector}}var ce={Call:[{name:"signer",type:"address"},{name:"systemNamespace",type:"string"},{name:"systemName",type:"string"},{name:"callData",type:"bytes"},{name:"nonce",type:"uint256"}]};function R(e){return{type:"tableId",input:e}}function W(e){return typeof e=="object"&&e!==null&&"type"in e&&"input"in e}function E(e){return typeof e=="object"&&e!==null&&"type"in e&&"value"in e}function k(e,a){if(E(e))return e;if(W(e)&&e.type==="tableId"){let t=Object.entries(a.config.tables).filter(([n,i])=>n===e.input||i.name===e.input);if(t.length>1)throw new Error(`Found more than one table with name "${e.input}". Try using one of the following table names instead: ${t.map(([n])=>n).join(", ")}`);if(t.length===1){let[n]=t,[,i]=n;return{type:"bytes32",value:i.tableId}}}throw new Error(`Could not resolve dynamic resolution:
|
2
2
|
${JSON.stringify(e,null,2)}`)}export{le as callFrom,ce as callWithSignatureTypes,c as encodeSystemCall,u as encodeSystemCallFrom,z as encodeSystemCalls,Y as encodeSystemCallsFrom,R as resolveTableId,k as resolveWithContext};
|
3
3
|
//# sourceMappingURL=internal.js.map
|