@latticexyz/world 3.0.0-main-e85dc5349 → 3.0.0-main-560fd6a0c

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.
@@ -1,2 +1,2 @@
1
- import{c as e}from"./chunk-KOZM4MYS.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-G7TYEQQ6.js.map
1
+ import{c as e}from"./chunk-QWCOI4NR.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-236CU3CY.js.map
@@ -0,0 +1,2 @@
1
+ var l=Object.create;var p=Object.defineProperty;var a=Object.getOwnPropertyDescriptor;var D=Object.getOwnPropertyNames;var E=Object.getPrototypeOf,c=Object.prototype.hasOwnProperty;var d=(e,t,o)=>t in e?p(e,t,{enumerable:!0,configurable:!0,writable:!0,value:o}):e[t]=o;var L=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports);var S=(e,t,o,s)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of D(t))!c.call(e,r)&&r!==o&&p(e,r,{get:()=>t[r],enumerable:!(s=a(t,r))||s.enumerable});return e};var u=(e,t,o)=>(o=e!=null?l(E(e)):{},S(t||!e||!e.__esModule?p(o,"default",{value:e,enumerable:!0}):o,e));var F=(e,t,o)=>(d(e,typeof t!="symbol"?t+"":t,o),o),n=(e,t,o)=>{if(!t.has(e))throw TypeError("Cannot "+o)};var f=(e,t,o)=>(n(e,t,"read from private field"),o?o.call(e):t.get(e)),T=(e,t,o)=>{if(t.has(e))throw TypeError("Cannot add the same private member more than once");t instanceof WeakSet?t.add(e):t.set(e,o)},U=(e,t,o,s)=>(n(e,t,"write to private field"),s?s.call(e,o):t.set(e,o),o);var I=(e,t,o)=>(n(e,t,"access private method"),o);var _={registerFunctionSelectors:!0,openAccess:!0,accessList:[]},m={root:!1,args:[],artifactPath:void 0},i={worldInterfaceName:"IWorld",worldgenDirectory:"world",worldImportPath:"@latticexyz/world/src/"},y={customWorldContract:void 0,postDeployScript:"PostDeploy",deploysDirectory:"./deploys",worldsFile:"./worlds.json",upgradeableWorldImplementation:!1},x={systems:{},tables:{},excludeSystems:[],modules:[],codegen:i,deploy:y};export{L as a,u as b,F as c,f as d,T as e,U as f,I as g,_ as h,m as i,i as j,y as k,x as l};
2
+ //# sourceMappingURL=chunk-JEHHYC6A.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../ts/config/v2/defaults.ts"],"sourcesContent":["import { CodegenInput, DeployInput, ModuleInput, SystemInput, WorldInput } from \"./input\";\n\nexport const SYSTEM_DEFAULTS = {\n registerFunctionSelectors: true,\n openAccess: true,\n accessList: [],\n} as const satisfies SystemInput;\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"],"mappings":"AAEO,IAAMA,EAAkB,CAC7B,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","names":["SYSTEM_DEFAULTS","MODULE_DEFAULTS","CODEGEN_DEFAULTS","DEPLOY_DEFAULTS","CONFIG_DEFAULTS"]}
1
+ {"version":3,"sources":["../ts/config/v2/defaults.ts"],"sourcesContent":["import { CodegenInput, DeployInput, ModuleInput, SystemInput, WorldInput } from \"./input\";\n\nexport const SYSTEM_DEFAULTS = {\n registerFunctionSelectors: true,\n openAccess: true,\n accessList: [],\n} as const satisfies SystemInput;\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"],"mappings":"shCAEO,IAAMA,EAAkB,CAC7B,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","names":["SYSTEM_DEFAULTS","MODULE_DEFAULTS","CODEGEN_DEFAULTS","DEPLOY_DEFAULTS","CONFIG_DEFAULTS"]}
@@ -0,0 +1,2 @@
1
+ import{h as c,i,j as p,k as d,l as t}from"./chunk-JEHHYC6A.js";import{extendedScope as S,get as A,resolveTable as W,validateTable as L,mergeIfUndefined as r,resolveStore as F,hasOwnKey as C,validateStore as j}from"@latticexyz/store/config/v2";import{mapObject as g}from"@latticexyz/common/utils";import{mergeIfUndefined as T}from"@latticexyz/store/config/v2";function y(e){return g(e,s=>T(s,c))}import{validateTables as E,isObject as I,hasOwnKey as w}from"@latticexyz/store/config/v2";function D(e,s){w(e,"tables")&&E(e.tables,s)}function f(e,s){if(!I(e))throw new Error(`Expected namespaces, received ${JSON.stringify(e)}`);for(let n of Object.values(e))D(n,s)}import{isObject as U,mergeIfUndefined as N}from"@latticexyz/store/config/v2";function v(e){return U(e)?N(e,p):p}import{mergeIfUndefined as O,isObject as _}from"@latticexyz/store/config/v2";function b(e){return _(e)?O(e,d):d}function $(e){let s=S(e);j(e),C(e,"namespaces")&&f(e.namespaces,s)}function M(e){let s=S(e),n=e.namespaces??{},x=Object.fromEntries(Object.entries(n).map(([o,u])=>Object.entries(u.tables??{}).map(([l,m])=>(L(m,s),[`${o}__${l}`,W(r(m,{namespace:o,name:l}),s)]))).flat()),a=F(e),k=(e.modules??t.modules).map(o=>r(o,i));return r({...a,tables:{...a.tables,...x},codegen:r(a.codegen,v(e.codegen)),deploy:b(e.deploy),systems:y(e.systems??t.systems),excludeSystems:A(e,"excludeSystems"),modules:k},t)}function ye(e){return $(e),M(e)}export{$ as a,M as b,ye as c};
2
+ //# sourceMappingURL=chunk-QWCOI4NR.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 } 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 \"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, \"namespaces\")) {\n validateNamespaces(world.namespaces, scope);\n }\n}\n\nexport type resolveWorld<world> = withJsDoc<\n resolveStore<world> &\n mergeIfUndefined<\n { tables: resolveNamespacedTables<world> } & Omit<\n {\n [key in keyof world]: key extends \"systems\"\n ? resolveSystems<world[key] & SystemsInput>\n : key extends \"deploy\"\n ? resolveDeploy<world[key]>\n : key extends \"codegen\"\n ? resolveCodegen<world[key]>\n : world[key];\n },\n \"namespaces\" | keyof Store\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 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 resolvedStore = resolveStore(world);\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),\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 { mapObject } from \"@latticexyz/common/utils\";\nimport { SYSTEM_DEFAULTS } from \"./defaults\";\nimport { SystemsInput } from \"./input\";\nimport { mergeIfUndefined } from \"@latticexyz/store/config/v2\";\n\nexport type resolveSystems<systems extends SystemsInput> = {\n [label in keyof systems]: mergeIfUndefined<systems[label], typeof SYSTEM_DEFAULTS>;\n};\n\nexport function resolveSystems<systems extends SystemsInput>(systems: systems): resolveSystems<systems> {\n return mapObject(systems, (system) => mergeIfUndefined(system, SYSTEM_DEFAULTS));\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":"+DACA,OAEE,iBAAAA,EACA,OAAAC,EACA,gBAAAC,EACA,iBAAAC,EACA,oBAAAC,EAEA,gBAAAC,EAEA,aAAAC,EACA,iBAAAC,MACK,8BCbP,OAAS,aAAAC,MAAiB,2BAG1B,OAAS,oBAAAC,MAAwB,8BAM1B,SAASC,EAA6CC,EAA2C,CACtG,OAAOC,EAAUD,EAAUE,GAAWJ,EAAiBI,EAAQC,CAAe,CAAC,CACjF,CCXA,OAGE,kBAAAC,EACA,YAAAC,EACA,aAAAC,MAKK,8BAoBA,SAASC,EACdC,EACAC,EACqC,CACjCH,EAAUE,EAAW,QAAQ,GAC/BJ,EAAeI,EAAU,OAAQC,CAAK,CAE1C,CAMO,SAASC,EACdC,EACAF,EACuC,CACvC,GAAI,CAACJ,EAASM,CAAU,EACtB,MAAM,IAAI,MAAM,iCAAiC,KAAK,UAAUA,CAAU,GAAG,EAE/E,QAAWH,KAAa,OAAO,OAAOG,CAAU,EAC9CJ,EAAkBC,EAAWC,CAAK,CAEtC,CCrDA,OAAS,YAAAG,EAAU,oBAAAC,MAAwB,8BAOpC,SAASC,EAAwBC,EAA2C,CACjF,OAAQC,EAASD,CAAO,EAAIE,EAAiBF,EAASG,CAAgB,EAAIA,CAC5E,CCTA,OAAS,oBAAAC,EAAkB,YAAAC,MAAgB,8BAKpC,SAASC,EAAsBC,EAAuC,CAC3E,OAAQC,EAASD,CAAM,EAAIE,EAAiBF,EAAQG,CAAe,EAAIA,CACzE,CJ+BO,SAASC,EAAcC,EAA6C,CACzE,IAAMC,EAAQC,EAAcF,CAAK,EACjCG,EAAcH,CAAK,EAEfI,EAAUJ,EAAO,YAAY,GAC/BK,EAAmBL,EAAM,WAAYC,CAAK,CAE9C,CAsBO,SAASK,EAA6CN,EAAmC,CAC9F,IAAMC,EAAQC,EAAcF,CAAK,EAC3BO,EAAaP,EAAM,YAAc,CAAC,EAElCQ,EAA2B,OAAO,YACtC,OAAO,QAAQD,CAAU,EACtB,IAAI,CAAC,CAACE,EAAcC,CAAS,IAC5B,OAAO,QAAQA,EAAU,QAAU,CAAC,CAAC,EAAE,IAAI,CAAC,CAACC,EAAUC,CAAK,KAC1DC,EAAcD,EAAOX,CAAK,EACnB,CACL,GAAGQ,MAAiBE,IACpBG,EAAaC,EAAiBH,EAAO,CAAE,UAAWH,EAAc,KAAME,CAAS,CAAC,EAAGV,CAAK,CAC1F,EACD,CACH,EACC,KAAK,CACV,EAEMe,EAAgBC,EAAajB,CAAK,EAElCkB,GAAWlB,EAAM,SAAWmB,EAAgB,SAAS,IAAKC,GAAQL,EAAiBK,EAAKC,CAAe,CAAC,EAE9G,OAAON,EACL,CACE,GAAGC,EACH,OAAQ,CAAE,GAAGA,EAAc,OAAQ,GAAGR,CAAyB,EAC/D,QAASO,EAAiBC,EAAc,QAASM,EAAetB,EAAM,OAAO,CAAC,EAC9E,OAAQuB,EAAcvB,EAAM,MAAM,EAClC,QAASwB,EAAexB,EAAM,SAAWmB,EAAgB,OAAO,EAChE,eAAgBM,EAAIzB,EAAO,gBAAgB,EAC3C,QAAAkB,CACF,EACAC,CACF,CACF,CAEO,SAASO,GAAyBC,EAAkD,CACzF,OAAA5B,EAAc4B,CAAK,EACZrB,EAAaqB,CAAK,CAC3B","names":["extendedScope","get","resolveTable","validateTable","mergeIfUndefined","resolveStore","hasOwnKey","validateStore","mapObject","mergeIfUndefined","resolveSystems","systems","mapObject","system","SYSTEM_DEFAULTS","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","validateNamespaces","resolveWorld","namespaces","resolvedNamespacedTables","namespaceKey","namespace","tableKey","table","validateTable","resolveTable","mergeIfUndefined","resolvedStore","resolveStore","modules","CONFIG_DEFAULTS","mod","MODULE_DEFAULTS","resolveCodegen","resolveDeploy","resolveSystems","get","defineWorld","input"]}
@@ -1,6 +1,5 @@
1
- export { d as defineWorld, r as resolveWorld, v as validateWorld } from '../world-75040f95.js';
2
- export { C as Codegen, c as Deploy, M as Module, S as System, b as Systems, W as World } from '../dynamicResolution-e56fd658.js';
1
+ export { d as defineWorld, r as resolveWorld, v as validateWorld } from '../world-95f49fc0.js';
2
+ export { C as Codegen, D as Deploy, M as Module, S as System, b as Systems, W as World } from '../dynamicResolution-b1bf86e3.js';
3
3
  import '@arktype/util';
4
4
  import '@latticexyz/store/config/v2';
5
- import '../defaults-1be1ffd2.js';
6
5
  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-KOZM4MYS.js";import"../chunk-E5NQ4W4F.js";import"../chunk-5UFRBM64.js";import"../chunk-H5QPQRXY.js";export{e as defineWorld,r as resolveWorld,o as validateWorld};
1
+ import{a as o,b as r,c as e}from"../chunk-QWCOI4NR.js";import"../chunk-JEHHYC6A.js";export{e as defineWorld,r as resolveWorld,o as validateWorld};
2
2
  //# sourceMappingURL=v2.js.map
@@ -101,4 +101,4 @@ declare function resolveWithContext(input: unknown, context: {
101
101
  systemAddresses?: Record<string, Promise<string>>;
102
102
  }): ValueWithType;
103
103
 
104
- export { Codegen as C, DynamicResolution as D, Module as M, System as S, ValueWithType as V, World as W, resolveWithContext as a, Systems as b, Deploy as c, resolveTableId as r };
104
+ export { Codegen as C, Deploy as D, Module as M, System as S, ValueWithType as V, World as W, resolveWithContext as a, Systems as b, DynamicResolution as c, resolveTableId as r };
package/dist/index.d.ts CHANGED
@@ -1,8 +1,7 @@
1
1
  import { validateTablesWithShorthands, extendedScope, Scope, AbiTypeScope, resolveTablesWithShorthands } from '@latticexyz/store/config/v2';
2
- import { v as validateWorld, a as validateNamespace, r as resolveWorld, W as WorldWithShorthandsInput } from './world-75040f95.js';
3
- export { W as World } from './dynamicResolution-e56fd658.js';
2
+ import { v as validateWorld, a as validateNamespace, r as resolveWorld, W as WorldWithShorthandsInput } from './world-95f49fc0.js';
3
+ export { W as World } from './dynamicResolution-b1bf86e3.js';
4
4
  import '@arktype/util';
5
- import './defaults-1be1ffd2.js';
6
5
  import '@latticexyz/store';
7
6
 
8
7
  declare const worldDeployedEvent = "event WorldDeployed(address indexed newContract, uint256 salt)";
package/dist/index.js CHANGED
@@ -1,2 +1,2 @@
1
- import{a as d,b as l}from"./chunk-KOZM4MYS.js";import"./chunk-E5NQ4W4F.js";import"./chunk-5UFRBM64.js";import"./chunk-H5QPQRXY.js";var W="event WorldDeployed(address indexed newContract, uint256 salt)",v="event HelloWorld(bytes32 indexed worldVersion)";import{mapObject as r}from"@latticexyz/common/utils";import{extendedScope as m,getPath as S,hasOwnKey as p,isObject as f,isTableShorthandInput as h,resolveTableShorthand as i,validateTablesWithShorthands as c}from"@latticexyz/store/config/v2";function k(e){let t=m(e);if(p(e,"tables")&&c(e.tables,t),p(e,"namespaces")&&f(e.namespaces))for(let a of Object.keys(e.namespaces))c(S(e.namespaces,[a,"tables"])??{},t)}function x(e){let t=m(e),a=r(e.tables??{},o=>h(o)?i(o,t):o),y=r(e.namespaces??{},o=>({...o,tables:r(o.tables??{},s=>h(s)?i(s,t):s)})),n={...e,tables:a,namespaces:y};return d(n),l(n)}function b(e){return k(e),x(e)}export{b as defineWorld,v as helloWorldEvent,W as worldDeployedEvent};
1
+ import{a as d,b as l}from"./chunk-QWCOI4NR.js";import"./chunk-JEHHYC6A.js";var W="event WorldDeployed(address indexed newContract, uint256 salt)",v="event HelloWorld(bytes32 indexed worldVersion)";import{mapObject as r}from"@latticexyz/common/utils";import{extendedScope as m,getPath as S,hasOwnKey as p,isObject as f,isTableShorthandInput as h,resolveTableShorthand as i,validateTablesWithShorthands as c}from"@latticexyz/store/config/v2";function k(e){let t=m(e);if(p(e,"tables")&&c(e.tables,t),p(e,"namespaces")&&f(e.namespaces))for(let a of Object.keys(e.namespaces))c(S(e.namespaces,[a,"tables"])??{},t)}function x(e){let t=m(e),a=r(e.tables??{},o=>h(o)?i(o,t):o),y=r(e.namespaces??{},o=>({...o,tables:r(o.tables??{},s=>h(s)?i(s,t):s)})),n={...e,tables:a,namespaces:y};return d(n),l(n)}function b(e){return k(e),x(e)}export{b as defineWorld,v as helloWorldEvent,W 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 AbiTypeScope,\n Scope,\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 { validateNamespace } from \"./namespaces\";\nimport { resolveWorld, validateWorld } from \"./world\";\n\nexport type resolveWorldWithShorthands<world> = resolveWorld<{\n [key in keyof world]: key extends \"tables\"\n ? resolveTablesWithShorthands<world[key], extendedScope<world>>\n : key extends \"namespaces\"\n ? {\n [namespaceKey in keyof world[key]]: {\n [namespaceProp in keyof world[key][namespaceKey]]: namespaceProp extends \"tables\"\n ? resolveTablesWithShorthands<world[key][namespaceKey][namespaceProp], extendedScope<world>>\n : world[key][namespaceKey][namespaceProp];\n };\n }\n : world[key];\n}>;\n\nexport type validateWorldWithShorthands<world> = {\n [key in keyof world]: key extends \"tables\"\n ? validateTablesWithShorthands<world[key], extendedScope<world>>\n : key extends \"namespaces\"\n ? validateNamespacesWithShorthands<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 validateNamespacesWithShorthands<namespaces, scope extends Scope = AbiTypeScope> = {\n [namespace in keyof namespaces]: {\n [key in keyof namespaces[namespace]]: key extends \"tables\"\n ? validateTablesWithShorthands<namespaces[namespace][key], scope>\n : validateNamespace<namespaces[namespace], scope>[key];\n };\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 const namespaces = mapObject(world.namespaces ?? {}, (namespace) => ({\n ...namespace,\n tables: mapObject(namespace.tables ?? {}, (table) => {\n return isTableShorthandInput(table) ? resolveTableShorthand(table, scope) : table;\n }),\n }));\n\n const fullConfig = { ...world, tables, namespaces };\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":"mIACO,IAAMA,EAAqB,iEAGrBC,EAAkB,iDCJ/B,OAAS,aAAAC,MAAiB,2BAC1B,OAGE,iBAAAC,EACA,WAAAC,EACA,aAAAC,EACA,YAAAC,EACA,yBAAAC,EACA,yBAAAC,EAEA,gCAAAC,MACK,8BA2BP,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,CAUO,SAASO,EACdR,EACmC,CACnC,IAAMC,EAAQC,EAAcF,CAAK,EAC3BS,EAASC,EAAUV,EAAM,QAAU,CAAC,EAAIW,GACrCC,EAAsBD,CAAK,EAAIE,EAAsBF,EAAOV,CAAK,EAAIU,CAC7E,EACKG,EAAaJ,EAAUV,EAAM,YAAc,CAAC,EAAIe,IAAe,CACnE,GAAGA,EACH,OAAQL,EAAUK,EAAU,QAAU,CAAC,EAAIJ,GAClCC,EAAsBD,CAAK,EAAIE,EAAsBF,EAAOV,CAAK,EAAIU,CAC7E,CACH,EAAE,EAEIK,EAAa,CAAE,GAAGhB,EAAO,OAAAS,EAAQ,WAAAK,CAAW,EAClD,OAAAG,EAAcD,CAAU,EAEjBE,EAAaF,CAAU,CAChC,CAEO,SAASG,EACdnB,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","namespaces","namespace","fullConfig","validateWorld","resolveWorld","defineWorldWithShorthands"]}
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 AbiTypeScope,\n Scope,\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 { validateNamespace } from \"./namespaces\";\nimport { resolveWorld, validateWorld } from \"./world\";\n\nexport type resolveWorldWithShorthands<world> = resolveWorld<{\n [key in keyof world]: key extends \"tables\"\n ? resolveTablesWithShorthands<world[key], extendedScope<world>>\n : key extends \"namespaces\"\n ? {\n [namespaceKey in keyof world[key]]: {\n [namespaceProp in keyof world[key][namespaceKey]]: namespaceProp extends \"tables\"\n ? resolveTablesWithShorthands<world[key][namespaceKey][namespaceProp], extendedScope<world>>\n : world[key][namespaceKey][namespaceProp];\n };\n }\n : world[key];\n}>;\n\nexport type validateWorldWithShorthands<world> = {\n [key in keyof world]: key extends \"tables\"\n ? validateTablesWithShorthands<world[key], extendedScope<world>>\n : key extends \"namespaces\"\n ? validateNamespacesWithShorthands<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 validateNamespacesWithShorthands<namespaces, scope extends Scope = AbiTypeScope> = {\n [namespace in keyof namespaces]: {\n [key in keyof namespaces[namespace]]: key extends \"tables\"\n ? validateTablesWithShorthands<namespaces[namespace][key], scope>\n : validateNamespace<namespaces[namespace], scope>[key];\n };\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 const namespaces = mapObject(world.namespaces ?? {}, (namespace) => ({\n ...namespace,\n tables: mapObject(namespace.tables ?? {}, (table) => {\n return isTableShorthandInput(table) ? resolveTableShorthand(table, scope) : table;\n }),\n }));\n\n const fullConfig = { ...world, tables, namespaces };\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,OAGE,iBAAAC,EACA,WAAAC,EACA,aAAAC,EACA,YAAAC,EACA,yBAAAC,EACA,yBAAAC,EAEA,gCAAAC,MACK,8BA2BP,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,CAUO,SAASO,EACdR,EACmC,CACnC,IAAMC,EAAQC,EAAcF,CAAK,EAC3BS,EAASC,EAAUV,EAAM,QAAU,CAAC,EAAIW,GACrCC,EAAsBD,CAAK,EAAIE,EAAsBF,EAAOV,CAAK,EAAIU,CAC7E,EACKG,EAAaJ,EAAUV,EAAM,YAAc,CAAC,EAAIe,IAAe,CACnE,GAAGA,EACH,OAAQL,EAAUK,EAAU,QAAU,CAAC,EAAIJ,GAClCC,EAAsBD,CAAK,EAAIE,EAAsBF,EAAOV,CAAK,EAAIU,CAC7E,CACH,EAAE,EAEIK,EAAa,CAAE,GAAGhB,EAAO,OAAAS,EAAQ,WAAAK,CAAW,EAClD,OAAAG,EAAcD,CAAU,EAEjBE,EAAaF,CAAU,CAChC,CAEO,SAASG,EACdnB,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","namespaces","namespace","fullConfig","validateWorld","resolveWorld","defineWorldWithShorthands"]}
@@ -1,10 +1,6 @@
1
- export { S as SYSTEM_DEFAULTS, W as WORLD_DEFAULTS } from './defaults-1be1ffd2.js';
2
- export { E as ExpandSystemConfig, b as ExpandSystemsConfig, M as ModuleConfig, d as SystemConfig, S as SystemUserConfig, a as SystemsUserConfig, c as WorldConfig, W as WorldUserConfig, e as zPluginWorldConfig, z as zWorldConfig } from './types-971c9ea5.js';
3
1
  import { Abi, ContractFunctionName, EncodeFunctionDataParameters, Hex, Address, Chain, Account, Client, Transport, WalletActions, PublicClient } from 'viem';
4
2
  import { AbiParametersToPrimitiveTypes, ExtractAbiFunction } from 'abitype';
5
- export { r as resolveTableId, a as resolveWithContext } from './dynamicResolution-e56fd658.js';
6
- import 'zod';
7
- import '@latticexyz/common/type-utils';
3
+ export { r as resolveTableId, a as resolveWithContext } from './dynamicResolution-b1bf86e3.js';
8
4
  import '@latticexyz/store';
9
5
 
10
6
  declare const abi: [
package/dist/internal.js CHANGED
@@ -1,3 +1,3 @@
1
- import{a as m}from"./chunk-G7TYEQQ6.js";import{a as V,b as j}from"./chunk-NXAGBVBE.js";import"./chunk-KOZM4MYS.js";import{a as M,b as H}from"./chunk-E5NQ4W4F.js";import"./chunk-5UFRBM64.js";import"./chunk-H5QPQRXY.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 Y(e,a){return a.map(t=>c({...t,abi:e}))}function ne(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 pe(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 be={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
- ${JSON.stringify(e,null,2)}`)}export{M as SYSTEM_DEFAULTS,H as WORLD_DEFAULTS,pe as callFrom,be as callWithSignatureTypes,c as encodeSystemCall,u as encodeSystemCallFrom,Y as encodeSystemCalls,ne as encodeSystemCallsFrom,R as resolveTableId,k as resolveWithContext,j as zPluginWorldConfig,V as zWorldConfig};
1
+ import{a as m}from"./chunk-236CU3CY.js";import"./chunk-QWCOI4NR.js";import"./chunk-JEHHYC6A.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
+ ${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
@@ -1 +1 @@
1
- {"version":3,"sources":["../ts/encodeSystemCall.ts","../ts/encodeSystemCallFrom.ts","../ts/encodeSystemCalls.ts","../ts/encodeSystemCallsFrom.ts","../ts/actions/callFrom.ts","../out/IStoreRead.sol/IStoreRead.abi.json","../ts/callWithSignatureTypes.ts","../ts/config/v2/dynamicResolution.ts"],"sourcesContent":["import { Abi, EncodeFunctionDataParameters, Hex, encodeFunctionData, type ContractFunctionName } from \"viem\";\nimport type { AbiParametersToPrimitiveTypes, ExtractAbiFunction } from \"abitype\";\nimport IWorldCallAbi from \"../out/IWorldKernel.sol/IWorldCall.abi.json\";\n\nexport type SystemCall<abi extends Abi, functionName extends ContractFunctionName<abi>> = EncodeFunctionDataParameters<\n abi,\n functionName\n> & {\n readonly systemId: Hex;\n};\n\n/** Encode a system call to be passed as arguments into `World.call` */\nexport function encodeSystemCall<abi extends Abi, functionName extends ContractFunctionName<abi>>({\n abi,\n systemId,\n functionName,\n args,\n}: SystemCall<abi, functionName>): AbiParametersToPrimitiveTypes<\n ExtractAbiFunction<typeof IWorldCallAbi, \"call\">[\"inputs\"]\n> {\n return [\n systemId,\n encodeFunctionData<abi, functionName>({\n abi,\n functionName,\n args,\n } as unknown as EncodeFunctionDataParameters<abi, functionName>),\n ];\n}\n","import { Abi, EncodeFunctionDataParameters, encodeFunctionData, Address, type ContractFunctionName } from \"viem\";\nimport type { AbiParametersToPrimitiveTypes, ExtractAbiFunction } from \"abitype\";\nimport IWorldCallAbi from \"../out/IWorldKernel.sol/IWorldCall.abi.json\";\nimport { SystemCall } from \"./encodeSystemCall\";\n\nexport type SystemCallFrom<abi extends Abi, functionName extends ContractFunctionName<abi>> = SystemCall<\n abi,\n functionName\n> & {\n readonly from: Address;\n};\n\n/** Encode a system call to be passed as arguments into `World.callFrom` */\nexport function encodeSystemCallFrom<abi extends Abi, functionName extends ContractFunctionName<abi>>({\n abi,\n from,\n systemId,\n functionName,\n args,\n}: SystemCallFrom<abi, functionName>): AbiParametersToPrimitiveTypes<\n ExtractAbiFunction<typeof IWorldCallAbi, \"callFrom\">[\"inputs\"]\n> {\n return [\n from,\n systemId,\n encodeFunctionData<abi, functionName>({\n abi,\n functionName,\n args,\n } as unknown as EncodeFunctionDataParameters<abi, functionName>),\n ];\n}\n","import { Abi, type ContractFunctionName } from \"viem\";\nimport IWorldCallAbi from \"../out/IWorldKernel.sol/IWorldCall.abi.json\";\nimport { SystemCall, encodeSystemCall } from \"./encodeSystemCall\";\nimport type { AbiParametersToPrimitiveTypes, ExtractAbiFunction } from \"abitype\";\n\n/** Encode system calls to be passed as arguments into `World.batchCall` */\nexport function encodeSystemCalls<abi extends Abi, functionName extends ContractFunctionName<abi>>(\n abi: abi,\n systemCalls: readonly Omit<SystemCall<abi, functionName>, \"abi\">[],\n): AbiParametersToPrimitiveTypes<ExtractAbiFunction<typeof IWorldCallAbi, \"call\">[\"inputs\"]>[] {\n return systemCalls.map((systemCall) => encodeSystemCall({ ...systemCall, abi } as SystemCall<abi, functionName>));\n}\n","import { Abi, Address, type ContractFunctionName } from \"viem\";\nimport IWorldCallAbi from \"../out/IWorldKernel.sol/IWorldCall.abi.json\";\nimport { SystemCallFrom, encodeSystemCallFrom } from \"./encodeSystemCallFrom\";\nimport type { AbiParametersToPrimitiveTypes, ExtractAbiFunction } from \"abitype\";\n\n/** Encode system calls to be passed as arguments into `World.batchCallFrom` */\nexport function encodeSystemCallsFrom<abi extends Abi, functionName extends ContractFunctionName<abi>>(\n abi: abi,\n from: Address,\n systemCalls: readonly Omit<SystemCallFrom<abi, functionName>, \"abi\" | \"from\">[],\n): AbiParametersToPrimitiveTypes<ExtractAbiFunction<typeof IWorldCallAbi, \"callFrom\">[\"inputs\"]>[] {\n return systemCalls.map((systemCall) =>\n encodeSystemCallFrom({ ...systemCall, abi, from } as SystemCallFrom<abi, functionName>),\n );\n}\n","import {\n slice,\n concat,\n type Transport,\n type Chain,\n type Account,\n type Hex,\n type WalletActions,\n type WriteContractReturnType,\n type EncodeFunctionDataParameters,\n type PublicClient,\n Client,\n} from \"viem\";\nimport { getAction, encodeFunctionData } from \"viem/utils\";\nimport { writeContract } from \"viem/actions\";\nimport { readHex } from \"@latticexyz/common\";\nimport {\n getKeySchema,\n getValueSchema,\n getSchemaTypes,\n decodeValueArgs,\n encodeKey,\n} from \"@latticexyz/protocol-parser/internal\";\nimport worldConfig from \"../../mud.config\";\nimport IStoreReadAbi from \"../../out/IStoreRead.sol/IStoreRead.abi.json\";\n\n// Accepts either `worldFunctionToSystemFunction` or `publicClient`, but not both.\ntype CallFromParameters = CallFromFunctionParameters | CallFromClientParameters;\ntype CallFromBaseParameters = {\n worldAddress: Hex;\n delegatorAddress: Hex;\n};\ntype CallFromFunctionParameters = CallFromBaseParameters & {\n worldFunctionToSystemFunction: (worldFunctionSelector: Hex) => Promise<SystemFunction>;\n publicClient?: never;\n};\ntype CallFromClientParameters = CallFromBaseParameters & {\n worldFunctionToSystemFunction?: never;\n publicClient: PublicClient;\n};\n\ntype SystemFunction = { systemId: Hex; systemFunctionSelector: Hex };\n\n// By extending viem clients with this function after delegation, the delegation is automatically applied to World contract writes.\n// This means that these writes are made on behalf of the delegator.\n// Internally, it transforms the write arguments to use `callFrom`.\n//\n// Accepts either `worldFunctionToSystemFunction` or `publicClient` as an argument.\n// `worldFunctionToSystemFunction` allows manually providing the mapping function, thus users can utilize their client store for the lookup.\n// If `publicClient` is provided instead, this function retrieves the corresponding system function from the World contract.\n//\n// The function mapping is cached to avoid redundant retrievals for the same World function.\nexport function callFrom<TChain extends Chain, TAccount extends Account>(\n params: CallFromParameters,\n): (client: Client<Transport, TChain, TAccount>) => Pick<WalletActions<TChain, TAccount>, \"writeContract\"> {\n return (client) => ({\n // Applies to: `client.writeContract`, `getContract(client, ...).write`\n writeContract: async (writeArgs): Promise<WriteContractReturnType> => {\n // Skip if the contract isn't the World or the function called should not be redirected through `callFrom`.\n if (\n writeArgs.address !== params.worldAddress ||\n writeArgs.functionName === \"call\" ||\n writeArgs.functionName === \"callFrom\" ||\n writeArgs.functionName === \"callWithSignature\"\n ) {\n return getAction(client, writeContract, \"writeContract\")(writeArgs);\n }\n\n // Encode the World's calldata (which includes the World's function selector).\n const worldCalldata = encodeFunctionData({\n abi: writeArgs.abi,\n functionName: writeArgs.functionName,\n args: writeArgs.args,\n } as unknown as EncodeFunctionDataParameters);\n\n // The first 4 bytes of calldata represent the function selector.\n const worldFunctionSelector = slice(worldCalldata, 0, 4);\n\n // Get the systemId and System's function selector.\n const { systemId, systemFunctionSelector } = await worldFunctionToSystemFunction(params, worldFunctionSelector);\n\n // Construct the System's calldata by replacing the World's function selector with the System's.\n // Use `readHex` instead of `slice` to prevent out-of-bounds errors with calldata that has no args.\n const systemCalldata = concat([systemFunctionSelector, readHex(worldCalldata, 4)]);\n\n // Construct args for `callFrom`.\n const callFromArgs: typeof writeArgs = {\n ...writeArgs,\n functionName: \"callFrom\",\n args: [params.delegatorAddress, systemId, systemCalldata],\n };\n\n // Call `writeContract` with the new args.\n return getAction(client, writeContract, \"writeContract\")(callFromArgs);\n },\n });\n}\n\nconst systemFunctionCache = new Map<Hex, SystemFunction>();\n\nasync function worldFunctionToSystemFunction(\n params: CallFromParameters,\n worldFunctionSelector: Hex,\n): Promise<SystemFunction> {\n const cacheKey = concat([params.worldAddress, worldFunctionSelector]);\n\n // Use cache if the function has been called previously.\n const cached = systemFunctionCache.get(cacheKey);\n if (cached) return cached;\n\n // If a mapping function is provided, use it. Otherwise, call the World contract.\n const systemFunction = params.worldFunctionToSystemFunction\n ? await params.worldFunctionToSystemFunction(worldFunctionSelector)\n : await retrieveSystemFunctionFromContract(params.publicClient, params.worldAddress, worldFunctionSelector);\n\n systemFunctionCache.set(cacheKey, systemFunction);\n\n return systemFunction;\n}\n\nasync function retrieveSystemFunctionFromContract(\n publicClient: PublicClient,\n worldAddress: Hex,\n worldFunctionSelector: Hex,\n): Promise<SystemFunction> {\n const table = worldConfig.tables.world__FunctionSelectors;\n\n const keySchema = getSchemaTypes(getKeySchema(table));\n const valueSchema = getSchemaTypes(getValueSchema(table));\n\n const [staticData, encodedLengths, dynamicData] = await publicClient.readContract({\n address: worldAddress,\n abi: IStoreReadAbi,\n functionName: \"getRecord\",\n args: [table.tableId, encodeKey(keySchema, { worldFunctionSelector })],\n });\n\n const decoded = decodeValueArgs(valueSchema, { staticData, encodedLengths, dynamicData });\n\n const systemFunction: SystemFunction = {\n systemId: decoded.systemId,\n systemFunctionSelector: decoded.systemFunctionSelector,\n };\n\n return systemFunction;\n}\n","[\n {\n \"type\": \"function\",\n \"name\": \"getDynamicField\",\n \"inputs\": [\n {\n \"name\": \"tableId\",\n \"type\": \"bytes32\",\n \"internalType\": \"ResourceId\"\n },\n {\n \"name\": \"keyTuple\",\n \"type\": \"bytes32[]\",\n \"internalType\": \"bytes32[]\"\n },\n {\n \"name\": \"dynamicFieldIndex\",\n \"type\": \"uint8\",\n \"internalType\": \"uint8\"\n }\n ],\n \"outputs\": [\n {\n \"name\": \"\",\n \"type\": \"bytes\",\n \"internalType\": \"bytes\"\n }\n ],\n \"stateMutability\": \"view\"\n },\n {\n \"type\": \"function\",\n \"name\": \"getDynamicFieldLength\",\n \"inputs\": [\n {\n \"name\": \"tableId\",\n \"type\": \"bytes32\",\n \"internalType\": \"ResourceId\"\n },\n {\n \"name\": \"keyTuple\",\n \"type\": \"bytes32[]\",\n \"internalType\": \"bytes32[]\"\n },\n {\n \"name\": \"dynamicFieldIndex\",\n \"type\": \"uint8\",\n \"internalType\": \"uint8\"\n }\n ],\n \"outputs\": [\n {\n \"name\": \"\",\n \"type\": \"uint256\",\n \"internalType\": \"uint256\"\n }\n ],\n \"stateMutability\": \"view\"\n },\n {\n \"type\": \"function\",\n \"name\": \"getDynamicFieldSlice\",\n \"inputs\": [\n {\n \"name\": \"tableId\",\n \"type\": \"bytes32\",\n \"internalType\": \"ResourceId\"\n },\n {\n \"name\": \"keyTuple\",\n \"type\": \"bytes32[]\",\n \"internalType\": \"bytes32[]\"\n },\n {\n \"name\": \"dynamicFieldIndex\",\n \"type\": \"uint8\",\n \"internalType\": \"uint8\"\n },\n {\n \"name\": \"start\",\n \"type\": \"uint256\",\n \"internalType\": \"uint256\"\n },\n {\n \"name\": \"end\",\n \"type\": \"uint256\",\n \"internalType\": \"uint256\"\n }\n ],\n \"outputs\": [\n {\n \"name\": \"data\",\n \"type\": \"bytes\",\n \"internalType\": \"bytes\"\n }\n ],\n \"stateMutability\": \"view\"\n },\n {\n \"type\": \"function\",\n \"name\": \"getField\",\n \"inputs\": [\n {\n \"name\": \"tableId\",\n \"type\": \"bytes32\",\n \"internalType\": \"ResourceId\"\n },\n {\n \"name\": \"keyTuple\",\n \"type\": \"bytes32[]\",\n \"internalType\": \"bytes32[]\"\n },\n {\n \"name\": \"fieldIndex\",\n \"type\": \"uint8\",\n \"internalType\": \"uint8\"\n },\n {\n \"name\": \"fieldLayout\",\n \"type\": \"bytes32\",\n \"internalType\": \"FieldLayout\"\n }\n ],\n \"outputs\": [\n {\n \"name\": \"data\",\n \"type\": \"bytes\",\n \"internalType\": \"bytes\"\n }\n ],\n \"stateMutability\": \"view\"\n },\n {\n \"type\": \"function\",\n \"name\": \"getField\",\n \"inputs\": [\n {\n \"name\": \"tableId\",\n \"type\": \"bytes32\",\n \"internalType\": \"ResourceId\"\n },\n {\n \"name\": \"keyTuple\",\n \"type\": \"bytes32[]\",\n \"internalType\": \"bytes32[]\"\n },\n {\n \"name\": \"fieldIndex\",\n \"type\": \"uint8\",\n \"internalType\": \"uint8\"\n }\n ],\n \"outputs\": [\n {\n \"name\": \"data\",\n \"type\": \"bytes\",\n \"internalType\": \"bytes\"\n }\n ],\n \"stateMutability\": \"view\"\n },\n {\n \"type\": \"function\",\n \"name\": \"getFieldLayout\",\n \"inputs\": [\n {\n \"name\": \"tableId\",\n \"type\": \"bytes32\",\n \"internalType\": \"ResourceId\"\n }\n ],\n \"outputs\": [\n {\n \"name\": \"fieldLayout\",\n \"type\": \"bytes32\",\n \"internalType\": \"FieldLayout\"\n }\n ],\n \"stateMutability\": \"view\"\n },\n {\n \"type\": \"function\",\n \"name\": \"getFieldLength\",\n \"inputs\": [\n {\n \"name\": \"tableId\",\n \"type\": \"bytes32\",\n \"internalType\": \"ResourceId\"\n },\n {\n \"name\": \"keyTuple\",\n \"type\": \"bytes32[]\",\n \"internalType\": \"bytes32[]\"\n },\n {\n \"name\": \"fieldIndex\",\n \"type\": \"uint8\",\n \"internalType\": \"uint8\"\n },\n {\n \"name\": \"fieldLayout\",\n \"type\": \"bytes32\",\n \"internalType\": \"FieldLayout\"\n }\n ],\n \"outputs\": [\n {\n \"name\": \"\",\n \"type\": \"uint256\",\n \"internalType\": \"uint256\"\n }\n ],\n \"stateMutability\": \"view\"\n },\n {\n \"type\": \"function\",\n \"name\": \"getFieldLength\",\n \"inputs\": [\n {\n \"name\": \"tableId\",\n \"type\": \"bytes32\",\n \"internalType\": \"ResourceId\"\n },\n {\n \"name\": \"keyTuple\",\n \"type\": \"bytes32[]\",\n \"internalType\": \"bytes32[]\"\n },\n {\n \"name\": \"fieldIndex\",\n \"type\": \"uint8\",\n \"internalType\": \"uint8\"\n }\n ],\n \"outputs\": [\n {\n \"name\": \"\",\n \"type\": \"uint256\",\n \"internalType\": \"uint256\"\n }\n ],\n \"stateMutability\": \"view\"\n },\n {\n \"type\": \"function\",\n \"name\": \"getKeySchema\",\n \"inputs\": [\n {\n \"name\": \"tableId\",\n \"type\": \"bytes32\",\n \"internalType\": \"ResourceId\"\n }\n ],\n \"outputs\": [\n {\n \"name\": \"keySchema\",\n \"type\": \"bytes32\",\n \"internalType\": \"Schema\"\n }\n ],\n \"stateMutability\": \"view\"\n },\n {\n \"type\": \"function\",\n \"name\": \"getRecord\",\n \"inputs\": [\n {\n \"name\": \"tableId\",\n \"type\": \"bytes32\",\n \"internalType\": \"ResourceId\"\n },\n {\n \"name\": \"keyTuple\",\n \"type\": \"bytes32[]\",\n \"internalType\": \"bytes32[]\"\n },\n {\n \"name\": \"fieldLayout\",\n \"type\": \"bytes32\",\n \"internalType\": \"FieldLayout\"\n }\n ],\n \"outputs\": [\n {\n \"name\": \"staticData\",\n \"type\": \"bytes\",\n \"internalType\": \"bytes\"\n },\n {\n \"name\": \"encodedLengths\",\n \"type\": \"bytes32\",\n \"internalType\": \"EncodedLengths\"\n },\n {\n \"name\": \"dynamicData\",\n \"type\": \"bytes\",\n \"internalType\": \"bytes\"\n }\n ],\n \"stateMutability\": \"view\"\n },\n {\n \"type\": \"function\",\n \"name\": \"getRecord\",\n \"inputs\": [\n {\n \"name\": \"tableId\",\n \"type\": \"bytes32\",\n \"internalType\": \"ResourceId\"\n },\n {\n \"name\": \"keyTuple\",\n \"type\": \"bytes32[]\",\n \"internalType\": \"bytes32[]\"\n }\n ],\n \"outputs\": [\n {\n \"name\": \"staticData\",\n \"type\": \"bytes\",\n \"internalType\": \"bytes\"\n },\n {\n \"name\": \"encodedLengths\",\n \"type\": \"bytes32\",\n \"internalType\": \"EncodedLengths\"\n },\n {\n \"name\": \"dynamicData\",\n \"type\": \"bytes\",\n \"internalType\": \"bytes\"\n }\n ],\n \"stateMutability\": \"view\"\n },\n {\n \"type\": \"function\",\n \"name\": \"getStaticField\",\n \"inputs\": [\n {\n \"name\": \"tableId\",\n \"type\": \"bytes32\",\n \"internalType\": \"ResourceId\"\n },\n {\n \"name\": \"keyTuple\",\n \"type\": \"bytes32[]\",\n \"internalType\": \"bytes32[]\"\n },\n {\n \"name\": \"fieldIndex\",\n \"type\": \"uint8\",\n \"internalType\": \"uint8\"\n },\n {\n \"name\": \"fieldLayout\",\n \"type\": \"bytes32\",\n \"internalType\": \"FieldLayout\"\n }\n ],\n \"outputs\": [\n {\n \"name\": \"\",\n \"type\": \"bytes32\",\n \"internalType\": \"bytes32\"\n }\n ],\n \"stateMutability\": \"view\"\n },\n {\n \"type\": \"function\",\n \"name\": \"getValueSchema\",\n \"inputs\": [\n {\n \"name\": \"tableId\",\n \"type\": \"bytes32\",\n \"internalType\": \"ResourceId\"\n }\n ],\n \"outputs\": [\n {\n \"name\": \"valueSchema\",\n \"type\": \"bytes32\",\n \"internalType\": \"Schema\"\n }\n ],\n \"stateMutability\": \"view\"\n }\n]","// Follows https://viem.sh/docs/actions/wallet/signTypedData#usage\n\nexport const callWithSignatureTypes = {\n Call: [\n { name: \"signer\", type: \"address\" },\n { name: \"systemNamespace\", type: \"string\" },\n { name: \"systemName\", type: \"string\" },\n { name: \"callData\", type: \"bytes\" },\n { name: \"nonce\", type: \"uint256\" },\n ],\n} as const;\n","import { World } from \"./output\";\n\nexport type DynamicResolution = {\n // TODO: add systemAddress support\n type: \"tableId\";\n input: string;\n};\n\nexport type ValueWithType = {\n value: string | number | Uint8Array;\n type: string;\n};\n\n/**\n * Dynamically resolve a table name to a table id at deploy time\n */\nexport function resolveTableId(tableName: string) {\n return {\n type: \"tableId\",\n input: tableName,\n } as const;\n}\n\n/** Type guard for DynamicResolution */\nexport function isDynamicResolution(value: unknown): value is DynamicResolution {\n return typeof value === \"object\" && value !== null && \"type\" in value && \"input\" in value;\n}\n\n/** Type guard for ValueWithType */\nexport function isValueWithType(value: unknown): value is ValueWithType {\n return typeof value === \"object\" && value !== null && \"type\" in value && \"value\" in value;\n}\n\n/**\n * Turn a DynamicResolution object into a ValueWithType based on the provided context\n */\nexport function resolveWithContext(\n input: unknown,\n context: { config: World; systemAddresses?: Record<string, Promise<string>> },\n): ValueWithType {\n if (isValueWithType(input)) return input;\n\n if (isDynamicResolution(input)) {\n if (input.type === \"tableId\") {\n const tableEntries = Object.entries(context.config.tables).filter(\n ([tableName, table]) => tableName === input.input || table.name === input.input,\n );\n\n if (tableEntries.length > 1) {\n throw new Error(\n `Found more than one table with name \"${input.input}\". Try using one of the following table names instead: ${tableEntries.map(([tableName]) => tableName).join(\", \")}`,\n );\n }\n\n if (tableEntries.length === 1) {\n const [entry] = tableEntries;\n const [, table] = entry;\n return { type: \"bytes32\", value: table.tableId };\n }\n }\n }\n\n throw new Error(`Could not resolve dynamic resolution:\\n${JSON.stringify(input, null, 2)}`);\n}\n"],"mappings":"0NAAA,OAAiD,sBAAAA,MAAqD,OAY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,KAAM,WAAY,KAAM,OAAQ,EAClC,CAAE,KAAM,QAAS,KAAM,SAAU,CACnC,CACF,ECMO,SAASC,EAAeC,EAAmB,CAChD,MAAO,CACL,KAAM,UACN,MAAOA,CACT,CACF,CAGO,SAASC,EAAoBC,EAA4C,CAC9E,OAAO,OAAOA,GAAU,UAAYA,IAAU,MAAQ,SAAUA,GAAS,UAAWA,CACtF,CAGO,SAASC,EAAgBD,EAAwC,CACtE,OAAO,OAAOA,GAAU,UAAYA,IAAU,MAAQ,SAAUA,GAAS,UAAWA,CACtF,CAKO,SAASE,EACdC,EACAC,EACe,CACf,GAAIH,EAAgBE,CAAK,EAAG,OAAOA,EAEnC,GAAIJ,EAAoBI,CAAK,GACvBA,EAAM,OAAS,UAAW,CAC5B,IAAME,EAAe,OAAO,QAAQD,EAAQ,OAAO,MAAM,EAAE,OACzD,CAAC,CAACN,EAAWQ,CAAK,IAAMR,IAAcK,EAAM,OAASG,EAAM,OAASH,EAAM,KAC5E,EAEA,GAAIE,EAAa,OAAS,EACxB,MAAM,IAAI,MACR,wCAAwCF,EAAM,+DAA+DE,EAAa,IAAI,CAAC,CAACP,CAAS,IAAMA,CAAS,EAAE,KAAK,IAAI,GACrK,EAGF,GAAIO,EAAa,SAAW,EAAG,CAC7B,GAAM,CAACE,CAAK,EAAIF,EACV,CAAC,CAAEC,CAAK,EAAIC,EAClB,MAAO,CAAE,KAAM,UAAW,MAAOD,EAAM,OAAQ,GAKrD,MAAM,IAAI,MAAM;AAAA,EAA0C,KAAK,UAAUH,EAAO,KAAM,CAAC,GAAG,CAC5F","names":["encodeFunctionData","encodeSystemCall","abi","systemId","functionName","args","encodeFunctionData","encodeSystemCallFrom","abi","from","systemId","functionName","args","encodeSystemCalls","abi","systemCalls","systemCall","encodeSystemCall","encodeSystemCallsFrom","abi","from","systemCalls","systemCall","encodeSystemCallFrom","slice","concat","getAction","encodeFunctionData","writeContract","readHex","getKeySchema","getValueSchema","getSchemaTypes","decodeValueArgs","encodeKey","IStoreRead_abi_default","callFrom","params","client","writeArgs","getAction","writeContract","worldCalldata","encodeFunctionData","worldFunctionSelector","slice","systemId","systemFunctionSelector","worldFunctionToSystemFunction","systemCalldata","concat","readHex","callFromArgs","systemFunctionCache","cacheKey","cached","systemFunction","retrieveSystemFunctionFromContract","publicClient","worldAddress","table","mud_config_default","keySchema","getSchemaTypes","getKeySchema","valueSchema","getValueSchema","staticData","encodedLengths","dynamicData","IStoreRead_abi_default","encodeKey","decoded","decodeValueArgs","callWithSignatureTypes","resolveTableId","tableName","isDynamicResolution","value","isValueWithType","resolveWithContext","input","context","tableEntries","table","entry"]}
1
+ {"version":3,"sources":["../ts/encodeSystemCall.ts","../ts/encodeSystemCallFrom.ts","../ts/encodeSystemCalls.ts","../ts/encodeSystemCallsFrom.ts","../ts/actions/callFrom.ts","../out/IStoreRead.sol/IStoreRead.abi.json","../ts/callWithSignatureTypes.ts","../ts/config/v2/dynamicResolution.ts"],"sourcesContent":["import { Abi, EncodeFunctionDataParameters, Hex, encodeFunctionData, type ContractFunctionName } from \"viem\";\nimport type { AbiParametersToPrimitiveTypes, ExtractAbiFunction } from \"abitype\";\nimport IWorldCallAbi from \"../out/IWorldKernel.sol/IWorldCall.abi.json\";\n\nexport type SystemCall<abi extends Abi, functionName extends ContractFunctionName<abi>> = EncodeFunctionDataParameters<\n abi,\n functionName\n> & {\n readonly systemId: Hex;\n};\n\n/** Encode a system call to be passed as arguments into `World.call` */\nexport function encodeSystemCall<abi extends Abi, functionName extends ContractFunctionName<abi>>({\n abi,\n systemId,\n functionName,\n args,\n}: SystemCall<abi, functionName>): AbiParametersToPrimitiveTypes<\n ExtractAbiFunction<typeof IWorldCallAbi, \"call\">[\"inputs\"]\n> {\n return [\n systemId,\n encodeFunctionData<abi, functionName>({\n abi,\n functionName,\n args,\n } as unknown as EncodeFunctionDataParameters<abi, functionName>),\n ];\n}\n","import { Abi, EncodeFunctionDataParameters, encodeFunctionData, Address, type ContractFunctionName } from \"viem\";\nimport type { AbiParametersToPrimitiveTypes, ExtractAbiFunction } from \"abitype\";\nimport IWorldCallAbi from \"../out/IWorldKernel.sol/IWorldCall.abi.json\";\nimport { SystemCall } from \"./encodeSystemCall\";\n\nexport type SystemCallFrom<abi extends Abi, functionName extends ContractFunctionName<abi>> = SystemCall<\n abi,\n functionName\n> & {\n readonly from: Address;\n};\n\n/** Encode a system call to be passed as arguments into `World.callFrom` */\nexport function encodeSystemCallFrom<abi extends Abi, functionName extends ContractFunctionName<abi>>({\n abi,\n from,\n systemId,\n functionName,\n args,\n}: SystemCallFrom<abi, functionName>): AbiParametersToPrimitiveTypes<\n ExtractAbiFunction<typeof IWorldCallAbi, \"callFrom\">[\"inputs\"]\n> {\n return [\n from,\n systemId,\n encodeFunctionData<abi, functionName>({\n abi,\n functionName,\n args,\n } as unknown as EncodeFunctionDataParameters<abi, functionName>),\n ];\n}\n","import { Abi, type ContractFunctionName } from \"viem\";\nimport IWorldCallAbi from \"../out/IWorldKernel.sol/IWorldCall.abi.json\";\nimport { SystemCall, encodeSystemCall } from \"./encodeSystemCall\";\nimport type { AbiParametersToPrimitiveTypes, ExtractAbiFunction } from \"abitype\";\n\n/** Encode system calls to be passed as arguments into `World.batchCall` */\nexport function encodeSystemCalls<abi extends Abi, functionName extends ContractFunctionName<abi>>(\n abi: abi,\n systemCalls: readonly Omit<SystemCall<abi, functionName>, \"abi\">[],\n): AbiParametersToPrimitiveTypes<ExtractAbiFunction<typeof IWorldCallAbi, \"call\">[\"inputs\"]>[] {\n return systemCalls.map((systemCall) => encodeSystemCall({ ...systemCall, abi } as SystemCall<abi, functionName>));\n}\n","import { Abi, Address, type ContractFunctionName } from \"viem\";\nimport IWorldCallAbi from \"../out/IWorldKernel.sol/IWorldCall.abi.json\";\nimport { SystemCallFrom, encodeSystemCallFrom } from \"./encodeSystemCallFrom\";\nimport type { AbiParametersToPrimitiveTypes, ExtractAbiFunction } from \"abitype\";\n\n/** Encode system calls to be passed as arguments into `World.batchCallFrom` */\nexport function encodeSystemCallsFrom<abi extends Abi, functionName extends ContractFunctionName<abi>>(\n abi: abi,\n from: Address,\n systemCalls: readonly Omit<SystemCallFrom<abi, functionName>, \"abi\" | \"from\">[],\n): AbiParametersToPrimitiveTypes<ExtractAbiFunction<typeof IWorldCallAbi, \"callFrom\">[\"inputs\"]>[] {\n return systemCalls.map((systemCall) =>\n encodeSystemCallFrom({ ...systemCall, abi, from } as SystemCallFrom<abi, functionName>),\n );\n}\n","import {\n slice,\n concat,\n type Transport,\n type Chain,\n type Account,\n type Hex,\n type WalletActions,\n type WriteContractReturnType,\n type EncodeFunctionDataParameters,\n type PublicClient,\n Client,\n} from \"viem\";\nimport { getAction, encodeFunctionData } from \"viem/utils\";\nimport { writeContract } from \"viem/actions\";\nimport { readHex } from \"@latticexyz/common\";\nimport {\n getKeySchema,\n getValueSchema,\n getSchemaTypes,\n decodeValueArgs,\n encodeKey,\n} from \"@latticexyz/protocol-parser/internal\";\nimport worldConfig from \"../../mud.config\";\nimport IStoreReadAbi from \"../../out/IStoreRead.sol/IStoreRead.abi.json\";\n\n// Accepts either `worldFunctionToSystemFunction` or `publicClient`, but not both.\ntype CallFromParameters = CallFromFunctionParameters | CallFromClientParameters;\ntype CallFromBaseParameters = {\n worldAddress: Hex;\n delegatorAddress: Hex;\n};\ntype CallFromFunctionParameters = CallFromBaseParameters & {\n worldFunctionToSystemFunction: (worldFunctionSelector: Hex) => Promise<SystemFunction>;\n publicClient?: never;\n};\ntype CallFromClientParameters = CallFromBaseParameters & {\n worldFunctionToSystemFunction?: never;\n publicClient: PublicClient;\n};\n\ntype SystemFunction = { systemId: Hex; systemFunctionSelector: Hex };\n\n// By extending viem clients with this function after delegation, the delegation is automatically applied to World contract writes.\n// This means that these writes are made on behalf of the delegator.\n// Internally, it transforms the write arguments to use `callFrom`.\n//\n// Accepts either `worldFunctionToSystemFunction` or `publicClient` as an argument.\n// `worldFunctionToSystemFunction` allows manually providing the mapping function, thus users can utilize their client store for the lookup.\n// If `publicClient` is provided instead, this function retrieves the corresponding system function from the World contract.\n//\n// The function mapping is cached to avoid redundant retrievals for the same World function.\nexport function callFrom<TChain extends Chain, TAccount extends Account>(\n params: CallFromParameters,\n): (client: Client<Transport, TChain, TAccount>) => Pick<WalletActions<TChain, TAccount>, \"writeContract\"> {\n return (client) => ({\n // Applies to: `client.writeContract`, `getContract(client, ...).write`\n writeContract: async (writeArgs): Promise<WriteContractReturnType> => {\n // Skip if the contract isn't the World or the function called should not be redirected through `callFrom`.\n if (\n writeArgs.address !== params.worldAddress ||\n writeArgs.functionName === \"call\" ||\n writeArgs.functionName === \"callFrom\" ||\n writeArgs.functionName === \"callWithSignature\"\n ) {\n return getAction(client, writeContract, \"writeContract\")(writeArgs);\n }\n\n // Encode the World's calldata (which includes the World's function selector).\n const worldCalldata = encodeFunctionData({\n abi: writeArgs.abi,\n functionName: writeArgs.functionName,\n args: writeArgs.args,\n } as unknown as EncodeFunctionDataParameters);\n\n // The first 4 bytes of calldata represent the function selector.\n const worldFunctionSelector = slice(worldCalldata, 0, 4);\n\n // Get the systemId and System's function selector.\n const { systemId, systemFunctionSelector } = await worldFunctionToSystemFunction(params, worldFunctionSelector);\n\n // Construct the System's calldata by replacing the World's function selector with the System's.\n // Use `readHex` instead of `slice` to prevent out-of-bounds errors with calldata that has no args.\n const systemCalldata = concat([systemFunctionSelector, readHex(worldCalldata, 4)]);\n\n // Construct args for `callFrom`.\n const callFromArgs: typeof writeArgs = {\n ...writeArgs,\n functionName: \"callFrom\",\n args: [params.delegatorAddress, systemId, systemCalldata],\n };\n\n // Call `writeContract` with the new args.\n return getAction(client, writeContract, \"writeContract\")(callFromArgs);\n },\n });\n}\n\nconst systemFunctionCache = new Map<Hex, SystemFunction>();\n\nasync function worldFunctionToSystemFunction(\n params: CallFromParameters,\n worldFunctionSelector: Hex,\n): Promise<SystemFunction> {\n const cacheKey = concat([params.worldAddress, worldFunctionSelector]);\n\n // Use cache if the function has been called previously.\n const cached = systemFunctionCache.get(cacheKey);\n if (cached) return cached;\n\n // If a mapping function is provided, use it. Otherwise, call the World contract.\n const systemFunction = params.worldFunctionToSystemFunction\n ? await params.worldFunctionToSystemFunction(worldFunctionSelector)\n : await retrieveSystemFunctionFromContract(params.publicClient, params.worldAddress, worldFunctionSelector);\n\n systemFunctionCache.set(cacheKey, systemFunction);\n\n return systemFunction;\n}\n\nasync function retrieveSystemFunctionFromContract(\n publicClient: PublicClient,\n worldAddress: Hex,\n worldFunctionSelector: Hex,\n): Promise<SystemFunction> {\n const table = worldConfig.tables.world__FunctionSelectors;\n\n const keySchema = getSchemaTypes(getKeySchema(table));\n const valueSchema = getSchemaTypes(getValueSchema(table));\n\n const [staticData, encodedLengths, dynamicData] = await publicClient.readContract({\n address: worldAddress,\n abi: IStoreReadAbi,\n functionName: \"getRecord\",\n args: [table.tableId, encodeKey(keySchema, { worldFunctionSelector })],\n });\n\n const decoded = decodeValueArgs(valueSchema, { staticData, encodedLengths, dynamicData });\n\n const systemFunction: SystemFunction = {\n systemId: decoded.systemId,\n systemFunctionSelector: decoded.systemFunctionSelector,\n };\n\n return systemFunction;\n}\n","[\n {\n \"type\": \"function\",\n \"name\": \"getDynamicField\",\n \"inputs\": [\n {\n \"name\": \"tableId\",\n \"type\": \"bytes32\",\n \"internalType\": \"ResourceId\"\n },\n {\n \"name\": \"keyTuple\",\n \"type\": \"bytes32[]\",\n \"internalType\": \"bytes32[]\"\n },\n {\n \"name\": \"dynamicFieldIndex\",\n \"type\": \"uint8\",\n \"internalType\": \"uint8\"\n }\n ],\n \"outputs\": [\n {\n \"name\": \"\",\n \"type\": \"bytes\",\n \"internalType\": \"bytes\"\n }\n ],\n \"stateMutability\": \"view\"\n },\n {\n \"type\": \"function\",\n \"name\": \"getDynamicFieldLength\",\n \"inputs\": [\n {\n \"name\": \"tableId\",\n \"type\": \"bytes32\",\n \"internalType\": \"ResourceId\"\n },\n {\n \"name\": \"keyTuple\",\n \"type\": \"bytes32[]\",\n \"internalType\": \"bytes32[]\"\n },\n {\n \"name\": \"dynamicFieldIndex\",\n \"type\": \"uint8\",\n \"internalType\": \"uint8\"\n }\n ],\n \"outputs\": [\n {\n \"name\": \"\",\n \"type\": \"uint256\",\n \"internalType\": \"uint256\"\n }\n ],\n \"stateMutability\": \"view\"\n },\n {\n \"type\": \"function\",\n \"name\": \"getDynamicFieldSlice\",\n \"inputs\": [\n {\n \"name\": \"tableId\",\n \"type\": \"bytes32\",\n \"internalType\": \"ResourceId\"\n },\n {\n \"name\": \"keyTuple\",\n \"type\": \"bytes32[]\",\n \"internalType\": \"bytes32[]\"\n },\n {\n \"name\": \"dynamicFieldIndex\",\n \"type\": \"uint8\",\n \"internalType\": \"uint8\"\n },\n {\n \"name\": \"start\",\n \"type\": \"uint256\",\n \"internalType\": \"uint256\"\n },\n {\n \"name\": \"end\",\n \"type\": \"uint256\",\n \"internalType\": \"uint256\"\n }\n ],\n \"outputs\": [\n {\n \"name\": \"data\",\n \"type\": \"bytes\",\n \"internalType\": \"bytes\"\n }\n ],\n \"stateMutability\": \"view\"\n },\n {\n \"type\": \"function\",\n \"name\": \"getField\",\n \"inputs\": [\n {\n \"name\": \"tableId\",\n \"type\": \"bytes32\",\n \"internalType\": \"ResourceId\"\n },\n {\n \"name\": \"keyTuple\",\n \"type\": \"bytes32[]\",\n \"internalType\": \"bytes32[]\"\n },\n {\n \"name\": \"fieldIndex\",\n \"type\": \"uint8\",\n \"internalType\": \"uint8\"\n },\n {\n \"name\": \"fieldLayout\",\n \"type\": \"bytes32\",\n \"internalType\": \"FieldLayout\"\n }\n ],\n \"outputs\": [\n {\n \"name\": \"data\",\n \"type\": \"bytes\",\n \"internalType\": \"bytes\"\n }\n ],\n \"stateMutability\": \"view\"\n },\n {\n \"type\": \"function\",\n \"name\": \"getField\",\n \"inputs\": [\n {\n \"name\": \"tableId\",\n \"type\": \"bytes32\",\n \"internalType\": \"ResourceId\"\n },\n {\n \"name\": \"keyTuple\",\n \"type\": \"bytes32[]\",\n \"internalType\": \"bytes32[]\"\n },\n {\n \"name\": \"fieldIndex\",\n \"type\": \"uint8\",\n \"internalType\": \"uint8\"\n }\n ],\n \"outputs\": [\n {\n \"name\": \"data\",\n \"type\": \"bytes\",\n \"internalType\": \"bytes\"\n }\n ],\n \"stateMutability\": \"view\"\n },\n {\n \"type\": \"function\",\n \"name\": \"getFieldLayout\",\n \"inputs\": [\n {\n \"name\": \"tableId\",\n \"type\": \"bytes32\",\n \"internalType\": \"ResourceId\"\n }\n ],\n \"outputs\": [\n {\n \"name\": \"fieldLayout\",\n \"type\": \"bytes32\",\n \"internalType\": \"FieldLayout\"\n }\n ],\n \"stateMutability\": \"view\"\n },\n {\n \"type\": \"function\",\n \"name\": \"getFieldLength\",\n \"inputs\": [\n {\n \"name\": \"tableId\",\n \"type\": \"bytes32\",\n \"internalType\": \"ResourceId\"\n },\n {\n \"name\": \"keyTuple\",\n \"type\": \"bytes32[]\",\n \"internalType\": \"bytes32[]\"\n },\n {\n \"name\": \"fieldIndex\",\n \"type\": \"uint8\",\n \"internalType\": \"uint8\"\n },\n {\n \"name\": \"fieldLayout\",\n \"type\": \"bytes32\",\n \"internalType\": \"FieldLayout\"\n }\n ],\n \"outputs\": [\n {\n \"name\": \"\",\n \"type\": \"uint256\",\n \"internalType\": \"uint256\"\n }\n ],\n \"stateMutability\": \"view\"\n },\n {\n \"type\": \"function\",\n \"name\": \"getFieldLength\",\n \"inputs\": [\n {\n \"name\": \"tableId\",\n \"type\": \"bytes32\",\n \"internalType\": \"ResourceId\"\n },\n {\n \"name\": \"keyTuple\",\n \"type\": \"bytes32[]\",\n \"internalType\": \"bytes32[]\"\n },\n {\n \"name\": \"fieldIndex\",\n \"type\": \"uint8\",\n \"internalType\": \"uint8\"\n }\n ],\n \"outputs\": [\n {\n \"name\": \"\",\n \"type\": \"uint256\",\n \"internalType\": \"uint256\"\n }\n ],\n \"stateMutability\": \"view\"\n },\n {\n \"type\": \"function\",\n \"name\": \"getKeySchema\",\n \"inputs\": [\n {\n \"name\": \"tableId\",\n \"type\": \"bytes32\",\n \"internalType\": \"ResourceId\"\n }\n ],\n \"outputs\": [\n {\n \"name\": \"keySchema\",\n \"type\": \"bytes32\",\n \"internalType\": \"Schema\"\n }\n ],\n \"stateMutability\": \"view\"\n },\n {\n \"type\": \"function\",\n \"name\": \"getRecord\",\n \"inputs\": [\n {\n \"name\": \"tableId\",\n \"type\": \"bytes32\",\n \"internalType\": \"ResourceId\"\n },\n {\n \"name\": \"keyTuple\",\n \"type\": \"bytes32[]\",\n \"internalType\": \"bytes32[]\"\n },\n {\n \"name\": \"fieldLayout\",\n \"type\": \"bytes32\",\n \"internalType\": \"FieldLayout\"\n }\n ],\n \"outputs\": [\n {\n \"name\": \"staticData\",\n \"type\": \"bytes\",\n \"internalType\": \"bytes\"\n },\n {\n \"name\": \"encodedLengths\",\n \"type\": \"bytes32\",\n \"internalType\": \"EncodedLengths\"\n },\n {\n \"name\": \"dynamicData\",\n \"type\": \"bytes\",\n \"internalType\": \"bytes\"\n }\n ],\n \"stateMutability\": \"view\"\n },\n {\n \"type\": \"function\",\n \"name\": \"getRecord\",\n \"inputs\": [\n {\n \"name\": \"tableId\",\n \"type\": \"bytes32\",\n \"internalType\": \"ResourceId\"\n },\n {\n \"name\": \"keyTuple\",\n \"type\": \"bytes32[]\",\n \"internalType\": \"bytes32[]\"\n }\n ],\n \"outputs\": [\n {\n \"name\": \"staticData\",\n \"type\": \"bytes\",\n \"internalType\": \"bytes\"\n },\n {\n \"name\": \"encodedLengths\",\n \"type\": \"bytes32\",\n \"internalType\": \"EncodedLengths\"\n },\n {\n \"name\": \"dynamicData\",\n \"type\": \"bytes\",\n \"internalType\": \"bytes\"\n }\n ],\n \"stateMutability\": \"view\"\n },\n {\n \"type\": \"function\",\n \"name\": \"getStaticField\",\n \"inputs\": [\n {\n \"name\": \"tableId\",\n \"type\": \"bytes32\",\n \"internalType\": \"ResourceId\"\n },\n {\n \"name\": \"keyTuple\",\n \"type\": \"bytes32[]\",\n \"internalType\": \"bytes32[]\"\n },\n {\n \"name\": \"fieldIndex\",\n \"type\": \"uint8\",\n \"internalType\": \"uint8\"\n },\n {\n \"name\": \"fieldLayout\",\n \"type\": \"bytes32\",\n \"internalType\": \"FieldLayout\"\n }\n ],\n \"outputs\": [\n {\n \"name\": \"\",\n \"type\": \"bytes32\",\n \"internalType\": \"bytes32\"\n }\n ],\n \"stateMutability\": \"view\"\n },\n {\n \"type\": \"function\",\n \"name\": \"getValueSchema\",\n \"inputs\": [\n {\n \"name\": \"tableId\",\n \"type\": \"bytes32\",\n \"internalType\": \"ResourceId\"\n }\n ],\n \"outputs\": [\n {\n \"name\": \"valueSchema\",\n \"type\": \"bytes32\",\n \"internalType\": \"Schema\"\n }\n ],\n \"stateMutability\": \"view\"\n }\n]","// Follows https://viem.sh/docs/actions/wallet/signTypedData#usage\n\nexport const callWithSignatureTypes = {\n Call: [\n { name: \"signer\", type: \"address\" },\n { name: \"systemNamespace\", type: \"string\" },\n { name: \"systemName\", type: \"string\" },\n { name: \"callData\", type: \"bytes\" },\n { name: \"nonce\", type: \"uint256\" },\n ],\n} as const;\n","import { World } from \"./output\";\n\nexport type DynamicResolution = {\n // TODO: add systemAddress support\n type: \"tableId\";\n input: string;\n};\n\nexport type ValueWithType = {\n value: string | number | Uint8Array;\n type: string;\n};\n\n/**\n * Dynamically resolve a table name to a table id at deploy time\n */\nexport function resolveTableId(tableName: string) {\n return {\n type: \"tableId\",\n input: tableName,\n } as const;\n}\n\n/** Type guard for DynamicResolution */\nexport function isDynamicResolution(value: unknown): value is DynamicResolution {\n return typeof value === \"object\" && value !== null && \"type\" in value && \"input\" in value;\n}\n\n/** Type guard for ValueWithType */\nexport function isValueWithType(value: unknown): value is ValueWithType {\n return typeof value === \"object\" && value !== null && \"type\" in value && \"value\" in value;\n}\n\n/**\n * Turn a DynamicResolution object into a ValueWithType based on the provided context\n */\nexport function resolveWithContext(\n input: unknown,\n context: { config: World; systemAddresses?: Record<string, Promise<string>> },\n): ValueWithType {\n if (isValueWithType(input)) return input;\n\n if (isDynamicResolution(input)) {\n if (input.type === \"tableId\") {\n const tableEntries = Object.entries(context.config.tables).filter(\n ([tableName, table]) => tableName === input.input || table.name === input.input,\n );\n\n if (tableEntries.length > 1) {\n throw new Error(\n `Found more than one table with name \"${input.input}\". Try using one of the following table names instead: ${tableEntries.map(([tableName]) => tableName).join(\", \")}`,\n );\n }\n\n if (tableEntries.length === 1) {\n const [entry] = tableEntries;\n const [, table] = entry;\n return { type: \"bytes32\", value: table.tableId };\n }\n }\n }\n\n throw new Error(`Could not resolve dynamic resolution:\\n${JSON.stringify(input, null, 2)}`);\n}\n"],"mappings":"gGAAA,OAAiD,sBAAAA,MAAqD,OAY/F,SAASC,EAAkF,CAChG,IAAAC,EACA,SAAAC,EACA,aAAAC,EACA,KAAAC,CACF,EAEE,CACA,MAAO,CACLF,EACAH,EAAsC,CACpC,IAAAE,EACA,aAAAE,EACA,KAAAC,CACF,CAA+D,CACjE,CACF,CC5BA,OAA4C,sBAAAC,MAA8D,OAanG,SAASC,EAAsF,CACpG,IAAAC,EACA,KAAAC,EACA,SAAAC,EACA,aAAAC,EACA,KAAAC,CACF,EAEE,CACA,MAAO,CACLH,EACAC,EACAJ,EAAsC,CACpC,IAAAE,EACA,aAAAG,EACA,KAAAC,CACF,CAA+D,CACjE,CACF,CCzBO,SAASC,EACdC,EACAC,EAC6F,CAC7F,OAAOA,EAAY,IAAKC,GAAeC,EAAiB,CAAE,GAAGD,EAAY,IAAAF,CAAI,CAAkC,CAAC,CAClH,CCLO,SAASI,EACdC,EACAC,EACAC,EACiG,CACjG,OAAOA,EAAY,IAAKC,GACtBC,EAAqB,CAAE,GAAGD,EAAY,IAAAH,EAAK,KAAAC,CAAK,CAAsC,CACxF,CACF,CCdA,OACE,SAAAI,EACA,UAAAC,MAUK,OACP,OAAS,aAAAC,EAAW,sBAAAC,MAA0B,aAC9C,OAAS,iBAAAC,MAAqB,eAC9B,OAAS,WAAAC,MAAe,qBACxB,OACE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,CAACE,CAAK,EAAIF,EACV,CAAC,CAAEC,CAAK,EAAIC,EAClB,MAAO,CAAE,KAAM,UAAW,MAAOD,EAAM,OAAQ,GAKrD,MAAM,IAAI,MAAM;AAAA,EAA0C,KAAK,UAAUH,EAAO,KAAM,CAAC,GAAG,CAC5F","names":["encodeFunctionData","encodeSystemCall","abi","systemId","functionName","args","encodeFunctionData","encodeSystemCallFrom","abi","from","systemId","functionName","args","encodeSystemCalls","abi","systemCalls","systemCall","encodeSystemCall","encodeSystemCallsFrom","abi","from","systemCalls","systemCall","encodeSystemCallFrom","slice","concat","getAction","encodeFunctionData","writeContract","readHex","getKeySchema","getValueSchema","getSchemaTypes","decodeValueArgs","encodeKey","IStoreRead_abi_default","callFrom","params","client","writeArgs","getAction","writeContract","worldCalldata","encodeFunctionData","worldFunctionSelector","slice","systemId","systemFunctionSelector","worldFunctionToSystemFunction","systemCalldata","concat","readHex","callFromArgs","systemFunctionCache","cacheKey","cached","systemFunction","retrieveSystemFunctionFromContract","publicClient","worldAddress","table","mud_config_default","keySchema","getSchemaTypes","getKeySchema","valueSchema","getValueSchema","staticData","encodedLengths","dynamicData","IStoreRead_abi_default","encodeKey","decoded","decodeValueArgs","callWithSignatureTypes","resolveTableId","tableName","isDynamicResolution","value","isValueWithType","resolveWithContext","input","context","tableEntries","table","entry"]}
@@ -1,2 +1,2 @@
1
- import{a}from"./chunk-G7TYEQQ6.js";import"./chunk-KOZM4MYS.js";import"./chunk-E5NQ4W4F.js";import"./chunk-5UFRBM64.js";import"./chunk-H5QPQRXY.js";export{a as default};
1
+ import{a}from"./chunk-236CU3CY.js";import"./chunk-QWCOI4NR.js";import"./chunk-JEHHYC6A.js";export{a as default};
2
2
  //# sourceMappingURL=mud.config.js.map
package/dist/node.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { ImportDatum, ContractInterfaceFunction, ContractInterfaceError, RelativeImportDatum } from '@latticexyz/common/codegen';
2
- import { W as World, S as System } from './dynamicResolution-e56fd658.js';
2
+ import { W as World, S as System } from './dynamicResolution-b1bf86e3.js';
3
3
  import { Hex } from 'viem';
4
4
  import '@latticexyz/store';
5
5
 
package/dist/node.js CHANGED
@@ -1,4 +1,4 @@
1
- import{a as je}from"./chunk-5UFRBM64.js";import{a as We,b as Vs,c as Pe,d as p,e as O,f as x,g as it}from"./chunk-H5QPQRXY.js";var Ze=We((en,Je)=>{"use strict";Je.exports=Ve;function Ve(n,t,e){n instanceof RegExp&&(n=Ke(n,e)),t instanceof RegExp&&(t=Ke(t,e));var s=Ye(n,t,e);return s&&{start:s[0],end:s[1],pre:e.slice(0,s[0]),body:e.slice(s[0]+n.length,s[1]),post:e.slice(s[1]+t.length)}}function Ke(n,t){var e=t.match(n);return e?e[0]:null}Ve.range=Ye;function Ye(n,t,e){var s,i,r,o,h,a=e.indexOf(n),l=e.indexOf(t,a+1),c=a;if(a>=0&&l>0){if(n===t)return[a,l];for(s=[],r=e.length;c>=0&&!h;)c==a?(s.push(c),a=e.indexOf(n,c+1)):s.length==1?h=[s.pop(),l]:(i=s.pop(),i<r&&(r=i,o=l),l=e.indexOf(t,c+1)),c=a<l&&a>=0?a:l;s.length&&(h=[r,o])}return h}});var ns=We((sn,rs)=>{var Xe=Ze();rs.exports=hi;var Qe="\0SLASH"+Math.random()+"\0",ts="\0OPEN"+Math.random()+"\0",be="\0CLOSE"+Math.random()+"\0",es="\0COMMA"+Math.random()+"\0",ss="\0PERIOD"+Math.random()+"\0";function ye(n){return parseInt(n,10)==n?parseInt(n,10):n.charCodeAt(0)}function ni(n){return n.split("\\\\").join(Qe).split("\\{").join(ts).split("\\}").join(be).split("\\,").join(es).split("\\.").join(ss)}function oi(n){return n.split(Qe).join("\\").split(ts).join("{").split(be).join("}").split(es).join(",").split(ss).join(".")}function is(n){if(!n)return[""];var t=[],e=Xe("{","}",n);if(!e)return n.split(",");var s=e.pre,i=e.body,r=e.post,o=s.split(",");o[o.length-1]+="{"+i+"}";var h=is(r);return r.length&&(o[o.length-1]+=h.shift(),o.push.apply(o,h)),t.push.apply(t,o),t}function hi(n){return n?(n.substr(0,2)==="{}"&&(n="\\{\\}"+n.substr(2)),Mt(ni(n),!0).map(oi)):[]}function ai(n){return"{"+n+"}"}function li(n){return/^-?0\d/.test(n)}function ci(n,t){return n<=t}function fi(n,t){return n>=t}function Mt(n,t){var e=[],s=Xe("{","}",n);if(!s)return[n];var i=s.pre,r=s.post.length?Mt(s.post,!1):[""];if(/\$$/.test(s.pre))for(var o=0;o<r.length;o++){var h=i+"{"+s.body+"}"+r[o];e.push(h)}else{var a=/^-?\d+\.\.-?\d+(?:\.\.-?\d+)?$/.test(s.body),l=/^[a-zA-Z]\.\.[a-zA-Z](?:\.\.-?\d+)?$/.test(s.body),c=a||l,f=s.body.indexOf(",")>=0;if(!c&&!f)return s.post.match(/,.*\}/)?(n=s.pre+"{"+s.body+be+s.post,Mt(n)):[n];var u;if(c)u=s.body.split(/\.\./);else if(u=is(s.body),u.length===1&&(u=Mt(u[0],!1).map(ai),u.length===1))return r.map(function(Yt){return s.pre+u[0]+Yt});var m;if(c){var y=ye(u[0]),d=ye(u[1]),w=Math.max(u[0].length,u[1].length),g=u.length==3?Math.abs(ye(u[2])):1,b=ci,E=d<y;E&&(g*=-1,b=fi);var S=u.some(li);m=[];for(var v=y;b(v,d);v+=g){var k;if(l)k=String.fromCharCode(v),k==="\\"&&(k="");else if(k=String(v),S){var H=w-k.length;if(H>0){var ft=new Array(H+1).join("0");v<0?k="-"+ft+k.slice(1):k=ft+k}}m.push(k)}}else{m=[];for(var q=0;q<u.length;q++)m.push.apply(m,Mt(u[q],!1))}for(var q=0;q<m.length;q++)for(var o=0;o<r.length;o++){var h=i+m[q]+r[o];(!t||c||h)&&e.push(h)}}return e}});import{renderArguments as we,renderList as ze,renderedSolidityHeader as Ys,renderImports as Js}from"@latticexyz/common/codegen";function $e(n){let{imports:t,name:e,functionPrefix:s,functions:i,errors:r}=n;return`
1
+ import{a as We,b as Vs,c as Pe,d as p,e as O,f as x,g as it,h as je}from"./chunk-JEHHYC6A.js";var Ze=We((en,Je)=>{"use strict";Je.exports=Ve;function Ve(n,t,e){n instanceof RegExp&&(n=Ke(n,e)),t instanceof RegExp&&(t=Ke(t,e));var s=Ye(n,t,e);return s&&{start:s[0],end:s[1],pre:e.slice(0,s[0]),body:e.slice(s[0]+n.length,s[1]),post:e.slice(s[1]+t.length)}}function Ke(n,t){var e=t.match(n);return e?e[0]:null}Ve.range=Ye;function Ye(n,t,e){var s,i,r,o,h,a=e.indexOf(n),l=e.indexOf(t,a+1),c=a;if(a>=0&&l>0){if(n===t)return[a,l];for(s=[],r=e.length;c>=0&&!h;)c==a?(s.push(c),a=e.indexOf(n,c+1)):s.length==1?h=[s.pop(),l]:(i=s.pop(),i<r&&(r=i,o=l),l=e.indexOf(t,c+1)),c=a<l&&a>=0?a:l;s.length&&(h=[r,o])}return h}});var ns=We((sn,rs)=>{var Xe=Ze();rs.exports=hi;var Qe="\0SLASH"+Math.random()+"\0",ts="\0OPEN"+Math.random()+"\0",be="\0CLOSE"+Math.random()+"\0",es="\0COMMA"+Math.random()+"\0",ss="\0PERIOD"+Math.random()+"\0";function ye(n){return parseInt(n,10)==n?parseInt(n,10):n.charCodeAt(0)}function ni(n){return n.split("\\\\").join(Qe).split("\\{").join(ts).split("\\}").join(be).split("\\,").join(es).split("\\.").join(ss)}function oi(n){return n.split(Qe).join("\\").split(ts).join("{").split(be).join("}").split(es).join(",").split(ss).join(".")}function is(n){if(!n)return[""];var t=[],e=Xe("{","}",n);if(!e)return n.split(",");var s=e.pre,i=e.body,r=e.post,o=s.split(",");o[o.length-1]+="{"+i+"}";var h=is(r);return r.length&&(o[o.length-1]+=h.shift(),o.push.apply(o,h)),t.push.apply(t,o),t}function hi(n){return n?(n.substr(0,2)==="{}"&&(n="\\{\\}"+n.substr(2)),Mt(ni(n),!0).map(oi)):[]}function ai(n){return"{"+n+"}"}function li(n){return/^-?0\d/.test(n)}function ci(n,t){return n<=t}function fi(n,t){return n>=t}function Mt(n,t){var e=[],s=Xe("{","}",n);if(!s)return[n];var i=s.pre,r=s.post.length?Mt(s.post,!1):[""];if(/\$$/.test(s.pre))for(var o=0;o<r.length;o++){var h=i+"{"+s.body+"}"+r[o];e.push(h)}else{var a=/^-?\d+\.\.-?\d+(?:\.\.-?\d+)?$/.test(s.body),l=/^[a-zA-Z]\.\.[a-zA-Z](?:\.\.-?\d+)?$/.test(s.body),c=a||l,f=s.body.indexOf(",")>=0;if(!c&&!f)return s.post.match(/,.*\}/)?(n=s.pre+"{"+s.body+be+s.post,Mt(n)):[n];var u;if(c)u=s.body.split(/\.\./);else if(u=is(s.body),u.length===1&&(u=Mt(u[0],!1).map(ai),u.length===1))return r.map(function(Yt){return s.pre+u[0]+Yt});var m;if(c){var y=ye(u[0]),d=ye(u[1]),w=Math.max(u[0].length,u[1].length),g=u.length==3?Math.abs(ye(u[2])):1,b=ci,E=d<y;E&&(g*=-1,b=fi);var S=u.some(li);m=[];for(var v=y;b(v,d);v+=g){var k;if(l)k=String.fromCharCode(v),k==="\\"&&(k="");else if(k=String(v),S){var H=w-k.length;if(H>0){var ft=new Array(H+1).join("0");v<0?k="-"+ft+k.slice(1):k=ft+k}}m.push(k)}}else{m=[];for(var q=0;q<u.length;q++)m.push.apply(m,Mt(u[q],!1))}for(var q=0;q<m.length;q++)for(var o=0;o<r.length;o++){var h=i+m[q]+r[o];(!t||c||h)&&e.push(h)}}return e}});import{renderArguments as we,renderList as ze,renderedSolidityHeader as Ys,renderImports as Js}from"@latticexyz/common/codegen";function $e(n){let{imports:t,name:e,functionPrefix:s,functions:i,errors:r}=n;return`
2
2
  ${Ys}
3
3
 
4
4
  ${Js(t)}