@latticexyz/world 3.0.0-main-8f6fa588d → 3.0.0-main-69e23a36b
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/chunk-BH75YTBY.js +2 -0
- package/dist/chunk-BH75YTBY.js.map +1 -0
- package/dist/{chunk-Z53LAQKB.js → chunk-OZBNK257.js} +2 -2
- package/dist/config/v2.d.ts +1 -1
- package/dist/config/v2.js +1 -1
- package/dist/index.d.ts +4 -13
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/internal.js +1 -1
- package/dist/mud.config.d.ts +362 -14
- package/dist/mud.config.js +1 -1
- package/dist/{world-ef5ac077.d.ts → world-6e8198d8.d.ts} +18 -22
- package/package.json +8 -8
- package/dist/chunk-OM2LE2WB.js +0 -2
- package/dist/chunk-OM2LE2WB.js.map +0 -1
- /package/dist/{chunk-Z53LAQKB.js.map → chunk-OZBNK257.js.map} +0 -0
@@ -0,0 +1,2 @@
|
|
1
|
+
import{h as c,i as p,j as l,k as r,l as i,m as y}from"./chunk-DK3XOTC2.js";import{extendedScope as k,get as j,resolveTable as L,validateTable as F,mergeIfUndefined as a,resolveStore as $,hasOwnKey as S,validateStore as C}from"@latticexyz/store/config/v2";import{isObject as w}from"@latticexyz/store/config/v2";function f(e){if(w(e)){for(let s of Object.values(e))i(s,{inNamespace:!0});return}throw new Error(`Expected system config, received ${JSON.stringify(e)}`)}function v(e,s){return Object.fromEntries(Object.entries(e).map(([o,n])=>[o,y({...n,label:o,namespace:s})]))}import{validateTables as I,isObject as N,hasOwnKey as O}from"@latticexyz/store/config/v2";function D(e,s){O(e,"tables")&&I(e.tables,s)}function b(e,s){if(!N(e))throw new Error(`Expected namespaces, received ${JSON.stringify(e)}`);for(let o of Object.values(e))D(o,s)}import{isObject as U,mergeIfUndefined as W}from"@latticexyz/store/config/v2";function u(e){return U(e)?W(e,p):p}import{mergeIfUndefined as _,isObject as A}from"@latticexyz/store/config/v2";function x(e){return A(e)?_(e,l):l}function h(e){let s=k(e);C(e),S(e,"systems")&&f(e.systems),S(e,"namespaces")&&b(e.namespaces,s)}function M(e){let s=k(e),o=$(e),n=e.namespaces??{},g=Object.fromEntries(Object.entries(n).map(([t,T])=>Object.entries(T.tables??{}).map(([m,d])=>(F(d,s),[`${t}__${m}`,L(a(d,{namespace:t,name:m}),s)]))).flat()),E=(e.modules??r.modules).map(t=>a(t,c));return a({...o,tables:{...o.tables,...g},codegen:a(o.codegen,u(e.codegen)),deploy:x(e.deploy),systems:v(e.systems??r.systems,o.namespace),excludeSystems:j(e,"excludeSystems"),modules:E},r)}function ye(e){return h(e),M(e)}export{h as a,M as b,ye as c};
|
2
|
+
//# sourceMappingURL=chunk-BH75YTBY.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"sources":["../ts/config/v2/world.ts","../ts/config/v2/systems.ts","../ts/config/v2/namespaces.ts","../ts/config/v2/codegen.ts","../ts/config/v2/deploy.ts"],"sourcesContent":["import { ErrorMessage, conform, narrow, type withJsDoc } from \"@arktype/util\";\nimport {\n UserTypes,\n extendedScope,\n get,\n resolveTable,\n validateTable,\n mergeIfUndefined,\n validateTables,\n resolveStore,\n Store,\n hasOwnKey,\n validateStore,\n} from \"@latticexyz/store/config/v2\";\nimport { SystemsInput, WorldInput } from \"./input\";\nimport { CONFIG_DEFAULTS, MODULE_DEFAULTS } from \"./defaults\";\nimport { Tables } from \"@latticexyz/store/internal\";\nimport { resolveSystems, validateSystems } from \"./systems\";\nimport { resolveNamespacedTables, validateNamespaces } from \"./namespaces\";\nimport { resolveCodegen } from \"./codegen\";\nimport { resolveDeploy } from \"./deploy\";\nimport type { World } from \"./output.js\";\n\nexport type validateWorld<world> = {\n readonly [key in keyof world]: key extends \"tables\"\n ? validateTables<world[key], extendedScope<world>>\n : key extends \"userTypes\"\n ? UserTypes\n : key extends \"enums\"\n ? narrow<world[key]>\n : key extends \"systems\"\n ? validateSystems<world[key]>\n : key extends \"namespaces\"\n ? // ? validateNamespaces<world[key], extendedScope<world>>\n ErrorMessage<`Namespaces config will be enabled soon.`>\n : key extends keyof WorldInput\n ? conform<world[key], WorldInput[key]>\n : ErrorMessage<`\\`${key & string}\\` is not a valid World config option.`>;\n};\n\nexport function validateWorld(world: unknown): asserts world is WorldInput {\n const scope = extendedScope(world);\n validateStore(world);\n\n if (hasOwnKey(world, \"systems\")) {\n validateSystems(world.systems);\n }\n if (hasOwnKey(world, \"namespaces\")) {\n validateNamespaces(world.namespaces, scope);\n }\n}\n\nexport type resolveWorld<world, namespace = resolveStore<world>[\"namespace\"]> = withJsDoc<\n resolveStore<world> &\n mergeIfUndefined<\n { readonly tables: resolveNamespacedTables<world> } & {\n [key in Exclude<keyof world, keyof Store>]: key extends \"systems\"\n ? resolveSystems<world[key] & SystemsInput, namespace & string>\n : key extends \"deploy\"\n ? resolveDeploy<world[key]>\n : key extends \"codegen\"\n ? resolveCodegen<world[key]>\n : world[key];\n },\n CONFIG_DEFAULTS\n >,\n World\n>;\n\nexport function resolveWorld<const world extends WorldInput>(world: world): resolveWorld<world> {\n const scope = extendedScope(world);\n const resolvedStore = resolveStore(world);\n const namespaces = world.namespaces ?? {};\n\n const resolvedNamespacedTables = Object.fromEntries(\n Object.entries(namespaces)\n .map(([namespaceKey, namespace]) =>\n Object.entries(namespace.tables ?? {}).map(([tableKey, table]) => {\n validateTable(table, scope);\n return [\n `${namespaceKey}__${tableKey}`,\n resolveTable(mergeIfUndefined(table, { namespace: namespaceKey, name: tableKey }), scope),\n ];\n }),\n )\n .flat(),\n ) as Tables;\n\n const modules = (world.modules ?? CONFIG_DEFAULTS.modules).map((mod) => mergeIfUndefined(mod, MODULE_DEFAULTS));\n\n return mergeIfUndefined(\n {\n ...resolvedStore,\n tables: { ...resolvedStore.tables, ...resolvedNamespacedTables },\n codegen: mergeIfUndefined(resolvedStore.codegen, resolveCodegen(world.codegen)),\n deploy: resolveDeploy(world.deploy),\n systems: resolveSystems(world.systems ?? CONFIG_DEFAULTS.systems, resolvedStore.namespace),\n excludeSystems: get(world, \"excludeSystems\"),\n modules,\n },\n CONFIG_DEFAULTS,\n ) as never;\n}\n\nexport function defineWorld<const input>(input: validateWorld<input>): resolveWorld<input> {\n validateWorld(input);\n return resolveWorld(input) as never;\n}\n","import { ErrorMessage } from \"@arktype/util\";\nimport { isObject } from \"@latticexyz/store/config/v2\";\nimport { SystemsInput } from \"./input\";\nimport { resolveSystem, validateSystem } from \"./system\";\n\n// TODO: add nuance between \"in namespace\" (namespace provided in context) and \"in systems\" (label provided in context)\n\nexport type validateSystems<input> = {\n [label in keyof input]: input[label] extends object\n ? validateSystem<input[label], { inNamespace: true }>\n : ErrorMessage<`Expected a system config for ${label & string}.`>;\n};\n\nexport function validateSystems(input: unknown): asserts input is SystemsInput {\n if (isObject(input)) {\n for (const table of Object.values(input)) {\n validateSystem(table, { inNamespace: true });\n }\n return;\n }\n throw new Error(`Expected system config, received ${JSON.stringify(input)}`);\n}\n\nexport type resolveSystems<systems extends SystemsInput, namespace extends string> = {\n [label in keyof systems]: resolveSystem<systems[label] & { label: label; namespace: namespace }>;\n};\n\nexport function resolveSystems<systems extends SystemsInput, namespace extends string>(\n systems: systems,\n namespace: namespace,\n): resolveSystems<systems, namespace> {\n return Object.fromEntries(\n Object.entries(systems).map(([label, system]) => {\n return [label, resolveSystem({ ...system, label, namespace })];\n }),\n ) as never;\n}\n","import {\n Scope,\n AbiTypeScope,\n validateTables,\n isObject,\n hasOwnKey,\n resolveTable,\n mergeIfUndefined,\n extendedScope,\n getPath,\n} from \"@latticexyz/store/config/v2\";\nimport { NamespaceInput, NamespacesInput } from \"./input\";\nimport { ErrorMessage, conform } from \"@arktype/util\";\n\nexport type namespacedTableKeys<world> = world extends { namespaces: infer namespaces }\n ? {\n [k in keyof namespaces]: namespaces[k] extends { tables: infer tables }\n ? `${k & string}__${keyof tables & string}`\n : never;\n }[keyof namespaces]\n : never;\n\nexport type validateNamespace<namespace, scope extends Scope = AbiTypeScope> = {\n readonly [key in keyof namespace]: key extends \"tables\"\n ? validateTables<namespace[key], scope>\n : key extends keyof NamespaceInput\n ? conform<namespace[key], NamespaceInput[key]>\n : ErrorMessage<`\\`${key & string}\\` is not a valid namespace config option.`>;\n};\n\nexport function validateNamespace<scope extends Scope = AbiTypeScope>(\n namespace: unknown,\n scope: scope,\n): asserts namespace is NamespaceInput {\n if (hasOwnKey(namespace, \"tables\")) {\n validateTables(namespace.tables, scope);\n }\n}\n\nexport type validateNamespaces<namespaces, scope extends Scope = AbiTypeScope> = {\n [label in keyof namespaces]: validateNamespace<namespaces[label], scope>;\n};\n\nexport function validateNamespaces<scope extends Scope = AbiTypeScope>(\n namespaces: unknown,\n scope: scope,\n): asserts namespaces is NamespacesInput {\n if (!isObject(namespaces)) {\n throw new Error(`Expected namespaces, received ${JSON.stringify(namespaces)}`);\n }\n for (const namespace of Object.values(namespaces)) {\n validateNamespace(namespace, scope);\n }\n}\n\nexport type resolveNamespacedTables<world> = \"namespaces\" extends keyof world\n ? {\n readonly [key in namespacedTableKeys<world>]: key extends `${infer namespace}__${infer table}`\n ? resolveTable<\n mergeIfUndefined<\n getPath<world, [\"namespaces\", namespace, \"tables\", table]>,\n { name: table; namespace: namespace }\n >,\n extendedScope<world>\n >\n : never;\n }\n : {};\n","import { isObject, mergeIfUndefined } from \"@latticexyz/store/config/v2\";\nimport { CODEGEN_DEFAULTS } from \"./defaults\";\n\nexport type resolveCodegen<codegen> = codegen extends {}\n ? mergeIfUndefined<codegen, CODEGEN_DEFAULTS>\n : CODEGEN_DEFAULTS;\n\nexport function resolveCodegen<codegen>(codegen: codegen): resolveCodegen<codegen> {\n return (isObject(codegen) ? mergeIfUndefined(codegen, CODEGEN_DEFAULTS) : CODEGEN_DEFAULTS) as never;\n}\n","import { mergeIfUndefined, isObject } from \"@latticexyz/store/config/v2\";\nimport { DEPLOY_DEFAULTS } from \"./defaults\";\n\nexport type resolveDeploy<deploy> = deploy extends {} ? mergeIfUndefined<deploy, DEPLOY_DEFAULTS> : DEPLOY_DEFAULTS;\n\nexport function resolveDeploy<deploy>(deploy: deploy): resolveDeploy<deploy> {\n return (isObject(deploy) ? mergeIfUndefined(deploy, DEPLOY_DEFAULTS) : DEPLOY_DEFAULTS) as never;\n}\n"],"mappings":"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","names":["extendedScope","get","resolveTable","validateTable","mergeIfUndefined","resolveStore","hasOwnKey","validateStore","isObject","validateSystems","input","isObject","table","validateSystem","resolveSystems","systems","namespace","label","system","resolveSystem","validateTables","isObject","hasOwnKey","validateNamespace","namespace","scope","validateNamespaces","namespaces","isObject","mergeIfUndefined","resolveCodegen","codegen","isObject","mergeIfUndefined","CODEGEN_DEFAULTS","mergeIfUndefined","isObject","resolveDeploy","deploy","isObject","mergeIfUndefined","DEPLOY_DEFAULTS","validateWorld","world","scope","extendedScope","validateStore","hasOwnKey","validateSystems","validateNamespaces","resolveWorld","resolvedStore","resolveStore","namespaces","resolvedNamespacedTables","namespaceKey","namespace","tableKey","table","validateTable","resolveTable","mergeIfUndefined","modules","CONFIG_DEFAULTS","mod","MODULE_DEFAULTS","resolveCodegen","resolveDeploy","resolveSystems","get","defineWorld","input"]}
|
@@ -1,2 +1,2 @@
|
|
1
|
-
import{c as e}from"./chunk-
|
2
|
-
//# sourceMappingURL=chunk-
|
1
|
+
import{c as e}from"./chunk-BH75YTBY.js";var a=e({codegen:{worldImportPath:"../../",worldgenDirectory:"interfaces",worldInterfaceName:"IBaseWorld"},namespace:"world",userTypes:{ResourceId:{filePath:"@latticexyz/store/src/ResourceId.sol",type:"bytes32"}},tables:{NamespaceOwner:{schema:{namespaceId:"ResourceId",owner:"address"},key:["namespaceId"]},ResourceAccess:{schema:{resourceId:"ResourceId",caller:"address",access:"bool"},key:["resourceId","caller"]},InstalledModules:{schema:{moduleAddress:"address",argumentsHash:"bytes32",isInstalled:"bool"},key:["moduleAddress","argumentsHash"]},UserDelegationControl:{schema:{delegator:"address",delegatee:"address",delegationControlId:"ResourceId"},key:["delegator","delegatee"]},NamespaceDelegationControl:{schema:{namespaceId:"ResourceId",delegationControlId:"ResourceId"},key:["namespaceId"]},Balances:{schema:{namespaceId:"ResourceId",balance:"uint256"},key:["namespaceId"]},Systems:{schema:{systemId:"ResourceId",system:"address",publicAccess:"bool"},key:["systemId"],codegen:{dataStruct:!1}},SystemRegistry:{schema:{system:"address",systemId:"ResourceId"},key:["system"]},SystemHooks:{schema:{systemId:"ResourceId",value:"bytes21[]"},key:["systemId"]},FunctionSelectors:{schema:{worldFunctionSelector:"bytes4",systemId:"ResourceId",systemFunctionSelector:"bytes4"},key:["worldFunctionSelector"],codegen:{dataStruct:!1}},FunctionSignatures:{type:"offchainTable",schema:{functionSelector:"bytes4",functionSignature:"string"},key:["functionSelector"]},InitModuleAddress:{schema:{value:"address"},key:[]}},excludeSystems:["StoreRegistrationSystem"]});export{a};
|
2
|
+
//# sourceMappingURL=chunk-OZBNK257.js.map
|
package/dist/config/v2.d.ts
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
export { d as defineWorld, r as resolveWorld, v as validateWorld } from '../world-
|
1
|
+
export { d as defineWorld, r as resolveWorld, v as validateWorld } from '../world-6e8198d8.js';
|
2
2
|
export { C as Codegen, D as Deploy, M as Module, S as System, b as Systems, W as World } from '../dynamicResolution-34391fca.js';
|
3
3
|
import '@arktype/util';
|
4
4
|
import '@latticexyz/store/config/v2';
|
package/dist/config/v2.js
CHANGED
@@ -1,2 +1,2 @@
|
|
1
|
-
import{a as o,b as r,c as e}from"../chunk-
|
1
|
+
import{a as o,b as r,c as e}from"../chunk-BH75YTBY.js";import"../chunk-DK3XOTC2.js";export{e as defineWorld,r as resolveWorld,o as validateWorld};
|
2
2
|
//# sourceMappingURL=v2.js.map
|
package/dist/index.d.ts
CHANGED
@@ -1,5 +1,5 @@
|
|
1
|
-
import { validateTablesWithShorthands, extendedScope,
|
2
|
-
import { v as validateWorld,
|
1
|
+
import { validateTablesWithShorthands, extendedScope, resolveTablesWithShorthands } from '@latticexyz/store/config/v2';
|
2
|
+
import { v as validateWorld, r as resolveWorld, W as WorldWithShorthandsInput } from './world-6e8198d8.js';
|
3
3
|
export { W as World } from './dynamicResolution-34391fca.js';
|
4
4
|
import '@arktype/util';
|
5
5
|
import 'viem';
|
@@ -9,19 +9,10 @@ declare const worldDeployedEvent = "event WorldDeployed(address indexed newContr
|
|
9
9
|
declare const helloWorldEvent = "event HelloWorld(bytes32 indexed worldVersion)";
|
10
10
|
|
11
11
|
type validateWorldWithShorthands<world> = {
|
12
|
-
[key in keyof world]: key extends "tables" ? validateTablesWithShorthands<world[key], extendedScope<world>> :
|
13
|
-
};
|
14
|
-
type validateNamespacesWithShorthands<namespaces, scope extends Scope = AbiTypeScope> = {
|
15
|
-
[namespace in keyof namespaces]: {
|
16
|
-
[key in keyof namespaces[namespace]]: key extends "tables" ? validateTablesWithShorthands<namespaces[namespace][key], scope> : validateNamespace<namespaces[namespace], scope>[key];
|
17
|
-
};
|
12
|
+
[key in keyof world]: key extends "tables" ? validateTablesWithShorthands<world[key], extendedScope<world>> : validateWorld<world>[key];
|
18
13
|
};
|
19
14
|
type resolveWorldWithShorthands<world> = resolveWorld<{
|
20
|
-
[key in keyof world]: key extends "tables" ? resolveTablesWithShorthands<world[key], extendedScope<world>> : key
|
21
|
-
[namespaceKey in keyof world[key]]: {
|
22
|
-
[namespaceProp in keyof world[key][namespaceKey]]: namespaceProp extends "tables" ? resolveTablesWithShorthands<world[key][namespaceKey][namespaceProp], extendedScope<world>> : world[key][namespaceKey][namespaceProp];
|
23
|
-
};
|
24
|
-
} : world[key];
|
15
|
+
readonly [key in keyof world]: key extends "tables" ? resolveTablesWithShorthands<world[key], extendedScope<world>> : world[key];
|
25
16
|
}>;
|
26
17
|
declare function resolveWorldWithShorthands<world extends WorldWithShorthandsInput>(world: world): resolveWorldWithShorthands<world>;
|
27
18
|
declare function defineWorldWithShorthands<world>(world: validateWorldWithShorthands<world>): resolveWorldWithShorthands<world>;
|
package/dist/index.js
CHANGED
@@ -1,2 +1,2 @@
|
|
1
|
-
import{a as
|
1
|
+
import{a as n,b as l}from"./chunk-BH75YTBY.js";import"./chunk-DK3XOTC2.js";var i="event WorldDeployed(address indexed newContract, uint256 salt)",W="event HelloWorld(bytes32 indexed worldVersion)";import{mapObject as p}from"@latticexyz/common/utils";import{extendedScope as h,getPath as c,hasOwnKey as s,isObject as v,isTableShorthandInput as f,resolveTableShorthand as y,validateTablesWithShorthands as a}from"@latticexyz/store/config/v2";function S(e){let o=h(e);if(s(e,"tables")&&a(e.tables,o),s(e,"namespaces")&&v(e.namespaces))for(let t of Object.keys(e.namespaces))a(c(e.namespaces,[t,"tables"])??{},o)}function m(e){let o=h(e),t=p(e.tables??{},r=>f(r)?y(r,o):r),d={...e,tables:t};return n(d),l(d)}function x(e){return S(e),m(e)}export{x as defineWorld,W as helloWorldEvent,i as worldDeployedEvent};
|
2
2
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../ts/worldEvents.ts","../ts/config/v2/worldWithShorthands.ts"],"sourcesContent":["// from WorldFactory\nexport const worldDeployedEvent = \"event WorldDeployed(address indexed newContract, uint256 salt)\";\n\n// from World\nexport const helloWorldEvent = \"event HelloWorld(bytes32 indexed worldVersion)\";\n","import { mapObject } from \"@latticexyz/common/utils\";\nimport {\n
|
1
|
+
{"version":3,"sources":["../ts/worldEvents.ts","../ts/config/v2/worldWithShorthands.ts"],"sourcesContent":["// from WorldFactory\nexport const worldDeployedEvent = \"event WorldDeployed(address indexed newContract, uint256 salt)\";\n\n// from World\nexport const helloWorldEvent = \"event HelloWorld(bytes32 indexed worldVersion)\";\n","import { mapObject } from \"@latticexyz/common/utils\";\nimport {\n extendedScope,\n getPath,\n hasOwnKey,\n isObject,\n isTableShorthandInput,\n resolveTableShorthand,\n resolveTablesWithShorthands,\n validateTablesWithShorthands,\n} from \"@latticexyz/store/config/v2\";\nimport { WorldWithShorthandsInput } from \"./input\";\nimport { resolveWorld, validateWorld } from \"./world\";\n\nexport type validateWorldWithShorthands<world> = {\n [key in keyof world]: key extends \"tables\"\n ? validateTablesWithShorthands<world[key], extendedScope<world>>\n : validateWorld<world>[key];\n};\n\nfunction validateWorldWithShorthands(world: unknown): asserts world is WorldWithShorthandsInput {\n const scope = extendedScope(world);\n if (hasOwnKey(world, \"tables\")) {\n validateTablesWithShorthands(world.tables, scope);\n }\n\n if (hasOwnKey(world, \"namespaces\") && isObject(world.namespaces)) {\n for (const namespaceKey of Object.keys(world.namespaces)) {\n validateTablesWithShorthands(getPath(world.namespaces, [namespaceKey, \"tables\"]) ?? {}, scope);\n }\n }\n}\n\nexport type resolveWorldWithShorthands<world> = resolveWorld<{\n readonly [key in keyof world]: key extends \"tables\"\n ? resolveTablesWithShorthands<world[key], extendedScope<world>>\n : world[key];\n}>;\n\nexport function resolveWorldWithShorthands<world extends WorldWithShorthandsInput>(\n world: world,\n): resolveWorldWithShorthands<world> {\n const scope = extendedScope(world);\n const tables = mapObject(world.tables ?? {}, (table) => {\n return isTableShorthandInput(table) ? resolveTableShorthand(table, scope) : table;\n });\n\n const fullConfig = { ...world, tables };\n validateWorld(fullConfig);\n\n return resolveWorld(fullConfig) as never;\n}\n\nexport function defineWorldWithShorthands<world>(\n world: validateWorldWithShorthands<world>,\n): resolveWorldWithShorthands<world> {\n validateWorldWithShorthands(world);\n return resolveWorldWithShorthands(world) as never;\n}\n"],"mappings":"2EACO,IAAMA,EAAqB,iEAGrBC,EAAkB,iDCJ/B,OAAS,aAAAC,MAAiB,2BAC1B,OACE,iBAAAC,EACA,WAAAC,EACA,aAAAC,EACA,YAAAC,EACA,yBAAAC,EACA,yBAAAC,EAEA,gCAAAC,MACK,8BAUP,SAASC,EAA4BC,EAA2D,CAC9F,IAAMC,EAAQC,EAAcF,CAAK,EAKjC,GAJIG,EAAUH,EAAO,QAAQ,GAC3BI,EAA6BJ,EAAM,OAAQC,CAAK,EAG9CE,EAAUH,EAAO,YAAY,GAAKK,EAASL,EAAM,UAAU,EAC7D,QAAWM,KAAgB,OAAO,KAAKN,EAAM,UAAU,EACrDI,EAA6BG,EAAQP,EAAM,WAAY,CAACM,EAAc,QAAQ,CAAC,GAAK,CAAC,EAAGL,CAAK,CAGnG,CAQO,SAASO,EACdR,EACmC,CACnC,IAAMC,EAAQC,EAAcF,CAAK,EAC3BS,EAASC,EAAUV,EAAM,QAAU,CAAC,EAAIW,GACrCC,EAAsBD,CAAK,EAAIE,EAAsBF,EAAOV,CAAK,EAAIU,CAC7E,EAEKG,EAAa,CAAE,GAAGd,EAAO,OAAAS,CAAO,EACtC,OAAAM,EAAcD,CAAU,EAEjBE,EAAaF,CAAU,CAChC,CAEO,SAASG,EACdjB,EACmC,CACnC,OAAAD,EAA4BC,CAAK,EAC1BQ,EAA2BR,CAAK,CACzC","names":["worldDeployedEvent","helloWorldEvent","mapObject","extendedScope","getPath","hasOwnKey","isObject","isTableShorthandInput","resolveTableShorthand","validateTablesWithShorthands","validateWorldWithShorthands","world","scope","extendedScope","hasOwnKey","validateTablesWithShorthands","isObject","namespaceKey","getPath","resolveWorldWithShorthands","tables","mapObject","table","isTableShorthandInput","resolveTableShorthand","fullConfig","validateWorld","resolveWorld","defineWorldWithShorthands"]}
|
package/dist/internal.js
CHANGED
@@ -1,3 +1,3 @@
|
|
1
|
-
import{a as m}from"./chunk-
|
1
|
+
import{a as m}from"./chunk-OZBNK257.js";import"./chunk-BH75YTBY.js";import"./chunk-DK3XOTC2.js";import{encodeFunctionData as C}from"viem";function c({abi:e,systemId:a,functionName:t,args:n}){return[a,C({abi:e,functionName:t,args:n})]}import{encodeFunctionData as x}from"viem";function u({abi:e,from:a,systemId:t,functionName:n,args:i}){return[a,t,x({abi:e,functionName:n,args:i})]}function z(e,a){return a.map(t=>c({...t,abi:e}))}function Y(e,a,t){return t.map(n=>u({...n,abi:e,from:a}))}import{slice as S,concat as F}from"viem";import{getAction as d,encodeFunctionData as A}from"viem/utils";import{writeContract as b}from"viem/actions";import{readHex as g}from"@latticexyz/common";import{getKeySchema as h,getValueSchema as P,getSchemaTypes as f,decodeValueArgs as w,encodeKey as N}from"@latticexyz/protocol-parser/internal";var p=[{type:"function",name:"getDynamicField",inputs:[{name:"tableId",type:"bytes32",internalType:"ResourceId"},{name:"keyTuple",type:"bytes32[]",internalType:"bytes32[]"},{name:"dynamicFieldIndex",type:"uint8",internalType:"uint8"}],outputs:[{name:"",type:"bytes",internalType:"bytes"}],stateMutability:"view"},{type:"function",name:"getDynamicFieldLength",inputs:[{name:"tableId",type:"bytes32",internalType:"ResourceId"},{name:"keyTuple",type:"bytes32[]",internalType:"bytes32[]"},{name:"dynamicFieldIndex",type:"uint8",internalType:"uint8"}],outputs:[{name:"",type:"uint256",internalType:"uint256"}],stateMutability:"view"},{type:"function",name:"getDynamicFieldSlice",inputs:[{name:"tableId",type:"bytes32",internalType:"ResourceId"},{name:"keyTuple",type:"bytes32[]",internalType:"bytes32[]"},{name:"dynamicFieldIndex",type:"uint8",internalType:"uint8"},{name:"start",type:"uint256",internalType:"uint256"},{name:"end",type:"uint256",internalType:"uint256"}],outputs:[{name:"data",type:"bytes",internalType:"bytes"}],stateMutability:"view"},{type:"function",name:"getField",inputs:[{name:"tableId",type:"bytes32",internalType:"ResourceId"},{name:"keyTuple",type:"bytes32[]",internalType:"bytes32[]"},{name:"fieldIndex",type:"uint8",internalType:"uint8"},{name:"fieldLayout",type:"bytes32",internalType:"FieldLayout"}],outputs:[{name:"data",type:"bytes",internalType:"bytes"}],stateMutability:"view"},{type:"function",name:"getField",inputs:[{name:"tableId",type:"bytes32",internalType:"ResourceId"},{name:"keyTuple",type:"bytes32[]",internalType:"bytes32[]"},{name:"fieldIndex",type:"uint8",internalType:"uint8"}],outputs:[{name:"data",type:"bytes",internalType:"bytes"}],stateMutability:"view"},{type:"function",name:"getFieldLayout",inputs:[{name:"tableId",type:"bytes32",internalType:"ResourceId"}],outputs:[{name:"fieldLayout",type:"bytes32",internalType:"FieldLayout"}],stateMutability:"view"},{type:"function",name:"getFieldLength",inputs:[{name:"tableId",type:"bytes32",internalType:"ResourceId"},{name:"keyTuple",type:"bytes32[]",internalType:"bytes32[]"},{name:"fieldIndex",type:"uint8",internalType:"uint8"},{name:"fieldLayout",type:"bytes32",internalType:"FieldLayout"}],outputs:[{name:"",type:"uint256",internalType:"uint256"}],stateMutability:"view"},{type:"function",name:"getFieldLength",inputs:[{name:"tableId",type:"bytes32",internalType:"ResourceId"},{name:"keyTuple",type:"bytes32[]",internalType:"bytes32[]"},{name:"fieldIndex",type:"uint8",internalType:"uint8"}],outputs:[{name:"",type:"uint256",internalType:"uint256"}],stateMutability:"view"},{type:"function",name:"getKeySchema",inputs:[{name:"tableId",type:"bytes32",internalType:"ResourceId"}],outputs:[{name:"keySchema",type:"bytes32",internalType:"Schema"}],stateMutability:"view"},{type:"function",name:"getRecord",inputs:[{name:"tableId",type:"bytes32",internalType:"ResourceId"},{name:"keyTuple",type:"bytes32[]",internalType:"bytes32[]"},{name:"fieldLayout",type:"bytes32",internalType:"FieldLayout"}],outputs:[{name:"staticData",type:"bytes",internalType:"bytes"},{name:"encodedLengths",type:"bytes32",internalType:"EncodedLengths"},{name:"dynamicData",type:"bytes",internalType:"bytes"}],stateMutability:"view"},{type:"function",name:"getRecord",inputs:[{name:"tableId",type:"bytes32",internalType:"ResourceId"},{name:"keyTuple",type:"bytes32[]",internalType:"bytes32[]"}],outputs:[{name:"staticData",type:"bytes",internalType:"bytes"},{name:"encodedLengths",type:"bytes32",internalType:"EncodedLengths"},{name:"dynamicData",type:"bytes",internalType:"bytes"}],stateMutability:"view"},{type:"function",name:"getStaticField",inputs:[{name:"tableId",type:"bytes32",internalType:"ResourceId"},{name:"keyTuple",type:"bytes32[]",internalType:"bytes32[]"},{name:"fieldIndex",type:"uint8",internalType:"uint8"},{name:"fieldLayout",type:"bytes32",internalType:"FieldLayout"}],outputs:[{name:"",type:"bytes32",internalType:"bytes32"}],stateMutability:"view"},{type:"function",name:"getValueSchema",inputs:[{name:"tableId",type:"bytes32",internalType:"ResourceId"}],outputs:[{name:"valueSchema",type:"bytes32",internalType:"Schema"}],stateMutability:"view"}];function le(e){return a=>({writeContract:async t=>{if(t.address!==e.worldAddress||t.functionName==="call"||t.functionName==="callFrom"||t.functionName==="callWithSignature")return d(a,b,"writeContract")(t);let n=A({abi:t.abi,functionName:t.functionName,args:t.args}),i=S(n,0,4),{systemId:o,systemFunctionSelector:r}=await v(e,i),y=F([r,g(n,4)]),s={...t,functionName:"callFrom",args:[e.delegatorAddress,o,y]};return d(a,b,"writeContract")(s)}})}var T=new Map;async function v(e,a){let t=F([e.worldAddress,a]),n=T.get(t);if(n)return n;let i=e.worldFunctionToSystemFunction?await e.worldFunctionToSystemFunction(a):await D(e.publicClient,e.worldAddress,a);return T.set(t,i),i}async function D(e,a,t){let n=m.tables.world__FunctionSelectors,i=f(h(n)),o=f(P(n)),[r,y,s]=await e.readContract({address:a,abi:p,functionName:"getRecord",args:[n.tableId,N(i,{worldFunctionSelector:t})]}),l=w(o,{staticData:r,encodedLengths:y,dynamicData:s});return{systemId:l.systemId,systemFunctionSelector:l.systemFunctionSelector}}var ce={Call:[{name:"signer",type:"address"},{name:"systemNamespace",type:"string"},{name:"systemName",type:"string"},{name:"callData",type:"bytes"},{name:"nonce",type:"uint256"}]};function R(e){return{type:"tableId",input:e}}function W(e){return typeof e=="object"&&e!==null&&"type"in e&&"input"in e}function E(e){return typeof e=="object"&&e!==null&&"type"in e&&"value"in e}function k(e,a){if(E(e))return e;if(W(e)&&e.type==="tableId"){let t=Object.entries(a.config.tables).filter(([n,i])=>n===e.input||i.name===e.input);if(t.length>1)throw new Error(`Found more than one table with name "${e.input}". Try using one of the following table names instead: ${t.map(([n])=>n).join(", ")}`);if(t.length===1){let[n]=t,[,i]=n;return{type:"bytes32",value:i.tableId}}}throw new Error(`Could not resolve dynamic resolution:
|
2
2
|
${JSON.stringify(e,null,2)}`)}export{le as callFrom,ce as callWithSignatureTypes,c as encodeSystemCall,u as encodeSystemCallFrom,z as encodeSystemCalls,Y as encodeSystemCallsFrom,R as resolveTableId,k as resolveWithContext};
|
3
3
|
//# sourceMappingURL=internal.js.map
|
package/dist/mud.config.d.ts
CHANGED
@@ -1,12 +1,11 @@
|
|
1
1
|
import * as _latticexyz_store_config_v2 from '@latticexyz/store/config/v2';
|
2
2
|
|
3
3
|
declare const _default: {
|
4
|
-
readonly sourceDirectory: "src";
|
5
4
|
readonly tables: _latticexyz_store_config_v2.resolveNamespacedTables<{
|
6
5
|
readonly NamespaceOwner: {
|
7
6
|
readonly label: "NamespaceOwner";
|
8
7
|
readonly type: "table";
|
9
|
-
readonly namespace:
|
8
|
+
readonly namespace: string;
|
10
9
|
readonly name: string;
|
11
10
|
readonly tableId: `0x${string}`;
|
12
11
|
readonly schema: {
|
@@ -33,7 +32,7 @@ declare const _default: {
|
|
33
32
|
readonly ResourceAccess: {
|
34
33
|
readonly label: "ResourceAccess";
|
35
34
|
readonly type: "table";
|
36
|
-
readonly namespace:
|
35
|
+
readonly namespace: string;
|
37
36
|
readonly name: string;
|
38
37
|
readonly tableId: `0x${string}`;
|
39
38
|
readonly schema: {
|
@@ -64,7 +63,7 @@ declare const _default: {
|
|
64
63
|
readonly InstalledModules: {
|
65
64
|
readonly label: "InstalledModules";
|
66
65
|
readonly type: "table";
|
67
|
-
readonly namespace:
|
66
|
+
readonly namespace: string;
|
68
67
|
readonly name: string;
|
69
68
|
readonly tableId: `0x${string}`;
|
70
69
|
readonly schema: {
|
@@ -95,7 +94,7 @@ declare const _default: {
|
|
95
94
|
readonly UserDelegationControl: {
|
96
95
|
readonly label: "UserDelegationControl";
|
97
96
|
readonly type: "table";
|
98
|
-
readonly namespace:
|
97
|
+
readonly namespace: string;
|
99
98
|
readonly name: string;
|
100
99
|
readonly tableId: `0x${string}`;
|
101
100
|
readonly schema: {
|
@@ -126,7 +125,7 @@ declare const _default: {
|
|
126
125
|
readonly NamespaceDelegationControl: {
|
127
126
|
readonly label: "NamespaceDelegationControl";
|
128
127
|
readonly type: "table";
|
129
|
-
readonly namespace:
|
128
|
+
readonly namespace: string;
|
130
129
|
readonly name: string;
|
131
130
|
readonly tableId: `0x${string}`;
|
132
131
|
readonly schema: {
|
@@ -153,7 +152,7 @@ declare const _default: {
|
|
153
152
|
readonly Balances: {
|
154
153
|
readonly label: "Balances";
|
155
154
|
readonly type: "table";
|
156
|
-
readonly namespace:
|
155
|
+
readonly namespace: string;
|
157
156
|
readonly name: string;
|
158
157
|
readonly tableId: `0x${string}`;
|
159
158
|
readonly schema: {
|
@@ -180,7 +179,7 @@ declare const _default: {
|
|
180
179
|
readonly Systems: {
|
181
180
|
readonly label: "Systems";
|
182
181
|
readonly type: "table";
|
183
|
-
readonly namespace:
|
182
|
+
readonly namespace: string;
|
184
183
|
readonly name: string;
|
185
184
|
readonly tableId: `0x${string}`;
|
186
185
|
readonly schema: {
|
@@ -211,7 +210,7 @@ declare const _default: {
|
|
211
210
|
readonly SystemRegistry: {
|
212
211
|
readonly label: "SystemRegistry";
|
213
212
|
readonly type: "table";
|
214
|
-
readonly namespace:
|
213
|
+
readonly namespace: string;
|
215
214
|
readonly name: string;
|
216
215
|
readonly tableId: `0x${string}`;
|
217
216
|
readonly schema: {
|
@@ -238,7 +237,7 @@ declare const _default: {
|
|
238
237
|
readonly SystemHooks: {
|
239
238
|
readonly label: "SystemHooks";
|
240
239
|
readonly type: "table";
|
241
|
-
readonly namespace:
|
240
|
+
readonly namespace: string;
|
242
241
|
readonly name: string;
|
243
242
|
readonly tableId: `0x${string}`;
|
244
243
|
readonly schema: {
|
@@ -265,7 +264,7 @@ declare const _default: {
|
|
265
264
|
readonly FunctionSelectors: {
|
266
265
|
readonly label: "FunctionSelectors";
|
267
266
|
readonly type: "table";
|
268
|
-
readonly namespace:
|
267
|
+
readonly namespace: string;
|
269
268
|
readonly name: string;
|
270
269
|
readonly tableId: `0x${string}`;
|
271
270
|
readonly schema: {
|
@@ -296,7 +295,7 @@ declare const _default: {
|
|
296
295
|
readonly FunctionSignatures: {
|
297
296
|
readonly label: "FunctionSignatures";
|
298
297
|
readonly type: "offchainTable";
|
299
|
-
readonly namespace:
|
298
|
+
readonly namespace: string;
|
300
299
|
readonly name: string;
|
301
300
|
readonly tableId: `0x${string}`;
|
302
301
|
readonly schema: {
|
@@ -323,7 +322,7 @@ declare const _default: {
|
|
323
322
|
readonly InitModuleAddress: {
|
324
323
|
readonly label: "InitModuleAddress";
|
325
324
|
readonly type: "table";
|
326
|
-
readonly namespace:
|
325
|
+
readonly namespace: string;
|
327
326
|
readonly name: string;
|
328
327
|
readonly tableId: `0x${string}`;
|
329
328
|
readonly schema: {
|
@@ -344,6 +343,8 @@ declare const _default: {
|
|
344
343
|
}>;
|
345
344
|
};
|
346
345
|
}, "world">;
|
346
|
+
readonly namespace: string;
|
347
|
+
readonly sourceDirectory: "src";
|
347
348
|
readonly userTypes: {
|
348
349
|
readonly ResourceId: {
|
349
350
|
readonly filePath: "@latticexyz/store/src/ResourceId.sol";
|
@@ -352,8 +353,355 @@ declare const _default: {
|
|
352
353
|
};
|
353
354
|
readonly enums: {};
|
354
355
|
readonly enumValues: {};
|
355
|
-
readonly namespace: "world";
|
356
356
|
readonly codegen: never;
|
357
|
+
readonly namespaces: {
|
358
|
+
readonly world: {
|
359
|
+
readonly label: "world";
|
360
|
+
readonly namespace: string;
|
361
|
+
readonly tables: {
|
362
|
+
readonly NamespaceOwner: {
|
363
|
+
readonly label: "NamespaceOwner";
|
364
|
+
readonly type: "table";
|
365
|
+
readonly namespace: string;
|
366
|
+
readonly name: string;
|
367
|
+
readonly tableId: `0x${string}`;
|
368
|
+
readonly schema: {
|
369
|
+
readonly namespaceId: {
|
370
|
+
readonly type: "bytes32";
|
371
|
+
readonly internalType: "ResourceId";
|
372
|
+
};
|
373
|
+
readonly owner: {
|
374
|
+
readonly type: "address";
|
375
|
+
readonly internalType: "address";
|
376
|
+
};
|
377
|
+
};
|
378
|
+
readonly key: readonly ["namespaceId"];
|
379
|
+
readonly codegen: {
|
380
|
+
readonly outputDirectory: string;
|
381
|
+
readonly tableIdArgument: false;
|
382
|
+
readonly storeArgument: false;
|
383
|
+
readonly dataStruct: boolean;
|
384
|
+
};
|
385
|
+
readonly deploy: _latticexyz_store_config_v2.mergeIfUndefined<{}, {
|
386
|
+
readonly disabled: false;
|
387
|
+
}>;
|
388
|
+
};
|
389
|
+
readonly ResourceAccess: {
|
390
|
+
readonly label: "ResourceAccess";
|
391
|
+
readonly type: "table";
|
392
|
+
readonly namespace: string;
|
393
|
+
readonly name: string;
|
394
|
+
readonly tableId: `0x${string}`;
|
395
|
+
readonly schema: {
|
396
|
+
readonly resourceId: {
|
397
|
+
readonly type: "bytes32";
|
398
|
+
readonly internalType: "ResourceId";
|
399
|
+
};
|
400
|
+
readonly caller: {
|
401
|
+
readonly type: "address";
|
402
|
+
readonly internalType: "address";
|
403
|
+
};
|
404
|
+
readonly access: {
|
405
|
+
readonly type: "bool";
|
406
|
+
readonly internalType: "bool";
|
407
|
+
};
|
408
|
+
};
|
409
|
+
readonly key: readonly ["resourceId", "caller"];
|
410
|
+
readonly codegen: {
|
411
|
+
readonly outputDirectory: string;
|
412
|
+
readonly tableIdArgument: false;
|
413
|
+
readonly storeArgument: false;
|
414
|
+
readonly dataStruct: boolean;
|
415
|
+
};
|
416
|
+
readonly deploy: _latticexyz_store_config_v2.mergeIfUndefined<{}, {
|
417
|
+
readonly disabled: false;
|
418
|
+
}>;
|
419
|
+
};
|
420
|
+
readonly InstalledModules: {
|
421
|
+
readonly label: "InstalledModules";
|
422
|
+
readonly type: "table";
|
423
|
+
readonly namespace: string;
|
424
|
+
readonly name: string;
|
425
|
+
readonly tableId: `0x${string}`;
|
426
|
+
readonly schema: {
|
427
|
+
readonly moduleAddress: {
|
428
|
+
readonly type: "address";
|
429
|
+
readonly internalType: "address";
|
430
|
+
};
|
431
|
+
readonly argumentsHash: {
|
432
|
+
readonly type: "bytes32";
|
433
|
+
readonly internalType: "bytes32";
|
434
|
+
};
|
435
|
+
readonly isInstalled: {
|
436
|
+
readonly type: "bool";
|
437
|
+
readonly internalType: "bool";
|
438
|
+
};
|
439
|
+
};
|
440
|
+
readonly key: readonly ["moduleAddress", "argumentsHash"];
|
441
|
+
readonly codegen: {
|
442
|
+
readonly outputDirectory: string;
|
443
|
+
readonly tableIdArgument: false;
|
444
|
+
readonly storeArgument: false;
|
445
|
+
readonly dataStruct: boolean;
|
446
|
+
};
|
447
|
+
readonly deploy: _latticexyz_store_config_v2.mergeIfUndefined<{}, {
|
448
|
+
readonly disabled: false;
|
449
|
+
}>;
|
450
|
+
};
|
451
|
+
readonly UserDelegationControl: {
|
452
|
+
readonly label: "UserDelegationControl";
|
453
|
+
readonly type: "table";
|
454
|
+
readonly namespace: string;
|
455
|
+
readonly name: string;
|
456
|
+
readonly tableId: `0x${string}`;
|
457
|
+
readonly schema: {
|
458
|
+
readonly delegator: {
|
459
|
+
readonly type: "address";
|
460
|
+
readonly internalType: "address";
|
461
|
+
};
|
462
|
+
readonly delegatee: {
|
463
|
+
readonly type: "address";
|
464
|
+
readonly internalType: "address";
|
465
|
+
};
|
466
|
+
readonly delegationControlId: {
|
467
|
+
readonly type: "bytes32";
|
468
|
+
readonly internalType: "ResourceId";
|
469
|
+
};
|
470
|
+
};
|
471
|
+
readonly key: readonly ["delegator", "delegatee"];
|
472
|
+
readonly codegen: {
|
473
|
+
readonly outputDirectory: string;
|
474
|
+
readonly tableIdArgument: false;
|
475
|
+
readonly storeArgument: false;
|
476
|
+
readonly dataStruct: boolean;
|
477
|
+
};
|
478
|
+
readonly deploy: _latticexyz_store_config_v2.mergeIfUndefined<{}, {
|
479
|
+
readonly disabled: false;
|
480
|
+
}>;
|
481
|
+
};
|
482
|
+
readonly NamespaceDelegationControl: {
|
483
|
+
readonly label: "NamespaceDelegationControl";
|
484
|
+
readonly type: "table";
|
485
|
+
readonly namespace: string;
|
486
|
+
readonly name: string;
|
487
|
+
readonly tableId: `0x${string}`;
|
488
|
+
readonly schema: {
|
489
|
+
readonly namespaceId: {
|
490
|
+
readonly type: "bytes32";
|
491
|
+
readonly internalType: "ResourceId";
|
492
|
+
};
|
493
|
+
readonly delegationControlId: {
|
494
|
+
readonly type: "bytes32";
|
495
|
+
readonly internalType: "ResourceId";
|
496
|
+
};
|
497
|
+
};
|
498
|
+
readonly key: readonly ["namespaceId"];
|
499
|
+
readonly codegen: {
|
500
|
+
readonly outputDirectory: string;
|
501
|
+
readonly tableIdArgument: false;
|
502
|
+
readonly storeArgument: false;
|
503
|
+
readonly dataStruct: boolean;
|
504
|
+
};
|
505
|
+
readonly deploy: _latticexyz_store_config_v2.mergeIfUndefined<{}, {
|
506
|
+
readonly disabled: false;
|
507
|
+
}>;
|
508
|
+
};
|
509
|
+
readonly Balances: {
|
510
|
+
readonly label: "Balances";
|
511
|
+
readonly type: "table";
|
512
|
+
readonly namespace: string;
|
513
|
+
readonly name: string;
|
514
|
+
readonly tableId: `0x${string}`;
|
515
|
+
readonly schema: {
|
516
|
+
readonly namespaceId: {
|
517
|
+
readonly type: "bytes32";
|
518
|
+
readonly internalType: "ResourceId";
|
519
|
+
};
|
520
|
+
readonly balance: {
|
521
|
+
readonly type: "uint256";
|
522
|
+
readonly internalType: "uint256";
|
523
|
+
};
|
524
|
+
};
|
525
|
+
readonly key: readonly ["namespaceId"];
|
526
|
+
readonly codegen: {
|
527
|
+
readonly outputDirectory: string;
|
528
|
+
readonly tableIdArgument: false;
|
529
|
+
readonly storeArgument: false;
|
530
|
+
readonly dataStruct: boolean;
|
531
|
+
};
|
532
|
+
readonly deploy: _latticexyz_store_config_v2.mergeIfUndefined<{}, {
|
533
|
+
readonly disabled: false;
|
534
|
+
}>;
|
535
|
+
};
|
536
|
+
readonly Systems: {
|
537
|
+
readonly label: "Systems";
|
538
|
+
readonly type: "table";
|
539
|
+
readonly namespace: string;
|
540
|
+
readonly name: string;
|
541
|
+
readonly tableId: `0x${string}`;
|
542
|
+
readonly schema: {
|
543
|
+
readonly systemId: {
|
544
|
+
readonly type: "bytes32";
|
545
|
+
readonly internalType: "ResourceId";
|
546
|
+
};
|
547
|
+
readonly system: {
|
548
|
+
readonly type: "address";
|
549
|
+
readonly internalType: "address";
|
550
|
+
};
|
551
|
+
readonly publicAccess: {
|
552
|
+
readonly type: "bool";
|
553
|
+
readonly internalType: "bool";
|
554
|
+
};
|
555
|
+
};
|
556
|
+
readonly key: readonly ["systemId"];
|
557
|
+
readonly codegen: {
|
558
|
+
readonly outputDirectory: string;
|
559
|
+
readonly tableIdArgument: false;
|
560
|
+
readonly storeArgument: false;
|
561
|
+
readonly dataStruct: false;
|
562
|
+
};
|
563
|
+
readonly deploy: _latticexyz_store_config_v2.mergeIfUndefined<{}, {
|
564
|
+
readonly disabled: false;
|
565
|
+
}>;
|
566
|
+
};
|
567
|
+
readonly SystemRegistry: {
|
568
|
+
readonly label: "SystemRegistry";
|
569
|
+
readonly type: "table";
|
570
|
+
readonly namespace: string;
|
571
|
+
readonly name: string;
|
572
|
+
readonly tableId: `0x${string}`;
|
573
|
+
readonly schema: {
|
574
|
+
readonly system: {
|
575
|
+
readonly type: "address";
|
576
|
+
readonly internalType: "address";
|
577
|
+
};
|
578
|
+
readonly systemId: {
|
579
|
+
readonly type: "bytes32";
|
580
|
+
readonly internalType: "ResourceId";
|
581
|
+
};
|
582
|
+
};
|
583
|
+
readonly key: readonly ["system"];
|
584
|
+
readonly codegen: {
|
585
|
+
readonly outputDirectory: string;
|
586
|
+
readonly tableIdArgument: false;
|
587
|
+
readonly storeArgument: false;
|
588
|
+
readonly dataStruct: boolean;
|
589
|
+
};
|
590
|
+
readonly deploy: _latticexyz_store_config_v2.mergeIfUndefined<{}, {
|
591
|
+
readonly disabled: false;
|
592
|
+
}>;
|
593
|
+
};
|
594
|
+
readonly SystemHooks: {
|
595
|
+
readonly label: "SystemHooks";
|
596
|
+
readonly type: "table";
|
597
|
+
readonly namespace: string;
|
598
|
+
readonly name: string;
|
599
|
+
readonly tableId: `0x${string}`;
|
600
|
+
readonly schema: {
|
601
|
+
readonly systemId: {
|
602
|
+
readonly type: "bytes32";
|
603
|
+
readonly internalType: "ResourceId";
|
604
|
+
};
|
605
|
+
readonly value: {
|
606
|
+
readonly type: "bytes21[]";
|
607
|
+
readonly internalType: "bytes21[]";
|
608
|
+
};
|
609
|
+
};
|
610
|
+
readonly key: readonly ["systemId"];
|
611
|
+
readonly codegen: {
|
612
|
+
readonly outputDirectory: string;
|
613
|
+
readonly tableIdArgument: false;
|
614
|
+
readonly storeArgument: false;
|
615
|
+
readonly dataStruct: boolean;
|
616
|
+
};
|
617
|
+
readonly deploy: _latticexyz_store_config_v2.mergeIfUndefined<{}, {
|
618
|
+
readonly disabled: false;
|
619
|
+
}>;
|
620
|
+
};
|
621
|
+
readonly FunctionSelectors: {
|
622
|
+
readonly label: "FunctionSelectors";
|
623
|
+
readonly type: "table";
|
624
|
+
readonly namespace: string;
|
625
|
+
readonly name: string;
|
626
|
+
readonly tableId: `0x${string}`;
|
627
|
+
readonly schema: {
|
628
|
+
readonly worldFunctionSelector: {
|
629
|
+
readonly type: "bytes4";
|
630
|
+
readonly internalType: "bytes4";
|
631
|
+
};
|
632
|
+
readonly systemId: {
|
633
|
+
readonly type: "bytes32";
|
634
|
+
readonly internalType: "ResourceId";
|
635
|
+
};
|
636
|
+
readonly systemFunctionSelector: {
|
637
|
+
readonly type: "bytes4";
|
638
|
+
readonly internalType: "bytes4";
|
639
|
+
};
|
640
|
+
};
|
641
|
+
readonly key: readonly ["worldFunctionSelector"];
|
642
|
+
readonly codegen: {
|
643
|
+
readonly outputDirectory: string;
|
644
|
+
readonly tableIdArgument: false;
|
645
|
+
readonly storeArgument: false;
|
646
|
+
readonly dataStruct: false;
|
647
|
+
};
|
648
|
+
readonly deploy: _latticexyz_store_config_v2.mergeIfUndefined<{}, {
|
649
|
+
readonly disabled: false;
|
650
|
+
}>;
|
651
|
+
};
|
652
|
+
readonly FunctionSignatures: {
|
653
|
+
readonly label: "FunctionSignatures";
|
654
|
+
readonly type: "offchainTable";
|
655
|
+
readonly namespace: string;
|
656
|
+
readonly name: string;
|
657
|
+
readonly tableId: `0x${string}`;
|
658
|
+
readonly schema: {
|
659
|
+
readonly functionSelector: {
|
660
|
+
readonly type: "bytes4";
|
661
|
+
readonly internalType: "bytes4";
|
662
|
+
};
|
663
|
+
readonly functionSignature: {
|
664
|
+
readonly type: "string";
|
665
|
+
readonly internalType: "string";
|
666
|
+
};
|
667
|
+
};
|
668
|
+
readonly key: readonly ["functionSelector"];
|
669
|
+
readonly codegen: {
|
670
|
+
readonly outputDirectory: string;
|
671
|
+
readonly tableIdArgument: false;
|
672
|
+
readonly storeArgument: false;
|
673
|
+
readonly dataStruct: boolean;
|
674
|
+
};
|
675
|
+
readonly deploy: _latticexyz_store_config_v2.mergeIfUndefined<{}, {
|
676
|
+
readonly disabled: false;
|
677
|
+
}>;
|
678
|
+
};
|
679
|
+
readonly InitModuleAddress: {
|
680
|
+
readonly label: "InitModuleAddress";
|
681
|
+
readonly type: "table";
|
682
|
+
readonly namespace: string;
|
683
|
+
readonly name: string;
|
684
|
+
readonly tableId: `0x${string}`;
|
685
|
+
readonly schema: {
|
686
|
+
readonly value: {
|
687
|
+
readonly type: "address";
|
688
|
+
readonly internalType: "address";
|
689
|
+
};
|
690
|
+
};
|
691
|
+
readonly key: readonly [];
|
692
|
+
readonly codegen: {
|
693
|
+
readonly outputDirectory: string;
|
694
|
+
readonly tableIdArgument: false;
|
695
|
+
readonly storeArgument: false;
|
696
|
+
readonly dataStruct: boolean;
|
697
|
+
};
|
698
|
+
readonly deploy: _latticexyz_store_config_v2.mergeIfUndefined<{}, {
|
699
|
+
readonly disabled: false;
|
700
|
+
}>;
|
701
|
+
};
|
702
|
+
};
|
703
|
+
};
|
704
|
+
};
|
357
705
|
readonly systems: {};
|
358
706
|
readonly excludeSystems: readonly ["StoreRegistrationSystem"];
|
359
707
|
readonly modules: readonly [];
|
package/dist/mud.config.js
CHANGED
@@ -1,2 +1,2 @@
|
|
1
|
-
import{a}from"./chunk-
|
1
|
+
import{a}from"./chunk-OZBNK257.js";import"./chunk-BH75YTBY.js";import"./chunk-DK3XOTC2.js";export{a as default};
|
2
2
|
//# sourceMappingURL=mud.config.js.map
|
@@ -1,5 +1,5 @@
|
|
1
|
-
import { show,
|
2
|
-
import { StoreInput, StoreWithShorthandsInput, resolveTable, mergeIfUndefined, getPath, extendedScope,
|
1
|
+
import { show, ErrorMessage, narrow, requiredKeyOf, conform, withJsDoc } from '@arktype/util';
|
2
|
+
import { StoreInput, StoreWithShorthandsInput, resolveTable, mergeIfUndefined, getPath, extendedScope, validateTables, UserTypes, resolveStore, Store } from '@latticexyz/store/config/v2';
|
3
3
|
import { V as ValueWithType, c as DynamicResolution, W as World } from './dynamicResolution-34391fca.js';
|
4
4
|
import { Hex } from 'viem';
|
5
5
|
|
@@ -111,24 +111,6 @@ type NamespaceInput = Pick<StoreInput, "tables">;
|
|
111
111
|
/******** Variations with shorthands ********/
|
112
112
|
type WorldWithShorthandsInput = Omit<WorldInput, "tables"> & Pick<StoreWithShorthandsInput, "tables">;
|
113
113
|
|
114
|
-
type namespacedTableKeys<world> = world extends {
|
115
|
-
namespaces: infer namespaces;
|
116
|
-
} ? {
|
117
|
-
[k in keyof namespaces]: namespaces[k] extends {
|
118
|
-
tables: infer tables;
|
119
|
-
} ? `${k & string}__${keyof tables & string}` : never;
|
120
|
-
}[keyof namespaces] : never;
|
121
|
-
type validateNamespace<namespace, scope extends Scope = AbiTypeScope> = {
|
122
|
-
readonly [key in keyof namespace]: key extends "tables" ? validateTables<namespace[key], scope> : key extends keyof NamespaceInput ? conform<namespace[key], NamespaceInput[key]> : ErrorMessage<`\`${key & string}\` is not a valid namespace config option.`>;
|
123
|
-
};
|
124
|
-
declare function validateNamespace<scope extends Scope = AbiTypeScope>(namespace: unknown, scope: scope): asserts namespace is NamespaceInput;
|
125
|
-
type resolveNamespacedTables<world> = "namespaces" extends keyof world ? {
|
126
|
-
readonly [key in namespacedTableKeys<world>]: key extends `${infer namespace}__${infer table}` ? resolveTable<mergeIfUndefined<getPath<world, ["namespaces", namespace, "tables", table]>, {
|
127
|
-
name: table;
|
128
|
-
namespace: namespace;
|
129
|
-
}>, extendedScope<world>> : never;
|
130
|
-
} : {};
|
131
|
-
|
132
114
|
declare const SYSTEM_DEFAULTS: {
|
133
115
|
readonly namespace: "";
|
134
116
|
readonly registerFunctionSelectors: true;
|
@@ -203,6 +185,20 @@ type resolveSystems<systems extends SystemsInput, namespace extends string> = {
|
|
203
185
|
};
|
204
186
|
declare function resolveSystems<systems extends SystemsInput, namespace extends string>(systems: systems, namespace: namespace): resolveSystems<systems, namespace>;
|
205
187
|
|
188
|
+
type namespacedTableKeys<world> = world extends {
|
189
|
+
namespaces: infer namespaces;
|
190
|
+
} ? {
|
191
|
+
[k in keyof namespaces]: namespaces[k] extends {
|
192
|
+
tables: infer tables;
|
193
|
+
} ? `${k & string}__${keyof tables & string}` : never;
|
194
|
+
}[keyof namespaces] : never;
|
195
|
+
type resolveNamespacedTables<world> = "namespaces" extends keyof world ? {
|
196
|
+
readonly [key in namespacedTableKeys<world>]: key extends `${infer namespace}__${infer table}` ? resolveTable<mergeIfUndefined<getPath<world, ["namespaces", namespace, "tables", table]>, {
|
197
|
+
name: table;
|
198
|
+
namespace: namespace;
|
199
|
+
}>, extendedScope<world>> : never;
|
200
|
+
} : {};
|
201
|
+
|
206
202
|
type resolveCodegen<codegen> = codegen extends {} ? mergeIfUndefined<codegen, CODEGEN_DEFAULTS> : CODEGEN_DEFAULTS;
|
207
203
|
declare function resolveCodegen<codegen>(codegen: codegen): resolveCodegen<codegen>;
|
208
204
|
|
@@ -216,9 +212,9 @@ declare function validateWorld(world: unknown): asserts world is WorldInput;
|
|
216
212
|
type resolveWorld<world, namespace = resolveStore<world>["namespace"]> = withJsDoc<resolveStore<world> & mergeIfUndefined<{
|
217
213
|
readonly tables: resolveNamespacedTables<world>;
|
218
214
|
} & {
|
219
|
-
[key in Exclude<keyof world,
|
215
|
+
[key in Exclude<keyof world, keyof Store>]: key extends "systems" ? resolveSystems<world[key] & SystemsInput, namespace & string> : key extends "deploy" ? resolveDeploy<world[key]> : key extends "codegen" ? resolveCodegen<world[key]> : world[key];
|
220
216
|
}, CONFIG_DEFAULTS>, World>;
|
221
217
|
declare function resolveWorld<const world extends WorldInput>(world: world): resolveWorld<world>;
|
222
218
|
declare function defineWorld<const input>(input: validateWorld<input>): resolveWorld<input>;
|
223
219
|
|
224
|
-
export { WorldWithShorthandsInput as W,
|
220
|
+
export { WorldWithShorthandsInput as W, defineWorld as d, resolveWorld as r, validateWorld as v };
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@latticexyz/world",
|
3
|
-
"version": "3.0.0-main-
|
3
|
+
"version": "3.0.0-main-69e23a36b",
|
4
4
|
"description": "World framework",
|
5
5
|
"repository": {
|
6
6
|
"type": "git",
|
@@ -47,11 +47,11 @@
|
|
47
47
|
"abitype": "1.0.0",
|
48
48
|
"arktype": "1.0.29-alpha",
|
49
49
|
"viem": "2.9.20",
|
50
|
-
"@latticexyz/common": "3.0.0-main-
|
51
|
-
"@latticexyz/config": "3.0.0-main-
|
52
|
-
"@latticexyz/
|
53
|
-
"@latticexyz/
|
54
|
-
"@latticexyz/store": "3.0.0-main-
|
50
|
+
"@latticexyz/common": "3.0.0-main-69e23a36b",
|
51
|
+
"@latticexyz/config": "3.0.0-main-69e23a36b",
|
52
|
+
"@latticexyz/schema-type": "3.0.0-main-69e23a36b",
|
53
|
+
"@latticexyz/protocol-parser": "3.0.0-main-69e23a36b",
|
54
|
+
"@latticexyz/store": "3.0.0-main-69e23a36b"
|
55
55
|
},
|
56
56
|
"devDependencies": {
|
57
57
|
"@arktype/attest": "0.7.5",
|
@@ -66,8 +66,8 @@
|
|
66
66
|
"tsup": "^6.7.0",
|
67
67
|
"tsx": "^3.12.6",
|
68
68
|
"vitest": "0.34.6",
|
69
|
-
"@latticexyz/abi-ts": "3.0.0-main-
|
70
|
-
"@latticexyz/gas-report": "3.0.0-main-
|
69
|
+
"@latticexyz/abi-ts": "3.0.0-main-69e23a36b",
|
70
|
+
"@latticexyz/gas-report": "3.0.0-main-69e23a36b"
|
71
71
|
},
|
72
72
|
"scripts": {
|
73
73
|
"build": "pnpm run build:mud && pnpm run build:abi && pnpm run build:abi-ts && pnpm run build:js",
|
package/dist/chunk-OM2LE2WB.js
DELETED
@@ -1,2 +0,0 @@
|
|
1
|
-
import{h as i,i as l,j as m,k as a,l as y,m as f}from"./chunk-DK3XOTC2.js";import{extendedScope as g,get as j,resolveTable as L,validateTable as F,mergeIfUndefined as n,resolveStore as $,hasOwnKey as k,validateStore as C}from"@latticexyz/store/config/v2";import{isObject as w}from"@latticexyz/store/config/v2";function v(e){if(w(e)){for(let s of Object.values(e))y(s,{inNamespace:!0});return}throw new Error(`Expected system config, received ${JSON.stringify(e)}`)}function b(e,s){return Object.fromEntries(Object.entries(e).map(([o,p])=>[o,f({...p,label:o,namespace:s})]))}import{validateTables as I,isObject as N,hasOwnKey as O}from"@latticexyz/store/config/v2";function D(e,s){O(e,"tables")&&I(e.tables,s)}function u(e,s){if(!N(e))throw new Error(`Expected namespaces, received ${JSON.stringify(e)}`);for(let o of Object.values(e))D(o,s)}import{isObject as U,mergeIfUndefined as W}from"@latticexyz/store/config/v2";function x(e){return U(e)?W(e,l):l}import{mergeIfUndefined as _,isObject as A}from"@latticexyz/store/config/v2";function S(e){return A(e)?_(e,m):m}function h(e){let s=g(e);C(e),k(e,"systems")&&v(e.systems),k(e,"namespaces")&&u(e.namespaces,s)}function M(e){let s=g(e),o=e.namespaces??{},p=Object.fromEntries(Object.entries(o).map(([r,T])=>Object.entries(T.tables??{}).map(([d,c])=>(F(c,s),[`${r}__${d}`,L(n(c,{namespace:r,name:d}),s)]))).flat()),t=$(e),E=(e.modules??a.modules).map(r=>n(r,i));return n({...t,tables:{...t.tables,...p},codegen:n(t.codegen,x(e.codegen)),deploy:S(e.deploy),systems:b(e.systems??a.systems,t.namespace),excludeSystems:j(e,"excludeSystems"),modules:E},a)}function ye(e){return h(e),M(e)}export{h as a,M as b,ye as c};
|
2
|
-
//# sourceMappingURL=chunk-OM2LE2WB.js.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"sources":["../ts/config/v2/world.ts","../ts/config/v2/systems.ts","../ts/config/v2/namespaces.ts","../ts/config/v2/codegen.ts","../ts/config/v2/deploy.ts"],"sourcesContent":["import { ErrorMessage, conform, narrow, type withJsDoc } from \"@arktype/util\";\nimport {\n UserTypes,\n extendedScope,\n get,\n resolveTable,\n validateTable,\n mergeIfUndefined,\n validateTables,\n resolveStore,\n Store,\n hasOwnKey,\n validateStore,\n} from \"@latticexyz/store/config/v2\";\nimport { SystemsInput, WorldInput } from \"./input\";\nimport { CONFIG_DEFAULTS, MODULE_DEFAULTS } from \"./defaults\";\nimport { Tables } from \"@latticexyz/store/internal\";\nimport { resolveSystems, validateSystems } from \"./systems\";\nimport { resolveNamespacedTables, validateNamespaces } from \"./namespaces\";\nimport { resolveCodegen } from \"./codegen\";\nimport { resolveDeploy } from \"./deploy\";\nimport type { World } from \"./output.js\";\n\nexport type validateWorld<world> = {\n readonly [key in keyof world]: key extends \"tables\"\n ? validateTables<world[key], extendedScope<world>>\n : key extends \"userTypes\"\n ? UserTypes\n : key extends \"enums\"\n ? narrow<world[key]>\n : key extends \"systems\"\n ? validateSystems<world[key]>\n : key extends \"namespaces\"\n ? // ? validateNamespaces<world[key], extendedScope<world>>\n ErrorMessage<`Namespaces config will be enabled soon.`>\n : key extends keyof WorldInput\n ? conform<world[key], WorldInput[key]>\n : ErrorMessage<`\\`${key & string}\\` is not a valid World config option.`>;\n};\n\nexport function validateWorld(world: unknown): asserts world is WorldInput {\n const scope = extendedScope(world);\n validateStore(world);\n\n if (hasOwnKey(world, \"systems\")) {\n validateSystems(world.systems);\n }\n if (hasOwnKey(world, \"namespaces\")) {\n validateNamespaces(world.namespaces, scope);\n }\n}\n\nexport type resolveWorld<world, namespace = resolveStore<world>[\"namespace\"]> = withJsDoc<\n resolveStore<world> &\n mergeIfUndefined<\n { readonly tables: resolveNamespacedTables<world> } & {\n [key in Exclude<keyof world, \"namespaces\" | keyof Store>]: key extends \"systems\"\n ? resolveSystems<world[key] & SystemsInput, namespace & string>\n : key extends \"deploy\"\n ? resolveDeploy<world[key]>\n : key extends \"codegen\"\n ? resolveCodegen<world[key]>\n : world[key];\n },\n CONFIG_DEFAULTS\n >,\n World\n>;\n\nexport function resolveWorld<const world extends WorldInput>(world: world): resolveWorld<world> {\n const scope = extendedScope(world);\n const 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, resolvedStore.namespace),\n excludeSystems: get(world, \"excludeSystems\"),\n modules,\n },\n CONFIG_DEFAULTS,\n ) as never;\n}\n\nexport function defineWorld<const input>(input: validateWorld<input>): resolveWorld<input> {\n validateWorld(input);\n return resolveWorld(input) as never;\n}\n","import { ErrorMessage } from \"@arktype/util\";\nimport { isObject } from \"@latticexyz/store/config/v2\";\nimport { SystemsInput } from \"./input\";\nimport { resolveSystem, validateSystem } from \"./system\";\n\n// TODO: add nuance between \"in namespace\" (namespace provided in context) and \"in systems\" (label provided in context)\n\nexport type validateSystems<input> = {\n [label in keyof input]: input[label] extends object\n ? validateSystem<input[label], { inNamespace: true }>\n : ErrorMessage<`Expected a system config for ${label & string}.`>;\n};\n\nexport function validateSystems(input: unknown): asserts input is SystemsInput {\n if (isObject(input)) {\n for (const table of Object.values(input)) {\n validateSystem(table, { inNamespace: true });\n }\n return;\n }\n throw new Error(`Expected system config, received ${JSON.stringify(input)}`);\n}\n\nexport type resolveSystems<systems extends SystemsInput, namespace extends string> = {\n [label in keyof systems]: resolveSystem<systems[label] & { label: label; namespace: namespace }>;\n};\n\nexport function resolveSystems<systems extends SystemsInput, namespace extends string>(\n systems: systems,\n namespace: namespace,\n): resolveSystems<systems, namespace> {\n return Object.fromEntries(\n Object.entries(systems).map(([label, system]) => {\n return [label, resolveSystem({ ...system, label, namespace })];\n }),\n ) as never;\n}\n","import {\n Scope,\n AbiTypeScope,\n validateTables,\n isObject,\n hasOwnKey,\n resolveTable,\n mergeIfUndefined,\n extendedScope,\n getPath,\n} from \"@latticexyz/store/config/v2\";\nimport { NamespaceInput, NamespacesInput } from \"./input\";\nimport { ErrorMessage, conform } from \"@arktype/util\";\n\nexport type namespacedTableKeys<world> = world extends { namespaces: infer namespaces }\n ? {\n [k in keyof namespaces]: namespaces[k] extends { tables: infer tables }\n ? `${k & string}__${keyof tables & string}`\n : never;\n }[keyof namespaces]\n : never;\n\nexport type validateNamespace<namespace, scope extends Scope = AbiTypeScope> = {\n readonly [key in keyof namespace]: key extends \"tables\"\n ? validateTables<namespace[key], scope>\n : key extends keyof NamespaceInput\n ? conform<namespace[key], NamespaceInput[key]>\n : ErrorMessage<`\\`${key & string}\\` is not a valid namespace config option.`>;\n};\n\nexport function validateNamespace<scope extends Scope = AbiTypeScope>(\n namespace: unknown,\n scope: scope,\n): asserts namespace is NamespaceInput {\n if (hasOwnKey(namespace, \"tables\")) {\n validateTables(namespace.tables, scope);\n }\n}\n\nexport type validateNamespaces<namespaces, scope extends Scope = AbiTypeScope> = {\n [label in keyof namespaces]: validateNamespace<namespaces[label], scope>;\n};\n\nexport function validateNamespaces<scope extends Scope = AbiTypeScope>(\n namespaces: unknown,\n scope: scope,\n): asserts namespaces is NamespacesInput {\n if (!isObject(namespaces)) {\n throw new Error(`Expected namespaces, received ${JSON.stringify(namespaces)}`);\n }\n for (const namespace of Object.values(namespaces)) {\n validateNamespace(namespace, scope);\n }\n}\n\nexport type resolveNamespacedTables<world> = \"namespaces\" extends keyof world\n ? {\n readonly [key in namespacedTableKeys<world>]: key extends `${infer namespace}__${infer table}`\n ? resolveTable<\n mergeIfUndefined<\n getPath<world, [\"namespaces\", namespace, \"tables\", table]>,\n { name: table; namespace: namespace }\n >,\n extendedScope<world>\n >\n : never;\n }\n : {};\n","import { isObject, mergeIfUndefined } from \"@latticexyz/store/config/v2\";\nimport { CODEGEN_DEFAULTS } from \"./defaults\";\n\nexport type resolveCodegen<codegen> = codegen extends {}\n ? mergeIfUndefined<codegen, CODEGEN_DEFAULTS>\n : CODEGEN_DEFAULTS;\n\nexport function resolveCodegen<codegen>(codegen: codegen): resolveCodegen<codegen> {\n return (isObject(codegen) ? mergeIfUndefined(codegen, CODEGEN_DEFAULTS) : CODEGEN_DEFAULTS) as never;\n}\n","import { mergeIfUndefined, isObject } from \"@latticexyz/store/config/v2\";\nimport { DEPLOY_DEFAULTS } from \"./defaults\";\n\nexport type resolveDeploy<deploy> = deploy extends {} ? mergeIfUndefined<deploy, DEPLOY_DEFAULTS> : DEPLOY_DEFAULTS;\n\nexport function resolveDeploy<deploy>(deploy: deploy): resolveDeploy<deploy> {\n return (isObject(deploy) ? mergeIfUndefined(deploy, DEPLOY_DEFAULTS) : DEPLOY_DEFAULTS) as never;\n}\n"],"mappings":"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","names":["extendedScope","get","resolveTable","validateTable","mergeIfUndefined","resolveStore","hasOwnKey","validateStore","isObject","validateSystems","input","isObject","table","validateSystem","resolveSystems","systems","namespace","label","system","resolveSystem","validateTables","isObject","hasOwnKey","validateNamespace","namespace","scope","validateNamespaces","namespaces","isObject","mergeIfUndefined","resolveCodegen","codegen","isObject","mergeIfUndefined","CODEGEN_DEFAULTS","mergeIfUndefined","isObject","resolveDeploy","deploy","isObject","mergeIfUndefined","DEPLOY_DEFAULTS","validateWorld","world","scope","extendedScope","validateStore","hasOwnKey","validateSystems","validateNamespaces","resolveWorld","namespaces","resolvedNamespacedTables","namespaceKey","namespace","tableKey","table","validateTable","resolveTable","mergeIfUndefined","resolvedStore","resolveStore","modules","CONFIG_DEFAULTS","mod","MODULE_DEFAULTS","resolveCodegen","resolveDeploy","resolveSystems","get","defineWorld","input"]}
|
File without changes
|