@latticexyz/world 2.0.12-main-d7526607 → 2.0.12-main-96e7bf43

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 (92) hide show
  1. package/dist/{chunk-YMY7QWFU.js → chunk-AEVS2CGG.js} +1 -1
  2. package/dist/chunk-AEVS2CGG.js.map +1 -0
  3. package/dist/{chunk-343CB7TH.js → chunk-E5NQ4W4F.js} +2 -2
  4. package/dist/{chunk-343CB7TH.js.map → chunk-E5NQ4W4F.js.map} +1 -1
  5. package/dist/chunk-MTFNNV27.js +2 -0
  6. package/dist/chunk-MTFNNV27.js.map +1 -0
  7. package/dist/chunk-NXAGBVBE.js +2 -0
  8. package/dist/chunk-NXAGBVBE.js.map +1 -0
  9. package/dist/chunk-UMWFUO6H.js +2 -0
  10. package/dist/chunk-UMWFUO6H.js.map +1 -0
  11. package/dist/{chunk-Z4R7FBSR.js → chunk-ZUIIMEYR.js} +2 -2
  12. package/dist/chunk-ZUIIMEYR.js.map +1 -0
  13. package/dist/config/v2.d.ts +5 -10
  14. package/dist/config/v2.js +1 -1
  15. package/dist/{defaults-0e720e83.d.ts → defaults-1be1ffd2.d.ts} +0 -1
  16. package/dist/{output-2c2f47d5.d.ts → dynamicResolution-1a0cabb0.d.ts} +28 -15
  17. package/dist/index.d.ts +3 -3
  18. package/dist/index.js +1 -1
  19. package/dist/internal.d.ts +6 -5
  20. package/dist/internal.js +2 -1
  21. package/dist/internal.js.map +1 -1
  22. package/dist/mud.config.d.ts +13 -12
  23. package/dist/mud.config.js +1 -1
  24. package/dist/node.d.ts +1 -1
  25. package/dist/node.js +1 -1
  26. package/dist/register.d.ts +5 -3
  27. package/dist/register.js +1 -1
  28. package/dist/register.js.map +1 -1
  29. package/dist/{types-6e8f0277.d.ts → types-daf44583.d.ts} +7 -203
  30. package/dist/{world-3ef0fea7.d.ts → world-487f256a.d.ts} +4 -2
  31. package/package.json +15 -27
  32. package/cache/solidity-files-cache.json +0 -1
  33. package/dist/chunk-6LUTYQMB.js +0 -2
  34. package/dist/chunk-6LUTYQMB.js.map +0 -1
  35. package/dist/chunk-G2HK4FEL.js +0 -2
  36. package/dist/chunk-G2HK4FEL.js.map +0 -1
  37. package/dist/chunk-NPFZQNKD.js +0 -2
  38. package/dist/chunk-NPFZQNKD.js.map +0 -1
  39. package/dist/chunk-YMY7QWFU.js.map +0 -1
  40. package/dist/chunk-Z4R7FBSR.js.map +0 -1
  41. package/mud.config.ts +0 -118
  42. package/ts/actions/callFrom.ts +0 -146
  43. package/ts/callWithSignatureTypes.ts +0 -11
  44. package/ts/config/defaults.ts +0 -22
  45. package/ts/config/resolveWorldConfig.ts +0 -79
  46. package/ts/config/types.ts +0 -93
  47. package/ts/config/v2/codegen.ts +0 -10
  48. package/ts/config/v2/compat.test.ts +0 -99
  49. package/ts/config/v2/compat.ts +0 -60
  50. package/ts/config/v2/defaults.ts +0 -44
  51. package/ts/config/v2/deploy.ts +0 -8
  52. package/ts/config/v2/dynamicResolution.ts +0 -57
  53. package/ts/config/v2/index.ts +0 -3
  54. package/ts/config/v2/input.ts +0 -107
  55. package/ts/config/v2/namespaces.ts +0 -58
  56. package/ts/config/v2/output.ts +0 -80
  57. package/ts/config/v2/systems.ts +0 -12
  58. package/ts/config/v2/world.test.ts +0 -782
  59. package/ts/config/v2/world.ts +0 -113
  60. package/ts/config/v2/worldWithShorthands.test.ts +0 -353
  61. package/ts/config/v2/worldWithShorthands.ts +0 -86
  62. package/ts/config/worldConfig.test-d.ts +0 -12
  63. package/ts/config/worldConfig.ts +0 -56
  64. package/ts/encodeSystemCall.test.ts +0 -50
  65. package/ts/encodeSystemCall.ts +0 -29
  66. package/ts/encodeSystemCallFrom.ts +0 -32
  67. package/ts/encodeSystemCalls.test.ts +0 -56
  68. package/ts/encodeSystemCalls.ts +0 -12
  69. package/ts/encodeSystemCallsFrom.ts +0 -15
  70. package/ts/exports/index.ts +0 -10
  71. package/ts/exports/internal.ts +0 -13
  72. package/ts/node/index.ts +0 -1
  73. package/ts/node/render-solidity/index.ts +0 -4
  74. package/ts/node/render-solidity/renderSystemInterface.ts +0 -38
  75. package/ts/node/render-solidity/renderWorldInterface.ts +0 -43
  76. package/ts/node/render-solidity/types.ts +0 -26
  77. package/ts/node/render-solidity/worldgen.ts +0 -75
  78. package/ts/protocol-snapshots/2.0.0.snap +0 -102
  79. package/ts/protocol-snapshots/2.0.1.snap +0 -102
  80. package/ts/protocol-snapshots/2.0.2.snap +0 -102
  81. package/ts/protocolVersions.test.ts +0 -30
  82. package/ts/protocolVersions.ts +0 -7
  83. package/ts/register/configExtensions.ts +0 -18
  84. package/ts/register/index.ts +0 -11
  85. package/ts/register/typeExtensions.ts +0 -28
  86. package/ts/scripts/codegenTightcoder.ts +0 -17
  87. package/ts/scripts/generate-test-tables.ts +0 -40
  88. package/ts/scripts/list-tables-from-store-and-world-configs.ts +0 -11
  89. package/ts/scripts/tablegen.ts +0 -11
  90. package/ts/scripts/worldgen.ts +0 -33
  91. package/ts/worldEvents.test.ts +0 -33
  92. package/ts/worldEvents.ts +0 -5
@@ -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"]}
@@ -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"]}
@@ -0,0 +1,2 @@
1
+ import{a as y}from"./chunk-E5NQ4W4F.js";import{extendedScope as u,get as O,resolveTable as _,validateTable as A,mergeIfUndefined as d,validateTables as b,resolveStore as k,hasOwnKey as E,validateStore as w,isObject as C}from"@latticexyz/store/config/v2";var i={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},p={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 c(e){return x(e,o=>U(o,y))}import{isObject as g,mergeIfUndefined as I}from"@latticexyz/store/config/v2";function f(e){return g(e)?I(e,r):r}import{mergeIfUndefined as L,isObject as F}from"@latticexyz/store/config/v2";function S(e){return F(e)?L(e,n):n}function W(e){let o=u(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 N(e){let o=u(e),s=e.namespaces??{},D=Object.fromEntries(Object.entries(s).map(([t,v])=>Object.entries(v.tables??{}).map(([a,m])=>(A(m,o),[`${t}__${a}`,_(d(m,{namespace:t,name:a}),o)]))).flat()),l=k(e),T=(e.modules??p.modules).map(t=>d(t,i));return d({...l,tables:{...l.tables,...D},codegen:d(l.codegen,f(e.codegen)),deploy:S(e.deploy),systems:c(e.systems??p.systems),excludeSystems:O(e,"excludeSystems"),modules:T},p)}function ee(e){return W(e),N(e)}export{W as a,N as b,ee as c};
2
+ //# sourceMappingURL=chunk-UMWFUO6H.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../ts/config/v2/world.ts","../ts/config/v2/defaults.ts","../ts/config/v2/systems.ts","../ts/config/v2/codegen.ts","../ts/config/v2/deploy.ts"],"sourcesContent":["import { ErrorMessage, conform, evaluate, narrow } from \"@arktype/util\";\nimport {\n UserTypes,\n extendedScope,\n get,\n resolveTable,\n validateTable,\n mergeIfUndefined,\n validateTables,\n resolveStore,\n Store,\n hasOwnKey,\n validateStore,\n isObject,\n} from \"@latticexyz/store/config/v2\";\nimport { SystemsInput, WorldInput } from \"./input\";\nimport { CONFIG_DEFAULTS, MODULE_DEFAULTS } from \"./defaults\";\nimport { Tables } from \"@latticexyz/store/internal\";\nimport { resolveSystems } from \"./systems\";\nimport { resolveNamespacedTables } from \"./namespaces\";\nimport { resolveCodegen } from \"./codegen\";\nimport { resolveDeploy } from \"./deploy\";\n\nexport type validateWorld<world> = {\n readonly [key in keyof world]: key extends \"tables\"\n ? validateTables<world[key], extendedScope<world>>\n : key extends \"userTypes\"\n ? UserTypes\n : key extends \"enums\"\n ? narrow<world[key]>\n : key extends \"namespaces\"\n ? // ? validateNamespaces<world[key], extendedScope<world>>\n ErrorMessage<`Namespaces config will be enabled soon.`>\n : key extends keyof WorldInput\n ? conform<world[key], WorldInput[key]>\n : ErrorMessage<`\\`${key & string}\\` is not a valid World config option.`>;\n};\n\nexport function validateWorld(world: unknown): asserts world is WorldInput {\n const scope = extendedScope(world);\n validateStore(world);\n\n if (hasOwnKey(world, \"namespaces\")) {\n if (!isObject(world.namespaces)) {\n throw new Error(`Expected namespaces, received ${JSON.stringify(world.namespaces)}`);\n }\n for (const namespace of Object.values(world.namespaces)) {\n if (hasOwnKey(namespace, \"tables\")) {\n validateTables(namespace.tables, scope);\n }\n }\n }\n}\n\nexport type resolveWorld<world> = evaluate<\n resolveStore<world> &\n mergeIfUndefined<\n { tables: resolveNamespacedTables<world> } & Omit<\n {\n [key in keyof world]: key extends \"systems\"\n ? resolveSystems<world[key] & SystemsInput>\n : key extends \"deploy\"\n ? resolveDeploy<world[key]>\n : key extends \"codegen\"\n ? resolveCodegen<world[key]>\n : world[key];\n },\n \"namespaces\" | keyof Store\n >,\n CONFIG_DEFAULTS\n >\n>;\n\nexport function resolveWorld<const world extends WorldInput>(world: world): resolveWorld<world> {\n const scope = extendedScope(world);\n const namespaces = world.namespaces ?? {};\n\n const resolvedNamespacedTables = Object.fromEntries(\n Object.entries(namespaces)\n .map(([namespaceKey, namespace]) =>\n Object.entries(namespace.tables ?? {}).map(([tableKey, table]) => {\n validateTable(table, scope);\n return [\n `${namespaceKey}__${tableKey}`,\n resolveTable(mergeIfUndefined(table, { namespace: namespaceKey, name: tableKey }), scope),\n ];\n }),\n )\n .flat(),\n ) as Tables;\n\n const resolvedStore = resolveStore(world);\n\n const modules = (world.modules ?? CONFIG_DEFAULTS.modules).map((mod) => mergeIfUndefined(mod, MODULE_DEFAULTS));\n\n return mergeIfUndefined(\n {\n ...resolvedStore,\n tables: { ...resolvedStore.tables, ...resolvedNamespacedTables },\n codegen: mergeIfUndefined(resolvedStore.codegen, resolveCodegen(world.codegen)),\n deploy: resolveDeploy(world.deploy),\n systems: resolveSystems(world.systems ?? CONFIG_DEFAULTS.systems),\n excludeSystems: get(world, \"excludeSystems\"),\n modules,\n },\n CONFIG_DEFAULTS,\n ) as never;\n}\n\nexport function defineWorld<const world>(world: validateWorld<world>): resolveWorld<world> {\n validateWorld(world);\n return resolveWorld(world) as never;\n}\n","import { CodegenInput, DeployInput, ModuleInput, SystemInput, WorldInput } from \"./input\";\n\nexport const SYSTEM_DEFAULTS = {\n registerFunctionSelectors: true,\n openAccess: true,\n accessList: [],\n} as const satisfies SystemInput;\n\nexport type SYSTEM_DEFAULTS = typeof SYSTEM_DEFAULTS;\n\nexport const MODULE_DEFAULTS = {\n root: false,\n args: [],\n artifactPath: undefined,\n} as const satisfies Pick<ModuleInput, \"root\" | \"args\" | \"artifactPath\">;\n\nexport type MODULE_DEFAULTS = typeof MODULE_DEFAULTS;\n\nexport const CODEGEN_DEFAULTS = {\n worldInterfaceName: \"IWorld\",\n worldgenDirectory: \"world\",\n worldImportPath: \"@latticexyz/world/src/\",\n} as const satisfies CodegenInput;\n\nexport type CODEGEN_DEFAULTS = typeof CODEGEN_DEFAULTS;\n\nexport const DEPLOY_DEFAULTS = {\n customWorldContract: undefined,\n postDeployScript: \"PostDeploy\",\n deploysDirectory: \"./deploys\",\n worldsFile: \"./worlds.json\",\n upgradeableWorldImplementation: false,\n} as const satisfies DeployInput;\n\nexport type DEPLOY_DEFAULTS = typeof DEPLOY_DEFAULTS;\n\nexport const CONFIG_DEFAULTS = {\n systems: {},\n tables: {},\n excludeSystems: [],\n modules: [],\n codegen: CODEGEN_DEFAULTS,\n deploy: DEPLOY_DEFAULTS,\n} as const satisfies WorldInput;\n\nexport type CONFIG_DEFAULTS = typeof CONFIG_DEFAULTS;\n","import { mapObject } from \"@latticexyz/common/utils\";\nimport { SYSTEM_DEFAULTS } from \"../defaults\";\nimport { SystemsInput } from \"./input\";\nimport { mergeIfUndefined } from \"@latticexyz/store/config/v2\";\n\nexport type resolveSystems<systems extends SystemsInput> = {\n [system in keyof systems]: mergeIfUndefined<systems[system], typeof SYSTEM_DEFAULTS>;\n};\n\nexport function resolveSystems<systems extends SystemsInput>(systems: systems): resolveSystems<systems> {\n return mapObject(systems, (system) => mergeIfUndefined(system, SYSTEM_DEFAULTS));\n}\n","import { isObject, mergeIfUndefined } from \"@latticexyz/store/config/v2\";\nimport { CODEGEN_DEFAULTS } from \"./defaults\";\n\nexport type resolveCodegen<codegen> = codegen extends {}\n ? mergeIfUndefined<codegen, CODEGEN_DEFAULTS>\n : CODEGEN_DEFAULTS;\n\nexport function resolveCodegen<codegen>(codegen: codegen): resolveCodegen<codegen> {\n return (isObject(codegen) ? mergeIfUndefined(codegen, CODEGEN_DEFAULTS) : CODEGEN_DEFAULTS) as never;\n}\n","import { mergeIfUndefined, isObject } from \"@latticexyz/store/config/v2\";\nimport { DEPLOY_DEFAULTS } from \"./defaults\";\n\nexport type resolveDeploy<deploy> = deploy extends {} ? mergeIfUndefined<deploy, DEPLOY_DEFAULTS> : DEPLOY_DEFAULTS;\n\nexport function resolveDeploy<deploy>(deploy: deploy): resolveDeploy<deploy> {\n return (isObject(deploy) ? mergeIfUndefined(deploy, DEPLOY_DEFAULTS) : DEPLOY_DEFAULTS) as never;\n}\n"],"mappings":"wCACA,OAEE,iBAAAA,EACA,OAAAC,EACA,gBAAAC,EACA,iBAAAC,EACA,oBAAAC,EACA,kBAAAC,EACA,gBAAAC,EAEA,aAAAC,EACA,iBAAAC,EACA,YAAAC,MACK,8BCJA,IAAMC,EAAkB,CAC7B,KAAM,GACN,KAAM,CAAC,EACP,aAAc,MAChB,EAIaC,EAAmB,CAC9B,mBAAoB,SACpB,kBAAmB,QACnB,gBAAiB,wBACnB,EAIaC,EAAkB,CAC7B,oBAAqB,OACrB,iBAAkB,aAClB,iBAAkB,YAClB,WAAY,gBACZ,+BAAgC,EAClC,EAIaC,EAAkB,CAC7B,QAAS,CAAC,EACV,OAAQ,CAAC,EACT,eAAgB,CAAC,EACjB,QAAS,CAAC,EACV,QAASF,EACT,OAAQC,CACV,EC3CA,OAAS,aAAAE,MAAiB,2BAG1B,OAAS,oBAAAC,MAAwB,8BAM1B,SAASC,EAA6CC,EAA2C,CACtG,OAAOC,EAAUD,EAAUE,GAAWJ,EAAiBI,EAAQC,CAAe,CAAC,CACjF,CCXA,OAAS,YAAAC,EAAU,oBAAAC,MAAwB,8BAOpC,SAASC,EAAwBC,EAA2C,CACjF,OAAQC,EAASD,CAAO,EAAIE,EAAiBF,EAASG,CAAgB,EAAIA,CAC5E,CCTA,OAAS,oBAAAC,EAAkB,YAAAC,MAAgB,8BAKpC,SAASC,EAAsBC,EAAuC,CAC3E,OAAQC,EAASD,CAAM,EAAIE,EAAiBF,EAAQG,CAAe,EAAIA,CACzE,CJ+BO,SAASC,EAAcC,EAA6C,CACzE,IAAMC,EAAQC,EAAc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Table","validateTable","mergeIfUndefined","validateTables","resolveStore","hasOwnKey","validateStore","isObject","MODULE_DEFAULTS","CODEGEN_DEFAULTS","DEPLOY_DEFAULTS","CONFIG_DEFAULTS","mapObject","mergeIfUndefined","resolveSystems","systems","mapObject","system","SYSTEM_DEFAULTS","isObject","mergeIfUndefined","resolveCodegen","codegen","isObject","mergeIfUndefined","CODEGEN_DEFAULTS","mergeIfUndefined","isObject","resolveDeploy","deploy","isObject","mergeIfUndefined","DEPLOY_DEFAULTS","validateWorld","world","scope","extendedScope","validateStore","hasOwnKey","isObject","namespace","validateTables","resolveWorld","namespaces","resolvedNamespacedTables","namespaceKey","tableKey","table","validateTable","resolveTable","mergeIfUndefined","resolvedStore","resolveStore","modules","CONFIG_DEFAULTS","mod","MODULE_DEFAULTS","resolveCodegen","resolveDeploy","resolveSystems","get","defineWorld"]}
@@ -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-UMWFUO6H.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-ZUIIMEYR.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../mud.config.ts"],"sourcesContent":["import { defineWorld } from \"./ts/config/v2/world\";\n\nexport default defineWorld({\n codegen: {\n worldImportPath: \"../../\",\n worldgenDirectory: \"interfaces\",\n worldInterfaceName: \"IBaseWorld\",\n },\n namespace: \"world\", // NOTE: this namespace is only used for tables, the core system is deployed in the root namespace.\n userTypes: {\n ResourceId: { filePath: \"@latticexyz/store/src/ResourceId.sol\", type: \"bytes32\" },\n },\n tables: {\n NamespaceOwner: {\n schema: {\n namespaceId: \"ResourceId\",\n owner: \"address\",\n },\n key: [\"namespaceId\"],\n },\n ResourceAccess: {\n schema: {\n resourceId: \"ResourceId\",\n caller: \"address\",\n access: \"bool\",\n },\n key: [\"resourceId\", \"caller\"],\n },\n InstalledModules: {\n schema: {\n moduleAddress: \"address\",\n argumentsHash: \"bytes32\", // Hash of the params passed to the `install` function\n isInstalled: \"bool\",\n },\n key: [\"moduleAddress\", \"argumentsHash\"],\n },\n UserDelegationControl: {\n schema: {\n delegator: \"address\",\n delegatee: \"address\",\n delegationControlId: \"ResourceId\",\n },\n key: [\"delegator\", \"delegatee\"],\n },\n NamespaceDelegationControl: {\n schema: {\n namespaceId: \"ResourceId\",\n delegationControlId: \"ResourceId\",\n },\n key: [\"namespaceId\"],\n },\n Balances: {\n schema: {\n namespaceId: \"ResourceId\",\n balance: \"uint256\",\n },\n key: [\"namespaceId\"],\n },\n Systems: {\n schema: {\n systemId: \"ResourceId\",\n system: \"address\",\n publicAccess: \"bool\",\n },\n key: [\"systemId\"],\n codegen: {\n dataStruct: false,\n },\n },\n SystemRegistry: {\n schema: {\n system: \"address\",\n systemId: \"ResourceId\",\n },\n key: [\"system\"],\n },\n SystemHooks: {\n schema: {\n systemId: \"ResourceId\",\n value: \"bytes21[]\",\n },\n key: [\"systemId\"],\n },\n FunctionSelectors: {\n schema: {\n worldFunctionSelector: \"bytes4\",\n systemId: \"ResourceId\",\n systemFunctionSelector: \"bytes4\",\n },\n key: [\"worldFunctionSelector\"],\n codegen: {\n dataStruct: false,\n },\n },\n FunctionSignatures: {\n type: \"offchainTable\",\n schema: {\n functionSelector: \"bytes4\",\n functionSignature: \"string\",\n },\n key: [\"functionSelector\"],\n },\n InitModuleAddress: {\n schema: {\n value: \"address\",\n },\n key: [],\n },\n },\n excludeSystems: [\n // Worldgen currently does not support systems inheriting logic\n // from other contracts, so all parts of RegistrationSystem are named\n // System too to be included in the IBaseWorld interface.\n // However, IStoreRegistrationSystem overlaps with IStore if\n // included in IBaseWorld, so it needs to be excluded from worldgen.\n // TODO: add support for inheritance to worldgen\n // (see: https://github.com/latticexyz/mud/issues/631)\n \"StoreRegistrationSystem\",\n ],\n});\n"],"mappings":"wCAEA,IAAOA,EAAQC,EAAY,CACzB,QAAS,CACP,gBAAiB,SACjB,kBAAmB,aACnB,mBAAoB,YACtB,EACA,UAAW,QACX,UAAW,CACT,WAAY,CAAE,SAAU,uCAAwC,KAAM,SAAU,CAClF,EACA,OAAQ,CACN,eAAgB,CACd,OAAQ,CACN,YAAa,aACb,MAAO,SACT,EACA,IAAK,CAAC,aAAa,CACrB,EACA,eAAgB,CACd,OAAQ,CACN,WAAY,aACZ,OAAQ,UACR,OAAQ,MACV,EACA,IAAK,CAAC,aAAc,QAAQ,CAC9B,EACA,iBAAkB,CAChB,OAAQ,CACN,cAAe,UACf,cAAe,UACf,YAAa,MACf,EACA,IAAK,CAAC,gBAAiB,eAAe,CACxC,EACA,sBAAuB,CACrB,OAAQ,CACN,UAAW,UACX,UAAW,UACX,oBAAqB,YACvB,EACA,IAAK,CAAC,YAAa,WAAW,CAChC,EACA,2BAA4B,CAC1B,OAAQ,CACN,YAAa,aACb,oBAAqB,YACvB,EACA,IAAK,CAAC,aAAa,CACrB,EACA,SAAU,CACR,OAAQ,CACN,YAAa,aACb,QAAS,SACX,EACA,IAAK,CAAC,aAAa,CACrB,EACA,QAAS,CACP,OAAQ,CACN,SAAU,aACV,OAAQ,UACR,aAAc,MAChB,EACA,IAAK,CAAC,UAAU,EAChB,QAAS,CACP,WAAY,EACd,CACF,EACA,eAAgB,CACd,OAAQ,CACN,OAAQ,UACR,SAAU,YACZ,EACA,IAAK,CAAC,QAAQ,CAChB,EACA,YAAa,CACX,OAAQ,CACN,SAAU,aACV,MAAO,WACT,EACA,IAAK,CAAC,UAAU,CAClB,EACA,kBAAmB,CACjB,OAAQ,CACN,sBAAuB,SACvB,SAAU,aACV,uBAAwB,QAC1B,EACA,IAAK,CAAC,uBAAuB,EAC7B,QAAS,CACP,WAAY,EACd,CACF,EACA,mBAAoB,CAClB,KAAM,gBACN,OAAQ,CACN,iBAAkB,SAClB,kBAAmB,QACrB,EACA,IAAK,CAAC,kBAAkB,CAC1B,EACA,kBAAmB,CACjB,OAAQ,CACN,MAAO,SACT,EACA,IAAK,CAAC,CACR,CACF,EACA,eAAgB,CAQd,yBACF,CACF,CAAC","names":["mud_config_default","defineWorld"]}
@@ -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-487f256a.js';
2
+ import { W as World, S as Systems } from '../dynamicResolution-1a0cabb0.js';
3
+ export { C as Codegen, c as Deploy, M as Module, b as System } from '../dynamicResolution-1a0cabb0.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-UMWFUO6H.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
@@ -73,7 +60,10 @@ type Codegen = {
73
60
  readonly worldInterfaceName: string;
74
61
  /** Directory to output system and world interfaces of `worldgen` (Default "world") */
75
62
  readonly worldgenDirectory: string;
76
- /** Path for world package imports. Default is "@latticexyz/world/src/" */
63
+ /**
64
+ * Path for world package imports. Default is "@latticexyz/world/src/"
65
+ * @internal
66
+ */
77
67
  readonly worldImportPath: string;
78
68
  };
79
69
  type World = Store & {
@@ -88,4 +78,27 @@ type World = Store & {
88
78
  readonly codegen: Codegen;
89
79
  };
90
80
 
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 };
81
+ type DynamicResolution = {
82
+ type: "tableId";
83
+ input: string;
84
+ };
85
+ type ValueWithType = {
86
+ value: string | number | Uint8Array;
87
+ type: string;
88
+ };
89
+ /**
90
+ * Dynamically resolve a table name to a table id at deploy time
91
+ */
92
+ declare function resolveTableId(tableName: string): {
93
+ readonly type: "tableId";
94
+ readonly input: string;
95
+ };
96
+ /**
97
+ * Turn a DynamicResolution object into a ValueWithType based on the provided context
98
+ */
99
+ declare function resolveWithContext(input: unknown, context: {
100
+ config: World;
101
+ systemAddresses?: Record<string, Promise<string>>;
102
+ }): ValueWithType;
103
+
104
+ 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-487f256a.js';
3
+ export { W as World } from './dynamicResolution-1a0cabb0.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-UMWFUO6H.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-daf44583.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-daf44583.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-1a0cabb0.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-ZUIIMEYR.js";import{a as K,b as O}from"./chunk-NXAGBVBE.js";import"./chunk-UMWFUO6H.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,KAAAC,CACF,EAEE,CACA,MAAO,CACLH,EACAC,EACAJ,EAAsC,CACpC,IAAAE,EACA,aAAAG,EACA,KAAAC,CACF,CAA+D,CACjE,CACF,CCzBO,SAASC,EACdC,EACAC,EAC6F,CAC7F,OAAOA,EAAY,IAAKC,GAAeC,EAAiB,CAAE,GAAGD,EAAY,IAAAF,CAAI,CAAkC,CAAC,CAClH,CCLO,SAASI,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,EACA,kBAAAC,EACA,kBAAAC,EACA,mBAAAC,EACA,aAAAC,MACK,uCCtBP,IAAAC,EAAA,CACE,CACE,KAAQ,WACR,KAAQ,kBACR,OAAU,CACR,CACE,KAAQ,UACR,KAAQ,UACR,aAAgB,YAClB,EACA,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AAC,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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E,OAAO,OAAOA,GAAU,UAAYA,IAAU,MAAQ,SAAUA,GAAS,UAAWA,CACtF,CAKO,SAASE,EACdC,EACAC,EACe,CACf,GAAIH,EAAgBE,CAAK,EAAG,OAAOA,EAEnC,GAAIJ,EAAoBI,CAAK,GACvBA,EAAM,OAAS,UAAW,CAC5B,IAAME,EAAe,OAAO,QAAQD,EAAQ,OAAO,MAAM,EAAE,OACzD,CAAC,CAACN,EAAWQ,CAAK,IAAMR,IAAcK,EAAM,OAASG,EAAM,OAASH,EAAM,KAC5E,EAEA,GAAIE,EAAa,OAAS,EACxB,MAAM,IAAI,MACR,wCAAwCF,EAAM,+DAA+DE,EAAa,IAAI,CAAC,CAACP,CAAS,IAAMA,CAAS,EAAE,KAAK,IAAI,GACrK,EAGF,GAAIO,EAAa,SAAW,EAAG,CAC7B,GAAM,CAACE,CAAK,EAAIF,EACV,CAAC,CAAEC,CAAK,EAAIC,EAClB,MAAO,CAAE,KAAM,UAAW,MAAOD,EAAM,OAAQ,GAKrD,MAAM,IAAI,MAAM;AAAA,EAA0C,KAAK,UAAUH,EAAO,KAAM,CAAC,GAAG,CAC5F","names":["encodeFunctionData","encodeSystemCall","abi","systemId","functionName","args","encodeFunctionData","encodeSystemCallFrom","abi","from","systemId","functionName","args","encodeSystemCalls","abi","systemCalls","systemCall","encodeSystemCall","encodeSystemCallsFrom","abi","from","systemCalls","systemCall","encodeSystemCallFrom","slice","concat","getAction","encodeFunctionData","writeContract","readHex","getKeySchema","getValueSchema","getSchemaTypes","decodeValueArgs","encodeKey","IStoreRead_abi_default","callFrom","params","client","writeArgs","getAction","writeContract","worldCalldata","encodeFunctionData","worldFunctionSelector","slice","systemId","systemFunctionSelector","worldFunctionToSystemFunction","systemCalldata","concat","readHex","callFromArgs","systemFunctionCache","cacheKey","cached","systemFunction","retrieveSystemFunctionFromContract","publicClient","worldAddress","table","mud_config_default","keySchema","getSchemaTypes","getKeySchema","valueSchema","getValueSchema","staticData","encodedLengths","dynamicData","IStoreRead_abi_default","encodeKey","decoded","decodeValueArgs","callWithSignatureTypes","resolveTableId","tableName","isDynamicResolution","value","isValueWithType","resolveWithContext","input","context","tableEntries","table","entry"]}