@latticexyz/common 2.2.18-c2ad22c7feb566e1731ff16e8be291746bdffb3e → 2.2.18-e1db80ad5648a9c77b757cda3930aa134e0f1c97

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.js CHANGED
@@ -1,3 +1,3 @@
1
- import{execa as s}from"execa";async function n(r){let{stdout:t}=await s("forge",["config","--json"],{stdio:["inherit","pipe","pipe"],env:{FOUNDRY_PROFILE:r}});return JSON.parse(t)}async function u(r){return(await n(r)).src}async function f(r){return(await n(r)).script}async function l(r){return(await n(r)).test}async function P(r){return(await n(r)).out}async function y(r){return process.env.FOUNDRY_ETH_RPC_URL||process.env.RPC_HTTP_URL||process.env.RPC_URL||(await n(r)).eth_rpc_url||"http://127.0.0.1:8545"}async function d(r,t){let e={env:{FOUNDRY_PROFILE:t?.profile,...t?.env},stdout:"inherit",stderr:"pipe",cwd:t?.cwd};await(t?.silent?s("forge",r,e):o("forge",r,e))}async function m(r,t){return o("cast",r,{env:{FOUNDRY_PROFILE:t?.profile}})}async function w(r){return o("anvil",r)}async function o(r,t,e){let c=`${r} ${t.join(" ")}`;try{console.log(`running "${c}"`);let{stdout:i}=await s(r,t,{...e,stdout:"pipe",stderr:"pipe",lines:!1,encoding:"utf8"});return i}catch(i){let g=i?.stderr||i?.message||"";throw g+=`
2
- Error running "${c}"`,new Error(g)}}export{w as anvil,m as cast,d as forge,n as getForgeConfig,P as getOutDirectory,y as getRpcUrl,f as getScriptDirectory,u as getSrcDirectory,l as getTestDirectory};
1
+ import{execa as s}from"execa";async function n(r){let{stdout:t}=await s("forge",["config","--json"],{stdio:["inherit","pipe","pipe"],env:{FOUNDRY_PROFILE:r}});return JSON.parse(t)}async function u(r){return(await n(r)).src}async function f(r){return(await n(r)).script}async function l(r){return(await n(r)).test}async function P(r){return(await n(r)).out}async function y(r){return process.env.FOUNDRY_ETH_RPC_URL||process.env.RPC_HTTP_URL||process.env.RPC_URL||(await n(r)).eth_rpc_url||"http://127.0.0.1:8545"}async function m(r,t){let e={env:{FOUNDRY_PROFILE:t?.profile,...t?.env},stdout:"inherit",stderr:"pipe",cwd:t?.cwd};await(t?.silent?s("forge",r,e):o("forge",r,e))}async function w(r,t){return o("cast",r,{env:{FOUNDRY_PROFILE:t?.profile}})}async function R(r){return o("anvil",r)}async function o(r,t,e){let c=`${r} ${t.join(" ")}`;try{console.log(`running "${c}"`);let{stdout:i}=await s(r,t,{stdout:"pipe",stderr:"pipe",...e});return i}catch(i){let g=i?.stderr||i?.message||"";throw g+=`
2
+ Error running "${c}"`,new Error(g)}}export{R as anvil,w as cast,m as forge,n as getForgeConfig,P as getOutDirectory,y as getRpcUrl,f as getScriptDirectory,u as getSrcDirectory,l as getTestDirectory};
3
3
  //# sourceMappingURL=foundry.js.map
@@ -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,OAAS,SAAAA,MAAsB,QAuB/B,eAAsBC,EAAeC,EAAwC,CAC3E,GAAM,CAAE,OAAAC,CAAO,EAAI,MAAMH,EAAM,QAAS,CAAC,SAAU,QAAQ,EAAG,CAC5D,MAAO,CAAC,UAAW,OAAQ,MAAM,EACjC,IAAK,CAAE,gBAAiBE,CAAQ,CAClC,CAAC,EAED,OAAO,KAAK,MAAMC,CAAM,CAC1B,CAMA,eAAsBC,EAAgBF,EAAmC,CACvE,OAAQ,MAAMD,EAAeC,CAAO,GAAG,GACzC,CAMA,eAAsBG,EAAmBH,EAAmC,CAC1E,OAAQ,MAAMD,EAAeC,CAAO,GAAG,MACzC,CAMA,eAAsBI,EAAiBJ,EAAmC,CACxE,OAAQ,MAAMD,EAAeC,CAAO,GAAG,IACzC,CAMA,eAAsBK,EAAgBL,EAAmC,CACvE,OAAQ,MAAMD,EAAeC,CAAO,GAAG,GACzC,CAOA,eAAsBM,EAAUN,EAAmC,CACjE,OACE,QAAQ,IAAI,qBACZ,QAAQ,IAAI,cACZ,QAAQ,IAAI,UACX,MAAMD,EAAeC,CAAO,GAAG,aAChC,uBAEJ,CAOA,eAAsBO,EACpBC,EACAC,EACe,CACf,IAAMC,EAAc,CAClB,IAAK,CAAE,gBAAiBD,GAAS,QAAS,GAAGA,GAAS,GAAI,EAC1D,OAAQ,UACR,OAAQ,OACR,IAAKA,GAAS,GAChB,EAEA,MAAOA,GAAS,OAASX,EAAM,QAASU,EAAME,CAAW,EAAIC,EAAQ,QAASH,EAAME,CAAW,EACjG,CAOA,eAAsBE,EAAKJ,EAAgBC,EAAiD,CAC1F,OAAOE,EAAQ,OAAQH,EAAM,CAC3B,IAAK,CAAE,gBAAiBC,GAAS,OAAQ,CAC3C,CAAC,CACH,CAOA,eAAsBI,EAAML,EAAiC,CAC3D,OAAOG,EAAQ,QAASH,CAAI,CAC9B,CASA,eAAeG,EAAQG,EAAiBN,EAAgBC,EAAoC,CAC1F,IAAMM,EAAgB,GAAGD,CAAO,IAAIN,EAAK,KAAK,GAAG,CAAC,GAClD,GAAI,CACF,QAAQ,IAAI,YAAYO,CAAa,GAAG,EACxC,GAAM,CAAE,OAAAd,CAAO,EAAI,MAAMH,EAAMgB,EAASN,EAAM,CAC5C,GAAGC,EACH,OAAQ,OACR,OAAQ,OACR,MAAO,GACP,SAAU,MACZ,CAAC,EACD,OAAOR,CAET,OAASe,EAAY,CACnB,IAAIC,EAAeD,GAAO,QAAUA,GAAO,SAAW,GACtD,MAAAC,GAAgB;AAAA,iBAAoBF,CAAa,IAC3C,IAAI,MAAME,CAAY,CAC9B,CACF","names":["execa","getForgeConfig","profile","stdout","getSrcDirectory","getScriptDirectory","getTestDirectory","getOutDirectory","getRpcUrl","forge","args","options","execOptions","execLog","cast","anvil","command","commandString","error","errorMessage"]}
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: Options<string> = {\n env: { FOUNDRY_PROFILE: options?.profile, ...options?.env },\n stdout: \"inherit\",\n stderr: \"pipe\",\n cwd: options?.cwd,\n };\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<string>): Promise<string> {\n const commandString = `${command} ${args.join(\" \")}`;\n try {\n console.log(`running \"${commandString}\"`);\n const { stdout } = await execa(command, args, { stdout: \"pipe\", stderr: \"pipe\", ...options });\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,OAAS,SAAAA,MAAsB,QAuB/B,eAAsBC,EAAeC,EAAwC,CAC3E,GAAM,CAAE,OAAAC,CAAO,EAAI,MAAMH,EAAM,QAAS,CAAC,SAAU,QAAQ,EAAG,CAC5D,MAAO,CAAC,UAAW,OAAQ,MAAM,EACjC,IAAK,CAAE,gBAAiBE,CAAQ,CAClC,CAAC,EAED,OAAO,KAAK,MAAMC,CAAM,CAC1B,CAMA,eAAsBC,EAAgBF,EAAmC,CACvE,OAAQ,MAAMD,EAAeC,CAAO,GAAG,GACzC,CAMA,eAAsBG,EAAmBH,EAAmC,CAC1E,OAAQ,MAAMD,EAAeC,CAAO,GAAG,MACzC,CAMA,eAAsBI,EAAiBJ,EAAmC,CACxE,OAAQ,MAAMD,EAAeC,CAAO,GAAG,IACzC,CAMA,eAAsBK,EAAgBL,EAAmC,CACvE,OAAQ,MAAMD,EAAeC,CAAO,GAAG,GACzC,CAOA,eAAsBM,EAAUN,EAAmC,CACjE,OACE,QAAQ,IAAI,qBACZ,QAAQ,IAAI,cACZ,QAAQ,IAAI,UACX,MAAMD,EAAeC,CAAO,GAAG,aAChC,uBAEJ,CAOA,eAAsBO,EACpBC,EACAC,EACe,CACf,IAAMC,EAA+B,CACnC,IAAK,CAAE,gBAAiBD,GAAS,QAAS,GAAGA,GAAS,GAAI,EAC1D,OAAQ,UACR,OAAQ,OACR,IAAKA,GAAS,GAChB,EAEA,MAAOA,GAAS,OAASX,EAAM,QAASU,EAAME,CAAW,EAAIC,EAAQ,QAASH,EAAME,CAAW,EACjG,CAOA,eAAsBE,EAAKJ,EAAgBC,EAAiD,CAC1F,OAAOE,EAAQ,OAAQH,EAAM,CAC3B,IAAK,CAAE,gBAAiBC,GAAS,OAAQ,CAC3C,CAAC,CACH,CAOA,eAAsBI,EAAML,EAAiC,CAC3D,OAAOG,EAAQ,QAASH,CAAI,CAC9B,CASA,eAAeG,EAAQG,EAAiBN,EAAgBC,EAA4C,CAClG,IAAMM,EAAgB,GAAGD,CAAO,IAAIN,EAAK,KAAK,GAAG,CAAC,GAClD,GAAI,CACF,QAAQ,IAAI,YAAYO,CAAa,GAAG,EACxC,GAAM,CAAE,OAAAd,CAAO,EAAI,MAAMH,EAAMgB,EAASN,EAAM,CAAE,OAAQ,OAAQ,OAAQ,OAAQ,GAAGC,CAAQ,CAAC,EAC5F,OAAOR,CAET,OAASe,EAAY,CACnB,IAAIC,EAAeD,GAAO,QAAUA,GAAO,SAAW,GACtD,MAAAC,GAAgB;AAAA,iBAAoBF,CAAa,IAC3C,IAAI,MAAME,CAAY,CAC9B,CACF","names":["execa","getForgeConfig","profile","stdout","getSrcDirectory","getScriptDirectory","getTestDirectory","getOutDirectory","getRpcUrl","forge","args","options","execOptions","execLog","cast","anvil","command","commandString","error","errorMessage"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@latticexyz/common",
3
- "version": "2.2.18-c2ad22c7feb566e1731ff16e8be291746bdffb3e",
3
+ "version": "2.2.18-e1db80ad5648a9c77b757cda3930aa134e0f1c97",
4
4
  "description": "Common low level logic shared between packages",
5
5
  "repository": {
6
6
  "type": "git",
@@ -64,12 +64,12 @@
64
64
  "@solidity-parser/parser": "^0.16.0",
65
65
  "abitype": "1.0.6",
66
66
  "debug": "^4.3.4",
67
- "execa": "^9.5.2",
67
+ "execa": "^7.0.0",
68
68
  "p-queue": "^7.4.1",
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.18-c2ad22c7feb566e1731ff16e8be291746bdffb3e"
72
+ "@latticexyz/schema-type": "2.2.18-e1db80ad5648a9c77b757cda3930aa134e0f1c97"
73
73
  },
74
74
  "devDependencies": {
75
75
  "@types/debug": "^4.1.7",