@latticexyz/cli 2.2.18-88af9325733387259f29dfdafd2fdbc23f2ab499 → 2.2.18-90aac1d4acce19ac592d47a090732dd11c1c3e7a
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,5 +1,5 @@
|
|
1
1
|
import{a as re}from"./chunk-PZL6GJOK.js";import{command as Za}from"@latticexyz/gas-report/internal";import{command as Xa}from"@latticexyz/abi-ts/internal";import{loadConfig as At,resolveConfigPath as Dt}from"@latticexyz/config/node";import{tablegen as wt}from"@latticexyz/store/codegen";import{buildSystemsManifest as xt,worldgen as St}from"@latticexyz/world/node";import{forge as Ct}from"@latticexyz/common/foundry";import{execa as vt}from"execa";async function F({rootDir:e,config:o,foundryProfile:t}){await Promise.all([wt({rootDir:e,config:o}),St({rootDir:e,config:o})]),await Ct(["build"],{profile:t}),await xt({rootDir:e,config:o}),await vt("mud",["abi-ts"],{stdio:"inherit"})}import kt from"node:path";var Tt={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 Dt(e.configPath),t=await At(o);await F({rootDir:kt.dirname(o),config:t,foundryProfile:e.profile}),process.exit(0)}},ze=Tt;import{rmSync as Mt}from"fs";import{homedir as Pt}from"os";import Ot from"path";import{execa as Bt}from"execa";var Ht={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=Pt();Mt(Ot.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=Bt("anvil",t,{stdio:["inherit","inherit","inherit"]});process.on("SIGINT",()=>{console.log(`
|
2
|
-
gracefully shutting down from SIGINT (Crtl-C)`),r.kill(),process.exit()}),await r}},Ne=Ht;var Wt={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)}},Ue=Wt;import{loadConfig as It,resolveConfigPath as jt}from"@latticexyz/config/node";import{tablegen as Rt}from"@latticexyz/store/codegen";import $t from"node:path";var Lt={command:"tablegen",describe:"Autogenerate MUD Store table libraries based on the config file",builder(e){return e.options({configPath:{type:"string",desc:"Path to the MUD config file"}})},async handler(e){let o=await jt(e.configPath),t=await It(o);await Rt({rootDir:$t.dirname(o),config:t}),process.exit(0)}},Ve=Lt;import ve from"node:path";import{existsSync as Yo,mkdirSync as Zn,readFileSync as Qo,writeFileSync as We}from"node:fs";var q={name:"@latticexyz/cli",version:"2.2.17",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-callwithsignature":"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:"^9.5.2","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"}};import{stringToHex as un}from"viem";import{waitForTransactionReceipt as ar}from"viem/actions";import Ye from"@latticexyz/world/out/WorldFactory.sol/WorldFactory.json"assert{type:"json"};import Nt from"@latticexyz/world/out/WorldFactory.sol/WorldFactory.abi.json"assert{type:"json"};import{encodeDeployData as Ut,size as Vt}from"viem";import _e from"@latticexyz/world/out/AccessManagementSystem.sol/AccessManagementSystem.json"assert{type:"json"};import Ke from"@latticexyz/world/out/BalanceTransferSystem.sol/BalanceTransferSystem.json"assert{type:"json"};import Je from"@latticexyz/world/out/BatchCallSystem.sol/BatchCallSystem.json"assert{type:"json"};import qe from"@latticexyz/world/out/RegistrationSystem.sol/RegistrationSystem.json"assert{type:"json"};import Ge from"@latticexyz/world/out/InitModule.sol/InitModule.json"assert{type:"json"};import Ft from"@latticexyz/world/out/InitModule.sol/InitModule.abi.json"assert{type:"json"};import{encodeDeployData as zt,size as G}from"viem";import{getContractAddress as Y}from"@latticexyz/common/internal";function z(e){let o=G(_e.deployedBytecode.object),t=_e.bytecode.object,r=Y({deployerAddress:e,bytecode:t}),n=G(Ke.deployedBytecode.object),s=Ke.bytecode.object,a=Y({deployerAddress:e,bytecode:s}),i=G(Je.deployedBytecode.object),m=Je.bytecode.object,l=Y({deployerAddress:e,bytecode:m}),c=G(qe.deployedBytecode.object),y=qe.bytecode.object,b=Y({deployerAddress:e,bytecode:y}),f=G(Ge.deployedBytecode.object),d=zt({bytecode:Ge.bytecode.object,abi:Ft,args:[r,a,l,b]}),h=Y({deployerAddress:e,bytecode:d});return{AccessManagementSystem:{bytecode:t,deployedBytecodeSize:o,debugLabel:"access management system",address:r},BalanceTransferSystem:{bytecode:s,deployedBytecodeSize:n,debugLabel:"balance transfer system",address:a},BatchCallSystem:{bytecode:m,deployedBytecodeSize:i,debugLabel:"batch call system",address:l},RegistrationSystem:{bytecode:y,deployedBytecodeSize:c,debugLabel:"core registration system",address:b},InitModule:{bytecode:d,deployedBytecodeSize:f,debugLabel:"core module",address:h}}}import{getContractAddress as _t}from"@latticexyz/common/internal";function ne(e){let o=z(e),t=Vt(Ye.deployedBytecode.object),r=Ut({bytecode:Ye.bytecode.object,abi:Nt,args:[o.InitModule.address]}),n=_t({deployerAddress:e,bytecode:r});return{...o,WorldFactory:{bytecode:r,deployedBytecodeSize:t,debugLabel:"world factory",address:n}}}import Qe from"@latticexyz/world/out/WorldProxyFactory.sol/WorldProxyFactory.json"assert{type:"json"};import Kt from"@latticexyz/world/out/WorldProxyFactory.sol/WorldProxyFactory.abi.json"assert{type:"json"};import{encodeDeployData as Jt,size as qt}from"viem";import{getContractAddress as Gt}from"@latticexyz/common/internal";function se(e){let o=z(e),t=qt(Qe.deployedBytecode.object),r=Jt({bytecode:Qe.bytecode.object,abi:Kt,args:[o.InitModule.address]}),n=Gt({deployerAddress:e,bytecode:r});return{...o,WorldProxyFactory:{bytecode:r,deployedBytecodeSize:t,debugLabel:"world proxy factory",address:n}}}import{ensureContractsDeployed as Ze}from"@latticexyz/common/internal";async function Xe(e,o,t){if(t){let n=se(o);return await Ze({client:e,deployerAddress:o,contracts:Object.values(n)}),n.WorldProxyFactory.address}let r=ne(o);return await Ze({client:e,deployerAddress:o,contracts:Object.values(r)}),r.WorldFactory.address}import ir from"@latticexyz/world/out/WorldFactory.sol/WorldFactory.abi.json"assert{type:"json"};import{writeContract as lr}from"@latticexyz/common";import eo from"debug";var P=eo("mud:cli"),Yt=eo("mud:cli");P.log=console.debug.bind(console);Yt.log=console.error.bind(console);var u=P.extend("deploy"),Qt=P.extend("deploy");u.log=console.debug.bind(console);Qt.log=console.error.bind(console);import{AbiEventSignatureNotFoundError as or,decodeEventLog as tr,hexToString as ro,parseAbi as rr,getAddress as nr}from"viem";import Zt from"@latticexyz/world/out/IBaseWorld.sol/IBaseWorld.abi.json"assert{type:"json"};import{helloStoreEvent as Xt}from"@latticexyz/store";import{helloWorldEvent as er}from"@latticexyz/world";var ae=[Xt,er],A=Zt,oo=["2.0.0","2.0.1","2.0.2"],to=["2.0.0","2.0.1","2.0.2"];import{isDefined as sr}from"@latticexyz/common/utils";function N(e){let o=e.map(a=>{try{return{...a,...tr({strict:!0,abi:rr(ae),topics:a.topics,data:a.data}),address:nr(a.address)}}catch(i){if(i instanceof or)return;throw i}}).filter(sr),{address:t,deployBlock:r,worldVersion:n,storeVersion:s}=o.reduce((a,i)=>({...a,address:i.address,deployBlock:i.blockNumber,...i.eventName==="HelloWorld"?{worldVersion:ro(i.args.worldVersion).replace(/\0+$/,"")}:null,...i.eventName==="HelloStore"?{storeVersion:ro(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(s==null)throw new Error("could not find store version");return{address:t,deployBlock:r,worldVersion:n,storeVersion:s}}async function no(e,o,t,r){let n=await Xe(e,o,r);u("deploying world");let s=await lr(e,{chain:e.chain??null,address:n,abi:ir,functionName:"deployWorld",args:[t]});u("waiting for world deploy");let a=await ar(e,{hash:s});if(a.status!=="success")throw console.error("world deploy failed",a),new Error("world deploy failed");let i=N(a.logs);return u("deployed world to",i.address,"at block",i.deployBlock),{...i,stateBlock:i.deployBlock}}import{resourceToLabel as le,writeContract as pr}from"@latticexyz/common";import{valueSchemaToFieldLayoutHex as fr,keySchemaToHex as lo,valueSchemaToHex as co,getSchemaTypes as U,getValueSchema as mo,getKeySchema as po}from"@latticexyz/protocol-parser/internal";import{decodeAbiParameters as so,parseAbiParameters as ao}from"viem";import{hexToResource as dr}from"@latticexyz/common";import{hexToSchema as io}from"@latticexyz/protocol-parser/internal";import cr from"@latticexyz/store/mud.config";import{getRecords as mr}from"@latticexyz/store-sync";async function ie({client:e,worldDeploy:o,indexerUrl:t,chainId:r}){u("looking up tables for",o.address);let{records:n}=await mr({table:cr.namespaces.store.tables.Tables,worldAddress:o.address,indexerUrl:t,chainId:r,client:e,fromBlock:o.deployBlock,toBlock:o.stateBlock}),s=n.map(a=>{let{type:i,namespace:m,name:l}=dr(a.tableId),c=io(a.keySchema),y=io(a.valueSchema),b=so(ao("string[]"),a.abiEncodedKeyNames)[0],f=so(ao("string[]"),a.abiEncodedFieldNames)[0],d=[...y.staticFields,...y.dynamicFields],h=Object.fromEntries(c.staticFields.map((D,k)=>[b[k],{type:D,internalType:D}])),S=Object.fromEntries(d.map((D,k)=>[f[k],{type:D,internalType:D}]));return{type:i,namespace:m,name:l,tableId:a.tableId,schema:{...h,...S},key:Object.keys(h),keySchema:h,keySchemaHex:a.keySchema,valueSchema:S,valueSchemaHex:a.valueSchema}});return u("found",s.length,"tables for",o.address),s}import ur from"p-retry";import{isDefined as yr}from"@latticexyz/common/utils";async function fo({client:e,worldDeploy:o,tables:t,indexerUrl:r,chainId:n}){let s=new Map(t.map(c=>{let y=U(po(c)),b=U(mo(c)),f=lo(y),d=co(b);return[c.tableId,{...c,keySchema:y,keySchemaHex:f,valueSchema:b,valueSchemaHex:d}]})),i=(await ie({client:e,worldDeploy:o,indexerUrl:r,chainId:n})).filter(({tableId:c})=>s.has(c));if(i.length){u("existing tables:",i.map(le).join(", "));let c=i.map(y=>{let b=s.get(y.tableId);if(y.keySchemaHex!==b.keySchemaHex||y.valueSchemaHex!==b.valueSchemaHex)return[`"${le(y)}" table:`,` Registered schema: ${JSON.stringify({schema:U(y.schema),key:y.key})}`,` Config schema: ${JSON.stringify({schema:U(b.schema),key:b.key})}`].join(`
|
2
|
+
gracefully shutting down from SIGINT (Crtl-C)`),r.kill(),process.exit()}),await r}},Ne=Ht;var Wt={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)}},Ue=Wt;import{loadConfig as It,resolveConfigPath as jt}from"@latticexyz/config/node";import{tablegen as Rt}from"@latticexyz/store/codegen";import $t from"node:path";var Lt={command:"tablegen",describe:"Autogenerate MUD Store table libraries based on the config file",builder(e){return e.options({configPath:{type:"string",desc:"Path to the MUD config file"}})},async handler(e){let o=await jt(e.configPath),t=await It(o);await Rt({rootDir:$t.dirname(o),config:t}),process.exit(0)}},Ve=Lt;import ve from"node:path";import{existsSync as Yo,mkdirSync as Zn,readFileSync as Qo,writeFileSync as We}from"node:fs";var q={name:"@latticexyz/cli",version:"2.2.17",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-callwithsignature":"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:"^9.5.2","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{stringToHex as un}from"viem";import{waitForTransactionReceipt as ar}from"viem/actions";import Ye from"@latticexyz/world/out/WorldFactory.sol/WorldFactory.json"assert{type:"json"};import Nt from"@latticexyz/world/out/WorldFactory.sol/WorldFactory.abi.json"assert{type:"json"};import{encodeDeployData as Ut,size as Vt}from"viem";import _e from"@latticexyz/world/out/AccessManagementSystem.sol/AccessManagementSystem.json"assert{type:"json"};import Ke from"@latticexyz/world/out/BalanceTransferSystem.sol/BalanceTransferSystem.json"assert{type:"json"};import Je from"@latticexyz/world/out/BatchCallSystem.sol/BatchCallSystem.json"assert{type:"json"};import qe from"@latticexyz/world/out/RegistrationSystem.sol/RegistrationSystem.json"assert{type:"json"};import Ge from"@latticexyz/world/out/InitModule.sol/InitModule.json"assert{type:"json"};import Ft from"@latticexyz/world/out/InitModule.sol/InitModule.abi.json"assert{type:"json"};import{encodeDeployData as zt,size as G}from"viem";import{getContractAddress as Y}from"@latticexyz/common/internal";function z(e){let o=G(_e.deployedBytecode.object),t=_e.bytecode.object,r=Y({deployerAddress:e,bytecode:t}),n=G(Ke.deployedBytecode.object),s=Ke.bytecode.object,a=Y({deployerAddress:e,bytecode:s}),i=G(Je.deployedBytecode.object),m=Je.bytecode.object,l=Y({deployerAddress:e,bytecode:m}),c=G(qe.deployedBytecode.object),y=qe.bytecode.object,b=Y({deployerAddress:e,bytecode:y}),f=G(Ge.deployedBytecode.object),d=zt({bytecode:Ge.bytecode.object,abi:Ft,args:[r,a,l,b]}),h=Y({deployerAddress:e,bytecode:d});return{AccessManagementSystem:{bytecode:t,deployedBytecodeSize:o,debugLabel:"access management system",address:r},BalanceTransferSystem:{bytecode:s,deployedBytecodeSize:n,debugLabel:"balance transfer system",address:a},BatchCallSystem:{bytecode:m,deployedBytecodeSize:i,debugLabel:"batch call system",address:l},RegistrationSystem:{bytecode:y,deployedBytecodeSize:c,debugLabel:"core registration system",address:b},InitModule:{bytecode:d,deployedBytecodeSize:f,debugLabel:"core module",address:h}}}import{getContractAddress as _t}from"@latticexyz/common/internal";function ne(e){let o=z(e),t=Vt(Ye.deployedBytecode.object),r=Ut({bytecode:Ye.bytecode.object,abi:Nt,args:[o.InitModule.address]}),n=_t({deployerAddress:e,bytecode:r});return{...o,WorldFactory:{bytecode:r,deployedBytecodeSize:t,debugLabel:"world factory",address:n}}}import Qe from"@latticexyz/world/out/WorldProxyFactory.sol/WorldProxyFactory.json"assert{type:"json"};import Kt from"@latticexyz/world/out/WorldProxyFactory.sol/WorldProxyFactory.abi.json"assert{type:"json"};import{encodeDeployData as Jt,size as qt}from"viem";import{getContractAddress as Gt}from"@latticexyz/common/internal";function se(e){let o=z(e),t=qt(Qe.deployedBytecode.object),r=Jt({bytecode:Qe.bytecode.object,abi:Kt,args:[o.InitModule.address]}),n=Gt({deployerAddress:e,bytecode:r});return{...o,WorldProxyFactory:{bytecode:r,deployedBytecodeSize:t,debugLabel:"world proxy factory",address:n}}}import{ensureContractsDeployed as Ze}from"@latticexyz/common/internal";async function Xe(e,o,t){if(t){let n=se(o);return await Ze({client:e,deployerAddress:o,contracts:Object.values(n)}),n.WorldProxyFactory.address}let r=ne(o);return await Ze({client:e,deployerAddress:o,contracts:Object.values(r)}),r.WorldFactory.address}import ir from"@latticexyz/world/out/WorldFactory.sol/WorldFactory.abi.json"assert{type:"json"};import{writeContract as lr}from"@latticexyz/common";import eo from"debug";var P=eo("mud:cli"),Yt=eo("mud:cli");P.log=console.debug.bind(console);Yt.log=console.error.bind(console);var u=P.extend("deploy"),Qt=P.extend("deploy");u.log=console.debug.bind(console);Qt.log=console.error.bind(console);import{AbiEventSignatureNotFoundError as or,decodeEventLog as tr,hexToString as ro,parseAbi as rr,getAddress as nr}from"viem";import Zt from"@latticexyz/world/out/IBaseWorld.sol/IBaseWorld.abi.json"assert{type:"json"};import{helloStoreEvent as Xt}from"@latticexyz/store";import{helloWorldEvent as er}from"@latticexyz/world";var ae=[Xt,er],A=Zt,oo=["2.0.0","2.0.1","2.0.2"],to=["2.0.0","2.0.1","2.0.2"];import{isDefined as sr}from"@latticexyz/common/utils";function N(e){let o=e.map(a=>{try{return{...a,...tr({strict:!0,abi:rr(ae),topics:a.topics,data:a.data}),address:nr(a.address)}}catch(i){if(i instanceof or)return;throw i}}).filter(sr),{address:t,deployBlock:r,worldVersion:n,storeVersion:s}=o.reduce((a,i)=>({...a,address:i.address,deployBlock:i.blockNumber,...i.eventName==="HelloWorld"?{worldVersion:ro(i.args.worldVersion).replace(/\0+$/,"")}:null,...i.eventName==="HelloStore"?{storeVersion:ro(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(s==null)throw new Error("could not find store version");return{address:t,deployBlock:r,worldVersion:n,storeVersion:s}}async function no(e,o,t,r){let n=await Xe(e,o,r);u("deploying world");let s=await lr(e,{chain:e.chain??null,address:n,abi:ir,functionName:"deployWorld",args:[t]});u("waiting for world deploy");let a=await ar(e,{hash:s});if(a.status!=="success")throw console.error("world deploy failed",a),new Error("world deploy failed");let i=N(a.logs);return u("deployed world to",i.address,"at block",i.deployBlock),{...i,stateBlock:i.deployBlock}}import{resourceToLabel as le,writeContract as pr}from"@latticexyz/common";import{valueSchemaToFieldLayoutHex as fr,keySchemaToHex as lo,valueSchemaToHex as co,getSchemaTypes as U,getValueSchema as mo,getKeySchema as po}from"@latticexyz/protocol-parser/internal";import{decodeAbiParameters as so,parseAbiParameters as ao}from"viem";import{hexToResource as dr}from"@latticexyz/common";import{hexToSchema as io}from"@latticexyz/protocol-parser/internal";import cr from"@latticexyz/store/mud.config";import{getRecords as mr}from"@latticexyz/store-sync";async function ie({client:e,worldDeploy:o,indexerUrl:t,chainId:r}){u("looking up tables for",o.address);let{records:n}=await mr({table:cr.namespaces.store.tables.Tables,worldAddress:o.address,indexerUrl:t,chainId:r,client:e,fromBlock:o.deployBlock,toBlock:o.stateBlock}),s=n.map(a=>{let{type:i,namespace:m,name:l}=dr(a.tableId),c=io(a.keySchema),y=io(a.valueSchema),b=so(ao("string[]"),a.abiEncodedKeyNames)[0],f=so(ao("string[]"),a.abiEncodedFieldNames)[0],d=[...y.staticFields,...y.dynamicFields],h=Object.fromEntries(c.staticFields.map((D,k)=>[b[k],{type:D,internalType:D}])),S=Object.fromEntries(d.map((D,k)=>[f[k],{type:D,internalType:D}]));return{type:i,namespace:m,name:l,tableId:a.tableId,schema:{...h,...S},key:Object.keys(h),keySchema:h,keySchemaHex:a.keySchema,valueSchema:S,valueSchemaHex:a.valueSchema}});return u("found",s.length,"tables for",o.address),s}import ur from"p-retry";import{isDefined as yr}from"@latticexyz/common/utils";async function fo({client:e,worldDeploy:o,tables:t,indexerUrl:r,chainId:n}){let s=new Map(t.map(c=>{let y=U(po(c)),b=U(mo(c)),f=lo(y),d=co(b);return[c.tableId,{...c,keySchema:y,keySchemaHex:f,valueSchema:b,valueSchemaHex:d}]})),i=(await ie({client:e,worldDeploy:o,indexerUrl:r,chainId:n})).filter(({tableId:c})=>s.has(c));if(i.length){u("existing tables:",i.map(le).join(", "));let c=i.map(y=>{let b=s.get(y.tableId);if(y.keySchemaHex!==b.keySchemaHex||y.valueSchemaHex!==b.valueSchemaHex)return[`"${le(y)}" table:`,` Registered schema: ${JSON.stringify({schema:U(y.schema),key:y.key})}`,` Config schema: ${JSON.stringify({schema:U(b.schema),key:b.key})}`].join(`
|
3
3
|
`)}).filter(yr);if(c.length)throw new Error(["Table schemas are immutable, but found registered tables with a different schema than what you have configured.",...c,"You can either update your config with the registered schema or change the table name to register a new table."].join(`
|
4
4
|
|
5
5
|
`)+`
|
@@ -45,4 +45,4 @@ Waiting for file changes\u2026
|
|
45
45
|
`),{overwrite:a});let D=E.join(S.sourceDirectory,"remote");a&&await De.rm(D,{recursive:!0,force:!0});for(let x of d.filter(w=>w.abi.length)){let w=`I${x.label}`,p=E.join(D,"namespaces",x.namespaceLabel,`${w}.sol`);H("writing system interface",w,"to",p);let g=ft({name:w,systemId:x.systemId,abi:x.abi});await Fe(E.join(e,p),await ut(g),{overwrite:a})}let k=d.flatMap(x=>x.worldAbi);if(k.length){let x="IWorldSystems",w=E.join(D,`${x}.sol`);H("writing world systems interface to",w);let p=ft({name:x,abi:k});await Fe(E.join(e,w),await ut(p),{overwrite:a})}return{config:S}}async function Va(e){return De.access(e).then(()=>!0,()=>!1)}async function Fe(e,o,t={}){if(!t.overwrite&&await Va(e))throw new ee(e);await De.mkdir(E.dirname(e),{recursive:!0}),await De.writeFile(e,o)}import qa from"node:path";import{getChainId as Ga}from"viem/actions";var Ya={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(Ya)},async handler(e){let o=e.profile,t=e.rpc??await _a(o),r=Ka({transport:Ja(t,{batch:e.rpcBatch?{batchSize:100,wait:1e3}:void 0})}),n=await Ga(r),s=e.indexerUrl??Ce.find(i=>i.id===n)?.indexerUrl;console.log(ke.bgBlue(ke.whiteBright(`
|
46
46
|
Pulling MUD config from world at ${e.worldAddress}
|
47
47
|
`)));let a=process.cwd();try{let{config:i}=await bt({rootDir:a,client:r,worldAddress:e.worldAddress,indexerUrl:s,chainId:n,replace:e.replace});await F({rootDir:a,config:i,foundryProfile:o})}catch(i){if(i instanceof ee){console.log(),console.log(ke.bgRed(ke.whiteBright(" Error "))),console.log(` Attempted to write file at "${qa.relative(a,i.filename)}", but it already exists.`),console.log(),console.log(" To overwrite files, use `--replace` when running this command."),console.log();return}throw i}}},ht=Qa;var iy=[ze,Zo,Ne,Za,Ue,Ve,Xo,tt,rt,at,it,Xa,mt,ht];export{iy as commands};
|
48
|
-
//# sourceMappingURL=commands-
|
48
|
+
//# sourceMappingURL=commands-FLWVUEDO.js.map
|