@latticexyz/world 2.0.12-main-d7526607 → 2.0.12-main-9be2bb86

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.
Files changed (44) hide show
  1. package/cache/solidity-files-cache.json +1 -1
  2. package/dist/{chunk-YMY7QWFU.js → chunk-AEVS2CGG.js} +1 -1
  3. package/dist/chunk-AEVS2CGG.js.map +1 -0
  4. package/dist/{chunk-343CB7TH.js → chunk-E5NQ4W4F.js} +2 -2
  5. package/dist/{chunk-343CB7TH.js.map → chunk-E5NQ4W4F.js.map} +1 -1
  6. package/dist/{chunk-G2HK4FEL.js → chunk-HG6V522M.js} +2 -2
  7. package/dist/chunk-MTFNNV27.js +2 -0
  8. package/dist/chunk-MTFNNV27.js.map +1 -0
  9. package/dist/chunk-NXAGBVBE.js +2 -0
  10. package/dist/chunk-NXAGBVBE.js.map +1 -0
  11. package/dist/{chunk-Z4R7FBSR.js → chunk-PWEXBICA.js} +2 -2
  12. package/dist/config/v2.d.ts +5 -10
  13. package/dist/config/v2.js +1 -1
  14. package/dist/{defaults-0e720e83.d.ts → defaults-1be1ffd2.d.ts} +0 -1
  15. package/dist/{output-2c2f47d5.d.ts → dynamicResolution-e364a0fe.d.ts} +24 -14
  16. package/dist/index.d.ts +3 -3
  17. package/dist/index.js +1 -1
  18. package/dist/internal.d.ts +6 -5
  19. package/dist/internal.js +2 -1
  20. package/dist/internal.js.map +1 -1
  21. package/dist/mud.config.js +1 -1
  22. package/dist/node.d.ts +1 -1
  23. package/dist/node.js +1 -1
  24. package/dist/register.d.ts +5 -3
  25. package/dist/register.js +1 -1
  26. package/dist/register.js.map +1 -1
  27. package/dist/{types-6e8f0277.d.ts → types-05e0a946.d.ts} +2 -198
  28. package/dist/{world-3ef0fea7.d.ts → world-028cabe5.d.ts} +2 -2
  29. package/package.json +8 -8
  30. package/ts/config/defaults.ts +0 -1
  31. package/ts/config/resolveWorldConfig.ts +4 -1
  32. package/ts/config/types.ts +1 -3
  33. package/ts/config/v2/compat.ts +1 -15
  34. package/ts/config/v2/dynamicResolution.ts +22 -15
  35. package/ts/config/worldConfig.ts +1 -18
  36. package/ts/exports/internal.ts +2 -0
  37. package/ts/register/index.ts +1 -1
  38. package/dist/chunk-6LUTYQMB.js +0 -2
  39. package/dist/chunk-6LUTYQMB.js.map +0 -1
  40. package/dist/chunk-NPFZQNKD.js +0 -2
  41. package/dist/chunk-NPFZQNKD.js.map +0 -1
  42. package/dist/chunk-YMY7QWFU.js.map +0 -1
  43. /package/dist/{chunk-G2HK4FEL.js.map → chunk-HG6V522M.js.map} +0 -0
  44. /package/dist/{chunk-Z4R7FBSR.js.map → chunk-PWEXBICA.js.map} +0 -0
@@ -1,2 +1,2 @@
1
1
  import{UnrecognizedSystemErrorFactory as y}from"@latticexyz/config/library";function S(t,s){let n=s?.filter(e=>e.endsWith("System")&&e!=="System"&&!e.match(/^I[A-Z]/))??[],c=Object.keys(t.systems);if(s){for(let e of c)if(!s.includes(e)||e==="World")throw y(["systems",e],e)}return{systems:[...new Set([...n,...c])].filter(e=>!t.excludeSystems.includes(e)).reduce((e,o)=>({...e,[o]:d(o,t.systems[o],s)}),{})}}function d(t,s,n){let c=s?.name??t,i=s?.registerFunctionSelectors??!0,m=s?.openAccess??!0,e=[],o=[],l=s&&!s.openAccess?s.accessList:[];for(let r of l)if(r.startsWith("0x"))e.push(r);else{if(n&&!n.includes(r))throw y(["systems",t,"accessList"],r);o.push(r)}return{name:c,registerFunctionSelectors:i,openAccess:m,accessListAddresses:e,accessListSystems:o}}export{S as a,d as b};
2
- //# sourceMappingURL=chunk-YMY7QWFU.js.map
2
+ //# sourceMappingURL=chunk-AEVS2CGG.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../ts/config/resolveWorldConfig.ts"],"sourcesContent":["import { UnrecognizedSystemErrorFactory } from \"@latticexyz/config/library\";\nimport { StoreConfig } from \"@latticexyz/store/internal\";\nimport { SystemConfig, WorldConfig } from \"./types\";\n\nexport type ResolvedSystemConfig = ReturnType<typeof resolveSystemConfig>;\n\nexport type ResolvedWorldConfig = ReturnType<typeof resolveWorldConfig>;\n\n/**\n * Resolves the world config by combining the default and overridden system configs,\n * filtering out excluded systems, validate system names refer to existing contracts, and\n * splitting the access list into addresses and system names.\n */\nexport function resolveWorldConfig(\n config: Pick<StoreConfig & WorldConfig, \"systems\" | \"excludeSystems\">,\n existingContracts?: string[],\n) {\n // Include contract names ending in \"System\", but not the base \"System\" contract, and not Interfaces\n const defaultSystemNames =\n existingContracts?.filter((name) => name.endsWith(\"System\") && name !== \"System\" && !name.match(/^I[A-Z]/)) ?? [];\n const overriddenSystemNames = Object.keys(config.systems);\n\n // Validate every key in systems refers to an existing system contract (and is not called \"World\")\n if (existingContracts) {\n for (const systemName of overriddenSystemNames) {\n if (!existingContracts.includes(systemName) || systemName === \"World\") {\n throw UnrecognizedSystemErrorFactory([\"systems\", systemName], systemName);\n }\n }\n }\n\n // Combine the default and overridden system names and filter out excluded systems\n const systemNames = [...new Set([...defaultSystemNames, ...overriddenSystemNames])].filter(\n (name) => !config.excludeSystems.includes(name),\n );\n\n // Resolve the config\n const resolvedSystems: Record<string, ResolvedSystemConfig> = systemNames.reduce((acc, systemName) => {\n return {\n ...acc,\n [systemName]: resolveSystemConfig(systemName, config.systems[systemName], existingContracts),\n };\n }, {});\n\n return { systems: resolvedSystems };\n}\n\n/**\n * Resolves the system config by combining the default and overridden system configs,\n * @param systemName name of the system\n * @param config optional SystemConfig object, if none is provided the default config is used\n * @param existingContracts optional list of existing contract names, used to validate system names in the access list. If not provided, no validation is performed.\n * @returns ResolvedSystemConfig object\n * Default value for name is `systemName`\n * Default value for registerFunctionSelectors is true\n * Default value for openAccess is true\n * Default value for accessListAddresses is []\n * Default value for accessListSystems is []\n */\nexport function resolveSystemConfig(systemName: string, config?: SystemConfig, existingContracts?: string[]) {\n const name = config?.name ?? systemName;\n const registerFunctionSelectors = config?.registerFunctionSelectors ?? true;\n const openAccess = config?.openAccess ?? true;\n const accessListAddresses: string[] = [];\n const accessListSystems: string[] = [];\n const accessList = config && !config.openAccess ? config.accessList : [];\n\n // Split the access list into addresses and system names\n for (const accessListItem of accessList) {\n if (accessListItem.startsWith(\"0x\")) {\n accessListAddresses.push(accessListItem);\n } else {\n // Validate every system refers to an existing system contract\n if (existingContracts && !existingContracts.includes(accessListItem)) {\n throw UnrecognizedSystemErrorFactory([\"systems\", systemName, \"accessList\"], accessListItem);\n }\n accessListSystems.push(accessListItem);\n }\n }\n\n return { name, registerFunctionSelectors, openAccess, accessListAddresses, accessListSystems };\n}\n"],"mappings":"AAAA,OAAS,kCAAAA,MAAsC,6BAaxC,SAASC,EACdC,EACAC,EACA,CAEA,IAAMC,EACJD,GAAmB,OAAQE,GAASA,EAAK,SAAS,QAAQ,GAAKA,IAAS,UAAY,CAACA,EAAK,MAAM,SAAS,CAAC,GAAK,CAAC,EAC5GC,EAAwB,OAAO,KAAKJ,EAAO,OAAO,EAGxD,GAAIC,GACF,QAAWI,KAAcD,EACvB,GAAI,CAACH,EAAkB,SAASI,CAAU,GAAKA,IAAe,QAC5D,MAAMP,EAA+B,CAAC,UAAWO,CAAU,EAAGA,CAAU,EAkB9E,MAAO,CAAE,QAZW,CAAC,GAAG,IAAI,IAAI,CAAC,GAAGH,EAAoB,GAAGE,CAAqB,CAAC,CAAC,EAAE,OACjFD,GAAS,CAACH,EAAO,eAAe,SAASG,CAAI,CAChD,EAG0E,OAAO,CAACG,EAAKD,KAC9E,CACL,GAAGC,EACH,CAACD,CAAU,EAAGE,EAAoBF,EAAYL,EAAO,QAAQK,CAAU,EAAGJ,CAAiB,CAC7F,GACC,CAAC,CAAC,CAE6B,CACpC,CAcO,SAASM,EAAoBF,EAAoBL,EAAuBC,EAA8B,CAC3G,IAAME,EAAOH,GAAQ,MAAQK,EACvBG,EAA4BR,GAAQ,2BAA6B,GACjES,EAAaT,GAAQ,YAAc,GACnCU,EAAgC,CAAC,EACjCC,EAA8B,CAAC,EAC/BC,EAAaZ,GAAU,CAACA,EAAO,WAAaA,EAAO,WAAa,CAAC,EAGvE,QAAWa,KAAkBD,EAC3B,GAAIC,EAAe,WAAW,IAAI,EAChCH,EAAoB,KAAKG,CAAc,MAClC,CAEL,GAAIZ,GAAqB,CAACA,EAAkB,SAASY,CAAc,EACjE,MAAMf,EAA+B,CAAC,UAAWO,EAAY,YAAY,EAAGQ,CAAc,EAE5FF,EAAkB,KAAKE,CAAc,EAIzC,MAAO,CAAE,KAAAV,EAAM,0BAAAK,EAA2B,WAAAC,EAAY,oBAAAC,EAAqB,kBAAAC,CAAkB,CAC/F","names":["UnrecognizedSystemErrorFactory","resolveWorldConfig","config","existingContracts","defaultSystemNames","name","overriddenSystemNames","systemName","acc","resolveSystemConfig","registerFunctionSelectors","openAccess","accessListAddresses","accessListSystems","accessList","accessListItem"]}
@@ -1,2 +1,2 @@
1
- var e={registerFunctionSelector:!0,openAccess:!0,accessList:[]},o={worldContractName:void 0,worldInterfaceName:"IWorld",systems:{},excludeSystems:[],postDeployScript:"PostDeploy",deploysDirectory:"./deploys",worldsFile:"./worlds.json",worldgenDirectory:"world",worldImportPath:"@latticexyz/world/src/",modules:[]};export{e as a,o as b};
2
- //# sourceMappingURL=chunk-343CB7TH.js.map
1
+ var e={registerFunctionSelector:!0,openAccess:!0,accessList:[]},o={worldContractName:void 0,worldInterfaceName:"IWorld",systems:{},excludeSystems:[],postDeployScript:"PostDeploy",deploysDirectory:"./deploys",worldsFile:"./worlds.json",worldgenDirectory:"world",worldImportPath:"@latticexyz/world/src/"};export{e as a,o as b};
2
+ //# sourceMappingURL=chunk-E5NQ4W4F.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../ts/config/defaults.ts"],"sourcesContent":["export const SYSTEM_DEFAULTS = {\n registerFunctionSelector: true,\n openAccess: true,\n accessList: [],\n} as const;\n\nexport type SYSTEM_DEFAULTS = typeof SYSTEM_DEFAULTS;\n\nexport const WORLD_DEFAULTS = {\n worldContractName: undefined,\n worldInterfaceName: \"IWorld\",\n systems: {},\n excludeSystems: [],\n postDeployScript: \"PostDeploy\",\n deploysDirectory: \"./deploys\",\n worldsFile: \"./worlds.json\",\n worldgenDirectory: \"world\",\n worldImportPath: \"@latticexyz/world/src/\",\n modules: [],\n} as const;\n\nexport type WORLD_DEFAULTS = typeof WORLD_DEFAULTS;\n"],"mappings":"AAAO,IAAMA,EAAkB,CAC7B,yBAA0B,GAC1B,WAAY,GACZ,WAAY,CAAC,CACf,EAIaC,EAAiB,CAC5B,kBAAmB,OACnB,mBAAoB,SACpB,QAAS,CAAC,EACV,eAAgB,CAAC,EACjB,iBAAkB,aAClB,iBAAkB,YAClB,WAAY,gBACZ,kBAAmB,QACnB,gBAAiB,yBACjB,QAAS,CAAC,CACZ","names":["SYSTEM_DEFAULTS","WORLD_DEFAULTS"]}
1
+ {"version":3,"sources":["../ts/config/defaults.ts"],"sourcesContent":["export const SYSTEM_DEFAULTS = {\n registerFunctionSelector: true,\n openAccess: true,\n accessList: [],\n} as const;\n\nexport type SYSTEM_DEFAULTS = typeof SYSTEM_DEFAULTS;\n\nexport const WORLD_DEFAULTS = {\n worldContractName: undefined,\n worldInterfaceName: \"IWorld\",\n systems: {},\n excludeSystems: [],\n postDeployScript: \"PostDeploy\",\n deploysDirectory: \"./deploys\",\n worldsFile: \"./worlds.json\",\n worldgenDirectory: \"world\",\n worldImportPath: \"@latticexyz/world/src/\",\n} as const;\n\nexport type WORLD_DEFAULTS = typeof WORLD_DEFAULTS;\n"],"mappings":"AAAO,IAAMA,EAAkB,CAC7B,yBAA0B,GAC1B,WAAY,GACZ,WAAY,CAAC,CACf,EAIaC,EAAiB,CAC5B,kBAAmB,OACnB,mBAAoB,SACpB,QAAS,CAAC,EACV,eAAgB,CAAC,EACjB,iBAAkB,aAClB,iBAAkB,YAClB,WAAY,gBACZ,kBAAmB,QACnB,gBAAiB,wBACnB","names":["SYSTEM_DEFAULTS","WORLD_DEFAULTS"]}
@@ -1,2 +1,2 @@
1
- import{a as y}from"./chunk-343CB7TH.js";import{extendedScope as D,get as _,resolveTable as A,validateTable as I,mergeIfUndefined as l,validateTables as b,resolveStore as k,hasOwnKey as E,validateStore as w,isObject as C}from"@latticexyz/store/config/v2";var c={root:!1,args:[],artifactPath:void 0},r={worldInterfaceName:"IWorld",worldgenDirectory:"world",worldImportPath:"@latticexyz/world/src/"},n={customWorldContract:void 0,postDeployScript:"PostDeploy",deploysDirectory:"./deploys",worldsFile:"./worlds.json",upgradeableWorldImplementation:!1},d={systems:{},tables:{},excludeSystems:[],modules:[],codegen:r,deploy:n};import{mapObject as x}from"@latticexyz/common/utils";import{mergeIfUndefined as U}from"@latticexyz/store/config/v2";function i(e){return x(e,o=>U(o,y))}import{isObject as L,mergeIfUndefined as g}from"@latticexyz/store/config/v2";function f(e){return L(e)?g(e,r):r}import{mergeIfUndefined as F,isObject as O}from"@latticexyz/store/config/v2";function S(e){return O(e)?F(e,n):n}function N(e){let o=D(e);if(w(e),E(e,"namespaces")){if(!C(e.namespaces))throw new Error(`Expected namespaces, received ${JSON.stringify(e.namespaces)}`);for(let s of Object.values(e.namespaces))E(s,"tables")&&b(s.tables,o)}}function W(e){let o=D(e),s=e.namespaces??{},T=Object.fromEntries(Object.entries(s).map(([t,v])=>Object.entries(v.tables??{}).map(([a,m])=>(I(m,o),[`${t}__${a}`,A(l(m,{namespace:t,name:a}),o)]))).flat()),p=k(e),u=(e.modules??d.modules).map(t=>l(t,c));return l({...p,tables:{...p.tables,...T},codegen:l(p.codegen,f(e.codegen)),deploy:S(e.deploy),systems:i(e.systems??d.systems),excludeSystems:_(e,"excludeSystems"),modules:u},d)}function ee(e){return N(e),W(e)}export{N as a,W as b,ee as c};
2
- //# sourceMappingURL=chunk-G2HK4FEL.js.map
1
+ import{a as y}from"./chunk-E5NQ4W4F.js";import{extendedScope as D,get as _,resolveTable as A,validateTable as I,mergeIfUndefined as l,validateTables as b,resolveStore as k,hasOwnKey as E,validateStore as w,isObject as C}from"@latticexyz/store/config/v2";var c={root:!1,args:[],artifactPath:void 0},r={worldInterfaceName:"IWorld",worldgenDirectory:"world",worldImportPath:"@latticexyz/world/src/"},n={customWorldContract:void 0,postDeployScript:"PostDeploy",deploysDirectory:"./deploys",worldsFile:"./worlds.json",upgradeableWorldImplementation:!1},d={systems:{},tables:{},excludeSystems:[],modules:[],codegen:r,deploy:n};import{mapObject as x}from"@latticexyz/common/utils";import{mergeIfUndefined as U}from"@latticexyz/store/config/v2";function i(e){return x(e,o=>U(o,y))}import{isObject as L,mergeIfUndefined as g}from"@latticexyz/store/config/v2";function f(e){return L(e)?g(e,r):r}import{mergeIfUndefined as F,isObject as O}from"@latticexyz/store/config/v2";function S(e){return O(e)?F(e,n):n}function N(e){let o=D(e);if(w(e),E(e,"namespaces")){if(!C(e.namespaces))throw new Error(`Expected namespaces, received ${JSON.stringify(e.namespaces)}`);for(let s of Object.values(e.namespaces))E(s,"tables")&&b(s.tables,o)}}function W(e){let o=D(e),s=e.namespaces??{},T=Object.fromEntries(Object.entries(s).map(([t,v])=>Object.entries(v.tables??{}).map(([a,m])=>(I(m,o),[`${t}__${a}`,A(l(m,{namespace:t,name:a}),o)]))).flat()),p=k(e),u=(e.modules??d.modules).map(t=>l(t,c));return l({...p,tables:{...p.tables,...T},codegen:l(p.codegen,f(e.codegen)),deploy:S(e.deploy),systems:i(e.systems??d.systems),excludeSystems:_(e,"excludeSystems"),modules:u},d)}function ee(e){return N(e),W(e)}export{N as a,W as b,ee as c};
2
+ //# sourceMappingURL=chunk-HG6V522M.js.map
@@ -0,0 +1,2 @@
1
+ import{storeToV1 as s}from"@latticexyz/store/config/v2";function t(e){let o={systems:e.systems,excludeSystems:e.excludeSystems,worldContractName:e.deploy.customWorldContract,postDeployScript:e.deploy.postDeployScript,deploysDirectory:e.deploy.deploysDirectory,worldsFile:e.deploy.worldsFile,worldInterfaceName:e.codegen.worldInterfaceName,worldgenDirectory:e.codegen.worldgenDirectory,worldImportPath:e.codegen.worldImportPath};return{...s(e),...o,v2:e}}export{t as a};
2
+ //# sourceMappingURL=chunk-MTFNNV27.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../ts/config/v2/compat.ts"],"sourcesContent":["import { conform } from \"@arktype/util\";\nimport { World, Systems } from \"./output\";\nimport { Store } from \"@latticexyz/store\";\nimport { storeToV1 } from \"@latticexyz/store/config/v2\";\n\ntype systemsToV1<systems extends Systems> = {\n [key in keyof systems]: {\n name?: systems[key][\"name\"];\n registerFunctionSelectors: systems[key][\"registerFunctionSelectors\"];\n } & ({ openAccess: true } | { openAccess: false; accessList: systems[key][\"accessList\"] });\n};\n\nfunction systemsToV1<systems extends Systems>(systems: systems): systemsToV1<systems> {\n return systems;\n}\n\nexport type worldToV1<world> = world extends World\n ? Omit<storeToV1<world>, \"v2\"> & {\n systems: systemsToV1<world[\"systems\"]>;\n excludeSystems: world[\"excludeSystems\"];\n worldContractName: world[\"deploy\"][\"customWorldContract\"];\n postDeployScript: world[\"deploy\"][\"postDeployScript\"];\n deploysDirectory: world[\"deploy\"][\"deploysDirectory\"];\n worldsFile: world[\"deploy\"][\"worldsFile\"];\n worldInterfaceName: world[\"codegen\"][\"worldInterfaceName\"];\n worldgenDirectory: world[\"codegen\"][\"worldgenDirectory\"];\n worldImportPath: world[\"codegen\"][\"worldImportPath\"];\n v2: world;\n }\n : never;\n\nexport function worldToV1<world>(world: conform<world, World>): worldToV1<world> {\n const v1WorldConfig = {\n systems: systemsToV1(world.systems),\n excludeSystems: world.excludeSystems,\n worldContractName: world.deploy.customWorldContract,\n postDeployScript: world.deploy.postDeployScript,\n deploysDirectory: world.deploy.deploysDirectory,\n worldsFile: world.deploy.worldsFile,\n worldInterfaceName: world.codegen.worldInterfaceName,\n worldgenDirectory: world.codegen.worldgenDirectory,\n worldImportPath: world.codegen.worldImportPath,\n };\n\n return { ...storeToV1(world as Store), ...v1WorldConfig, v2: world } as never;\n}\n"],"mappings":"AAGA,OAAS,aAAAA,MAAiB,8BA4BnB,SAASC,EAAiBC,EAAgD,CAC/E,IAAMC,EAAgB,CACpB,QAAqBD,EAAM,QAC3B,eAAgBA,EAAM,eACtB,kBAAmBA,EAAM,OAAO,oBAChC,iBAAkBA,EAAM,OAAO,iBAC/B,iBAAkBA,EAAM,OAAO,iBAC/B,WAAYA,EAAM,OAAO,WACzB,mBAAoBA,EAAM,QAAQ,mBAClC,kBAAmBA,EAAM,QAAQ,kBACjC,gBAAiBA,EAAM,QAAQ,eACjC,EAEA,MAAO,CAAE,GAAGE,EAAUF,CAAc,EAAG,GAAGC,EAAe,GAAID,CAAM,CACrE","names":["storeToV1","worldToV1","world","v1WorldConfig","storeToV1"]}
@@ -0,0 +1,2 @@
1
+ import{a as o,b as t}from"./chunk-E5NQ4W4F.js";import{z as e}from"zod";import{zEthereumAddress as s,zName as l,zObjectName as c}from"@latticexyz/config/library";var r=c,a=e.array(r.or(s)).readonly().default(o.accessList),n=e.intersection(e.object({name:l.optional(),registerFunctionSelectors:e.boolean().default(o.registerFunctionSelector)}),e.discriminatedUnion("openAccess",[e.object({openAccess:e.literal(!0).default(o.openAccess)}),e.object({openAccess:e.literal(!1),accessList:a})])),i=e.object({worldContractName:e.string().optional(),worldInterfaceName:e.string().default(t.worldInterfaceName),systems:e.record(r,n).default(t.systems),excludeSystems:e.array(r).readonly().default(t.excludeSystems),postDeployScript:e.string().default(t.postDeployScript),deploysDirectory:e.string().default(t.deploysDirectory),worldsFile:e.string().default(t.worldsFile),worldgenDirectory:e.string().default(t.worldgenDirectory),worldImportPath:e.string().default(t.worldImportPath)}),f=i.catchall(e.any());export{i as a,f as b};
2
+ //# sourceMappingURL=chunk-NXAGBVBE.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../ts/config/worldConfig.ts"],"sourcesContent":["import { z } from \"zod\";\nimport { zEthereumAddress, zName, zObjectName } from \"@latticexyz/config/library\";\nimport { SYSTEM_DEFAULTS, WORLD_DEFAULTS } from \"./defaults\";\n\nconst zSystemName = zObjectName;\nconst zSystemAccessList = z.array(zSystemName.or(zEthereumAddress)).readonly().default(SYSTEM_DEFAULTS.accessList);\n\n// The system config is a combination of a name config and access config\nconst zSystemConfig = z.intersection(\n z.object({\n name: zName.optional(),\n registerFunctionSelectors: z.boolean().default(SYSTEM_DEFAULTS.registerFunctionSelector),\n }),\n z.discriminatedUnion(\"openAccess\", [\n z.object({\n openAccess: z.literal(true).default(SYSTEM_DEFAULTS.openAccess),\n }),\n z.object({\n openAccess: z.literal(false),\n accessList: zSystemAccessList,\n }),\n ]),\n);\n\n// The parsed world config is the result of parsing the user config\nexport const zWorldConfig = z.object({\n worldContractName: z.string().optional(),\n worldInterfaceName: z.string().default(WORLD_DEFAULTS.worldInterfaceName),\n systems: z.record(zSystemName, zSystemConfig).default(WORLD_DEFAULTS.systems),\n excludeSystems: z.array(zSystemName).readonly().default(WORLD_DEFAULTS.excludeSystems),\n postDeployScript: z.string().default(WORLD_DEFAULTS.postDeployScript),\n deploysDirectory: z.string().default(WORLD_DEFAULTS.deploysDirectory),\n worldsFile: z.string().default(WORLD_DEFAULTS.worldsFile),\n worldgenDirectory: z.string().default(WORLD_DEFAULTS.worldgenDirectory),\n worldImportPath: z.string().default(WORLD_DEFAULTS.worldImportPath),\n});\n\n// Catchall preserves other plugins' options\nexport const zPluginWorldConfig = zWorldConfig.catchall(z.any());\n"],"mappings":"+CAAA,OAAS,KAAAA,MAAS,MAClB,OAAS,oBAAAC,EAAkB,SAAAC,EAAO,eAAAC,MAAmB,6BAGrD,IAAMC,EAAcC,EACdC,EAAoBC,EAAE,MAAMH,EAAY,GAAGI,CAAgB,CAAC,EAAE,SAAS,EAAE,QAAQC,EAAgB,UAAU,EAG3GC,EAAgBH,EAAE,aACtBA,EAAE,OAAO,CACP,KAAMI,EAAM,SAAS,EACrB,0BAA2BJ,EAAE,QAAQ,EAAE,QAAQE,EAAgB,wBAAwB,CACzF,CAAC,EACDF,EAAE,mBAAmB,aAAc,CACjCA,EAAE,OAAO,CACP,WAAYA,EAAE,QAAQ,EAAI,EAAE,QAAQE,EAAgB,UAAU,CAChE,CAAC,EACDF,EAAE,OAAO,CACP,WAAYA,EAAE,QAAQ,EAAK,EAC3B,WAAYD,CACd,CAAC,CACH,CAAC,CACH,EAGaM,EAAeL,EAAE,OAAO,CACnC,kBAAmBA,EAAE,OAAO,EAAE,SAAS,EACvC,mBAAoBA,EAAE,OAAO,EAAE,QAAQM,EAAe,kBAAkB,EACxE,QAASN,EAAE,OAAOH,EAAaM,CAAa,EAAE,QAAQG,EAAe,OAAO,EAC5E,eAAgBN,EAAE,MAAMH,CAAW,EAAE,SAAS,EAAE,QAAQS,EAAe,cAAc,EACrF,iBAAkBN,EAAE,OAAO,EAAE,QAAQM,EAAe,gBAAgB,EACpE,iBAAkBN,EAAE,OAAO,EAAE,QAAQM,EAAe,gBAAgB,EACpE,WAAYN,EAAE,OAAO,EAAE,QAAQM,EAAe,UAAU,EACxD,kBAAmBN,EAAE,OAAO,EAAE,QAAQM,EAAe,iBAAiB,EACtE,gBAAiBN,EAAE,OAAO,EAAE,QAAQM,EAAe,eAAe,CACpE,CAAC,EAGYC,EAAqBF,EAAa,SAASL,EAAE,IAAI,CAAC","names":["z","zEthereumAddress","zName","zObjectName","zSystemName","zObjectName","zSystemAccessList","z","zEthereumAddress","SYSTEM_DEFAULTS","zSystemConfig","zName","zWorldConfig","WORLD_DEFAULTS","zPluginWorldConfig"]}
@@ -1,2 +1,2 @@
1
- import{c as e}from"./chunk-G2HK4FEL.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-Z4R7FBSR.js.map
1
+ import{c as e}from"./chunk-HG6V522M.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-PWEXBICA.js.map
@@ -1,15 +1,11 @@
1
- export { d as defineWorld, r as resolveWorld, v as validateWorld } from '../world-3ef0fea7.js';
2
- import { W as World, M as Module, S as Systems } from '../output-2c2f47d5.js';
3
- export { C as Codegen, D as Deploy, a as System } from '../output-2c2f47d5.js';
1
+ export { d as defineWorld, r as resolveWorld, v as validateWorld } from '../world-028cabe5.js';
2
+ import { W as World, S as Systems } from '../dynamicResolution-e364a0fe.js';
3
+ export { C as Codegen, c as Deploy, M as Module, b as System } from '../dynamicResolution-e364a0fe.js';
4
4
  import { conform } from '@arktype/util';
5
5
  import { storeToV1 } from '@latticexyz/store/config/v2';
6
- import '../defaults-0e720e83.js';
6
+ import '../defaults-1be1ffd2.js';
7
7
  import '@latticexyz/store';
8
8
 
9
- type modulesToV1<modules extends readonly Module[]> = {
10
- [key in keyof modules]: Omit<modules[key], "artifactPath">;
11
- };
12
- declare function modulesToV1<modules extends readonly Module[]>(modules: modules): modulesToV1<modules>;
13
9
  type systemsToV1<systems extends Systems> = {
14
10
  [key in keyof systems]: {
15
11
  name?: systems[key]["name"];
@@ -25,7 +21,6 @@ declare function systemsToV1<systems extends Systems>(systems: systems): systems
25
21
  type worldToV1<world> = world extends World ? Omit<storeToV1<world>, "v2"> & {
26
22
  systems: systemsToV1<world["systems"]>;
27
23
  excludeSystems: world["excludeSystems"];
28
- modules: modulesToV1<world["modules"]>;
29
24
  worldContractName: world["deploy"]["customWorldContract"];
30
25
  postDeployScript: world["deploy"]["postDeployScript"];
31
26
  deploysDirectory: world["deploy"]["deploysDirectory"];
@@ -37,4 +32,4 @@ type worldToV1<world> = world extends World ? Omit<storeToV1<world>, "v2"> & {
37
32
  } : never;
38
33
  declare function worldToV1<world>(world: conform<world, World>): worldToV1<world>;
39
34
 
40
- export { Module, Systems, World, worldToV1 };
35
+ export { Systems, World, worldToV1 };
package/dist/config/v2.js CHANGED
@@ -1,2 +1,2 @@
1
- import{a as o,b as r,c as e}from"../chunk-G2HK4FEL.js";import"../chunk-343CB7TH.js";import{a as f}from"../chunk-6LUTYQMB.js";export{e as defineWorld,r as resolveWorld,o as validateWorld,f as worldToV1};
1
+ import{a as o,b as r,c as e}from"../chunk-HG6V522M.js";import"../chunk-E5NQ4W4F.js";import{a as f}from"../chunk-MTFNNV27.js";export{e as defineWorld,r as resolveWorld,o as validateWorld,f as worldToV1};
2
2
  //# sourceMappingURL=v2.js.map
@@ -14,7 +14,6 @@ declare const WORLD_DEFAULTS: {
14
14
  readonly worldsFile: "./worlds.json";
15
15
  readonly worldgenDirectory: "world";
16
16
  readonly worldImportPath: "@latticexyz/world/src/";
17
- readonly modules: readonly [];
18
17
  };
19
18
  type WORLD_DEFAULTS = typeof WORLD_DEFAULTS;
20
19
 
@@ -1,18 +1,5 @@
1
1
  import { Store } from '@latticexyz/store';
2
2
 
3
- declare enum DynamicResolutionType {
4
- TABLE_ID = 0,
5
- SYSTEM_ADDRESS = 1
6
- }
7
- type DynamicResolution = {
8
- type: DynamicResolutionType;
9
- input: string;
10
- };
11
- type ValueWithType = {
12
- value: string | number | Uint8Array;
13
- type: string;
14
- };
15
-
16
3
  type Module = {
17
4
  /**
18
5
  * The name of the module
@@ -88,4 +75,27 @@ type World = Store & {
88
75
  readonly codegen: Codegen;
89
76
  };
90
77
 
91
- export { Codegen as C, Deploy as D, Module as M, Systems as S, ValueWithType as V, World as W, System as a, DynamicResolution as b };
78
+ type DynamicResolution = {
79
+ type: "tableId";
80
+ input: string;
81
+ };
82
+ type ValueWithType = {
83
+ value: string | number | Uint8Array;
84
+ type: string;
85
+ };
86
+ /**
87
+ * Dynamically resolve a table name to a table id at deploy time
88
+ */
89
+ declare function resolveTableId(tableName: string): {
90
+ readonly type: "tableId";
91
+ readonly input: string;
92
+ };
93
+ /**
94
+ * Turn a DynamicResolution object into a ValueWithType based on the provided context
95
+ */
96
+ declare function resolveWithContext(input: unknown, context: {
97
+ config: World;
98
+ systemAddresses?: Record<string, Promise<string>>;
99
+ }): ValueWithType;
100
+
101
+ export { Codegen as C, DynamicResolution as D, Module as M, Systems as S, ValueWithType as V, World as W, resolveWithContext as a, System as b, Deploy as c, resolveTableId as r };
package/dist/index.d.ts CHANGED
@@ -1,8 +1,8 @@
1
1
  import { validateTablesWithShorthands, extendedScope, Scope, AbiTypeScope, resolveTablesWithShorthands } from '@latticexyz/store/config/v2';
2
- import { v as validateWorld, a as validateNamespaces, r as resolveWorld, W as WorldWithShorthandsInput } from './world-3ef0fea7.js';
3
- export { W as World } from './output-2c2f47d5.js';
2
+ import { v as validateWorld, a as validateNamespaces, r as resolveWorld, W as WorldWithShorthandsInput } from './world-028cabe5.js';
3
+ export { W as World } from './dynamicResolution-e364a0fe.js';
4
4
  import '@arktype/util';
5
- import './defaults-0e720e83.js';
5
+ import './defaults-1be1ffd2.js';
6
6
  import '@latticexyz/store';
7
7
 
8
8
  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-G2HK4FEL.js";import"./chunk-343CB7TH.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 s of Object.keys(e.namespaces))c(S(e.namespaces,[s,"tables"])??{},t)}function x(e){let t=m(e),s=r(e.tables??{},o=>h(o)?i(o,t):o),y=r(e.namespaces??{},o=>({...o,tables:r(o.tables??{},a=>h(a)?i(a,t):a)})),n={...e,tables:s,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-HG6V522M.js";import"./chunk-E5NQ4W4F.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 s of Object.keys(e.namespaces))c(S(e.namespaces,[s,"tables"])??{},t)}function x(e){let t=m(e),s=r(e.tables??{},o=>h(o)?i(o,t):o),y=r(e.namespaces??{},o=>({...o,tables:r(o.tables??{},a=>h(a)?i(a,t):a)})),n={...e,tables:s,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
@@ -1,12 +1,13 @@
1
- export { S as SYSTEM_DEFAULTS, W as WORLD_DEFAULTS } from './defaults-0e720e83.js';
1
+ export { S as SYSTEM_DEFAULTS, W as WORLD_DEFAULTS } from './defaults-1be1ffd2.js';
2
2
  import { StoreConfig } from '@latticexyz/store/internal';
3
- import { W as WorldConfig, S as SystemConfig } from './types-6e8f0277.js';
4
- export { E as ExpandSystemConfig, c as ExpandSystemsConfig, M as ModuleConfig, a as SystemUserConfig, b as SystemsUserConfig, d as WorldUserConfig, e as zPluginWorldConfig, z as zWorldConfig } from './types-6e8f0277.js';
3
+ import { W as WorldConfig, S as SystemConfig } from './types-05e0a946.js';
4
+ export { E as ExpandSystemConfig, c as ExpandSystemsConfig, M as ModuleConfig, a as SystemUserConfig, b as SystemsUserConfig, d as WorldUserConfig, e as zPluginWorldConfig, z as zWorldConfig } from './types-05e0a946.js';
5
5
  import { Abi, ContractFunctionName, EncodeFunctionDataParameters, Hex, Address, Chain, Account, Client, Transport, WalletActions, PublicClient } from 'viem';
6
6
  import { AbiParametersToPrimitiveTypes, ExtractAbiFunction } from 'abitype';
7
+ export { r as resolveTableId, a as resolveWithContext } from './dynamicResolution-e364a0fe.js';
7
8
  import 'zod';
8
- import '@latticexyz/config/library';
9
9
  import '@latticexyz/common/type-utils';
10
+ import '@latticexyz/store';
10
11
 
11
12
  type ResolvedSystemConfig = ReturnType<typeof resolveSystemConfig>;
12
13
  type ResolvedWorldConfig = ReturnType<typeof resolveWorldConfig>;
@@ -15,7 +16,7 @@ type ResolvedWorldConfig = ReturnType<typeof resolveWorldConfig>;
15
16
  * filtering out excluded systems, validate system names refer to existing contracts, and
16
17
  * splitting the access list into addresses and system names.
17
18
  */
18
- declare function resolveWorldConfig(config: StoreConfig & WorldConfig, existingContracts?: string[]): {
19
+ declare function resolveWorldConfig(config: Pick<StoreConfig & WorldConfig, "systems" | "excludeSystems">, existingContracts?: string[]): {
19
20
  systems: Record<string, {
20
21
  name: string;
21
22
  registerFunctionSelectors: boolean;
package/dist/internal.js CHANGED
@@ -1,2 +1,3 @@
1
- import{a as l}from"./chunk-Z4R7FBSR.js";import{a as W,b as H}from"./chunk-NPFZQNKD.js";import"./chunk-G2HK4FEL.js";import{a as R,b as E}from"./chunk-343CB7TH.js";import{a as k,b as M}from"./chunk-YMY7QWFU.js";import{encodeFunctionData as C}from"viem";function c({abi:t,systemId:n,functionName:e,args:a}){return[n,C({abi:t,functionName:e,args:a})]}import{encodeFunctionData as x}from"viem";function p({abi:t,from:n,systemId:e,functionName:a,args:i}){return[n,e,x({abi:t,functionName:a,args:i})]}function X(t,n){return n.map(e=>c({...e,abi:t}))}function ee(t,n,e){return e.map(a=>p({...a,abi:t,from:n}))}import{slice as I,concat as T}from"viem";import{getAction as d,encodeFunctionData as A}from"viem/utils";import{writeContract as b}from"viem/actions";import{readHex as P}from"@latticexyz/common";import{getKeySchema as N,getValueSchema as g,getSchemaTypes as F,decodeValueArgs as w,encodeKey as h}from"@latticexyz/protocol-parser/internal";var u=[{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 ce(t){return n=>({writeContract:async e=>{if(e.address!==t.worldAddress||e.functionName==="call"||e.functionName==="callFrom"||e.functionName==="callWithSignature")return d(n,b,"writeContract")(e);let a=A({abi:e.abi,functionName:e.functionName,args:e.args}),i=I(a,0,4),{systemId:o,systemFunctionSelector:r}=await v(t,i),y=T([r,P(a,4)]),s={...e,functionName:"callFrom",args:[t.delegatorAddress,o,y]};return d(n,b,"writeContract")(s)}})}var f=new Map;async function v(t,n){let e=T([t.worldAddress,n]),a=f.get(e);if(a)return a;let i=t.worldFunctionToSystemFunction?await t.worldFunctionToSystemFunction(n):await D(t.publicClient,t.worldAddress,n);return f.set(e,i),i}async function D(t,n,e){let a=l.tables.world__FunctionSelectors,i=F(N(a)),o=F(g(a)),[r,y,s]=await t.readContract({address:n,abi:u,functionName:"getRecord",args:[a.tableId,h(i,{worldFunctionSelector:e})]}),m=w(o,{staticData:r,encodedLengths:y,dynamicData:s});return{systemId:m.systemId,systemFunctionSelector:m.systemFunctionSelector}}var ue={Call:[{name:"signer",type:"address"},{name:"systemNamespace",type:"string"},{name:"systemName",type:"string"},{name:"callData",type:"bytes"},{name:"nonce",type:"uint256"}]};export{R as SYSTEM_DEFAULTS,E as WORLD_DEFAULTS,ce as callFrom,ue as callWithSignatureTypes,c as encodeSystemCall,p as encodeSystemCallFrom,X as encodeSystemCalls,ee as encodeSystemCallsFrom,M as resolveSystemConfig,k as resolveWorldConfig,H as zPluginWorldConfig,W as zWorldConfig};
1
+ import{a as m}from"./chunk-PWEXBICA.js";import{a as K,b as O}from"./chunk-NXAGBVBE.js";import"./chunk-HG6V522M.js";import{a as M,b as H}from"./chunk-E5NQ4W4F.js";import{a as V,b as j}from"./chunk-AEVS2CGG.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 p({abi:e,from:a,systemId:t,functionName:n,args:i}){return[a,t,x({abi:e,functionName:n,args:i})]}function ee(e,a){return a.map(t=>c({...t,abi:e}))}function ie(e,a,t){return t.map(n=>p({...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 u=[{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 be(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:u,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 Te={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,be as callFrom,Te as callWithSignatureTypes,c as encodeSystemCall,p as encodeSystemCallFrom,ee as encodeSystemCalls,ie as encodeSystemCallsFrom,j as resolveSystemConfig,R as resolveTableId,k as resolveWithContext,V as resolveWorldConfig,O as zPluginWorldConfig,K as zWorldConfig};
2
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"],"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"],"mappings":"iNAAA,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,K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EACyB,CACzB,IAAMU,EAAWJ,EAAO,CAACb,EAAO,aAAcO,CAAqB,CAAC,EAG9DW,EAASF,EAAoB,IAAIC,CAAQ,EAC/C,GAAIC,EAAQ,OAAOA,EAGnB,IAAMC,EAAiBnB,EAAO,8BAC1B,MAAMA,EAAO,8BAA8BO,CAAqB,EAChE,MAAMa,EAAmCpB,EAAO,aAAcA,EAAO,aAAcO,CAAqB,EAE5G,OAAAS,EAAoB,IAAIC,EAAUE,CAAc,EAEzCA,CACT,CAEA,eAAeC,EACbC,EACAC,EACAf,EACyB,CACzB,IAAMgB,EAAQC,EAAY,OAAO,yBAE3BC,EAAYC,EAAeC,EAAaJ,CAAK,CAAC,EAC9CK,EAAcF,EAAeG,EAAeN,CAAK,CAAC,EAElD,CAACO,EAAYC,EAAgBC,CAAW,EAAI,MAAMX,EAAa,aAAa,CAChF,QAASC,EACT,IAAKW,EACL,aAAc,YACd,KAAM,CAACV,EAAM,QAASW,EAAUT,EAAW,CAAE,sBAAAlB,CAAsB,CAAC,CAAC,CACvE,CAAC,EAEK4B,EAAUC,EAAgBR,EAAa,CAAE,WAAAE,EAAY,eAAAC,EAAgB,YAAAC,CAAY,CAAC,EAOxF,MALuC,CACrC,SAAUG,EAAQ,SAClB,uBAAwBA,EAAQ,sBAClC,CAGF,CE/IO,IAAME,GAAyB,CACpC,KAAM,CACJ,CAAE,KAAM,SAAU,KAAM,SAAU,EAClC,CAAE,KAAM,kBAAmB,KAAM,QAAS,EAC1C,CAAE,KAAM,aAAc,KAAM,QAAS,EACrC,CAAE,KAAM,WAAY,KAAM,OAAQ,EAClC,CAAE,KAAM,QAAS,KAAM,SAAU,CACnC,CACF","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"]}
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":"iNAAA,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,GACdC,EACAC,EAC6F,CAC7F,OAAOA,EAAY,IAAKC,GAAeC,EAAiB,CAAE,GAAGD,EAAY,IAAAF,CAAI,CAAkC,CAAC,CAClH,CCLO,SAASI,GACdC,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,gBAAAC,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AK,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-Z4R7FBSR.js";import"./chunk-G2HK4FEL.js";import"./chunk-343CB7TH.js";export{a as default};
1
+ import{a}from"./chunk-PWEXBICA.js";import"./chunk-HG6V522M.js";import"./chunk-E5NQ4W4F.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 } from './output-2c2f47d5.js';
2
+ import { W as World } from './dynamicResolution-e364a0fe.js';
3
3
  import '@latticexyz/store';
4
4
 
5
5
  interface RenderSystemInterfaceOptions {
package/dist/node.js CHANGED
@@ -1,4 +1,4 @@
1
- import{a as y}from"./chunk-YMY7QWFU.js";import{a as h}from"./chunk-6LUTYQMB.js";import{renderArguments as u,renderList as I,renderedSolidityHeader as R,renderImports as O}from"@latticexyz/common/codegen";function $(t){let{imports:r,name:i,functionPrefix:e,functions:m,errors:o}=t;return`
1
+ import{a as y}from"./chunk-AEVS2CGG.js";import{a as h}from"./chunk-MTFNNV27.js";import{renderArguments as u,renderList as I,renderedSolidityHeader as R,renderImports as O}from"@latticexyz/common/codegen";function $(t){let{imports:r,name:i,functionPrefix:e,functions:m,errors:o}=t;return`
2
2
  ${R}
3
3
 
4
4
  ${O(r)}
@@ -1,9 +1,11 @@
1
- export { mudConfig, mudCoreConfig, resolveTableId } from '@latticexyz/store/register';
1
+ export { mudConfig, mudCoreConfig } from '@latticexyz/store/register';
2
2
  import { OrDefaults } from '@latticexyz/common/type-utils';
3
3
  import { MUDCoreUserConfig } from '@latticexyz/config/library';
4
- import { W as WORLD_DEFAULTS } from './defaults-0e720e83.js';
5
- import { d as WorldUserConfig, W as WorldConfig, c as ExpandSystemsConfig } from './types-6e8f0277.js';
4
+ import { W as WORLD_DEFAULTS } from './defaults-1be1ffd2.js';
5
+ import { d as WorldUserConfig, W as WorldConfig, c as ExpandSystemsConfig } from './types-05e0a946.js';
6
6
  import 'zod';
7
+ import './dynamicResolution-e364a0fe.js';
8
+ import '@latticexyz/store';
7
9
 
8
10
  declare module "@latticexyz/config/library" {
9
11
  interface MUDCoreUserConfig extends WorldUserConfig {
package/dist/register.js CHANGED
@@ -1,2 +1,2 @@
1
- import{b as o}from"./chunk-NPFZQNKD.js";import"./chunk-343CB7TH.js";import"@latticexyz/store/register";import{mudConfig as x,mudCoreConfig as U,resolveTableId as c}from"@latticexyz/store/register";import{extendMUDCoreConfig as t,fromZodErrorCustom as i}from"@latticexyz/config/library";import{ZodError as n}from"zod";t(e=>{try{return o.parse(e)}catch(r){throw r instanceof n?i(r,"WorldConfig Validation Error"):r}});import"@latticexyz/store/register";export{x as mudConfig,U as mudCoreConfig,c as resolveTableId};
1
+ import{b as o}from"./chunk-NXAGBVBE.js";import"./chunk-E5NQ4W4F.js";import"@latticexyz/store/register";import{mudConfig as x,mudCoreConfig as U}from"@latticexyz/store/register";import{extendMUDCoreConfig as t,fromZodErrorCustom as i}from"@latticexyz/config/library";import{ZodError as n}from"zod";t(e=>{try{return o.parse(e)}catch(r){throw r instanceof n?i(r,"WorldConfig Validation Error"):r}});import"@latticexyz/store/register";export{x as mudConfig,U as mudCoreConfig};
2
2
  //# sourceMappingURL=register.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../ts/register/index.ts","../ts/register/configExtensions.ts","../ts/register/typeExtensions.ts"],"sourcesContent":["// Importing this file has side-effects for MUD config,\n// and the order of imports is important in relation to other plugins\n// (store should usually be the first plugin, followed by world)\n\n// For convenience register and reexport store (which does the same for core config),\n// to reduce the number of needed imports for users\nimport \"@latticexyz/store/register\";\nexport { mudConfig, mudCoreConfig, resolveTableId } from \"@latticexyz/store/register\";\n// Extend core config and types\nimport \"./configExtensions\";\nimport \"./typeExtensions\";\n","import { extendMUDCoreConfig, fromZodErrorCustom } from \"@latticexyz/config/library\";\nimport { ZodError } from \"zod\";\nimport { zPluginWorldConfig } from \"../config/worldConfig\";\n\nextendMUDCoreConfig((config) => {\n // This function gets called within mudConfig.\n // The call order of config extenders depends on the order of their imports.\n // Any config validation and transformation should be placed here.\n try {\n return zPluginWorldConfig.parse(config);\n } catch (error) {\n if (error instanceof ZodError) {\n throw fromZodErrorCustom(error, \"WorldConfig Validation Error\");\n } else {\n throw error;\n }\n }\n});\n","import { OrDefaults } from \"@latticexyz/common/type-utils\";\nimport { MUDCoreUserConfig } from \"@latticexyz/config/library\";\n\nimport \"@latticexyz/store/register\";\nimport { WORLD_DEFAULTS } from \"../config/defaults\";\nimport { WorldUserConfig, WorldConfig, ExpandSystemsConfig } from \"../config/types\";\n\n// Inject the plugin options into the core config.\n// Re-exporting an interface of an existing module merges them, adding new options to the interface.\n// (typescript has no way to override types)\ndeclare module \"@latticexyz/config/library\" {\n // Extend the user config type, which represents the config as written by the users.\n // Most things are optional here.\n // eslint-disable-next-line @typescript-eslint/no-empty-interface\n export interface MUDCoreUserConfig extends WorldUserConfig {}\n\n // Also extend the config type, which represents the configuration after it has been resolved.\n // It should not have any optional properties, with the default values applied instead.\n // Other plugins may receive this resolved config as their input.\n // eslint-disable-next-line @typescript-eslint/no-empty-interface\n export interface MUDCoreConfig extends WorldConfig {}\n}\n\ndeclare module \"@latticexyz/store/register\" {\n export interface ExpandMUDUserConfig<T extends MUDCoreUserConfig> extends OrDefaults<T, WORLD_DEFAULTS> {\n systems: ExpandSystemsConfig<T[\"systems\"] extends Record<string, unknown> ? T[\"systems\"] : Record<string, never>>;\n }\n}\n"],"mappings":"oEAMA,MAAO,6BACP,OAAS,aAAAA,EAAW,iBAAAC,EAAe,kBAAAC,MAAsB,6BCPzD,OAAS,uBAAAC,EAAqB,sBAAAC,MAA0B,6BACxD,OAAS,YAAAC,MAAgB,MAGzBC,EAAqBC,GAAW,CAI9B,GAAI,CACF,OAAOC,EAAmB,MAAMD,CAAM,CACxC,OAASE,EAAP,CACA,MAAIA,aAAiBC,EACbC,EAAmBF,EAAO,8BAA8B,EAExDA,CAEV,CACF,CAAC,ECdD,MAAO","names":["mudConfig","mudCoreConfig","resolveTableId","extendMUDCoreConfig","fromZodErrorCustom","ZodError","extendMUDCoreConfig","config","zPluginWorldConfig","error","ZodError","fromZodErrorCustom"]}
1
+ {"version":3,"sources":["../ts/register/index.ts","../ts/register/configExtensions.ts","../ts/register/typeExtensions.ts"],"sourcesContent":["// Importing this file has side-effects for MUD config,\n// and the order of imports is important in relation to other plugins\n// (store should usually be the first plugin, followed by world)\n\n// For convenience register and reexport store (which does the same for core config),\n// to reduce the number of needed imports for users\nimport \"@latticexyz/store/register\";\nexport { mudConfig, mudCoreConfig } from \"@latticexyz/store/register\";\n// Extend core config and types\nimport \"./configExtensions\";\nimport \"./typeExtensions\";\n","import { extendMUDCoreConfig, fromZodErrorCustom } from \"@latticexyz/config/library\";\nimport { ZodError } from \"zod\";\nimport { zPluginWorldConfig } from \"../config/worldConfig\";\n\nextendMUDCoreConfig((config) => {\n // This function gets called within mudConfig.\n // The call order of config extenders depends on the order of their imports.\n // Any config validation and transformation should be placed here.\n try {\n return zPluginWorldConfig.parse(config);\n } catch (error) {\n if (error instanceof ZodError) {\n throw fromZodErrorCustom(error, \"WorldConfig Validation Error\");\n } else {\n throw error;\n }\n }\n});\n","import { OrDefaults } from \"@latticexyz/common/type-utils\";\nimport { MUDCoreUserConfig } from \"@latticexyz/config/library\";\n\nimport \"@latticexyz/store/register\";\nimport { WORLD_DEFAULTS } from \"../config/defaults\";\nimport { WorldUserConfig, WorldConfig, ExpandSystemsConfig } from \"../config/types\";\n\n// Inject the plugin options into the core config.\n// Re-exporting an interface of an existing module merges them, adding new options to the interface.\n// (typescript has no way to override types)\ndeclare module \"@latticexyz/config/library\" {\n // Extend the user config type, which represents the config as written by the users.\n // Most things are optional here.\n // eslint-disable-next-line @typescript-eslint/no-empty-interface\n export interface MUDCoreUserConfig extends WorldUserConfig {}\n\n // Also extend the config type, which represents the configuration after it has been resolved.\n // It should not have any optional properties, with the default values applied instead.\n // Other plugins may receive this resolved config as their input.\n // eslint-disable-next-line @typescript-eslint/no-empty-interface\n export interface MUDCoreConfig extends WorldConfig {}\n}\n\ndeclare module \"@latticexyz/store/register\" {\n export interface ExpandMUDUserConfig<T extends MUDCoreUserConfig> extends OrDefaults<T, WORLD_DEFAULTS> {\n systems: ExpandSystemsConfig<T[\"systems\"] extends Record<string, unknown> ? T[\"systems\"] : Record<string, never>>;\n }\n}\n"],"mappings":"oEAMA,MAAO,6BACP,OAAS,aAAAA,EAAW,iBAAAC,MAAqB,6BCPzC,OAAS,uBAAAC,EAAqB,sBAAAC,MAA0B,6BACxD,OAAS,YAAAC,MAAgB,MAGzBC,EAAqBC,GAAW,CAI9B,GAAI,CACF,OAAOC,EAAmB,MAAMD,CAAM,CACxC,OAASE,EAAP,CACA,MAAIA,aAAiBC,EACbC,EAAmBF,EAAO,8BAA8B,EAExDA,CAEV,CACF,CAAC,ECdD,MAAO","names":["mudConfig","mudCoreConfig","extendMUDCoreConfig","fromZodErrorCustom","ZodError","extendMUDCoreConfig","config","zPluginWorldConfig","error","ZodError","fromZodErrorCustom"]}