@latticexyz/cli 2.2.15 → 2.2.16-54e5c06dd4606d2484a790cd1d531931d634d7a1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
1
  import n from"chalk";import{ZodError as e}from"zod";import{fromZodError as i,ValidationError as s}from"zod-validation-error";import{MUDError as t}from"@latticexyz/common/errors";function c(o){if(o instanceof s)console.log(n.redBright(o.message));else if(o instanceof e){let r=i(o,{prefixSeparator:`
2
2
  - `,issueSeparator:`
3
3
  - `});console.log(n.redBright(r.message))}else o instanceof t?console.log(n.red(o)):console.log(o)}export{c as a};
4
- //# sourceMappingURL=chunk-JXC4VYGI.js.map
4
+ //# sourceMappingURL=chunk-PZL6GJOK.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/utils/errors.ts"],"sourcesContent":["import chalk from \"chalk\";\nimport { ZodError } from \"zod\";\nimport { fromZodError, ValidationError } from \"zod-validation-error\";\nimport { MUDError } from \"@latticexyz/common/errors\";\n\nexport function logError(error: unknown) {\n if (error instanceof ValidationError) {\n console.log(chalk.redBright(error.message));\n } else if (error instanceof ZodError) {\n // TODO currently this error shouldn't happen, use `fromZodErrorCustom`\n // (see https://github.com/latticexyz/mud/issues/438)\n const validationError = fromZodError(error, {\n prefixSeparator: \"\\n- \",\n issueSeparator: \"\\n- \",\n });\n console.log(chalk.redBright(validationError.message));\n } else if (error instanceof MUDError) {\n console.log(chalk.red(error));\n } else {\n console.log(error);\n }\n}\n"],"mappings":"AAAA,OAAOA,MAAW,QAClB,OAAS,YAAAC,MAAgB,MACzB,OAAS,gBAAAC,EAAc,mBAAAC,MAAuB,uBAC9C,OAAS,YAAAC,MAAgB,4BAElB,SAASC,EAASC,EAAgB,CACvC,GAAIA,aAAiBH,EACnB,QAAQ,IAAIH,EAAM,UAAUM,EAAM,OAAO,CAAC,UACjCA,aAAiBL,EAAU,CAGpC,IAAMM,EAAkBL,EAAaI,EAAO,CAC1C,gBAAiB;AAAA,IACjB,eAAgB;AAAA,GAClB,CAAC,EACD,QAAQ,IAAIN,EAAM,UAAUO,EAAgB,OAAO,CAAC,OAC3CD,aAAiBF,EAC1B,QAAQ,IAAIJ,EAAM,IAAIM,CAAK,CAAC,EAE5B,QAAQ,IAAIA,CAAK,CAErB","names":["chalk","ZodError","fromZodError","ValidationError","MUDError","logError","error","validationError"]}
1
+ {"version":3,"sources":["../src/utils/errors.ts"],"sourcesContent":["import chalk from \"chalk\";\nimport { ZodError } from \"zod\";\nimport { fromZodError, ValidationError } from \"zod-validation-error\";\nimport { MUDError } from \"@latticexyz/common/errors\";\n\nexport function logError(error: unknown) {\n if (error instanceof ValidationError) {\n console.log(chalk.redBright(error.message));\n } else if (error instanceof ZodError) {\n // TODO currently this error shouldn't happen, use `fromZodErrorCustom`\n // (see https://github.com/latticexyz/mud/issues/438)\n const validationError = fromZodError(error, {\n prefixSeparator: \"\\n- \",\n issueSeparator: \"\\n- \",\n });\n console.log(chalk.redBright(validationError.message));\n } else if (error instanceof MUDError) {\n console.log(chalk.red(error));\n } else {\n console.log(error);\n }\n}\n"],"mappings":"AAAA,OAAOA,MAAW,QAClB,OAAS,YAAAC,MAAgB,MACzB,OAAS,gBAAAC,EAAc,mBAAAC,MAAuB,uBAC9C,OAAS,YAAAC,MAAgB,4BAElB,SAASC,EAASC,EAAgB,CACvC,GAAIA,aAAiBH,EACnB,QAAQ,IAAIH,EAAM,UAAUM,EAAM,OAAO,CAAC,UACjCA,aAAiBL,EAAU,CAGpC,IAAMM,EAAkBL,EAAaI,EAAO,CAC1C,gBAAiB;AAAA,IACjB,eAAgB;AAAA,GAClB,CAAC,EACD,QAAQ,IAAIN,EAAM,UAAUO,EAAgB,OAAO,CAAC,CACtD,MAAWD,aAAiBF,EAC1B,QAAQ,IAAIJ,EAAM,IAAIM,CAAK,CAAC,EAE5B,QAAQ,IAAIA,CAAK,CAErB","names":["chalk","ZodError","fromZodError","ValidationError","MUDError","logError","error","validationError"]}
@@ -1,4 +1,4 @@
1
- import{a as te}from"./chunk-JXC4VYGI.js";import{command as Ya}from"@latticexyz/gas-report/internal";import{command as Ga}from"@latticexyz/abi-ts/internal";import{loadConfig as St,resolveConfigPath as Ct}from"@latticexyz/config/node";import{tablegen as bt}from"@latticexyz/store/codegen";import{buildSystemsManifest as ht,worldgen as wt}from"@latticexyz/world/node";import{forge as xt}from"@latticexyz/common/foundry";import{execa as vt}from"execa";async function L({rootDir:e,config:o,foundryProfile:t=process.env.FOUNDRY_PROFILE}){await Promise.all([bt({rootDir:e,config:o}),wt({rootDir:e,config:o})]),await xt(["build"],{profile:t}),await ht({rootDir:e,config:o}),await vt("mud",["abi-ts"],{stdio:"inherit"})}import Dt from"node:path";var At={command:"build",describe:"Build contracts and generate MUD artifacts (table libraries, world interface, ABI)",builder(e){return e.options({configPath:{type:"string",desc:"Path to the MUD config file"},profile:{type:"string",desc:"The foundry profile to use"}})},async handler(e){let o=await Ct(e.configPath),t=await St(o);await L({rootDir:Dt.dirname(o),config:t,foundryProfile:e.profile}),process.exit(0)}},Re=At;import{rmSync as kt}from"fs";import{homedir as Tt}from"os";import Pt from"path";import{execa as Ot}from"execa";var Mt={command:"devnode",describe:"Start a local Ethereum node for development",builder(e){return e.options({blocktime:{type:"number",default:1,decs:"Interval in which new blocks are produced"}})},async handler({blocktime:e}){console.log("Clearing devnode history");let o=Tt();kt(Pt.join(o,".foundry","anvil","tmp"),{recursive:!0,force:!0});let t=["-b",String(e),"--block-base-fee-per-gas","0"];console.log(`Running: anvil ${t.join(" ")}`);let r=Ot("anvil",t,{stdio:["inherit","inherit","inherit"]});process.on("SIGINT",()=>{console.log(`
1
+ import{a as te}from"./chunk-PZL6GJOK.js";import{command as Ya}from"@latticexyz/gas-report/internal";import{command as Ga}from"@latticexyz/abi-ts/internal";import{loadConfig as St,resolveConfigPath as Ct}from"@latticexyz/config/node";import{tablegen as bt}from"@latticexyz/store/codegen";import{buildSystemsManifest as ht,worldgen as wt}from"@latticexyz/world/node";import{forge as xt}from"@latticexyz/common/foundry";import{execa as vt}from"execa";async function L({rootDir:e,config:o,foundryProfile:t=process.env.FOUNDRY_PROFILE}){await Promise.all([bt({rootDir:e,config:o}),wt({rootDir:e,config:o})]),await xt(["build"],{profile:t}),await ht({rootDir:e,config:o}),await vt("mud",["abi-ts"],{stdio:"inherit"})}import Dt from"node:path";var At={command:"build",describe:"Build contracts and generate MUD artifacts (table libraries, world interface, ABI)",builder(e){return e.options({configPath:{type:"string",desc:"Path to the MUD config file"},profile:{type:"string",desc:"The foundry profile to use"}})},async handler(e){let o=await Ct(e.configPath),t=await St(o);await L({rootDir:Dt.dirname(o),config:t,foundryProfile:e.profile}),process.exit(0)}},Re=At;import{rmSync as kt}from"fs";import{homedir as Tt}from"os";import Pt from"path";import{execa as Ot}from"execa";var Mt={command:"devnode",describe:"Start a local Ethereum node for development",builder(e){return e.options({blocktime:{type:"number",default:1,decs:"Interval in which new blocks are produced"}})},async handler({blocktime:e}){console.log("Clearing devnode history");let o=Tt();kt(Pt.join(o,".foundry","anvil","tmp"),{recursive:!0,force:!0});let t=["-b",String(e),"--block-base-fee-per-gas","0"];console.log(`Running: anvil ${t.join(" ")}`);let r=Ot("anvil",t,{stdio:["inherit","inherit","inherit"]});process.on("SIGINT",()=>{console.log(`
2
2
  gracefully shutting down from SIGINT (Crtl-C)`),r.kill(),process.exit()}),await r}},$e=Mt;var Bt={command:"hello <name>",describe:"Greet <name> with Hello",builder(e){return e.options({upper:{type:"boolean"}}).positional("name",{type:"string",demandOption:!0})},handler({name:e}){let o=`Gm, ${e}!`;console.log(o),process.exit(0)}},Fe=Bt;import{loadConfig as Ht,resolveConfigPath as It}from"@latticexyz/config/node";import{tablegen as Wt}from"@latticexyz/store/codegen";import jt from"node:path";var Rt={command:"tablegen",describe:"Autogenerate MUD Store table libraries based on the config file",builder(e){return e.options({configPath:{type:"string",desc:"Path to the MUD config file"}})},async handler(e){let o=await It(e.configPath),t=await Ht(o);await Wt({rootDir:jt.dirname(o),config:t}),process.exit(0)}},Le=Rt;import he from"node:path";import{existsSync as Jo,mkdirSync as Jn,readFileSync as qo,writeFileSync as Pe}from"node:fs";import{stringToHex as cn}from"viem";import{waitForTransactionReceipt as tr}from"viem/actions";import Ve from"@latticexyz/world/out/WorldFactory.sol/WorldFactory.json"assert{type:"json"};import Lt from"@latticexyz/world/out/WorldFactory.sol/WorldFactory.abi.json"assert{type:"json"};import{encodeDeployData as Et,size as zt}from"viem";import Ee from"@latticexyz/world/out/AccessManagementSystem.sol/AccessManagementSystem.json"assert{type:"json"};import ze from"@latticexyz/world/out/BalanceTransferSystem.sol/BalanceTransferSystem.json"assert{type:"json"};import Ne from"@latticexyz/world/out/BatchCallSystem.sol/BatchCallSystem.json"assert{type:"json"};import Ue from"@latticexyz/world/out/RegistrationSystem.sol/RegistrationSystem.json"assert{type:"json"};import _e from"@latticexyz/world/out/InitModule.sol/InitModule.json"assert{type:"json"};import $t from"@latticexyz/world/out/InitModule.sol/InitModule.abi.json"assert{type:"json"};import{encodeDeployData as Ft,size as q}from"viem";import{getContractAddress as Y}from"@latticexyz/common/internal";function E(e){let o=q(Ee.deployedBytecode.object),t=Ee.bytecode.object,r=Y({deployerAddress:e,bytecode:t}),n=q(ze.deployedBytecode.object),a=ze.bytecode.object,s=Y({deployerAddress:e,bytecode:a}),i=q(Ne.deployedBytecode.object),c=Ne.bytecode.object,d=Y({deployerAddress:e,bytecode:c}),p=q(Ue.deployedBytecode.object),y=Ue.bytecode.object,u=Y({deployerAddress:e,bytecode:y}),l=q(_e.deployedBytecode.object),f=Ft({bytecode:_e.bytecode.object,abi:$t,args:[r,s,d,u]}),h=Y({deployerAddress:e,bytecode:f});return{AccessManagementSystem:{bytecode:t,deployedBytecodeSize:o,debugLabel:"access management system",address:r},BalanceTransferSystem:{bytecode:a,deployedBytecodeSize:n,debugLabel:"balance transfer system",address:s},BatchCallSystem:{bytecode:c,deployedBytecodeSize:i,debugLabel:"batch call system",address:d},RegistrationSystem:{bytecode:y,deployedBytecodeSize:p,debugLabel:"core registration system",address:u},InitModule:{bytecode:f,deployedBytecodeSize:l,debugLabel:"core module",address:h}}}import{getContractAddress as Nt}from"@latticexyz/common/internal";function re(e){let o=E(e),t=zt(Ve.deployedBytecode.object),r=Et({bytecode:Ve.bytecode.object,abi:Lt,args:[o.InitModule.address]}),n=Nt({deployerAddress:e,bytecode:r});return{...o,WorldFactory:{bytecode:r,deployedBytecodeSize:t,debugLabel:"world factory",address:n}}}import Ke from"@latticexyz/world/out/WorldProxyFactory.sol/WorldProxyFactory.json"assert{type:"json"};import Ut from"@latticexyz/world/out/WorldProxyFactory.sol/WorldProxyFactory.abi.json"assert{type:"json"};import{encodeDeployData as _t,size as Vt}from"viem";import{getContractAddress as Kt}from"@latticexyz/common/internal";function ne(e){let o=E(e),t=Vt(Ke.deployedBytecode.object),r=_t({bytecode:Ke.bytecode.object,abi:Ut,args:[o.InitModule.address]}),n=Kt({deployerAddress:e,bytecode:r});return{...o,WorldProxyFactory:{bytecode:r,deployedBytecodeSize:t,debugLabel:"world proxy factory",address:n}}}import{ensureContractsDeployed as Je}from"@latticexyz/common/internal";async function qe(e,o,t){if(t){let n=ne(o);return await Je({client:e,deployerAddress:o,contracts:Object.values(n)}),n.WorldProxyFactory.address}let r=re(o);return await Je({client:e,deployerAddress:o,contracts:Object.values(r)}),r.WorldFactory.address}import rr from"@latticexyz/world/out/WorldFactory.sol/WorldFactory.abi.json"assert{type:"json"};import{writeContract as nr}from"@latticexyz/common";import Ye from"debug";var O=Ye("mud:cli"),Jt=Ye("mud:cli");O.log=console.debug.bind(console);Jt.log=console.error.bind(console);var g=O.extend("deploy"),qt=O.extend("deploy");g.log=console.debug.bind(console);qt.log=console.error.bind(console);import{AbiEventSignatureNotFoundError as Zt,decodeEventLog as Xt,hexToString as Ze,parseAbi as er}from"viem";import Yt from"@latticexyz/world/out/IBaseWorld.sol/IBaseWorld.abi.json"assert{type:"json"};import{helloStoreEvent as Gt}from"@latticexyz/store";import{helloWorldEvent as Qt}from"@latticexyz/world";var se=[Gt,Qt],D=Yt,Ge=["2.0.0","2.0.1","2.0.2"],Qe=["2.0.0","2.0.1","2.0.2"];import{isDefined as or}from"@latticexyz/common/utils";function z(e){let o=e.map(s=>{try{return{...s,...Xt({strict:!0,abi:er(se),topics:s.topics,data:s.data})}}catch(i){if(i instanceof Zt)return;throw i}}).filter(or),{address:t,deployBlock:r,worldVersion:n,storeVersion:a}=o.reduce((s,i)=>({...s,address:i.address,deployBlock:i.blockNumber,...i.eventName==="HelloWorld"?{worldVersion:Ze(i.args.worldVersion).replace(/\0+$/,"")}:null,...i.eventName==="HelloStore"?{storeVersion:Ze(i.args.storeVersion).replace(/\0+$/,"")}:null}),{});if(t==null)throw new Error("could not find world address");if(r==null)throw new Error("could not find world deploy block number");if(n==null)throw new Error("could not find world version");if(a==null)throw new Error("could not find store version");return{address:t,deployBlock:r,worldVersion:n,storeVersion:a}}async function Xe(e,o,t,r){let n=await qe(e,o,r);g("deploying world");let a=await nr(e,{chain:e.chain??null,address:n,abi:rr,functionName:"deployWorld",args:[t]});g("waiting for world deploy");let s=await tr(e,{hash:a});if(s.status!=="success")throw console.error("world deploy failed",s),new Error("world deploy failed");let i=z(s.logs);return g("deployed world to",i.address,"at block",i.deployBlock),{...i,stateBlock:i.deployBlock}}import{resourceToLabel as ie,writeContract as dr}from"@latticexyz/common";import{valueSchemaToFieldLayoutHex as lr,keySchemaToHex as ro,valueSchemaToHex as no,getSchemaTypes as N,getValueSchema as so,getKeySchema as ao}from"@latticexyz/protocol-parser/internal";import{decodeAbiParameters as eo,parseAbiParameters as oo}from"viem";import{hexToResource as sr}from"@latticexyz/common";import{hexToSchema as to}from"@latticexyz/protocol-parser/internal";import ar from"@latticexyz/store/mud.config";import{getRecords as ir}from"@latticexyz/store-sync";async function ae({client:e,worldDeploy:o,indexerUrl:t,chainId:r}){g("looking up tables for",o.address);let{records:n}=await ir({table:ar.namespaces.store.tables.Tables,worldAddress:o.address,indexerUrl:t,chainId:r,client:e,fromBlock:o.deployBlock,toBlock:o.stateBlock}),a=n.map(s=>{let{type:i,namespace:c,name:d}=sr(s.tableId),p=to(s.keySchema),y=to(s.valueSchema),u=eo(oo("string[]"),s.abiEncodedKeyNames)[0],l=eo(oo("string[]"),s.abiEncodedFieldNames)[0],f=[...y.staticFields,...y.dynamicFields],h=Object.fromEntries(p.staticFields.map((A,k)=>[u[k],{type:A,internalType:A}])),S=Object.fromEntries(f.map((A,k)=>[l[k],{type:A,internalType:A}]));return{type:i,namespace:c,name:d,tableId:s.tableId,schema:{...h,...S},key:Object.keys(h),keySchema:h,keySchemaHex:s.keySchema,valueSchema:S,valueSchemaHex:s.valueSchema}});return g("found",a.length,"tables for",o.address),a}import cr from"p-retry";import{isDefined as mr}from"@latticexyz/common/utils";async function io({client:e,worldDeploy:o,tables:t,indexerUrl:r,chainId:n}){let a=new Map(t.map(p=>{let y=N(ao(p)),u=N(so(p)),l=ro(y),f=no(u);return[p.tableId,{...p,keySchema:y,keySchemaHex:l,valueSchema:u,valueSchemaHex:f}]})),i=(await ae({client:e,worldDeploy:o,indexerUrl:r,chainId:n})).filter(({tableId:p})=>a.has(p));if(i.length){g("existing tables:",i.map(ie).join(", "));let p=i.map(y=>{let u=a.get(y.tableId);if(y.keySchemaHex!==u.keySchemaHex||y.valueSchemaHex!==u.valueSchemaHex)return[`"${ie(y)}" table:`,` Registered schema: ${JSON.stringify({schema:N(y.schema),key:y.key})}`,` Config schema: ${JSON.stringify({schema:N(u.schema),key:u.key})}`].join(`
3
3
  `)}).filter(mr);if(p.length)throw new Error(["Table schemas are immutable, but found registered tables with a different schema than what you have configured.",...p,"You can either update your config with the registered schema or change the table name to register a new table."].join(`
4
4
 
@@ -17,7 +17,7 @@ Resolved config:
17
17
  Run 'echo "PRIVATE_KEY=0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80" > .env'
18
18
  in your contracts directory to use the default anvil private key.`);return Zn(b)}})(),f=qn({transport:Yn(i,{batch:e.rpcBatch?{batchSize:100,wait:1e3}:void 0}),account:l}),h=await rs(f),S=e.indexerUrl??be.find(b=>b.id===h)?.indexerUrl,A=e.worldAddress?as({worldAddress:e.worldAddress,worldsFile:n.deploy.worldsFile,chainId:h}):void 0;console.log("Deploying from",f.account.address);let k=await Vo(f),x=Date.now(),w=await Ho({config:n,deployerAddress:e.deployerAddress,salt:o,worldAddress:e.worldAddress,worldDeployBlock:A,client:f,tables:u,systems:c,libraries:d,modules:y,artifacts:p,indexerUrl:S,chainId:h});(e.worldAddress==null||e.alwaysRunPostDeploy)&&await Eo(n.deploy.postDeployScript,w.address,i,t,e.forgeScriptOptions,!!e.kms),await k?.reset(),console.log(V.green("Deployment completed in",(Date.now()-x)/1e3,"seconds"));let m={worldAddress:w.address,blockNumber:Number(w.deployBlock)};if(e.saveDeployment){let b=he.join(n.deploy.deploysDirectory,h.toString());Jn(b,{recursive:!0}),Pe(he.join(b,"latest.json"),JSON.stringify(m,null,2)),Pe(he.join(b,Date.now()+".json"),JSON.stringify(m,null,2));let T=[1337,31337],j=Jo(n.deploy.worldsFile)?JSON.parse(qo(n.deploy.worldsFile,"utf-8")):{};j[h]={address:m.worldAddress,blockNumber:T.includes(h)?void 0:m.blockNumber},Pe(n.deploy.worldsFile,JSON.stringify(j,null,2)),console.log(V.bgGreen(V.whiteBright(`
19
19
  Deployment result (written to ${n.deploy.worldsFile} and ${b}):
20
- `)))}return console.log(m),w}function as({chainId:e,worldAddress:o,worldsFile:t}){let r=Jo(t)?JSON.parse(qo(t,"utf-8")):{},n=r[e]?.address===o?r[e].blockNumber:void 0;return n?BigInt(n):void 0}var is={command:"deploy",describe:"Deploy MUD contracts",builder(e){return e.options(M)},async handler(e){try{await K(e)}catch(o){te(o),process.exit(1)}process.exit(0)}},Yo=is;import ds from"node:path";import{loadConfig as ls,resolveConfigPath as cs}from"@latticexyz/config/node";import{worldgen as ms}from"@latticexyz/world/node";var ps={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 MUD config file"},clean:{type:"boolean",desc:"Clear the worldgen directory before generating new interfaces (defaults to true)",default:!0}})},async handler(e){await fs(e),process.exit(0)}};async function fs(e){let o=await cs(e.configPath),t=await ls(o),r=ds.dirname(o);await ms({rootDir:r,config:t,clean:e.clean})}var Go=ps;import Z from"chalk";import{readFileSync as hs,writeFileSync as ws}from"fs";import Me from"path";import{MUDError as J}from"@latticexyz/common/errors";var Qo={name:"@latticexyz/cli",version:"2.2.15",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"},typesVersions:{"*":{index:["./dist/index.d.ts"]}},bin:{mud:"./bin/mud.js"},files:["bin","dist"],scripts:{build:"pnpm run build:js && pnpm run build:test-tables","build:js":"tsup && chmod +x ./dist/mud.js","build:test-tables":"tsx ./scripts/generate-test-tables.ts",clean:"pnpm run clean:js && pnpm run clean:test-tables","clean:js":"shx rm -rf dist","clean:test-tables":"shx rm -rf src/**/codegen",dev:"tsup --watch",lint:"eslint . --ext .ts",test:"tsc --noEmit && forge test","test:ci":"pnpm run test"},dependencies:{"@ark/util":"0.2.2","@aws-sdk/client-kms":"^3.556.0","@latticexyz/abi-ts":"workspace:*","@latticexyz/block-logs-stream":"workspace:*","@latticexyz/common":"workspace:*","@latticexyz/config":"workspace:*","@latticexyz/gas-report":"workspace:*","@latticexyz/protocol-parser":"workspace:*","@latticexyz/schema-type":"workspace:*","@latticexyz/store":"workspace:*","@latticexyz/store-sync":"workspace:*","@latticexyz/utils":"workspace:*","@latticexyz/world":"workspace:*","@latticexyz/world-module-metadata":"workspace:*",abitype:"1.0.6","asn1.js":"^5.4.1",chalk:"^5.0.1",chokidar:"^3.5.3",debug:"^4.3.4",dotenv:"^16.0.3",execa:"^7.0.0","find-up":"^6.3.0",glob:"^10.4.2",openurl:"^1.1.1","p-queue":"^7.4.1","p-retry":"^5.1.2",path:"^0.12.7",rxjs:"7.5.5","throttle-debounce":"^5.0.0",toposort:"^2.0.2",typescript:"5.4.2",viem:"2.21.19",yargs:"^17.7.1",zod:"3.23.8","zod-validation-error":"^1.3.0"},devDependencies:{"@types/debug":"^4.1.7","@types/ejs":"^3.1.1","@types/node":"^18.15.11","@types/openurl":"^1.0.0","@types/throttle-debounce":"^5.0.0","@types/toposort":"^2.0.6","@types/yargs":"^17.0.10","ds-test":"https://github.com/dapphub/ds-test.git#e282159d5170298eb2455a6c05280ab5a73a4ef0","forge-std":"https://github.com/foundry-rs/forge-std.git#74cfb77e308dd188d2f58864aaf44963ae6b88b1",tsup:"^6.7.0",vitest:"0.34.6"}};import{globSync as xs}from"glob";import{ZodError as us,z as Zo}from"zod";var gs=Zo.object({MUD_PACKAGES:Zo.string().transform(e=>JSON.parse(e))});function bs(){try{return gs.parse({MUD_PACKAGES:'{"@latticexyz/abi-ts":{"localPath":"packages/abi-ts"},"@latticexyz/block-logs-stream":{"localPath":"packages/block-logs-stream"},"@latticexyz/cli":{"localPath":"packages/cli"},"@latticexyz/common":{"localPath":"packages/common"},"@latticexyz/config":{"localPath":"packages/config"},"create-mud":{"localPath":"packages/create-mud"},"@latticexyz/dev-tools":{"localPath":"packages/dev-tools"},"@latticexyz/entrykit":{"localPath":"packages/entrykit"},"@latticexyz/explorer":{"localPath":"packages/explorer"},"@latticexyz/faucet":{"localPath":"packages/faucet"},"@latticexyz/gas-report":{"localPath":"packages/gas-report"},"@latticexyz/paymaster":{"localPath":"packages/paymaster"},"@latticexyz/protocol-parser":{"localPath":"packages/protocol-parser"},"@latticexyz/react":{"localPath":"packages/react"},"@latticexyz/recs":{"localPath":"packages/recs"},"@latticexyz/schema-type":{"localPath":"packages/schema-type"},"solhint-config-mud":{"localPath":"packages/solhint-config-mud"},"solhint-plugin-mud":{"localPath":"packages/solhint-plugin-mud"},"@latticexyz/stash":{"localPath":"packages/stash"},"@latticexyz/store-consumer":{"localPath":"packages/store-consumer"},"@latticexyz/store-indexer":{"localPath":"packages/store-indexer"},"@latticexyz/store-sync":{"localPath":"packages/store-sync"},"@latticexyz/store":{"localPath":"packages/store"},"@latticexyz/utils":{"localPath":"packages/utils"},"vite-plugin-mud":{"localPath":"packages/vite-plugin-mud"},"@latticexyz/world-module-erc20":{"localPath":"packages/world-module-erc20"},"@latticexyz/world-module-metadata":{"localPath":"packages/world-module-metadata"},"@latticexyz/world-modules":{"localPath":"packages/world-modules"},"@latticexyz/world":{"localPath":"packages/world"}}'})}catch(e){if(e instanceof us){let{...o}=e.format();console.error(`
20
+ `)))}return console.log(m),w}function as({chainId:e,worldAddress:o,worldsFile:t}){let r=Jo(t)?JSON.parse(qo(t,"utf-8")):{},n=r[e]?.address===o?r[e].blockNumber:void 0;return n?BigInt(n):void 0}var is={command:"deploy",describe:"Deploy MUD contracts",builder(e){return e.options(M)},async handler(e){try{await K(e)}catch(o){te(o),process.exit(1)}process.exit(0)}},Yo=is;import ds from"node:path";import{loadConfig as ls,resolveConfigPath as cs}from"@latticexyz/config/node";import{worldgen as ms}from"@latticexyz/world/node";var ps={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 MUD config file"},clean:{type:"boolean",desc:"Clear the worldgen directory before generating new interfaces (defaults to true)",default:!0}})},async handler(e){await fs(e),process.exit(0)}};async function fs(e){let o=await cs(e.configPath),t=await ls(o),r=ds.dirname(o);await ms({rootDir:r,config:t,clean:e.clean})}var Go=ps;import Z from"chalk";import{readFileSync as hs,writeFileSync as ws}from"fs";import Me from"path";import{MUDError as J}from"@latticexyz/common/errors";var Qo={name:"@latticexyz/cli",version:"2.2.15",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"},typesVersions:{"*":{index:["./dist/index.d.ts"]}},bin:{mud:"./bin/mud.js"},files:["bin","dist"],scripts:{build:"pnpm run build:js && pnpm run build:test-tables","build:js":"tsup && chmod +x ./dist/mud.js","build:test-tables":"tsx ./scripts/generate-test-tables.ts",clean:"pnpm run clean:js && pnpm run clean:test-tables","clean:js":"shx rm -rf dist","clean:test-tables":"shx rm -rf src/**/codegen",dev:"tsup --watch",lint:"eslint . --ext .ts",test:"tsc --noEmit && forge test","test:ci":"pnpm run test"},dependencies:{"@ark/util":"0.2.2","@aws-sdk/client-kms":"^3.556.0","@latticexyz/abi-ts":"workspace:*","@latticexyz/block-logs-stream":"workspace:*","@latticexyz/common":"workspace:*","@latticexyz/config":"workspace:*","@latticexyz/gas-report":"workspace:*","@latticexyz/protocol-parser":"workspace:*","@latticexyz/schema-type":"workspace:*","@latticexyz/store":"workspace:*","@latticexyz/store-sync":"workspace:*","@latticexyz/utils":"workspace:*","@latticexyz/world":"workspace:*","@latticexyz/world-module-metadata":"workspace:*",abitype:"1.0.6","asn1.js":"^5.4.1",chalk:"^5.0.1",chokidar:"^3.5.3",debug:"^4.3.4",dotenv:"^16.0.3",execa:"^7.0.0","find-up":"^6.3.0",glob:"^10.4.2",openurl:"^1.1.1","p-queue":"^7.4.1","p-retry":"^5.1.2",path:"^0.12.7",rxjs:"7.5.5","throttle-debounce":"^5.0.0",toposort:"^2.0.2",viem:"2.21.19",yargs:"^17.7.1",zod:"3.23.8","zod-validation-error":"^1.3.0"},devDependencies:{"@types/debug":"^4.1.7","@types/ejs":"^3.1.1","@types/openurl":"^1.0.0","@types/throttle-debounce":"^5.0.0","@types/toposort":"^2.0.6","@types/yargs":"^17.0.10","ds-test":"https://github.com/dapphub/ds-test.git#e282159d5170298eb2455a6c05280ab5a73a4ef0","forge-std":"https://github.com/foundry-rs/forge-std.git#74cfb77e308dd188d2f58864aaf44963ae6b88b1",vitest:"0.34.6"}};import{globSync as xs}from"glob";import{ZodError as us,z as Zo}from"zod";var gs=Zo.object({MUD_PACKAGES:Zo.string().transform(e=>JSON.parse(e))});function bs(){try{return gs.parse({MUD_PACKAGES:'{"@latticexyz/abi-ts":{"localPath":"packages/abi-ts"},"@latticexyz/block-logs-stream":{"localPath":"packages/block-logs-stream"},"@latticexyz/cli":{"localPath":"packages/cli"},"@latticexyz/common":{"localPath":"packages/common"},"@latticexyz/config":{"localPath":"packages/config"},"create-mud":{"localPath":"packages/create-mud"},"@latticexyz/dev-tools":{"localPath":"packages/dev-tools"},"@latticexyz/entrykit":{"localPath":"packages/entrykit"},"@latticexyz/explorer":{"localPath":"packages/explorer"},"@latticexyz/faucet":{"localPath":"packages/faucet"},"@latticexyz/gas-report":{"localPath":"packages/gas-report"},"@latticexyz/paymaster":{"localPath":"packages/paymaster"},"@latticexyz/protocol-parser":{"localPath":"packages/protocol-parser"},"@latticexyz/react":{"localPath":"packages/react"},"@latticexyz/recs":{"localPath":"packages/recs"},"@latticexyz/schema-type":{"localPath":"packages/schema-type"},"solhint-config-mud":{"localPath":"packages/solhint-config-mud"},"solhint-plugin-mud":{"localPath":"packages/solhint-plugin-mud"},"@latticexyz/stash":{"localPath":"packages/stash"},"@latticexyz/store-consumer":{"localPath":"packages/store-consumer"},"@latticexyz/store-indexer":{"localPath":"packages/store-indexer"},"@latticexyz/store-sync":{"localPath":"packages/store-sync"},"@latticexyz/store":{"localPath":"packages/store"},"@latticexyz/utils":{"localPath":"packages/utils"},"vite-plugin-mud":{"localPath":"packages/vite-plugin-mud"},"@latticexyz/world-module-erc20":{"localPath":"packages/world-module-erc20"},"@latticexyz/world-module-metadata":{"localPath":"packages/world-module-metadata"},"@latticexyz/world-modules":{"localPath":"packages/world-modules"},"@latticexyz/world":{"localPath":"packages/world"}}'})}catch(e){if(e instanceof us){let{...o}=e.format();console.error(`
21
21
  Missing or invalid environment variables:
22
22
 
23
23
  ${Object.keys(o).join(`
@@ -31,7 +31,7 @@ Waiting for file changes\u2026
31
31
  Waiting for file changes\u2026
32
32
  `))}}),na(sa)).subscribe()}},st=ia;import{sliceHex as la,zeroHash as ca}from"viem";import{forge as da}from"@latticexyz/common/foundry";async function $(e){let o=["verify-contract",e.address,e.name,"--rpc-url",e.rpc];e.verifier&&o.push("--verifier",e.verifier),e.verifierUrl&&o.push("--verifier-url",e.verifierUrl),await da(o,{cwd:e.cwd})}import ma from"p-queue";import{MUDError as pa}from"@latticexyz/common/errors";import{getStorageAt as fa}from"viem/actions";import{execa as Be}from"execa";import{getContractAddress as at,getDeployer as ya}from"@latticexyz/common/internal";var ua="0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc";async function it({client:e,rpc:o,systems:t,modules:r,worldAddress:n,deployerAddress:a,verifier:s,verifierUrl:i}){let c=a??await ya(e);if(!c)throw new pa("No deployer address provided or found.");let d=await fa(e,{address:n,slot:ua}),p=d&&d!==ca,y=new ma({concurrency:4});if(t.map(({name:u,bytecode:l})=>y.add(()=>$({name:u,rpc:o,verifier:s,verifierUrl:i,address:at({deployerAddress:c,bytecode:l})}).catch(f=>{console.error(`Error verifying system contract ${u}:`,f)}))),s==="sourcify")if(await Be("npm",["install"],{cwd:"node_modules/@latticexyz/store"}),await Be("npm",["install"],{cwd:"node_modules/@latticexyz/world"}),await Be("npm",["install"],{cwd:"node_modules/@latticexyz/world-modules"}),Object.entries(p?ne(c):re(c)).map(([u,{bytecode:l}])=>y.add(()=>$({cwd:"node_modules/@latticexyz/world",name:u,rpc:o,verifier:s,verifierUrl:i,address:at({deployerAddress:c,bytecode:l})}).catch(f=>{console.error(`Error verifying world factory contract ${u}:`,f)}))),r.map(({name:u,prepareDeploy:l})=>{let{address:f}=l(c);return y.add(()=>$({cwd:"node_modules/@latticexyz/world-modules",name:u,rpc:o,verifier:s,verifierUrl:i,address:f}).catch(h=>{console.error(`Error verifying module contract ${u}:`,h)}))}),p){let u=la(d,-20);y.add(()=>$({cwd:"node_modules/@latticexyz/world",name:"WorldProxy",rpc:o,verifier:s,verifierUrl:i,address:n}).catch(l=>{console.error("Error verifying WorldProxy contract:",l)})),y.add(()=>$({cwd:"node_modules/@latticexyz/world",name:"World",rpc:o,verifier:s,verifierUrl:i,address:u}).catch(l=>{console.error("Error verifying World contract:",l)}))}else y.add(()=>$({cwd:"node_modules/@latticexyz/world",name:"World",rpc:o,verifier:s,verifierUrl:i,address:n}).catch(u=>{console.error("Error verifying World contract:",u)}));else console.log(""),console.log(`Note: MUD is currently unable to verify store, world, and world-modules contracts with ${s}. We are planning to expand support in a future version.`),console.log("")}import{loadConfig as ga,resolveConfigPath as ba}from"@latticexyz/config/node";import{resolveSystems as ha}from"@latticexyz/world/node";import{getOutDirectory as wa,getRpcUrl as xa}from"@latticexyz/common/foundry";import{createWalletClient as va,http as Sa}from"viem";import dt from"chalk";import Ca from"node:path";var Da={deployerAddress:{type:"string",desc:"Deploy using an existing deterministic deployer (https://github.com/Arachnid/deterministic-deployment-proxy)"},worldAddress:{type:"string",required:!0,desc:"Verify an existing World at the given address"},configPath:{type:"string",desc:"Path to the MUD config file"},profile:{type:"string",desc:"The foundry profile to use"},rpc:{type:"string",desc:"The RPC URL to use. Defaults to the RPC url from the local foundry.toml"},rpcBatch:{type:"boolean",desc:"Enable batch processing of RPC requests in viem client (defaults to batch size of 100 and wait of 1s)"},verifier:{type:"string",desc:"The verifier to use. Defaults to blockscout",default:"blockscout"},verifierUrl:{type:"string",desc:"The verification provider."}},Aa={command:"verify",describe:"Verify contracts",builder(e){return e.options(Da)},async handler(e){let o=e.profile??process.env.FOUNDRY_PROFILE,t=await ba(e.configPath),r=Ca.dirname(t),n=await ga(t),a=await wa(o),s=e.rpc??await xa(o);console.log(dt.bgBlue(dt.whiteBright(`
33
33
  Verifying MUD contracts${o?" with profile "+o:""} to RPC ${s}
34
- `)));let i=va({transport:Sa(s,{batch:e.rpcBatch?{batchSize:100,wait:1e3}:void 0})}),d=(await ha({rootDir:r,config:n})).map(y=>{let u=_(`${y.name}.sol`,y.name,a);return{name:y.name,bytecode:u.bytecode}}),p=await ge(n,a);await it({client:i,rpc:s,systems:d,modules:p,deployerAddress:e.deployerAddress,worldAddress:e.worldAddress,verifier:e.verifier,verifierUrl:e.verifierUrl})}},lt=Aa;import{getRpcUrl as Na}from"@latticexyz/common/foundry";import{createClient as Ua,http as _a}from"viem";import ve from"chalk";import{hexToString as He,parseAbiItem as ct,stringToHex as Ie}from"viem";import{getSchemaTypes as Ia}from"@latticexyz/protocol-parser/internal";import{hexToResource as Wa,resourceToHex as ja}from"@latticexyz/common";import We from"@latticexyz/world-module-metadata/mud.config";import{decodeValueArgs as ka,getKeyTuple as Ta,getSchemaTypes as Pa,getValueSchema as Oa}from"@latticexyz/protocol-parser/internal";import{readContract as Ma}from"viem/actions";import{mapObject as Ba}from"@latticexyz/common/utils";async function we({client:e,worldDeploy:o,table:t,key:r}){let[n,a,s]=await Ma(e,{blockNumber:o.stateBlock,address:o.address,abi:D,functionName:"getRecord",args:[t.tableId,Ta(t,r)]}),i={...r,...ka(Pa(Oa(t)),{staticData:n,encodedLengths:a,dynamicData:s})};return Ba(t.schema,(c,d)=>i[d])}import F from"node:path";import xe from"node:fs/promises";import{getFunctions as Ra}from"@latticexyz/store-sync/world";import{abiToInterface as mt,formatSolidity as pt,formatTypescript as $a}from"@latticexyz/common/codegen";var H=O.extend("pull"),Ha=O.extend("pull");H.log=console.debug.bind(console);Ha.log=console.error.bind(console);import{defineWorld as Fa}from"@latticexyz/world";import{findUp as La}from"find-up";import{isDefined as ft}from"@latticexyz/common/utils";var Ea=new Set(["store","world","metadata"]);function yt(e){return ja({type:"namespace",namespace:e,name:""})}var X=class extends Error{constructor(t){super(`Attempted to write file at "${t}", but it already exists.`);this.filename=t}name="WriteFileExistsError"};async function ut({rootDir:e,client:o,worldAddress:t,replace:r,indexerUrl:n,chainId:a}){let s=r??await La(".git",{cwd:e})!=null,i=await ce(o,t),c=await U({client:o,worldDeploy:i,indexerUrl:n,chainId:a}),d=c.map(Wa).filter(x=>!Ea.has(x.namespace)),p=await ae({client:o,worldDeploy:i,indexerUrl:n,chainId:a}),y=Object.fromEntries((await Promise.all(c.map(async x=>{let{value:w}=await we({client:o,worldDeploy:i,table:We.tables.metadata__ResourceTag,key:{resource:x,tag:Ie("label",{size:32})}}),m=He(w);return[x,m===""?null:m]}))).filter(([,x])=>x!=null));y[yt("")]??="root";let u=await Ra({client:o,worldAddress:i.address,fromBlock:i.deployBlock,toBlock:i.stateBlock,indexerUrl:n,chainId:a}),l=d.filter(x=>x.type==="namespace"),f=await Promise.all(d.filter(x=>x.type==="system").map(async({namespace:x,name:w,resourceId:m})=>{let b=yt(x),T=y[m]??w.replace(/(S(y(s(t(e(m)?)?)?)?)?)?$/,"System"),[j,ee]=await Promise.all([we({client:o,worldDeploy:i,table:We.tables.metadata__ResourceTag,key:{resource:m,tag:Ie("abi",{size:32})}}).then(C=>He(C.value)).then(C=>C!==""?C.split(`
34
+ `)));let i=va({transport:Sa(s,{batch:e.rpcBatch?{batchSize:100,wait:1e3}:void 0})}),d=(await ha({rootDir:r,config:n})).map(y=>{let u=_(`${y.name}.sol`,y.name,a);return{name:y.name,bytecode:u.bytecode}}),p=await ge(n,a);await it({client:i,rpc:s,systems:d,modules:p,deployerAddress:e.deployerAddress,worldAddress:e.worldAddress,verifier:e.verifier,verifierUrl:e.verifierUrl})}},lt=Aa;import{getRpcUrl as Na}from"@latticexyz/common/foundry";import{createClient as Ua,http as _a}from"viem";import ve from"chalk";import{hexToString as He,parseAbiItem as ct,stringToHex as Ie}from"viem";import{getSchemaTypes as Ia}from"@latticexyz/protocol-parser/internal";import{hexToResource as Wa,resourceToHex as ja}from"@latticexyz/common";import We from"@latticexyz/world-module-metadata/mud.config";import{decodeValueArgs as ka,getKeyTuple as Ta,getSchemaTypes as Pa,getValueSchema as Oa}from"@latticexyz/protocol-parser/internal";import{readContract as Ma}from"viem/actions";import{mapObject as Ba}from"@latticexyz/common/utils";async function we({client:e,worldDeploy:o,table:t,key:r}){let[n,a,s]=await Ma(e,{blockNumber:o.stateBlock,address:o.address,abi:D,functionName:"getRecord",args:[t.tableId,Ta(t,r)]}),i={...r,...ka(Pa(Oa(t)),{staticData:n,encodedLengths:a,dynamicData:s})};return Ba(t.schema,(c,d)=>i[d])}import F from"node:path";import xe from"node:fs/promises";import{getFunctions as Ra}from"@latticexyz/store-sync/world";import{abiToInterface as mt,formatSolidity as pt,formatTypescript as $a}from"@latticexyz/common/codegen";var H=O.extend("pull"),Ha=O.extend("pull");H.log=console.debug.bind(console);Ha.log=console.error.bind(console);import{defineWorld as Fa}from"@latticexyz/world";import{findUp as La}from"find-up";import{isDefined as ft}from"@latticexyz/common/utils";var Ea=new Set(["store","world","metadata"]);function yt(e){return ja({type:"namespace",namespace:e,name:""})}var X=class extends Error{constructor(t){super(`Attempted to write file at "${t}", but it already exists.`);this.filename=t;this.name="WriteFileExistsError"}};async function ut({rootDir:e,client:o,worldAddress:t,replace:r,indexerUrl:n,chainId:a}){let s=r??await La(".git",{cwd:e})!=null,i=await ce(o,t),c=await U({client:o,worldDeploy:i,indexerUrl:n,chainId:a}),d=c.map(Wa).filter(x=>!Ea.has(x.namespace)),p=await ae({client:o,worldDeploy:i,indexerUrl:n,chainId:a}),y=Object.fromEntries((await Promise.all(c.map(async x=>{let{value:w}=await we({client:o,worldDeploy:i,table:We.tables.metadata__ResourceTag,key:{resource:x,tag:Ie("label",{size:32})}}),m=He(w);return[x,m===""?null:m]}))).filter(([,x])=>x!=null));y[yt("")]??="root";let u=await Ra({client:o,worldAddress:i.address,fromBlock:i.deployBlock,toBlock:i.stateBlock,indexerUrl:n,chainId:a}),l=d.filter(x=>x.type==="namespace"),f=await Promise.all(d.filter(x=>x.type==="system").map(async({namespace:x,name:w,resourceId:m})=>{let b=yt(x),T=y[m]??w.replace(/(S(y(s(t(e(m)?)?)?)?)?)?$/,"System"),[j,ee]=await Promise.all([we({client:o,worldDeploy:i,table:We.tables.metadata__ResourceTag,key:{resource:m,tag:Ie("abi",{size:32})}}).then(C=>He(C.value)).then(C=>C!==""?C.split(`
35
35
  `):[]),we({client:o,worldDeploy:i,table:We.tables.metadata__ResourceTag,key:{resource:m,tag:Ie("worldAbi",{size:32})}}).then(C=>He(C.value)).then(C=>C!==""?C.split(`
36
36
  `):[])]),v=u.filter(C=>C.systemId===m),P=(j.length?j:v.map(C=>`function ${C.systemFunctionSignature}`)).map(C=>{try{return ct(C)}catch{H(`Skipping invalid system signature: ${C}`)}}).filter(ft),oe=(ee.length?ee:v.map(C=>`function ${C.signature}`)).map(C=>{try{return ct(C)}catch{H(`Skipping invalid world signature: ${C}`)}}).filter(ft);return{namespaceId:b,namespaceLabel:y[b]??x,label:T,systemId:m,namespace:x,name:w,abi:P,worldAbi:oe}}));H("generating config");let h={namespaces:Object.fromEntries(l.map(({namespace:x,resourceId:w})=>{let m=y[w]??x;return[m,{...m!==x?{namespace:x}:null,tables:Object.fromEntries(p.filter(b=>b.namespace===x).map(b=>{let T=y[b.tableId]??b.name;return[T,{...T!==b.name?{name:b.name}:null,...b.type!=="table"?{type:b.type}:null,schema:Ia(b.schema),key:b.key,deploy:{disabled:!0}}]}))}]}))};H("validating config");let S=Fa(h);H("writing config"),await je(F.join(e,"mud.config.ts"),await $a(`
37
37
  import { defineWorld } from "@latticexyz/world";
@@ -40,4 +40,4 @@ Waiting for file changes\u2026
40
40
  `),{overwrite:s});let A=F.join(S.sourceDirectory,"remote");s&&await xe.rm(A,{recursive:!0,force:!0});for(let x of f.filter(w=>w.abi.length)){let w=`I${x.label}`,m=F.join(A,"namespaces",x.namespaceLabel,`${w}.sol`);H("writing system interface",w,"to",m);let b=mt({name:w,systemId:x.systemId,abi:x.abi});await je(F.join(e,m),await pt(b),{overwrite:s})}let k=f.flatMap(x=>x.worldAbi);if(k.length){let x="IWorldSystems",w=F.join(A,`${x}.sol`);H("writing world systems interface to",w);let m=mt({name:x,abi:k});await je(F.join(e,w),await pt(m),{overwrite:s})}return{config:S}}async function za(e){return xe.access(e).then(()=>!0,()=>!1)}async function je(e,o,t={}){if(!t.overwrite&&await za(e))throw new X(e);await xe.mkdir(F.dirname(e),{recursive:!0}),await xe.writeFile(e,o)}import Va from"node:path";import{getChainId as Ka}from"viem/actions";var Ja={worldAddress:{type:"string",required:!0,desc:"Remote world address"},profile:{type:"string",desc:"The foundry profile to use"},rpc:{type:"string",desc:"The RPC URL to use. Defaults to the RPC url from the local foundry.toml"},rpcBatch:{type:"boolean",desc:"Enable batch processing of RPC requests in viem client (defaults to batch size of 100 and wait of 1s)"},replace:{type:"boolean",desc:"Replace existing files and directories with data from remote world."},indexerUrl:{type:"string",desc:"The indexer URL to pull from.",required:!1}},qa={command:"pull",describe:"Pull mud.config.ts and interfaces from an existing world.",builder(e){return e.options(Ja)},async handler(e){let o=e.profile??process.env.FOUNDRY_PROFILE,t=e.rpc??await Na(o),r=Ua({transport:_a(t,{batch:e.rpcBatch?{batchSize:100,wait:1e3}:void 0})}),n=await Ka(r),a=e.indexerUrl??be.find(i=>i.id===n)?.indexerUrl;console.log(ve.bgBlue(ve.whiteBright(`
41
41
  Pulling MUD config from world at ${e.worldAddress}
42
42
  `)));let s=process.cwd();try{let{config:i}=await ut({rootDir:s,client:r,worldAddress:e.worldAddress,indexerUrl:a,chainId:n,replace:e.replace});await L({rootDir:s,config:i,foundryProfile:o})}catch(i){if(i instanceof X){console.log(),console.log(ve.bgRed(ve.whiteBright(" Error "))),console.log(` Attempted to write file at "${Va.relative(s,i.filename)}", but it already exists.`),console.log(),console.log(" To overwrite files, use `--replace` when running this command."),console.log();return}throw i}}},gt=qa;var Zy=[Re,Yo,$e,Ya,Fe,Le,Go,et,ot,nt,st,Ga,lt,gt];export{Zy as commands};
43
- //# sourceMappingURL=commands-KACKXII3.js.map
43
+ //# sourceMappingURL=commands-RZL4UL2O.js.map