@latticexyz/cli 0.0.0-main-20230704121617
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/README.md +3 -0
- package/dist/chunk-LFIOIY67.js +30 -0
- package/dist/chunk-LFIOIY67.js.map +1 -0
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -0
- package/dist/mud.js +20 -0
- package/dist/mud.js.map +1 -0
- package/package.json +77 -0
- package/src/commands/deploy.ts +49 -0
- package/src/commands/dev-contracts.ts +176 -0
- package/src/commands/devnode.ts +42 -0
- package/src/commands/faucet.ts +60 -0
- package/src/commands/gas-report.ts +193 -0
- package/src/commands/hello.ts +28 -0
- package/src/commands/index.ts +30 -0
- package/src/commands/set-version.ts +200 -0
- package/src/commands/tablegen.ts +33 -0
- package/src/commands/test.ts +70 -0
- package/src/commands/trace.ts +108 -0
- package/src/commands/tsgen.ts +34 -0
- package/src/commands/worldgen.ts +57 -0
- package/src/index.ts +2 -0
- package/src/modules.d.ts +11 -0
- package/src/mud.ts +36 -0
- package/src/render-ts/index.ts +5 -0
- package/src/render-ts/recsV1TableOptions.ts +39 -0
- package/src/render-ts/renderRecsV1Tables.ts +31 -0
- package/src/render-ts/schemaTypesToRecsTypeStrings.ts +202 -0
- package/src/render-ts/tsgen.ts +12 -0
- package/src/render-ts/types.ts +13 -0
- package/src/utils/deploy.ts +602 -0
- package/src/utils/deployHandler.ts +87 -0
- package/src/utils/errors.ts +29 -0
- package/src/utils/getChainId.ts +10 -0
- package/src/utils/getExistingContracts.ts +12 -0
- package/src/utils/index.ts +7 -0
- package/src/utils/printMUD.ts +14 -0
- package/src/utils/worldtypes.ts +21 -0
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import chalk from "chalk";
|
|
2
|
+
import { ZodError } from "zod";
|
|
3
|
+
import { fromZodError, ValidationError } from "zod-validation-error";
|
|
4
|
+
import { NotInsideProjectError } from "@latticexyz/config";
|
|
5
|
+
import { MUDError } from "@latticexyz/common/errors";
|
|
6
|
+
|
|
7
|
+
export function logError(error: unknown) {
|
|
8
|
+
if (error instanceof ValidationError) {
|
|
9
|
+
console.log(chalk.redBright(error.message));
|
|
10
|
+
} else if (error instanceof ZodError) {
|
|
11
|
+
// TODO currently this error shouldn't happen, use `fromZodErrorCustom`
|
|
12
|
+
// (see https://github.com/latticexyz/mud/issues/438)
|
|
13
|
+
const validationError = fromZodError(error, {
|
|
14
|
+
prefixSeparator: "\n- ",
|
|
15
|
+
issueSeparator: "\n- ",
|
|
16
|
+
});
|
|
17
|
+
console.log(chalk.redBright(validationError.message));
|
|
18
|
+
} else if (error instanceof NotInsideProjectError) {
|
|
19
|
+
console.log(chalk.red(error.message));
|
|
20
|
+
console.log("");
|
|
21
|
+
// TODO add docs to the website and update the link to the specific page
|
|
22
|
+
// (see https://github.com/latticexyz/mud/issues/445)
|
|
23
|
+
console.log(chalk.blue(`To learn more about MUD's configuration, please go to https://mud.dev/packages/cli/`));
|
|
24
|
+
} else if (error instanceof MUDError) {
|
|
25
|
+
console.log(chalk.red(error));
|
|
26
|
+
} else {
|
|
27
|
+
console.log(error);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { ethers } from "ethers";
|
|
2
|
+
|
|
3
|
+
// TODO: Use viem's getChainId
|
|
4
|
+
export async function getChainId(rpc: string) {
|
|
5
|
+
const { result: chainId } = await ethers.utils.fetchJson(
|
|
6
|
+
rpc,
|
|
7
|
+
'{ "id": 42, "jsonrpc": "2.0", "method": "eth_chainId", "params": [ ] }'
|
|
8
|
+
);
|
|
9
|
+
return Number(chainId);
|
|
10
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import glob from "glob";
|
|
2
|
+
import { basename } from "path";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Get a list of all contract paths/names within the provided src directory
|
|
6
|
+
*/
|
|
7
|
+
export function getExistingContracts(srcDir: string) {
|
|
8
|
+
return glob.sync(`${srcDir}/**/*.sol`).map((path) => ({
|
|
9
|
+
path,
|
|
10
|
+
basename: basename(path, ".sol"),
|
|
11
|
+
}));
|
|
12
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import chalk from "chalk";
|
|
2
|
+
|
|
3
|
+
export function printMUD() {
|
|
4
|
+
console.log(
|
|
5
|
+
chalk.yellow(`
|
|
6
|
+
.------..------..------.
|
|
7
|
+
|M.--. ||U.--. ||D.--. |
|
|
8
|
+
| (\\/) || (\\/) || :/\\: |
|
|
9
|
+
| :\\/: || :\\/: || (__) |
|
|
10
|
+
| '--'M|| '--'U|| '--'D|
|
|
11
|
+
'------''------''------'
|
|
12
|
+
`)
|
|
13
|
+
);
|
|
14
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { getOutDirectory } from "@latticexyz/common/foundry";
|
|
2
|
+
import path from "path";
|
|
3
|
+
import { runTypeChain } from "typechain";
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Generate IWorld typescript bindings
|
|
7
|
+
*/
|
|
8
|
+
export async function worldtypes() {
|
|
9
|
+
const cwd = process.cwd();
|
|
10
|
+
const forgeOurDir = await getOutDirectory();
|
|
11
|
+
const IWorldPath = path.join(process.cwd(), forgeOurDir, "IWorld.sol/IWorld.json");
|
|
12
|
+
|
|
13
|
+
await runTypeChain({
|
|
14
|
+
cwd,
|
|
15
|
+
filesToProcess: [IWorldPath],
|
|
16
|
+
allFiles: [IWorldPath],
|
|
17
|
+
target: "ethers-v5",
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
console.log("Typechain generated IWorld interface");
|
|
21
|
+
}
|