@latticexyz/cli 1.40.0 → 1.41.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/LICENSE +21 -0
- package/dist/chunk-AER7UDD4.js +0 -0
- package/dist/chunk-ATAWDHWC.js +67 -0
- package/dist/{chunk-6AQ6LFVZ.js → chunk-GR245KYP.js} +95 -1
- package/dist/{chunk-S3V3XX7N.js → chunk-SLIMIO4Z.js} +1 -1
- package/dist/{chunk-JNGSW4AP.js → chunk-XRS7KWBZ.js} +139 -85
- package/dist/chunk-YZATC2M3.js +397 -0
- package/dist/chunk-ZYDMYSTH.js +1178 -0
- package/dist/config/index.d.ts +427 -3
- package/dist/config/index.js +26 -3
- package/dist/deploy-v2-b7b3207d.d.ts +92 -0
- package/dist/index.d.ts +110 -3
- package/dist/index.js +53 -8
- package/dist/mud.js +172 -46
- package/dist/utils/deprecated/index.js +2 -2
- package/dist/utils/index.d.ts +5 -44
- package/dist/utils/index.js +18 -3
- package/package.json +13 -9
- package/src/commands/deploy-v2.ts +100 -0
- package/src/commands/deprecated/call-system.ts +1 -1
- package/src/commands/deprecated/deploy-contracts.ts +1 -1
- package/src/commands/deprecated/test.ts +9 -6
- package/src/commands/deprecated/trace.ts +1 -1
- package/src/commands/gas-report.ts +1 -1
- package/src/commands/index.ts +2 -0
- package/src/commands/tablegen.ts +4 -18
- package/src/config/commonSchemas.ts +16 -0
- package/src/config/index.ts +8 -0
- package/src/config/loadStoreConfig.ts +2 -88
- package/src/config/loadWorldConfig.test-d.ts +11 -0
- package/src/config/loadWorldConfig.ts +178 -0
- package/src/config/{loadStoreConfig.test-d.ts → parseStoreConfig.test-d.ts} +5 -2
- package/src/config/parseStoreConfig.ts +174 -0
- package/src/config/validation.ts +46 -0
- package/src/constants.ts +1 -0
- package/src/index.ts +15 -5
- package/src/mud.ts +4 -0
- package/src/{render-table → render-solidity}/common.ts +37 -11
- package/src/{render-table → render-solidity}/field.ts +29 -20
- package/src/{render-table → render-solidity}/record.ts +3 -8
- package/src/{render-table → render-solidity}/renderTable.ts +38 -11
- package/src/{render-table → render-solidity}/renderTablesFromConfig.ts +37 -27
- package/src/render-solidity/renderTypes.ts +19 -0
- package/src/render-solidity/renderTypesFromConfig.ts +13 -0
- package/src/render-solidity/tablegen.ts +35 -0
- package/src/{render-table → render-solidity}/types.ts +25 -0
- package/src/render-solidity/userType.ts +100 -0
- package/src/utils/deploy-v2.ts +345 -0
- package/src/utils/deprecated/build.ts +1 -1
- package/src/utils/deprecated/typegen.ts +1 -1
- package/src/utils/errors.ts +12 -2
- package/src/utils/execLog.ts +22 -0
- package/src/utils/foundry.ts +94 -0
- package/src/utils/index.ts +2 -1
- package/dist/chunk-B6VWCGHZ.js +0 -199
- package/dist/chunk-JKAA3WMC.js +0 -55
- package/dist/chunk-PJ6GS2R4.js +0 -22
- package/dist/chunk-UC3QPOON.js +0 -35
- package/dist/loadStoreConfig-37f99136.d.ts +0 -164
- package/dist/render-table/index.d.ts +0 -29
- package/dist/render-table/index.js +0 -24
- package/dist/renderTable-9e6410c5.d.ts +0 -72
- package/src/utils/forgeConfig.ts +0 -45
- /package/src/{render-table → render-solidity}/index.ts +0 -0
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,111 @@
|
|
|
1
|
-
|
|
2
|
-
export {
|
|
3
|
-
import '@latticexyz/schema-type';
|
|
1
|
+
import { StoreConfig } from './config/index.js';
|
|
2
|
+
export { MUDConfig, MUDUserConfig, ResolvedWorldConfig, StoreConfig, StoreUserConfig, WorldUserConfig, loadStoreConfig, loadWorldConfig, parseStoreConfig, parseWorldConfig, resolveWorldConfig } from './config/index.js';
|
|
3
|
+
import * as _latticexyz_schema_type from '@latticexyz/schema-type';
|
|
4
|
+
export { D as DeployConfig, m as DeploymentInfo, F as ForgeConfig, M as MUDError, a as NotESMConfigError, N as NotInsideProjectError, U as UnrecognizedSystemErrorFactory, j as cast, n as deploy, i as forge, k as formatSolidity, f as fromZodErrorCustom, g as getForgeConfig, e as getOutDirectory, h as getRpcUrl, c as getScriptDirectory, b as getSrcDirectory, d as getTestDirectory, l as logError } from './deploy-v2-b7b3207d.js';
|
|
4
5
|
import 'zod';
|
|
6
|
+
import 'zod-validation-error';
|
|
7
|
+
|
|
8
|
+
declare function renderTablesFromConfig(config: StoreConfig, srcDirectory: string): {
|
|
9
|
+
outputDirectory: string;
|
|
10
|
+
tableName: string;
|
|
11
|
+
tableData: {
|
|
12
|
+
route?: string | undefined;
|
|
13
|
+
dataStruct?: boolean | undefined;
|
|
14
|
+
directory: string;
|
|
15
|
+
tableIdArgument: boolean;
|
|
16
|
+
storeArgument: boolean;
|
|
17
|
+
primaryKeys: Record<string, string | _latticexyz_schema_type.SchemaType>;
|
|
18
|
+
schema: Record<string, string | _latticexyz_schema_type.SchemaType>;
|
|
19
|
+
} & Required<Pick<{
|
|
20
|
+
route?: string | undefined;
|
|
21
|
+
dataStruct?: boolean | undefined;
|
|
22
|
+
directory: string;
|
|
23
|
+
tableIdArgument: boolean;
|
|
24
|
+
storeArgument: boolean;
|
|
25
|
+
primaryKeys: Record<string, string | _latticexyz_schema_type.SchemaType>;
|
|
26
|
+
schema: Record<string, string | _latticexyz_schema_type.SchemaType>;
|
|
27
|
+
}, "dataStruct">> & Required<Pick<{
|
|
28
|
+
route?: string | undefined;
|
|
29
|
+
dataStruct?: boolean | undefined;
|
|
30
|
+
directory: string;
|
|
31
|
+
tableIdArgument: boolean;
|
|
32
|
+
storeArgument: boolean;
|
|
33
|
+
primaryKeys: Record<string, string | _latticexyz_schema_type.SchemaType>;
|
|
34
|
+
schema: Record<string, string | _latticexyz_schema_type.SchemaType>;
|
|
35
|
+
} & Required<Pick<{
|
|
36
|
+
route?: string | undefined;
|
|
37
|
+
dataStruct?: boolean | undefined;
|
|
38
|
+
directory: string;
|
|
39
|
+
tableIdArgument: boolean;
|
|
40
|
+
storeArgument: boolean;
|
|
41
|
+
primaryKeys: Record<string, string | _latticexyz_schema_type.SchemaType>;
|
|
42
|
+
schema: Record<string, string | _latticexyz_schema_type.SchemaType>;
|
|
43
|
+
}, "dataStruct">>, "route">>;
|
|
44
|
+
output: string;
|
|
45
|
+
}[];
|
|
46
|
+
|
|
47
|
+
interface RenderTableOptions {
|
|
48
|
+
/** List of symbols to import, and their file paths */
|
|
49
|
+
imports: ImportDatum[];
|
|
50
|
+
/** Name of the library to render. */
|
|
51
|
+
libraryName: string;
|
|
52
|
+
/** Name of the struct to render. If undefined, struct and its methods aren't rendered. */
|
|
53
|
+
structName?: string;
|
|
54
|
+
/** Data used to statically registed the table. If undefined, all methods receive `_tableId` as an argument. */
|
|
55
|
+
staticRouteData?: StaticRouteData;
|
|
56
|
+
/** Path for store package imports */
|
|
57
|
+
storeImportPath: string;
|
|
58
|
+
primaryKeys: RenderTablePrimaryKey[];
|
|
59
|
+
fields: RenderTableField[];
|
|
60
|
+
staticFields: RenderTableStaticField[];
|
|
61
|
+
dynamicFields: RenderTableDynamicField[];
|
|
62
|
+
/** Whether to render get/set methods for the whole record */
|
|
63
|
+
withRecordMethods: boolean;
|
|
64
|
+
/** Whether to render additional methods that accept a manual `IStore` argument */
|
|
65
|
+
storeArgument: boolean;
|
|
66
|
+
}
|
|
67
|
+
interface ImportDatum {
|
|
68
|
+
symbol: string;
|
|
69
|
+
path: string;
|
|
70
|
+
}
|
|
71
|
+
interface StaticRouteData {
|
|
72
|
+
/** Name of the table id constant to render. */
|
|
73
|
+
tableIdName: string;
|
|
74
|
+
baseRoute: string;
|
|
75
|
+
subRoute: string;
|
|
76
|
+
}
|
|
77
|
+
interface RenderTableType {
|
|
78
|
+
typeId: string;
|
|
79
|
+
typeWithLocation: string;
|
|
80
|
+
/** The name of the enum element in SchemaType to use for schema registration (e.g. "UINT256_ARRAY") */
|
|
81
|
+
enumName: string;
|
|
82
|
+
staticByteLength: number;
|
|
83
|
+
isDynamic: boolean;
|
|
84
|
+
/** Empty for internal types. Custom `wrap` method for user defined types. */
|
|
85
|
+
typeWrap: string;
|
|
86
|
+
/** Empty for internal types. Custom `unwrap` method for user defined types. */
|
|
87
|
+
typeUnwrap: string;
|
|
88
|
+
/** Same as typeId for internal types. The underlying `typeId` for user defined types. */
|
|
89
|
+
internalTypeId: string;
|
|
90
|
+
}
|
|
91
|
+
interface RenderTablePrimaryKey extends RenderTableType {
|
|
92
|
+
name: string;
|
|
93
|
+
isDynamic: false;
|
|
94
|
+
}
|
|
95
|
+
interface RenderTableStaticField extends RenderTableField {
|
|
96
|
+
isDynamic: false;
|
|
97
|
+
}
|
|
98
|
+
interface RenderTableDynamicField extends RenderTableField {
|
|
99
|
+
isDynamic: true;
|
|
100
|
+
}
|
|
101
|
+
interface RenderTableField extends RenderTableType {
|
|
102
|
+
arrayElement: RenderTableType | undefined;
|
|
103
|
+
name: string;
|
|
104
|
+
methodNameSuffix: string;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
declare function renderTable(options: RenderTableOptions): string;
|
|
108
|
+
|
|
109
|
+
declare const deploymentInfoFilenamePrefix = "mud-deployment-";
|
|
110
|
+
|
|
111
|
+
export { deploymentInfoFilenamePrefix, renderTable, renderTablesFromConfig };
|
package/dist/index.js
CHANGED
|
@@ -1,17 +1,62 @@
|
|
|
1
1
|
import {
|
|
2
|
-
|
|
3
|
-
parseStoreConfig
|
|
4
|
-
} from "./chunk-B6VWCGHZ.js";
|
|
5
|
-
import {
|
|
2
|
+
deploymentInfoFilenamePrefix,
|
|
6
3
|
renderTable,
|
|
7
4
|
renderTablesFromConfig
|
|
8
|
-
} from "./chunk-
|
|
9
|
-
import
|
|
10
|
-
|
|
5
|
+
} from "./chunk-XRS7KWBZ.js";
|
|
6
|
+
import {
|
|
7
|
+
loadStoreConfig,
|
|
8
|
+
loadWorldConfig,
|
|
9
|
+
parseStoreConfig,
|
|
10
|
+
parseWorldConfig,
|
|
11
|
+
resolveWorldConfig
|
|
12
|
+
} from "./chunk-YZATC2M3.js";
|
|
13
|
+
import "./chunk-AER7UDD4.js";
|
|
14
|
+
import {
|
|
15
|
+
deploy,
|
|
16
|
+
formatSolidity
|
|
17
|
+
} from "./chunk-ZYDMYSTH.js";
|
|
18
|
+
import {
|
|
19
|
+
MUDError,
|
|
20
|
+
NotESMConfigError,
|
|
21
|
+
NotInsideProjectError,
|
|
22
|
+
UnrecognizedSystemErrorFactory,
|
|
23
|
+
fromZodErrorCustom,
|
|
24
|
+
logError
|
|
25
|
+
} from "./chunk-GR245KYP.js";
|
|
26
|
+
import {
|
|
27
|
+
cast,
|
|
28
|
+
forge,
|
|
29
|
+
getForgeConfig,
|
|
30
|
+
getOutDirectory,
|
|
31
|
+
getRpcUrl,
|
|
32
|
+
getScriptDirectory,
|
|
33
|
+
getSrcDirectory,
|
|
34
|
+
getTestDirectory
|
|
35
|
+
} from "./chunk-ATAWDHWC.js";
|
|
11
36
|
import "./chunk-O6HOO6WA.js";
|
|
12
37
|
export {
|
|
38
|
+
MUDError,
|
|
39
|
+
NotESMConfigError,
|
|
40
|
+
NotInsideProjectError,
|
|
41
|
+
UnrecognizedSystemErrorFactory,
|
|
42
|
+
cast,
|
|
43
|
+
deploy,
|
|
44
|
+
deploymentInfoFilenamePrefix,
|
|
45
|
+
forge,
|
|
46
|
+
formatSolidity,
|
|
47
|
+
fromZodErrorCustom,
|
|
48
|
+
getForgeConfig,
|
|
49
|
+
getOutDirectory,
|
|
50
|
+
getRpcUrl,
|
|
51
|
+
getScriptDirectory,
|
|
52
|
+
getSrcDirectory,
|
|
53
|
+
getTestDirectory,
|
|
13
54
|
loadStoreConfig,
|
|
55
|
+
loadWorldConfig,
|
|
56
|
+
logError,
|
|
14
57
|
parseStoreConfig,
|
|
58
|
+
parseWorldConfig,
|
|
15
59
|
renderTable,
|
|
16
|
-
renderTablesFromConfig
|
|
60
|
+
renderTablesFromConfig,
|
|
61
|
+
resolveWorldConfig
|
|
17
62
|
};
|
package/dist/mud.js
CHANGED
|
@@ -1,17 +1,23 @@
|
|
|
1
1
|
#!/usr/bin/env -S TS_NODE_COMPILER_OPTIONS={\"module\":\"esnext\"} node --loader=ts-node/esm --no-warnings
|
|
2
2
|
import {
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
deploymentInfoFilenamePrefix,
|
|
4
|
+
renderArguments,
|
|
5
|
+
renderList,
|
|
6
|
+
renderTablesFromConfig,
|
|
7
|
+
renderedSolidityHeader
|
|
8
|
+
} from "./chunk-XRS7KWBZ.js";
|
|
5
9
|
import {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
10
|
+
loadStoreConfig,
|
|
11
|
+
loadWorldConfig
|
|
12
|
+
} from "./chunk-YZATC2M3.js";
|
|
9
13
|
import {
|
|
14
|
+
deploy,
|
|
10
15
|
formatSolidity
|
|
11
|
-
} from "./chunk-
|
|
16
|
+
} from "./chunk-ZYDMYSTH.js";
|
|
12
17
|
import {
|
|
18
|
+
MUDError,
|
|
13
19
|
logError
|
|
14
|
-
} from "./chunk-
|
|
20
|
+
} from "./chunk-GR245KYP.js";
|
|
15
21
|
import {
|
|
16
22
|
JsonRpcProvider,
|
|
17
23
|
componentsDir,
|
|
@@ -25,11 +31,14 @@ import {
|
|
|
25
31
|
keccak256,
|
|
26
32
|
resetLibDeploy,
|
|
27
33
|
systemsDir
|
|
28
|
-
} from "./chunk-
|
|
34
|
+
} from "./chunk-SLIMIO4Z.js";
|
|
29
35
|
import {
|
|
36
|
+
forge,
|
|
37
|
+
getOutDirectory,
|
|
38
|
+
getRpcUrl,
|
|
30
39
|
getSrcDirectory,
|
|
31
40
|
getTestDirectory
|
|
32
|
-
} from "./chunk-
|
|
41
|
+
} from "./chunk-ATAWDHWC.js";
|
|
33
42
|
import {
|
|
34
43
|
__commonJS,
|
|
35
44
|
__toESM
|
|
@@ -1528,8 +1537,8 @@ var commandModule3 = {
|
|
|
1528
1537
|
systems: { type: "string", desc: "Only generate deploy code for the given systems" }
|
|
1529
1538
|
});
|
|
1530
1539
|
},
|
|
1531
|
-
async handler({ config, out, systems }) {
|
|
1532
|
-
await generateLibDeploy(
|
|
1540
|
+
async handler({ config: config2, out, systems }) {
|
|
1541
|
+
await generateLibDeploy(config2, out, systems);
|
|
1533
1542
|
process.exit(0);
|
|
1534
1543
|
}
|
|
1535
1544
|
};
|
|
@@ -1559,7 +1568,7 @@ var commandModule4 = {
|
|
|
1559
1568
|
});
|
|
1560
1569
|
},
|
|
1561
1570
|
async handler({
|
|
1562
|
-
config,
|
|
1571
|
+
config: config2,
|
|
1563
1572
|
deployerPrivateKey,
|
|
1564
1573
|
worldAddress,
|
|
1565
1574
|
rpc,
|
|
@@ -1578,7 +1587,7 @@ var commandModule4 = {
|
|
|
1578
1587
|
let genDeployResult;
|
|
1579
1588
|
try {
|
|
1580
1589
|
genDeployResult = await generateAndDeploy({
|
|
1581
|
-
config,
|
|
1590
|
+
config: config2,
|
|
1582
1591
|
deployerPrivateKey,
|
|
1583
1592
|
worldAddress,
|
|
1584
1593
|
rpc,
|
|
@@ -1609,7 +1618,7 @@ var commandModule4 = {
|
|
|
1609
1618
|
hsr(srcDir, async (systems2) => {
|
|
1610
1619
|
try {
|
|
1611
1620
|
return await generateAndDeploy({
|
|
1612
|
-
config,
|
|
1621
|
+
config: config2,
|
|
1613
1622
|
deployerPrivateKey,
|
|
1614
1623
|
worldAddress,
|
|
1615
1624
|
rpc,
|
|
@@ -1661,22 +1670,24 @@ var commandModule6 = {
|
|
|
1661
1670
|
v: { type: "number", default: 2, desc: "Verbosity for forge test" }
|
|
1662
1671
|
});
|
|
1663
1672
|
},
|
|
1664
|
-
async handler({ forgeOpts, config, v }) {
|
|
1673
|
+
async handler({ forgeOpts, config: config2, v }) {
|
|
1665
1674
|
const testDir = await getTestDirectory();
|
|
1666
1675
|
console.log("Generate LibDeploy.sol");
|
|
1667
|
-
await generateLibDeploy(
|
|
1676
|
+
await generateLibDeploy(config2, testDir);
|
|
1668
1677
|
const child = execLog("forge", [
|
|
1669
1678
|
"test",
|
|
1670
1679
|
...v ? ["-" + [...new Array(v)].map(() => "v").join("")] : [],
|
|
1671
1680
|
...forgeOpts?.split(" ") || []
|
|
1672
1681
|
]);
|
|
1673
|
-
|
|
1674
|
-
await resetLibDeploy(testDir);
|
|
1675
|
-
process.on("SIGINT", () => {
|
|
1682
|
+
process.on("SIGINT", async () => {
|
|
1676
1683
|
console.log("\ngracefully shutting down from SIGINT (Crtl-C)");
|
|
1677
1684
|
child.kill();
|
|
1685
|
+
await resetLibDeploy(testDir);
|
|
1678
1686
|
process.exit();
|
|
1679
1687
|
});
|
|
1688
|
+
await child;
|
|
1689
|
+
console.log("Reset LibDeploy.sol");
|
|
1690
|
+
await resetLibDeploy(testDir);
|
|
1680
1691
|
}
|
|
1681
1692
|
};
|
|
1682
1693
|
var test_default = commandModule6;
|
|
@@ -9652,9 +9663,9 @@ var commandModule7 = {
|
|
|
9652
9663
|
debug: { type: "boolean", description: "open debugger" }
|
|
9653
9664
|
});
|
|
9654
9665
|
},
|
|
9655
|
-
async handler({ config, world, rpc, tx, debug }) {
|
|
9666
|
+
async handler({ config: config2, world, rpc, tx, debug }) {
|
|
9656
9667
|
const wd = process.cwd();
|
|
9657
|
-
const deployData =
|
|
9668
|
+
const deployData = config2 && JSON.parse(readFileSync(config2, { encoding: "utf8" }));
|
|
9658
9669
|
const labels = [];
|
|
9659
9670
|
const rpcUrl = rpc || "http://localhost:8545";
|
|
9660
9671
|
const provider = new JsonRpcProvider(rpcUrl);
|
|
@@ -11250,9 +11261,9 @@ var commandModule11 = {
|
|
|
11250
11261
|
compare: { type: "string", desc: "Compare to an existing gas report" }
|
|
11251
11262
|
});
|
|
11252
11263
|
},
|
|
11253
|
-
async handler({ path:
|
|
11264
|
+
async handler({ path: path7, save, compare: compare2 }) {
|
|
11254
11265
|
let gasReport = [];
|
|
11255
|
-
for (const file of
|
|
11266
|
+
for (const file of path7) {
|
|
11256
11267
|
gasReport = gasReport.concat(await runGasReport(file));
|
|
11257
11268
|
}
|
|
11258
11269
|
const compareGasReport = [];
|
|
@@ -11284,14 +11295,14 @@ var commandModule11 = {
|
|
|
11284
11295
|
}
|
|
11285
11296
|
};
|
|
11286
11297
|
var gas_report_default = commandModule11;
|
|
11287
|
-
async function runGasReport(
|
|
11288
|
-
if (!
|
|
11289
|
-
console.log("Skipping gas report for", chalk3.bold(
|
|
11298
|
+
async function runGasReport(path7) {
|
|
11299
|
+
if (!path7.endsWith(".t.sol")) {
|
|
11300
|
+
console.log("Skipping gas report for", chalk3.bold(path7), "(not a test file)");
|
|
11290
11301
|
return [];
|
|
11291
11302
|
}
|
|
11292
|
-
console.log("Running gas report for", chalk3.bold(
|
|
11303
|
+
console.log("Running gas report for", chalk3.bold(path7));
|
|
11293
11304
|
const gasReport = [];
|
|
11294
|
-
const fileContents = readFileSync2(
|
|
11305
|
+
const fileContents = readFileSync2(path7, "utf8");
|
|
11295
11306
|
let newFile = fileContents;
|
|
11296
11307
|
const functionRegex = new RegExp(/function (.*){/g);
|
|
11297
11308
|
let functionMatch;
|
|
@@ -11315,7 +11326,7 @@ console.log("GAS REPORT: ${name} [${functionCall.replaceAll('"', '\\"')}]:", _ga
|
|
|
11315
11326
|
);
|
|
11316
11327
|
}
|
|
11317
11328
|
newFile = newFile.replace(/pure/g, "view");
|
|
11318
|
-
const tempFileName =
|
|
11329
|
+
const tempFileName = path7.replace(/\.t\.sol$/, "MudGasReport.t.sol");
|
|
11319
11330
|
writeFileSync(tempFileName, newFile);
|
|
11320
11331
|
const child = execa2("forge", ["test", "--match-path", tempFileName, "-vvv"], {
|
|
11321
11332
|
stdio: ["inherit", "pipe", "inherit"]
|
|
@@ -11336,7 +11347,7 @@ console.log("GAS REPORT: ${name} [${functionCall.replaceAll('"', '\\"')}]:", _ga
|
|
|
11336
11347
|
const name = gasReportMatch[1];
|
|
11337
11348
|
const functionCall = gasReportMatch[2].replace(";", "");
|
|
11338
11349
|
const gasUsed = gasReportMatch[3];
|
|
11339
|
-
gasReport.push({ source:
|
|
11350
|
+
gasReport.push({ source: path7, name, functionCall, gasUsed: parseInt(gasUsed) });
|
|
11340
11351
|
}
|
|
11341
11352
|
return gasReport;
|
|
11342
11353
|
}
|
|
@@ -11360,10 +11371,10 @@ function printGasReport(gasReport, compare2) {
|
|
|
11360
11371
|
const rows = [headers, ...values];
|
|
11361
11372
|
console.log(table(rows, { border: getBorderCharacters("norc") }));
|
|
11362
11373
|
}
|
|
11363
|
-
function saveGasReport(gasReport,
|
|
11364
|
-
console.log(chalk3.bold(`Saving gas report to ${
|
|
11374
|
+
function saveGasReport(gasReport, path7) {
|
|
11375
|
+
console.log(chalk3.bold(`Saving gas report to ${path7}`));
|
|
11365
11376
|
const serializedGasReport = gasReport.map((entry) => `(${entry.source}) | ${entry.name} [${entry.functionCall}]: ${entry.gasUsed}`).join("\n");
|
|
11366
|
-
writeFileSync(
|
|
11377
|
+
writeFileSync(path7, serializedGasReport);
|
|
11367
11378
|
}
|
|
11368
11379
|
|
|
11369
11380
|
// src/commands/hello.ts
|
|
@@ -11383,9 +11394,60 @@ var commandModule12 = {
|
|
|
11383
11394
|
};
|
|
11384
11395
|
var hello_default = commandModule12;
|
|
11385
11396
|
|
|
11386
|
-
// src/
|
|
11397
|
+
// src/render-solidity/tablegen.ts
|
|
11387
11398
|
import { mkdirSync, writeFileSync as writeFileSync2 } from "fs";
|
|
11388
11399
|
import path5 from "path";
|
|
11400
|
+
|
|
11401
|
+
// src/render-solidity/renderTypes.ts
|
|
11402
|
+
function renderTypes(options) {
|
|
11403
|
+
const { enums } = options;
|
|
11404
|
+
return `${renderedSolidityHeader}
|
|
11405
|
+
|
|
11406
|
+
${renderList(
|
|
11407
|
+
enums,
|
|
11408
|
+
({ name, memberNames }) => `
|
|
11409
|
+
enum ${name} {
|
|
11410
|
+
${renderArguments(memberNames)}
|
|
11411
|
+
}
|
|
11412
|
+
`
|
|
11413
|
+
)}
|
|
11414
|
+
|
|
11415
|
+
`;
|
|
11416
|
+
}
|
|
11417
|
+
|
|
11418
|
+
// src/render-solidity/renderTypesFromConfig.ts
|
|
11419
|
+
function renderTypesFromConfig(config2) {
|
|
11420
|
+
const enums = Object.keys(config2.userTypes.enums).map((name) => ({
|
|
11421
|
+
name,
|
|
11422
|
+
memberNames: config2.userTypes.enums[name]
|
|
11423
|
+
}));
|
|
11424
|
+
return renderTypes({
|
|
11425
|
+
enums
|
|
11426
|
+
});
|
|
11427
|
+
}
|
|
11428
|
+
|
|
11429
|
+
// src/render-solidity/tablegen.ts
|
|
11430
|
+
async function tablegen(config2, outputBaseDirectory) {
|
|
11431
|
+
const renderedTables = renderTablesFromConfig(config2, outputBaseDirectory);
|
|
11432
|
+
for (const { outputDirectory, output, tableName } of renderedTables) {
|
|
11433
|
+
const formattedOutput = await formatSolidity(output);
|
|
11434
|
+
mkdirSync(outputDirectory, { recursive: true });
|
|
11435
|
+
const outputPath = path5.join(outputDirectory, `${tableName}.sol`);
|
|
11436
|
+
writeFileSync2(outputPath, formattedOutput);
|
|
11437
|
+
console.log(`Generated table: ${outputPath}`);
|
|
11438
|
+
}
|
|
11439
|
+
if (Object.keys(config2.userTypes.enums).length > 0) {
|
|
11440
|
+
const renderedTypes = renderTypesFromConfig(config2);
|
|
11441
|
+
const formattedOutput = await formatSolidity(renderedTypes);
|
|
11442
|
+
const outputPath = path5.join(outputBaseDirectory, `${config2.userTypes.path}.sol`);
|
|
11443
|
+
const outputDirectory = path5.dirname(outputPath);
|
|
11444
|
+
mkdirSync(outputDirectory, { recursive: true });
|
|
11445
|
+
writeFileSync2(outputPath, formattedOutput);
|
|
11446
|
+
console.log(`Generated types file: ${outputPath}`);
|
|
11447
|
+
}
|
|
11448
|
+
}
|
|
11449
|
+
|
|
11450
|
+
// src/commands/tablegen.ts
|
|
11389
11451
|
var commandModule13 = {
|
|
11390
11452
|
command: "tablegen",
|
|
11391
11453
|
describe: "Autogenerate MUD Store table libraries based on the config file",
|
|
@@ -11395,29 +11457,91 @@ var commandModule13 = {
|
|
|
11395
11457
|
});
|
|
11396
11458
|
},
|
|
11397
11459
|
async handler({ configPath }) {
|
|
11398
|
-
const
|
|
11399
|
-
const
|
|
11400
|
-
|
|
11401
|
-
for (const { output, tableName } of renderedTables) {
|
|
11402
|
-
const formattedOutput = await formatSolidity(output);
|
|
11403
|
-
const tablePath = config.tables[tableName].route;
|
|
11404
|
-
const outputDirectory = path5.join(srcDir, tablePath);
|
|
11405
|
-
mkdirSync(outputDirectory, { recursive: true });
|
|
11406
|
-
const outputPath = path5.join(outputDirectory, `${tableName}.sol`);
|
|
11407
|
-
writeFileSync2(outputPath, formattedOutput);
|
|
11408
|
-
console.log(`Generated schema: ${outputPath}`);
|
|
11409
|
-
}
|
|
11460
|
+
const srcDirectory = await getSrcDirectory();
|
|
11461
|
+
const config2 = await loadStoreConfig(configPath);
|
|
11462
|
+
await tablegen(config2, srcDirectory);
|
|
11410
11463
|
process.exit(0);
|
|
11411
11464
|
}
|
|
11412
11465
|
};
|
|
11413
11466
|
var tablegen_default = commandModule13;
|
|
11414
11467
|
|
|
11468
|
+
// src/commands/deploy-v2.ts
|
|
11469
|
+
import chalk4 from "chalk";
|
|
11470
|
+
import glob from "glob";
|
|
11471
|
+
import path6, { basename } from "path";
|
|
11472
|
+
import { mkdirSync as mkdirSync2, writeFileSync as writeFileSync3 } from "fs";
|
|
11473
|
+
var commandModule14 = {
|
|
11474
|
+
command: "deploy-v2",
|
|
11475
|
+
describe: "Deploy MUD v2 contracts",
|
|
11476
|
+
builder(yargs2) {
|
|
11477
|
+
return yargs2.options({
|
|
11478
|
+
configPath: { type: "string", desc: "Path to the config file" },
|
|
11479
|
+
clean: { type: "boolean", desc: "Remove the build forge artifacts and cache directories before building" },
|
|
11480
|
+
printConfig: { type: "boolean", desc: "Print the resolved config" },
|
|
11481
|
+
profile: { type: "string", desc: "The foundry profile to use" },
|
|
11482
|
+
priorityFeeMultiplier: {
|
|
11483
|
+
type: "number",
|
|
11484
|
+
desc: "Multiply the estimated priority fee by the provided factor",
|
|
11485
|
+
default: 1
|
|
11486
|
+
}
|
|
11487
|
+
});
|
|
11488
|
+
},
|
|
11489
|
+
async handler(args) {
|
|
11490
|
+
args.profile = args.profile ?? process.env.FOUNDRY_PROFILE;
|
|
11491
|
+
const { configPath, printConfig, profile, clean } = args;
|
|
11492
|
+
const rpc = await getRpcUrl(profile);
|
|
11493
|
+
console.log(
|
|
11494
|
+
chalk4.bgBlue(
|
|
11495
|
+
chalk4.whiteBright(`
|
|
11496
|
+
Deploying MUD v2 contracts${profile ? " with profile " + profile : ""} to RPC ${rpc}
|
|
11497
|
+
`)
|
|
11498
|
+
)
|
|
11499
|
+
);
|
|
11500
|
+
if (clean)
|
|
11501
|
+
await forge(["clean"], { profile });
|
|
11502
|
+
await forge(["build"], { profile });
|
|
11503
|
+
const outDir = await getOutDirectory();
|
|
11504
|
+
const existingContracts = glob.sync(`${outDir}/*.sol`).map((path7) => basename(path7, ".sol"));
|
|
11505
|
+
const worldConfig = await loadWorldConfig(configPath, existingContracts);
|
|
11506
|
+
const storeConfig = await loadStoreConfig(configPath);
|
|
11507
|
+
const mudConfig = { ...worldConfig, ...storeConfig };
|
|
11508
|
+
if (printConfig)
|
|
11509
|
+
console.log(chalk4.green("\nResolved config:\n"), JSON.stringify(mudConfig, null, 2));
|
|
11510
|
+
try {
|
|
11511
|
+
const privateKey = process.env.PRIVATE_KEY;
|
|
11512
|
+
if (!privateKey)
|
|
11513
|
+
throw new MUDError("Missing PRIVATE_KEY environment variable");
|
|
11514
|
+
const deploymentInfo = await deploy(mudConfig, { ...args, rpc, privateKey });
|
|
11515
|
+
const outputDir = mudConfig.deploymentInfoDirectory;
|
|
11516
|
+
mkdirSync2(outputDir, { recursive: true });
|
|
11517
|
+
writeFileSync3(
|
|
11518
|
+
path6.join(outputDir, deploymentInfoFilenamePrefix + "latest.json"),
|
|
11519
|
+
JSON.stringify(deploymentInfo, null, 2)
|
|
11520
|
+
);
|
|
11521
|
+
writeFileSync3(
|
|
11522
|
+
path6.join(outputDir, deploymentInfoFilenamePrefix + Date.now() + ".json"),
|
|
11523
|
+
JSON.stringify(deploymentInfo, null, 2)
|
|
11524
|
+
);
|
|
11525
|
+
console.log(chalk4.bgGreen(chalk4.whiteBright(`
|
|
11526
|
+
Deployment result (written to ${outputDir}):
|
|
11527
|
+
`)));
|
|
11528
|
+
console.log(deploymentInfo);
|
|
11529
|
+
} catch (error) {
|
|
11530
|
+
logError(error);
|
|
11531
|
+
process.exit(1);
|
|
11532
|
+
}
|
|
11533
|
+
process.exit(0);
|
|
11534
|
+
}
|
|
11535
|
+
};
|
|
11536
|
+
var deploy_v2_default = commandModule14;
|
|
11537
|
+
|
|
11415
11538
|
// src/commands/index.ts
|
|
11416
11539
|
var commands = [
|
|
11417
11540
|
bulkupload_default,
|
|
11418
11541
|
call_system_default,
|
|
11419
11542
|
codegen_libdeploy_default,
|
|
11420
11543
|
deploy_contracts_default,
|
|
11544
|
+
deploy_v2_default,
|
|
11421
11545
|
devnode_default,
|
|
11422
11546
|
faucet_default,
|
|
11423
11547
|
gas_report_default,
|
|
@@ -11430,6 +11554,8 @@ var commands = [
|
|
|
11430
11554
|
];
|
|
11431
11555
|
|
|
11432
11556
|
// src/mud.ts
|
|
11557
|
+
import * as dotenv from "dotenv";
|
|
11558
|
+
dotenv.config();
|
|
11433
11559
|
yargs(hideBin(process.argv)).scriptName("mud").command(commands).strict().fail((msg, err) => {
|
|
11434
11560
|
console.log("");
|
|
11435
11561
|
logError(err);
|
|
@@ -14,8 +14,8 @@ import {
|
|
|
14
14
|
hsr,
|
|
15
15
|
keccak256,
|
|
16
16
|
resetLibDeploy
|
|
17
|
-
} from "../../chunk-
|
|
18
|
-
import "../../chunk-
|
|
17
|
+
} from "../../chunk-SLIMIO4Z.js";
|
|
18
|
+
import "../../chunk-ATAWDHWC.js";
|
|
19
19
|
import "../../chunk-O6HOO6WA.js";
|
|
20
20
|
export {
|
|
21
21
|
IDregex,
|
package/dist/utils/index.d.ts
CHANGED
|
@@ -1,44 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
name: string;
|
|
7
|
-
message: string;
|
|
8
|
-
}
|
|
9
|
-
declare class NotESMConfigError extends Error {
|
|
10
|
-
name: string;
|
|
11
|
-
message: string;
|
|
12
|
-
}
|
|
13
|
-
declare function logError(error: Error): void;
|
|
14
|
-
|
|
15
|
-
interface ForgeConfig {
|
|
16
|
-
src: string;
|
|
17
|
-
test: string;
|
|
18
|
-
out: string;
|
|
19
|
-
libs: string[];
|
|
20
|
-
[key: string]: unknown;
|
|
21
|
-
}
|
|
22
|
-
/**
|
|
23
|
-
* Get forge config as a parsed json object.
|
|
24
|
-
*/
|
|
25
|
-
declare function getForgeConfig(): Promise<ForgeConfig>;
|
|
26
|
-
/**
|
|
27
|
-
* Get the value of "src" from forge config.
|
|
28
|
-
* The path to the contract sources relative to the root of the project.
|
|
29
|
-
*/
|
|
30
|
-
declare function getSrcDirectory(): Promise<string>;
|
|
31
|
-
/**
|
|
32
|
-
* Get the value of "test" from forge config.
|
|
33
|
-
* The path to the test contract sources relative to the root of the project.
|
|
34
|
-
*/
|
|
35
|
-
declare function getTestDirectory(): Promise<string>;
|
|
36
|
-
/**
|
|
37
|
-
* Get the value of "out" from forge config.
|
|
38
|
-
* The path to put contract artifacts in, relative to the root of the project.
|
|
39
|
-
*/
|
|
40
|
-
declare function getOutDirectory(): Promise<string>;
|
|
41
|
-
|
|
42
|
-
declare function formatSolidity(content: string, prettierConfigPath?: string): Promise<string>;
|
|
43
|
-
|
|
44
|
-
export { ForgeConfig, NotESMConfigError, NotInsideProjectError, formatSolidity, fromZodErrorCustom, getForgeConfig, getOutDirectory, getSrcDirectory, getTestDirectory, logError };
|
|
1
|
+
export { D as DeployConfig, m as DeploymentInfo, F as ForgeConfig, M as MUDError, a as NotESMConfigError, N as NotInsideProjectError, U as UnrecognizedSystemErrorFactory, j as cast, n as deploy, i as forge, k as formatSolidity, f as fromZodErrorCustom, g as getForgeConfig, e as getOutDirectory, h as getRpcUrl, c as getScriptDirectory, b as getSrcDirectory, d as getTestDirectory, l as logError } from '../deploy-v2-b7b3207d.js';
|
|
2
|
+
import 'zod';
|
|
3
|
+
import 'zod-validation-error';
|
|
4
|
+
import '../config/index.js';
|
|
5
|
+
import '@latticexyz/schema-type';
|
package/dist/utils/index.js
CHANGED
|
@@ -1,26 +1,41 @@
|
|
|
1
|
+
import "../chunk-AER7UDD4.js";
|
|
1
2
|
import {
|
|
3
|
+
deploy,
|
|
2
4
|
formatSolidity
|
|
3
|
-
} from "../chunk-
|
|
5
|
+
} from "../chunk-ZYDMYSTH.js";
|
|
4
6
|
import {
|
|
7
|
+
MUDError,
|
|
5
8
|
NotESMConfigError,
|
|
6
9
|
NotInsideProjectError,
|
|
10
|
+
UnrecognizedSystemErrorFactory,
|
|
7
11
|
fromZodErrorCustom,
|
|
8
12
|
logError
|
|
9
|
-
} from "../chunk-
|
|
13
|
+
} from "../chunk-GR245KYP.js";
|
|
10
14
|
import {
|
|
15
|
+
cast,
|
|
16
|
+
forge,
|
|
11
17
|
getForgeConfig,
|
|
12
18
|
getOutDirectory,
|
|
19
|
+
getRpcUrl,
|
|
20
|
+
getScriptDirectory,
|
|
13
21
|
getSrcDirectory,
|
|
14
22
|
getTestDirectory
|
|
15
|
-
} from "../chunk-
|
|
23
|
+
} from "../chunk-ATAWDHWC.js";
|
|
16
24
|
import "../chunk-O6HOO6WA.js";
|
|
17
25
|
export {
|
|
26
|
+
MUDError,
|
|
18
27
|
NotESMConfigError,
|
|
19
28
|
NotInsideProjectError,
|
|
29
|
+
UnrecognizedSystemErrorFactory,
|
|
30
|
+
cast,
|
|
31
|
+
deploy,
|
|
32
|
+
forge,
|
|
20
33
|
formatSolidity,
|
|
21
34
|
fromZodErrorCustom,
|
|
22
35
|
getForgeConfig,
|
|
23
36
|
getOutDirectory,
|
|
37
|
+
getRpcUrl,
|
|
38
|
+
getScriptDirectory,
|
|
24
39
|
getSrcDirectory,
|
|
25
40
|
getTestDirectory,
|
|
26
41
|
logError
|