@latticexyz/cli 2.0.0-alpha.1.89 → 2.0.0-alpha.1.91
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/mud.js +19 -5
- package/dist/mud.js.map +1 -1
- package/package.json +12 -13
- package/src/commands/{deploy-v2.ts → deploy.ts} +19 -6
- package/src/commands/devnode.ts +7 -2
- package/src/commands/index.ts +4 -4
- package/src/commands/{test-v2.ts → test.ts} +3 -3
- package/src/mud.ts +2 -3
- package/src/utils/{deploy-v2.ts → deploy.ts} +0 -1
- package/src/utils/index.ts +1 -1
- package/dist/chunk-JVFSJGQJ.js +0 -49
- package/dist/chunk-JVFSJGQJ.js.map +0 -1
- package/dist/mud2.js +0 -3
- package/dist/mud2.js.map +0 -1
- package/src/commands/deprecated/bulkupload.ts +0 -50
- package/src/commands/deprecated/call-system.ts +0 -70
- package/src/commands/deprecated/codegen-libdeploy.ts +0 -29
- package/src/commands/deprecated/deploy-contracts.ts +0 -120
- package/src/commands/deprecated/index.ts +0 -22
- package/src/commands/deprecated/system-types.ts +0 -29
- package/src/commands/deprecated/test.ts +0 -53
- package/src/commands/deprecated/trace.ts +0 -81
- package/src/commands/deprecated/types.ts +0 -33
- package/src/contracts/BulkUpload.sol +0 -174
- package/src/contracts/Deploy.sol +0 -23
- package/src/contracts/LibDeploy.ejs +0 -121
- package/src/contracts/LibDeploy.sol +0 -23
- package/src/contracts/LibDeployStub.sol +0 -23
- package/src/mud2.ts +0 -29
- package/src/utils/deprecated/build.ts +0 -55
- package/src/utils/deprecated/codegen.ts +0 -42
- package/src/utils/deprecated/constants.ts +0 -2
- package/src/utils/deprecated/deploy.ts +0 -111
- package/src/utils/deprecated/exec.ts +0 -18
- package/src/utils/deprecated/findLog.ts +0 -8
- package/src/utils/deprecated/hsr.ts +0 -71
- package/src/utils/deprecated/ids.ts +0 -14
- package/src/utils/deprecated/index.ts +0 -8
- package/src/utils/deprecated/typegen.ts +0 -133
package/dist/mud.js
CHANGED
|
@@ -1,8 +1,22 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import{
|
|
2
|
+
import{d as ce}from"./chunk-YGEQVVUG.js";import wt from"yargs";import{hideBin as vt}from"yargs/helpers";import{rmSync as Ye}from"fs";import{homedir as Ze}from"os";import Xe from"path";import{execa as Qe}from"execa";var eo={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 t=Ze();Ye(Xe.join(t,".foundry","anvil","tmp"),{recursive:!0,force:!0});let o=["-b",String(e),"--block-base-fee-per-gas","0"];console.log(`Running: anvil ${o.join(" ")}`);let i=Qe("anvil",o,{stdio:["inherit","inherit","inherit"]});process.on("SIGINT",()=>{console.log(`
|
|
3
|
+
gracefully shutting down from SIGINT (Crtl-C)`),i.kill(),process.exit()}),await i}},le=eo;import{FaucetServiceDefinition as oo}from"@latticexyz/services/faucet";import{createChannel as to,createClient as ro}from"nice-grpc-web";import de from"chalk";import{NodeHttpTransport as no}from"@improbable-eng/grpc-web-node-http-transport";function so(e){return ro(oo,to(e,no()))}var io={command:"faucet",describe:"Interact with a MUD faucet",builder(e){return e.options({dripDev:{type:"boolean",desc:"Request a drip from the dev endpoint (requires faucet to have dev mode enabled)",default:!0},faucetUrl:{type:"string",desc:"URL of the MUD faucet",default:"https://faucet.testnet-mud-services.linfra.xyz"},address:{type:"string",desc:"Ethereum address to fund",required:!0}})},async handler({dripDev:e,faucetUrl:t,address:o}){let i=so(t);e&&(console.log(de.yellow("Dripping to",o)),await i.dripDev({address:o}),console.log(de.yellow("Success"))),process.exit(0)}},pe=io;import{readFileSync as ge,writeFileSync as ue,rmSync as me}from"fs";import{execa as ao}from"execa";import D from"chalk";import{table as co,getBorderCharacters as lo}from"table";var fe="MudGasReport",po={command:"gas-report",describe:"Create a gas report",builder(e){return e.options({path:{type:"array",string:!0,default:["Gas.t.sol"],desc:"File containing the gas tests"},save:{type:"string",desc:"Save the gas report to a file"},compare:{type:"string",desc:"Compare to an existing gas report"}})},async handler({path:e,save:t,compare:o}){let i=e.filter(n=>n.endsWith(".t.sol")),a=await Promise.all(i.map(n=>mo(n)));process.once("SIGINT",()=>{console.log("caught sigint, deleting temp files"),a.forEach(n=>me(n))});let c;try{c=await go()}catch{setTimeout(()=>process.exit());return}finally{a.forEach(n=>me(n))}if(o)try{let n=JSON.parse(ge(o,"utf8"));c=c.map(g=>{let u=n.find(d=>d.name===g.name&&d.functionCall===g.functionCall);return{...g,prevGasUsed:u?.gasUsed}})}catch{console.log(D.red(`Gas report to compare not found: ${o}`)),o=void 0}uo(c,o),t&&fo(c,t),process.exit(0)}},ye=po;async function mo(e){console.log("Creating gas report for",D.bold(e));let t=ge(e,"utf8"),o=t,i=new RegExp(/function (.*){/g),a;for(;(a=i.exec(t))!==null;){let u=a[0];o=o.replace(u,`${u}
|
|
4
|
+
uint256 _gasreport;`)}let c=new RegExp(/\/\/ !gasreport (.*)\n(.*)/g),n;for(;(n=c.exec(t))!==null;){let u=n[1],d=n[2].trim();o=o.replace(n[0],`
|
|
5
|
+
_gasreport = gasleft();
|
|
6
|
+
${d}
|
|
7
|
+
_gasreport = _gasreport - gasleft();
|
|
8
|
+
console.log("GAS REPORT(${e}): ${u} [${d.replaceAll('"','\\"')}]:", _gasreport);`)}o=o.replace(/pure/g,"view");let g=e.replace(/\.t\.sol$/,`${fe}.t.sol`);return ue(g,o),g}async function go(){console.log("Running gas report");let e=[],t="";try{t=(await ao("forge",["test","--match-path",`*${fe}*`,"-vvv"],{stdio:["inherit","pipe","inherit"]})).stdout}catch(a){throw console.log(a.stdout??a),console.log(D.red(`
|
|
3
9
|
-----------
|
|
4
|
-
Error
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
10
|
+
Error while running the gas report (see above)`)),a}let o=new RegExp(/GAS REPORT\((.*)\): (.*) \[(.*)\]: (.*)/g),i;for(;(i=o.exec(t))!==null;){let a=i[1],c=i[2],n=i[3].replace(";",""),g=parseInt(i[4]);e.push({source:a,name:c,functionCall:n,gasUsed:g})}return e.sort((a,c)=>a.source.localeCompare(c.source)),e}function uo(e,t){t&&console.log(D.bold(`Gas report compared to ${t}`));let o=[D.bold("Source"),D.bold("Name"),D.bold("Function call"),D.bold("Gas used"),...t?[D.bold("Prev gas used"),D.bold("Difference")]:[]],i=e.map(c=>{let n=c.prevGasUsed?c.gasUsed-c.prevGasUsed:0,g=n>0?D.red(`+${n}`):n<0?D.green(`${n}`):n,u=t?[c.prevGasUsed??"n/a",g]:[],d=n>0?D.red(c.gasUsed):n<0?D.green(c.gasUsed):c.gasUsed;return[c.source,c.name,c.functionCall,d,...u]}),a=[o,...i];console.log(co(a,{border:lo("norc")}))}function fo(e,t){console.log(D.bold(`Saving gas report to ${t}`)),ue(t,`${JSON.stringify(e,null,2)}
|
|
11
|
+
`)}var yo={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 t=`Gm, ${e}!`;console.log(t),process.exit(0)}},be=yo;import bo from"path";import{loadConfig as ho}from"@latticexyz/config";import{tablegen as wo}from"@latticexyz/store";import{getSrcDirectory as vo}from"@latticexyz/common/foundry";var Co={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 config file"}})},async handler({configPath:e}){let t=await ho(e),o=await vo();await wo(t,bo.join(o,t.codegenDirectory)),process.exit(0)}},he=Co;import{loadConfig as Do}from"@latticexyz/config";var xo={command:"tsgen",describe:"Autogenerate MUD typescript definitions based on the config file",builder(e){return e.options({configPath:{type:"string",demandOption:!0,desc:"Path to the config file"},out:{type:"string",demandOption:!0,desc:"Directory to output MUD typescript definition files"}})},async handler(e){let{configPath:t,out:o}=e,i=await Do(t);await ce(i,o),process.exit(0)}},we=xo;import B from"chalk";import Jo from"glob";import Z,{basename as Vo}from"path";import{MUDError as _o}from"@latticexyz/common/errors";import{loadConfig as zo}from"@latticexyz/config";import{existsSync as ko,readFileSync as So}from"fs";import ve from"path";import b from"chalk";import{ethers as E}from"ethers";import{defaultAbiCoder as $o}from"ethers/lib/utils.js";import{getOutDirectory as Mo,getScriptDirectory as Ro,cast as Po,forge as Oo}from"@latticexyz/common/foundry";import{resolveWithContext as Fo}from"@latticexyz/config";import{MUDError as j}from"@latticexyz/common/errors";import{encodeSchema as Ce}from"@latticexyz/schema-type";import{resolveAbiOrUserType as De}from"@latticexyz/store";import{resolveWorldConfig as Uo}from"@latticexyz/world";import jo from"@latticexyz/world/abi/World.sol/World.json"assert{type:"json"};import xe from"@latticexyz/world/abi/IBaseWorld.sol/IBaseWorld.json"assert{type:"json"};import ke from"@latticexyz/world/abi/CoreModule.sol/CoreModule.json"assert{type:"json"};import Se from"@latticexyz/world/abi/KeysWithValueModule.sol/KeysWithValueModule.json"assert{type:"json"};import $e from"@latticexyz/world/abi/KeysInTableModule.sol/KeysInTableModule.json"assert{type:"json"};import Me from"@latticexyz/world/abi/UniqueEntityModule.sol/UniqueEntityModule.json"assert{type:"json"};async function Pe(e,t,o){let i=Uo(e,t),a=Date.now(),{worldContractName:c,namespace:n,postDeployScript:g}=e,{profile:u,rpc:d,privateKey:x,priorityFeeMultiplier:k,debug:S,worldAddress:O,disableTxWait:p}=o,V=await Mo(u),oe=new E.providers.StaticJsonRpcProvider(d),K=new E.Wallet(x,oe),W=await K.getTransactionCount();console.log("Initial nonce",W);let _,L;Y(k);let w=[],te=Number(await Po(["block-number","--rpc-url",d],{profile:u}));console.log("Start deployment at block",te);let ze={World:O?Promise.resolve(O):c?H(c,p):U(xe.abi,jo.bytecode,p,"World")},Ke=Object.keys(i.systems).reduce((r,s)=>(r[s]=H(s,p),r),{}),re={CoreModule:U(ke.abi,ke.bytecode,p,"CoreModule"),KeysWithValueModule:U(Se.abi,Se.bytecode,p,"KeysWithValueModule"),KeysInTableModule:U($e.abi,$e.bytecode,p,"KeysInTableModule"),UniqueEntityModule:U(Me.abi,Me.bytecode,p,"UniqueEntityModule")},ne=e.modules.filter(r=>!re[r.name]).reduce((r,s)=>(r[s.name]=H(s.name,p),r),re),F={...ze,...Ke,...ne},M=new E.Contract(await F.World,xe.abi,K),R=p?0:1;O||(console.log(b.blue("Installing core World modules")),await $(M,"installRootModule",[await ne.CoreModule,"0x"],R),console.log(b.green("Installed core World modules"))),n&&await $(M,"registerNamespace",[v(n)],R);let se={};w=[...w,...Object.entries(e.tables).map(async([r,{name:s,schema:l,primaryKeys:f}])=>{console.log(b.blue(`Registering table ${r} at ${n}/${s}`)),se[r]=Eo(n,s);let h=Object.values(l).map(y=>{let{schemaType:C}=De(y,e);return C}),m=Object.values(f).map(y=>{let{schemaType:C}=De(y,e);return C});await $(M,"registerTable",[v(n),v(s),Ce(h),Ce(m)],R),await $(M,"setMetadata(bytes16,bytes16,string,string[])",[v(n),v(s),r,Object.keys(l)],R),console.log(b.green(`Registered table ${r} at ${s}`))})],w=[...w,...Object.entries(i.systems).map(async([r,{name:s,openAccess:l,registerFunctionSelectors:f}])=>{if(console.log(b.blue(`Registering system ${r} at ${n}/${s}`)),await $(M,"registerSystem",[v(n),v(s),await F[r],l],R),console.log(b.green(`Registered system ${r} at ${n}/${s}`)),f){let h=await Le(r),m=n==="";await Promise.all(h.map(async({functionName:y,functionArgs:C})=>{let P=m?y+C:`${n}_${s}_${y}${C}`;if(console.log(b.blue(`Registering function "${P}"`)),m){let qe=Re(P===""?{functionName:r,functionArgs:C}:{functionName:y,functionArgs:C}),He=Re({functionName:y,functionArgs:C});await $(M,"registerRootFunctionSelector",[v(n),v(s),qe,He],R)}else await $(M,"registerFunctionSelector",[v(n),v(s),y,C],R);console.log(b.green(`Registered function "${P}"`))}))}})],await Promise.all(w),w=[];for(let[r,{name:s,accessListAddresses:l,accessListSystems:f}]of Object.entries(i.systems)){let h=`${n}/${s}`;w=[...w,...l.map(async m=>{console.log(b.blue(`Grant ${m} access to ${r} (${h})`)),await $(M,"grantAccess",[v(n),v(s),m],R),console.log(b.green(`Granted ${m} access to ${r} (${n}/${s})`))})],w=[...w,...f.map(async m=>{console.log(b.blue(`Grant ${m} access to ${r} (${h})`)),await $(M,"grantAccess",[v(n),v(s),await F[m]],R),console.log(b.green(`Granted ${m} access to ${r} (${h})`))})]}await Promise.all(w),w=[],w=[...w,...e.modules.map(async r=>{console.log(b.blue(`Installing${r.root?" root ":" "}module ${r.name}`));let s=await Promise.all(r.args.map(m=>Fo(m,{tableIds:se,systemAddresses:F}))),l=s.map(m=>m.value),f=s.map(m=>m.type),h=await F[r.name];if(!h)throw new Error(`Module ${r.name} not found`);await $(M,r.root?"installRootModule":"installModule",[h,$o.encode(f,l)],R),console.log(b.green(`Installed${r.root?" root ":" "}module ${r.name}`))})],await Promise.all(w),w=[];let q=ve.join(await Ro(),g+".s.sol");return ko(q)?(console.log(b.blue(`Executing post deploy script at ${q}`)),await Oo(["script",g,"--sig","run(address)",await F.World,"--broadcast","--rpc-url",d,"-vvv"],{profile:u})):console.log(`No script at ${q}, skipping post deploy hook`),console.log(b.green("Deployment completed in",(Date.now()-a)/1e3,"seconds")),{worldAddress:await F.World,blockNumber:te};async function H(r,s){console.log(b.blue("Deploying",r));let{abi:l,bytecode:f}=await ae(r);return U(l,f,s,r)}async function U(r,s,l,f,h=0){try{let m=new E.ContractFactory(r,s,K);console.log(b.gray(`executing deployment of ${f} with nonce ${W}`));let y=m.deploy({nonce:W++,maxPriorityFeePerGas:_,maxFeePerGas:L}).then(P=>l?P:P.deployed());w.push(y);let{address:C}=await y;return console.log(b.green("Deployed",f,"to",C)),C}catch(m){if(S&&console.error(m),h===0&&m?.message.includes("transaction already imported"))return Y(k*1.1),U(r,s,l,f,h++);throw m?.message.includes("invalid bytecode")?new j(`Error deploying ${f}: invalid bytecode. Note that linking of public libraries is not supported yet, make sure none of your libraries use "external" functions.`):m?.message.includes("CreateContractLimit")?new j(`Error deploying ${f}: CreateContractLimit exceeded.`):m}}async function Le(r){let{abi:s}=await ae(r);return s.filter(l=>["fallback","function"].includes(l.type)).map(l=>l.type==="fallback"?{functionName:"",functionArgs:""}:{functionName:l.name,functionArgs:ie(l.inputs)})}function ie(r){return`(${r.map(l=>l.type==="tuple"?ie(l.components):l.type)})`}async function $(r,s,l,f=1,h=0){let m=`${s}(${l.map(y=>`'${y}'`).join(",")})`;try{let y=await r.estimateGas[s].apply(null,l);console.log(b.gray(`executing transaction: ${m} with nonce ${W}`));let C=r[s].apply(null,[...l,{gasLimit:y,nonce:W++,maxPriorityFeePerGas:_,maxFeePerGas:L}]).then(P=>f===0?P:P.wait(f));return w.push(C),C}catch(y){if(S&&console.error(y),h===0&&y?.message.includes("transaction already imported"))return Y(k*1.1),$(r,s,l,f,h++);throw new j(`Gas estimation error for ${m}: ${y?.reason}`)}}async function ae(r){let s,l=ve.join(V,r+".sol",r+".json");try{s=JSON.parse(So(l,"utf8"))}catch{throw new j(`Error reading file at ${l}`)}let f=s?.bytecode?.object;if(!f)throw new j(`No bytecode found in ${l}`);let h=s?.abi;if(!h)throw new j(`No ABI found in ${l}`);return{abi:h,bytecode:f}}async function Y(r){let s=await oe.getFeeData();if(!s.lastBaseFeePerGas)throw new j("Can not fetch lastBaseFeePerGas from RPC");_=s.lastBaseFeePerGas.eq(0)?0:Math.floor(15e8*r),L=s.lastBaseFeePerGas.mul(2).add(_)}}function v(e){if(e.length>16)throw new Error("String does not fit into 16 bytes");let t=new Uint8Array(16);for(let o=0;o<e.length;o++)t[o]=e.charCodeAt(o);for(let o=e.length;o<16;o++)t[o]=0;return t}function Eo(e,t){let o=v(e),i=v(t),a=new Uint8Array(32);return a.set(o),a.set(i,16),a}function Re({functionName:e,functionArgs:t}){let o=e+t;return o===""?"0x":Go(o)}function Go(e){return E.utils.hexDataSlice(E.utils.keccak256(E.utils.toUtf8Bytes(e)),0,4)}import T from"chalk";import{ZodError as Ao}from"zod";import{fromZodError as Io,ValidationError as Wo}from"zod-validation-error";import{NotInsideProjectError as To}from"@latticexyz/config";import{MUDError as Bo}from"@latticexyz/common/errors";function G(e){if(e instanceof Wo)console.log(T.redBright(e.message));else if(e instanceof Ao){let t=Io(e,{prefixSeparator:`
|
|
12
|
+
- `,issueSeparator:`
|
|
13
|
+
- `});console.log(T.redBright(t.message))}else e instanceof To?(console.log(T.red(e.message)),console.log(""),console.log(T.blue("To learn more about MUD's configuration, please go to https://mud.dev/packages/cli/"))):e instanceof Bo?console.log(T.red(e)):console.log(e)}import{forge as Fe,getRpcUrl as Ko,getSrcDirectory as Lo}from"@latticexyz/common/foundry";import{existsSync as qo,mkdirSync as Ho,readFileSync as Yo,writeFileSync as X}from"fs";import{ethers as No}from"ethers";async function Oe(e){let{result:t}=await No.utils.fetchJson(e,'{ "id": 42, "jsonrpc": "2.0", "method": "eth_chainId", "params": [ ] }');return Number(t)}var Q={configPath:{type:"string",desc:"Path to the config file"},clean:{type:"boolean",desc:"Remove the build forge artifacts and cache directories before building"},printConfig:{type:"boolean",desc:"Print the resolved config"},profile:{type:"string",desc:"The foundry profile to use"},debug:{type:"boolean",desc:"Print debug logs, like full error messages"},priorityFeeMultiplier:{type:"number",desc:"Multiply the estimated priority fee by the provided factor",default:1},saveDeployment:{type:"boolean",desc:"Save the deployment info to a file",default:!0},rpc:{type:"string",desc:"The RPC URL to use. Defaults to the RPC url from the local foundry.toml"},worldAddress:{type:"string",desc:"Deploy to an existing World at the given address"},srcDir:{type:"string",desc:"Source directory. Defaults to foundry src directory."},disableTxWait:{type:"boolean",desc:"Disable waiting for transactions to be confirmed.",default:!1}};async function ee(e){e.profile=e.profile??process.env.FOUNDRY_PROFILE;let{configPath:t,printConfig:o,profile:i,clean:a}=e,c=e.rpc??await Ko(i);console.log(B.bgBlue(B.whiteBright(`
|
|
14
|
+
Deploying MUD contracts${i?" with profile "+i:""} to RPC ${c}
|
|
15
|
+
`))),a&&await Fe(["clean"],{profile:i}),await Fe(["build"],{profile:i});let n=e?.srcDir??await Lo(),g=Jo.sync(`${n}/**/*.sol`).map(d=>Vo(d,".sol")),u=await zo(t);o&&console.log(B.green(`
|
|
16
|
+
Resolved config:
|
|
17
|
+
`),JSON.stringify(u,null,2));try{let d=process.env.PRIVATE_KEY;if(!d)throw new _o("Missing PRIVATE_KEY environment variable");let x=await Pe(u,g,{...e,rpc:c,privateKey:d});if(e.saveDeployment){let k=await Oe(c),S=Z.join(u.deploysDirectory,k.toString());Ho(S,{recursive:!0}),X(Z.join(S,"latest.json"),JSON.stringify(x,null,2)),X(Z.join(S,Date.now()+".json"),JSON.stringify(x,null,2));let O=[1337,31337],p=qo(u.worldsFile)?JSON.parse(Yo(u.worldsFile,"utf-8")):{};p[k]={address:x.worldAddress,blockNumber:O.includes(k)?void 0:x.blockNumber},X(u.worldsFile,JSON.stringify(p,null,2)),console.log(B.bgGreen(B.whiteBright(`
|
|
18
|
+
Deployment result (written to ${u.worldsFile} and ${S}):
|
|
19
|
+
`)))}return console.log(x),x}catch(d){G(d),process.exit(1)}}var Zo={command:"deploy",describe:"Deploy MUD contracts",builder(e){return e.options(Q)},async handler(e){await ee(e),process.exit(0)}},Ue=Zo;import{loadConfig as Xo}from"@latticexyz/config";import{worldgen as Qo}from"@latticexyz/world";import{getSrcDirectory as et}from"@latticexyz/common/foundry";import ot from"glob";import je,{basename as tt}from"path";import{rmSync as rt}from"fs";var nt={command:"worldgen",describe:"Autogenerate interfaces for Systems and World based on existing contracts and the config file",builder(e){return e.options({configPath:{type:"string",desc:"Path to the config file"},clean:{type:"boolean",desc:"Clear the worldgen directory before generating new interfaces"}})},async handler(e){let{configPath:t,clean:o}=e,i=await et(),a=ot.sync(`${i}/**/*.sol`).map(g=>({path:g,basename:tt(g,".sol")})),c=await Xo(t),n=je.join(i,c.codegenDirectory);o&&rt(je.join(n,c.worldgenDirectory),{recursive:!0,force:!0}),await Qo(c,a,n),process.exit(0)}},Ee=nt;import I from"chalk";import{existsSync as it,readFileSync as at,rmSync as ct,writeFileSync as Ae}from"fs";import A from"path";import{MUDError as J}from"@latticexyz/common/errors";var Ge={name:"@latticexyz/cli",version:"1.42.0",description:"Command line interface for mud",repository:{type:"git",url:"https://github.com/latticexyz/mud.git",directory:"packages/cli"},license:"MIT",type:"module",exports:{".":"./dist/index.js"},types:"src/index.ts",bin:{mud:"./dist/mud.js"},scripts:{build:"pnpm run build:js","build:js":"tsup && chmod +x ./dist/mud.js",clean:"pnpm run clean:js","clean:js":"rimraf dist",dev:"tsup --watch","generate-test-tables":"tsx ./scripts/generate-test-tables.ts",lint:"eslint . --ext .ts",test:"tsc --noEmit && pnpm run generate-test-tables && forge test"},dependencies:{"@ethersproject/abi":"^5.7.0","@ethersproject/providers":"^5.7.2","@improbable-eng/grpc-web":"^0.15.0","@improbable-eng/grpc-web-node-http-transport":"^0.15.0","@latticexyz/common":"workspace:*","@latticexyz/config":"workspace:*","@latticexyz/schema-type":"workspace:*","@latticexyz/services":"workspace:*","@latticexyz/solecs":"workspace:*","@latticexyz/std-contracts":"workspace:*","@latticexyz/store":"workspace:*","@latticexyz/world":"workspace:*","@typechain/ethers-v5":"^10.2.0",chalk:"^5.0.1",chokidar:"^3.5.3",dotenv:"^16.0.3",ejs:"^3.1.8",ethers:"^5.7.2",execa:"^7.0.0",glob:"^8.0.3","nice-grpc-web":"^2.0.1",openurl:"^1.1.1",path:"^0.12.7",table:"^6.8.1",typechain:"^8.1.1",typescript:"^4.9.5",yargs:"^17.7.1",zod:"^3.21.4","zod-validation-error":"^1.3.0"},devDependencies:{"@types/ejs":"^3.1.1","@types/glob":"^7.2.0","@types/node":"^18.15.11","@types/openurl":"^1.0.0","@types/yargs":"^17.0.10","ds-test":"https://github.com/dapphub/ds-test.git#c9ce3f25bde29fc5eb9901842bf02850dfd2d084","forge-std":"https://github.com/foundry-rs/forge-std.git#b4f121555729b3afb3c5ffccb62ff4b6e2818fd3",tsup:"^6.7.0",tsx:"^3.12.6",vitest:"0.30.1"},gitHead:"914a1e0ae4a573d685841ca2ea921435057deb8f"};var z=".mudbackup",N="@latticexyz",lt={command:"set-version",describe:"Install a custom MUD version and optionally backup the previously installed version",builder(e){return e.options({backup:{type:"boolean",description:`Back up the current MUD versions to "${z}"`},force:{type:"boolean",description:`Backup fails if a "${z}" file is found, unless --force is provided`},restore:{type:"boolean",description:`Restore the previous MUD versions from "${z}"`},mudVersion:{alias:"v",type:"string",description:"The MUD version to install"},link:{alias:"l",type:"string",description:"Relative path to the local MUD root directory to link"}})},async handler(e){try{if(!e.mudVersion&&!e.link&&!e.restore)throw new J("`--mudVersion` or `--link` is required unless --restore is provided.");if(e.link&&e.mudVersion)throw new J("Options `--link` and `--mudVersion` are mutually exclusive");e.mudVersion=e.mudVersion==="canary"?await dt(Ge.name):e.mudVersion;let t="./package.json",{workspaces:o}=Ie(t,e);if(o)for(let i of o){let a=A.join(i,"/package.json");Ie(a,e)}}catch(t){G(t)}finally{process.exit(0)}}};function Ie(e,t){let{restore:o,force:i,link:a}=t,{backup:c,mudVersion:n}=t,g=A.join(A.dirname(e),z),u=it(g);if(a&&!u&&(c=!0),c&&!i&&u)throw new J(`A backup file already exists at ${g}.
|
|
20
|
+
Use --force to overwrite it or --restore to restore it.`);let d=We(e),x=o?We(g):void 0,k={};for(let p in d.dependencies)p.startsWith(N)&&(k[p]=d.dependencies[p]);let S={};for(let p in d.devDependencies)p.startsWith(N)&&(S[p]=d.devDependencies[p]);c&&(Ae(g,JSON.stringify({dependencies:k,devDependencies:S},null,2)),console.log(I.green(`Backed up MUD dependencies from ${e} to ${g}`)));for(let p in d.dependencies)p.startsWith(N)&&(d.dependencies[p]=O(p,"dependencies"));for(let p in d.devDependencies)p.startsWith(N)&&(d.devDependencies[p]=O(p,"devDependencies"));return Ae(e,JSON.stringify(d,null,2)+`
|
|
21
|
+
`),console.log(`Updating ${e}`),Te(k,d.dependencies),Te(S,d.devDependencies),o&&!c&&(ct(g),console.log(I.green(`Cleaned up ${g}`))),d;function O(p,V){return o&&x?x[V][p]:(a&&(n=pt(e,a,p)),n||d[V][p])}}function We(e){try{let t=at(e,"utf8");return JSON.parse(t)}catch{throw new J("Could not read JSON at "+e)}}async function dt(e){try{console.log(I.blue("fetching MUD canary version..."));let o=(await(await fetch(`https://registry.npmjs.org/${e}`)).json())["dist-tags"].canary;return console.log(I.green("MUD canary version:",o)),o}catch{throw new J(`Could not fetch canary version of ${e}`)}}function Te(e,t){for(let o in e)e[o]!==t[o]&&console.log(`${o}: ${I.red(e[o])} -> ${I.green(t[o])}`)}function pt(e,t,o){let i=o.replace(N,""),a=A.relative(A.dirname(e),process.cwd());return"link:"+A.join(a,t,"packages",i)}var Be=lt;import{anvil as mt,forge as gt,getRpcUrl as ut}from"@latticexyz/common/foundry";import ft from"chalk";import{rmSync as yt,writeFileSync as bt}from"fs";var Ne=".mudtest",ht={command:"test",describe:"Run tests in MUD contracts",builder(e){return e.options({...Q,port:{type:"number",description:"Port to run internal node for fork testing on",default:4242},worldAddress:{type:"string",description:"Address of an existing world contract. If provided, deployment is skipped and the RPC provided in the foundry.toml is used for fork testing."},forgeOptions:{type:"string",description:"Options to pass to forge test"}})},async handler(e){if(!e.worldAddress){let a=["--block-base-fee-per-gas","0","--port",String(e.port)];mt(a)}let t=e.worldAddress?await ut(e.profile):`http://127.0.0.1:${e.port}`,o=e.worldAddress??(await ee({...e,saveDeployment:!1,rpc:t})).worldAddress;console.log(ft.blue("World address",o)),bt(Ne,o);let i=e.forgeOptions?.replaceAll("\\","").split(" ")??[];try{let a=await gt(["test","--fork-url",t,...i],{profile:e.profile});console.log(a)}catch(a){console.error(a)}yt(Ne),process.exit(0)}},Je=ht;var Ve=[Ue,le,pe,ye,be,he,we,Ee,Be,Je];import*as _e from"dotenv";_e.config();wt(vt(process.argv)).scriptName("mud").command(Ve).strict().fail((e,t)=>{console.log(""),G(t),console.log(""),process.exit(1)}).alias({h:"help"}).argv;
|
|
8
22
|
//# sourceMappingURL=mud.js.map
|
package/dist/mud.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/mud.ts","../src/commands/deprecated/bulkupload.ts","../src/commands/deprecated/call-system.ts","../src/commands/deprecated/codegen-libdeploy.ts","../src/commands/deprecated/deploy-contracts.ts","../src/commands/deprecated/system-types.ts","../src/commands/deprecated/test.ts","../src/commands/deprecated/trace.ts","../src/commands/deprecated/types.ts","../src/commands/deprecated/index.ts"],"sourcesContent":["#!/usr/bin/env node\n\nimport yargs from \"yargs\";\nimport { hideBin } from \"yargs/helpers\";\nimport { commands as v2 } from \"./commands\";\nimport { commands as v1 } from \"./commands/deprecated\";\nimport { logError } from \"./utils/errors\";\n\n// Load .env file into process.env\nimport * as dotenv from \"dotenv\";\ndotenv.config();\n\nyargs(hideBin(process.argv))\n // Explicit name to display in help (by default it's the entry file, which may not be \"mud\" for e.g. ts-node)\n .scriptName(\"mud\")\n // Use the commands directory to scaffold\n // eslint-disable-next-line @typescript-eslint/no-explicit-any -- command array overload isn't typed, see https://github.com/yargs/yargs/blob/main/docs/advanced.md#esm-hierarchy\n .command([...v1, ...v2] as any)\n // Enable strict mode.\n .strict()\n // Custom error handler\n .fail((msg, err) => {\n console.log(\"\");\n logError(err);\n console.log(\"\");\n\n process.exit(1);\n })\n // Useful aliases.\n .alias({ h: \"help\" }).argv;\n","import { execa } from \"execa\";\nimport path from \"path\";\nimport type { CommandModule } from \"yargs\";\n\nconst contractsDirectory = new URL(\"../src/contracts\", import.meta.url).pathname;\n\ntype Options = {\n statePath: string;\n worldAddress: string;\n rpc: string;\n};\n\nconst commandModule: CommandModule<Options, Options> = {\n command: \"bulkupload\",\n\n describe: \"Uploads the provided ECS state to the provided World\",\n\n builder(yargs) {\n return yargs.options({\n statePath: { type: \"string\", demandOption: true, desc: \"Path to the ECS state to upload\" },\n worldAddress: { type: \"string\", demandOption: true, desc: \"Contract address of the World to upload to\" },\n rpc: { type: \"string\", demandOption: true, desc: \"JSON RPC endpoint\" },\n });\n },\n\n async handler({ statePath, worldAddress, rpc }) {\n console.log(\"Uploading state at \", statePath, \"to\", worldAddress, \"on\", rpc);\n const url = path.join(contractsDirectory, \"BulkUpload.sol\");\n console.log(\"Using BulkUpload script from\", url);\n\n try {\n await execa(\"forge\", [\n \"script\",\n \"--sig\",\n '\"run(string, address)\"',\n \"--rpc-url\",\n rpc,\n `${url}:BulkUpload`,\n statePath,\n worldAddress,\n ]);\n } catch (e) {\n console.error(e);\n }\n\n process.exit(0);\n },\n};\n\nexport default commandModule;\n","import { getTestDirectory } from \"@latticexyz/common/foundry\";\nimport { defaultAbiCoder as abi } from \"ethers/lib/utils.js\";\nimport path from \"path\";\nimport type { CommandModule } from \"yargs\";\nimport { execLog } from \"../../utils/deprecated\";\n\ntype Options = {\n rpc?: string;\n caller?: string;\n world: string;\n systemId?: string;\n systemAddress?: string;\n argTypes?: string[];\n args?: (string | number)[];\n calldata?: string;\n broadcast?: boolean;\n callerPrivateKey?: string;\n debug?: boolean;\n};\n\nconst commandModule: CommandModule<Options, Options> = {\n command: \"call-system\",\n\n describe: \"Execute a mud system\",\n\n builder(yargs) {\n return yargs.options({\n rpc: { type: \"string\", description: \"json rpc endpoint, defaults to http://localhost:8545\" },\n caller: { type: \"string\", description: \"caller address\" },\n world: { type: \"string\", required: true, description: \"world contract address\" },\n systemId: { type: \"string\", description: \"system id preimage (eg mud.system.Move)\" },\n systemAddress: { type: \"string\", description: \"system address (alternative to system id)\" },\n argTypes: { type: \"array\", string: true, description: \"system argument types for abi encoding\" },\n args: { type: \"array\", description: \"system arguments\" },\n calldata: { type: \"string\", description: \"abi encoded system arguments (instead of args/argTypes)\" },\n broadcast: { type: \"boolean\", description: \"send txs to the chain\" },\n callerPrivateKey: {\n type: \"string\",\n description: \"must be set if broadcast is set, must correspond to caller address\",\n },\n debug: { type: \"boolean\", description: \"open debugger\" },\n });\n },\n\n async handler({ rpc, caller, world, systemId, argTypes, args, calldata, broadcast, callerPrivateKey, debug }) {\n const encodedArgs = calldata ?? (argTypes && args && abi.encode(argTypes, args)) ?? \"\";\n const testDir = await getTestDirectory();\n await execLog(\"forge\", [\n \"script\",\n \"--fork-url\",\n rpc ?? \"http://localhost:8545\", // default anvil rpc\n \"--sig\",\n \"debug(address,address,string,bytes,bool)\",\n path.join(testDir, \"utils/Debug.sol\"), // the cli expects the Debug.sol file at this path\n caller ?? \"0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266\", // default anvil deployer\n world,\n systemId || \"\",\n encodedArgs,\n broadcast ? \"true\" : \"false\",\n \"-vvvvv\",\n broadcast ? \"--broadcast\" : \"\",\n callerPrivateKey ? `--private-key ${callerPrivateKey}` : \"\",\n debug ? \"--debug\" : \"\",\n ]);\n\n process.exit(0);\n },\n};\n\nexport default commandModule;\n","import type { CommandModule } from \"yargs\";\nimport { generateLibDeploy } from \"../../utils/deprecated\";\n\ntype Options = {\n config: string;\n out: string;\n systems?: string;\n};\n\nconst commandModule: CommandModule<Options, Options> = {\n command: \"codegen-libdeploy\",\n\n describe: \"Generate LibDeploy.sol from given deploy config\",\n\n builder(yargs) {\n return yargs.options({\n config: { type: \"string\", default: \"./deploy.json\", desc: \"Component and system deployment configuration\" },\n out: { type: \"string\", default: \".\", desc: \"Output directory for LibDeploy.sol\" },\n systems: { type: \"string\", desc: \"Only generate deploy code for the given systems\" },\n });\n },\n\n async handler({ config, out, systems }) {\n await generateLibDeploy(config, out, systems);\n process.exit(0);\n },\n};\n\nexport default commandModule;\n","import type { CommandModule } from \"yargs\";\nimport { DeployOptions, generateAndDeploy, hsr } from \"../../utils/deprecated\";\nimport openurl from \"openurl\";\nimport chalk from \"chalk\";\nimport { getSrcDirectory } from \"@latticexyz/common/foundry\";\n\ntype Options = DeployOptions & {\n watch?: boolean;\n dev?: boolean;\n openUrl?: string;\n};\n\nconst commandModule: CommandModule<Options, Options> = {\n command: \"deploy-contracts\",\n\n describe: \"Deploy mud contracts\",\n\n builder(yargs) {\n return yargs.options({\n config: { type: \"string\", default: \"./deploy.json\", desc: \"Component and system deployment configuration\" },\n deployerPrivateKey: { type: \"string\", desc: \"Deployer private key. If omitted, deployment is not broadcasted.\" },\n worldAddress: { type: \"string\", desc: \"World address to deploy to. If omitted, a new World is deployed.\" },\n rpc: { type: \"string\", default: \"http://localhost:8545\", desc: \"RPC URL of the network to deploy to.\" },\n systems: { type: \"string\", desc: \"Only upgrade the given systems. Requires World address.\" },\n reuseComponents: { type: \"boolean\", desc: \"Skip deploying components and initialization.\" },\n watch: { type: \"boolean\", desc: \"Automatically redeploy changed systems\" },\n dev: { type: \"boolean\", desc: \"Automatically use funded dev private key for local development\" },\n openUrl: {\n type: \"string\",\n desc: \"Opens a browser at the provided url with the worldAddress url param prefilled\",\n },\n gasPrice: { type: \"number\", desc: \"Gas price to set for deploy transactions\" },\n });\n },\n\n async handler({\n config,\n deployerPrivateKey,\n worldAddress,\n rpc,\n systems,\n reuseComponents,\n watch,\n dev,\n openUrl,\n gasPrice,\n }) {\n if (systems != null && !worldAddress) {\n console.error(\"Error: Upgrading systems requires a World address.\");\n process.exit(1);\n }\n\n deployerPrivateKey =\n deployerPrivateKey ??\n (dev\n ? \"0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80\" // Default anvil private key\n : undefined);\n\n // Deploy world, components and systems\n let genDeployResult: Awaited<ReturnType<typeof generateAndDeploy>>;\n try {\n genDeployResult = await generateAndDeploy({\n config,\n deployerPrivateKey,\n worldAddress,\n rpc,\n systems,\n reuseComponents,\n clear: true,\n gasPrice,\n });\n } catch (e: any) {\n if (!e.stderr) {\n // log error if it wasn't piped\n console.log(e);\n }\n console.log(chalk.red(\"\\n-----------\\nError during generateAndDeploy (see above)\"));\n process.exit();\n }\n const { deployedWorldAddress, initialBlockNumber } = genDeployResult;\n console.log(\"World deployed at\", worldAddress, \"at block\", initialBlockNumber);\n\n if (deployedWorldAddress && openUrl) {\n const url = new URL(openUrl);\n url.searchParams.set(\"worldAddress\", deployedWorldAddress);\n console.log(\"\");\n console.log(chalk.cyan(\"Opening client URL to\", url.toString()));\n console.log(\"\");\n openurl.open(url.toString());\n }\n\n // Set up watcher for system files to redeploy on change\n if (watch) {\n const srcDir = await getSrcDirectory();\n hsr(srcDir, async (systems: string[]) => {\n try {\n return await generateAndDeploy({\n config,\n deployerPrivateKey,\n worldAddress,\n rpc,\n systems,\n gasPrice,\n reuseComponents: true,\n });\n } catch (e: any) {\n if (!e.stderr) {\n // log error if it wasn't piped\n console.log(e);\n }\n console.log(chalk.red(\"\\n-----------\\nError during generateAndDeploy in HSR (see above)\"));\n }\n });\n } else {\n process.exit(0);\n }\n },\n};\n\nexport default commandModule;\n","import type { CommandModule } from \"yargs\";\nimport { generateSystemTypes } from \"../../utils/deprecated\";\nimport { systemsDir } from \"../../utils/deprecated/constants\";\n\ntype Options = {\n outputDir: string;\n};\n\nconst commandModule: CommandModule<Options, Options> = {\n command: \"system-types\",\n\n describe: `Generates system type file. Note: assumes contracts of all systems in <forge src path>/${systemsDir} folder, ABIs of all systems in ./abi and typechain generated types in ./types/ethers-contracts`,\n\n builder(yargs) {\n return yargs.options({\n outputDir: {\n type: \"string\",\n description: \"generated types directory, defaults to ./types\",\n default: \"./types\",\n },\n });\n },\n\n async handler({ outputDir }) {\n await generateSystemTypes(outputDir);\n },\n};\n\nexport default commandModule;\n","import type { CommandModule } from \"yargs\";\nimport { execLog, generateLibDeploy, resetLibDeploy } from \"../../utils/deprecated\";\nimport { getTestDirectory } from \"@latticexyz/common/foundry\";\n\ntype Options = {\n forgeOpts?: string;\n config: string;\n v: number;\n};\n\nconst commandModule: CommandModule<Options, Options> = {\n command: \"test\",\n\n describe: \"Run contract tests\",\n\n builder(yargs) {\n return yargs.options({\n forgeOpts: { type: \"string\", desc: \"Options passed to `forge test` command\" },\n config: { type: \"string\", default: \"./deploy.json\", desc: \"Component and system deployment configuration\" },\n v: { type: \"number\", default: 2, desc: \"Verbosity for forge test\" },\n });\n },\n\n async handler({ forgeOpts, config, v }) {\n const testDir = await getTestDirectory();\n\n // Generate LibDeploy.sol\n console.log(\"Generate LibDeploy.sol\");\n await generateLibDeploy(config, testDir);\n\n // Call forge test\n const child = execLog(\"forge\", [\n \"test\",\n ...(v ? [\"-\" + [...new Array(v)].map(() => \"v\").join(\"\")] : []),\n ...(forgeOpts?.split(\" \") || []),\n ]);\n\n process.on(\"SIGINT\", async () => {\n console.log(\"\\ngracefully shutting down from SIGINT (Crtl-C)\");\n child.kill();\n await resetLibDeploy(testDir);\n process.exit();\n });\n\n await child;\n\n // Reset LibDeploy.sol\n console.log(\"Reset LibDeploy.sol\");\n await resetLibDeploy(testDir);\n },\n};\n\nexport default commandModule;\n","import type { CommandModule } from \"yargs\";\nimport { execLog, extractIdFromFile, keccak256 } from \"../../utils/deprecated\";\nimport { readFileSync } from \"fs\";\nimport { Contract } from \"ethers\";\nimport { JsonRpcProvider } from \"@ethersproject/providers\";\nimport WorldAbi from \"@latticexyz/solecs/abi/World.sol/World.json\" assert { type: \"json\" };\nimport { getSrcDirectory } from \"@latticexyz/common/foundry\";\nimport path from \"path\";\nimport { componentsDir, systemsDir } from \"../../utils/deprecated/constants\";\n\ntype Options = {\n config?: string;\n world: string;\n tx: string;\n rpc?: string;\n debug?: boolean;\n};\n\nconst commandModule: CommandModule<Options, Options> = {\n command: \"trace\",\n\n describe: \"Display the trace of a transaction\",\n\n builder(yargs) {\n return yargs.options({\n config: { type: \"string\", description: \"path to mud deploy config (deploy.json)\" },\n world: { type: \"string\", required: true, description: \"world contract address\" },\n tx: { type: \"string\", required: true, description: \"tx hash to replay\" },\n rpc: { type: \"string\", description: \"json rpc endpoint, defaults to http://localhost:8545\" },\n debug: { type: \"boolean\", description: \"open debugger\" },\n });\n },\n\n async handler({ config, world, rpc, tx, debug }) {\n const wd = process.cwd();\n const deployData = config && JSON.parse(readFileSync(config, { encoding: \"utf8\" }));\n const labels = [];\n\n const rpcUrl = rpc || \"http://localhost:8545\";\n const provider = new JsonRpcProvider(rpcUrl);\n const World = new Contract(world, WorldAbi.abi, provider);\n\n if (deployData) {\n const srcDir = await getSrcDirectory();\n\n // Create component labels\n const componentPromises = deployData.components.map(async (component: string) => {\n const filePath = path.join(wd, srcDir, componentsDir, `${component}.sol`);\n const id = extractIdFromFile(filePath);\n if (!id) return;\n const address = await World.getComponent(keccak256(id));\n return [component, address];\n });\n // Create system labels\n const systemPromises = deployData.systems.map(async (system: { name: string }) => {\n const filePath = path.join(wd, srcDir, systemsDir, `${system.name}.sol`);\n const id = extractIdFromFile(filePath);\n if (!id) return;\n const address = await World.getSystemAddress(keccak256(id));\n return [system.name, address];\n });\n\n const components = await Promise.all(componentPromises);\n const systems = await Promise.all(systemPromises);\n\n labels.push(...components, ...systems);\n }\n await execLog(\"cast\", [\n \"run\",\n ...labels.map((label) => [\"--label\", `${label[1]}:${label[0]}`]).flat(),\n ...(debug ? [\"--debug\"] : []),\n `--rpc-url`,\n `${rpcUrl}`,\n `${tx}`,\n ]);\n\n process.exit(0);\n },\n};\n\nexport default commandModule;\n","import type { CommandModule } from \"yargs\";\nimport { generateTypes } from \"../../utils/deprecated\";\n\ntype Options = {\n abiDir?: string;\n outputDir: string;\n};\n\nconst commandModule: CommandModule<Options, Options> = {\n command: \"types\",\n\n describe: \"Generates typescript types for contracts and systems.\",\n\n builder(yargs) {\n return yargs.options({\n abiDir: {\n type: \"string\",\n description: \"Input directory of existing ABI to use to generate types. If not provided, contracts are built.\",\n },\n outputDir: {\n type: \"string\",\n description: \"Output directory for generated types. Defaults to ./types\",\n default: \"./types\",\n },\n });\n },\n\n async handler({ abiDir, outputDir }) {\n await generateTypes(abiDir, outputDir, { clear: true });\n },\n};\n\nexport default commandModule;\n","import { CommandModule } from \"yargs\";\n\nimport bulkupload from \"./bulkupload\";\nimport callSystem from \"./call-system\";\nimport codegenLibdeploy from \"./codegen-libdeploy\";\nimport deployContracts from \"./deploy-contracts\";\nimport systemTypes from \"./system-types\";\nimport test from \"./test\";\nimport trace from \"./trace\";\nimport types from \"./types\";\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any -- Each command has different options\nexport const commands: CommandModule<any, any>[] = [\n b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AAiB,EAChDa,EAAU,MAAM,QAAQ,IAAIJ,CAAc,EAEhDlB,EAAO,KAAK,GAAGqB,EAAY,GAAGC,CAAO,EAEvC,MAAMC,EAAQ,OAAQ,CACpB,MACA,GAAGvB,EAAO,IAAKwB,GAAU,CAAC,UAAW,GAAGA,EAAM,CAAC,KAAKA,EAAM,CAAC,GAAG,CAAC,EAAE,KAAK,EACtE,GAAI5B,EAAQ,CAAC,SAAS,EAAI,CAAC,EAC3B,YACA,GAAGK,IACH,GAAGN,GACL,CAAC,EAED,QAAQ,KAAK,CAAC,CAChB,CACF,EAEO8B,EAAQnC,GCxEf,IAAMoC,GAAiD,CACrD,QAAS,QAET,SAAU,wDAEV,QAAQC,EAAO,CACb,OAAOA,EAAM,QAAQ,CACnB,OAAQ,CACN,KAAM,SACN,YAAa,iGACf,EACA,UAAW,CACT,KAAM,SACN,YAAa,4DACb,QAAS,SACX,CACF,CAAC,CACH,EAEA,MAAM,QAAQ,CAAE,OAAAC,EAAQ,UAAAC,CAAU,EAAG,CACnC,MAAMC,EAAcF,EAAQC,EAAW,CAAE,MAAO,EAAK,CAAC,CACxD,CACF,EAEOE,EAAQL,GCpBR,IAAMM,EAAsC,CACjDC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,CACF,ETZA,UAAYC,MAAY,SACjB,SAAO,EAEdC,GAAMC,GAAQ,QAAQ,IAAI,CAAC,EAExB,WAAW,KAAK,EAGhB,QAAQ,CAAC,GAAGC,EAAI,GAAGA,CAAE,CAAQ,EAE7B,OAAO,EAEP,KAAK,CAACC,EAAKC,IAAQ,CAClB,QAAQ,IAAI,EAAE,EACdC,EAASD,CAAG,EACZ,QAAQ,IAAI,EAAE,EAEd,QAAQ,KAAK,CAAC,CAChB,CAAC,EAEA,MAAM,CAAE,EAAG,MAAO,CAAC,EAAE","names":["yargs","hideBin","execa","path","contractsDirectory","commandModule","yargs","statePath","worldAddress","rpc","url","e","bulkupload_default","getTestDirectory","abi","path","commandModule","yargs","rpc","caller","world","systemId","argTypes","args","calldata","broadcast","callerPrivateKey","debug","encodedArgs","abi","testDir","getTestDirectory","execLog","path","call_system_default","commandModule","yargs","config","out","systems","generateLibDeploy","codegen_libdeploy_default","openurl","chalk","getSrcDirectory","commandModule","yargs","config","deployerPrivateKey","worldAddress","rpc","systems","reuseComponents","watch","dev","openUrl","gasPrice","genDeployResult","generateAndDeploy","e","deployedWorldAddress","initialBlockNumber","url","srcDir","hsr","deploy_contracts_default","commandModule","systemsDir","yargs","outputDir","generateSystemTypes","system_types_default","getTestDirectory","commandModule","yargs","forgeOpts","config","v","testDir","generateLibDeploy","child","execLog","resetLibDeploy","test_default","readFileSync","Contract","JsonRpcProvider","WorldAbi","getSrcDirectory","path","commandModule","yargs","config","world","rpc","tx","debug","wd","deployData","readFileSync","labels","rpcUrl","provider","JsonRpcProvider","World","Contract","WorldAbi","srcDir","getSrcDirectory","componentPromises","component","filePath","path","componentsDir","id","extractIdFromFile","address","keccak256","systemPromises","system","systemsDir","components","systems","execLog","label","trace_default","commandModule","yargs","abiDir","outputDir","generateTypes","types_default","commands","bulkupload_default","call_system_default","deploy_contracts_default","codegen_libdeploy_default","system_types_default","test_default","trace_default","types_default","dotenv","yargs","hideBin","commands","msg","err","logError"]}
|
|
1
|
+
{"version":3,"sources":["../src/mud.ts","../src/commands/devnode.ts","../src/commands/faucet.ts","../src/commands/gas-report.ts","../src/commands/hello.ts","../src/commands/tablegen.ts","../src/commands/tsgen.ts","../src/commands/deploy.ts","../src/utils/deploy.ts","../src/utils/errors.ts","../src/utils/getChainId.ts","../src/commands/worldgen.ts","../src/commands/set-version.ts","../package.json","../src/commands/test.ts","../src/commands/index.ts"],"sourcesContent":["#!/usr/bin/env node\n\nimport yargs from \"yargs\";\nimport { hideBin } from \"yargs/helpers\";\nimport { commands } from \"./commands\";\nimport { logError } from \"./utils/errors\";\n\n// Load .env file into process.env\nimport * as dotenv from \"dotenv\";\ndotenv.config();\n\nyargs(hideBin(process.argv))\n // Explicit name to display in help (by default it's the entry file, which may not be \"mud\" for e.g. ts-node)\n .scriptName(\"mud\")\n // Use the commands directory to scaffold\n // eslint-disable-next-line @typescript-eslint/no-explicit-any -- command array overload isn't typed, see https://github.com/yargs/yargs/blob/main/docs/advanced.md#esm-hierarchy\n .command(commands as any)\n // Enable strict mode.\n .strict()\n // Custom error handler\n .fail((msg, err) => {\n console.log(\"\");\n logError(err);\n console.log(\"\");\n\n process.exit(1);\n })\n // Useful aliases.\n .alias({ h: \"help\" }).argv;\n","import { rmSync } from \"fs\";\nimport { homedir } from \"os\";\nimport path from \"path\";\nimport type { CommandModule } from \"yargs\";\nimport { execa } from \"execa\";\n\ntype Options = {\n blocktime: number;\n};\n\nconst commandModule: CommandModule<Options, Options> = {\n command: \"devnode\",\n\n describe: \"Start a local Ethereum node for development\",\n\n builder(yargs) {\n return yargs.options({\n blocktime: { type: \"number\", default: 1, decs: \"Interval in which new blocks are produced\" },\n });\n },\n\n async handler({ blocktime }) {\n console.log(\"Clearing devnode history\");\n const userHomeDir = homedir();\n rmSync(path.join(userHomeDir, \".foundry\", \"anvil\", \"tmp\"), { recursive: true, force: true });\n\n const anvilArgs = [\"-b\", String(blocktime), \"--block-base-fee-per-gas\", \"0\"];\n console.log(`Running: anvil ${anvilArgs.join(\" \")}`);\n const child = execa(\"anvil\", anvilArgs, {\n stdio: [\"inherit\", \"inherit\", \"inherit\"],\n });\n\n process.on(\"SIGINT\", () => {\n console.log(\"\\ngracefully shutting down from SIGINT (Crtl-C)\");\n child.kill();\n process.exit();\n });\n await child;\n },\n};\n\nexport default commandModule;\n","import type { CommandModule } from \"yargs\";\nimport { FaucetServiceDefinition } from \"@latticexyz/services/faucet\";\nimport { createChannel, createClient } from \"nice-grpc-web\";\nimport chalk from \"chalk\";\nimport { NodeHttpTransport } from \"@improbable-eng/grpc-web-node-http-transport\";\n\ntype Options = {\n dripDev?: boolean;\n faucetUrl: string;\n address: string;\n};\n\n/**\n * Create a FaucetServiceClient\n * @param url FaucetService URL\n * @returns FaucetServiceClient\n */\nfunction createFaucetService(url: string) {\n return createClient(FaucetServiceDefinition, createChannel(url, NodeHttpTransport()));\n}\n\nconst commandModule: CommandModule<Options, Options> = {\n command: \"faucet\",\n\n describe: \"Interact with a MUD faucet\",\n\n builder(yargs) {\n return yargs.options({\n dripDev: {\n type: \"boolean\",\n desc: \"Request a drip from the dev endpoint (requires faucet to have dev mode enabled)\",\n default: true,\n },\n faucetUrl: {\n type: \"string\",\n desc: \"URL of the MUD faucet\",\n default: \"https://faucet.testnet-mud-services.linfra.xyz\",\n },\n address: {\n type: \"string\",\n desc: \"Ethereum address to fund\",\n required: true,\n },\n });\n },\n\n async handler({ dripDev, faucetUrl, address }) {\n const faucet = createFaucetService(faucetUrl);\n\n if (dripDev) {\n console.log(chalk.yellow(\"Dripping to\", address));\n await faucet.dripDev({ address });\n console.log(chalk.yellow(\"Success\"));\n }\n\n process.exit(0);\n },\n};\n\nexport default commandModule;\n","import type { CommandModule } from \"yargs\";\nimport { readFileSync, writeFileSync, rmSync } from \"fs\";\nimport { execa } from \"execa\";\nimport chalk from \"chalk\";\nimport { table, getBorderCharacters } from \"table\";\n\n/**\n * Print the gas report to the console, save it to a file and compare it to a previous gas report if provided.\n * Requires forge to be installed, and gas test files including `// !gasreport` comments, like this:\n *\n * ```solidity\n * contract GasTest is DSTestPlus {\n * function testBuffer() public pure {\n * // !gasreport allocate a buffer\n * Buffer buffer = Buffer_.allocate(32);\n *\n * bytes32 value = keccak256(\"some data\");\n *\n * // !gasreport append 32 bytes to a buffer\n * buffer.append(value);\n * }\n * }\n * ```\n */\n\ntype Options = {\n path: string[];\n save?: string;\n compare?: string;\n};\n\ntype GasReportEntry = {\n source: string;\n name: string;\n functionCall: string;\n gasUsed: number;\n prevGasUsed?: number;\n};\n\ntype GasReport = GasReportEntry[];\n\nconst tempFileSuffix = \"MudGasReport\";\n\nconst commandModule: CommandModule<Options, Options> = {\n command: \"gas-report\",\n\n describe: \"Create a gas report\",\n\n builder(yargs) {\n return yargs.options({\n path: { type: \"array\", string: true, default: [\"Gas.t.sol\"], desc: \"File containing the gas tests\" },\n save: { type: \"string\", desc: \"Save the gas report to a file\" },\n compare: { type: \"string\", desc: \"Compare to an existing gas report\" },\n });\n },\n\n async handler({ path: files, save, compare }) {\n const validFiles = files.filter((file) => file.endsWith(\".t.sol\"));\n const tempFiles = await Promise.all(validFiles.map((file) => createGasReport(file)));\n\n process.once(\"SIGINT\", () => {\n console.log(\"caught sigint, deleting temp files\");\n tempFiles.forEach((file) => rmSync(file));\n });\n\n let gasReport: GasReport;\n try {\n gasReport = await runGasReport();\n } catch {\n setTimeout(() => process.exit());\n return;\n } finally {\n // Delete the temporary files\n tempFiles.forEach((file) => rmSync(file));\n }\n\n // If this gas report should be compared to an existing one, load the existing one\n if (compare) {\n try {\n const compareGasReport: GasReport = JSON.parse(readFileSync(compare, \"utf8\"));\n // Merge the previous gas report with the new one\n gasReport = gasReport.map((entry) => {\n const prevEntry = compareGasReport.find(\n (e) => e.name === entry.name && e.functionCall === entry.functionCall\n );\n return { ...entry, prevGasUsed: prevEntry?.gasUsed };\n });\n } catch {\n console.log(chalk.red(`Gas report to compare not found: ${compare}`));\n compare = undefined;\n }\n }\n\n // Print gas report\n printGasReport(gasReport, compare);\n\n // Save gas report to file if requested\n if (save) saveGasReport(gasReport, save);\n\n process.exit(0);\n },\n};\n\nexport default commandModule;\n\nasync function createGasReport(filename: string): Promise<string> {\n console.log(\"Creating gas report for\", chalk.bold(filename));\n\n // Parse the given test file, and add gas reporting wherever requested by a `// !gasreport` comment\n const fileContents = readFileSync(filename, \"utf8\");\n let newFile = fileContents;\n\n // Use a regex to find first line of each function\n const functionRegex = new RegExp(/function (.*){/g);\n // Insert a line to declare the _gasreport variable at the start of each function\n let functionMatch;\n while ((functionMatch = functionRegex.exec(fileContents)) !== null) {\n const functionSignature = functionMatch[0];\n newFile = newFile.replace(functionSignature, `${functionSignature}\\nuint256 _gasreport;`);\n }\n\n // A gasreport comment has a name (written after the comment) and a function call (written on the next line)\n // Create a regex to extract both the name and the function call\n const regex = new RegExp(/\\/\\/ !gasreport (.*)\\n(.*)/g);\n\n // Apply the regex and loop through the matches,\n // and create a new file with the gasreport comments replaced by the gas report\n let match;\n while ((match = regex.exec(fileContents)) !== null) {\n const name = match[1];\n const functionCall = match[2].trim();\n\n newFile = newFile.replace(\n match[0],\n `\n_gasreport = gasleft();\n${functionCall}\n_gasreport = _gasreport - gasleft();\nconsole.log(\"GAS REPORT(${filename}): ${name} [${functionCall.replaceAll('\"', '\\\\\"')}]:\", _gasreport);`\n );\n }\n\n // Remove all occurrences of `pure` with `view`\n newFile = newFile.replace(/pure/g, \"view\");\n\n // Write the new file to disk (temporarily)\n // Create the temp file by replacing the previous file name with MudGasReport\n const tempFileName = filename.replace(/\\.t\\.sol$/, `${tempFileSuffix}.t.sol`);\n writeFileSync(tempFileName, newFile);\n\n return tempFileName;\n}\n\nasync function runGasReport(): Promise<GasReport> {\n console.log(\"Running gas report\");\n const gasReport: GasReport = [];\n\n // Extract the logs from the child process\n let logs = \"\";\n try {\n // Run the generated file using forge\n const child = execa(\"forge\", [\"test\", \"--match-path\", `*${tempFileSuffix}*`, \"-vvv\"], {\n stdio: [\"inherit\", \"pipe\", \"inherit\"],\n });\n logs = (await child).stdout;\n } catch (error: any) {\n console.log(error.stdout ?? error);\n console.log(chalk.red(\"\\n-----------\\nError while running the gas report (see above)\"));\n throw error;\n }\n\n // Extract the gas reports from the logs\n\n // Create a regex to find all lines starting with `GAS REPORT:` and extract the name, function call and gas used\n const gasReportRegex = new RegExp(/GAS REPORT\\((.*)\\): (.*) \\[(.*)\\]: (.*)/g);\n\n // Loop through the matches and print the gas report\n let gasReportMatch;\n while ((gasReportMatch = gasReportRegex.exec(logs)) !== null) {\n const source = gasReportMatch[1];\n const name = gasReportMatch[2];\n const functionCall = gasReportMatch[3].replace(\";\", \"\");\n const gasUsed = parseInt(gasReportMatch[4]);\n gasReport.push({ source, name, functionCall, gasUsed });\n }\n\n gasReport.sort((a, b) => a.source.localeCompare(b.source));\n\n return gasReport;\n}\n\nfunction printGasReport(gasReport: GasReport, compare?: string) {\n if (compare) console.log(chalk.bold(`Gas report compared to ${compare}`));\n\n const headers = [\n chalk.bold(\"Source\"),\n chalk.bold(\"Name\"),\n chalk.bold(\"Function call\"),\n chalk.bold(\"Gas used\"),\n ...(compare ? [chalk.bold(\"Prev gas used\"), chalk.bold(\"Difference\")] : []),\n ];\n\n const values = gasReport.map((entry) => {\n const diff = entry.prevGasUsed ? entry.gasUsed - entry.prevGasUsed : 0;\n const diffEntry = diff > 0 ? chalk.red(`+${diff}`) : diff < 0 ? chalk.green(`${diff}`) : diff;\n const compareColumns = compare ? [entry.prevGasUsed ?? \"n/a\", diffEntry] : [];\n const gasUsedEntry = diff > 0 ? chalk.red(entry.gasUsed) : diff < 0 ? chalk.green(entry.gasUsed) : entry.gasUsed;\n return [entry.source, entry.name, entry.functionCall, gasUsedEntry, ...compareColumns];\n });\n\n const rows = [headers, ...values];\n\n console.log(table(rows, { border: getBorderCharacters(\"norc\") }));\n}\n\nfunction saveGasReport(gasReport: GasReport, path: string) {\n console.log(chalk.bold(`Saving gas report to ${path}`));\n writeFileSync(path, `${JSON.stringify(gasReport, null, 2)}\\n`);\n}\n","import type { CommandModule } from \"yargs\";\n\ntype Options = {\n name: string;\n upper: boolean | undefined;\n};\n\nconst commandModule: CommandModule<Options, Options> = {\n command: \"hello <name>\",\n\n describe: \"Greet <name> with Hello\",\n\n builder(yargs) {\n return yargs\n .options({\n upper: { type: \"boolean\" },\n })\n .positional(\"name\", { type: \"string\", demandOption: true });\n },\n\n handler({ name }) {\n const greeting = `Gm, ${name}!`;\n console.log(greeting);\n process.exit(0);\n },\n};\n\nexport default commandModule;\n","import path from \"path\";\nimport type { CommandModule } from \"yargs\";\nimport { loadConfig } from \"@latticexyz/config\";\nimport { StoreConfig, tablegen } from \"@latticexyz/store\";\nimport { getSrcDirectory } from \"@latticexyz/common/foundry\";\n\ntype Options = {\n configPath?: string;\n};\n\nconst commandModule: CommandModule<Options, Options> = {\n command: \"tablegen\",\n\n describe: \"Autogenerate MUD Store table libraries based on the config file\",\n\n builder(yargs) {\n return yargs.options({\n configPath: { type: \"string\", desc: \"Path to the config file\" },\n });\n },\n\n async handler({ configPath }) {\n const config = (await loadConfig(configPath)) as StoreConfig;\n const srcDir = await getSrcDirectory();\n\n await tablegen(config, path.join(srcDir, config.codegenDirectory));\n\n process.exit(0);\n },\n};\n\nexport default commandModule;\n","import type { CommandModule } from \"yargs\";\nimport { loadConfig } from \"@latticexyz/config\";\nimport { StoreConfig } from \"@latticexyz/store\";\nimport { tsgen } from \"../render-ts/tsgen\";\n\ntype Options = {\n configPath: string;\n out: string;\n};\n\nconst commandModule: CommandModule<Options, Options> = {\n command: \"tsgen\",\n\n describe: \"Autogenerate MUD typescript definitions based on the config file\",\n\n builder(yargs) {\n return yargs.options({\n configPath: { type: \"string\", demandOption: true, desc: \"Path to the config file\" },\n out: { type: \"string\", demandOption: true, desc: \"Directory to output MUD typescript definition files\" },\n });\n },\n\n async handler(args) {\n const { configPath, out } = args;\n\n const config = (await loadConfig(configPath)) as StoreConfig;\n\n await tsgen(config, out);\n\n process.exit(0);\n },\n};\n\nexport default commandModule;\n","import chalk from \"chalk\";\nimport glob from \"glob\";\nimport path, { basename } from \"path\";\nimport type { CommandModule, Options } from \"yargs\";\nimport { MUDError } from \"@latticexyz/common/errors\";\nimport { loadConfig } from \"@latticexyz/config\";\nimport { StoreConfig } from \"@latticexyz/store\";\nimport { WorldConfig } from \"@latticexyz/world\";\nimport { deploy } from \"../utils/deploy\";\nimport { logError } from \"../utils/errors\";\nimport { forge, getRpcUrl, getSrcDirectory } from \"@latticexyz/common/foundry\";\nimport { existsSync, mkdirSync, readFileSync, writeFileSync } from \"fs\";\nimport { getChainId } from \"../utils/getChainId\";\n\nexport type DeployOptions = {\n configPath?: string;\n printConfig?: boolean;\n profile?: string;\n priorityFeeMultiplier: number;\n clean?: boolean;\n debug?: boolean;\n saveDeployment?: boolean;\n rpc?: string;\n worldAddress?: string;\n srcDir?: string;\n disableTxWait: boolean;\n};\n\nexport const yDeployOptions = {\n configPath: { type: \"string\", desc: \"Path to the config file\" },\n clean: { type: \"boolean\", desc: \"Remove the build forge artifacts and cache directories before building\" },\n printConfig: { type: \"boolean\", desc: \"Print the resolved config\" },\n profile: { type: \"string\", desc: \"The foundry profile to use\" },\n debug: { type: \"boolean\", desc: \"Print debug logs, like full error messages\" },\n priorityFeeMultiplier: {\n type: \"number\",\n desc: \"Multiply the estimated priority fee by the provided factor\",\n default: 1,\n },\n saveDeployment: { type: \"boolean\", desc: \"Save the deployment info to a file\", default: true },\n rpc: { type: \"string\", desc: \"The RPC URL to use. Defaults to the RPC url from the local foundry.toml\" },\n worldAddress: { type: \"string\", desc: \"Deploy to an existing World at the given address\" },\n srcDir: { type: \"string\", desc: \"Source directory. Defaults to foundry src directory.\" },\n disableTxWait: { type: \"boolean\", desc: \"Disable waiting for transactions to be confirmed.\", default: false },\n} satisfies Record<keyof DeployOptions, Options>;\n\nexport async function deployHandler(args: Parameters<(typeof commandModule)[\"handler\"]>[0]) {\n args.profile = args.profile ?? process.env.FOUNDRY_PROFILE;\n const { configPath, printConfig, profile, clean } = args;\n\n const rpc = args.rpc ?? (await getRpcUrl(profile));\n console.log(\n chalk.bgBlue(\n chalk.whiteBright(`\\n Deploying MUD contracts${profile ? \" with profile \" + profile : \"\"} to RPC ${rpc} \\n`)\n )\n );\n\n if (clean) await forge([\"clean\"], { profile });\n\n // Run forge build\n await forge([\"build\"], { profile });\n\n // Get a list of all contract names\n const srcDir = args?.srcDir ?? (await getSrcDirectory());\n const existingContracts = glob\n .sync(`${srcDir}/**/*.sol`)\n // Get the basename of the file\n .map((path) => basename(path, \".sol\"));\n\n // Load the config\n const mudConfig = (await loadConfig(configPath)) as StoreConfig & WorldConfig;\n\n if (printConfig) console.log(chalk.green(\"\\nResolved config:\\n\"), JSON.stringify(mudConfig, null, 2));\n\n try {\n const privateKey = process.env.PRIVATE_KEY;\n if (!privateKey) throw new MUDError(\"Missing PRIVATE_KEY environment variable\");\n const deploymentInfo = await deploy(mudConfig, existingContracts, { ...args, rpc, privateKey });\n\n if (args.saveDeployment) {\n // Write deployment result to file (latest and timestamp)\n const chainId = await getChainId(rpc);\n const outputDir = path.join(mudConfig.deploysDirectory, chainId.toString());\n mkdirSync(outputDir, { recursive: true });\n writeFileSync(path.join(outputDir, \"latest.json\"), JSON.stringify(deploymentInfo, null, 2));\n writeFileSync(path.join(outputDir, Date.now() + \".json\"), JSON.stringify(deploymentInfo, null, 2));\n\n const localChains = [1337, 31337];\n const deploys = existsSync(mudConfig.worldsFile) ? JSON.parse(readFileSync(mudConfig.worldsFile, \"utf-8\")) : {};\n deploys[chainId] = {\n address: deploymentInfo.worldAddress,\n // 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.\n blockNumber: localChains.includes(chainId) ? undefined : deploymentInfo.blockNumber,\n };\n writeFileSync(mudConfig.worldsFile, JSON.stringify(deploys, null, 2));\n\n console.log(\n chalk.bgGreen(\n chalk.whiteBright(`\\n Deployment result (written to ${mudConfig.worldsFile} and ${outputDir}): \\n`)\n )\n );\n }\n\n console.log(deploymentInfo);\n return deploymentInfo;\n } catch (error: any) {\n logError(error);\n process.exit(1);\n }\n}\n\nconst commandModule: CommandModule<DeployOptions, DeployOptions> = {\n command: \"deploy\",\n\n describe: \"Deploy MUD contracts\",\n\n builder(yargs) {\n return yargs.options(yDeployOptions);\n },\n\n async handler(args) {\n await deployHandler(args);\n process.exit(0);\n },\n};\n\nexport default commandModule;\n","import { existsSync, readFileSync } from \"fs\";\nimport path from \"path\";\nimport chalk from \"chalk\";\nimport { BigNumber, ContractInterface, ethers } from \"ethers\";\nimport { defaultAbiCoder as abi, Fragment, ParamType } from \"ethers/lib/utils.js\";\n\nimport { getOutDirectory, getScriptDirectory, cast, forge } from \"@latticexyz/common/foundry\";\nimport { resolveWithContext } from \"@latticexyz/config\";\nimport { MUDError } from \"@latticexyz/common/errors\";\nimport { encodeSchema } from \"@latticexyz/schema-type\";\nimport { StoreConfig, resolveAbiOrUserType } from \"@latticexyz/store\";\nimport { WorldConfig, resolveWorldConfig } from \"@latticexyz/world\";\nimport { IBaseWorld } from \"@latticexyz/world/types/ethers-contracts/IBaseWorld\";\n\nimport WorldData from \"@latticexyz/world/abi/World.sol/World.json\" assert { type: \"json\" };\nimport IBaseWorldData from \"@latticexyz/world/abi/IBaseWorld.sol/IBaseWorld.json\" assert { type: \"json\" };\nimport CoreModuleData from \"@latticexyz/world/abi/CoreModule.sol/CoreModule.json\" assert { type: \"json\" };\nimport KeysWithValueModuleData from \"@latticexyz/world/abi/KeysWithValueModule.sol/KeysWithValueModule.json\" assert { type: \"json\" };\nimport KeysInTableModuleData from \"@latticexyz/world/abi/KeysInTableModule.sol/KeysInTableModule.json\" assert { type: \"json\" };\nimport UniqueEntityModuleData from \"@latticexyz/world/abi/UniqueEntityModule.sol/UniqueEntityModule.json\" assert { type: \"json\" };\n\nexport interface DeployConfig {\n profile?: string;\n rpc: string;\n privateKey: string;\n priorityFeeMultiplier: number;\n debug?: boolean;\n worldAddress?: string;\n disableTxWait: boolean;\n}\n\nexport interface DeploymentInfo {\n blockNumber: number;\n worldAddress: string;\n}\n\nexport async function deploy(\n mudConfig: StoreConfig & WorldConfig,\n existingContracts: string[],\n deployConfig: DeployConfig\n): Promise<DeploymentInfo> {\n const resolvedConfig = resolveWorldConfig(mudConfig, existingContracts);\n\n const startTime = Date.now();\n const { worldContractName, namespace, postDeployScript } = mudConfig;\n const { profile, rpc, privateKey, priorityFeeMultiplier, debug, worldAddress, disableTxWait } = deployConfig;\n const forgeOutDirectory = await getOutDirectory(profile);\n\n // Set up signer for deployment\n const provider = new ethers.providers.StaticJsonRpcProvider(rpc);\n const signer = new ethers.Wallet(privateKey, provider);\n\n // Manual nonce handling to allow for faster sending of transactions without waiting for previous transactions\n let nonce = await signer.getTransactionCount();\n console.log(\"Initial nonce\", nonce);\n\n // Compute maxFeePerGas and maxPriorityFeePerGas like ethers, but allow for a multiplier to allow replacing pending transactions\n let maxPriorityFeePerGas: number;\n let maxFeePerGas: BigNumber;\n setInternalFeePerGas(priorityFeeMultiplier);\n\n // Catch all to await any promises before exiting the script\n let promises: Promise<unknown>[] = [];\n\n // Get block number before deploying\n const blockNumber = Number(await cast([\"block-number\", \"--rpc-url\", rpc], { profile }));\n console.log(\"Start deployment at block\", blockNumber);\n\n // Deploy World\n const worldPromise = {\n World: worldAddress\n ? Promise.resolve(worldAddress)\n : worldContractName\n ? deployContractByName(worldContractName, disableTxWait)\n : deployContract(IBaseWorldData.abi, WorldData.bytecode, disableTxWait, \"World\"),\n };\n\n // Deploy Systems\n const systemPromises = Object.keys(resolvedConfig.systems).reduce<Record<string, Promise<string>>>(\n (acc, systemName) => {\n acc[systemName] = deployContractByName(systemName, disableTxWait);\n return acc;\n },\n {}\n );\n\n // Deploy default World modules\n const defaultModules: Record<string, Promise<string>> = {\n // TODO: these only need to be deployed once per chain, add a check if they exist already\n CoreModule: deployContract(CoreModuleData.abi, CoreModuleData.bytecode, disableTxWait, \"CoreModule\"),\n KeysWithValueModule: deployContract(\n KeysWithValueModuleData.abi,\n KeysWithValueModuleData.bytecode,\n disableTxWait,\n \"KeysWithValueModule\"\n ),\n KeysInTableModule: deployContract(\n KeysInTableModuleData.abi,\n KeysInTableModuleData.bytecode,\n disableTxWait,\n \"KeysInTableModule\"\n ),\n UniqueEntityModule: deployContract(\n UniqueEntityModuleData.abi,\n UniqueEntityModuleData.bytecode,\n disableTxWait,\n \"UniqueEntityModule\"\n ),\n };\n\n // Deploy user Modules\n const modulePromises = mudConfig.modules\n .filter((module) => !defaultModules[module.name]) // Only deploy user modules here, not default modules\n .reduce<Record<string, Promise<string>>>((acc, module) => {\n acc[module.name] = deployContractByName(module.name, disableTxWait);\n return acc;\n }, defaultModules);\n\n // Combine all contracts into one object\n const contractPromises: Record<string, Promise<string>> = { ...worldPromise, ...systemPromises, ...modulePromises };\n\n // Create World contract instance from deployed address\n const WorldContract = new ethers.Contract(await contractPromises.World, IBaseWorldData.abi, signer) as IBaseWorld;\n\n const confirmations = disableTxWait ? 0 : 1;\n\n // Install core Modules\n if (!worldAddress) {\n console.log(chalk.blue(\"Installing core World modules\"));\n await fastTxExecute(WorldContract, \"installRootModule\", [await modulePromises.CoreModule, \"0x\"], confirmations);\n console.log(chalk.green(\"Installed core World modules\"));\n }\n\n // Register namespace\n if (namespace) await fastTxExecute(WorldContract, \"registerNamespace\", [toBytes16(namespace)], confirmations);\n\n // Register tables\n const tableIds: { [tableName: string]: Uint8Array } = {};\n promises = [\n ...promises,\n ...Object.entries(mudConfig.tables).map(async ([tableName, { name, schema, primaryKeys }]) => {\n console.log(chalk.blue(`Registering table ${tableName} at ${namespace}/${name}`));\n\n // Store the tableId for later use\n tableIds[tableName] = toResourceSelector(namespace, name);\n\n // Register table\n const schemaTypes = Object.values(schema).map((abiOrUserType) => {\n const { schemaType } = resolveAbiOrUserType(abiOrUserType, mudConfig);\n return schemaType;\n });\n\n const keyTypes = Object.values(primaryKeys).map((abiOrUserType) => {\n const { schemaType } = resolveAbiOrUserType(abiOrUserType, mudConfig);\n return schemaType;\n });\n\n await fastTxExecute(\n WorldContract,\n \"registerTable\",\n [toBytes16(namespace), toBytes16(name), encodeSchema(schemaTypes), encodeSchema(keyTypes)],\n confirmations\n );\n\n // Register table metadata\n await fastTxExecute(\n WorldContract,\n \"setMetadata(bytes16,bytes16,string,string[])\",\n [toBytes16(namespace), toBytes16(name), tableName, Object.keys(schema)],\n confirmations\n );\n\n console.log(chalk.green(`Registered table ${tableName} at ${name}`));\n }),\n ];\n\n // Register systems (using forEach instead of for..of to avoid blocking on async calls)\n promises = [\n ...promises,\n ...Object.entries(resolvedConfig.systems).map(\n async ([systemName, { name, openAccess, registerFunctionSelectors }]) => {\n // Register system at route\n console.log(chalk.blue(`Registering system ${systemName} at ${namespace}/${name}`));\n await fastTxExecute(\n WorldContract,\n \"registerSystem\",\n [toBytes16(namespace), toBytes16(name), await contractPromises[systemName], openAccess],\n confirmations\n );\n console.log(chalk.green(`Registered system ${systemName} at ${namespace}/${name}`));\n\n // Register function selectors for the system\n if (registerFunctionSelectors) {\n const functionSignatures: FunctionSignature[] = await loadFunctionSignatures(systemName);\n const isRoot = namespace === \"\";\n // Using Promise.all to avoid blocking on async calls\n await Promise.all(\n functionSignatures.map(async ({ functionName, functionArgs }) => {\n const functionSignature = isRoot\n ? functionName + functionArgs\n : `${namespace}_${name}_${functionName}${functionArgs}`;\n\n console.log(chalk.blue(`Registering function \"${functionSignature}\"`));\n if (isRoot) {\n const worldFunctionSelector = toFunctionSelector(\n functionSignature === \"\"\n ? { functionName: systemName, functionArgs } // Register the system's fallback function as `<systemName>(<args>)`\n : { functionName, functionArgs }\n );\n const systemFunctionSelector = toFunctionSelector({ functionName, functionArgs });\n await fastTxExecute(\n WorldContract,\n \"registerRootFunctionSelector\",\n [toBytes16(namespace), toBytes16(name), worldFunctionSelector, systemFunctionSelector],\n confirmations\n );\n } else {\n await fastTxExecute(\n WorldContract,\n \"registerFunctionSelector\",\n [toBytes16(namespace), toBytes16(name), functionName, functionArgs],\n confirmations\n );\n }\n console.log(chalk.green(`Registered function \"${functionSignature}\"`));\n })\n );\n }\n }\n ),\n ];\n\n // Wait for resources to be registered before granting access to them\n await Promise.all(promises); // ----------------------------------------------------------------------------------------------\n promises = [];\n\n // Grant access to systems\n for (const [systemName, { name, accessListAddresses, accessListSystems }] of Object.entries(resolvedConfig.systems)) {\n const resourceSelector = `${namespace}/${name}`;\n\n // Grant access to addresses\n promises = [\n ...promises,\n ...accessListAddresses.map(async (address) => {\n console.log(chalk.blue(`Grant ${address} access to ${systemName} (${resourceSelector})`));\n await fastTxExecute(\n WorldContract,\n \"grantAccess\",\n [toBytes16(namespace), toBytes16(name), address],\n confirmations\n );\n console.log(chalk.green(`Granted ${address} access to ${systemName} (${namespace}/${name})`));\n }),\n ];\n\n // Grant access to other systems\n promises = [\n ...promises,\n ...accessListSystems.map(async (granteeSystem) => {\n console.log(chalk.blue(`Grant ${granteeSystem} access to ${systemName} (${resourceSelector})`));\n await fastTxExecute(\n WorldContract,\n \"grantAccess\",\n [toBytes16(namespace), toBytes16(name), await contractPromises[granteeSystem]],\n confirmations\n );\n console.log(chalk.green(`Granted ${granteeSystem} access to ${systemName} (${resourceSelector})`));\n }),\n ];\n }\n\n // Wait for access to be granted before installing modules\n await Promise.all(promises); // ----------------------------------------------------------------------------------------------\n promises = [];\n\n // Install modules\n promises = [\n ...promises,\n ...mudConfig.modules.map(async (module) => {\n console.log(chalk.blue(`Installing${module.root ? \" root \" : \" \"}module ${module.name}`));\n // Resolve arguments\n const resolvedArgs = await Promise.all(\n module.args.map((arg) => resolveWithContext(arg, { tableIds, systemAddresses: contractPromises }))\n );\n const values = resolvedArgs.map((arg) => arg.value);\n const types = resolvedArgs.map((arg) => arg.type);\n const moduleAddress = await contractPromises[module.name];\n if (!moduleAddress) throw new Error(`Module ${module.name} not found`);\n\n // Send transaction to install module\n await fastTxExecute(\n WorldContract,\n module.root ? \"installRootModule\" : \"installModule\",\n [moduleAddress, abi.encode(types, values)],\n confirmations\n );\n\n console.log(chalk.green(`Installed${module.root ? \" root \" : \" \"}module ${module.name}`));\n }),\n ];\n\n // Await all promises before executing PostDeploy script\n await Promise.all(promises); // ----------------------------------------------------------------------------------------------\n promises = [];\n\n // Execute postDeploy forge script\n const postDeployPath = path.join(await getScriptDirectory(), postDeployScript + \".s.sol\");\n if (existsSync(postDeployPath)) {\n console.log(chalk.blue(`Executing post deploy script at ${postDeployPath}`));\n await forge(\n [\n \"script\",\n postDeployScript,\n \"--sig\",\n \"run(address)\",\n await contractPromises.World,\n \"--broadcast\",\n \"--rpc-url\",\n rpc,\n \"-vvv\",\n ],\n {\n profile,\n }\n );\n } else {\n console.log(`No script at ${postDeployPath}, skipping post deploy hook`);\n }\n\n console.log(chalk.green(\"Deployment completed in\", (Date.now() - startTime) / 1000, \"seconds\"));\n\n return { worldAddress: await contractPromises.World, blockNumber };\n\n // ------------------- INTERNAL FUNCTIONS -------------------\n // (Inlined to avoid having to pass around nonce, signer and forgeOutDir)\n\n /**\n * Deploy a contract and return the address\n * @param contractName Name of the contract to deploy (must exist in the file system)\n * @param disableTxWait Disable waiting for contract deployment\n * @returns Address of the deployed contract\n */\n async function deployContractByName(contractName: string, disableTxWait: boolean): Promise<string> {\n console.log(chalk.blue(\"Deploying\", contractName));\n\n const { abi, bytecode } = await getContractData(contractName);\n return deployContract(abi, bytecode, disableTxWait, contractName);\n }\n\n /**\n * Deploy a contract and return the address\n * @param abi The contract interface\n * @param bytecode The contract bytecode\n * @param disableTxWait Disable waiting for contract deployment\n * @param contractName The contract name (optional, used for logs)\n * @param retryCount\n * @returns Address of the deployed contract\n */\n async function deployContract(\n abi: ContractInterface,\n bytecode: string | { object: string },\n disableTxWait: boolean,\n contractName?: string,\n retryCount = 0\n ): Promise<string> {\n try {\n const factory = new ethers.ContractFactory(abi, bytecode, signer);\n console.log(chalk.gray(`executing deployment of ${contractName} with nonce ${nonce}`));\n const deployPromise = factory\n .deploy({\n nonce: nonce++,\n maxPriorityFeePerGas,\n maxFeePerGas,\n })\n .then((c) => (disableTxWait ? c : c.deployed()));\n\n promises.push(deployPromise);\n const { address } = await deployPromise;\n\n console.log(chalk.green(\"Deployed\", contractName, \"to\", address));\n return address;\n } catch (error: any) {\n if (debug) console.error(error);\n if (retryCount === 0 && error?.message.includes(\"transaction already imported\")) {\n // If the deployment failed because the transaction was already imported,\n // retry with a higher priority fee\n setInternalFeePerGas(priorityFeeMultiplier * 1.1);\n return deployContract(abi, bytecode, disableTxWait, contractName, retryCount++);\n } else if (error?.message.includes(\"invalid bytecode\")) {\n throw new MUDError(\n `Error deploying ${contractName}: invalid bytecode. Note that linking of public libraries is not supported yet, make sure none of your libraries use \"external\" functions.`\n );\n } else if (error?.message.includes(\"CreateContractLimit\")) {\n throw new MUDError(`Error deploying ${contractName}: CreateContractLimit exceeded.`);\n } else throw error;\n }\n }\n\n /**\n * Deploy a contract and return the address\n * @param contractName Name of the contract to deploy (must exist in the file system)\n * @returns Address of the deployed contract\n *\n * NOTE: Forge deploy seems to be slightly slower than ethers\n * (probably due to the extra overhead spawning a child process to run forge),\n * so we mostly use ethersDeployContract here.\n * However, for contracts not in the user directory (eg. the vanilla World contract),\n * using forge is more convenient because it automatically finds the contract in the @latticexyz/world package.\n */\n // async function forgeDeployContract(contractName: string): Promise<string> {\n // console.log(chalk.blue(\"Deploying\", contractName));\n\n // const { deployedTo } = JSON.parse(\n // await forge(\n // [\"create\", contractName, \"--rpc-url\", rpc, \"--private-key\", privateKey, \"--json\", \"--nonce\", String(nonce++)],\n // { profile, silent: true }\n // )\n // );\n // return deployedTo;\n // }\n\n async function loadFunctionSignatures(contractName: string): Promise<FunctionSignature[]> {\n const { abi } = await getContractData(contractName);\n\n return abi\n .filter((item) => [\"fallback\", \"function\"].includes(item.type))\n .map((item) => {\n if (item.type === \"fallback\") return { functionName: \"\", functionArgs: \"\" };\n\n return {\n functionName: item.name,\n functionArgs: parseComponents(item.inputs),\n };\n });\n }\n\n /**\n * Recursively turn (nested) structs in signatures into tuples\n */\n function parseComponents(params: ParamType[]): string {\n const components = params.map((param) => (param.type === \"tuple\" ? parseComponents(param.components) : param.type));\n return `(${components})`;\n }\n\n /**\n * Only await gas estimation (for speed), only execute if gas estimation succeeds (for safety)\n */\n async function fastTxExecute<C extends { estimateGas: any; [key: string]: any }, F extends keyof C>(\n contract: C,\n func: F,\n args: Parameters<C[F]>,\n confirmations = 1,\n retryCount = 0\n ): Promise<Awaited<ReturnType<Awaited<ReturnType<C[F]>>[\"wait\"]>>> {\n const functionName = `${func as string}(${args.map((arg) => `'${arg}'`).join(\",\")})`;\n try {\n const gasLimit = await contract.estimateGas[func].apply(null, args);\n console.log(chalk.gray(`executing transaction: ${functionName} with nonce ${nonce}`));\n const txPromise = contract[func]\n .apply(null, [...args, { gasLimit, nonce: nonce++, maxPriorityFeePerGas, maxFeePerGas }])\n .then((tx: any) => (confirmations === 0 ? tx : tx.wait(confirmations)));\n promises.push(txPromise);\n return txPromise;\n } catch (error: any) {\n if (debug) console.error(error);\n if (retryCount === 0 && error?.message.includes(\"transaction already imported\")) {\n // If the deployment failed because the transaction was already imported,\n // retry with a higher priority fee\n setInternalFeePerGas(priorityFeeMultiplier * 1.1);\n return fastTxExecute(contract, func, args, confirmations, retryCount++);\n } else throw new MUDError(`Gas estimation error for ${functionName}: ${error?.reason}`);\n }\n }\n\n /**\n * Load the contract's abi and bytecode from the file system\n * @param contractName: Name of the contract to load\n */\n async function getContractData(contractName: string): Promise<{ bytecode: string; abi: Fragment[] }> {\n let data: any;\n const contractDataPath = path.join(forgeOutDirectory, contractName + \".sol\", contractName + \".json\");\n try {\n data = JSON.parse(readFileSync(contractDataPath, \"utf8\"));\n } catch (error: any) {\n throw new MUDError(`Error reading file at ${contractDataPath}`);\n }\n\n const bytecode = data?.bytecode?.object;\n if (!bytecode) throw new MUDError(`No bytecode found in ${contractDataPath}`);\n\n const abi = data?.abi;\n if (!abi) throw new MUDError(`No ABI found in ${contractDataPath}`);\n\n return { abi, bytecode };\n }\n\n /**\n * Set the maxFeePerGas and maxPriorityFeePerGas based on the current base fee and the given multiplier.\n * The multiplier is used to allow replacing pending transactions.\n * @param multiplier Multiplier to apply to the base fee\n */\n async function setInternalFeePerGas(multiplier: number) {\n // Compute maxFeePerGas and maxPriorityFeePerGas like ethers, but allow for a multiplier to allow replacing pending transactions\n const feeData = await provider.getFeeData();\n if (!feeData.lastBaseFeePerGas) throw new MUDError(\"Can not fetch lastBaseFeePerGas from RPC\");\n\n // Set the priority fee to 0 for development chains with no base fee, to allow transactions from unfunded wallets\n maxPriorityFeePerGas = feeData.lastBaseFeePerGas.eq(0) ? 0 : Math.floor(1_500_000_000 * multiplier);\n maxFeePerGas = feeData.lastBaseFeePerGas.mul(2).add(maxPriorityFeePerGas);\n }\n}\n\n// TODO: use stringToBytes16 from utils as soon as utils are usable inside cli\n// (see https://github.com/latticexyz/mud/issues/499)\nfunction toBytes16(input: string) {\n if (input.length > 16) throw new Error(\"String does not fit into 16 bytes\");\n\n const result = new Uint8Array(16);\n // Set ascii bytes\n for (let i = 0; i < input.length; i++) {\n result[i] = input.charCodeAt(i);\n }\n // Set the remaining bytes to 0\n for (let i = input.length; i < 16; i++) {\n result[i] = 0;\n }\n return result;\n}\n\n// TODO: use TableId from utils as soon as utils are usable inside cli\n// (see https://github.com/latticexyz/mud/issues/499)\nfunction toResourceSelector(namespace: string, file: string): Uint8Array {\n const namespaceBytes = toBytes16(namespace);\n const fileBytes = toBytes16(file);\n const result = new Uint8Array(32);\n result.set(namespaceBytes);\n result.set(fileBytes, 16);\n return result;\n}\n\ninterface FunctionSignature {\n functionName: string;\n functionArgs: string;\n}\n\n// TODO: move this to utils as soon as utils are usable inside cli\n// (see https://github.com/latticexyz/mud/issues/499)\nfunction toFunctionSelector({ functionName, functionArgs }: FunctionSignature): string {\n const functionSignature = functionName + functionArgs;\n if (functionSignature === \"\") return \"0x\";\n return sigHash(functionSignature);\n}\n\n// TODO: move this to utils as soon as utils are usable inside cli\n// (see https://github.com/latticexyz/mud/issues/499)\nfunction sigHash(signature: string) {\n return ethers.utils.hexDataSlice(ethers.utils.keccak256(ethers.utils.toUtf8Bytes(signature)), 0, 4);\n}\n","import chalk from \"chalk\";\nimport { ZodError } from \"zod\";\nimport { fromZodError, ValidationError } from \"zod-validation-error\";\nimport { NotInsideProjectError } from \"@latticexyz/config\";\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","import { ethers } from \"ethers\";\n\n// TODO: Use viem's getChainId\nexport async function getChainId(rpc: string) {\n const { result: chainId } = await ethers.utils.fetchJson(\n rpc,\n '{ \"id\": 42, \"jsonrpc\": \"2.0\", \"method\": \"eth_chainId\", \"params\": [ ] }'\n );\n return Number(chainId);\n}\n","import type { CommandModule } from \"yargs\";\nimport { loadConfig } from \"@latticexyz/config\";\nimport { StoreConfig } from \"@latticexyz/store\";\nimport { WorldConfig, worldgen } from \"@latticexyz/world\";\nimport { getSrcDirectory } from \"@latticexyz/common/foundry\";\nimport glob from \"glob\";\nimport path, { basename } from \"path\";\nimport { rmSync } from \"fs\";\n\ntype Options = {\n configPath?: string;\n clean?: boolean;\n};\n\nconst commandModule: CommandModule<Options, Options> = {\n command: \"worldgen\",\n\n describe: \"Autogenerate interfaces for Systems and World based on existing contracts and the config file\",\n\n builder(yargs) {\n return yargs.options({\n configPath: { type: \"string\", desc: \"Path to the config file\" },\n clean: { type: \"boolean\", desc: \"Clear the worldgen directory before generating new interfaces\" },\n });\n },\n\n async handler(args) {\n const { configPath, clean } = args;\n const srcDir = await getSrcDirectory();\n\n // Get a list of all contract names\n const existingContracts = glob.sync(`${srcDir}/**/*.sol`).map((path) => ({\n path,\n basename: basename(path, \".sol\"),\n }));\n\n // Load the config\n const mudConfig = (await loadConfig(configPath)) as StoreConfig & WorldConfig;\n\n const outputBaseDirectory = path.join(srcDir, mudConfig.codegenDirectory);\n\n // clear the worldgen directory\n if (clean) rmSync(path.join(outputBaseDirectory, mudConfig.worldgenDirectory), { recursive: true, force: true });\n\n // generate new interfaces\n await worldgen(mudConfig, existingContracts, outputBaseDirectory);\n\n process.exit(0);\n },\n};\n\nexport default commandModule;\n","import chalk from \"chalk\";\nimport { existsSync, readFileSync, rmSync, writeFileSync } from \"fs\";\nimport path from \"path\";\nimport type { CommandModule } from \"yargs\";\nimport { MUDError } from \"@latticexyz/common/errors\";\nimport { logError } from \"../utils/errors\";\nimport localPackageJson from \"../../package.json\" assert { type: \"json\" };\n\ntype Options = {\n backup?: boolean;\n force?: boolean;\n restore?: boolean;\n mudVersion?: string;\n link?: string;\n};\n\nconst BACKUP_FILE = \".mudbackup\";\nconst MUD_PREFIX = \"@latticexyz\";\n\nconst commandModule: CommandModule<Options, Options> = {\n command: \"set-version\",\n\n describe: \"Install a custom MUD version and optionally backup the previously installed version\",\n\n builder(yargs) {\n return yargs.options({\n backup: { type: \"boolean\", description: `Back up the current MUD versions to \"${BACKUP_FILE}\"` },\n force: {\n type: \"boolean\",\n description: `Backup fails if a \"${BACKUP_FILE}\" file is found, unless --force is provided`,\n },\n restore: { type: \"boolean\", description: `Restore the previous MUD versions from \"${BACKUP_FILE}\"` },\n mudVersion: { alias: \"v\", type: \"string\", description: \"The MUD version to install\" },\n link: { alias: \"l\", type: \"string\", description: \"Relative path to the local MUD root directory to link\" },\n });\n },\n\n async handler(options) {\n try {\n if (!options.mudVersion && !options.link && !options.restore) {\n throw new MUDError(\"`--mudVersion` or `--link` is required unless --restore is provided.\");\n }\n\n // `link` and `mudVersion` are mutually exclusive\n if (options.link && options.mudVersion) {\n throw new MUDError(\"Options `--link` and `--mudVersion` are mutually exclusive\");\n }\n\n // Resolve the `canary` version number if needed\n options.mudVersion =\n options.mudVersion === \"canary\" ? await getCanaryVersion(localPackageJson.name) : options.mudVersion;\n\n // Read the current package.json\n const rootPath = \"./package.json\";\n const { workspaces } = updatePackageJson(rootPath, options);\n\n // Load the package.json of each workspace\n if (workspaces) {\n for (const workspace of workspaces) {\n const filePath = path.join(workspace, \"/package.json\");\n updatePackageJson(filePath, options);\n }\n }\n } catch (e) {\n logError(e);\n } finally {\n process.exit(0);\n }\n },\n};\n\nfunction updatePackageJson(filePath: string, options: Options): { workspaces?: string[] } {\n const { restore, force, link } = options;\n let { backup, mudVersion } = options;\n\n const backupFilePath = path.join(path.dirname(filePath), BACKUP_FILE);\n const backupFileExists = existsSync(backupFilePath);\n\n // Create a backup file for previous MUD versions by default if linking to local MUD\n if (link && !backupFileExists) backup = true;\n\n // If `backup` is true and force not set, check if a backup file already exists and throw an error if it does\n if (backup && !force && backupFileExists) {\n throw new MUDError(\n `A backup file already exists at ${backupFilePath}.\\nUse --force to overwrite it or --restore to restore it.`\n );\n }\n\n const packageJson = readPackageJson(filePath);\n\n // Load .mudbackup if `restore` is true\n const backupJson = restore ? readPackageJson(backupFilePath) : undefined;\n\n // Find all MUD dependencies\n const mudDependencies: Record<string, string> = {};\n for (const key in packageJson.dependencies) {\n if (key.startsWith(MUD_PREFIX)) {\n mudDependencies[key] = packageJson.dependencies[key];\n }\n }\n\n // Find all MUD devDependencies\n const mudDevDependencies: Record<string, string> = {};\n for (const key in packageJson.devDependencies) {\n if (key.startsWith(MUD_PREFIX)) {\n mudDevDependencies[key] = packageJson.devDependencies[key];\n }\n }\n\n // Back up the current dependencies if `backup` is true\n if (backup) {\n writeFileSync(\n backupFilePath,\n JSON.stringify({ dependencies: mudDependencies, devDependencies: mudDevDependencies }, null, 2)\n );\n console.log(chalk.green(`Backed up MUD dependencies from ${filePath} to ${backupFilePath}`));\n }\n\n // Update the dependencies\n for (const key in packageJson.dependencies) {\n if (key.startsWith(MUD_PREFIX)) {\n packageJson.dependencies[key] = resolveMudVersion(key, \"dependencies\");\n }\n }\n\n // Update the devDependencies\n for (const key in packageJson.devDependencies) {\n if (key.startsWith(MUD_PREFIX)) {\n packageJson.devDependencies[key] = resolveMudVersion(key, \"devDependencies\");\n }\n }\n\n // Write the updated package.json\n writeFileSync(filePath, JSON.stringify(packageJson, null, 2) + \"\\n\");\n\n console.log(`Updating ${filePath}`);\n logComparison(mudDependencies, packageJson.dependencies);\n logComparison(mudDevDependencies, packageJson.devDependencies);\n\n // Remove the backup file if `restore` is true and `backup` is false\n // because the old backup file is no longer needed\n if (restore && !backup) {\n rmSync(backupFilePath);\n console.log(chalk.green(`Cleaned up ${backupFilePath}`));\n }\n\n return packageJson;\n\n function resolveMudVersion(key: string, type: \"dependencies\" | \"devDependencies\") {\n if (restore && backupJson) return backupJson[type][key];\n if (link) mudVersion = resolveLinkPath(filePath, link, key);\n if (!mudVersion) return packageJson[type][key];\n return mudVersion;\n }\n}\n\nfunction readPackageJson(path: string): {\n workspaces?: string[];\n dependencies: Record<string, string>;\n devDependencies: Record<string, string>;\n} {\n try {\n const jsonString = readFileSync(path, \"utf8\");\n return JSON.parse(jsonString);\n } catch {\n throw new MUDError(\"Could not read JSON at \" + path);\n }\n}\n\nasync function getCanaryVersion(pkg: string) {\n try {\n console.log(chalk.blue(\"fetching MUD canary version...\"));\n const result = await (await fetch(`https://registry.npmjs.org/${pkg}`)).json();\n const canary = result[\"dist-tags\"].canary;\n console.log(chalk.green(\"MUD canary version:\", canary));\n return canary;\n } catch (e) {\n throw new MUDError(`Could not fetch canary version of ${pkg}`);\n }\n}\n\nfunction logComparison(prev: Record<string, string>, curr: Record<string, string>) {\n for (const key in prev) {\n if (prev[key] !== curr[key]) {\n console.log(`${key}: ${chalk.red(prev[key])} -> ${chalk.green(curr[key])}`);\n }\n }\n}\n\n/**\n * Returns path of the package to link, given a path to a local MUD clone and a package\n */\nfunction resolveLinkPath(packageJsonPath: string, mudLinkPath: string, pkg: string) {\n const pkgName = pkg.replace(MUD_PREFIX, \"\");\n const packageJsonToRootPath = path.relative(path.dirname(packageJsonPath), process.cwd());\n const linkPath = path.join(packageJsonToRootPath, mudLinkPath, \"packages\", pkgName);\n return \"link:\" + linkPath;\n}\n\nexport default commandModule;\n","{\n \"name\": \"@latticexyz/cli\",\n \"version\": \"1.42.0\",\n \"description\": \"Command line interface for mud\",\n \"repository\": {\n \"type\": \"git\",\n \"url\": \"https://github.com/latticexyz/mud.git\",\n \"directory\": \"packages/cli\"\n },\n \"license\": \"MIT\",\n \"type\": \"module\",\n \"exports\": {\n \".\": \"./dist/index.js\"\n },\n \"types\": \"src/index.ts\",\n \"bin\": {\n \"mud\": \"./dist/mud.js\"\n },\n \"scripts\": {\n \"build\": \"pnpm run build:js\",\n \"build:js\": \"tsup && chmod +x ./dist/mud.js\",\n \"clean\": \"pnpm run clean:js\",\n \"clean:js\": \"rimraf dist\",\n \"dev\": \"tsup --watch\",\n \"generate-test-tables\": \"tsx ./scripts/generate-test-tables.ts\",\n \"lint\": \"eslint . --ext .ts\",\n \"test\": \"tsc --noEmit && pnpm run generate-test-tables && forge test\"\n },\n \"dependencies\": {\n \"@ethersproject/abi\": \"^5.7.0\",\n \"@ethersproject/providers\": \"^5.7.2\",\n \"@improbable-eng/grpc-web\": \"^0.15.0\",\n \"@improbable-eng/grpc-web-node-http-transport\": \"^0.15.0\",\n \"@latticexyz/common\": \"workspace:*\",\n \"@latticexyz/config\": \"workspace:*\",\n \"@latticexyz/schema-type\": \"workspace:*\",\n \"@latticexyz/services\": \"workspace:*\",\n \"@latticexyz/solecs\": \"workspace:*\",\n \"@latticexyz/std-contracts\": \"workspace:*\",\n \"@latticexyz/store\": \"workspace:*\",\n \"@latticexyz/world\": \"workspace:*\",\n \"@typechain/ethers-v5\": \"^10.2.0\",\n \"chalk\": \"^5.0.1\",\n \"chokidar\": \"^3.5.3\",\n \"dotenv\": \"^16.0.3\",\n \"ejs\": \"^3.1.8\",\n \"ethers\": \"^5.7.2\",\n \"execa\": \"^7.0.0\",\n \"glob\": \"^8.0.3\",\n \"nice-grpc-web\": \"^2.0.1\",\n \"openurl\": \"^1.1.1\",\n \"path\": \"^0.12.7\",\n \"table\": \"^6.8.1\",\n \"typechain\": \"^8.1.1\",\n \"typescript\": \"^4.9.5\",\n \"yargs\": \"^17.7.1\",\n \"zod\": \"^3.21.4\",\n \"zod-validation-error\": \"^1.3.0\"\n },\n \"devDependencies\": {\n \"@types/ejs\": \"^3.1.1\",\n \"@types/glob\": \"^7.2.0\",\n \"@types/node\": \"^18.15.11\",\n \"@types/openurl\": \"^1.0.0\",\n \"@types/yargs\": \"^17.0.10\",\n \"ds-test\": \"https://github.com/dapphub/ds-test.git#c9ce3f25bde29fc5eb9901842bf02850dfd2d084\",\n \"forge-std\": \"https://github.com/foundry-rs/forge-std.git#b4f121555729b3afb3c5ffccb62ff4b6e2818fd3\",\n \"tsup\": \"^6.7.0\",\n \"tsx\": \"^3.12.6\",\n \"vitest\": \"0.30.1\"\n },\n \"gitHead\": \"914a1e0ae4a573d685841ca2ea921435057deb8f\"\n}\n","import type { CommandModule } from \"yargs\";\nimport { deployHandler, DeployOptions, yDeployOptions } from \"./deploy\";\nimport { anvil, forge, getRpcUrl } from \"@latticexyz/common/foundry\";\nimport chalk from \"chalk\";\nimport { rmSync, writeFileSync } from \"fs\";\n\ntype Options = DeployOptions & { port?: number; worldAddress?: string; forgeOptions?: string };\n\nconst WORLD_ADDRESS_FILE = \".mudtest\";\n\nconst commandModule: CommandModule<Options, Options> = {\n command: \"test\",\n\n describe: \"Run tests in MUD contracts\",\n\n builder(yargs) {\n return yargs.options({\n ...yDeployOptions,\n port: { type: \"number\", description: \"Port to run internal node for fork testing on\", default: 4242 },\n worldAddress: {\n type: \"string\",\n description:\n \"Address of an existing world contract. If provided, deployment is skipped and the RPC provided in the foundry.toml is used for fork testing.\",\n },\n forgeOptions: { type: \"string\", description: \"Options to pass to forge test\" },\n });\n },\n\n async handler(args) {\n // Start an internal anvil process if no world address is provided\n if (!args.worldAddress) {\n const anvilArgs = [\"--block-base-fee-per-gas\", \"0\", \"--port\", String(args.port)];\n anvil(anvilArgs);\n }\n\n const forkRpc = args.worldAddress ? await getRpcUrl(args.profile) : `http://127.0.0.1:${args.port}`;\n\n const worldAddress =\n args.worldAddress ??\n (\n await deployHandler({\n ...args,\n saveDeployment: false,\n rpc: forkRpc,\n })\n ).worldAddress;\n\n console.log(chalk.blue(\"World address\", worldAddress));\n\n // Create a temporary file to pass the world address to the tests\n writeFileSync(WORLD_ADDRESS_FILE, worldAddress);\n\n const userOptions = args.forgeOptions?.replaceAll(\"\\\\\", \"\").split(\" \") ?? [];\n try {\n const testResult = await forge([\"test\", \"--fork-url\", forkRpc, ...userOptions], {\n profile: args.profile,\n });\n console.log(testResult);\n } catch (e) {\n console.error(e);\n }\n\n rmSync(WORLD_ADDRESS_FILE);\n\n process.exit(0);\n },\n};\n\nexport default commandModule;\n","import { CommandModule } from \"yargs\";\n\nimport devnode from \"./devnode\";\nimport faucet from \"./faucet\";\nimport gasReport from \"./gas-report\";\nimport hello from \"./hello\";\nimport tablegen from \"./tablegen\";\nimport tsgen from \"./tsgen\";\nimport deploy from \"./deploy\";\nimport worldgen from \"./worldgen\";\nimport setVersion from \"./set-version\";\nimport test from \"./test\";\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any -- Each command has different options\nexport const commands: CommandModule<any, any>[] = [\n deploy,\n devnode,\n faucet,\n gasReport,\n hello,\n tablegen,\n tsgen,\n worldgen,\n setVersion,\n test,\n];\n"],"mappings":";yCAEA,OAAOA,OAAW,QAClB,OAAS,WAAAC,OAAe,gBCHxB,OAAS,UAAAC,OAAc,KACvB,OAAS,WAAAC,OAAe,KACxB,OAAOC,OAAU,OAEjB,OAAS,SAAAC,OAAa,QAMtB,IAAMC,GAAiD,CACrD,QAAS,UAET,SAAU,8CAEV,QAAQC,EAAO,CACb,OAAOA,EAAM,QAAQ,CACnB,UAAW,CAAE,KAAM,SAAU,QAAS,EAAG,KAAM,2CAA4C,CAC7F,CAAC,CACH,EAEA,MAAM,QAAQ,CAAE,UAAAC,CAAU,EAAG,CAC3B,QAAQ,IAAI,0BAA0B,EACtC,IAAMC,EAAcN,GAAQ,EAC5BD,GAAOE,GAAK,KAAKK,EAAa,WAAY,QAAS,KAAK,EAAG,CAAE,UAAW,GAAM,MAAO,EAAK,CAAC,EAE3F,IAAMC,EAAY,CAAC,KAAM,OAAOF,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oBAAoBA,EAAK,OAEvFG,EACJH,EAAK,eAEH,MAAMI,GAAc,CAClB,GAAGJ,EACH,eAAgB,GAChB,IAAKE,CACP,CAAC,GACD,aAEJ,QAAQ,IAAIT,GAAM,KAAK,gBAAiBU,CAAY,CAAC,EAGrDR,GAAcC,GAAoBO,CAAY,EAE9C,IAAME,EAAcL,EAAK,cAAc,WAAW,KAAM,EAAE,EAAE,MAAM,GAAG,GAAK,CAAC,EAC3E,GAAI,CACF,IAAMM,EAAa,MAAMf,GAAM,CAAC,OAAQ,aAAcW,EAAS,GAAGG,CAAW,EAAG,CAC9E,QAASL,EAAK,OAChB,CAAC,EACD,QAAQ,IAAIM,CAAU,CACxB,OAASC,EAAP,CACA,QAAQ,MAAMA,CAAC,CACjB,CAEAb,GAAOE,EAAkB,EAEzB,QAAQ,KAAK,CAAC,CAChB,CACF,EAEOY,GAAQX,GCtDR,IAAMY,GAAsC,CACjDC,GACAC,GACAC,GACAC,GACAC,GACAC,GACAC,GACAC,GACAC,GACAC,EACF,EfjBA,UAAYC,OAAY,SACjB,UAAO,EAEdC,GAAMC,GAAQ,QAAQ,IAAI,CAAC,EAExB,WAAW,KAAK,EAGhB,QAAQC,EAAe,EAEvB,OAAO,EAEP,KAAK,CAACC,EAAKC,IAAQ,CAClB,QAAQ,IAAI,EAAE,EACdC,EAASD,CAAG,EACZ,QAAQ,IAAI,EAAE,EAEd,QAAQ,KAAK,CAAC,CAChB,CAAC,EAEA,MAAM,CAAE,EAAG,MAAO,CAAC,EAAE","names":["yargs","hideBin","rmSync","homedir","path","execa","commandModule","yargs","blocktime","userHomeDir","anvilArgs","child","devnode_default","FaucetServiceDefinition","createChannel","createClient","chalk","NodeHttpTransport","createFaucetService","url","commandModule","yargs","dripDev","faucetUrl","address","faucet","faucet_default","readFileSync","writeFileSync","rmSync","execa","chalk","table","getBorderCharacters","tempFileSuffix","commandModule","yargs","files","save","compare","validFiles","file","tempFiles","createGasReport","gasReport","runGasReport","compareGasReport","entry","prevEntry","e","printGasReport","saveGasReport","gas_report_default","filename","fileContents","newFile","functionRegex","functionMatch","functionSignature","regex","match","name","functionCall","tempFileName","logs","error","gasReportRegex","gasReportMatch","source","gasUsed","b","headers","values","diff","diffEntry","compareColumns","gasUsedEntry","rows","path","commandModule","yargs","name","greeting","hello_default","path","loadConfig","tablegen","getSrcDirectory","commandModule","yargs","configPath","config","srcDir","tablegen_default","loadConfig","commandModule","yargs","args","configPath","out","config","loadConfig","tsgen","tsgen_default","chalk","glob","path","basename","MUDError","loadConfig","existsSync","readFileSync","path","chalk","ethers","abi","getOutDirectory","getScriptDirectory","cast","forge","resolveWithContext","MUDError","encodeSchema","resolveAbiOrUserType","resolveWorldConfig","WorldData","IBaseWorldData","CoreModuleData","KeysWithValueModuleData","KeysInTableModuleData","UniqueEntityModuleData","deploy","mudConfig","existingContracts","deployConfig","resolvedConfig","startTime","worldContractName","namespace","postDeployScript","profile","rpc","privateKey","priorityFeeMultiplier","debug","worldAddress","disableTxWait","forgeOutDirectory","provider","signer","nonce","maxPriorityFeePerGas","maxFeePerGas","setInternalFeePerGas","promises","blockNumber","worldPromise","deployContractByName","deployContract","systemPromises","acc","systemName","defaultModules","modulePromises","module","contractPromises","WorldContract","confirmations","fastTxExecute","toBytes16","tableIds","tableName","name","schema","primaryKeys","toResourceSelector","schemaTypes","abiOrUserType","schemaType","keyTypes","openAccess","registerFunctionSelectors","functionSignatures","loadFunctionSignatures","isRoot","functionName","functionArgs","functionSignature","worldFunctionSelector","toFunctionSelector","systemFunctionSelector","accessListAddresses","accessListSystems","resourceSelector","address","granteeSystem","resolvedArgs","arg","values","types","moduleAddress","postDeployPath","contractName","bytecode","getContractData","retryCount","factory","deployPromise","c","error","item","parseComponents","params","param","contract","func","args","gasLimit","txPromise","tx","data","contractDataPath","multiplier","feeData","input","result","i","file","namespaceBytes","fileBytes","sigHash","signature","chalk","ZodError","fromZodError","ValidationError","NotInsideProjectError","MUDError","logError","error","validationError","forge","getRpcUrl","getSrcDirectory","existsSync","mkdirSync","readFileSync","writeFileSync","ethers","getChainId","rpc","chainId","yDeployOptions","deployHandler","args","configPath","printConfig","profile","clean","rpc","getRpcUrl","chalk","forge","srcDir","getSrcDirectory","existingContracts","glob","path","basename","mudConfig","loadConfig","privateKey","MUDError","deploymentInfo","deploy","chainId","getChainId","outputDir","mkdirSync","writeFileSync","localChains","deploys","existsSync","readFileSync","error","logError","commandModule","yargs","deploy_default","loadConfig","worldgen","getSrcDirectory","glob","path","basename","rmSync","commandModule","yargs","args","configPath","clean","srcDir","existingContracts","mudConfig","outputBaseDirectory","worldgen_default","chalk","existsSync","readFileSync","rmSync","writeFileSync","path","MUDError","package_default","BACKUP_FILE","MUD_PREFIX","commandModule","yargs","options","MUDError","getCanaryVersion","package_default","rootPath","workspaces","updatePackageJson","workspace","filePath","path","e","logError","restore","force","link","backup","mudVersion","backupFilePath","backupFileExists","existsSync","packageJson","readPackageJson","backupJson","mudDependencies","key","mudDevDependencies","writeFileSync","chalk","resolveMudVersion","logComparison","rmSync","type","resolveLinkPath","jsonString","readFileSync","pkg","canary","prev","curr","packageJsonPath","mudLinkPath","pkgName","packageJsonToRootPath","set_version_default","anvil","forge","getRpcUrl","chalk","rmSync","writeFileSync","WORLD_ADDRESS_FILE","commandModule","yargs","yDeployOptions","args","anvilArgs","forkRpc","worldAddress","deployHandler","userOptions","testResult","e","test_default","commands","deploy_default","devnode_default","faucet_default","gas_report_default","hello_default","tablegen_default","tsgen_default","worldgen_default","set_version_default","test_default","dotenv","yargs","hideBin","commands","msg","err","logError"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@latticexyz/cli",
|
|
3
|
-
"version": "2.0.0-alpha.1.
|
|
3
|
+
"version": "2.0.0-alpha.1.91+1daed5a8",
|
|
4
4
|
"description": "Command line interface for mud",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -14,12 +14,11 @@
|
|
|
14
14
|
},
|
|
15
15
|
"types": "src/index.ts",
|
|
16
16
|
"bin": {
|
|
17
|
-
"mud": "./dist/mud.js"
|
|
18
|
-
"mud2": "./dist/mud2.js"
|
|
17
|
+
"mud": "./dist/mud.js"
|
|
19
18
|
},
|
|
20
19
|
"scripts": {
|
|
21
20
|
"build": "pnpm run build:js",
|
|
22
|
-
"build:js": "tsup && chmod +x ./dist/mud.js
|
|
21
|
+
"build:js": "tsup && chmod +x ./dist/mud.js",
|
|
23
22
|
"clean": "pnpm run clean:js",
|
|
24
23
|
"clean:js": "rimraf dist",
|
|
25
24
|
"dev": "tsup --watch",
|
|
@@ -32,14 +31,14 @@
|
|
|
32
31
|
"@ethersproject/providers": "^5.7.2",
|
|
33
32
|
"@improbable-eng/grpc-web": "^0.15.0",
|
|
34
33
|
"@improbable-eng/grpc-web-node-http-transport": "^0.15.0",
|
|
35
|
-
"@latticexyz/common": "2.0.0-alpha.1.
|
|
36
|
-
"@latticexyz/config": "2.0.0-alpha.1.
|
|
37
|
-
"@latticexyz/schema-type": "2.0.0-alpha.1.
|
|
38
|
-
"@latticexyz/services": "2.0.0-alpha.1.
|
|
39
|
-
"@latticexyz/solecs": "2.0.0-alpha.1.
|
|
40
|
-
"@latticexyz/std-contracts": "2.0.0-alpha.1.
|
|
41
|
-
"@latticexyz/store": "2.0.0-alpha.1.
|
|
42
|
-
"@latticexyz/world": "2.0.0-alpha.1.
|
|
34
|
+
"@latticexyz/common": "2.0.0-alpha.1.91+1daed5a8",
|
|
35
|
+
"@latticexyz/config": "2.0.0-alpha.1.91+1daed5a8",
|
|
36
|
+
"@latticexyz/schema-type": "2.0.0-alpha.1.91+1daed5a8",
|
|
37
|
+
"@latticexyz/services": "2.0.0-alpha.1.91+1daed5a8",
|
|
38
|
+
"@latticexyz/solecs": "2.0.0-alpha.1.91+1daed5a8",
|
|
39
|
+
"@latticexyz/std-contracts": "2.0.0-alpha.1.91+1daed5a8",
|
|
40
|
+
"@latticexyz/store": "2.0.0-alpha.1.91+1daed5a8",
|
|
41
|
+
"@latticexyz/world": "2.0.0-alpha.1.91+1daed5a8",
|
|
43
42
|
"@typechain/ethers-v5": "^10.2.0",
|
|
44
43
|
"chalk": "^5.0.1",
|
|
45
44
|
"chokidar": "^3.5.3",
|
|
@@ -70,5 +69,5 @@
|
|
|
70
69
|
"tsx": "^3.12.6",
|
|
71
70
|
"vitest": "0.30.1"
|
|
72
71
|
},
|
|
73
|
-
"gitHead": "
|
|
72
|
+
"gitHead": "1daed5a8e4121a14decbe8d3136e77aae8764312"
|
|
74
73
|
}
|
|
@@ -6,10 +6,10 @@ import { MUDError } from "@latticexyz/common/errors";
|
|
|
6
6
|
import { loadConfig } from "@latticexyz/config";
|
|
7
7
|
import { StoreConfig } from "@latticexyz/store";
|
|
8
8
|
import { WorldConfig } from "@latticexyz/world";
|
|
9
|
-
import { deploy } from "../utils/deploy
|
|
9
|
+
import { deploy } from "../utils/deploy";
|
|
10
10
|
import { logError } from "../utils/errors";
|
|
11
11
|
import { forge, getRpcUrl, getSrcDirectory } from "@latticexyz/common/foundry";
|
|
12
|
-
import { mkdirSync, writeFileSync } from "fs";
|
|
12
|
+
import { existsSync, mkdirSync, readFileSync, writeFileSync } from "fs";
|
|
13
13
|
import { getChainId } from "../utils/getChainId";
|
|
14
14
|
|
|
15
15
|
export type DeployOptions = {
|
|
@@ -51,7 +51,7 @@ export async function deployHandler(args: Parameters<(typeof commandModule)["han
|
|
|
51
51
|
const rpc = args.rpc ?? (await getRpcUrl(profile));
|
|
52
52
|
console.log(
|
|
53
53
|
chalk.bgBlue(
|
|
54
|
-
chalk.whiteBright(`\n Deploying MUD
|
|
54
|
+
chalk.whiteBright(`\n Deploying MUD contracts${profile ? " with profile " + profile : ""} to RPC ${rpc} \n`)
|
|
55
55
|
)
|
|
56
56
|
);
|
|
57
57
|
|
|
@@ -85,7 +85,20 @@ export async function deployHandler(args: Parameters<(typeof commandModule)["han
|
|
|
85
85
|
writeFileSync(path.join(outputDir, "latest.json"), JSON.stringify(deploymentInfo, null, 2));
|
|
86
86
|
writeFileSync(path.join(outputDir, Date.now() + ".json"), JSON.stringify(deploymentInfo, null, 2));
|
|
87
87
|
|
|
88
|
-
|
|
88
|
+
const localChains = [1337, 31337];
|
|
89
|
+
const deploys = existsSync(mudConfig.worldsFile) ? JSON.parse(readFileSync(mudConfig.worldsFile, "utf-8")) : {};
|
|
90
|
+
deploys[chainId] = {
|
|
91
|
+
address: deploymentInfo.worldAddress,
|
|
92
|
+
// 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.
|
|
93
|
+
blockNumber: localChains.includes(chainId) ? undefined : deploymentInfo.blockNumber,
|
|
94
|
+
};
|
|
95
|
+
writeFileSync(mudConfig.worldsFile, JSON.stringify(deploys, null, 2));
|
|
96
|
+
|
|
97
|
+
console.log(
|
|
98
|
+
chalk.bgGreen(
|
|
99
|
+
chalk.whiteBright(`\n Deployment result (written to ${mudConfig.worldsFile} and ${outputDir}): \n`)
|
|
100
|
+
)
|
|
101
|
+
);
|
|
89
102
|
}
|
|
90
103
|
|
|
91
104
|
console.log(deploymentInfo);
|
|
@@ -97,9 +110,9 @@ export async function deployHandler(args: Parameters<(typeof commandModule)["han
|
|
|
97
110
|
}
|
|
98
111
|
|
|
99
112
|
const commandModule: CommandModule<DeployOptions, DeployOptions> = {
|
|
100
|
-
command: "deploy
|
|
113
|
+
command: "deploy",
|
|
101
114
|
|
|
102
|
-
describe: "Deploy MUD
|
|
115
|
+
describe: "Deploy MUD contracts",
|
|
103
116
|
|
|
104
117
|
builder(yargs) {
|
|
105
118
|
return yargs.options(yDeployOptions);
|
package/src/commands/devnode.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { rmSync } from "fs";
|
|
|
2
2
|
import { homedir } from "os";
|
|
3
3
|
import path from "path";
|
|
4
4
|
import type { CommandModule } from "yargs";
|
|
5
|
-
import {
|
|
5
|
+
import { execa } from "execa";
|
|
6
6
|
|
|
7
7
|
type Options = {
|
|
8
8
|
blocktime: number;
|
|
@@ -23,7 +23,12 @@ const commandModule: CommandModule<Options, Options> = {
|
|
|
23
23
|
console.log("Clearing devnode history");
|
|
24
24
|
const userHomeDir = homedir();
|
|
25
25
|
rmSync(path.join(userHomeDir, ".foundry", "anvil", "tmp"), { recursive: true, force: true });
|
|
26
|
-
|
|
26
|
+
|
|
27
|
+
const anvilArgs = ["-b", String(blocktime), "--block-base-fee-per-gas", "0"];
|
|
28
|
+
console.log(`Running: anvil ${anvilArgs.join(" ")}`);
|
|
29
|
+
const child = execa("anvil", anvilArgs, {
|
|
30
|
+
stdio: ["inherit", "inherit", "inherit"],
|
|
31
|
+
});
|
|
27
32
|
|
|
28
33
|
process.on("SIGINT", () => {
|
|
29
34
|
console.log("\ngracefully shutting down from SIGINT (Crtl-C)");
|
package/src/commands/index.ts
CHANGED
|
@@ -6,14 +6,14 @@ import gasReport from "./gas-report";
|
|
|
6
6
|
import hello from "./hello";
|
|
7
7
|
import tablegen from "./tablegen";
|
|
8
8
|
import tsgen from "./tsgen";
|
|
9
|
-
import
|
|
9
|
+
import deploy from "./deploy";
|
|
10
10
|
import worldgen from "./worldgen";
|
|
11
11
|
import setVersion from "./set-version";
|
|
12
|
-
import
|
|
12
|
+
import test from "./test";
|
|
13
13
|
|
|
14
14
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- Each command has different options
|
|
15
15
|
export const commands: CommandModule<any, any>[] = [
|
|
16
|
-
|
|
16
|
+
deploy,
|
|
17
17
|
devnode,
|
|
18
18
|
faucet,
|
|
19
19
|
gasReport,
|
|
@@ -22,5 +22,5 @@ export const commands: CommandModule<any, any>[] = [
|
|
|
22
22
|
tsgen,
|
|
23
23
|
worldgen,
|
|
24
24
|
setVersion,
|
|
25
|
-
|
|
25
|
+
test,
|
|
26
26
|
];
|