@latticexyz/common 2.2.19 → 2.2.20-391575967cd09bd527d819222232a54a7d722fc2

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/foundry.d.ts CHANGED
@@ -40,30 +40,5 @@ declare function getOutDirectory(profile?: string): Promise<string>;
40
40
  * @returns The rpc url
41
41
  */
42
42
  declare function getRpcUrl(profile?: string): Promise<string>;
43
- /**
44
- * Execute a forge command
45
- * @param args The arguments to pass to forge
46
- * @param options { profile?: The foundry profile to use; silent?: If true, nothing will be logged to the console }
47
- */
48
- declare function forge(args: string[], options?: {
49
- profile?: string;
50
- silent?: boolean;
51
- env?: NodeJS.ProcessEnv;
52
- cwd?: string;
53
- }): Promise<void>;
54
- /**
55
- * Execute a cast command
56
- * @param args The arguments to pass to cast
57
- * @returns Stdout of the command
58
- */
59
- declare function cast(args: string[], options?: {
60
- profile?: string;
61
- }): Promise<string>;
62
- /**
63
- * Start an anvil chain
64
- * @param args The arguments to pass to anvil
65
- * @returns Stdout of the command
66
- */
67
- declare function anvil(args: string[]): Promise<string>;
68
43
 
69
- export { type ForgeConfig, anvil, cast, forge, getForgeConfig, getOutDirectory, getRpcUrl, getScriptDirectory, getSrcDirectory, getTestDirectory };
44
+ export { type ForgeConfig, getForgeConfig, getOutDirectory, getRpcUrl, getScriptDirectory, getSrcDirectory, getTestDirectory };
package/dist/foundry.js CHANGED
@@ -22,46 +22,7 @@ async function getOutDirectory(profile) {
22
22
  async function getRpcUrl(profile) {
23
23
  return process.env.FOUNDRY_ETH_RPC_URL || process.env.RPC_HTTP_URL || process.env.RPC_URL || (await getForgeConfig(profile)).eth_rpc_url || "http://127.0.0.1:8545";
24
24
  }
25
- async function forge(args, options) {
26
- const execOptions = {
27
- env: { FOUNDRY_PROFILE: options?.profile, ...options?.env },
28
- stdout: "inherit",
29
- stderr: "pipe",
30
- cwd: options?.cwd
31
- };
32
- await (options?.silent ? execa("forge", args, execOptions) : execLog("forge", args, execOptions));
33
- }
34
- async function cast(args, options) {
35
- return execLog("cast", args, {
36
- env: { FOUNDRY_PROFILE: options?.profile }
37
- });
38
- }
39
- async function anvil(args) {
40
- return execLog("anvil", args);
41
- }
42
- async function execLog(command, args, options) {
43
- const commandString = `${command} ${args.join(" ")}`;
44
- try {
45
- console.log(`running "${commandString}"`);
46
- const { stdout } = await execa(command, args, {
47
- ...options,
48
- stdout: "pipe",
49
- stderr: "pipe",
50
- lines: false,
51
- encoding: "utf8"
52
- });
53
- return stdout;
54
- } catch (error) {
55
- let errorMessage = error?.stderr || error?.message || "";
56
- errorMessage += `
57
- Error running "${commandString}"`;
58
- throw new Error(errorMessage);
59
- }
60
- }
61
25
  export {
62
- anvil,
63
- cast,
64
- forge,
65
26
  getForgeConfig,
66
27
  getOutDirectory,
67
28
  getRpcUrl,
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/foundry/index.ts"],"sourcesContent":["import { execa, Options } from \"execa\";\n\nexport interface ForgeConfig {\n // project\n src: string;\n test: string;\n script: string;\n out: string;\n libs: string[];\n cache: boolean;\n cache_path: string;\n eth_rpc_url: string | null;\n\n // compiler\n remappings: string[];\n\n // all unspecified keys (this interface is far from comprehensive)\n [key: string]: unknown;\n}\n\n/**\n * Get forge config as a parsed json object.\n */\nexport async function getForgeConfig(profile?: string): Promise<ForgeConfig> {\n const { stdout } = await execa(\"forge\", [\"config\", \"--json\"], {\n stdio: [\"inherit\", \"pipe\", \"pipe\"],\n env: { FOUNDRY_PROFILE: profile },\n });\n\n return JSON.parse(stdout) as ForgeConfig;\n}\n\n/**\n * Get the value of \"src\" from forge config.\n * The path to the contract sources relative to the root of the project.\n */\nexport async function getSrcDirectory(profile?: string): Promise<string> {\n return (await getForgeConfig(profile)).src;\n}\n\n/**\n * Get the value of \"script\" from forge config.\n * The path to the contract sources relative to the root of the project.\n */\nexport async function getScriptDirectory(profile?: string): Promise<string> {\n return (await getForgeConfig(profile)).script;\n}\n\n/**\n * Get the value of \"test\" from forge config.\n * The path to the test contract sources relative to the root of the project.\n */\nexport async function getTestDirectory(profile?: string): Promise<string> {\n return (await getForgeConfig(profile)).test;\n}\n\n/**\n * Get the value of \"out\" from forge config.\n * The path to put contract artifacts in, relative to the root of the project.\n */\nexport async function getOutDirectory(profile?: string): Promise<string> {\n return (await getForgeConfig(profile)).out;\n}\n\n/**\n * Get the value of \"eth_rpc_url\" from forge config, default to \"http://127.0.0.1:8545\"\n * @param profile The foundry profile to use\n * @returns The rpc url\n */\nexport async function getRpcUrl(profile?: string): Promise<string> {\n return (\n process.env.FOUNDRY_ETH_RPC_URL ||\n process.env.RPC_HTTP_URL ||\n process.env.RPC_URL ||\n (await getForgeConfig(profile)).eth_rpc_url ||\n \"http://127.0.0.1:8545\"\n );\n}\n\n/**\n * Execute a forge command\n * @param args The arguments to pass to forge\n * @param options { profile?: The foundry profile to use; silent?: If true, nothing will be logged to the console }\n */\nexport async function forge(\n args: string[],\n options?: { profile?: string; silent?: boolean; env?: NodeJS.ProcessEnv; cwd?: string },\n): Promise<void> {\n const execOptions = {\n env: { FOUNDRY_PROFILE: options?.profile, ...options?.env },\n stdout: \"inherit\",\n stderr: \"pipe\",\n cwd: options?.cwd,\n } satisfies Options;\n\n await (options?.silent ? execa(\"forge\", args, execOptions) : execLog(\"forge\", args, execOptions));\n}\n\n/**\n * Execute a cast command\n * @param args The arguments to pass to cast\n * @returns Stdout of the command\n */\nexport async function cast(args: string[], options?: { profile?: string }): Promise<string> {\n return execLog(\"cast\", args, {\n env: { FOUNDRY_PROFILE: options?.profile },\n });\n}\n\n/**\n * Start an anvil chain\n * @param args The arguments to pass to anvil\n * @returns Stdout of the command\n */\nexport async function anvil(args: string[]): Promise<string> {\n return execLog(\"anvil\", args);\n}\n\n/**\n * Executes the given command, returns the stdout, and logs the command to the console.\n * Throws an error if the command fails.\n * @param command The command to execute\n * @param args The arguments to pass to the command\n * @returns The stdout of the command\n */\nasync function execLog(command: string, args: string[], options?: Options): Promise<string> {\n const commandString = `${command} ${args.join(\" \")}`;\n try {\n console.log(`running \"${commandString}\"`);\n const { stdout } = await execa(command, args, {\n ...options,\n stdout: \"pipe\",\n stderr: \"pipe\",\n lines: false,\n encoding: \"utf8\",\n });\n return stdout;\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n } catch (error: any) {\n let errorMessage = error?.stderr || error?.message || \"\";\n errorMessage += `\\nError running \"${commandString}\"`;\n throw new Error(errorMessage);\n }\n}\n"],"mappings":";AAAA,SAAS,aAAsB;AAuB/B,eAAsB,eAAe,SAAwC;AAC3E,QAAM,EAAE,OAAO,IAAI,MAAM,MAAM,SAAS,CAAC,UAAU,QAAQ,GAAG;AAAA,IAC5D,OAAO,CAAC,WAAW,QAAQ,MAAM;AAAA,IACjC,KAAK,EAAE,iBAAiB,QAAQ;AAAA,EAClC,CAAC;AAED,SAAO,KAAK,MAAM,MAAM;AAC1B;AAMA,eAAsB,gBAAgB,SAAmC;AACvE,UAAQ,MAAM,eAAe,OAAO,GAAG;AACzC;AAMA,eAAsB,mBAAmB,SAAmC;AAC1E,UAAQ,MAAM,eAAe,OAAO,GAAG;AACzC;AAMA,eAAsB,iBAAiB,SAAmC;AACxE,UAAQ,MAAM,eAAe,OAAO,GAAG;AACzC;AAMA,eAAsB,gBAAgB,SAAmC;AACvE,UAAQ,MAAM,eAAe,OAAO,GAAG;AACzC;AAOA,eAAsB,UAAU,SAAmC;AACjE,SACE,QAAQ,IAAI,uBACZ,QAAQ,IAAI,gBACZ,QAAQ,IAAI,YACX,MAAM,eAAe,OAAO,GAAG,eAChC;AAEJ;AAOA,eAAsB,MACpB,MACA,SACe;AACf,QAAM,cAAc;AAAA,IAClB,KAAK,EAAE,iBAAiB,SAAS,SAAS,GAAG,SAAS,IAAI;AAAA,IAC1D,QAAQ;AAAA,IACR,QAAQ;AAAA,IACR,KAAK,SAAS;AAAA,EAChB;AAEA,SAAO,SAAS,SAAS,MAAM,SAAS,MAAM,WAAW,IAAI,QAAQ,SAAS,MAAM,WAAW;AACjG;AAOA,eAAsB,KAAK,MAAgB,SAAiD;AAC1F,SAAO,QAAQ,QAAQ,MAAM;AAAA,IAC3B,KAAK,EAAE,iBAAiB,SAAS,QAAQ;AAAA,EAC3C,CAAC;AACH;AAOA,eAAsB,MAAM,MAAiC;AAC3D,SAAO,QAAQ,SAAS,IAAI;AAC9B;AASA,eAAe,QAAQ,SAAiB,MAAgB,SAAoC;AAC1F,QAAM,gBAAgB,GAAG,OAAO,IAAI,KAAK,KAAK,GAAG,CAAC;AAClD,MAAI;AACF,YAAQ,IAAI,YAAY,aAAa,GAAG;AACxC,UAAM,EAAE,OAAO,IAAI,MAAM,MAAM,SAAS,MAAM;AAAA,MAC5C,GAAG;AAAA,MACH,QAAQ;AAAA,MACR,QAAQ;AAAA,MACR,OAAO;AAAA,MACP,UAAU;AAAA,IACZ,CAAC;AACD,WAAO;AAAA,EAET,SAAS,OAAY;AACnB,QAAI,eAAe,OAAO,UAAU,OAAO,WAAW;AACtD,oBAAgB;AAAA,iBAAoB,aAAa;AACjD,UAAM,IAAI,MAAM,YAAY;AAAA,EAC9B;AACF;","names":[]}
1
+ {"version":3,"sources":["../src/foundry/index.ts"],"sourcesContent":["import { execa } from \"execa\";\n\nexport interface ForgeConfig {\n // project\n src: string;\n test: string;\n script: string;\n out: string;\n libs: string[];\n cache: boolean;\n cache_path: string;\n eth_rpc_url: string | null;\n\n // compiler\n remappings: string[];\n\n // all unspecified keys (this interface is far from comprehensive)\n [key: string]: unknown;\n}\n\n/**\n * Get forge config as a parsed json object.\n */\nexport async function getForgeConfig(profile?: string): Promise<ForgeConfig> {\n const { stdout } = await execa(\"forge\", [\"config\", \"--json\"], {\n stdio: [\"inherit\", \"pipe\", \"pipe\"],\n env: { FOUNDRY_PROFILE: profile },\n });\n\n return JSON.parse(stdout) as ForgeConfig;\n}\n\n/**\n * Get the value of \"src\" from forge config.\n * The path to the contract sources relative to the root of the project.\n */\nexport async function getSrcDirectory(profile?: string): Promise<string> {\n return (await getForgeConfig(profile)).src;\n}\n\n/**\n * Get the value of \"script\" from forge config.\n * The path to the contract sources relative to the root of the project.\n */\nexport async function getScriptDirectory(profile?: string): Promise<string> {\n return (await getForgeConfig(profile)).script;\n}\n\n/**\n * Get the value of \"test\" from forge config.\n * The path to the test contract sources relative to the root of the project.\n */\nexport async function getTestDirectory(profile?: string): Promise<string> {\n return (await getForgeConfig(profile)).test;\n}\n\n/**\n * Get the value of \"out\" from forge config.\n * The path to put contract artifacts in, relative to the root of the project.\n */\nexport async function getOutDirectory(profile?: string): Promise<string> {\n return (await getForgeConfig(profile)).out;\n}\n\n/**\n * Get the value of \"eth_rpc_url\" from forge config, default to \"http://127.0.0.1:8545\"\n * @param profile The foundry profile to use\n * @returns The rpc url\n */\nexport async function getRpcUrl(profile?: string): Promise<string> {\n return (\n process.env.FOUNDRY_ETH_RPC_URL ||\n process.env.RPC_HTTP_URL ||\n process.env.RPC_URL ||\n (await getForgeConfig(profile)).eth_rpc_url ||\n \"http://127.0.0.1:8545\"\n );\n}\n"],"mappings":";AAAA,SAAS,aAAa;AAuBtB,eAAsB,eAAe,SAAwC;AAC3E,QAAM,EAAE,OAAO,IAAI,MAAM,MAAM,SAAS,CAAC,UAAU,QAAQ,GAAG;AAAA,IAC5D,OAAO,CAAC,WAAW,QAAQ,MAAM;AAAA,IACjC,KAAK,EAAE,iBAAiB,QAAQ;AAAA,EAClC,CAAC;AAED,SAAO,KAAK,MAAM,MAAM;AAC1B;AAMA,eAAsB,gBAAgB,SAAmC;AACvE,UAAQ,MAAM,eAAe,OAAO,GAAG;AACzC;AAMA,eAAsB,mBAAmB,SAAmC;AAC1E,UAAQ,MAAM,eAAe,OAAO,GAAG;AACzC;AAMA,eAAsB,iBAAiB,SAAmC;AACxE,UAAQ,MAAM,eAAe,OAAO,GAAG;AACzC;AAMA,eAAsB,gBAAgB,SAAmC;AACvE,UAAQ,MAAM,eAAe,OAAO,GAAG;AACzC;AAOA,eAAsB,UAAU,SAAmC;AACjE,SACE,QAAQ,IAAI,uBACZ,QAAQ,IAAI,gBACZ,QAAQ,IAAI,YACX,MAAM,eAAe,OAAO,GAAG,eAChC;AAEJ;","names":[]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@latticexyz/common",
3
- "version": "2.2.19",
3
+ "version": "2.2.20-391575967cd09bd527d819222232a54a7d722fc2",
4
4
  "description": "Common low level logic shared between packages",
5
5
  "repository": {
6
6
  "type": "git",
@@ -69,7 +69,7 @@
69
69
  "p-retry": "^5.1.2",
70
70
  "prettier": "3.2.5",
71
71
  "prettier-plugin-solidity": "1.3.1",
72
- "@latticexyz/schema-type": "2.2.19"
72
+ "@latticexyz/schema-type": "2.2.20-391575967cd09bd527d819222232a54a7d722fc2"
73
73
  },
74
74
  "devDependencies": {
75
75
  "@types/debug": "^4.1.7",