@latticexyz/cli 2.0.0-skystrife-playtest-9e9511d4 → 2.0.0-transaction-context-324984c5

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.
Files changed (61) hide show
  1. package/dist/chunk-22IIKR4S.js +4 -0
  2. package/dist/chunk-22IIKR4S.js.map +1 -0
  3. package/dist/commands-3JV3U43E.js +27 -0
  4. package/dist/commands-3JV3U43E.js.map +1 -0
  5. package/dist/errors-XGN6V2Y3.js +2 -0
  6. package/dist/errors-XGN6V2Y3.js.map +1 -0
  7. package/dist/index.js +0 -1
  8. package/dist/mud.js +1 -14
  9. package/dist/mud.js.map +1 -1
  10. package/package.json +20 -13
  11. package/src/build.ts +44 -0
  12. package/src/commands/build.ts +36 -0
  13. package/src/commands/deploy.ts +7 -30
  14. package/src/commands/dev-contracts.ts +76 -128
  15. package/src/commands/index.ts +2 -0
  16. package/src/commands/set-version.ts +23 -61
  17. package/src/commands/tablegen.ts +3 -2
  18. package/src/commands/test.ts +30 -36
  19. package/src/commands/trace.ts +13 -6
  20. package/src/commands/worldgen.ts +1 -1
  21. package/src/common.ts +1 -0
  22. package/src/debug.ts +10 -0
  23. package/src/deploy/common.ts +76 -0
  24. package/src/deploy/configToTables.ts +68 -0
  25. package/src/deploy/create2/README.md +9 -0
  26. package/src/deploy/create2/deployment.json +7 -0
  27. package/src/deploy/debug.ts +10 -0
  28. package/src/deploy/deploy.ts +116 -0
  29. package/src/deploy/deployWorld.ts +37 -0
  30. package/src/deploy/ensureContract.ts +61 -0
  31. package/src/deploy/ensureContractsDeployed.ts +25 -0
  32. package/src/deploy/ensureDeployer.ts +36 -0
  33. package/src/deploy/ensureFunctions.ts +86 -0
  34. package/src/deploy/ensureModules.ts +73 -0
  35. package/src/deploy/ensureNamespaceOwner.ts +71 -0
  36. package/src/deploy/ensureSystems.ts +162 -0
  37. package/src/deploy/ensureTables.ts +65 -0
  38. package/src/deploy/ensureWorldFactory.ts +118 -0
  39. package/src/deploy/getFunctions.ts +58 -0
  40. package/src/deploy/getResourceAccess.ts +51 -0
  41. package/src/deploy/getResourceIds.ts +31 -0
  42. package/src/deploy/getSystems.ts +48 -0
  43. package/src/deploy/getTableValue.ts +30 -0
  44. package/src/deploy/getTables.ts +59 -0
  45. package/src/deploy/getWorldDeploy.ts +39 -0
  46. package/src/deploy/logsToWorldDeploy.ts +49 -0
  47. package/src/deploy/resolveConfig.ts +151 -0
  48. package/src/deploy/resourceLabel.ts +3 -0
  49. package/src/index.ts +1 -1
  50. package/src/mud.ts +37 -31
  51. package/src/mudPackages.ts +24 -0
  52. package/src/runDeploy.ts +131 -0
  53. package/src/utils/modules/constants.ts +26 -0
  54. package/src/utils/utils/getContractData.ts +32 -0
  55. package/src/utils/utils/postDeploy.ts +25 -0
  56. package/dist/chunk-OJAPOMSC.js +0 -11
  57. package/dist/chunk-OJAPOMSC.js.map +0 -1
  58. package/src/utils/deploy.ts +0 -620
  59. package/src/utils/deployHandler.ts +0 -93
  60. package/src/utils/getChainId.ts +0 -10
  61. package/src/utils/index.ts +0 -6
@@ -1,93 +0,0 @@
1
- import chalk from "chalk";
2
- import path from "path";
3
- import { MUDError } from "@latticexyz/common/errors";
4
- import { loadConfig } from "@latticexyz/config/node";
5
- import { StoreConfig } from "@latticexyz/store";
6
- import { WorldConfig } from "@latticexyz/world";
7
- import { deploy } from "../utils/deploy";
8
- import { forge, getRpcUrl, getSrcDirectory } from "@latticexyz/common/foundry";
9
- import { existsSync, mkdirSync, readFileSync, writeFileSync } from "fs";
10
- import { getChainId } from "../utils/getChainId";
11
- import { getExistingContracts } from "./getExistingContracts";
12
- import { execa } from "execa";
13
-
14
- export type DeployOptions = {
15
- configPath?: string;
16
- printConfig?: boolean;
17
- profile?: string;
18
- priorityFeeMultiplier: number;
19
- clean?: boolean;
20
- debug?: boolean;
21
- saveDeployment: boolean;
22
- rpc?: string;
23
- worldAddress?: string;
24
- srcDir?: string;
25
- disableTxWait: boolean;
26
- pollInterval: number;
27
- skipBuild?: boolean;
28
- };
29
-
30
- export async function deployHandler(args: DeployOptions) {
31
- args.profile ??= process.env.FOUNDRY_PROFILE;
32
- const { configPath, printConfig, profile, clean, skipBuild } = args;
33
-
34
- const rpc = args.rpc ?? (await getRpcUrl(profile));
35
- console.log(
36
- chalk.bgBlue(
37
- chalk.whiteBright(`\n Deploying MUD contracts${profile ? " with profile " + profile : ""} to RPC ${rpc} \n`)
38
- )
39
- );
40
-
41
- if (clean) {
42
- await forge(["clean"], { profile });
43
- }
44
-
45
- // Run forge build
46
- if (!skipBuild) {
47
- await forge(["build", "--skip", "test", "script"], { profile });
48
- await execa("mud", ["abi-ts"], { stdio: "inherit" });
49
- }
50
-
51
- // Get a list of all contract names
52
- const srcDir = args?.srcDir ?? (await getSrcDirectory());
53
- const existingContractNames = getExistingContracts(srcDir).map(({ basename }) => basename);
54
-
55
- // Load the config
56
- const mudConfig = (await loadConfig(configPath)) as StoreConfig & WorldConfig;
57
-
58
- if (printConfig) console.log(chalk.green("\nResolved config:\n"), JSON.stringify(mudConfig, null, 2));
59
-
60
- const privateKey = process.env.PRIVATE_KEY;
61
- if (!privateKey)
62
- throw new MUDError(
63
- `Missing PRIVATE_KEY environment variable.
64
- Run 'echo "PRIVATE_KEY=0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80" > .env'
65
- in your contracts directory to use the default anvil private key.`
66
- );
67
- const deploymentInfo = await deploy(mudConfig, existingContractNames, { ...args, rpc, privateKey });
68
-
69
- if (args.saveDeployment) {
70
- // Write deployment result to file (latest and timestamp)
71
- const chainId = await getChainId(rpc);
72
- const outputDir = path.join(mudConfig.deploysDirectory, chainId.toString());
73
- mkdirSync(outputDir, { recursive: true });
74
- writeFileSync(path.join(outputDir, "latest.json"), JSON.stringify(deploymentInfo, null, 2));
75
- writeFileSync(path.join(outputDir, Date.now() + ".json"), JSON.stringify(deploymentInfo, null, 2));
76
-
77
- const localChains = [1337, 31337];
78
- const deploys = existsSync(mudConfig.worldsFile) ? JSON.parse(readFileSync(mudConfig.worldsFile, "utf-8")) : {};
79
- deploys[chainId] = {
80
- address: deploymentInfo.worldAddress,
81
- // We expect the worlds file to be committed and since local deployments are often a consistent address but different block number, we'll ignore the block number.
82
- blockNumber: localChains.includes(chainId) ? undefined : deploymentInfo.blockNumber,
83
- };
84
- writeFileSync(mudConfig.worldsFile, JSON.stringify(deploys, null, 2));
85
-
86
- console.log(
87
- chalk.bgGreen(chalk.whiteBright(`\n Deployment result (written to ${mudConfig.worldsFile} and ${outputDir}): \n`))
88
- );
89
- }
90
-
91
- console.log(deploymentInfo);
92
- return deploymentInfo;
93
- }
@@ -1,10 +0,0 @@
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
- }
@@ -1,6 +0,0 @@
1
- export * from "./deploy";
2
- export * from "./deployHandler";
3
- export * from "./errors";
4
- export * from "./getChainId";
5
- export * from "./getExistingContracts";
6
- export * from "./printMUD";