@latticexyz/cli 2.0.0-alpha.38 → 2.0.0-alpha.4
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-6V563IAZ.js +283 -0
- package/dist/{chunk-ATAWDHWC.js → chunk-FPG73MVN.js} +5 -1
- package/dist/chunk-KJTPZOUH.js +3864 -0
- package/dist/{chunk-O6HOO6WA.js → chunk-L4YLJHLJ.js} +1 -9
- package/dist/{chunk-KPBNUPK6.js → chunk-SKNB74MT.js} +155 -159
- package/dist/chunk-VQTZJIFF.js +353 -0
- package/dist/{chunk-MXDV47JM.js → chunk-WZFXLDPK.js} +75 -24
- package/dist/chunk-YL4GJLLL.js +26139 -0
- package/dist/index.d.ts +2 -4
- package/dist/index.js +0 -22
- package/dist/mud.d.ts +1 -1
- package/dist/mud.js +319 -3972
- package/dist/mud2.d.ts +1 -0
- package/dist/mud2.js +25 -0
- package/dist/render-solidity/index.d.ts +3 -3
- package/dist/render-solidity/index.js +3 -4
- package/dist/render-ts/index.d.ts +2 -3
- package/dist/render-ts/index.js +3 -4
- package/dist/utils/deprecated/index.js +3 -3
- package/dist/utils/index.d.ts +9 -19
- package/dist/utils/index.js +7 -18
- package/package.json +19 -20
- package/src/commands/deploy-v2.ts +80 -64
- package/src/commands/deprecated/index.ts +22 -0
- package/src/commands/deprecated/test.ts +1 -1
- package/src/commands/gas-report.ts +54 -55
- package/src/commands/index.ts +2 -17
- package/src/commands/set-version.ts +39 -10
- package/src/commands/tablegen.ts +5 -5
- package/src/commands/test-v2.ts +71 -0
- package/src/commands/tsgen.ts +1 -1
- package/src/commands/worldgen.ts +5 -4
- package/src/contracts/BulkUpload.sol +13 -20
- package/src/contracts/Deploy.sol +3 -3
- package/src/contracts/LibDeploy.sol +1 -1
- package/src/contracts/LibDeployStub.sol +1 -1
- package/src/index.ts +1 -15
- package/src/mud.ts +4 -3
- package/src/mud2.ts +29 -0
- package/src/render-solidity/common.ts +4 -4
- package/src/render-solidity/field.ts +25 -2
- package/src/render-solidity/record.ts +14 -10
- package/src/render-solidity/renderSystemInterface.ts +4 -4
- package/src/render-solidity/renderTableIndex.ts +15 -0
- package/src/render-solidity/renderTypesFromConfig.ts +1 -1
- package/src/render-solidity/tableOptions.ts +2 -2
- package/src/render-solidity/tablegen.ts +13 -1
- package/src/render-solidity/types.ts +2 -1
- package/src/render-solidity/userType.ts +1 -2
- package/src/render-solidity/worldgen.ts +5 -6
- package/src/render-ts/recsV1TableOptions.ts +2 -2
- package/src/render-ts/renderRecsV1Tables.ts +2 -2
- package/src/render-ts/schemaTypesToRecsTypeStrings.ts +136 -136
- package/src/render-ts/tsgen.ts +1 -1
- package/src/render-ts/types.ts +1 -1
- package/src/utils/contractToInterface.ts +5 -3
- package/src/utils/deploy-v2.ts +90 -84
- package/src/utils/errors.ts +3 -34
- package/src/utils/foundry.ts +9 -0
- package/dist/chunk-3FLNCDSC.js +0 -22908
- package/dist/chunk-5NC2OON2.js +0 -164
- package/dist/chunk-7GA2K5A6.js +0 -283
- package/dist/chunk-SLIMIO4Z.js +0 -14358
- package/dist/chunk-UN37BCLQ.js +0 -453
- package/dist/config/index.d.ts +0 -400
- package/dist/config/index.js +0 -85
- package/dist/parseStoreConfig-899f574e.d.ts +0 -369
- package/src/config/commonSchemas.ts +0 -34
- package/src/config/dynamicResolution.ts +0 -49
- package/src/config/index.ts +0 -24
- package/src/config/loadConfig.ts +0 -39
- package/src/config/loadStoreConfig.ts +0 -18
- package/src/config/parseStoreConfig.test-d.ts +0 -40
- package/src/config/parseStoreConfig.ts +0 -314
- package/src/config/validation.ts +0 -163
- package/src/config/world/index.ts +0 -4
- package/src/config/world/loadWorldConfig.test-d.ts +0 -11
- package/src/config/world/loadWorldConfig.ts +0 -26
- package/src/config/world/parseWorldConfig.ts +0 -55
- package/src/config/world/resolveWorldConfig.ts +0 -80
- package/src/config/world/userTypes.ts +0 -72
- package/src/utils/typeUtils.ts +0 -17
|
@@ -41,8 +41,6 @@ export function renderFieldMethods(options: RenderTableOptions) {
|
|
|
41
41
|
`
|
|
42
42
|
);
|
|
43
43
|
|
|
44
|
-
// TODO: this is super inefficient right now, need to add support for pushing to arrays to the store core library to avoid reading/writing the entire array
|
|
45
|
-
// (see https://github.com/latticexyz/mud/issues/438)
|
|
46
44
|
if (field.isDynamic) {
|
|
47
45
|
const portionData = fieldPortionData(field);
|
|
48
46
|
|
|
@@ -61,6 +59,29 @@ export function renderFieldMethods(options: RenderTableOptions) {
|
|
|
61
59
|
}
|
|
62
60
|
`
|
|
63
61
|
);
|
|
62
|
+
|
|
63
|
+
result += renderWithStore(
|
|
64
|
+
storeArgument,
|
|
65
|
+
(_typedStore, _store, _commentSuffix) => `
|
|
66
|
+
/** Update ${portionData.title} of ${field.name}${_commentSuffix} at \`_index\` */
|
|
67
|
+
function update${field.methodNameSuffix}(${renderArguments([
|
|
68
|
+
_typedStore,
|
|
69
|
+
_typedTableId,
|
|
70
|
+
_typedKeyArgs,
|
|
71
|
+
"uint256 _index",
|
|
72
|
+
`${portionData.typeWithLocation} ${portionData.name}`,
|
|
73
|
+
])}) internal {
|
|
74
|
+
${_primaryKeysDefinition}
|
|
75
|
+
${_store}.updateInField(
|
|
76
|
+
_tableId,
|
|
77
|
+
_primaryKeys,
|
|
78
|
+
${index},
|
|
79
|
+
_index * ${portionData.elementLength},
|
|
80
|
+
${portionData.encoded}
|
|
81
|
+
);
|
|
82
|
+
}
|
|
83
|
+
`
|
|
84
|
+
);
|
|
64
85
|
}
|
|
65
86
|
}
|
|
66
87
|
return result;
|
|
@@ -109,6 +130,7 @@ function fieldPortionData(field: RenderTableField) {
|
|
|
109
130
|
name: "_element",
|
|
110
131
|
encoded: renderEncodeField({ ...field.arrayElement, arrayElement: undefined, name, methodNameSuffix }),
|
|
111
132
|
title: "an element",
|
|
133
|
+
elementLength: field.arrayElement.staticByteLength,
|
|
112
134
|
};
|
|
113
135
|
} else {
|
|
114
136
|
const name = "_slice";
|
|
@@ -117,6 +139,7 @@ function fieldPortionData(field: RenderTableField) {
|
|
|
117
139
|
name,
|
|
118
140
|
encoded: renderEncodeField({ ...field, name, methodNameSuffix }),
|
|
119
141
|
title: "a slice",
|
|
142
|
+
elementLength: 1,
|
|
120
143
|
};
|
|
121
144
|
}
|
|
122
145
|
}
|
|
@@ -99,16 +99,20 @@ function renderDecodeFunction({ structName, fields, staticFields, dynamicFields
|
|
|
99
99
|
${fieldNamePrefix}${field.name} = ${renderDecodeValueType(field, staticOffsets[index])};
|
|
100
100
|
`
|
|
101
101
|
)}
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
102
|
+
// Store trims the blob if dynamic fields are all empty
|
|
103
|
+
if (_blob.length > ${totalStaticLength}) {
|
|
104
|
+
uint256 _start;
|
|
105
|
+
// skip static data length + dynamic lengths word
|
|
106
|
+
uint256 _end = ${totalStaticLength + 32};
|
|
107
|
+
${renderList(
|
|
108
|
+
dynamicFields,
|
|
109
|
+
(field, index) => `
|
|
110
|
+
_start = _end;
|
|
111
|
+
_end += _encodedLengths.atIndex(${index});
|
|
112
|
+
${fieldNamePrefix}${field.name} = ${renderDecodeDynamicFieldPartial(field)};
|
|
113
|
+
`
|
|
114
|
+
)}
|
|
115
|
+
}
|
|
112
116
|
}
|
|
113
117
|
`;
|
|
114
118
|
} else {
|
|
@@ -11,10 +11,10 @@ ${renderImports(imports)}
|
|
|
11
11
|
interface ${name} {
|
|
12
12
|
${renderList(
|
|
13
13
|
functions,
|
|
14
|
-
({ name, parameters, returnParameters }) => `
|
|
15
|
-
function ${functionPrefix}${name}(
|
|
16
|
-
|
|
17
|
-
)};
|
|
14
|
+
({ name, parameters, stateMutability, returnParameters }) => `
|
|
15
|
+
function ${functionPrefix}${name}(
|
|
16
|
+
${renderArguments(parameters)}
|
|
17
|
+
) external ${stateMutability} ${renderReturnParameters(returnParameters)};
|
|
18
18
|
`
|
|
19
19
|
)}
|
|
20
20
|
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { renderList, renderedSolidityHeader } from "./common.js";
|
|
2
|
+
import { TableOptions } from "./tableOptions.js";
|
|
3
|
+
|
|
4
|
+
export function renderTableIndex(options: TableOptions[]) {
|
|
5
|
+
return `${renderedSolidityHeader}
|
|
6
|
+
|
|
7
|
+
${renderList(options, ({ outputPath, tableName, renderOptions: { structName, staticResourceData } }) => {
|
|
8
|
+
const imports = [tableName];
|
|
9
|
+
if (structName) imports.push(structName);
|
|
10
|
+
if (staticResourceData) imports.push(`${tableName}TableId`);
|
|
11
|
+
|
|
12
|
+
return `import { ${imports.join(", ")} } from "./${outputPath}";`;
|
|
13
|
+
})}
|
|
14
|
+
`;
|
|
15
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import path from "path";
|
|
2
2
|
import { SchemaTypeArrayToElement } from "@latticexyz/schema-type";
|
|
3
|
-
import { StoreConfig } from "
|
|
3
|
+
import { StoreConfig } from "@latticexyz/config";
|
|
4
4
|
import {
|
|
5
5
|
ImportDatum,
|
|
6
6
|
RenderTableDynamicField,
|
|
@@ -80,7 +80,7 @@ export function getTableOptions(config: StoreConfig): TableOptions[] {
|
|
|
80
80
|
return {
|
|
81
81
|
tableIdName: tableName + "TableId",
|
|
82
82
|
namespace: config.namespace,
|
|
83
|
-
|
|
83
|
+
name: tableData.name,
|
|
84
84
|
};
|
|
85
85
|
}
|
|
86
86
|
})();
|
|
@@ -1,12 +1,20 @@
|
|
|
1
1
|
import path from "path";
|
|
2
|
-
import { StoreConfig } from "
|
|
2
|
+
import { StoreConfig } from "@latticexyz/config";
|
|
3
3
|
import { getTableOptions } from "./tableOptions.js";
|
|
4
4
|
import { renderTable } from "./renderTable.js";
|
|
5
5
|
import { renderTypesFromConfig } from "./renderTypesFromConfig.js";
|
|
6
6
|
import { formatAndWriteSolidity } from "../utils/formatAndWrite.js";
|
|
7
|
+
import { renderTableIndex } from "./renderTableIndex.js";
|
|
8
|
+
import { rmSync } from "fs";
|
|
7
9
|
|
|
8
10
|
export async function tablegen(config: StoreConfig, outputBaseDirectory: string) {
|
|
9
11
|
const allTableOptions = getTableOptions(config);
|
|
12
|
+
|
|
13
|
+
const uniqueTableDirectories = new Set(allTableOptions.map(({ outputPath }) => path.dirname(outputPath)));
|
|
14
|
+
for (const tableDir of uniqueTableDirectories) {
|
|
15
|
+
rmSync(path.join(outputBaseDirectory, tableDir), { recursive: true, force: true });
|
|
16
|
+
}
|
|
17
|
+
|
|
10
18
|
// write tables to files
|
|
11
19
|
for (const { outputPath, renderOptions } of allTableOptions) {
|
|
12
20
|
const fullOutputPath = path.join(outputBaseDirectory, outputPath);
|
|
@@ -20,4 +28,8 @@ export async function tablegen(config: StoreConfig, outputBaseDirectory: string)
|
|
|
20
28
|
const output = renderTypesFromConfig(config);
|
|
21
29
|
formatAndWriteSolidity(output, fullOutputPath, "Generated types file");
|
|
22
30
|
}
|
|
31
|
+
|
|
32
|
+
const fullOutputPath = path.join(outputBaseDirectory, `Tables.sol`);
|
|
33
|
+
const output = renderTableIndex(allTableOptions);
|
|
34
|
+
formatAndWriteSolidity(output, fullOutputPath, "Generated table index");
|
|
23
35
|
}
|
|
@@ -29,7 +29,7 @@ export interface StaticResourceData {
|
|
|
29
29
|
/** Name of the table id constant to render. */
|
|
30
30
|
tableIdName: string;
|
|
31
31
|
namespace: string;
|
|
32
|
-
|
|
32
|
+
name: string;
|
|
33
33
|
}
|
|
34
34
|
|
|
35
35
|
export interface RenderTableType {
|
|
@@ -95,6 +95,7 @@ export interface RenderSystemInterfaceOptions {
|
|
|
95
95
|
export interface RenderSystemInterfaceFunction {
|
|
96
96
|
name: string;
|
|
97
97
|
parameters: string[];
|
|
98
|
+
stateMutability: string;
|
|
98
99
|
returnParameters: string[];
|
|
99
100
|
}
|
|
100
101
|
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { AbiTypeToSchemaType, getStaticByteLength, SchemaType, SchemaTypeToAbiType } from "@latticexyz/schema-type";
|
|
2
|
-
import { StoreConfig } from "
|
|
2
|
+
import { StoreConfig, parseStaticArray } from "@latticexyz/config";
|
|
3
3
|
import { ImportDatum, RenderTableType } from "./types.js";
|
|
4
|
-
import { parseStaticArray } from "../config/validation.js";
|
|
5
4
|
|
|
6
5
|
export type UserTypeInfo = ReturnType<typeof getUserTypeInfo>;
|
|
7
6
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { readFileSync } from "fs";
|
|
2
2
|
import path from "path";
|
|
3
|
-
import { MUDConfig } from "
|
|
3
|
+
import { MUDConfig } from "@latticexyz/config";
|
|
4
4
|
import { contractToInterface } from "../utils/contractToInterface.js";
|
|
5
5
|
import { formatAndWriteSolidity } from "../utils/formatAndWrite.js";
|
|
6
6
|
import { renderSystemInterface } from "./renderSystemInterface.js";
|
|
@@ -27,10 +27,10 @@ export async function worldgen(
|
|
|
27
27
|
}));
|
|
28
28
|
const systemInterfaceName = `I${system.basename}`;
|
|
29
29
|
// create an interface using the external functions and imports
|
|
30
|
-
const {
|
|
30
|
+
const { name } = config.systems[system.basename];
|
|
31
31
|
const output = renderSystemInterface({
|
|
32
32
|
name: systemInterfaceName,
|
|
33
|
-
functionPrefix: config.namespace === "" ? "" : `${config.namespace}_${
|
|
33
|
+
functionPrefix: config.namespace === "" ? "" : `${config.namespace}_${name}_`,
|
|
34
34
|
functions,
|
|
35
35
|
imports,
|
|
36
36
|
});
|
|
@@ -47,14 +47,13 @@ export async function worldgen(
|
|
|
47
47
|
}
|
|
48
48
|
|
|
49
49
|
// render IWorld
|
|
50
|
-
const worldInterfaceName = "IWorld";
|
|
51
50
|
const output = renderWorld({
|
|
52
|
-
interfaceName: worldInterfaceName,
|
|
51
|
+
interfaceName: config.worldInterfaceName,
|
|
53
52
|
imports: systemInterfaceImports,
|
|
54
53
|
storeImportPath: config.storeImportPath,
|
|
55
54
|
worldImportPath: config.worldImportPath,
|
|
56
55
|
});
|
|
57
56
|
// write to file
|
|
58
|
-
const fullOutputPath = path.join(worldgenBaseDirectory, worldInterfaceName + ".sol");
|
|
57
|
+
const fullOutputPath = path.join(worldgenBaseDirectory, config.worldInterfaceName + ".sol");
|
|
59
58
|
await formatAndWriteSolidity(output, fullOutputPath, "Generated system interface");
|
|
60
59
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { StoreConfig } from "
|
|
1
|
+
import { StoreConfig } from "@latticexyz/config";
|
|
2
2
|
import { resolveAbiOrUserType } from "../render-solidity/userType.js";
|
|
3
3
|
import { schemaTypesToRecsTypeStrings } from "./schemaTypesToRecsTypeStrings.js";
|
|
4
4
|
import { RecsV1TableOptions } from "./types.js";
|
|
@@ -24,7 +24,7 @@ export function getRecsV1TableOptions(config: StoreConfig): RecsV1TableOptions {
|
|
|
24
24
|
if (tableData.tableIdArgument) continue;
|
|
25
25
|
const staticResourceData = {
|
|
26
26
|
namespace: config.namespace,
|
|
27
|
-
|
|
27
|
+
name: tableData.name,
|
|
28
28
|
};
|
|
29
29
|
|
|
30
30
|
tableOptions.push({
|
|
@@ -17,10 +17,10 @@ export function defineContractComponents(world: World) {
|
|
|
17
17
|
}
|
|
18
18
|
|
|
19
19
|
function renderDefineComponent(table: RecsV1TableOptions["tables"][number]) {
|
|
20
|
-
const { namespace,
|
|
20
|
+
const { namespace, name } = table.staticResourceData;
|
|
21
21
|
return `
|
|
22
22
|
(() => {
|
|
23
|
-
const tableId = new TableId("${namespace}", "${
|
|
23
|
+
const tableId = new TableId("${namespace}", "${name}");
|
|
24
24
|
return defineComponent(world, {
|
|
25
25
|
${table.fields.map(({ name, recsTypeString }) => `${name}: ${recsTypeString},`).join("")}
|
|
26
26
|
}, {
|
|
@@ -7,64 +7,64 @@ export const schemaTypesToRecsTypeStrings: Record<SchemaType, string> = {
|
|
|
7
7
|
[SchemaType.UINT32]: "RecsType.Number",
|
|
8
8
|
[SchemaType.UINT40]: "RecsType.Number",
|
|
9
9
|
[SchemaType.UINT48]: "RecsType.Number",
|
|
10
|
-
[SchemaType.UINT56]: "RecsType.
|
|
11
|
-
[SchemaType.UINT64]: "RecsType.
|
|
12
|
-
[SchemaType.UINT72]: "RecsType.
|
|
13
|
-
[SchemaType.UINT80]: "RecsType.
|
|
14
|
-
[SchemaType.UINT88]: "RecsType.
|
|
15
|
-
[SchemaType.UINT96]: "RecsType.
|
|
16
|
-
[SchemaType.UINT104]: "RecsType.
|
|
17
|
-
[SchemaType.UINT112]: "RecsType.
|
|
18
|
-
[SchemaType.UINT120]: "RecsType.
|
|
19
|
-
[SchemaType.UINT128]: "RecsType.
|
|
20
|
-
[SchemaType.UINT136]: "RecsType.
|
|
21
|
-
[SchemaType.UINT144]: "RecsType.
|
|
22
|
-
[SchemaType.UINT152]: "RecsType.
|
|
23
|
-
[SchemaType.UINT160]: "RecsType.
|
|
24
|
-
[SchemaType.UINT168]: "RecsType.
|
|
25
|
-
[SchemaType.UINT176]: "RecsType.
|
|
26
|
-
[SchemaType.UINT184]: "RecsType.
|
|
27
|
-
[SchemaType.UINT192]: "RecsType.
|
|
28
|
-
[SchemaType.UINT200]: "RecsType.
|
|
29
|
-
[SchemaType.UINT208]: "RecsType.
|
|
30
|
-
[SchemaType.UINT216]: "RecsType.
|
|
31
|
-
[SchemaType.UINT224]: "RecsType.
|
|
32
|
-
[SchemaType.UINT232]: "RecsType.
|
|
33
|
-
[SchemaType.UINT240]: "RecsType.
|
|
34
|
-
[SchemaType.UINT248]: "RecsType.
|
|
35
|
-
[SchemaType.UINT256]: "RecsType.
|
|
10
|
+
[SchemaType.UINT56]: "RecsType.BigInt",
|
|
11
|
+
[SchemaType.UINT64]: "RecsType.BigInt",
|
|
12
|
+
[SchemaType.UINT72]: "RecsType.BigInt",
|
|
13
|
+
[SchemaType.UINT80]: "RecsType.BigInt",
|
|
14
|
+
[SchemaType.UINT88]: "RecsType.BigInt",
|
|
15
|
+
[SchemaType.UINT96]: "RecsType.BigInt",
|
|
16
|
+
[SchemaType.UINT104]: "RecsType.BigInt",
|
|
17
|
+
[SchemaType.UINT112]: "RecsType.BigInt",
|
|
18
|
+
[SchemaType.UINT120]: "RecsType.BigInt",
|
|
19
|
+
[SchemaType.UINT128]: "RecsType.BigInt",
|
|
20
|
+
[SchemaType.UINT136]: "RecsType.BigInt",
|
|
21
|
+
[SchemaType.UINT144]: "RecsType.BigInt",
|
|
22
|
+
[SchemaType.UINT152]: "RecsType.BigInt",
|
|
23
|
+
[SchemaType.UINT160]: "RecsType.BigInt",
|
|
24
|
+
[SchemaType.UINT168]: "RecsType.BigInt",
|
|
25
|
+
[SchemaType.UINT176]: "RecsType.BigInt",
|
|
26
|
+
[SchemaType.UINT184]: "RecsType.BigInt",
|
|
27
|
+
[SchemaType.UINT192]: "RecsType.BigInt",
|
|
28
|
+
[SchemaType.UINT200]: "RecsType.BigInt",
|
|
29
|
+
[SchemaType.UINT208]: "RecsType.BigInt",
|
|
30
|
+
[SchemaType.UINT216]: "RecsType.BigInt",
|
|
31
|
+
[SchemaType.UINT224]: "RecsType.BigInt",
|
|
32
|
+
[SchemaType.UINT232]: "RecsType.BigInt",
|
|
33
|
+
[SchemaType.UINT240]: "RecsType.BigInt",
|
|
34
|
+
[SchemaType.UINT248]: "RecsType.BigInt",
|
|
35
|
+
[SchemaType.UINT256]: "RecsType.BigInt",
|
|
36
36
|
[SchemaType.INT8]: "RecsType.Number",
|
|
37
37
|
[SchemaType.INT16]: "RecsType.Number",
|
|
38
38
|
[SchemaType.INT24]: "RecsType.Number",
|
|
39
39
|
[SchemaType.INT32]: "RecsType.Number",
|
|
40
40
|
[SchemaType.INT40]: "RecsType.Number",
|
|
41
41
|
[SchemaType.INT48]: "RecsType.Number",
|
|
42
|
-
[SchemaType.INT56]: "RecsType.
|
|
43
|
-
[SchemaType.INT64]: "RecsType.
|
|
44
|
-
[SchemaType.INT72]: "RecsType.
|
|
45
|
-
[SchemaType.INT80]: "RecsType.
|
|
46
|
-
[SchemaType.INT88]: "RecsType.
|
|
47
|
-
[SchemaType.INT96]: "RecsType.
|
|
48
|
-
[SchemaType.INT104]: "RecsType.
|
|
49
|
-
[SchemaType.INT112]: "RecsType.
|
|
50
|
-
[SchemaType.INT120]: "RecsType.
|
|
51
|
-
[SchemaType.INT128]: "RecsType.
|
|
52
|
-
[SchemaType.INT136]: "RecsType.
|
|
53
|
-
[SchemaType.INT144]: "RecsType.
|
|
54
|
-
[SchemaType.INT152]: "RecsType.
|
|
55
|
-
[SchemaType.INT160]: "RecsType.
|
|
56
|
-
[SchemaType.INT168]: "RecsType.
|
|
57
|
-
[SchemaType.INT176]: "RecsType.
|
|
58
|
-
[SchemaType.INT184]: "RecsType.
|
|
59
|
-
[SchemaType.INT192]: "RecsType.
|
|
60
|
-
[SchemaType.INT200]: "RecsType.
|
|
61
|
-
[SchemaType.INT208]: "RecsType.
|
|
62
|
-
[SchemaType.INT216]: "RecsType.
|
|
63
|
-
[SchemaType.INT224]: "RecsType.
|
|
64
|
-
[SchemaType.INT232]: "RecsType.
|
|
65
|
-
[SchemaType.INT240]: "RecsType.
|
|
66
|
-
[SchemaType.INT248]: "RecsType.
|
|
67
|
-
[SchemaType.INT256]: "RecsType.
|
|
42
|
+
[SchemaType.INT56]: "RecsType.BigInt",
|
|
43
|
+
[SchemaType.INT64]: "RecsType.BigInt",
|
|
44
|
+
[SchemaType.INT72]: "RecsType.BigInt",
|
|
45
|
+
[SchemaType.INT80]: "RecsType.BigInt",
|
|
46
|
+
[SchemaType.INT88]: "RecsType.BigInt",
|
|
47
|
+
[SchemaType.INT96]: "RecsType.BigInt",
|
|
48
|
+
[SchemaType.INT104]: "RecsType.BigInt",
|
|
49
|
+
[SchemaType.INT112]: "RecsType.BigInt",
|
|
50
|
+
[SchemaType.INT120]: "RecsType.BigInt",
|
|
51
|
+
[SchemaType.INT128]: "RecsType.BigInt",
|
|
52
|
+
[SchemaType.INT136]: "RecsType.BigInt",
|
|
53
|
+
[SchemaType.INT144]: "RecsType.BigInt",
|
|
54
|
+
[SchemaType.INT152]: "RecsType.BigInt",
|
|
55
|
+
[SchemaType.INT160]: "RecsType.BigInt",
|
|
56
|
+
[SchemaType.INT168]: "RecsType.BigInt",
|
|
57
|
+
[SchemaType.INT176]: "RecsType.BigInt",
|
|
58
|
+
[SchemaType.INT184]: "RecsType.BigInt",
|
|
59
|
+
[SchemaType.INT192]: "RecsType.BigInt",
|
|
60
|
+
[SchemaType.INT200]: "RecsType.BigInt",
|
|
61
|
+
[SchemaType.INT208]: "RecsType.BigInt",
|
|
62
|
+
[SchemaType.INT216]: "RecsType.BigInt",
|
|
63
|
+
[SchemaType.INT224]: "RecsType.BigInt",
|
|
64
|
+
[SchemaType.INT232]: "RecsType.BigInt",
|
|
65
|
+
[SchemaType.INT240]: "RecsType.BigInt",
|
|
66
|
+
[SchemaType.INT248]: "RecsType.BigInt",
|
|
67
|
+
[SchemaType.INT256]: "RecsType.BigInt",
|
|
68
68
|
[SchemaType.BYTES1]: "RecsType.String",
|
|
69
69
|
[SchemaType.BYTES2]: "RecsType.String",
|
|
70
70
|
[SchemaType.BYTES3]: "RecsType.String",
|
|
@@ -105,96 +105,96 @@ export const schemaTypesToRecsTypeStrings: Record<SchemaType, string> = {
|
|
|
105
105
|
[SchemaType.UINT32_ARRAY]: "RecsType.NumberArray",
|
|
106
106
|
[SchemaType.UINT40_ARRAY]: "RecsType.NumberArray",
|
|
107
107
|
[SchemaType.UINT48_ARRAY]: "RecsType.NumberArray",
|
|
108
|
-
[SchemaType.UINT56_ARRAY]: "RecsType.
|
|
109
|
-
[SchemaType.UINT64_ARRAY]: "RecsType.
|
|
110
|
-
[SchemaType.UINT72_ARRAY]: "RecsType.
|
|
111
|
-
[SchemaType.UINT80_ARRAY]: "RecsType.
|
|
112
|
-
[SchemaType.UINT88_ARRAY]: "RecsType.
|
|
113
|
-
[SchemaType.UINT96_ARRAY]: "RecsType.
|
|
114
|
-
[SchemaType.UINT104_ARRAY]: "RecsType.
|
|
115
|
-
[SchemaType.UINT112_ARRAY]: "RecsType.
|
|
116
|
-
[SchemaType.UINT120_ARRAY]: "RecsType.
|
|
117
|
-
[SchemaType.UINT128_ARRAY]: "RecsType.
|
|
118
|
-
[SchemaType.UINT136_ARRAY]: "RecsType.
|
|
119
|
-
[SchemaType.UINT144_ARRAY]: "RecsType.
|
|
120
|
-
[SchemaType.UINT152_ARRAY]: "RecsType.
|
|
121
|
-
[SchemaType.UINT160_ARRAY]: "RecsType.
|
|
122
|
-
[SchemaType.UINT168_ARRAY]: "RecsType.
|
|
123
|
-
[SchemaType.UINT176_ARRAY]: "RecsType.
|
|
124
|
-
[SchemaType.UINT184_ARRAY]: "RecsType.
|
|
125
|
-
[SchemaType.UINT192_ARRAY]: "RecsType.
|
|
126
|
-
[SchemaType.UINT200_ARRAY]: "RecsType.
|
|
127
|
-
[SchemaType.UINT208_ARRAY]: "RecsType.
|
|
128
|
-
[SchemaType.UINT216_ARRAY]: "RecsType.
|
|
129
|
-
[SchemaType.UINT224_ARRAY]: "RecsType.
|
|
130
|
-
[SchemaType.UINT232_ARRAY]: "RecsType.
|
|
131
|
-
[SchemaType.UINT240_ARRAY]: "RecsType.
|
|
132
|
-
[SchemaType.UINT248_ARRAY]: "RecsType.
|
|
133
|
-
[SchemaType.UINT256_ARRAY]: "RecsType.
|
|
108
|
+
[SchemaType.UINT56_ARRAY]: "RecsType.BigIntArray",
|
|
109
|
+
[SchemaType.UINT64_ARRAY]: "RecsType.BigIntArray",
|
|
110
|
+
[SchemaType.UINT72_ARRAY]: "RecsType.BigIntArray",
|
|
111
|
+
[SchemaType.UINT80_ARRAY]: "RecsType.BigIntArray",
|
|
112
|
+
[SchemaType.UINT88_ARRAY]: "RecsType.BigIntArray",
|
|
113
|
+
[SchemaType.UINT96_ARRAY]: "RecsType.BigIntArray",
|
|
114
|
+
[SchemaType.UINT104_ARRAY]: "RecsType.BigIntArray",
|
|
115
|
+
[SchemaType.UINT112_ARRAY]: "RecsType.BigIntArray",
|
|
116
|
+
[SchemaType.UINT120_ARRAY]: "RecsType.BigIntArray",
|
|
117
|
+
[SchemaType.UINT128_ARRAY]: "RecsType.BigIntArray",
|
|
118
|
+
[SchemaType.UINT136_ARRAY]: "RecsType.BigIntArray",
|
|
119
|
+
[SchemaType.UINT144_ARRAY]: "RecsType.BigIntArray",
|
|
120
|
+
[SchemaType.UINT152_ARRAY]: "RecsType.BigIntArray",
|
|
121
|
+
[SchemaType.UINT160_ARRAY]: "RecsType.BigIntArray",
|
|
122
|
+
[SchemaType.UINT168_ARRAY]: "RecsType.BigIntArray",
|
|
123
|
+
[SchemaType.UINT176_ARRAY]: "RecsType.BigIntArray",
|
|
124
|
+
[SchemaType.UINT184_ARRAY]: "RecsType.BigIntArray",
|
|
125
|
+
[SchemaType.UINT192_ARRAY]: "RecsType.BigIntArray",
|
|
126
|
+
[SchemaType.UINT200_ARRAY]: "RecsType.BigIntArray",
|
|
127
|
+
[SchemaType.UINT208_ARRAY]: "RecsType.BigIntArray",
|
|
128
|
+
[SchemaType.UINT216_ARRAY]: "RecsType.BigIntArray",
|
|
129
|
+
[SchemaType.UINT224_ARRAY]: "RecsType.BigIntArray",
|
|
130
|
+
[SchemaType.UINT232_ARRAY]: "RecsType.BigIntArray",
|
|
131
|
+
[SchemaType.UINT240_ARRAY]: "RecsType.BigIntArray",
|
|
132
|
+
[SchemaType.UINT248_ARRAY]: "RecsType.BigIntArray",
|
|
133
|
+
[SchemaType.UINT256_ARRAY]: "RecsType.BigIntArray",
|
|
134
134
|
[SchemaType.INT8_ARRAY]: "RecsType.NumberArray",
|
|
135
135
|
[SchemaType.INT16_ARRAY]: "RecsType.NumberArray",
|
|
136
136
|
[SchemaType.INT24_ARRAY]: "RecsType.NumberArray",
|
|
137
137
|
[SchemaType.INT32_ARRAY]: "RecsType.NumberArray",
|
|
138
138
|
[SchemaType.INT40_ARRAY]: "RecsType.NumberArray",
|
|
139
139
|
[SchemaType.INT48_ARRAY]: "RecsType.NumberArray",
|
|
140
|
-
[SchemaType.INT56_ARRAY]: "RecsType.
|
|
141
|
-
[SchemaType.INT64_ARRAY]: "RecsType.
|
|
142
|
-
[SchemaType.INT72_ARRAY]: "RecsType.
|
|
143
|
-
[SchemaType.INT80_ARRAY]: "RecsType.
|
|
144
|
-
[SchemaType.INT88_ARRAY]: "RecsType.
|
|
145
|
-
[SchemaType.INT96_ARRAY]: "RecsType.
|
|
146
|
-
[SchemaType.INT104_ARRAY]: "RecsType.
|
|
147
|
-
[SchemaType.INT112_ARRAY]: "RecsType.
|
|
148
|
-
[SchemaType.INT120_ARRAY]: "RecsType.
|
|
149
|
-
[SchemaType.INT128_ARRAY]: "RecsType.
|
|
150
|
-
[SchemaType.INT136_ARRAY]: "RecsType.
|
|
151
|
-
[SchemaType.INT144_ARRAY]: "RecsType.
|
|
152
|
-
[SchemaType.INT152_ARRAY]: "RecsType.
|
|
153
|
-
[SchemaType.INT160_ARRAY]: "RecsType.
|
|
154
|
-
[SchemaType.INT168_ARRAY]: "RecsType.
|
|
155
|
-
[SchemaType.INT176_ARRAY]: "RecsType.
|
|
156
|
-
[SchemaType.INT184_ARRAY]: "RecsType.
|
|
157
|
-
[SchemaType.INT192_ARRAY]: "RecsType.
|
|
158
|
-
[SchemaType.INT200_ARRAY]: "RecsType.
|
|
159
|
-
[SchemaType.INT208_ARRAY]: "RecsType.
|
|
160
|
-
[SchemaType.INT216_ARRAY]: "RecsType.
|
|
161
|
-
[SchemaType.INT224_ARRAY]: "RecsType.
|
|
162
|
-
[SchemaType.INT232_ARRAY]: "RecsType.
|
|
163
|
-
[SchemaType.INT240_ARRAY]: "RecsType.
|
|
164
|
-
[SchemaType.INT248_ARRAY]: "RecsType.
|
|
165
|
-
[SchemaType.INT256_ARRAY]: "RecsType.
|
|
166
|
-
[SchemaType.BYTES1_ARRAY]: "RecsType.
|
|
167
|
-
[SchemaType.BYTES2_ARRAY]: "RecsType.
|
|
168
|
-
[SchemaType.BYTES3_ARRAY]: "RecsType.
|
|
169
|
-
[SchemaType.BYTES4_ARRAY]: "RecsType.
|
|
170
|
-
[SchemaType.BYTES5_ARRAY]: "RecsType.
|
|
171
|
-
[SchemaType.BYTES6_ARRAY]: "RecsType.
|
|
172
|
-
[SchemaType.BYTES7_ARRAY]: "RecsType.
|
|
173
|
-
[SchemaType.BYTES8_ARRAY]: "RecsType.
|
|
174
|
-
[SchemaType.BYTES9_ARRAY]: "RecsType.
|
|
175
|
-
[SchemaType.BYTES10_ARRAY]: "RecsType.
|
|
176
|
-
[SchemaType.BYTES11_ARRAY]: "RecsType.
|
|
177
|
-
[SchemaType.BYTES12_ARRAY]: "RecsType.
|
|
178
|
-
[SchemaType.BYTES13_ARRAY]: "RecsType.
|
|
179
|
-
[SchemaType.BYTES14_ARRAY]: "RecsType.
|
|
180
|
-
[SchemaType.BYTES15_ARRAY]: "RecsType.
|
|
181
|
-
[SchemaType.BYTES16_ARRAY]: "RecsType.
|
|
182
|
-
[SchemaType.BYTES17_ARRAY]: "RecsType.
|
|
183
|
-
[SchemaType.BYTES18_ARRAY]: "RecsType.
|
|
184
|
-
[SchemaType.BYTES19_ARRAY]: "RecsType.
|
|
185
|
-
[SchemaType.BYTES20_ARRAY]: "RecsType.
|
|
186
|
-
[SchemaType.BYTES21_ARRAY]: "RecsType.
|
|
187
|
-
[SchemaType.BYTES22_ARRAY]: "RecsType.
|
|
188
|
-
[SchemaType.BYTES23_ARRAY]: "RecsType.
|
|
189
|
-
[SchemaType.BYTES24_ARRAY]: "RecsType.
|
|
190
|
-
[SchemaType.BYTES25_ARRAY]: "RecsType.
|
|
191
|
-
[SchemaType.BYTES26_ARRAY]: "RecsType.
|
|
192
|
-
[SchemaType.BYTES27_ARRAY]: "RecsType.
|
|
193
|
-
[SchemaType.BYTES28_ARRAY]: "RecsType.
|
|
194
|
-
[SchemaType.BYTES29_ARRAY]: "RecsType.
|
|
195
|
-
[SchemaType.BYTES30_ARRAY]: "RecsType.
|
|
196
|
-
[SchemaType.BYTES31_ARRAY]: "RecsType.
|
|
197
|
-
[SchemaType.BYTES32_ARRAY]: "RecsType.
|
|
140
|
+
[SchemaType.INT56_ARRAY]: "RecsType.BigIntArray",
|
|
141
|
+
[SchemaType.INT64_ARRAY]: "RecsType.BigIntArray",
|
|
142
|
+
[SchemaType.INT72_ARRAY]: "RecsType.BigIntArray",
|
|
143
|
+
[SchemaType.INT80_ARRAY]: "RecsType.BigIntArray",
|
|
144
|
+
[SchemaType.INT88_ARRAY]: "RecsType.BigIntArray",
|
|
145
|
+
[SchemaType.INT96_ARRAY]: "RecsType.BigIntArray",
|
|
146
|
+
[SchemaType.INT104_ARRAY]: "RecsType.BigIntArray",
|
|
147
|
+
[SchemaType.INT112_ARRAY]: "RecsType.BigIntArray",
|
|
148
|
+
[SchemaType.INT120_ARRAY]: "RecsType.BigIntArray",
|
|
149
|
+
[SchemaType.INT128_ARRAY]: "RecsType.BigIntArray",
|
|
150
|
+
[SchemaType.INT136_ARRAY]: "RecsType.BigIntArray",
|
|
151
|
+
[SchemaType.INT144_ARRAY]: "RecsType.BigIntArray",
|
|
152
|
+
[SchemaType.INT152_ARRAY]: "RecsType.BigIntArray",
|
|
153
|
+
[SchemaType.INT160_ARRAY]: "RecsType.BigIntArray",
|
|
154
|
+
[SchemaType.INT168_ARRAY]: "RecsType.BigIntArray",
|
|
155
|
+
[SchemaType.INT176_ARRAY]: "RecsType.BigIntArray",
|
|
156
|
+
[SchemaType.INT184_ARRAY]: "RecsType.BigIntArray",
|
|
157
|
+
[SchemaType.INT192_ARRAY]: "RecsType.BigIntArray",
|
|
158
|
+
[SchemaType.INT200_ARRAY]: "RecsType.BigIntArray",
|
|
159
|
+
[SchemaType.INT208_ARRAY]: "RecsType.BigIntArray",
|
|
160
|
+
[SchemaType.INT216_ARRAY]: "RecsType.BigIntArray",
|
|
161
|
+
[SchemaType.INT224_ARRAY]: "RecsType.BigIntArray",
|
|
162
|
+
[SchemaType.INT232_ARRAY]: "RecsType.BigIntArray",
|
|
163
|
+
[SchemaType.INT240_ARRAY]: "RecsType.BigIntArray",
|
|
164
|
+
[SchemaType.INT248_ARRAY]: "RecsType.BigIntArray",
|
|
165
|
+
[SchemaType.INT256_ARRAY]: "RecsType.BigIntArray",
|
|
166
|
+
[SchemaType.BYTES1_ARRAY]: "RecsType.BigIntArray",
|
|
167
|
+
[SchemaType.BYTES2_ARRAY]: "RecsType.BigIntArray",
|
|
168
|
+
[SchemaType.BYTES3_ARRAY]: "RecsType.BigIntArray",
|
|
169
|
+
[SchemaType.BYTES4_ARRAY]: "RecsType.BigIntArray",
|
|
170
|
+
[SchemaType.BYTES5_ARRAY]: "RecsType.BigIntArray",
|
|
171
|
+
[SchemaType.BYTES6_ARRAY]: "RecsType.BigIntArray",
|
|
172
|
+
[SchemaType.BYTES7_ARRAY]: "RecsType.BigIntArray",
|
|
173
|
+
[SchemaType.BYTES8_ARRAY]: "RecsType.BigIntArray",
|
|
174
|
+
[SchemaType.BYTES9_ARRAY]: "RecsType.BigIntArray",
|
|
175
|
+
[SchemaType.BYTES10_ARRAY]: "RecsType.BigIntArray",
|
|
176
|
+
[SchemaType.BYTES11_ARRAY]: "RecsType.BigIntArray",
|
|
177
|
+
[SchemaType.BYTES12_ARRAY]: "RecsType.BigIntArray",
|
|
178
|
+
[SchemaType.BYTES13_ARRAY]: "RecsType.BigIntArray",
|
|
179
|
+
[SchemaType.BYTES14_ARRAY]: "RecsType.BigIntArray",
|
|
180
|
+
[SchemaType.BYTES15_ARRAY]: "RecsType.BigIntArray",
|
|
181
|
+
[SchemaType.BYTES16_ARRAY]: "RecsType.BigIntArray",
|
|
182
|
+
[SchemaType.BYTES17_ARRAY]: "RecsType.BigIntArray",
|
|
183
|
+
[SchemaType.BYTES18_ARRAY]: "RecsType.BigIntArray",
|
|
184
|
+
[SchemaType.BYTES19_ARRAY]: "RecsType.BigIntArray",
|
|
185
|
+
[SchemaType.BYTES20_ARRAY]: "RecsType.BigIntArray",
|
|
186
|
+
[SchemaType.BYTES21_ARRAY]: "RecsType.BigIntArray",
|
|
187
|
+
[SchemaType.BYTES22_ARRAY]: "RecsType.BigIntArray",
|
|
188
|
+
[SchemaType.BYTES23_ARRAY]: "RecsType.BigIntArray",
|
|
189
|
+
[SchemaType.BYTES24_ARRAY]: "RecsType.BigIntArray",
|
|
190
|
+
[SchemaType.BYTES25_ARRAY]: "RecsType.BigIntArray",
|
|
191
|
+
[SchemaType.BYTES26_ARRAY]: "RecsType.BigIntArray",
|
|
192
|
+
[SchemaType.BYTES27_ARRAY]: "RecsType.BigIntArray",
|
|
193
|
+
[SchemaType.BYTES28_ARRAY]: "RecsType.BigIntArray",
|
|
194
|
+
[SchemaType.BYTES29_ARRAY]: "RecsType.BigIntArray",
|
|
195
|
+
[SchemaType.BYTES30_ARRAY]: "RecsType.BigIntArray",
|
|
196
|
+
[SchemaType.BYTES31_ARRAY]: "RecsType.BigIntArray",
|
|
197
|
+
[SchemaType.BYTES32_ARRAY]: "RecsType.BigIntArray",
|
|
198
198
|
[SchemaType.BOOL_ARRAY]: "RecsType.T", // no boolean array
|
|
199
199
|
[SchemaType.ADDRESS_ARRAY]: "RecsType.StringArray",
|
|
200
200
|
[SchemaType.BYTES]: "RecsType.String",
|
package/src/render-ts/tsgen.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import path from "path";
|
|
2
|
-
import { StoreConfig } from "
|
|
2
|
+
import { StoreConfig } from "@latticexyz/config";
|
|
3
3
|
import { getRecsV1TableOptions } from "../render-ts/recsV1TableOptions.js";
|
|
4
4
|
import { renderRecsV1Tables } from "../render-ts/renderRecsV1Tables.js";
|
|
5
5
|
import { formatAndWriteTypescript } from "../utils/formatAndWrite.js";
|
package/src/render-ts/types.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { parse, visit } from "@solidity-parser/parser";
|
|
2
2
|
import { TypeName, VariableDeclaration } from "@solidity-parser/parser/dist/src/ast-types.js";
|
|
3
|
+
import { MUDError } from "@latticexyz/config";
|
|
3
4
|
import { RenderSystemInterfaceFunction } from "../render-solidity/types.js";
|
|
4
|
-
import { MUDError } from "./errors.js";
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* Parse the contract data to get the functions necessary to generate an interface,
|
|
@@ -24,7 +24,7 @@ export function contractToInterface(data: string, contractName: string) {
|
|
|
24
24
|
}
|
|
25
25
|
},
|
|
26
26
|
FunctionDefinition(
|
|
27
|
-
{ name, visibility, parameters, returnParameters, isConstructor, isFallback, isReceiveEther },
|
|
27
|
+
{ name, visibility, parameters, stateMutability, returnParameters, isConstructor, isFallback, isReceiveEther },
|
|
28
28
|
parent
|
|
29
29
|
) {
|
|
30
30
|
if (parent !== undefined && parent.type === "ContractDefinition" && parent.name === contractName) {
|
|
@@ -38,6 +38,7 @@ export function contractToInterface(data: string, contractName: string) {
|
|
|
38
38
|
functions.push({
|
|
39
39
|
name: name === null ? "" : name,
|
|
40
40
|
parameters: parameters.map(parseParameter),
|
|
41
|
+
stateMutability: stateMutability || "",
|
|
41
42
|
returnParameters: returnParameters === null ? [] : returnParameters.map(parseParameter),
|
|
42
43
|
});
|
|
43
44
|
|
|
@@ -105,9 +106,10 @@ function flattenTypeName(typeName: TypeName | null): { name: string; stateMutabi
|
|
|
105
106
|
stateMutability: null,
|
|
106
107
|
};
|
|
107
108
|
} else if (typeName.type === "ArrayTypeName") {
|
|
109
|
+
const length = typeName.length?.type === "NumberLiteral" ? typeName.length.number : "";
|
|
108
110
|
const { name, stateMutability } = flattenTypeName(typeName.baseTypeName);
|
|
109
111
|
return {
|
|
110
|
-
name: `${name}[]`,
|
|
112
|
+
name: `${name}[${length}]`,
|
|
111
113
|
stateMutability,
|
|
112
114
|
};
|
|
113
115
|
} else {
|