@latticexyz/cli 3.0.0-main-e85dc5349 → 3.0.0-main-8f6fa588d

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.
@@ -0,0 +1,4 @@
1
+ import n from"chalk";import{ZodError as e}from"zod";import{fromZodError as i,ValidationError as s}from"zod-validation-error";import{MUDError as t}from"@latticexyz/common/errors";function c(o){if(o instanceof s)console.log(n.redBright(o.message));else if(o instanceof e){let r=i(o,{prefixSeparator:`
2
+ - `,issueSeparator:`
3
+ - `});console.log(n.redBright(r.message))}else o instanceof t?console.log(n.red(o)):console.log(o)}export{c as a};
4
+ //# sourceMappingURL=chunk-JXC4VYGI.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/utils/errors.ts"],"sourcesContent":["import chalk from \"chalk\";\nimport { ZodError } from \"zod\";\nimport { fromZodError, ValidationError } from \"zod-validation-error\";\nimport { MUDError } from \"@latticexyz/common/errors\";\n\nexport function logError(error: unknown) {\n if (error instanceof ValidationError) {\n console.log(chalk.redBright(error.message));\n } else if (error instanceof ZodError) {\n // TODO currently this error shouldn't happen, use `fromZodErrorCustom`\n // (see https://github.com/latticexyz/mud/issues/438)\n const validationError = fromZodError(error, {\n prefixSeparator: \"\\n- \",\n issueSeparator: \"\\n- \",\n });\n console.log(chalk.redBright(validationError.message));\n } else if (error instanceof MUDError) {\n console.log(chalk.red(error));\n } else {\n console.log(error);\n }\n}\n"],"mappings":"AAAA,OAAOA,MAAW,QAClB,OAAS,YAAAC,MAAgB,MACzB,OAAS,gBAAAC,EAAc,mBAAAC,MAAuB,uBAC9C,OAAS,YAAAC,MAAgB,4BAElB,SAASC,EAASC,EAAgB,CACvC,GAAIA,aAAiBH,EACnB,QAAQ,IAAIH,EAAM,UAAUM,EAAM,OAAO,CAAC,UACjCA,aAAiBL,EAAU,CAGpC,IAAMM,EAAkBL,EAAaI,EAAO,CAC1C,gBAAiB;AAAA,IACjB,eAAgB;AAAA,GAClB,CAAC,EACD,QAAQ,IAAIN,EAAM,UAAUO,EAAgB,OAAO,CAAC,OAC3CD,aAAiBF,EAC1B,QAAQ,IAAIJ,EAAM,IAAIM,CAAK,CAAC,EAE5B,QAAQ,IAAIA,CAAK,CAErB","names":["chalk","ZodError","fromZodError","ValidationError","MUDError","logError","error","validationError"]}
@@ -1,4 +1,4 @@
1
- import{a as U}from"./chunk-QXUPZVZL.js";import Us from"@latticexyz/gas-report";import Ks from"@latticexyz/abi-ts";import{loadConfig as Yo,resolveConfigPath as Go}from"@latticexyz/config/node";import{tablegen as Vo}from"@latticexyz/store/codegen";import{worldgen as Uo}from"@latticexyz/world/node";import{forge as Ko,getRemappings as Jo}from"@latticexyz/common/foundry";import{execa as qo}from"execa";async function K({rootDir:e,config:o,foundryProfile:n=process.env.FOUNDRY_PROFILE}){let r=await Jo(n);await Promise.all([Vo({rootDir:e,config:o,remappings:r}),Uo({rootDir:e,config:o})]),await Ko(["build"],{profile:n}),await qo("mud",["abi-ts"],{stdio:"inherit"})}import Qo from"node:path";var Zo={command:"build",describe:"Build contracts and generate MUD artifacts (table libraries, world interface, ABI)",builder(e){return e.options({configPath:{type:"string",desc:"Path to the MUD config file"},profile:{type:"string",desc:"The foundry profile to use"}})},async handler(e){let o=await Go(e.configPath),n=await Yo(o);await K({rootDir:Qo.dirname(o),config:n,foundryProfile:e.profile}),process.exit(0)}},xe=Zo;import{rmSync as Xo}from"fs";import{homedir as et}from"os";import ot from"path";import{execa as tt}from"execa";var rt={command:"devnode",describe:"Start a local Ethereum node for development",builder(e){return e.options({blocktime:{type:"number",default:1,decs:"Interval in which new blocks are produced"}})},async handler({blocktime:e}){console.log("Clearing devnode history");let o=et();Xo(ot.join(o,".foundry","anvil","tmp"),{recursive:!0,force:!0});let n=["-b",String(e),"--block-base-fee-per-gas","0"];console.log(`Running: anvil ${n.join(" ")}`);let r=tt("anvil",n,{stdio:["inherit","inherit","inherit"]});process.on("SIGINT",()=>{console.log(`
1
+ import{a as U}from"./chunk-JXC4VYGI.js";import Us from"@latticexyz/gas-report";import Ks from"@latticexyz/abi-ts";import{loadConfig as Yo,resolveConfigPath as Go}from"@latticexyz/config/node";import{tablegen as Vo}from"@latticexyz/store/codegen";import{worldgen as Uo}from"@latticexyz/world/node";import{forge as Ko,getRemappings as Jo}from"@latticexyz/common/foundry";import{execa as qo}from"execa";async function K({rootDir:e,config:o,foundryProfile:n=process.env.FOUNDRY_PROFILE}){let r=await Jo(n);await Promise.all([Vo({rootDir:e,config:o,remappings:r}),Uo({rootDir:e,config:o})]),await Ko(["build"],{profile:n}),await qo("mud",["abi-ts"],{stdio:"inherit"})}import Qo from"node:path";var Zo={command:"build",describe:"Build contracts and generate MUD artifacts (table libraries, world interface, ABI)",builder(e){return e.options({configPath:{type:"string",desc:"Path to the MUD config file"},profile:{type:"string",desc:"The foundry profile to use"}})},async handler(e){let o=await Go(e.configPath),n=await Yo(o);await K({rootDir:Qo.dirname(o),config:n,foundryProfile:e.profile}),process.exit(0)}},xe=Zo;import{rmSync as Xo}from"fs";import{homedir as et}from"os";import ot from"path";import{execa as tt}from"execa";var rt={command:"devnode",describe:"Start a local Ethereum node for development",builder(e){return e.options({blocktime:{type:"number",default:1,decs:"Interval in which new blocks are produced"}})},async handler({blocktime:e}){console.log("Clearing devnode history");let o=et();Xo(ot.join(o,".foundry","anvil","tmp"),{recursive:!0,force:!0});let n=["-b",String(e),"--block-base-fee-per-gas","0"];console.log(`Running: anvil ${n.join(" ")}`);let r=tt("anvil",n,{stdio:["inherit","inherit","inherit"]});process.on("SIGINT",()=>{console.log(`
2
2
  gracefully shutting down from SIGINT (Crtl-C)`),r.kill(),process.exit()}),await r}},Se=rt;var nt={command:"hello <name>",describe:"Greet <name> with Hello",builder(e){return e.options({upper:{type:"boolean"}}).positional("name",{type:"string",demandOption:!0})},handler({name:e}){let o=`Gm, ${e}!`;console.log(o),process.exit(0)}},Ce=nt;import{loadConfig as st,resolveConfigPath as at}from"@latticexyz/config/node";import{tablegen as it}from"@latticexyz/store/codegen";import{getRemappings as dt}from"@latticexyz/common/foundry";import ct from"node:path";var lt={command:"tablegen",describe:"Autogenerate MUD Store table libraries based on the config file",builder(e){return e.options({configPath:{type:"string",desc:"Path to the MUD config file"}})},async handler(e){let o=await at(e.configPath),n=await st(o),r=await dt();await it({rootDir:ct.dirname(o),config:n,remappings:r}),process.exit(0)}},De=lt;import ce from"node:path";import{existsSync as yn,mkdirSync as un,readFileSync as gn,writeFileSync as ue}from"node:fs";import{getBalance as gt,sendRawTransaction as bt,sendTransaction as ve,waitForTransactionReceipt as Te}from"viem/actions";var v={gasPrice:1e11,gasLimit:1e5,signerAddress:"3fab184622dc19b6109349b94811493bf2a45362",transaction:"f8a58085174876e800830186a08080b853604580600e600039806000f350fe7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe03601600081602082378035828234f58015156039578182fd5b8082525050506014600cf31ba02222222222222222222222222222222222222222222222222222222222222222a02222222222222222222222222222222222222222222222222222222222222222",address:"4e59b44847b379578588920ca78fbf26c0b4956c",creationCode:"604580600e600039806000f350fe7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe03601600081602082378035828234f58015156039578182fd5b8082525050506014600cf3"};import Ae from"debug";var J=Ae("mud:cli"),pt=Ae("mud:cli");J.log=console.debug.bind(console);pt.log=console.error.bind(console);var m=J.extend("deploy"),ft=J.extend("deploy");m.log=console.debug.bind(console);ft.log=console.error.bind(console);import{sliceHex as yt}from"viem";import{getBytecode as ut}from"viem/actions";var q=`0x${v.address}`;async function Y(e){let o=await ut(e,{address:q});if(o)return m("found CREATE2 deployer at",q),o!==yt(`0x${v.creationCode}`,14)&&console.warn(`
3
3
  \u26A0\uFE0F Bytecode for deployer at ${q} did not match the expected CREATE2 bytecode. You may have unexpected results.
4
4
  `),q}var le=`0x${v.address}`;async function ke(e){let o=await Y(e);if(o!==void 0)return o;let n=BigInt(v.gasLimit)*BigInt(v.gasPrice),r=await gt(e,{address:`0x${v.signerAddress}`}),t=n-r;if(t>0){m("sending gas for CREATE2 deployer to signer at",v.signerAddress);let a=await ve(e,{chain:e.chain??null,to:`0x${v.signerAddress}`,value:t}),l=await Te(e,{hash:a});if(l.status!=="success")throw console.error("failed to send gas to deployer signer",l),new Error("failed to send gas to deployer signer")}m("deploying CREATE2 deployer at",le);let s=await bt(e,{serializedTransaction:`0x${v.transaction}`}).catch(a=>{if(String(a).includes("only replay-protected (EIP-155) transactions allowed over RPC"))return console.warn(`
@@ -36,4 +36,4 @@ Waiting for file changes\u2026
36
36
  `))}}),As(vs)).subscribe()}},Fo=ks;import{getCreate2Address as zo,sliceHex as Os,zeroHash as Is}from"viem";import{forge as Ps}from"@latticexyz/common/foundry";async function B(e){let o=["verify-contract",e.address,e.name,"--rpc-url",e.rpc];e.verifier&&o.push("--verifier",e.verifier),e.verifierUrl&&o.push("--verifier-url",e.verifierUrl),await Ps(o,{cwd:e.cwd})}import Ms from"p-queue";import{MUDError as Bs}from"@latticexyz/common/errors";import{getStorageAt as Ws}from"viem/actions";import{execa as we}from"execa";var Rs="0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc";async function No({client:e,rpc:o,systems:n,modules:r,worldAddress:t,deployerAddress:s,verifier:i,verifierUrl:a}){let l=s??await Y(e);if(!l)throw new Bs("No deployer address provided or found.");let d=await Ws(e,{address:t,slot:Rs}),c=d&&d!==Is,p=new Ms({concurrency:4});if(n.map(({name:u,bytecode:h})=>p.add(()=>B({name:u,rpc:o,verifier:i,verifierUrl:a,address:zo({from:l,bytecode:h,salt:S})}).catch(w=>{console.error(`Error verifying system contract ${u}:`,w)}))),i==="sourcify")if(await we("npm",["install"],{cwd:"node_modules/@latticexyz/store"}),await we("npm",["install"],{cwd:"node_modules/@latticexyz/world"}),await we("npm",["install"],{cwd:"node_modules/@latticexyz/world-modules"}),Object.entries(c?X(l):Z(l)).map(([u,{bytecode:h}])=>p.add(()=>B({cwd:"node_modules/@latticexyz/world",name:u,rpc:o,verifier:i,verifierUrl:a,address:zo({from:l,bytecode:h,salt:S})}).catch(w=>{console.error(`Error verifying world factory contract ${u}:`,w)}))),r.map(({name:u,prepareDeploy:h})=>{let{address:w}=h(l,[]);return p.add(()=>B({cwd:"node_modules/@latticexyz/world-modules",name:u,rpc:o,verifier:i,verifierUrl:a,address:w}).catch(g=>{console.error(`Error verifying module contract ${u}:`,g)}))}),c){let u=Os(d,-20);p.add(()=>B({cwd:"node_modules/@latticexyz/world",name:"WorldProxy",rpc:o,verifier:i,verifierUrl:a,address:t}).catch(h=>{console.error("Error verifying WorldProxy contract:",h)})),p.add(()=>B({cwd:"node_modules/@latticexyz/world",name:"World",rpc:o,verifier:i,verifierUrl:a,address:u}).catch(h=>{console.error("Error verifying World contract:",h)}))}else p.add(()=>B({cwd:"node_modules/@latticexyz/world",name:"World",rpc:o,verifier:i,verifierUrl:a,address:t}).catch(u=>{console.error("Error verifying World contract:",u)}));else console.log(""),console.log(`Note: MUD is currently unable to verify store, world, and world-modules contracts with ${i}. We are planning to expand support in a future version.`),console.log("")}import{loadConfig as js,resolveConfigPath as Hs}from"@latticexyz/config/node";import{resolveSystems as $s}from"@latticexyz/world/node";import{getOutDirectory as Es,getRpcUrl as Fs}from"@latticexyz/common/foundry";import{createWalletClient as zs,http as Ns}from"viem";import _o from"chalk";import _s from"node:path";var Ls={deployerAddress:{type:"string",desc:"Deploy using an existing deterministic deployer (https://github.com/Arachnid/deterministic-deployment-proxy)"},worldAddress:{type:"string",required:!0,desc:"Verify an existing World at the given address"},configPath:{type:"string",desc:"Path to the MUD config file"},profile:{type:"string",desc:"The foundry profile to use"},rpc:{type:"string",desc:"The RPC URL to use. Defaults to the RPC url from the local foundry.toml"},rpcBatch:{type:"boolean",desc:"Enable batch processing of RPC requests in viem client (defaults to batch size of 100 and wait of 1s)"},verifier:{type:"string",desc:"The verifier to use. Defaults to blockscout",default:"blockscout"},verifierUrl:{type:"string",desc:"The verification provider."}},Vs={command:"verify",describe:"Verify contracts",builder(e){return e.options(Ls)},async handler(e){let o=e.profile??process.env.FOUNDRY_PROFILE,n=await Hs(e.configPath),r=_s.dirname(n),t=await js(n),s=await Es(o),i=e.rpc??await Fs(o);console.log(_o.bgBlue(_o.whiteBright(`
37
37
  Verifying MUD contracts${o?" with profile "+o:""} to RPC ${i}
38
38
  `)));let a=zs({transport:Ns(i,{batch:e.rpcBatch?{batchSize:100,wait:1e3}:void 0})}),d=(await $s({rootDir:r,config:t})).map(p=>{let u=j(`${p.name}.sol`,p.name,s);return{name:p.name,bytecode:u.bytecode}}),c=await de(t,s);await No({client:a,rpc:i,systems:d,modules:c,deployerAddress:e.deployerAddress,worldAddress:e.worldAddress,verifier:e.verifier,verifierUrl:e.verifierUrl})}},Lo=Vs;var Nf=[xe,Oo,Se,Us,Ce,De,Io,Ro,jo,Eo,Fo,Ks,Lo];export{Nf as commands};
39
- //# sourceMappingURL=commands-2DM4XJGZ.js.map
39
+ //# sourceMappingURL=commands-UVPI4WHN.js.map
@@ -0,0 +1,2 @@
1
+ import{a}from"./chunk-JXC4VYGI.js";export{a as logError};
2
+ //# sourceMappingURL=errors-JCLK7DZO.js.map
package/dist/mud.js CHANGED
@@ -1,3 +1,3 @@
1
1
  #!/usr/bin/env node
2
- import*as i from"dotenv";i.config();async function l(){let{default:r}=await import("yargs"),{default:o}=await import("chalk"),{hideBin:e}=await import("yargs/helpers"),{logError:s}=await import("./errors-MZURIB7V.js"),{commands:t}=await import("./commands-2DM4XJGZ.js");r(e(process.argv)).scriptName("mud").command(t).strict().fail((a,n)=>{console.error(o.red(a)),a.includes("Missing required argument")&&console.log(o.yellow(`Run 'pnpm mud ${process.argv[2]} --help' for a list of available and required arguments.`)),console.log(""),n!=null&&(s(n),console.log("")),process.exit(1)}).alias({h:"help"}).argv}l();
2
+ import*as i from"dotenv";i.config();async function l(){let{default:r}=await import("yargs"),{default:o}=await import("chalk"),{hideBin:e}=await import("yargs/helpers"),{logError:s}=await import("./errors-JCLK7DZO.js"),{commands:t}=await import("./commands-UVPI4WHN.js");r(e(process.argv)).scriptName("mud").command(t).strict().fail((a,n)=>{console.error(o.red(a)),a.includes("Missing required argument")&&console.log(o.yellow(`Run 'pnpm mud ${process.argv[2]} --help' for a list of available and required arguments.`)),console.log(""),n!=null&&(s(n),console.log("")),process.exit(1)}).alias({h:"help"}).argv}l();
3
3
  //# sourceMappingURL=mud.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@latticexyz/cli",
3
- "version": "3.0.0-main-e85dc5349",
3
+ "version": "3.0.0-main-8f6fa588d",
4
4
  "description": "Command line interface for mud",
5
5
  "repository": {
6
6
  "type": "git",
@@ -48,15 +48,15 @@
48
48
  "yargs": "^17.7.1",
49
49
  "zod": "^3.22.2",
50
50
  "zod-validation-error": "^1.3.0",
51
- "@latticexyz/abi-ts": "3.0.0-main-e85dc5349",
52
- "@latticexyz/common": "3.0.0-main-e85dc5349",
53
- "@latticexyz/config": "3.0.0-main-e85dc5349",
54
- "@latticexyz/gas-report": "3.0.0-main-e85dc5349",
55
- "@latticexyz/protocol-parser": "3.0.0-main-e85dc5349",
56
- "@latticexyz/schema-type": "3.0.0-main-e85dc5349",
57
- "@latticexyz/store": "3.0.0-main-e85dc5349",
58
- "@latticexyz/utils": "3.0.0-main-e85dc5349",
59
- "@latticexyz/world": "3.0.0-main-e85dc5349"
51
+ "@latticexyz/abi-ts": "3.0.0-main-8f6fa588d",
52
+ "@latticexyz/common": "3.0.0-main-8f6fa588d",
53
+ "@latticexyz/config": "3.0.0-main-8f6fa588d",
54
+ "@latticexyz/gas-report": "3.0.0-main-8f6fa588d",
55
+ "@latticexyz/protocol-parser": "3.0.0-main-8f6fa588d",
56
+ "@latticexyz/schema-type": "3.0.0-main-8f6fa588d",
57
+ "@latticexyz/store": "3.0.0-main-8f6fa588d",
58
+ "@latticexyz/utils": "3.0.0-main-8f6fa588d",
59
+ "@latticexyz/world": "3.0.0-main-8f6fa588d"
60
60
  },
61
61
  "devDependencies": {
62
62
  "@types/debug": "^4.1.7",
@@ -1,4 +0,0 @@
1
- import e from"chalk";import{ZodError as s}from"zod";import{fromZodError as i,ValidationError as l}from"zod-validation-error";import{NotInsideProjectError as t}from"@latticexyz/config/library";import{MUDError as r}from"@latticexyz/common/errors";function p(o){if(o instanceof l)console.log(e.redBright(o.message));else if(o instanceof s){let n=i(o,{prefixSeparator:`
2
- - `,issueSeparator:`
3
- - `});console.log(e.redBright(n.message))}else o instanceof t?(console.log(e.red(o.message)),console.log(""),console.log(e.blue("To learn more about MUD's configuration, please go to https://mud.dev/packages/cli/"))):o instanceof r?console.log(e.red(o)):console.log(o)}export{p as a};
4
- //# sourceMappingURL=chunk-QXUPZVZL.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/utils/errors.ts"],"sourcesContent":["import chalk from \"chalk\";\nimport { ZodError } from \"zod\";\nimport { fromZodError, ValidationError } from \"zod-validation-error\";\nimport { NotInsideProjectError } from \"@latticexyz/config/library\";\nimport { MUDError } from \"@latticexyz/common/errors\";\n\nexport function logError(error: unknown) {\n if (error instanceof ValidationError) {\n console.log(chalk.redBright(error.message));\n } else if (error instanceof ZodError) {\n // TODO currently this error shouldn't happen, use `fromZodErrorCustom`\n // (see https://github.com/latticexyz/mud/issues/438)\n const validationError = fromZodError(error, {\n prefixSeparator: \"\\n- \",\n issueSeparator: \"\\n- \",\n });\n console.log(chalk.redBright(validationError.message));\n } else if (error instanceof NotInsideProjectError) {\n console.log(chalk.red(error.message));\n console.log(\"\");\n // TODO add docs to the website and update the link to the specific page\n // (see https://github.com/latticexyz/mud/issues/445)\n console.log(chalk.blue(`To learn more about MUD's configuration, please go to https://mud.dev/packages/cli/`));\n } else if (error instanceof MUDError) {\n console.log(chalk.red(error));\n } else {\n console.log(error);\n }\n}\n"],"mappings":"AAAA,OAAOA,MAAW,QAClB,OAAS,YAAAC,MAAgB,MACzB,OAAS,gBAAAC,EAAc,mBAAAC,MAAuB,uBAC9C,OAAS,yBAAAC,MAA6B,6BACtC,OAAS,YAAAC,MAAgB,4BAElB,SAASC,EAASC,EAAgB,CACvC,GAAIA,aAAiBJ,EACnB,QAAQ,IAAIH,EAAM,UAAUO,EAAM,OAAO,CAAC,UACjCA,aAAiBN,EAAU,CAGpC,IAAMO,EAAkBN,EAAaK,EAAO,CAC1C,gBAAiB;AAAA,IACjB,eAAgB;AAAA,GAClB,CAAC,EACD,QAAQ,IAAIP,EAAM,UAAUQ,EAAgB,OAAO,CAAC,OAC3CD,aAAiBH,GAC1B,QAAQ,IAAIJ,EAAM,IAAIO,EAAM,OAAO,CAAC,EACpC,QAAQ,IAAI,EAAE,EAGd,QAAQ,IAAIP,EAAM,KAAK,qFAAqF,CAAC,GACpGO,aAAiBF,EAC1B,QAAQ,IAAIL,EAAM,IAAIO,CAAK,CAAC,EAE5B,QAAQ,IAAIA,CAAK,CAErB","names":["chalk","ZodError","fromZodError","ValidationError","NotInsideProjectError","MUDError","logError","error","validationError"]}
@@ -1,2 +0,0 @@
1
- import{a}from"./chunk-QXUPZVZL.js";export{a as logError};
2
- //# sourceMappingURL=errors-MZURIB7V.js.map