@latticexyz/cli 2.2.13-main-b3b4c559e57286e7ee58c8c079c6093835944d04 → 2.2.13-main-75e93bac492f9000c482d6a26a5c8e29079dd32d
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.
@@ -1,4 +1,4 @@
|
|
1
|
-
import{a as ne}from"./chunk-JXC4VYGI.js";import di
|
1
|
+
import{a as ne}from"./chunk-JXC4VYGI.js";import{command as di}from"@latticexyz/gas-report/internal";import{command as li}from"@latticexyz/abi-ts/internal";import{loadConfig as At,resolveConfigPath as vt}from"@latticexyz/config/node";import{tablegen as bt}from"@latticexyz/store/codegen";import{buildSystemsManifest as ht,worldgen as wt}from"@latticexyz/world/node";import{forge as xt}from"@latticexyz/common/foundry";import{execa as Ct}from"execa";async function F({rootDir:e,config:o,foundryProfile:t=process.env.FOUNDRY_PROFILE}){await Promise.all([bt({rootDir:e,config:o}),wt({rootDir:e,config:o})]),await xt(["build"],{profile:t}),await ht({rootDir:e,config:o}),await Ct("mud",["abi-ts"],{stdio:"inherit"})}import St from"node:path";var Dt={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 vt(e.configPath),t=await At(o);await F({rootDir:St.dirname(o),config:t,foundryProfile:e.profile}),process.exit(0)}},Ne=Dt;import{rmSync as Tt}from"fs";import{homedir as kt}from"os";import Pt from"path";import{execa as Mt}from"execa";var Bt={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=kt();Tt(Pt.join(o,".foundry","anvil","tmp"),{recursive:!0,force:!0});let t=["-b",String(e),"--block-base-fee-per-gas","0"];console.log(`Running: anvil ${t.join(" ")}`);let r=Mt("anvil",t,{stdio:["inherit","inherit","inherit"]});process.on("SIGINT",()=>{console.log(`
|
2
2
|
gracefully shutting down from SIGINT (Crtl-C)`),r.kill(),process.exit()}),await r}},Ue=Bt;var Ot={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)}},Ve=Ot;import{loadConfig as It,resolveConfigPath as Wt}from"@latticexyz/config/node";import{tablegen as Rt}from"@latticexyz/store/codegen";import Ht from"node:path";var jt={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 Wt(e.configPath),t=await It(o);await Rt({rootDir:Ht.dirname(o),config:t}),process.exit(0)}},_e=jt;import we from"node:path";import{existsSync as ys,mkdirSync as us,readFileSync as gs,writeFileSync as We}from"node:fs";import{stringToHex as $n}from"viem";import{getBalance as Nt,sendRawTransaction as Ut,sendTransaction as Je,waitForTransactionReceipt as qe}from"viem/actions";var P={gasPrice:1e11,gasLimit:1e5,signerAddress:"3fab184622dc19b6109349b94811493bf2a45362",transaction:"f8a58085174876e800830186a08080b853604580600e600039806000f350fe7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe03601600081602082378035828234f58015156039578182fd5b8082525050506014600cf31ba02222222222222222222222222222222222222222222222222222222222222222a02222222222222222222222222222222222222222222222222222222222222222",address:"4e59b44847b379578588920ca78fbf26c0b4956c",creationCode:"604580600e600039806000f350fe7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe03601600081602082378035828234f58015156039578182fd5b8082525050506014600cf3"};import Ke from"debug";var O=Ke("mud:cli"),Et=Ke("mud:cli");O.log=console.debug.bind(console);Et.log=console.error.bind(console);var p=O.extend("deploy"),Lt=O.extend("deploy");p.log=console.debug.bind(console);Lt.log=console.error.bind(console);import{sliceHex as Ft}from"viem";import{getBytecode as zt}from"viem/actions";var se=`0x${P.address}`;async function ae(e){let o=await zt(e,{address:se});if(o)return p("found CREATE2 deployer at",se),o!==Ft(`0x${P.creationCode}`,14)&&console.warn(`
|
3
3
|
\u26A0\uFE0F Bytecode for deployer at ${se} did not match the expected CREATE2 bytecode. You may have unexpected results.
|
4
4
|
`),se}var Se=`0x${P.address}`;async function Ye(e){let o=await ae(e);if(o!==void 0)return o;let t=BigInt(P.gasLimit)*BigInt(P.gasPrice),r=await Nt(e,{address:`0x${P.signerAddress}`}),n=t-r;if(n>0){p("sending gas for CREATE2 deployer to signer at",P.signerAddress);let i=await Je(e,{chain:e.chain??null,to:`0x${P.signerAddress}`,value:n}),c=await qe(e,{hash:i});if(c.status!=="success")throw console.error("failed to send gas to deployer signer",c),new Error("failed to send gas to deployer signer")}p("deploying CREATE2 deployer at",Se);let s=await Ut(e,{serializedTransaction:`0x${P.transaction}`}).catch(i=>{if(String(i).includes("only replay-protected (EIP-155) transactions allowed over RPC"))return console.warn(`
|
@@ -47,4 +47,4 @@ Waiting for file changes\u2026
|
|
47
47
|
`),{overwrite:n});let S=L.join(x.sourceDirectory,"remote");n&&await xe.rm(S,{recursive:!0,force:!0});for(let f of u.filter(h=>h.abi.length)){let h=`I${f.label}`,m=L.join(S,"namespaces",f.namespaceLabel,`${h}.sol`);R("writing system interface",h,"to",m);let g=mt({name:h,systemId:f.systemId,abi:f.abi});await ze(L.join(e,m),await pt(g),{overwrite:n})}let T=u.flatMap(f=>f.worldAbi);if(T.length){let f="IWorldSystems",h=L.join(S,`${f}.sol`);R("writing world systems interface to",h);let m=mt({name:f,abi:T});await ze(L.join(e,h),await pt(m),{overwrite:n})}return{config:x}}async function oi(e){return xe.access(e).then(()=>!0,()=>!1)}async function ze(e,o,t={}){if(!t.overwrite&&await oi(e))throw new re(e);await xe.mkdir(L.dirname(e),{recursive:!0}),await xe.writeFile(e,o)}import si from"node:path";var ai={worldAddress:{type:"string",required:!0,desc:"Remote world address"},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)"},replace:{type:"boolean",desc:"Replace existing files and directories with data from remote world."}},ii={command:"pull",describe:"Pull mud.config.ts and interfaces from an existing world.",builder(e){return e.options(ai)},async handler(e){let o=e.profile??process.env.FOUNDRY_PROFILE,t=e.rpc??await ti(o),r=ri({transport:ni(t,{batch:e.rpcBatch?{batchSize:100,wait:1e3}:void 0})});console.log(Ce.bgBlue(Ce.whiteBright(`
|
48
48
|
Pulling MUD config from world at ${e.worldAddress}
|
49
49
|
`)));let n=process.cwd();try{let{config:s}=await ut({rootDir:n,client:r,worldAddress:e.worldAddress,replace:e.replace});await F({rootDir:n,config:s,foundryProfile:o})}catch(s){if(s instanceof re){console.log(),console.log(Ce.bgRed(Ce.whiteBright(" Error "))),console.log(` Attempted to write file at "${si.relative(n,s.filename)}", but it already exists.`),console.log(),console.log(" To overwrite files, use `--replace` when running this command."),console.log();return}throw s}}},gt=ii;var ug=[Ne,Yo,Ue,di,Ve,_e,Go,et,ot,nt,st,li,lt,gt];export{ug as commands};
|
50
|
-
//# sourceMappingURL=commands-
|
50
|
+
//# sourceMappingURL=commands-V3WI2M57.js.map
|