@latticexyz/cli 1.41.0 → 2.0.0-alpha.0
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-GR245KYP.js → chunk-J4DJQNIC.js} +679 -133
- package/dist/chunk-O57QENJ6.js +23039 -0
- package/dist/config/index.d.ts +606 -292
- package/dist/config/index.js +49 -26
- package/dist/index.d.ts +2 -110
- package/dist/index.js +9 -50
- package/dist/mud.js +937 -57
- package/dist/utils/index.d.ts +92 -4
- package/dist/utils/index.js +2 -3
- package/package.json +10 -9
- package/src/commands/deploy-v2.ts +11 -15
- package/src/commands/index.ts +2 -0
- package/src/commands/worldgen.ts +55 -0
- package/src/config/commonSchemas.ts +11 -13
- package/src/config/dynamicResolution.ts +49 -0
- package/src/config/index.ts +15 -3
- package/src/config/loadStoreConfig.ts +1 -1
- package/src/config/parseStoreConfig.test-d.ts +31 -5
- package/src/config/parseStoreConfig.ts +218 -78
- package/src/config/validation.ts +25 -0
- package/src/config/world/index.ts +4 -0
- package/src/config/{loadWorldConfig.test-d.ts → world/loadWorldConfig.test-d.ts} +3 -3
- package/src/config/world/loadWorldConfig.ts +26 -0
- package/src/config/world/parseWorldConfig.ts +55 -0
- package/src/config/world/resolveWorldConfig.ts +80 -0
- package/src/config/world/userTypes.ts +72 -0
- package/src/index.ts +4 -6
- package/src/render-solidity/common.ts +51 -6
- package/src/render-solidity/field.ts +40 -44
- package/src/render-solidity/index.ts +5 -1
- package/src/render-solidity/record.ts +56 -73
- package/src/render-solidity/renderSystemInterface.ts +31 -0
- package/src/render-solidity/renderTable.ts +98 -70
- package/src/render-solidity/renderTypeHelpers.ts +99 -0
- package/src/render-solidity/renderTypesFromConfig.ts +2 -2
- package/src/render-solidity/renderWorld.ts +24 -0
- package/src/render-solidity/{renderTablesFromConfig.ts → tableOptions.ts} +28 -30
- package/src/render-solidity/tablegen.ts +20 -22
- package/src/render-solidity/types.ts +39 -5
- package/src/render-solidity/userType.ts +80 -48
- package/src/render-solidity/worldgen.ts +60 -0
- package/src/utils/contractToInterface.ts +130 -0
- package/src/utils/deploy-v2.ts +268 -101
- package/src/utils/formatAndWrite.ts +12 -0
- package/src/utils/getChainId.ts +10 -0
- package/src/utils/typeUtils.ts +17 -0
- package/dist/chunk-AER7UDD4.js +0 -0
- package/dist/chunk-XRS7KWBZ.js +0 -547
- package/dist/chunk-YZATC2M3.js +0 -397
- package/dist/chunk-ZYDMYSTH.js +0 -1178
- package/dist/deploy-v2-b7b3207d.d.ts +0 -92
- package/src/config/loadWorldConfig.ts +0 -178
- package/src/constants.ts +0 -1
package/dist/config/index.d.ts
CHANGED
|
@@ -1,12 +1,226 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { SchemaType } from '@latticexyz/schema-type';
|
|
1
|
+
import { AbiType, StaticAbiType } from '@latticexyz/schema-type';
|
|
3
2
|
import { z, RefinementCtx } from 'zod';
|
|
4
3
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
4
|
+
type RequireKeys<T extends Record<string, unknown>, P extends string> = T & Required<Pick<T, P>>;
|
|
5
|
+
type StringForUnion = string & Record<never, never>;
|
|
6
|
+
type StaticArray = `${StaticAbiType}[${number}]`;
|
|
7
|
+
type ExtractUserTypes<UnknownTypes extends StringForUnion> = Exclude<UnknownTypes, AbiType | StaticArray>;
|
|
8
|
+
type AsDependent<T> = T extends infer P ? P : never;
|
|
9
|
+
|
|
10
|
+
declare function loadStoreConfig(configPath?: string): Promise<{
|
|
11
|
+
namespace: string;
|
|
12
|
+
storeImportPath: string;
|
|
13
|
+
tables: Record<string, RequireKeys<RequireKeys<{
|
|
14
|
+
directory: string;
|
|
15
|
+
tableIdArgument: boolean;
|
|
16
|
+
storeArgument: boolean;
|
|
17
|
+
primaryKeys: Record<string, string>;
|
|
18
|
+
schema: Record<string, string>;
|
|
19
|
+
fileSelector?: string | undefined;
|
|
20
|
+
dataStruct?: boolean | undefined;
|
|
21
|
+
}, "dataStruct">, "fileSelector">>;
|
|
22
|
+
userTypesPath: string;
|
|
23
|
+
enums: Record<string, string[]>;
|
|
24
|
+
}>;
|
|
25
|
+
|
|
26
|
+
type FieldData<UserTypes extends StringForUnion> = AbiType | StaticArray | UserTypes;
|
|
27
|
+
type PrimaryKey<StaticUserTypes extends StringForUnion> = StaticAbiType | StaticUserTypes;
|
|
28
|
+
/************************************************************************
|
|
29
|
+
*
|
|
30
|
+
* TABLE SCHEMA
|
|
31
|
+
*
|
|
32
|
+
************************************************************************/
|
|
33
|
+
type FullSchemaConfig<UserTypes extends StringForUnion = StringForUnion> = Record<string, FieldData<UserTypes>>;
|
|
34
|
+
type ShorthandSchemaConfig<UserTypes extends StringForUnion = StringForUnion> = FieldData<UserTypes>;
|
|
35
|
+
type SchemaConfig<UserTypes extends StringForUnion = StringForUnion> = FullSchemaConfig<UserTypes> | ShorthandSchemaConfig<UserTypes>;
|
|
36
|
+
declare const zSchemaConfig: z.ZodUnion<[z.ZodEffects<z.ZodRecord<z.ZodEffects<z.ZodString, string, string>, z.ZodString>, Record<string, string>, Record<string, string>>, z.ZodEffects<z.ZodString, Record<string, string>, string>]>;
|
|
37
|
+
/************************************************************************
|
|
38
|
+
*
|
|
39
|
+
* TABLE
|
|
40
|
+
*
|
|
41
|
+
************************************************************************/
|
|
42
|
+
interface TableConfig<UserTypes extends StringForUnion = StringForUnion, StaticUserTypes extends StringForUnion = StringForUnion> {
|
|
43
|
+
/** Output directory path for the file. Default is "tables" */
|
|
44
|
+
directory?: string;
|
|
45
|
+
/**
|
|
46
|
+
* The fileSelector is used with the namespace to register the table and construct its id.
|
|
47
|
+
* The table id will be uint256(bytes32(abi.encodePacked(bytes16(namespace), bytes16(fileSelector)))).
|
|
48
|
+
* Default is "<tableName>"
|
|
49
|
+
* */
|
|
50
|
+
fileSelector?: string;
|
|
51
|
+
/** Make methods accept `tableId` argument instead of it being a hardcoded constant. Default is false */
|
|
52
|
+
tableIdArgument?: boolean;
|
|
53
|
+
/** Include methods that accept a manual `IStore` argument. Default is false. */
|
|
54
|
+
storeArgument?: boolean;
|
|
55
|
+
/** Include a data struct and methods for it. Default is false for 1-column tables; true for multi-column tables. */
|
|
56
|
+
dataStruct?: boolean;
|
|
57
|
+
/** Table's primary key names mapped to their types. Default is `{ key: "bytes32" }` */
|
|
58
|
+
primaryKeys?: Record<string, PrimaryKey<StaticUserTypes>>;
|
|
59
|
+
/** Table's column names mapped to their types. Table name's 1st letter should be lowercase. */
|
|
60
|
+
schema: SchemaConfig<UserTypes>;
|
|
61
|
+
}
|
|
62
|
+
declare const zTableConfig: z.ZodUnion<[z.ZodEffects<z.ZodObject<{
|
|
63
|
+
directory: z.ZodDefault<z.ZodString>;
|
|
64
|
+
fileSelector: z.ZodOptional<z.ZodEffects<z.ZodString, string, string>>;
|
|
65
|
+
tableIdArgument: z.ZodDefault<z.ZodBoolean>;
|
|
66
|
+
storeArgument: z.ZodDefault<z.ZodBoolean>;
|
|
67
|
+
primaryKeys: z.ZodDefault<z.ZodRecord<z.ZodEffects<z.ZodString, string, string>, z.ZodString>>;
|
|
68
|
+
schema: z.ZodUnion<[z.ZodEffects<z.ZodRecord<z.ZodEffects<z.ZodString, string, string>, z.ZodString>, Record<string, string>, Record<string, string>>, z.ZodEffects<z.ZodString, Record<string, string>, string>]>;
|
|
69
|
+
dataStruct: z.ZodOptional<z.ZodBoolean>;
|
|
70
|
+
}, "strip", z.ZodTypeAny, {
|
|
71
|
+
directory: string;
|
|
72
|
+
tableIdArgument: boolean;
|
|
73
|
+
storeArgument: boolean;
|
|
74
|
+
primaryKeys: Record<string, string>;
|
|
75
|
+
schema: Record<string, string>;
|
|
76
|
+
fileSelector?: string | undefined;
|
|
77
|
+
dataStruct?: boolean | undefined;
|
|
78
|
+
}, {
|
|
79
|
+
schema: (string | Record<string, string>) & (string | Record<string, string> | undefined);
|
|
80
|
+
directory?: string | undefined;
|
|
81
|
+
fileSelector?: string | undefined;
|
|
82
|
+
tableIdArgument?: boolean | undefined;
|
|
83
|
+
storeArgument?: boolean | undefined;
|
|
84
|
+
primaryKeys?: Record<string, string> | undefined;
|
|
85
|
+
dataStruct?: boolean | undefined;
|
|
86
|
+
}>, RequireKeys<{
|
|
87
|
+
directory: string;
|
|
88
|
+
tableIdArgument: boolean;
|
|
89
|
+
storeArgument: boolean;
|
|
90
|
+
primaryKeys: Record<string, string>;
|
|
91
|
+
schema: Record<string, string>;
|
|
92
|
+
fileSelector?: string | undefined;
|
|
93
|
+
dataStruct?: boolean | undefined;
|
|
94
|
+
}, "dataStruct">, {
|
|
95
|
+
schema: (string | Record<string, string>) & (string | Record<string, string> | undefined);
|
|
96
|
+
directory?: string | undefined;
|
|
97
|
+
fileSelector?: string | undefined;
|
|
98
|
+
tableIdArgument?: boolean | undefined;
|
|
99
|
+
storeArgument?: boolean | undefined;
|
|
100
|
+
primaryKeys?: Record<string, string> | undefined;
|
|
101
|
+
dataStruct?: boolean | undefined;
|
|
102
|
+
}>, z.ZodEffects<z.ZodString, RequireKeys<{
|
|
103
|
+
directory: string;
|
|
104
|
+
tableIdArgument: boolean;
|
|
105
|
+
storeArgument: boolean;
|
|
106
|
+
primaryKeys: Record<string, string>;
|
|
107
|
+
schema: Record<string, string>;
|
|
108
|
+
fileSelector?: string | undefined;
|
|
109
|
+
dataStruct?: boolean | undefined;
|
|
110
|
+
}, "dataStruct">, string>]>;
|
|
111
|
+
/************************************************************************
|
|
112
|
+
*
|
|
113
|
+
* TABLES
|
|
114
|
+
*
|
|
115
|
+
************************************************************************/
|
|
116
|
+
type TablesConfig<UserTypes extends StringForUnion = StringForUnion, StaticUserTypes extends StringForUnion = StringForUnion> = Record<string, TableConfig<UserTypes, StaticUserTypes> | FieldData<UserTypes>>;
|
|
117
|
+
declare const zTablesConfig: z.ZodEffects<z.ZodRecord<z.ZodEffects<z.ZodString, string, string>, z.ZodUnion<[z.ZodEffects<z.ZodObject<{
|
|
118
|
+
directory: z.ZodDefault<z.ZodString>;
|
|
119
|
+
fileSelector: z.ZodOptional<z.ZodEffects<z.ZodString, string, string>>;
|
|
120
|
+
tableIdArgument: z.ZodDefault<z.ZodBoolean>;
|
|
121
|
+
storeArgument: z.ZodDefault<z.ZodBoolean>;
|
|
122
|
+
primaryKeys: z.ZodDefault<z.ZodRecord<z.ZodEffects<z.ZodString, string, string>, z.ZodString>>;
|
|
123
|
+
schema: z.ZodUnion<[z.ZodEffects<z.ZodRecord<z.ZodEffects<z.ZodString, string, string>, z.ZodString>, Record<string, string>, Record<string, string>>, z.ZodEffects<z.ZodString, Record<string, string>, string>]>;
|
|
124
|
+
dataStruct: z.ZodOptional<z.ZodBoolean>;
|
|
125
|
+
}, "strip", z.ZodTypeAny, {
|
|
126
|
+
directory: string;
|
|
127
|
+
tableIdArgument: boolean;
|
|
128
|
+
storeArgument: boolean;
|
|
129
|
+
primaryKeys: Record<string, string>;
|
|
130
|
+
schema: Record<string, string>;
|
|
131
|
+
fileSelector?: string | undefined;
|
|
132
|
+
dataStruct?: boolean | undefined;
|
|
133
|
+
}, {
|
|
134
|
+
schema: (string | Record<string, string>) & (string | Record<string, string> | undefined);
|
|
135
|
+
directory?: string | undefined;
|
|
136
|
+
fileSelector?: string | undefined;
|
|
137
|
+
tableIdArgument?: boolean | undefined;
|
|
138
|
+
storeArgument?: boolean | undefined;
|
|
139
|
+
primaryKeys?: Record<string, string> | undefined;
|
|
140
|
+
dataStruct?: boolean | undefined;
|
|
141
|
+
}>, RequireKeys<{
|
|
142
|
+
directory: string;
|
|
143
|
+
tableIdArgument: boolean;
|
|
144
|
+
storeArgument: boolean;
|
|
145
|
+
primaryKeys: Record<string, string>;
|
|
146
|
+
schema: Record<string, string>;
|
|
147
|
+
fileSelector?: string | undefined;
|
|
148
|
+
dataStruct?: boolean | undefined;
|
|
149
|
+
}, "dataStruct">, {
|
|
150
|
+
schema: (string | Record<string, string>) & (string | Record<string, string> | undefined);
|
|
151
|
+
directory?: string | undefined;
|
|
152
|
+
fileSelector?: string | undefined;
|
|
153
|
+
tableIdArgument?: boolean | undefined;
|
|
154
|
+
storeArgument?: boolean | undefined;
|
|
155
|
+
primaryKeys?: Record<string, string> | undefined;
|
|
156
|
+
dataStruct?: boolean | undefined;
|
|
157
|
+
}>, z.ZodEffects<z.ZodString, RequireKeys<{
|
|
158
|
+
directory: string;
|
|
159
|
+
tableIdArgument: boolean;
|
|
160
|
+
storeArgument: boolean;
|
|
161
|
+
primaryKeys: Record<string, string>;
|
|
162
|
+
schema: Record<string, string>;
|
|
163
|
+
fileSelector?: string | undefined;
|
|
164
|
+
dataStruct?: boolean | undefined;
|
|
165
|
+
}, "dataStruct">, string>]>>, Record<string, RequireKeys<RequireKeys<{
|
|
166
|
+
directory: string;
|
|
167
|
+
tableIdArgument: boolean;
|
|
168
|
+
storeArgument: boolean;
|
|
169
|
+
primaryKeys: Record<string, string>;
|
|
170
|
+
schema: Record<string, string>;
|
|
171
|
+
fileSelector?: string | undefined;
|
|
172
|
+
dataStruct?: boolean | undefined;
|
|
173
|
+
}, "dataStruct">, "fileSelector">>, Record<string, string | {
|
|
174
|
+
schema: (string | Record<string, string>) & (string | Record<string, string> | undefined);
|
|
175
|
+
directory?: string | undefined;
|
|
176
|
+
fileSelector?: string | undefined;
|
|
177
|
+
tableIdArgument?: boolean | undefined;
|
|
178
|
+
storeArgument?: boolean | undefined;
|
|
179
|
+
primaryKeys?: Record<string, string> | undefined;
|
|
180
|
+
dataStruct?: boolean | undefined;
|
|
181
|
+
}>>;
|
|
182
|
+
/************************************************************************
|
|
183
|
+
*
|
|
184
|
+
* USER TYPES
|
|
185
|
+
*
|
|
186
|
+
************************************************************************/
|
|
187
|
+
type EnumsConfig<EnumNames extends StringForUnion> = never extends EnumNames ? {
|
|
188
|
+
/**
|
|
189
|
+
* Enum names mapped to lists of their member names
|
|
190
|
+
*
|
|
191
|
+
* (enums are inferred to be absent)
|
|
192
|
+
*/
|
|
193
|
+
enums?: Record<EnumNames, string[]>;
|
|
194
|
+
} : StringForUnion extends EnumNames ? {
|
|
195
|
+
/**
|
|
196
|
+
* Enum names mapped to lists of their member names
|
|
197
|
+
*
|
|
198
|
+
* (enums aren't inferred - use `mudConfig` or `storeConfig` helper, and `as const` for variables)
|
|
199
|
+
*/
|
|
200
|
+
enums?: Record<EnumNames, string[]>;
|
|
201
|
+
} : {
|
|
202
|
+
/**
|
|
203
|
+
* Enum names mapped to lists of their member names
|
|
204
|
+
*
|
|
205
|
+
* Enums defined here can be used as types in table schemas/keys
|
|
206
|
+
*/
|
|
207
|
+
enums: Record<EnumNames, string[]>;
|
|
208
|
+
};
|
|
209
|
+
declare const zEnumsConfig: z.ZodObject<{
|
|
210
|
+
enums: z.ZodDefault<z.ZodRecord<z.ZodEffects<z.ZodString, string, string>, z.ZodEffects<z.ZodArray<z.ZodEffects<z.ZodString, string, string>, "many">, string[], string[]>>>;
|
|
211
|
+
}, "strip", z.ZodTypeAny, {
|
|
212
|
+
enums: Record<string, string[]>;
|
|
213
|
+
}, {
|
|
214
|
+
enums?: Record<string, string[]> | undefined;
|
|
215
|
+
}>;
|
|
216
|
+
/************************************************************************
|
|
217
|
+
*
|
|
218
|
+
* FINAL
|
|
219
|
+
*
|
|
220
|
+
************************************************************************/
|
|
221
|
+
type StoreUserConfig<EnumNames extends StringForUnion = StringForUnion, StaticUserTypes extends ExtractUserTypes<EnumNames> = ExtractUserTypes<EnumNames>> = EnumsConfig<EnumNames> & {
|
|
222
|
+
/** The namespace for table ids. Default is "" (empty string) */
|
|
223
|
+
namespace?: string;
|
|
10
224
|
/** Path for store package imports. Default is "@latticexyz/store/src/" */
|
|
11
225
|
storeImportPath?: string;
|
|
12
226
|
/**
|
|
@@ -15,249 +229,291 @@ interface StoreUserConfig {
|
|
|
15
229
|
* The key is the table name (capitalized).
|
|
16
230
|
*
|
|
17
231
|
* The value:
|
|
18
|
-
* -
|
|
232
|
+
* - abi or user type for a single-value table.
|
|
19
233
|
* - FullTableConfig object for multi-value tables (or for customizable options).
|
|
20
234
|
*/
|
|
21
|
-
tables:
|
|
22
|
-
/**
|
|
23
|
-
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
/** Make methods accept `tableId` argument instead of it being a hardcoded constant. Default is false */
|
|
31
|
-
tableIdArgument?: boolean;
|
|
32
|
-
/** Include methods that accept a manual `IStore` argument. Default is false. */
|
|
33
|
-
storeArgument?: boolean;
|
|
34
|
-
/** Include a data struct and methods for it. Default is false for 1-column tables; true for multi-column tables. */
|
|
35
|
-
dataStruct?: boolean;
|
|
36
|
-
/** Table's primary key names mapped to their types. Default is `{ key: SchemaType.BYTES32 }` */
|
|
37
|
-
primaryKeys?: Record<string, z.input<typeof PrimaryKey>>;
|
|
38
|
-
/** Table's column names mapped to their types. Table name's 1st letter should be lowercase. */
|
|
39
|
-
schema: Record<string, z.input<typeof FieldData>>;
|
|
40
|
-
}
|
|
41
|
-
interface UserTypesConfig {
|
|
42
|
-
/** Path to the file where common types will be generated and imported from. Default is "/types" */
|
|
43
|
-
path?: string;
|
|
44
|
-
/** Enum names mapped to lists of their member names */
|
|
45
|
-
enums?: Record<string, string[]>;
|
|
46
|
-
}
|
|
47
|
-
declare const StoreConfig: z.ZodEffects<z.ZodObject<{
|
|
48
|
-
baseRoute: z.ZodDefault<z.ZodEffects<z.ZodString, string, string>>;
|
|
235
|
+
tables: TablesConfig<AsDependent<StaticUserTypes>, AsDependent<StaticUserTypes>>;
|
|
236
|
+
/** Path to the file where common user types will be generated and imported from. Default is "Types" */
|
|
237
|
+
userTypesPath?: string;
|
|
238
|
+
};
|
|
239
|
+
/** Type helper for defining StoreUserConfig */
|
|
240
|
+
declare function storeConfig<EnumNames extends StringForUnion = never, StaticUserTypes extends ExtractUserTypes<EnumNames> = ExtractUserTypes<EnumNames>>(config: StoreUserConfig<EnumNames, StaticUserTypes>): StoreUserConfig<EnumNames, StaticUserTypes>;
|
|
241
|
+
type StoreConfig = z.output<typeof zStoreConfig>;
|
|
242
|
+
declare const zStoreConfig: z.ZodEffects<z.ZodObject<{
|
|
243
|
+
namespace: z.ZodDefault<z.ZodEffects<z.ZodString, string, string>>;
|
|
49
244
|
storeImportPath: z.ZodDefault<z.ZodString>;
|
|
50
|
-
tables: z.ZodEffects<z.ZodRecord<z.ZodEffects<z.ZodString, string, string>, z.ZodUnion<[z.ZodEffects<z.
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
directory: string;
|
|
54
|
-
tableIdArgument: boolean;
|
|
55
|
-
storeArgument: boolean;
|
|
56
|
-
primaryKeys: Record<string, string | SchemaType>;
|
|
57
|
-
schema: Record<string, string | SchemaType>;
|
|
58
|
-
}, "dataStruct">, string | SchemaType>, z.ZodEffects<z.ZodObject<{
|
|
59
|
-
directory: z.ZodDefault<z.ZodEffects<z.ZodString, string, string>>;
|
|
60
|
-
route: z.ZodOptional<z.ZodEffects<z.ZodString, string, string>>;
|
|
245
|
+
tables: z.ZodEffects<z.ZodRecord<z.ZodEffects<z.ZodString, string, string>, z.ZodUnion<[z.ZodEffects<z.ZodObject<{
|
|
246
|
+
directory: z.ZodDefault<z.ZodString>;
|
|
247
|
+
fileSelector: z.ZodOptional<z.ZodEffects<z.ZodString, string, string>>;
|
|
61
248
|
tableIdArgument: z.ZodDefault<z.ZodBoolean>;
|
|
62
249
|
storeArgument: z.ZodDefault<z.ZodBoolean>;
|
|
63
|
-
primaryKeys: z.ZodDefault<z.ZodRecord<z.ZodEffects<z.ZodString, string, string>, z.
|
|
64
|
-
schema: z.ZodEffects<z.ZodRecord<z.ZodEffects<z.ZodString, string, string>, z.
|
|
250
|
+
primaryKeys: z.ZodDefault<z.ZodRecord<z.ZodEffects<z.ZodString, string, string>, z.ZodString>>;
|
|
251
|
+
schema: z.ZodUnion<[z.ZodEffects<z.ZodRecord<z.ZodEffects<z.ZodString, string, string>, z.ZodString>, Record<string, string>, Record<string, string>>, z.ZodEffects<z.ZodString, Record<string, string>, string>]>;
|
|
65
252
|
dataStruct: z.ZodOptional<z.ZodBoolean>;
|
|
66
253
|
}, "strip", z.ZodTypeAny, {
|
|
67
|
-
route?: string | undefined;
|
|
68
|
-
dataStruct?: boolean | undefined;
|
|
69
254
|
directory: string;
|
|
70
255
|
tableIdArgument: boolean;
|
|
71
256
|
storeArgument: boolean;
|
|
72
|
-
primaryKeys: Record<string, string
|
|
73
|
-
schema: Record<string, string
|
|
257
|
+
primaryKeys: Record<string, string>;
|
|
258
|
+
schema: Record<string, string>;
|
|
259
|
+
fileSelector?: string | undefined;
|
|
260
|
+
dataStruct?: boolean | undefined;
|
|
74
261
|
}, {
|
|
262
|
+
schema: (string | Record<string, string>) & (string | Record<string, string> | undefined);
|
|
75
263
|
directory?: string | undefined;
|
|
76
|
-
|
|
264
|
+
fileSelector?: string | undefined;
|
|
77
265
|
tableIdArgument?: boolean | undefined;
|
|
78
266
|
storeArgument?: boolean | undefined;
|
|
79
|
-
primaryKeys?: Record<string, string
|
|
267
|
+
primaryKeys?: Record<string, string> | undefined;
|
|
80
268
|
dataStruct?: boolean | undefined;
|
|
81
|
-
schema: Record<string, string | SchemaType>;
|
|
82
269
|
}>, RequireKeys<{
|
|
83
|
-
route?: string | undefined;
|
|
84
|
-
dataStruct?: boolean | undefined;
|
|
85
270
|
directory: string;
|
|
86
271
|
tableIdArgument: boolean;
|
|
87
272
|
storeArgument: boolean;
|
|
88
|
-
primaryKeys: Record<string, string
|
|
89
|
-
schema: Record<string, string
|
|
273
|
+
primaryKeys: Record<string, string>;
|
|
274
|
+
schema: Record<string, string>;
|
|
275
|
+
fileSelector?: string | undefined;
|
|
276
|
+
dataStruct?: boolean | undefined;
|
|
90
277
|
}, "dataStruct">, {
|
|
278
|
+
schema: (string | Record<string, string>) & (string | Record<string, string> | undefined);
|
|
91
279
|
directory?: string | undefined;
|
|
92
|
-
|
|
280
|
+
fileSelector?: string | undefined;
|
|
93
281
|
tableIdArgument?: boolean | undefined;
|
|
94
282
|
storeArgument?: boolean | undefined;
|
|
95
|
-
primaryKeys?: Record<string, string
|
|
283
|
+
primaryKeys?: Record<string, string> | undefined;
|
|
96
284
|
dataStruct?: boolean | undefined;
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
285
|
+
}>, z.ZodEffects<z.ZodString, RequireKeys<{
|
|
286
|
+
directory: string;
|
|
287
|
+
tableIdArgument: boolean;
|
|
288
|
+
storeArgument: boolean;
|
|
289
|
+
primaryKeys: Record<string, string>;
|
|
290
|
+
schema: Record<string, string>;
|
|
291
|
+
fileSelector?: string | undefined;
|
|
100
292
|
dataStruct?: boolean | undefined;
|
|
293
|
+
}, "dataStruct">, string>]>>, Record<string, RequireKeys<RequireKeys<{
|
|
101
294
|
directory: string;
|
|
102
295
|
tableIdArgument: boolean;
|
|
103
296
|
storeArgument: boolean;
|
|
104
|
-
primaryKeys: Record<string, string
|
|
105
|
-
schema: Record<string, string
|
|
106
|
-
|
|
297
|
+
primaryKeys: Record<string, string>;
|
|
298
|
+
schema: Record<string, string>;
|
|
299
|
+
fileSelector?: string | undefined;
|
|
300
|
+
dataStruct?: boolean | undefined;
|
|
301
|
+
}, "dataStruct">, "fileSelector">>, Record<string, string | {
|
|
302
|
+
schema: (string | Record<string, string>) & (string | Record<string, string> | undefined);
|
|
107
303
|
directory?: string | undefined;
|
|
108
|
-
|
|
304
|
+
fileSelector?: string | undefined;
|
|
109
305
|
tableIdArgument?: boolean | undefined;
|
|
110
306
|
storeArgument?: boolean | undefined;
|
|
111
|
-
primaryKeys?: Record<string, string
|
|
307
|
+
primaryKeys?: Record<string, string> | undefined;
|
|
112
308
|
dataStruct?: boolean | undefined;
|
|
113
|
-
schema: Record<string, string | SchemaType>;
|
|
114
|
-
}>>;
|
|
115
|
-
userTypes: z.ZodDefault<z.ZodObject<{
|
|
116
|
-
path: z.ZodDefault<z.ZodEffects<z.ZodString, string, string>>;
|
|
117
|
-
enums: z.ZodDefault<z.ZodRecord<z.ZodEffects<z.ZodString, string, string>, z.ZodEffects<z.ZodArray<z.ZodEffects<z.ZodString, string, string>, "many">, string[], string[]>>>;
|
|
118
|
-
}, "strip", z.ZodTypeAny, {
|
|
119
|
-
path: string;
|
|
120
|
-
enums: Record<string, string[]>;
|
|
121
|
-
}, {
|
|
122
|
-
path?: string | undefined;
|
|
123
|
-
enums?: Record<string, string[]> | undefined;
|
|
124
309
|
}>>;
|
|
310
|
+
userTypesPath: z.ZodDefault<z.ZodString>;
|
|
311
|
+
enums: z.ZodDefault<z.ZodRecord<z.ZodEffects<z.ZodString, string, string>, z.ZodEffects<z.ZodArray<z.ZodEffects<z.ZodString, string, string>, "many">, string[], string[]>>>;
|
|
125
312
|
}, "strip", z.ZodTypeAny, {
|
|
126
|
-
|
|
313
|
+
namespace: string;
|
|
127
314
|
storeImportPath: string;
|
|
128
315
|
tables: Record<string, RequireKeys<RequireKeys<{
|
|
129
|
-
route?: string | undefined;
|
|
130
|
-
dataStruct?: boolean | undefined;
|
|
131
316
|
directory: string;
|
|
132
317
|
tableIdArgument: boolean;
|
|
133
318
|
storeArgument: boolean;
|
|
134
|
-
primaryKeys: Record<string, string
|
|
135
|
-
schema: Record<string, string
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
319
|
+
primaryKeys: Record<string, string>;
|
|
320
|
+
schema: Record<string, string>;
|
|
321
|
+
fileSelector?: string | undefined;
|
|
322
|
+
dataStruct?: boolean | undefined;
|
|
323
|
+
}, "dataStruct">, "fileSelector">>;
|
|
324
|
+
userTypesPath: string;
|
|
325
|
+
enums: Record<string, string[]>;
|
|
141
326
|
}, {
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
userTypes?: {
|
|
145
|
-
path?: string | undefined;
|
|
146
|
-
enums?: Record<string, string[]> | undefined;
|
|
147
|
-
} | undefined;
|
|
148
|
-
tables: Record<string, string | SchemaType | {
|
|
327
|
+
tables: Record<string, string | {
|
|
328
|
+
schema: (string | Record<string, string>) & (string | Record<string, string> | undefined);
|
|
149
329
|
directory?: string | undefined;
|
|
150
|
-
|
|
330
|
+
fileSelector?: string | undefined;
|
|
151
331
|
tableIdArgument?: boolean | undefined;
|
|
152
332
|
storeArgument?: boolean | undefined;
|
|
153
|
-
primaryKeys?: Record<string, string
|
|
333
|
+
primaryKeys?: Record<string, string> | undefined;
|
|
154
334
|
dataStruct?: boolean | undefined;
|
|
155
|
-
schema: Record<string, string | SchemaType>;
|
|
156
335
|
}>;
|
|
336
|
+
namespace?: string | undefined;
|
|
337
|
+
storeImportPath?: string | undefined;
|
|
338
|
+
userTypesPath?: string | undefined;
|
|
339
|
+
enums?: Record<string, string[]> | undefined;
|
|
157
340
|
}>, {
|
|
158
|
-
|
|
341
|
+
namespace: string;
|
|
159
342
|
storeImportPath: string;
|
|
160
343
|
tables: Record<string, RequireKeys<RequireKeys<{
|
|
161
|
-
route?: string | undefined;
|
|
162
|
-
dataStruct?: boolean | undefined;
|
|
163
344
|
directory: string;
|
|
164
345
|
tableIdArgument: boolean;
|
|
165
346
|
storeArgument: boolean;
|
|
166
|
-
primaryKeys: Record<string, string
|
|
167
|
-
schema: Record<string, string
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
347
|
+
primaryKeys: Record<string, string>;
|
|
348
|
+
schema: Record<string, string>;
|
|
349
|
+
fileSelector?: string | undefined;
|
|
350
|
+
dataStruct?: boolean | undefined;
|
|
351
|
+
}, "dataStruct">, "fileSelector">>;
|
|
352
|
+
userTypesPath: string;
|
|
353
|
+
enums: Record<string, string[]>;
|
|
173
354
|
}, {
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
userTypes?: {
|
|
177
|
-
path?: string | undefined;
|
|
178
|
-
enums?: Record<string, string[]> | undefined;
|
|
179
|
-
} | undefined;
|
|
180
|
-
tables: Record<string, string | SchemaType | {
|
|
355
|
+
tables: Record<string, string | {
|
|
356
|
+
schema: (string | Record<string, string>) & (string | Record<string, string> | undefined);
|
|
181
357
|
directory?: string | undefined;
|
|
182
|
-
|
|
358
|
+
fileSelector?: string | undefined;
|
|
183
359
|
tableIdArgument?: boolean | undefined;
|
|
184
360
|
storeArgument?: boolean | undefined;
|
|
185
|
-
primaryKeys?: Record<string, string
|
|
361
|
+
primaryKeys?: Record<string, string> | undefined;
|
|
186
362
|
dataStruct?: boolean | undefined;
|
|
187
|
-
schema: Record<string, string | SchemaType>;
|
|
188
363
|
}>;
|
|
364
|
+
namespace?: string | undefined;
|
|
365
|
+
storeImportPath?: string | undefined;
|
|
366
|
+
userTypesPath?: string | undefined;
|
|
367
|
+
enums?: Record<string, string[]> | undefined;
|
|
189
368
|
}>;
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
baseRoute: string;
|
|
369
|
+
declare function parseStoreConfig(config: unknown): {
|
|
370
|
+
namespace: string;
|
|
193
371
|
storeImportPath: string;
|
|
194
372
|
tables: Record<string, RequireKeys<RequireKeys<{
|
|
195
|
-
route?: string | undefined;
|
|
196
|
-
dataStruct?: boolean | undefined;
|
|
197
373
|
directory: string;
|
|
198
374
|
tableIdArgument: boolean;
|
|
199
375
|
storeArgument: boolean;
|
|
200
|
-
primaryKeys: Record<string, string
|
|
201
|
-
schema: Record<string, string
|
|
202
|
-
|
|
203
|
-
userTypes: {
|
|
204
|
-
path: string;
|
|
205
|
-
enums: Record<string, string[]>;
|
|
206
|
-
};
|
|
207
|
-
}>;
|
|
208
|
-
type RequireKeys<T extends Record<string, unknown>, P extends string> = T & Required<Pick<T, P>>;
|
|
209
|
-
|
|
210
|
-
declare function loadStoreConfig(configPath?: string): Promise<{
|
|
211
|
-
baseRoute: string;
|
|
212
|
-
storeImportPath: string;
|
|
213
|
-
tables: Record<string, {
|
|
214
|
-
route?: string | undefined;
|
|
376
|
+
primaryKeys: Record<string, string>;
|
|
377
|
+
schema: Record<string, string>;
|
|
378
|
+
fileSelector?: string | undefined;
|
|
215
379
|
dataStruct?: boolean | undefined;
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
380
|
+
}, "dataStruct">, "fileSelector">>;
|
|
381
|
+
userTypesPath: string;
|
|
382
|
+
enums: Record<string, string[]>;
|
|
383
|
+
};
|
|
384
|
+
|
|
385
|
+
type SystemUserConfig = {
|
|
386
|
+
/** The full resource selector consists of namespace and fileSelector */
|
|
387
|
+
fileSelector?: string;
|
|
388
|
+
/**
|
|
389
|
+
* Register function selectors for the system in the World.
|
|
390
|
+
* Defaults to true.
|
|
391
|
+
* Note:
|
|
392
|
+
* - For root systems all World function selectors will correspond to the system's function selectors.
|
|
393
|
+
* - For non-root systems, the World function selectors will be <namespace>_<system>_<function>.
|
|
394
|
+
*/
|
|
395
|
+
registerFunctionSelectors?: boolean;
|
|
396
|
+
} & ({
|
|
397
|
+
/** If openAccess is true, any address can call the system */
|
|
398
|
+
openAccess: true;
|
|
399
|
+
} | {
|
|
400
|
+
/** If openAccess is false, only the addresses or systems in `access` can call the system */
|
|
401
|
+
openAccess: false;
|
|
402
|
+
/** An array of addresses or system names that can access the system */
|
|
403
|
+
accessList: string[];
|
|
404
|
+
});
|
|
405
|
+
type ValueWithType = {
|
|
406
|
+
value: string | number | Uint8Array;
|
|
407
|
+
type: string;
|
|
408
|
+
};
|
|
409
|
+
type ModuleConfig = {
|
|
410
|
+
/** The name of the module */
|
|
411
|
+
name: string;
|
|
412
|
+
/** Should this module be installed as a root module? */
|
|
413
|
+
root?: boolean;
|
|
414
|
+
/** Arguments to be passed to the module's install method */
|
|
415
|
+
args?: (ValueWithType | DynamicResolution)[];
|
|
416
|
+
};
|
|
417
|
+
interface WorldUserConfig {
|
|
418
|
+
/** The namespace to register tables and systems at. Defaults to the root namespace (empty string) */
|
|
419
|
+
namespace?: string;
|
|
420
|
+
/** The name of the World contract to deploy. If no name is provided, a vanilla World is deployed */
|
|
421
|
+
worldContractName?: string;
|
|
422
|
+
/**
|
|
423
|
+
* Contracts named *System will be deployed by default
|
|
424
|
+
* as public systems at `namespace/ContractName`, unless overridden
|
|
425
|
+
*
|
|
426
|
+
* The key is the system name (capitalized).
|
|
427
|
+
* The value is a SystemConfig object.
|
|
428
|
+
*/
|
|
429
|
+
overrideSystems?: Record<string, SystemUserConfig>;
|
|
430
|
+
/** Systems to exclude from automatic deployment */
|
|
431
|
+
excludeSystems?: string[];
|
|
432
|
+
/**
|
|
433
|
+
* Script to execute after the deployment is complete (Default "PostDeploy").
|
|
434
|
+
* Script must be placed in the forge scripts directory (see foundry.toml) and have a ".s.sol" extension.
|
|
435
|
+
*/
|
|
436
|
+
postDeployScript?: string;
|
|
437
|
+
/** Directory to write the deployment info to (Default "./deploys") */
|
|
438
|
+
deploysDirectory?: string;
|
|
439
|
+
/** Directory to output system and world interfaces of `worldgen` (Default "world") */
|
|
440
|
+
worldgenDirectory?: string;
|
|
441
|
+
/** Path for world package imports. Default is "@latticexyz/world/src/" */
|
|
442
|
+
worldImportPath?: string;
|
|
443
|
+
/** Modules to in the World */
|
|
444
|
+
modules?: ModuleConfig[];
|
|
445
|
+
}
|
|
446
|
+
|
|
447
|
+
declare enum DynamicResolutionType {
|
|
448
|
+
TABLE_ID = 0,
|
|
449
|
+
SYSTEM_ADDRESS = 1
|
|
450
|
+
}
|
|
451
|
+
type DynamicResolution = {
|
|
452
|
+
type: DynamicResolutionType;
|
|
453
|
+
input: string;
|
|
454
|
+
};
|
|
455
|
+
/**
|
|
456
|
+
* Dynamically resolve a table name to a table id at deploy time
|
|
457
|
+
*/
|
|
458
|
+
declare function resolveTableId(tableName: string): {
|
|
459
|
+
type: DynamicResolutionType;
|
|
460
|
+
input: string;
|
|
461
|
+
};
|
|
462
|
+
/** Type guard for DynamicResolution */
|
|
463
|
+
declare function isDynamicResolution(value: unknown): value is DynamicResolution;
|
|
464
|
+
/**
|
|
465
|
+
* Turn a DynamicResolution object into a ValueWithType based on the provided context
|
|
466
|
+
*/
|
|
467
|
+
declare function resolveWithContext(unresolved: any, context: {
|
|
468
|
+
systemAddresses?: Record<string, Promise<string>>;
|
|
469
|
+
tableIds?: Record<string, Uint8Array>;
|
|
470
|
+
}): Promise<ValueWithType>;
|
|
471
|
+
|
|
472
|
+
/**
|
|
473
|
+
* Loads and resolves the world config.
|
|
474
|
+
* @param configPath Path to load the config from. Defaults to "mud.config.mts" or "mud.config.ts"
|
|
475
|
+
* @param existingContracts Optional list of existing contract names to validate system names against. If not provided, no validation is performed. Contract names ending in `System` will be added to the config with default values.
|
|
476
|
+
* @returns Promise of ResolvedWorldConfig object
|
|
477
|
+
*/
|
|
478
|
+
declare function loadWorldConfig(configPath?: string, existingContracts?: string[]): Promise<{
|
|
479
|
+
systems: Record<string, {
|
|
480
|
+
fileSelector: string;
|
|
481
|
+
registerFunctionSelectors: boolean;
|
|
482
|
+
openAccess: boolean;
|
|
483
|
+
accessListAddresses: string[];
|
|
484
|
+
accessListSystems: string[];
|
|
485
|
+
}>;
|
|
486
|
+
namespace: string;
|
|
487
|
+
postDeployScript: string;
|
|
488
|
+
deploysDirectory: string;
|
|
489
|
+
worldgenDirectory: string;
|
|
490
|
+
worldImportPath: string;
|
|
491
|
+
modules: {
|
|
492
|
+
name: string;
|
|
493
|
+
root: boolean;
|
|
494
|
+
args: ({
|
|
495
|
+
type: string;
|
|
496
|
+
value: (string | number | Uint8Array) & (string | number | Uint8Array | undefined);
|
|
497
|
+
} | {
|
|
498
|
+
type: DynamicResolutionType;
|
|
499
|
+
input: string;
|
|
500
|
+
})[];
|
|
501
|
+
}[];
|
|
502
|
+
worldContractName?: string | undefined;
|
|
250
503
|
}>;
|
|
251
504
|
|
|
252
|
-
declare const
|
|
253
|
-
|
|
505
|
+
declare const zWorldConfig: z.ZodObject<{
|
|
506
|
+
namespace: z.ZodDefault<z.ZodEffects<z.ZodString, string, string>>;
|
|
254
507
|
worldContractName: z.ZodOptional<z.ZodString>;
|
|
255
508
|
overrideSystems: z.ZodDefault<z.ZodRecord<z.ZodEffects<z.ZodString, string, string>, z.ZodIntersection<z.ZodObject<{
|
|
256
|
-
|
|
509
|
+
fileSelector: z.ZodEffects<z.ZodString, string, string>;
|
|
510
|
+
registerFunctionSelectors: z.ZodDefault<z.ZodBoolean>;
|
|
257
511
|
}, "strip", z.ZodTypeAny, {
|
|
258
|
-
|
|
512
|
+
fileSelector: string;
|
|
513
|
+
registerFunctionSelectors: boolean;
|
|
259
514
|
}, {
|
|
260
|
-
|
|
515
|
+
fileSelector: string;
|
|
516
|
+
registerFunctionSelectors?: boolean | undefined;
|
|
261
517
|
}>, z.ZodDiscriminatedUnion<"openAccess", [z.ZodObject<{
|
|
262
518
|
openAccess: z.ZodLiteral<true>;
|
|
263
519
|
}, "strip", z.ZodTypeAny, {
|
|
@@ -271,17 +527,62 @@ declare const WorldConfig: z.ZodObject<{
|
|
|
271
527
|
openAccess: false;
|
|
272
528
|
accessList: string[];
|
|
273
529
|
}, {
|
|
274
|
-
accessList?: string[] | undefined;
|
|
275
530
|
openAccess: false;
|
|
531
|
+
accessList?: string[] | undefined;
|
|
276
532
|
}>]>>>>;
|
|
277
533
|
excludeSystems: z.ZodDefault<z.ZodArray<z.ZodEffects<z.ZodString, string, string>, "many">>;
|
|
278
534
|
postDeployScript: z.ZodDefault<z.ZodString>;
|
|
279
|
-
|
|
535
|
+
deploysDirectory: z.ZodDefault<z.ZodString>;
|
|
536
|
+
worldgenDirectory: z.ZodDefault<z.ZodString>;
|
|
537
|
+
worldImportPath: z.ZodDefault<z.ZodString>;
|
|
538
|
+
modules: z.ZodDefault<z.ZodArray<z.ZodObject<{
|
|
539
|
+
name: z.ZodEffects<z.ZodString, string, string>;
|
|
540
|
+
root: z.ZodDefault<z.ZodBoolean>;
|
|
541
|
+
args: z.ZodDefault<z.ZodArray<z.ZodUnion<[z.ZodObject<{
|
|
542
|
+
value: z.ZodUnion<[z.ZodString, z.ZodNumber, z.ZodType<Uint8Array, z.ZodTypeDef, Uint8Array>]>;
|
|
543
|
+
type: z.ZodString;
|
|
544
|
+
}, "strip", z.ZodTypeAny, {
|
|
545
|
+
type: string;
|
|
546
|
+
value: (string | number | Uint8Array) & (string | number | Uint8Array | undefined);
|
|
547
|
+
}, {
|
|
548
|
+
type: string;
|
|
549
|
+
value: (string | number | Uint8Array) & (string | number | Uint8Array | undefined);
|
|
550
|
+
}>, z.ZodObject<{
|
|
551
|
+
type: z.ZodNativeEnum<typeof DynamicResolutionType>;
|
|
552
|
+
input: z.ZodString;
|
|
553
|
+
}, "strip", z.ZodTypeAny, {
|
|
554
|
+
type: DynamicResolutionType;
|
|
555
|
+
input: string;
|
|
556
|
+
}, {
|
|
557
|
+
type: DynamicResolutionType;
|
|
558
|
+
input: string;
|
|
559
|
+
}>]>, "many">>;
|
|
560
|
+
}, "strip", z.ZodTypeAny, {
|
|
561
|
+
name: string;
|
|
562
|
+
root: boolean;
|
|
563
|
+
args: ({
|
|
564
|
+
type: string;
|
|
565
|
+
value: (string | number | Uint8Array) & (string | number | Uint8Array | undefined);
|
|
566
|
+
} | {
|
|
567
|
+
type: DynamicResolutionType;
|
|
568
|
+
input: string;
|
|
569
|
+
})[];
|
|
570
|
+
}, {
|
|
571
|
+
name: string;
|
|
572
|
+
root?: boolean | undefined;
|
|
573
|
+
args?: ({
|
|
574
|
+
type: string;
|
|
575
|
+
value: (string | number | Uint8Array) & (string | number | Uint8Array | undefined);
|
|
576
|
+
} | {
|
|
577
|
+
type: DynamicResolutionType;
|
|
578
|
+
input: string;
|
|
579
|
+
})[] | undefined;
|
|
580
|
+
}>, "many">>;
|
|
280
581
|
}, "strip", z.ZodTypeAny, {
|
|
281
|
-
|
|
282
|
-
baseRoute: string;
|
|
582
|
+
namespace: string;
|
|
283
583
|
overrideSystems: Record<string, {
|
|
284
|
-
|
|
584
|
+
fileSelector: string;
|
|
585
|
+
registerFunctionSelectors: boolean;
|
|
285
586
|
} & ({
|
|
286
587
|
openAccess: true;
|
|
287
588
|
} | {
|
|
@@ -290,39 +591,83 @@ declare const WorldConfig: z.ZodObject<{
|
|
|
290
591
|
})>;
|
|
291
592
|
excludeSystems: string[];
|
|
292
593
|
postDeployScript: string;
|
|
293
|
-
|
|
594
|
+
deploysDirectory: string;
|
|
595
|
+
worldgenDirectory: string;
|
|
596
|
+
worldImportPath: string;
|
|
597
|
+
modules: {
|
|
598
|
+
name: string;
|
|
599
|
+
root: boolean;
|
|
600
|
+
args: ({
|
|
601
|
+
type: string;
|
|
602
|
+
value: (string | number | Uint8Array) & (string | number | Uint8Array | undefined);
|
|
603
|
+
} | {
|
|
604
|
+
type: DynamicResolutionType;
|
|
605
|
+
input: string;
|
|
606
|
+
})[];
|
|
607
|
+
}[];
|
|
608
|
+
worldContractName?: string | undefined;
|
|
294
609
|
}, {
|
|
295
|
-
|
|
610
|
+
namespace?: string | undefined;
|
|
296
611
|
worldContractName?: string | undefined;
|
|
297
612
|
overrideSystems?: Record<string, {
|
|
298
|
-
|
|
613
|
+
fileSelector: string;
|
|
614
|
+
registerFunctionSelectors?: boolean | undefined;
|
|
299
615
|
} & ({
|
|
300
616
|
openAccess: true;
|
|
301
617
|
} | {
|
|
302
|
-
accessList?: string[] | undefined;
|
|
303
618
|
openAccess: false;
|
|
619
|
+
accessList?: string[] | undefined;
|
|
304
620
|
})> | undefined;
|
|
305
621
|
excludeSystems?: string[] | undefined;
|
|
306
622
|
postDeployScript?: string | undefined;
|
|
307
|
-
|
|
623
|
+
deploysDirectory?: string | undefined;
|
|
624
|
+
worldgenDirectory?: string | undefined;
|
|
625
|
+
worldImportPath?: string | undefined;
|
|
626
|
+
modules?: {
|
|
627
|
+
name: string;
|
|
628
|
+
root?: boolean | undefined;
|
|
629
|
+
args?: ({
|
|
630
|
+
type: string;
|
|
631
|
+
value: (string | number | Uint8Array) & (string | number | Uint8Array | undefined);
|
|
632
|
+
} | {
|
|
633
|
+
type: DynamicResolutionType;
|
|
634
|
+
input: string;
|
|
635
|
+
})[] | undefined;
|
|
636
|
+
}[] | undefined;
|
|
308
637
|
}>;
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
638
|
+
declare function parseWorldConfig(config: unknown): Promise<{
|
|
639
|
+
namespace: string;
|
|
640
|
+
overrideSystems: Record<string, {
|
|
641
|
+
fileSelector: string;
|
|
642
|
+
registerFunctionSelectors: boolean;
|
|
643
|
+
} & ({
|
|
644
|
+
openAccess: true;
|
|
645
|
+
} | {
|
|
646
|
+
openAccess: false;
|
|
647
|
+
accessList: string[];
|
|
648
|
+
})>;
|
|
649
|
+
excludeSystems: string[];
|
|
650
|
+
postDeployScript: string;
|
|
651
|
+
deploysDirectory: string;
|
|
652
|
+
worldgenDirectory: string;
|
|
653
|
+
worldImportPath: string;
|
|
654
|
+
modules: {
|
|
655
|
+
name: string;
|
|
656
|
+
root: boolean;
|
|
657
|
+
args: ({
|
|
658
|
+
type: string;
|
|
659
|
+
value: (string | number | Uint8Array) & (string | number | Uint8Array | undefined);
|
|
660
|
+
} | {
|
|
661
|
+
type: DynamicResolutionType;
|
|
662
|
+
input: string;
|
|
663
|
+
})[];
|
|
664
|
+
}[];
|
|
665
|
+
worldContractName?: string | undefined;
|
|
666
|
+
}>;
|
|
667
|
+
type ParsedWorldConfig = z.output<typeof zWorldConfig>;
|
|
668
|
+
|
|
669
|
+
type ResolvedSystemConfig = ReturnType<typeof resolveSystemConfig>;
|
|
670
|
+
type ResolvedWorldConfig = ReturnType<typeof resolveWorldConfig>;
|
|
326
671
|
/**
|
|
327
672
|
* Resolves the world config by combining the default and overridden system configs,
|
|
328
673
|
* filtering out excluded systems, validate system names refer to existing contracts, and
|
|
@@ -330,106 +675,68 @@ declare function resolveSystemConfig(systemName: string, config?: SystemUserConf
|
|
|
330
675
|
*/
|
|
331
676
|
declare function resolveWorldConfig(config: ParsedWorldConfig, existingContracts?: string[]): {
|
|
332
677
|
systems: Record<string, {
|
|
333
|
-
|
|
678
|
+
fileSelector: string;
|
|
679
|
+
registerFunctionSelectors: boolean;
|
|
334
680
|
openAccess: boolean;
|
|
335
681
|
accessListAddresses: string[];
|
|
336
682
|
accessListSystems: string[];
|
|
337
683
|
}>;
|
|
338
|
-
|
|
339
|
-
baseRoute: string;
|
|
684
|
+
namespace: string;
|
|
340
685
|
postDeployScript: string;
|
|
341
|
-
|
|
686
|
+
deploysDirectory: string;
|
|
687
|
+
worldgenDirectory: string;
|
|
688
|
+
worldImportPath: string;
|
|
689
|
+
modules: {
|
|
690
|
+
name: string;
|
|
691
|
+
root: boolean;
|
|
692
|
+
args: ({
|
|
693
|
+
type: string;
|
|
694
|
+
value: (string | number | Uint8Array) & (string | number | Uint8Array | undefined);
|
|
695
|
+
} | {
|
|
696
|
+
type: DynamicResolutionType;
|
|
697
|
+
input: string;
|
|
698
|
+
})[];
|
|
699
|
+
}[];
|
|
700
|
+
worldContractName?: string | undefined;
|
|
342
701
|
};
|
|
343
702
|
/**
|
|
344
|
-
*
|
|
345
|
-
* @param
|
|
346
|
-
* @param
|
|
347
|
-
* @
|
|
703
|
+
* Resolves the system config by combining the default and overridden system configs,
|
|
704
|
+
* @param systemName name of the system
|
|
705
|
+
* @param config optional SystemConfig object, if none is provided the default config is used
|
|
706
|
+
* @param existingContracts optional list of existing contract names, used to validate system names in the access list. If not provided, no validation is performed.
|
|
707
|
+
* @returns ResolvedSystemConfig object
|
|
708
|
+
* Default value for fileSelector is `systemName`
|
|
709
|
+
* Default value for registerFunctionSelectors is true
|
|
710
|
+
* Default value for openAccess is true
|
|
711
|
+
* Default value for accessListAddresses is []
|
|
712
|
+
* Default value for accessListSystems is []
|
|
348
713
|
*/
|
|
349
|
-
declare function
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
worldContractName?: string | undefined;
|
|
357
|
-
baseRoute: string;
|
|
358
|
-
postDeployScript: string;
|
|
359
|
-
deploymentInfoDirectory: string;
|
|
360
|
-
}>;
|
|
361
|
-
declare function parseWorldConfig(config: unknown): Promise<{
|
|
362
|
-
worldContractName?: string | undefined;
|
|
363
|
-
baseRoute: string;
|
|
364
|
-
overrideSystems: Record<string, {
|
|
365
|
-
route?: string | undefined;
|
|
366
|
-
} & ({
|
|
367
|
-
openAccess: true;
|
|
368
|
-
} | {
|
|
369
|
-
openAccess: false;
|
|
370
|
-
accessList: string[];
|
|
371
|
-
})>;
|
|
372
|
-
excludeSystems: string[];
|
|
373
|
-
postDeployScript: string;
|
|
374
|
-
deploymentInfoDirectory: string;
|
|
375
|
-
}>;
|
|
376
|
-
type SystemUserConfig = {
|
|
377
|
-
/** The system will be deployed at `baseRoute + route` */
|
|
378
|
-
route?: string;
|
|
379
|
-
} & ({
|
|
380
|
-
/** If openAccess is true, any address can call the system */
|
|
381
|
-
openAccess: true;
|
|
382
|
-
} | {
|
|
383
|
-
/** If openAccess is false, only the addresses or systems in `access` can call the system */
|
|
384
|
-
openAccess: false;
|
|
385
|
-
/** An array of addresses or system names that can access the system */
|
|
386
|
-
accessList: string[];
|
|
387
|
-
});
|
|
388
|
-
interface WorldUserConfig {
|
|
389
|
-
/** The base route to register tables and systems at. Defaults to the root route (empty string) */
|
|
390
|
-
baseRoute?: string;
|
|
391
|
-
/** The name of the World contract to deploy. If no name is provided, a vanilla World is deployed */
|
|
392
|
-
worldContractName?: string;
|
|
393
|
-
/**
|
|
394
|
-
* Contracts named *System will be deployed by default
|
|
395
|
-
* as public systems at `baseRoute/ContractName`, unless overridden
|
|
396
|
-
*
|
|
397
|
-
* The key is the system name (capitalized).
|
|
398
|
-
* The value is a SystemConfig object.
|
|
399
|
-
*/
|
|
400
|
-
overrideSystems?: Record<string, SystemUserConfig>;
|
|
401
|
-
/** Systems to exclude from automatic deployment */
|
|
402
|
-
excludeSystems?: string[];
|
|
403
|
-
/**
|
|
404
|
-
* Script to execute after the deployment is complete (Default "PostDeploy").
|
|
405
|
-
* Script must be placed in the forge scripts directory (see foundry.toml) and have a ".s.sol" extension.
|
|
406
|
-
*/
|
|
407
|
-
postDeployScript?: string;
|
|
408
|
-
/** Directory to write the deployment info to (Default ".") */
|
|
409
|
-
deploymentInfoDirectory?: string;
|
|
410
|
-
}
|
|
411
|
-
type ParsedWorldConfig = z.output<typeof WorldConfig>;
|
|
412
|
-
type ResolvedSystemConfig = ReturnType<typeof resolveSystemConfig>;
|
|
413
|
-
type ResolvedWorldConfig = ReturnType<typeof resolveWorldConfig>;
|
|
714
|
+
declare function resolveSystemConfig(systemName: string, config?: SystemUserConfig, existingContracts?: string[]): {
|
|
715
|
+
fileSelector: string;
|
|
716
|
+
registerFunctionSelectors: boolean;
|
|
717
|
+
openAccess: boolean;
|
|
718
|
+
accessListAddresses: string[];
|
|
719
|
+
accessListSystems: string[];
|
|
720
|
+
};
|
|
414
721
|
|
|
415
722
|
/** Capitalized names of objects, like tables and systems */
|
|
416
|
-
declare const
|
|
723
|
+
declare const zObjectName: z.ZodEffects<z.ZodString, string, string>;
|
|
417
724
|
/** Uncapitalized names of values, like keys and columns */
|
|
418
|
-
declare const
|
|
725
|
+
declare const zValueName: z.ZodEffects<z.ZodString, string, string>;
|
|
419
726
|
/** Name that can start with any case */
|
|
420
|
-
declare const
|
|
727
|
+
declare const zAnyCaseName: z.ZodEffects<z.ZodString, string, string>;
|
|
421
728
|
/** List of unique enum member names and 0 < length < 256 */
|
|
422
|
-
declare const
|
|
729
|
+
declare const zUserEnum: z.ZodEffects<z.ZodArray<z.ZodEffects<z.ZodString, string, string>, "many">, string[], string[]>;
|
|
423
730
|
/** Ordinary routes */
|
|
424
|
-
declare const
|
|
731
|
+
declare const zOrdinaryRoute: z.ZodEffects<z.ZodString, string, string>;
|
|
425
732
|
/** Routes with exactly 1 non-empty level */
|
|
426
|
-
declare const
|
|
733
|
+
declare const zSingleLevelRoute: z.ZodEffects<z.ZodString, string, string>;
|
|
427
734
|
/** Base routes (can be an empty string) */
|
|
428
|
-
declare const
|
|
735
|
+
declare const zBaseRoute: z.ZodEffects<z.ZodString, string, string>;
|
|
429
736
|
/** A valid Ethereum address */
|
|
430
|
-
declare const
|
|
431
|
-
/**
|
|
432
|
-
declare const
|
|
737
|
+
declare const zEthereumAddress: z.ZodEffects<z.ZodString, string, string>;
|
|
738
|
+
/** A selector for namespace/file/resource */
|
|
739
|
+
declare const zSelector: z.ZodEffects<z.ZodString, string, string>;
|
|
433
740
|
|
|
434
741
|
declare function loadConfig(configPath?: string): Promise<unknown>;
|
|
435
742
|
|
|
@@ -442,8 +749,15 @@ declare const validateBaseRoute: (route: string, ctx: RefinementCtx) => void;
|
|
|
442
749
|
declare const validateSingleLevelRoute: (route: string, ctx: RefinementCtx) => void;
|
|
443
750
|
declare function validateEthereumAddress(address: string, ctx: RefinementCtx): void;
|
|
444
751
|
declare function getDuplicates<T>(array: T[]): T[];
|
|
752
|
+
declare function validateSelector(name: string, ctx: RefinementCtx): void;
|
|
753
|
+
/** Returns null if the type does not look like a static array, otherwise element and length data */
|
|
754
|
+
declare function parseStaticArray(abiType: string): {
|
|
755
|
+
elementType: string;
|
|
756
|
+
staticLength: number;
|
|
757
|
+
} | null;
|
|
445
758
|
|
|
446
|
-
type MUDUserConfig = StoreUserConfig & WorldUserConfig;
|
|
759
|
+
type MUDUserConfig<EnumNames extends StringForUnion = StringForUnion, StaticUserTypes extends ExtractUserTypes<EnumNames> = ExtractUserTypes<EnumNames>> = StoreUserConfig<EnumNames, StaticUserTypes> & WorldUserConfig;
|
|
447
760
|
type MUDConfig = StoreConfig & ResolvedWorldConfig;
|
|
761
|
+
declare function mudConfig<EnumNames extends StringForUnion = never, StaticUserTypes extends ExtractUserTypes<EnumNames> = ExtractUserTypes<EnumNames>>(config: MUDUserConfig<EnumNames, StaticUserTypes>): MUDUserConfig<EnumNames, StaticUserTypes>;
|
|
448
762
|
|
|
449
|
-
export {
|
|
763
|
+
export { DynamicResolution, DynamicResolutionType, EnumsConfig, FullSchemaConfig, MUDConfig, MUDUserConfig, ModuleConfig, ParsedWorldConfig, ResolvedSystemConfig, ResolvedWorldConfig, SchemaConfig, ShorthandSchemaConfig, StoreConfig, StoreUserConfig, SystemUserConfig, TableConfig, TablesConfig, ValueWithType, WorldUserConfig, getDuplicates, isDynamicResolution, loadConfig, loadStoreConfig, loadWorldConfig, mudConfig, parseStaticArray, parseStoreConfig, parseWorldConfig, resolveSystemConfig, resolveTableId, resolveWithContext, resolveWorldConfig, storeConfig, validateBaseRoute, validateCapitalizedName, validateEnum, validateEthereumAddress, validateName, validateRoute, validateSelector, validateSingleLevelRoute, validateUncapitalizedName, zAnyCaseName, zBaseRoute, zEnumsConfig, zEthereumAddress, zObjectName, zOrdinaryRoute, zSchemaConfig, zSelector, zSingleLevelRoute, zStoreConfig, zTableConfig, zTablesConfig, zUserEnum, zValueName, zWorldConfig };
|