@latticexyz/cli 2.0.0-alpha.93 → 2.0.0-foundry-js-c7b0289b
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-22IIKR4S.js +4 -0
- package/dist/chunk-22IIKR4S.js.map +1 -0
- package/dist/commands-UYAATBY6.js +27 -0
- package/dist/commands-UYAATBY6.js.map +1 -0
- package/dist/errors-XGN6V2Y3.js +2 -0
- package/dist/errors-XGN6V2Y3.js.map +1 -0
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -0
- package/dist/mud.js +2 -8340
- package/dist/mud.js.map +1 -0
- package/package.json +54 -46
- package/src/commands/deploy.ts +26 -0
- package/src/commands/dev-contracts.ts +114 -0
- package/src/commands/devnode.ts +7 -2
- package/src/commands/faucet.ts +1 -1
- package/src/commands/index.ts +19 -14
- package/src/commands/set-version.ts +103 -81
- package/src/commands/tablegen.ts +7 -5
- package/src/commands/test.ts +65 -0
- package/src/commands/trace.ts +118 -0
- package/src/commands/worldgen.ts +29 -28
- package/src/common.ts +1 -0
- package/src/debug.ts +3 -0
- package/src/deploy/assertNamespaceOwner.ts +42 -0
- package/src/deploy/common.ts +76 -0
- package/src/deploy/configToTables.ts +68 -0
- package/src/deploy/create2/README.md +9 -0
- package/src/deploy/create2/deployment.json +7 -0
- package/src/deploy/debug.ts +3 -0
- package/src/deploy/deploy.ts +108 -0
- package/src/deploy/deployWorld.ts +33 -0
- package/src/deploy/ensureContract.ts +61 -0
- package/src/deploy/ensureContractsDeployed.ts +25 -0
- package/src/deploy/ensureDeployer.ts +36 -0
- package/src/deploy/ensureFunctions.ts +86 -0
- package/src/deploy/ensureModules.ts +73 -0
- package/src/deploy/ensureSystems.ts +162 -0
- package/src/deploy/ensureTables.ts +65 -0
- package/src/deploy/ensureWorldFactory.ts +47 -0
- package/src/deploy/getFunctions.ts +58 -0
- package/src/deploy/getResourceAccess.ts +51 -0
- package/src/deploy/getResourceIds.ts +31 -0
- package/src/deploy/getSystems.ts +48 -0
- package/src/deploy/getTableValue.ts +30 -0
- package/src/deploy/getTables.ts +59 -0
- package/src/deploy/getWorldDeploy.ts +39 -0
- package/src/deploy/logsToWorldDeploy.ts +49 -0
- package/src/deploy/resolveConfig.ts +151 -0
- package/src/deploy/resourceLabel.ts +3 -0
- package/src/index.ts +1 -1
- package/src/modules.d.ts +11 -0
- package/src/mud.ts +38 -23
- package/src/mudPackages.ts +24 -0
- package/src/runDeploy.ts +128 -0
- package/src/utils/errors.ts +1 -1
- package/src/utils/getExistingContracts.ts +12 -0
- package/src/utils/modules/constants.ts +26 -0
- package/src/utils/printMUD.ts +14 -0
- package/src/utils/utils/getContractData.ts +32 -0
- package/src/utils/utils/postDeploy.ts +25 -0
- package/dist/chunk-6V563IAZ.js +0 -283
- package/dist/chunk-FPG73MVN.js +0 -71
- package/dist/chunk-L4YLJHLJ.js +0 -30
- package/dist/chunk-P5YXGXRI.js +0 -3842
- package/dist/chunk-SKNB74MT.js +0 -726
- package/dist/chunk-VQTZJIFF.js +0 -353
- package/dist/chunk-WZFXLDPK.js +0 -761
- package/dist/chunk-YL4GJLLL.js +0 -26139
- package/dist/index.d.ts +0 -2
- package/dist/mud.d.ts +0 -1
- package/dist/mud2.d.ts +0 -1
- package/dist/mud2.js +0 -25
- package/dist/render-solidity/index.d.ts +0 -171
- package/dist/render-solidity/index.js +0 -49
- package/dist/render-ts/index.d.ts +0 -26
- package/dist/render-ts/index.js +0 -14
- package/dist/utils/deprecated/index.d.ts +0 -76
- package/dist/utils/deprecated/index.js +0 -36
- package/dist/utils/index.d.ts +0 -88
- package/dist/utils/index.js +0 -39
- package/src/commands/deploy-v2.ts +0 -112
- package/src/commands/deprecated/bulkupload.ts +0 -50
- package/src/commands/deprecated/call-system.ts +0 -70
- package/src/commands/deprecated/codegen-libdeploy.ts +0 -29
- package/src/commands/deprecated/deploy-contracts.ts +0 -120
- package/src/commands/deprecated/index.ts +0 -22
- package/src/commands/deprecated/system-types.ts +0 -29
- package/src/commands/deprecated/test.ts +0 -53
- package/src/commands/deprecated/trace.ts +0 -81
- package/src/commands/deprecated/types.ts +0 -33
- package/src/commands/gas-report.ts +0 -219
- package/src/commands/test-v2.ts +0 -71
- package/src/commands/tsgen.ts +0 -33
- package/src/contracts/BulkUpload.sol +0 -174
- package/src/contracts/Deploy.sol +0 -23
- package/src/contracts/LibDeploy.ejs +0 -121
- package/src/contracts/LibDeploy.sol +0 -23
- package/src/contracts/LibDeployStub.sol +0 -23
- package/src/mud2.ts +0 -29
- package/src/render-solidity/common.ts +0 -138
- package/src/render-solidity/field.ts +0 -160
- package/src/render-solidity/index.ts +0 -10
- package/src/render-solidity/record.ts +0 -158
- package/src/render-solidity/renderSystemInterface.ts +0 -31
- package/src/render-solidity/renderTable.ts +0 -164
- package/src/render-solidity/renderTableIndex.ts +0 -15
- package/src/render-solidity/renderTypeHelpers.ts +0 -99
- package/src/render-solidity/renderTypes.ts +0 -19
- package/src/render-solidity/renderTypesFromConfig.ts +0 -13
- package/src/render-solidity/renderWorld.ts +0 -24
- package/src/render-solidity/tableOptions.ts +0 -107
- package/src/render-solidity/tablegen.ts +0 -35
- package/src/render-solidity/types.ts +0 -111
- package/src/render-solidity/userType.ts +0 -131
- package/src/render-solidity/worldgen.ts +0 -59
- package/src/render-ts/index.ts +0 -5
- package/src/render-ts/recsV1TableOptions.ts +0 -39
- package/src/render-ts/renderRecsV1Tables.ts +0 -31
- package/src/render-ts/schemaTypesToRecsTypeStrings.ts +0 -202
- package/src/render-ts/tsgen.ts +0 -12
- package/src/render-ts/types.ts +0 -13
- package/src/utils/contractToInterface.ts +0 -132
- package/src/utils/deploy-v2.ts +0 -518
- package/src/utils/deprecated/build.ts +0 -55
- package/src/utils/deprecated/codegen.ts +0 -42
- package/src/utils/deprecated/constants.ts +0 -2
- package/src/utils/deprecated/deploy.ts +0 -111
- package/src/utils/deprecated/exec.ts +0 -18
- package/src/utils/deprecated/findLog.ts +0 -8
- package/src/utils/deprecated/hsr.ts +0 -71
- package/src/utils/deprecated/ids.ts +0 -14
- package/src/utils/deprecated/index.ts +0 -8
- package/src/utils/deprecated/typegen.ts +0 -133
- package/src/utils/execLog.ts +0 -22
- package/src/utils/format.ts +0 -39
- package/src/utils/formatAndWrite.ts +0 -21
- package/src/utils/foundry.ts +0 -103
- package/src/utils/getChainId.ts +0 -10
- package/src/utils/index.ts +0 -5
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
import { execa } from "execa";
|
|
2
|
-
import path from "path";
|
|
3
|
-
import type { CommandModule } from "yargs";
|
|
4
|
-
|
|
5
|
-
const contractsDirectory = new URL("../src/contracts", import.meta.url).pathname;
|
|
6
|
-
|
|
7
|
-
type Options = {
|
|
8
|
-
statePath: string;
|
|
9
|
-
worldAddress: string;
|
|
10
|
-
rpc: string;
|
|
11
|
-
};
|
|
12
|
-
|
|
13
|
-
const commandModule: CommandModule<Options, Options> = {
|
|
14
|
-
command: "bulkupload",
|
|
15
|
-
|
|
16
|
-
describe: "Uploads the provided ECS state to the provided World",
|
|
17
|
-
|
|
18
|
-
builder(yargs) {
|
|
19
|
-
return yargs.options({
|
|
20
|
-
statePath: { type: "string", demandOption: true, desc: "Path to the ECS state to upload" },
|
|
21
|
-
worldAddress: { type: "string", demandOption: true, desc: "Contract address of the World to upload to" },
|
|
22
|
-
rpc: { type: "string", demandOption: true, desc: "JSON RPC endpoint" },
|
|
23
|
-
});
|
|
24
|
-
},
|
|
25
|
-
|
|
26
|
-
async handler({ statePath, worldAddress, rpc }) {
|
|
27
|
-
console.log("Uploading state at ", statePath, "to", worldAddress, "on", rpc);
|
|
28
|
-
const url = path.join(contractsDirectory, "BulkUpload.sol");
|
|
29
|
-
console.log("Using BulkUpload script from", url);
|
|
30
|
-
|
|
31
|
-
try {
|
|
32
|
-
await execa("forge", [
|
|
33
|
-
"script",
|
|
34
|
-
"--sig",
|
|
35
|
-
'"run(string, address)"',
|
|
36
|
-
"--rpc-url",
|
|
37
|
-
rpc,
|
|
38
|
-
`${url}:BulkUpload`,
|
|
39
|
-
statePath,
|
|
40
|
-
worldAddress,
|
|
41
|
-
]);
|
|
42
|
-
} catch (e) {
|
|
43
|
-
console.error(e);
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
process.exit(0);
|
|
47
|
-
},
|
|
48
|
-
};
|
|
49
|
-
|
|
50
|
-
export default commandModule;
|
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
import { defaultAbiCoder as abi } from "ethers/lib/utils.js";
|
|
2
|
-
import path from "path";
|
|
3
|
-
import type { CommandModule } from "yargs";
|
|
4
|
-
import { execLog } from "../../utils/deprecated/index.js";
|
|
5
|
-
import { getTestDirectory } from "../../utils/foundry.js";
|
|
6
|
-
|
|
7
|
-
type Options = {
|
|
8
|
-
rpc?: string;
|
|
9
|
-
caller?: string;
|
|
10
|
-
world: string;
|
|
11
|
-
systemId?: string;
|
|
12
|
-
systemAddress?: string;
|
|
13
|
-
argTypes?: string[];
|
|
14
|
-
args?: (string | number)[];
|
|
15
|
-
calldata?: string;
|
|
16
|
-
broadcast?: boolean;
|
|
17
|
-
callerPrivateKey?: string;
|
|
18
|
-
debug?: boolean;
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
const commandModule: CommandModule<Options, Options> = {
|
|
22
|
-
command: "call-system",
|
|
23
|
-
|
|
24
|
-
describe: "Execute a mud system",
|
|
25
|
-
|
|
26
|
-
builder(yargs) {
|
|
27
|
-
return yargs.options({
|
|
28
|
-
rpc: { type: "string", description: "json rpc endpoint, defaults to http://localhost:8545" },
|
|
29
|
-
caller: { type: "string", description: "caller address" },
|
|
30
|
-
world: { type: "string", required: true, description: "world contract address" },
|
|
31
|
-
systemId: { type: "string", description: "system id preimage (eg mud.system.Move)" },
|
|
32
|
-
systemAddress: { type: "string", description: "system address (alternative to system id)" },
|
|
33
|
-
argTypes: { type: "array", string: true, description: "system argument types for abi encoding" },
|
|
34
|
-
args: { type: "array", description: "system arguments" },
|
|
35
|
-
calldata: { type: "string", description: "abi encoded system arguments (instead of args/argTypes)" },
|
|
36
|
-
broadcast: { type: "boolean", description: "send txs to the chain" },
|
|
37
|
-
callerPrivateKey: {
|
|
38
|
-
type: "string",
|
|
39
|
-
description: "must be set if broadcast is set, must correspond to caller address",
|
|
40
|
-
},
|
|
41
|
-
debug: { type: "boolean", description: "open debugger" },
|
|
42
|
-
});
|
|
43
|
-
},
|
|
44
|
-
|
|
45
|
-
async handler({ rpc, caller, world, systemId, argTypes, args, calldata, broadcast, callerPrivateKey, debug }) {
|
|
46
|
-
const encodedArgs = calldata ?? (argTypes && args && abi.encode(argTypes, args)) ?? "";
|
|
47
|
-
const testDir = await getTestDirectory();
|
|
48
|
-
await execLog("forge", [
|
|
49
|
-
"script",
|
|
50
|
-
"--fork-url",
|
|
51
|
-
rpc ?? "http://localhost:8545", // default anvil rpc
|
|
52
|
-
"--sig",
|
|
53
|
-
"debug(address,address,string,bytes,bool)",
|
|
54
|
-
path.join(testDir, "utils/Debug.sol"), // the cli expects the Debug.sol file at this path
|
|
55
|
-
caller ?? "0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266", // default anvil deployer
|
|
56
|
-
world,
|
|
57
|
-
systemId || "",
|
|
58
|
-
encodedArgs,
|
|
59
|
-
broadcast ? "true" : "false",
|
|
60
|
-
"-vvvvv",
|
|
61
|
-
broadcast ? "--broadcast" : "",
|
|
62
|
-
callerPrivateKey ? `--private-key ${callerPrivateKey}` : "",
|
|
63
|
-
debug ? "--debug" : "",
|
|
64
|
-
]);
|
|
65
|
-
|
|
66
|
-
process.exit(0);
|
|
67
|
-
},
|
|
68
|
-
};
|
|
69
|
-
|
|
70
|
-
export default commandModule;
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import type { CommandModule } from "yargs";
|
|
2
|
-
import { generateLibDeploy } from "../../utils/deprecated/index.js";
|
|
3
|
-
|
|
4
|
-
type Options = {
|
|
5
|
-
config: string;
|
|
6
|
-
out: string;
|
|
7
|
-
systems?: string;
|
|
8
|
-
};
|
|
9
|
-
|
|
10
|
-
const commandModule: CommandModule<Options, Options> = {
|
|
11
|
-
command: "codegen-libdeploy",
|
|
12
|
-
|
|
13
|
-
describe: "Generate LibDeploy.sol from given deploy config",
|
|
14
|
-
|
|
15
|
-
builder(yargs) {
|
|
16
|
-
return yargs.options({
|
|
17
|
-
config: { type: "string", default: "./deploy.json", desc: "Component and system deployment configuration" },
|
|
18
|
-
out: { type: "string", default: ".", desc: "Output directory for LibDeploy.sol" },
|
|
19
|
-
systems: { type: "string", desc: "Only generate deploy code for the given systems" },
|
|
20
|
-
});
|
|
21
|
-
},
|
|
22
|
-
|
|
23
|
-
async handler({ config, out, systems }) {
|
|
24
|
-
await generateLibDeploy(config, out, systems);
|
|
25
|
-
process.exit(0);
|
|
26
|
-
},
|
|
27
|
-
};
|
|
28
|
-
|
|
29
|
-
export default commandModule;
|
|
@@ -1,120 +0,0 @@
|
|
|
1
|
-
import type { CommandModule } from "yargs";
|
|
2
|
-
import { DeployOptions, generateAndDeploy, hsr } from "../../utils/deprecated/index.js";
|
|
3
|
-
import openurl from "openurl";
|
|
4
|
-
import chalk from "chalk";
|
|
5
|
-
import { getSrcDirectory } from "../../utils/foundry.js";
|
|
6
|
-
|
|
7
|
-
type Options = DeployOptions & {
|
|
8
|
-
watch?: boolean;
|
|
9
|
-
dev?: boolean;
|
|
10
|
-
openUrl?: string;
|
|
11
|
-
};
|
|
12
|
-
|
|
13
|
-
const commandModule: CommandModule<Options, Options> = {
|
|
14
|
-
command: "deploy-contracts",
|
|
15
|
-
|
|
16
|
-
describe: "Deploy mud contracts",
|
|
17
|
-
|
|
18
|
-
builder(yargs) {
|
|
19
|
-
return yargs.options({
|
|
20
|
-
config: { type: "string", default: "./deploy.json", desc: "Component and system deployment configuration" },
|
|
21
|
-
deployerPrivateKey: { type: "string", desc: "Deployer private key. If omitted, deployment is not broadcasted." },
|
|
22
|
-
worldAddress: { type: "string", desc: "World address to deploy to. If omitted, a new World is deployed." },
|
|
23
|
-
rpc: { type: "string", default: "http://localhost:8545", desc: "RPC URL of the network to deploy to." },
|
|
24
|
-
systems: { type: "string", desc: "Only upgrade the given systems. Requires World address." },
|
|
25
|
-
reuseComponents: { type: "boolean", desc: "Skip deploying components and initialization." },
|
|
26
|
-
watch: { type: "boolean", desc: "Automatically redeploy changed systems" },
|
|
27
|
-
dev: { type: "boolean", desc: "Automatically use funded dev private key for local development" },
|
|
28
|
-
openUrl: {
|
|
29
|
-
type: "string",
|
|
30
|
-
desc: "Opens a browser at the provided url with the worldAddress url param prefilled",
|
|
31
|
-
},
|
|
32
|
-
gasPrice: { type: "number", desc: "Gas price to set for deploy transactions" },
|
|
33
|
-
});
|
|
34
|
-
},
|
|
35
|
-
|
|
36
|
-
async handler({
|
|
37
|
-
config,
|
|
38
|
-
deployerPrivateKey,
|
|
39
|
-
worldAddress,
|
|
40
|
-
rpc,
|
|
41
|
-
systems,
|
|
42
|
-
reuseComponents,
|
|
43
|
-
watch,
|
|
44
|
-
dev,
|
|
45
|
-
openUrl,
|
|
46
|
-
gasPrice,
|
|
47
|
-
}) {
|
|
48
|
-
if (systems != null && !worldAddress) {
|
|
49
|
-
console.error("Error: Upgrading systems requires a World address.");
|
|
50
|
-
process.exit(1);
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
deployerPrivateKey =
|
|
54
|
-
deployerPrivateKey ??
|
|
55
|
-
(dev
|
|
56
|
-
? "0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80" // Default anvil private key
|
|
57
|
-
: undefined);
|
|
58
|
-
|
|
59
|
-
// Deploy world, components and systems
|
|
60
|
-
let genDeployResult: Awaited<ReturnType<typeof generateAndDeploy>>;
|
|
61
|
-
try {
|
|
62
|
-
genDeployResult = await generateAndDeploy({
|
|
63
|
-
config,
|
|
64
|
-
deployerPrivateKey,
|
|
65
|
-
worldAddress,
|
|
66
|
-
rpc,
|
|
67
|
-
systems,
|
|
68
|
-
reuseComponents,
|
|
69
|
-
clear: true,
|
|
70
|
-
gasPrice,
|
|
71
|
-
});
|
|
72
|
-
} catch (e: any) {
|
|
73
|
-
if (!e.stderr) {
|
|
74
|
-
// log error if it wasn't piped
|
|
75
|
-
console.log(e);
|
|
76
|
-
}
|
|
77
|
-
console.log(chalk.red("\n-----------\nError during generateAndDeploy (see above)"));
|
|
78
|
-
process.exit();
|
|
79
|
-
}
|
|
80
|
-
const { deployedWorldAddress, initialBlockNumber } = genDeployResult;
|
|
81
|
-
console.log("World deployed at", worldAddress, "at block", initialBlockNumber);
|
|
82
|
-
|
|
83
|
-
if (deployedWorldAddress && openUrl) {
|
|
84
|
-
const url = new URL(openUrl);
|
|
85
|
-
url.searchParams.set("worldAddress", deployedWorldAddress);
|
|
86
|
-
console.log("");
|
|
87
|
-
console.log(chalk.cyan("Opening client URL to", url.toString()));
|
|
88
|
-
console.log("");
|
|
89
|
-
openurl.open(url.toString());
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
// Set up watcher for system files to redeploy on change
|
|
93
|
-
if (watch) {
|
|
94
|
-
const srcDir = await getSrcDirectory();
|
|
95
|
-
hsr(srcDir, async (systems: string[]) => {
|
|
96
|
-
try {
|
|
97
|
-
return await generateAndDeploy({
|
|
98
|
-
config,
|
|
99
|
-
deployerPrivateKey,
|
|
100
|
-
worldAddress,
|
|
101
|
-
rpc,
|
|
102
|
-
systems,
|
|
103
|
-
gasPrice,
|
|
104
|
-
reuseComponents: true,
|
|
105
|
-
});
|
|
106
|
-
} catch (e: any) {
|
|
107
|
-
if (!e.stderr) {
|
|
108
|
-
// log error if it wasn't piped
|
|
109
|
-
console.log(e);
|
|
110
|
-
}
|
|
111
|
-
console.log(chalk.red("\n-----------\nError during generateAndDeploy in HSR (see above)"));
|
|
112
|
-
}
|
|
113
|
-
});
|
|
114
|
-
} else {
|
|
115
|
-
process.exit(0);
|
|
116
|
-
}
|
|
117
|
-
},
|
|
118
|
-
};
|
|
119
|
-
|
|
120
|
-
export default commandModule;
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { CommandModule } from "yargs";
|
|
2
|
-
|
|
3
|
-
import bulkupload from "./bulkupload.js";
|
|
4
|
-
import callSystem from "./call-system.js";
|
|
5
|
-
import codegenLibdeploy from "./codegen-libdeploy.js";
|
|
6
|
-
import deployContracts from "./deploy-contracts.js";
|
|
7
|
-
import systemTypes from "./system-types.js";
|
|
8
|
-
import test from "./test.js";
|
|
9
|
-
import trace from "./trace.js";
|
|
10
|
-
import types from "./types.js";
|
|
11
|
-
|
|
12
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- Each command has different options
|
|
13
|
-
export const commands: CommandModule<any, any>[] = [
|
|
14
|
-
bulkupload,
|
|
15
|
-
callSystem,
|
|
16
|
-
deployContracts,
|
|
17
|
-
codegenLibdeploy,
|
|
18
|
-
systemTypes,
|
|
19
|
-
test,
|
|
20
|
-
trace,
|
|
21
|
-
types,
|
|
22
|
-
];
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import type { CommandModule } from "yargs";
|
|
2
|
-
import { generateSystemTypes } from "../../utils/deprecated/index.js";
|
|
3
|
-
import { systemsDir } from "../../utils/deprecated/constants.js";
|
|
4
|
-
|
|
5
|
-
type Options = {
|
|
6
|
-
outputDir: string;
|
|
7
|
-
};
|
|
8
|
-
|
|
9
|
-
const commandModule: CommandModule<Options, Options> = {
|
|
10
|
-
command: "system-types",
|
|
11
|
-
|
|
12
|
-
describe: `Generates system type file. Note: assumes contracts of all systems in <forge src path>/${systemsDir} folder, ABIs of all systems in ./abi and typechain generated types in ./types/ethers-contracts`,
|
|
13
|
-
|
|
14
|
-
builder(yargs) {
|
|
15
|
-
return yargs.options({
|
|
16
|
-
outputDir: {
|
|
17
|
-
type: "string",
|
|
18
|
-
description: "generated types directory, defaults to ./types",
|
|
19
|
-
default: "./types",
|
|
20
|
-
},
|
|
21
|
-
});
|
|
22
|
-
},
|
|
23
|
-
|
|
24
|
-
async handler({ outputDir }) {
|
|
25
|
-
await generateSystemTypes(outputDir);
|
|
26
|
-
},
|
|
27
|
-
};
|
|
28
|
-
|
|
29
|
-
export default commandModule;
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
import type { CommandModule } from "yargs";
|
|
2
|
-
import { execLog, generateLibDeploy, resetLibDeploy } from "../../utils/deprecated/index.js";
|
|
3
|
-
import { getTestDirectory } from "../../utils/foundry.js";
|
|
4
|
-
|
|
5
|
-
type Options = {
|
|
6
|
-
forgeOpts?: string;
|
|
7
|
-
config: string;
|
|
8
|
-
v: number;
|
|
9
|
-
};
|
|
10
|
-
|
|
11
|
-
const commandModule: CommandModule<Options, Options> = {
|
|
12
|
-
command: "test",
|
|
13
|
-
|
|
14
|
-
describe: "Run contract tests",
|
|
15
|
-
|
|
16
|
-
builder(yargs) {
|
|
17
|
-
return yargs.options({
|
|
18
|
-
forgeOpts: { type: "string", desc: "Options passed to `forge test` command" },
|
|
19
|
-
config: { type: "string", default: "./deploy.json", desc: "Component and system deployment configuration" },
|
|
20
|
-
v: { type: "number", default: 2, desc: "Verbosity for forge test" },
|
|
21
|
-
});
|
|
22
|
-
},
|
|
23
|
-
|
|
24
|
-
async handler({ forgeOpts, config, v }) {
|
|
25
|
-
const testDir = await getTestDirectory();
|
|
26
|
-
|
|
27
|
-
// Generate LibDeploy.sol
|
|
28
|
-
console.log("Generate LibDeploy.sol");
|
|
29
|
-
await generateLibDeploy(config, testDir);
|
|
30
|
-
|
|
31
|
-
// Call forge test
|
|
32
|
-
const child = execLog("forge", [
|
|
33
|
-
"test",
|
|
34
|
-
...(v ? ["-" + [...new Array(v)].map(() => "v").join("")] : []),
|
|
35
|
-
...(forgeOpts?.split(" ") || []),
|
|
36
|
-
]);
|
|
37
|
-
|
|
38
|
-
process.on("SIGINT", async () => {
|
|
39
|
-
console.log("\ngracefully shutting down from SIGINT (Crtl-C)");
|
|
40
|
-
child.kill();
|
|
41
|
-
await resetLibDeploy(testDir);
|
|
42
|
-
process.exit();
|
|
43
|
-
});
|
|
44
|
-
|
|
45
|
-
await child;
|
|
46
|
-
|
|
47
|
-
// Reset LibDeploy.sol
|
|
48
|
-
console.log("Reset LibDeploy.sol");
|
|
49
|
-
await resetLibDeploy(testDir);
|
|
50
|
-
},
|
|
51
|
-
};
|
|
52
|
-
|
|
53
|
-
export default commandModule;
|
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
import type { CommandModule } from "yargs";
|
|
2
|
-
import { execLog, extractIdFromFile, keccak256 } from "../../utils/deprecated/index.js";
|
|
3
|
-
import { readFileSync } from "fs";
|
|
4
|
-
import { Contract } from "ethers";
|
|
5
|
-
import { JsonRpcProvider } from "@ethersproject/providers";
|
|
6
|
-
import WorldAbi from "@latticexyz/solecs/abi/World.json" assert { type: "json" };
|
|
7
|
-
import { getSrcDirectory } from "../../utils/foundry.js";
|
|
8
|
-
import path from "path";
|
|
9
|
-
import { componentsDir, systemsDir } from "../../utils/deprecated/constants.js";
|
|
10
|
-
|
|
11
|
-
type Options = {
|
|
12
|
-
config?: string;
|
|
13
|
-
world: string;
|
|
14
|
-
tx: string;
|
|
15
|
-
rpc?: string;
|
|
16
|
-
debug?: boolean;
|
|
17
|
-
};
|
|
18
|
-
|
|
19
|
-
const commandModule: CommandModule<Options, Options> = {
|
|
20
|
-
command: "trace",
|
|
21
|
-
|
|
22
|
-
describe: "Display the trace of a transaction",
|
|
23
|
-
|
|
24
|
-
builder(yargs) {
|
|
25
|
-
return yargs.options({
|
|
26
|
-
config: { type: "string", description: "path to mud deploy config (deploy.json)" },
|
|
27
|
-
world: { type: "string", required: true, description: "world contract address" },
|
|
28
|
-
tx: { type: "string", required: true, description: "tx hash to replay" },
|
|
29
|
-
rpc: { type: "string", description: "json rpc endpoint, defaults to http://localhost:8545" },
|
|
30
|
-
debug: { type: "boolean", description: "open debugger" },
|
|
31
|
-
});
|
|
32
|
-
},
|
|
33
|
-
|
|
34
|
-
async handler({ config, world, rpc, tx, debug }) {
|
|
35
|
-
const wd = process.cwd();
|
|
36
|
-
const deployData = config && JSON.parse(readFileSync(config, { encoding: "utf8" }));
|
|
37
|
-
const labels = [];
|
|
38
|
-
|
|
39
|
-
const rpcUrl = rpc || "http://localhost:8545";
|
|
40
|
-
const provider = new JsonRpcProvider(rpcUrl);
|
|
41
|
-
const World = new Contract(world, WorldAbi.abi, provider);
|
|
42
|
-
|
|
43
|
-
if (deployData) {
|
|
44
|
-
const srcDir = await getSrcDirectory();
|
|
45
|
-
|
|
46
|
-
// Create component labels
|
|
47
|
-
const componentPromises = deployData.components.map(async (component: string) => {
|
|
48
|
-
const filePath = path.join(wd, srcDir, componentsDir, `${component}.sol`);
|
|
49
|
-
const id = extractIdFromFile(filePath);
|
|
50
|
-
if (!id) return;
|
|
51
|
-
const address = await World.getComponent(keccak256(id));
|
|
52
|
-
return [component, address];
|
|
53
|
-
});
|
|
54
|
-
// Create system labels
|
|
55
|
-
const systemPromises = deployData.systems.map(async (system: { name: string }) => {
|
|
56
|
-
const filePath = path.join(wd, srcDir, systemsDir, `${system.name}.sol`);
|
|
57
|
-
const id = extractIdFromFile(filePath);
|
|
58
|
-
if (!id) return;
|
|
59
|
-
const address = await World.getSystemAddress(keccak256(id));
|
|
60
|
-
return [system.name, address];
|
|
61
|
-
});
|
|
62
|
-
|
|
63
|
-
const components = await Promise.all(componentPromises);
|
|
64
|
-
const systems = await Promise.all(systemPromises);
|
|
65
|
-
|
|
66
|
-
labels.push(...components, ...systems);
|
|
67
|
-
}
|
|
68
|
-
await execLog("cast", [
|
|
69
|
-
"run",
|
|
70
|
-
...labels.map((label) => ["--label", `${label[1]}:${label[0]}`]).flat(),
|
|
71
|
-
...(debug ? ["--debug"] : []),
|
|
72
|
-
`--rpc-url`,
|
|
73
|
-
`${rpcUrl}`,
|
|
74
|
-
`${tx}`,
|
|
75
|
-
]);
|
|
76
|
-
|
|
77
|
-
process.exit(0);
|
|
78
|
-
},
|
|
79
|
-
};
|
|
80
|
-
|
|
81
|
-
export default commandModule;
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import type { CommandModule } from "yargs";
|
|
2
|
-
import { generateTypes } from "../../utils/deprecated/index.js";
|
|
3
|
-
|
|
4
|
-
type Options = {
|
|
5
|
-
abiDir?: string;
|
|
6
|
-
outputDir: string;
|
|
7
|
-
};
|
|
8
|
-
|
|
9
|
-
const commandModule: CommandModule<Options, Options> = {
|
|
10
|
-
command: "types",
|
|
11
|
-
|
|
12
|
-
describe: "Generates typescript types for contracts and systems.",
|
|
13
|
-
|
|
14
|
-
builder(yargs) {
|
|
15
|
-
return yargs.options({
|
|
16
|
-
abiDir: {
|
|
17
|
-
type: "string",
|
|
18
|
-
description: "Input directory of existing ABI to use to generate types. If not provided, contracts are built.",
|
|
19
|
-
},
|
|
20
|
-
outputDir: {
|
|
21
|
-
type: "string",
|
|
22
|
-
description: "Output directory for generated types. Defaults to ./types",
|
|
23
|
-
default: "./types",
|
|
24
|
-
},
|
|
25
|
-
});
|
|
26
|
-
},
|
|
27
|
-
|
|
28
|
-
async handler({ abiDir, outputDir }) {
|
|
29
|
-
await generateTypes(abiDir, outputDir, { clear: true });
|
|
30
|
-
},
|
|
31
|
-
};
|
|
32
|
-
|
|
33
|
-
export default commandModule;
|