@latticexyz/cli 2.0.0-next.1 → 2.0.0-next.11
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/chunk-TW3YGZ4D.js +11 -0
- package/dist/chunk-TW3YGZ4D.js.map +1 -0
- package/dist/index.js +1 -1
- package/dist/mud.js +11 -7
- package/dist/mud.js.map +1 -1
- package/package.json +17 -15
- package/src/commands/deploy.ts +1 -1
- package/src/commands/dev-contracts.ts +17 -16
- package/src/commands/index.ts +2 -2
- package/src/commands/set-version.ts +19 -60
- package/src/commands/tablegen.ts +3 -2
- package/src/commands/test.ts +3 -2
- package/src/commands/trace.ts +17 -9
- package/src/commands/worldgen.ts +1 -1
- package/src/common.ts +1 -0
- package/src/index.ts +0 -1
- package/src/mud.ts +5 -2
- package/src/mudPackages.ts +24 -0
- package/src/utils/deploy.ts +189 -554
- package/src/utils/deployHandler.ts +9 -3
- package/src/utils/modules/constants.ts +23 -0
- package/src/utils/modules/getInstallModuleCallData.ts +27 -0
- package/src/utils/modules/getUserModules.ts +5 -0
- package/src/utils/modules/types.ts +14 -0
- package/src/utils/systems/getGrantAccessCallData.ts +29 -0
- package/src/utils/systems/getRegisterFunctionSelectorsCallData.ts +57 -0
- package/src/utils/systems/getRegisterSystemCallData.ts +17 -0
- package/src/utils/systems/types.ts +9 -0
- package/src/utils/systems/utils.ts +42 -0
- package/src/utils/tables/getRegisterTableCallData.ts +49 -0
- package/src/utils/tables/getTableIds.ts +18 -0
- package/src/utils/tables/types.ts +12 -0
- package/src/utils/utils/confirmNonce.ts +24 -0
- package/src/utils/utils/deployContract.ts +33 -0
- package/src/utils/utils/fastTxExecute.ts +56 -0
- package/src/utils/utils/getContractData.ts +29 -0
- package/src/utils/utils/postDeploy.ts +25 -0
- package/src/utils/utils/setInternalFeePerGas.ts +49 -0
- package/src/utils/utils/types.ts +21 -0
- package/src/utils/world.ts +28 -0
- package/dist/chunk-P7JIR52V.js +0 -32
- package/dist/chunk-P7JIR52V.js.map +0 -1
- package/src/commands/tsgen.ts +0 -34
- package/src/render-ts/index.ts +0 -5
- package/src/render-ts/recsV1TableOptions.ts +0 -57
- package/src/render-ts/renderRecsV1Tables.ts +0 -35
- package/src/render-ts/schemaTypesToRecsTypeStrings.ts +0 -202
- package/src/render-ts/tsgen.ts +0 -12
- package/src/render-ts/types.ts +0 -17
- package/src/utils/index.ts +0 -7
- package/src/utils/worldtypes.ts +0 -21
- /package/src/utils/{getChainId.ts → utils/getChainId.ts} +0 -0
package/dist/chunk-P7JIR52V.js
DELETED
@@ -1,32 +0,0 @@
|
|
1
|
-
import{SchemaType as e}from"@latticexyz/schema-type/deprecated";var oe={[e.UINT8]:"RecsType.Number",[e.UINT16]:"RecsType.Number",[e.UINT24]:"RecsType.Number",[e.UINT32]:"RecsType.Number",[e.UINT40]:"RecsType.Number",[e.UINT48]:"RecsType.Number",[e.UINT56]:"RecsType.BigInt",[e.UINT64]:"RecsType.BigInt",[e.UINT72]:"RecsType.BigInt",[e.UINT80]:"RecsType.BigInt",[e.UINT88]:"RecsType.BigInt",[e.UINT96]:"RecsType.BigInt",[e.UINT104]:"RecsType.BigInt",[e.UINT112]:"RecsType.BigInt",[e.UINT120]:"RecsType.BigInt",[e.UINT128]:"RecsType.BigInt",[e.UINT136]:"RecsType.BigInt",[e.UINT144]:"RecsType.BigInt",[e.UINT152]:"RecsType.BigInt",[e.UINT160]:"RecsType.BigInt",[e.UINT168]:"RecsType.BigInt",[e.UINT176]:"RecsType.BigInt",[e.UINT184]:"RecsType.BigInt",[e.UINT192]:"RecsType.BigInt",[e.UINT200]:"RecsType.BigInt",[e.UINT208]:"RecsType.BigInt",[e.UINT216]:"RecsType.BigInt",[e.UINT224]:"RecsType.BigInt",[e.UINT232]:"RecsType.BigInt",[e.UINT240]:"RecsType.BigInt",[e.UINT248]:"RecsType.BigInt",[e.UINT256]:"RecsType.BigInt",[e.INT8]:"RecsType.Number",[e.INT16]:"RecsType.Number",[e.INT24]:"RecsType.Number",[e.INT32]:"RecsType.Number",[e.INT40]:"RecsType.Number",[e.INT48]:"RecsType.Number",[e.INT56]:"RecsType.BigInt",[e.INT64]:"RecsType.BigInt",[e.INT72]:"RecsType.BigInt",[e.INT80]:"RecsType.BigInt",[e.INT88]:"RecsType.BigInt",[e.INT96]:"RecsType.BigInt",[e.INT104]:"RecsType.BigInt",[e.INT112]:"RecsType.BigInt",[e.INT120]:"RecsType.BigInt",[e.INT128]:"RecsType.BigInt",[e.INT136]:"RecsType.BigInt",[e.INT144]:"RecsType.BigInt",[e.INT152]:"RecsType.BigInt",[e.INT160]:"RecsType.BigInt",[e.INT168]:"RecsType.BigInt",[e.INT176]:"RecsType.BigInt",[e.INT184]:"RecsType.BigInt",[e.INT192]:"RecsType.BigInt",[e.INT200]:"RecsType.BigInt",[e.INT208]:"RecsType.BigInt",[e.INT216]:"RecsType.BigInt",[e.INT224]:"RecsType.BigInt",[e.INT232]:"RecsType.BigInt",[e.INT240]:"RecsType.BigInt",[e.INT248]:"RecsType.BigInt",[e.INT256]:"RecsType.BigInt",[e.BYTES1]:"RecsType.String",[e.BYTES2]:"RecsType.String",[e.BYTES3]:"RecsType.String",[e.BYTES4]:"RecsType.String",[e.BYTES5]:"RecsType.String",[e.BYTES6]:"RecsType.String",[e.BYTES7]:"RecsType.String",[e.BYTES8]:"RecsType.String",[e.BYTES9]:"RecsType.String",[e.BYTES10]:"RecsType.String",[e.BYTES11]:"RecsType.String",[e.BYTES12]:"RecsType.String",[e.BYTES13]:"RecsType.String",[e.BYTES14]:"RecsType.String",[e.BYTES15]:"RecsType.String",[e.BYTES16]:"RecsType.String",[e.BYTES17]:"RecsType.String",[e.BYTES18]:"RecsType.String",[e.BYTES19]:"RecsType.String",[e.BYTES20]:"RecsType.String",[e.BYTES21]:"RecsType.String",[e.BYTES22]:"RecsType.String",[e.BYTES23]:"RecsType.String",[e.BYTES24]:"RecsType.String",[e.BYTES25]:"RecsType.String",[e.BYTES26]:"RecsType.String",[e.BYTES27]:"RecsType.String",[e.BYTES28]:"RecsType.String",[e.BYTES29]:"RecsType.String",[e.BYTES30]:"RecsType.String",[e.BYTES31]:"RecsType.String",[e.BYTES32]:"RecsType.String",[e.BOOL]:"RecsType.Boolean",[e.ADDRESS]:"RecsType.String",[e.UINT8_ARRAY]:"RecsType.NumberArray",[e.UINT16_ARRAY]:"RecsType.NumberArray",[e.UINT24_ARRAY]:"RecsType.NumberArray",[e.UINT32_ARRAY]:"RecsType.NumberArray",[e.UINT40_ARRAY]:"RecsType.NumberArray",[e.UINT48_ARRAY]:"RecsType.NumberArray",[e.UINT56_ARRAY]:"RecsType.BigIntArray",[e.UINT64_ARRAY]:"RecsType.BigIntArray",[e.UINT72_ARRAY]:"RecsType.BigIntArray",[e.UINT80_ARRAY]:"RecsType.BigIntArray",[e.UINT88_ARRAY]:"RecsType.BigIntArray",[e.UINT96_ARRAY]:"RecsType.BigIntArray",[e.UINT104_ARRAY]:"RecsType.BigIntArray",[e.UINT112_ARRAY]:"RecsType.BigIntArray",[e.UINT120_ARRAY]:"RecsType.BigIntArray",[e.UINT128_ARRAY]:"RecsType.BigIntArray",[e.UINT136_ARRAY]:"RecsType.BigIntArray",[e.UINT144_ARRAY]:"RecsType.BigIntArray",[e.UINT152_ARRAY]:"RecsType.BigIntArray",[e.UINT160_ARRAY]:"RecsType.BigIntArray",[e.UINT168_ARRAY]:"RecsType.BigIntArray",[e.UINT176_ARRAY]:"RecsType.BigIntArray",[e.UINT184_ARRAY]:"RecsType.BigIntArray",[e.UINT192_ARRAY]:"RecsType.BigIntArray",[e.UINT200_ARRAY]:"RecsType.BigIntArray",[e.UINT208_ARRAY]:"RecsType.BigIntArray",[e.UINT216_ARRAY]:"RecsType.BigIntArray",[e.UINT224_ARRAY]:"RecsType.BigIntArray",[e.UINT232_ARRAY]:"RecsType.BigIntArray",[e.UINT240_ARRAY]:"RecsType.BigIntArray",[e.UINT248_ARRAY]:"RecsType.BigIntArray",[e.UINT256_ARRAY]:"RecsType.BigIntArray",[e.INT8_ARRAY]:"RecsType.NumberArray",[e.INT16_ARRAY]:"RecsType.NumberArray",[e.INT24_ARRAY]:"RecsType.NumberArray",[e.INT32_ARRAY]:"RecsType.NumberArray",[e.INT40_ARRAY]:"RecsType.NumberArray",[e.INT48_ARRAY]:"RecsType.NumberArray",[e.INT56_ARRAY]:"RecsType.BigIntArray",[e.INT64_ARRAY]:"RecsType.BigIntArray",[e.INT72_ARRAY]:"RecsType.BigIntArray",[e.INT80_ARRAY]:"RecsType.BigIntArray",[e.INT88_ARRAY]:"RecsType.BigIntArray",[e.INT96_ARRAY]:"RecsType.BigIntArray",[e.INT104_ARRAY]:"RecsType.BigIntArray",[e.INT112_ARRAY]:"RecsType.BigIntArray",[e.INT120_ARRAY]:"RecsType.BigIntArray",[e.INT128_ARRAY]:"RecsType.BigIntArray",[e.INT136_ARRAY]:"RecsType.BigIntArray",[e.INT144_ARRAY]:"RecsType.BigIntArray",[e.INT152_ARRAY]:"RecsType.BigIntArray",[e.INT160_ARRAY]:"RecsType.BigIntArray",[e.INT168_ARRAY]:"RecsType.BigIntArray",[e.INT176_ARRAY]:"RecsType.BigIntArray",[e.INT184_ARRAY]:"RecsType.BigIntArray",[e.INT192_ARRAY]:"RecsType.BigIntArray",[e.INT200_ARRAY]:"RecsType.BigIntArray",[e.INT208_ARRAY]:"RecsType.BigIntArray",[e.INT216_ARRAY]:"RecsType.BigIntArray",[e.INT224_ARRAY]:"RecsType.BigIntArray",[e.INT232_ARRAY]:"RecsType.BigIntArray",[e.INT240_ARRAY]:"RecsType.BigIntArray",[e.INT248_ARRAY]:"RecsType.BigIntArray",[e.INT256_ARRAY]:"RecsType.BigIntArray",[e.BYTES1_ARRAY]:"RecsType.StringArray",[e.BYTES2_ARRAY]:"RecsType.StringArray",[e.BYTES3_ARRAY]:"RecsType.StringArray",[e.BYTES4_ARRAY]:"RecsType.StringArray",[e.BYTES5_ARRAY]:"RecsType.StringArray",[e.BYTES6_ARRAY]:"RecsType.StringArray",[e.BYTES7_ARRAY]:"RecsType.StringArray",[e.BYTES8_ARRAY]:"RecsType.StringArray",[e.BYTES9_ARRAY]:"RecsType.StringArray",[e.BYTES10_ARRAY]:"RecsType.StringArray",[e.BYTES11_ARRAY]:"RecsType.StringArray",[e.BYTES12_ARRAY]:"RecsType.StringArray",[e.BYTES13_ARRAY]:"RecsType.StringArray",[e.BYTES14_ARRAY]:"RecsType.StringArray",[e.BYTES15_ARRAY]:"RecsType.StringArray",[e.BYTES16_ARRAY]:"RecsType.StringArray",[e.BYTES17_ARRAY]:"RecsType.StringArray",[e.BYTES18_ARRAY]:"RecsType.StringArray",[e.BYTES19_ARRAY]:"RecsType.StringArray",[e.BYTES20_ARRAY]:"RecsType.StringArray",[e.BYTES21_ARRAY]:"RecsType.StringArray",[e.BYTES22_ARRAY]:"RecsType.StringArray",[e.BYTES23_ARRAY]:"RecsType.StringArray",[e.BYTES24_ARRAY]:"RecsType.StringArray",[e.BYTES25_ARRAY]:"RecsType.StringArray",[e.BYTES26_ARRAY]:"RecsType.StringArray",[e.BYTES27_ARRAY]:"RecsType.StringArray",[e.BYTES28_ARRAY]:"RecsType.StringArray",[e.BYTES29_ARRAY]:"RecsType.StringArray",[e.BYTES30_ARRAY]:"RecsType.StringArray",[e.BYTES31_ARRAY]:"RecsType.StringArray",[e.BYTES32_ARRAY]:"RecsType.StringArray",[e.BOOL_ARRAY]:"RecsType.T",[e.ADDRESS_ARRAY]:"RecsType.StringArray",[e.BYTES]:"RecsType.String",[e.STRING]:"RecsType.String"};import{resolveAbiOrUserType as q}from"@latticexyz/store/codegen";import{SchemaTypeToAbiType as se}from"@latticexyz/schema-type/deprecated";function ie(n){let a=[];for(let i of Object.keys(n.tables)){let p=n.tables[i],u=Object.keys(p.schema).map(d=>{let A=p.schema[d],{schemaType:x}=q(A,n);return{recsTypeString:oe[x],name:d}});if(p.tableIdArgument)continue;let h={namespace:n.namespace,name:p.name},y=Object.fromEntries(Object.entries(p.keySchema).map(([d,A])=>[d,se[q(A,n).schemaType]])),D=Object.fromEntries(Object.entries(p.schema).map(([d,A])=>[d,se[q(A,n).schemaType]]));a.push({tableName:i,keySchema:y,valueSchema:D,fields:u,staticResourceData:h})}return{tables:a}}import{TableId as he}from"@latticexyz/common/deprecated";function ae(n){let{tables:a}=n;return`/* Autogenerated file. Do not edit manually. */
|
2
|
-
|
3
|
-
import { defineComponent, Type as RecsType, type World } from "@latticexyz/recs";
|
4
|
-
|
5
|
-
export function defineContractComponents(world: World) {
|
6
|
-
return {
|
7
|
-
${a.map(i=>`${i.tableName}: ${Ee(i)},`).join("")}
|
8
|
-
}
|
9
|
-
}
|
10
|
-
`}function Ee(n){let{namespace:a,name:i}=n.staticResourceData,p=new he(a,i);return`
|
11
|
-
defineComponent(world, {
|
12
|
-
${n.fields.map(({name:u,recsTypeString:h})=>`${u}: ${h}`).join(",")}
|
13
|
-
}, {
|
14
|
-
id: ${JSON.stringify(p.toHex())},
|
15
|
-
metadata: {
|
16
|
-
componentName: ${JSON.stringify(i)},
|
17
|
-
tableName: ${JSON.stringify([a,i].join(":"))},
|
18
|
-
keySchema: ${JSON.stringify(n.keySchema)},
|
19
|
-
valueSchema: ${JSON.stringify(n.valueSchema)},
|
20
|
-
},
|
21
|
-
} as const)
|
22
|
-
`}import Ue from"path";import{formatAndWriteTypescript as $e}from"@latticexyz/common/codegen";async function Rt(n,a){let i=Ue.join(a,"contractComponents.ts"),p=ie(n),u=ae(p);$e(u,i,"Generated ts definition files")}import F from"chalk";import z from"path";import{MUDError as Le}from"@latticexyz/common/errors";import{loadConfig as qe}from"@latticexyz/config/node";import{existsSync as Ce,readFileSync as De}from"fs";import ce from"path";import T from"chalk";import{ethers as O}from"ethers";import{defaultAbiCoder as Pe}from"ethers/lib/utils.js";import{getOutDirectory as Oe,getScriptDirectory as xe,cast as ve,forge as Fe}from"@latticexyz/common/foundry";import{resolveWithContext as je}from"@latticexyz/config";import{MUDError as Y}from"@latticexyz/common/errors";import{encodeSchema as ye}from"@latticexyz/schema-type/deprecated";import{resolveAbiOrUserType as pe}from"@latticexyz/store/codegen";import{resolveWorldConfig as ke}from"@latticexyz/world";import Me from"@latticexyz/world/abi/World.sol/World.json"assert{type:"json"};import Te from"@latticexyz/world/abi/IBaseWorld.sol/IBaseWorld.json"assert{type:"json"};import Re from"@latticexyz/world/abi/CoreModule.sol/CoreModule.json"assert{type:"json"};import le from"@latticexyz/world/abi/KeysWithValueModule.sol/KeysWithValueModule.json"assert{type:"json"};import ge from"@latticexyz/world/abi/KeysInTableModule.sol/KeysInTableModule.json"assert{type:"json"};import Ae from"@latticexyz/world/abi/UniqueEntityModule.sol/UniqueEntityModule.json"assert{type:"json"};import me from"@latticexyz/world/abi/SnapSyncModule.sol/SnapSyncModule.json"assert{type:"json"};async function ue(n,a,i){let p=ke(n,a),u=Date.now(),{worldContractName:h,namespace:y,postDeployScript:D}=n,{profile:d,rpc:A,privateKey:x,priorityFeeMultiplier:S,debug:E,worldAddress:U,disableTxWait:f,pollInterval:v}=i,Be=await Oe(d),M=new O.providers.StaticJsonRpcProvider(A);M.pollingInterval=v;let w=new O.Wallet(x,M);console.log("Deploying from",w.address);let $=await w.getTransactionCount();console.log("Initial nonce",$);let j,W,G;await L(S);let g=[],Q=Number(await ve(["block-number","--rpc-url",A],{profile:d}));console.log("Start deployment at block",Q);let Ne={World:U?Promise.resolve(U):h?K(h,f):C(Te.abi,Me.bytecode,f,"World")},be=Object.keys(p.systems).reduce((t,r)=>(t[r]=K(r,f),t),{}),X={CoreModule:C(Re.abi,Re.bytecode,f,"CoreModule"),KeysWithValueModule:C(le.abi,le.bytecode,f,"KeysWithValueModule"),KeysInTableModule:C(ge.abi,ge.bytecode,f,"KeysInTableModule"),UniqueEntityModule:C(Ae.abi,Ae.bytecode,f,"UniqueEntityModule"),SnapSyncModule:C(me.abi,me.bytecode,f,"SnapSyncModule")},Z=n.modules.filter(t=>!X[t.name]).reduce((t,r)=>(t[r.name]=K(r.name,f),t),X),P={...Ne,...be,...Z},N=new O.Contract(await P.World,Te.abi,w),b=f?0:1;U||(console.log(T.blue("Installing core World modules")),await B(N,"installRootModule",[await Z.CoreModule,"0x"],b),console.log(T.green("Installed core World modules"))),y&&await B(N,"registerNamespace",[m(y)],b);let ee={};g=[...g,...Object.entries(n.tables).map(async([t,{name:r,schema:o,keySchema:c}])=>{console.log(T.blue(`Registering table ${t} at ${y}/${r}`)),ee[t]=We(y,r);let l=Object.values(o).map(R=>{let{schemaType:I}=pe(R,n);return I}),s=Object.values(c).map(R=>{let{schemaType:I}=pe(R,n);return I});await B(N,"registerTable",[m(y),m(r),ye(l),ye(s)],b),await B(N,"setMetadata(bytes16,bytes16,string,string[])",[m(y),m(r),t,Object.keys(o)],b),console.log(T.green(`Registered table ${t} at ${r}`))})],g=[...g,...Object.entries(p.systems).map(async([t,{name:r,openAccess:o,registerFunctionSelectors:c}])=>{if(console.log(T.blue(`Registering system ${t} at ${y}/${r}`)),await B(N,"registerSystem",[m(y),m(r),await P[t],o],b),console.log(T.green(`Registered system ${t} at ${y}/${r}`)),c){let l=await Ye(t),s=y==="";await Promise.all(l.map(async({functionName:R,functionArgs:I})=>{let _=s?R+I:`${y}_${r}_${R}${I}`;if(console.log(T.blue(`Registering function "${_}"`)),s){let we=Ie(_===""?{functionName:t,functionArgs:I}:{functionName:R,functionArgs:I}),_e=Ie({functionName:R,functionArgs:I});await B(N,"registerRootFunctionSelector",[m(y),m(r),we,_e],b)}else await B(N,"registerFunctionSelector",[m(y),m(r),R,I],b);console.log(T.green(`Registered function "${_}"`))}))}})],await Promise.all(g),g=[];for(let[t,{name:r,accessListAddresses:o,accessListSystems:c}]of Object.entries(p.systems)){let l=`${y}/${r}`;g=[...g,...o.map(async s=>{console.log(T.blue(`Grant ${s} access to ${t} (${l})`)),await B(N,"grantAccess",[m(y),m(r),s],b),console.log(T.green(`Granted ${s} access to ${t} (${y}/${r})`))})],g=[...g,...c.map(async s=>{console.log(T.blue(`Grant ${s} access to ${t} (${l})`)),await B(N,"grantAccess",[m(y),m(r),await P[s]],b),console.log(T.green(`Granted ${s} access to ${t} (${l})`))})]}await Promise.all(g),g=[],g=[...g,...n.modules.map(async t=>{console.log(T.blue(`Installing${t.root?" root ":" "}module ${t.name}`));let r=await Promise.all(t.args.map(s=>je(s,{tableIds:ee,systemAddresses:P}))),o=r.map(s=>s.value),c=r.map(s=>s.type),l=await P[t.name];if(!l)throw new Error(`Module ${t.name} not found`);await B(N,t.root?"installRootModule":"installModule",[l,Pe.encode(c,o)],b),console.log(T.green(`Installed${t.root?" root ":" "}module ${t.name}`))})],await Promise.all(g);let k=await w.getTransactionCount(),V=0,te=100;for(;k!==$&&V<te;)console.log(T.gray(`Waiting for transactions to be included before executing ${D} (local nonce: ${$}, remote nonce: ${k}, retry number ${V}/${te})`)),await new Promise(t=>setTimeout(t,v)),V++,k=await w.getTransactionCount();if(k!==$)throw new Y("Remote nonce doesn't match local nonce, indicating that not all deploy transactions were included.");g=[];let J=ce.join(await xe(),D+".s.sol");return Ce(J)?(console.log(T.blue(`Executing post deploy script at ${J}`)),await Fe(["script",D,"--sig","run(address)",await P.World,"--broadcast","--rpc-url",A,"-vvv"],{profile:d})):console.log(`No script at ${J}, skipping post deploy hook`),console.log(T.green("Deployment completed in",(Date.now()-u)/1e3,"seconds")),{worldAddress:await P.World,blockNumber:Q};async function K(t,r){console.log(T.blue("Deploying",t));let{abi:o,bytecode:c}=await ne(t);return C(o,c,r,t)}async function C(t,r,o,c,l=0){try{let s=new O.ContractFactory(t,r,w);console.log(T.gray(`executing deployment of ${c} with nonce ${$}`));let R=s.deploy({nonce:$++,maxPriorityFeePerGas:j,maxFeePerGas:W,gasPrice:G}).then(_=>o?_:_.deployed());g.push(R);let{address:I}=await R;return console.log(T.green("Deployed",c,"to",I)),I}catch(s){if(E&&console.error(s),l===0&&s?.message.includes("transaction already imported"))return L(S*1.1),C(t,r,o,c,l++);throw s?.message.includes("invalid bytecode")?new Y(`Error deploying ${c}: invalid bytecode. Note that linking of public libraries is not supported yet, make sure none of your libraries use "external" functions.`):s?.message.includes("CreateContractLimit")?new Y(`Error deploying ${c}: CreateContractLimit exceeded.`):s}}async function Ye(t){let{abi:r}=await ne(t);return r.filter(o=>["fallback","function"].includes(o.type)).map(o=>o.type==="fallback"?{functionName:"",functionArgs:""}:{functionName:o.name,functionArgs:re(o.inputs)})}function re(t){return`(${t.map(o=>{let c=o.type.match(/tuple(.*)/);return c?re(o.components)+c[1]:o.type})})`}async function B(t,r,o,c=1,l=0){let s=`${r}(${o.map(R=>`'${R}'`).join(",")})`;try{let R=await t.estimateGas[r].apply(null,o);console.log(T.gray(`executing transaction: ${s} with nonce ${$}`));let I=t[r].apply(null,[...o,{gasLimit:R,nonce:$++,maxPriorityFeePerGas:j,maxFeePerGas:W,gasPrice:G}]).then(_=>c===0?_:_.wait(c));return g.push(I),I}catch(R){if(E&&console.error(R),l===0&&R?.message.includes("transaction already imported"))return L(S*1.1),B(t,r,o,c,l++);throw new Y(`Gas estimation error for ${s}: ${R?.reason}`)}}async function ne(t){let r,o=ce.join(Be,t+".sol",t+".json");try{r=JSON.parse(De(o,"utf8"))}catch{throw new Y(`Error reading file at ${o}`)}let c=r?.bytecode?.object;if(!c)throw new Y(`No bytecode found in ${o}`);let l=r?.abi;if(!l)throw new Y(`No ABI found in ${o}`);return{abi:l,bytecode:c}}async function L(t){let r=await M.getFeeData();if(r.lastBaseFeePerGas){if(!r.lastBaseFeePerGas.eq(0)&&(await w.getBalance()).eq(0))throw new Y(`Attempting to deploy to a chain with non-zero base fee with an account that has no balance.
|
23
|
-
If you're deploying to the Lattice testnet, you can fund your account by running 'pnpm mud faucet --address ${await w.getAddress()}'`);j=r.lastBaseFeePerGas.eq(0)?0:Math.floor(15e8*t),W=r.lastBaseFeePerGas.mul(2).add(j)}else if(r.gasPrice){if(!r.gasPrice.eq(0)&&(await w.getBalance()).eq(0))throw new Y("Attempting to deploy to a chain with non-zero gas price with an account that has no balance.");G=r.gasPrice}else throw new Y("Can not fetch fee data from RPC")}}function m(n){if(n.length>16)throw new Error("String does not fit into 16 bytes");let a=new Uint8Array(16);for(let i=0;i<n.length;i++)a[i]=n.charCodeAt(i);for(let i=n.length;i<16;i++)a[i]=0;return a}function We(n,a){let i=m(n),p=m(a),u=new Uint8Array(32);return u.set(i),u.set(p,16),u}function Ie({functionName:n,functionArgs:a}){let i=n+a;return i===""?"0x":Ge(i)}function Ge(n){return O.utils.hexDataSlice(O.utils.keccak256(O.utils.toUtf8Bytes(n)),0,4)}import{forge as Se,getRpcUrl as ze,getSrcDirectory as He}from"@latticexyz/common/foundry";import{existsSync as Qe,mkdirSync as Xe,readFileSync as Ze,writeFileSync as H}from"fs";import{ethers as Ve}from"ethers";async function de(n){let{result:a}=await Ve.utils.fetchJson(n,'{ "id": 42, "jsonrpc": "2.0", "method": "eth_chainId", "params": [ ] }');return Number(a)}import Je from"glob";import{basename as Ke}from"path";function fe(n){return Je.sync(`${n}/**/*.sol`).map(a=>({path:a,basename:Ke(a,".sol")}))}async function or(n){n.profile??=process.env.FOUNDRY_PROFILE;let{configPath:a,printConfig:i,profile:p,clean:u,skipBuild:h}=n,y=n.rpc??await ze(p);console.log(F.bgBlue(F.whiteBright(`
|
24
|
-
Deploying MUD contracts${p?" with profile "+p:""} to RPC ${y}
|
25
|
-
`))),u&&await Se(["clean"],{profile:p}),h||await Se(["build"],{profile:p});let D=n?.srcDir??await He(),d=fe(D).map(({basename:E})=>E),A=await qe(a);i&&console.log(F.green(`
|
26
|
-
Resolved config:
|
27
|
-
`),JSON.stringify(A,null,2));let x=process.env.PRIVATE_KEY;if(!x)throw new Le(`Missing PRIVATE_KEY environment variable.
|
28
|
-
Run 'echo "PRIVATE_KEY=0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80" > .env'
|
29
|
-
in your contracts directory to use the default anvil private key.`);let S=await ue(A,d,{...n,rpc:y,privateKey:x});if(n.saveDeployment){let E=await de(y),U=z.join(A.deploysDirectory,E.toString());Xe(U,{recursive:!0}),H(z.join(U,"latest.json"),JSON.stringify(S,null,2)),H(z.join(U,Date.now()+".json"),JSON.stringify(S,null,2));let f=[1337,31337],v=Qe(A.worldsFile)?JSON.parse(Ze(A.worldsFile,"utf-8")):{};v[E]={address:S.worldAddress,blockNumber:f.includes(E)?void 0:S.blockNumber},H(A.worldsFile,JSON.stringify(v,null,2)),console.log(F.bgGreen(F.whiteBright(`
|
30
|
-
Deployment result (written to ${A.worldsFile} and ${U}):
|
31
|
-
`)))}return console.log(S),S}export{oe as a,ie as b,ae as c,Rt as d,de as e,fe as f,or as g};
|
32
|
-
//# sourceMappingURL=chunk-P7JIR52V.js.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"sources":["../src/render-ts/schemaTypesToRecsTypeStrings.ts","../src/render-ts/recsV1TableOptions.ts","../src/render-ts/renderRecsV1Tables.ts","../src/render-ts/tsgen.ts","../src/utils/deployHandler.ts","../src/utils/deploy.ts","../src/utils/getChainId.ts","../src/utils/getExistingContracts.ts"],"sourcesContent":["import { SchemaType } from \"@latticexyz/schema-type/deprecated\";\n\nexport const schemaTypesToRecsTypeStrings: Record<SchemaType, string> = {\n [SchemaType.UINT8]: \"RecsType.Number\",\n [SchemaType.UINT16]: \"RecsType.Number\",\n [SchemaType.UINT24]: \"RecsType.Number\",\n [SchemaType.UINT32]: \"RecsType.Number\",\n [SchemaType.UINT40]: \"RecsType.Number\",\n [SchemaType.UINT48]: \"RecsType.Number\",\n [SchemaType.UINT56]: \"RecsType.BigInt\",\n [SchemaType.UINT64]: \"RecsType.BigInt\",\n [SchemaType.UINT72]: \"RecsType.BigInt\",\n [SchemaType.UINT80]: \"RecsType.BigInt\",\n [SchemaType.UINT88]: \"RecsType.BigInt\",\n [SchemaType.UINT96]: \"RecsType.BigInt\",\n [SchemaType.UINT104]: \"RecsType.BigInt\",\n [SchemaType.UINT112]: \"RecsType.BigInt\",\n [SchemaType.UINT120]: \"RecsType.BigInt\",\n [SchemaType.UINT128]: \"RecsType.BigInt\",\n [SchemaType.UINT136]: \"RecsType.BigInt\",\n [SchemaType.UINT144]: \"RecsType.BigInt\",\n [SchemaType.UINT152]: \"RecsType.BigInt\",\n [SchemaType.UINT160]: \"RecsType.BigInt\",\n [SchemaType.UINT168]: \"RecsType.BigInt\",\n [SchemaType.UINT176]: \"RecsType.BigInt\",\n [SchemaType.UINT184]: \"RecsType.BigInt\",\n [SchemaType.UINT192]: \"RecsType.BigInt\",\n [SchemaType.UINT200]: \"RecsType.BigInt\",\n [SchemaType.UINT208]: \"RecsType.BigInt\",\n [SchemaType.UINT216]: \"RecsType.BigInt\",\n [SchemaType.UINT224]: \"RecsType.BigInt\",\n [SchemaType.UINT232]: \"RecsType.BigInt\",\n [SchemaType.UINT240]: \"RecsType.BigInt\",\n [SchemaType.UINT248]: \"RecsType.BigInt\",\n [SchemaType.UINT256]: \"RecsType.BigInt\",\n [SchemaType.INT8]: \"RecsType.Number\",\n [SchemaType.INT16]: \"RecsType.Number\",\n [SchemaType.INT24]: \"RecsType.Number\",\n [SchemaType.INT32]: \"RecsType.Number\",\n [SchemaType.INT40]: \"RecsType.Number\",\n [SchemaType.INT48]: \"RecsType.Number\",\n [SchemaType.INT56]: \"RecsType.BigInt\",\n [SchemaType.INT64]: \"RecsType.BigInt\",\n [SchemaType.INT72]: \"RecsType.BigInt\",\n [SchemaType.INT80]: \"RecsType.BigInt\",\n [SchemaType.INT88]: \"RecsType.BigInt\",\n [SchemaType.INT96]: \"RecsType.BigInt\",\n [SchemaType.INT104]: \"RecsType.BigInt\",\n [SchemaType.INT112]: \"RecsType.BigInt\",\n [SchemaType.INT120]: \"RecsType.BigInt\",\n [SchemaType.INT128]: \"RecsType.BigInt\",\n [SchemaType.INT136]: \"RecsType.BigInt\",\n [SchemaType.INT144]: \"RecsType.BigInt\",\n [SchemaType.INT152]: \"RecsType.BigInt\",\n [SchemaType.INT160]: \"RecsType.BigInt\",\n [SchemaType.INT168]: \"RecsType.BigInt\",\n [SchemaType.INT176]: \"RecsType.BigInt\",\n [SchemaType.INT184]: \"RecsType.BigInt\",\n [SchemaType.INT192]: \"RecsType.BigInt\",\n [SchemaType.INT200]: \"RecsType.BigInt\",\n [SchemaType.INT208]: \"RecsType.BigInt\",\n [SchemaType.INT216]: \"RecsType.BigInt\",\n [SchemaType.INT224]: \"RecsType.BigInt\",\n [SchemaType.INT232]: \"RecsType.BigInt\",\n [SchemaType.INT240]: \"RecsType.BigInt\",\n [SchemaType.INT248]: \"RecsType.BigInt\",\n [SchemaType.INT256]: \"RecsType.BigInt\",\n [SchemaType.BYTES1]: \"RecsType.String\",\n [SchemaType.BYTES2]: \"RecsType.String\",\n [SchemaType.BYTES3]: \"RecsType.String\",\n [SchemaType.BYTES4]: \"RecsType.String\",\n [SchemaType.BYTES5]: \"RecsType.String\",\n [SchemaType.BYTES6]: \"RecsType.String\",\n [SchemaType.BYTES7]: \"RecsType.String\",\n [SchemaType.BYTES8]: \"RecsType.String\",\n [SchemaType.BYTES9]: \"RecsType.String\",\n [SchemaType.BYTES10]: \"RecsType.String\",\n [SchemaType.BYTES11]: \"RecsType.String\",\n [SchemaType.BYTES12]: \"RecsType.String\",\n [SchemaType.BYTES13]: \"RecsType.String\",\n [SchemaType.BYTES14]: \"RecsType.String\",\n [SchemaType.BYTES15]: \"RecsType.String\",\n [SchemaType.BYTES16]: \"RecsType.String\",\n [SchemaType.BYTES17]: \"RecsType.String\",\n [SchemaType.BYTES18]: \"RecsType.String\",\n [SchemaType.BYTES19]: \"RecsType.String\",\n [SchemaType.BYTES20]: \"RecsType.String\",\n [SchemaType.BYTES21]: \"RecsType.String\",\n [SchemaType.BYTES22]: \"RecsType.String\",\n [SchemaType.BYTES23]: \"RecsType.String\",\n [SchemaType.BYTES24]: \"RecsType.String\",\n [SchemaType.BYTES25]: \"RecsType.String\",\n [SchemaType.BYTES26]: \"RecsType.String\",\n [SchemaType.BYTES27]: \"RecsType.String\",\n [SchemaType.BYTES28]: \"RecsType.String\",\n [SchemaType.BYTES29]: \"RecsType.String\",\n [SchemaType.BYTES30]: \"RecsType.String\",\n [SchemaType.BYTES31]: \"RecsType.String\",\n [SchemaType.BYTES32]: \"RecsType.String\",\n [SchemaType.BOOL]: \"RecsType.Boolean\",\n [SchemaType.ADDRESS]: \"RecsType.String\",\n [SchemaType.UINT8_ARRAY]: \"RecsType.NumberArray\",\n [SchemaType.UINT16_ARRAY]: \"RecsType.NumberArray\",\n [SchemaType.UINT24_ARRAY]: \"RecsType.NumberArray\",\n [SchemaType.UINT32_ARRAY]: \"RecsType.NumberArray\",\n [SchemaType.UINT40_ARRAY]: \"RecsType.NumberArray\",\n [SchemaType.UINT48_ARRAY]: \"RecsType.NumberArray\",\n [SchemaType.UINT56_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.UINT64_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.UINT72_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.UINT80_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.UINT88_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.UINT96_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.UINT104_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.UINT112_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.UINT120_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.UINT128_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.UINT136_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.UINT144_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.UINT152_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.UINT160_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.UINT168_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.UINT176_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.UINT184_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.UINT192_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.UINT200_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.UINT208_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.UINT216_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.UINT224_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.UINT232_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.UINT240_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.UINT248_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.UINT256_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.INT8_ARRAY]: \"RecsType.NumberArray\",\n [SchemaType.INT16_ARRAY]: \"RecsType.NumberArray\",\n [SchemaType.INT24_ARRAY]: \"RecsType.NumberArray\",\n [SchemaType.INT32_ARRAY]: \"RecsType.NumberArray\",\n [SchemaType.INT40_ARRAY]: \"RecsType.NumberArray\",\n [SchemaType.INT48_ARRAY]: \"RecsType.NumberArray\",\n [SchemaType.INT56_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.INT64_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.INT72_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.INT80_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.INT88_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.INT96_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.INT104_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.INT112_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.INT120_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.INT128_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.INT136_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.INT144_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.INT152_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.INT160_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.INT168_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.INT176_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.INT184_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.INT192_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.INT200_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.INT208_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.INT216_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.INT224_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.INT232_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.INT240_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.INT248_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.INT256_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.BYTES1_ARRAY]: \"RecsType.StringArray\",\n [SchemaType.BYTES2_ARRAY]: \"RecsType.StringArray\",\n [SchemaType.BYTES3_ARRAY]: \"RecsType.StringArray\",\n [SchemaType.BYTES4_ARRAY]: \"RecsType.StringArray\",\n [SchemaType.BYTES5_ARRAY]: \"RecsType.StringArray\",\n [SchemaType.BYTES6_ARRAY]: \"RecsType.StringArray\",\n [SchemaType.BYTES7_ARRAY]: \"RecsType.StringArray\",\n [SchemaType.BYTES8_ARRAY]: \"RecsType.StringArray\",\n [SchemaType.BYTES9_ARRAY]: \"RecsType.StringArray\",\n [SchemaType.BYTES10_ARRAY]: \"RecsType.StringArray\",\n [SchemaType.BYTES11_ARRAY]: \"RecsType.StringArray\",\n [SchemaType.BYTES12_ARRAY]: \"RecsType.StringArray\",\n [SchemaType.BYTES13_ARRAY]: \"RecsType.StringArray\",\n [SchemaType.BYTES14_ARRAY]: \"RecsType.StringArray\",\n [SchemaType.BYTES15_ARRAY]: \"RecsType.StringArray\",\n [SchemaType.BYTES16_ARRAY]: \"RecsType.StringArray\",\n [SchemaType.BYTES17_ARRAY]: \"RecsType.StringArray\",\n [SchemaType.BYTES18_ARRAY]: \"RecsType.StringArray\",\n [SchemaType.BYTES19_ARRAY]: \"RecsType.StringArray\",\n [SchemaType.BYTES20_ARRAY]: \"RecsType.StringArray\",\n [SchemaType.BYTES21_ARRAY]: \"RecsType.StringArray\",\n [SchemaType.BYTES22_ARRAY]: \"RecsType.StringArray\",\n [SchemaType.BYTES23_ARRAY]: \"RecsType.StringArray\",\n [SchemaType.BYTES24_ARRAY]: \"RecsType.StringArray\",\n [SchemaType.BYTES25_ARRAY]: \"RecsType.StringArray\",\n [SchemaType.BYTES26_ARRAY]: \"RecsType.StringArray\",\n [SchemaType.BYTES27_ARRAY]: \"RecsType.StringArray\",\n [SchemaType.BYTES28_ARRAY]: \"RecsType.StringArray\",\n [SchemaType.BYTES29_ARRAY]: \"RecsType.StringArray\",\n [SchemaType.BYTES30_ARRAY]: \"RecsType.StringArray\",\n [SchemaType.BYTES31_ARRAY]: \"RecsType.StringArray\",\n [SchemaType.BYTES32_ARRAY]: \"RecsType.StringArray\",\n [SchemaType.BOOL_ARRAY]: \"RecsType.T\", // no boolean array\n [SchemaType.ADDRESS_ARRAY]: \"RecsType.StringArray\",\n [SchemaType.BYTES]: \"RecsType.String\",\n [SchemaType.STRING]: \"RecsType.String\",\n};\n","import { StoreConfig } from \"@latticexyz/store\";\nimport { resolveAbiOrUserType } from \"@latticexyz/store/codegen\";\nimport { schemaTypesToRecsTypeStrings } from \"./schemaTypesToRecsTypeStrings\";\nimport { RecsV1TableOptions } from \"./types\";\nimport { SchemaTypeToAbiType } from \"@latticexyz/schema-type/deprecated\";\nimport { StaticAbiType } from \"@latticexyz/schema-type\";\n\nexport function getRecsV1TableOptions(config: StoreConfig): RecsV1TableOptions {\n const tableOptions = [];\n for (const tableName of Object.keys(config.tables)) {\n const tableData = config.tables[tableName];\n\n const fields = Object.keys(tableData.schema).map((name) => {\n const abiOrUserType = tableData.schema[name];\n const { schemaType } = resolveAbiOrUserType(abiOrUserType, config);\n\n const recsTypeString = schemaTypesToRecsTypeStrings[schemaType];\n\n return {\n recsTypeString,\n name,\n };\n });\n\n // WARNING: skip tables without a static tableId\n if (tableData.tableIdArgument) continue;\n const staticResourceData = {\n namespace: config.namespace,\n name: tableData.name,\n };\n\n // TODO: move user type -> abi type into our config expanding step rather than sprinkled everywhere (https://github.com/latticexyz/mud/issues/1201)\n const keySchema = Object.fromEntries(\n Object.entries(tableData.keySchema).map(([name, type]) => [\n name,\n SchemaTypeToAbiType[resolveAbiOrUserType(type, config).schemaType] as StaticAbiType,\n ])\n );\n const valueSchema = Object.fromEntries(\n Object.entries(tableData.schema).map(([name, type]) => [\n name,\n SchemaTypeToAbiType[resolveAbiOrUserType(type, config).schemaType],\n ])\n );\n\n tableOptions.push({\n tableName,\n keySchema,\n valueSchema,\n fields,\n staticResourceData,\n });\n }\n return {\n tables: tableOptions,\n };\n}\n","import { TableId } from \"@latticexyz/common/deprecated\";\nimport { RecsV1TableOptions } from \"./types\";\n\nexport function renderRecsV1Tables(options: RecsV1TableOptions) {\n const { tables } = options;\n\n return `/* Autogenerated file. Do not edit manually. */\n\nimport { defineComponent, Type as RecsType, type World } from \"@latticexyz/recs\";\n\nexport function defineContractComponents(world: World) {\n return {\n ${tables.map((table) => `${table.tableName}: ${renderDefineComponent(table)},`).join(\"\")}\n }\n}\n`;\n}\n\nfunction renderDefineComponent(table: RecsV1TableOptions[\"tables\"][number]) {\n const { namespace, name } = table.staticResourceData;\n const tableId = new TableId(namespace, name);\n return `\n defineComponent(world, {\n ${table.fields.map(({ name, recsTypeString }) => `${name}: ${recsTypeString}`).join(\",\")}\n }, {\n id: ${JSON.stringify(tableId.toHex())},\n metadata: {\n componentName: ${JSON.stringify(name)},\n tableName: ${JSON.stringify([namespace, name].join(\":\"))},\n keySchema: ${JSON.stringify(table.keySchema)},\n valueSchema: ${JSON.stringify(table.valueSchema)},\n },\n } as const)\n `;\n}\n","import path from \"path\";\nimport { StoreConfig } from \"@latticexyz/store\";\nimport { formatAndWriteTypescript } from \"@latticexyz/common/codegen\";\nimport { getRecsV1TableOptions } from \"../render-ts/recsV1TableOptions\";\nimport { renderRecsV1Tables } from \"../render-ts/renderRecsV1Tables\";\n\nexport async function tsgen(config: StoreConfig, outDirectory: string) {\n const fullOutputPath = path.join(outDirectory, `contractComponents.ts`);\n const options = getRecsV1TableOptions(config);\n const output = renderRecsV1Tables(options);\n formatAndWriteTypescript(output, fullOutputPath, \"Generated ts definition files\");\n}\n","import chalk from \"chalk\";\nimport path from \"path\";\nimport { MUDError } from \"@latticexyz/common/errors\";\nimport { loadConfig } from \"@latticexyz/config/node\";\nimport { StoreConfig } from \"@latticexyz/store\";\nimport { WorldConfig } from \"@latticexyz/world\";\nimport { deploy } from \"../utils/deploy\";\nimport { forge, getRpcUrl, getSrcDirectory } from \"@latticexyz/common/foundry\";\nimport { existsSync, mkdirSync, readFileSync, writeFileSync } from \"fs\";\nimport { getChainId } from \"../utils/getChainId\";\nimport { getExistingContracts } from \"./getExistingContracts\";\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 pollInterval: number;\n skipBuild?: boolean;\n};\n\nexport async function deployHandler(args: DeployOptions) {\n args.profile ??= process.env.FOUNDRY_PROFILE;\n const { configPath, printConfig, profile, clean, skipBuild } = 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 if (!skipBuild) await forge([\"build\"], { profile });\n\n // Get a list of all contract names\n const srcDir = args?.srcDir ?? (await getSrcDirectory());\n const existingContractNames = getExistingContracts(srcDir).map(({ basename }) => basename);\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 const privateKey = process.env.PRIVATE_KEY;\n if (!privateKey)\n throw new MUDError(\n `Missing PRIVATE_KEY environment variable.\nRun 'echo \"PRIVATE_KEY=0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80\" > .env'\nin your contracts directory to use the default anvil private key.`\n );\n const deploymentInfo = await deploy(mudConfig, existingContractNames, { ...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(chalk.whiteBright(`\\n Deployment result (written to ${mudConfig.worldsFile} and ${outputDir}): \\n`))\n );\n }\n\n console.log(deploymentInfo);\n return deploymentInfo;\n}\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/deprecated\";\nimport { StoreConfig } from \"@latticexyz/store\";\nimport { resolveAbiOrUserType } from \"@latticexyz/store/codegen\";\nimport { WorldConfig, resolveWorldConfig } from \"@latticexyz/world\";\nimport { IBaseWorld } from \"@latticexyz/world/types/ethers-contracts/IBaseWorld\";\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\" };\nimport SnapSyncModuleData from \"@latticexyz/world/abi/SnapSyncModule.sol/SnapSyncModule.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 pollInterval: number;\n}\n\nexport interface DeploymentInfo {\n blockNumber: number;\n worldAddress: string;\n}\n\nexport async function deploy(\n mudConfig: StoreConfig & WorldConfig,\n existingContractNames: string[],\n deployConfig: DeployConfig\n): Promise<DeploymentInfo> {\n const resolvedConfig = resolveWorldConfig(mudConfig, existingContractNames);\n\n const startTime = Date.now();\n const { worldContractName, namespace, postDeployScript } = mudConfig;\n const { profile, rpc, privateKey, priorityFeeMultiplier, debug, worldAddress, disableTxWait, pollInterval } =\n deployConfig;\n const forgeOutDirectory = await getOutDirectory(profile);\n\n // Set up signer for deployment\n const provider = new ethers.providers.StaticJsonRpcProvider(rpc);\n provider.pollingInterval = pollInterval;\n const signer = new ethers.Wallet(privateKey, provider);\n console.log(\"Deploying from\", signer.address);\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 | undefined;\n let maxFeePerGas: BigNumber | undefined;\n let gasPrice: BigNumber | undefined;\n\n await 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 SnapSyncModule: deployContract(\n SnapSyncModuleData.abi,\n SnapSyncModuleData.bytecode,\n disableTxWait,\n \"SnapSyncModule\"\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, keySchema }]) => {\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(keySchema).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\n // Confirm the current nonce is the expected nonce to make sure all transactions have been included\n let remoteNonce = await signer.getTransactionCount();\n let retryCount = 0;\n const maxRetries = 100;\n while (remoteNonce !== nonce && retryCount < maxRetries) {\n console.log(\n chalk.gray(\n `Waiting for transactions to be included before executing ${postDeployScript} (local nonce: ${nonce}, remote nonce: ${remoteNonce}, retry number ${retryCount}/${maxRetries})`\n )\n );\n await new Promise((resolve) => setTimeout(resolve, pollInterval));\n retryCount++;\n remoteNonce = await signer.getTransactionCount();\n }\n if (remoteNonce !== nonce) {\n throw new MUDError(\n \"Remote nonce doesn't match local nonce, indicating that not all deploy transactions were included.\"\n );\n }\n\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 gasPrice,\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) => {\n const tupleMatch = param.type.match(/tuple(.*)/);\n if (tupleMatch) {\n // there can be arrays of tuples,\n // `tupleMatch[1]` preserves the array brackets (or is empty string for non-arrays)\n return parseComponents(param.components) + tupleMatch[1];\n } else {\n return param.type;\n }\n });\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, gasPrice }])\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\n if (feeData.lastBaseFeePerGas) {\n if (!feeData.lastBaseFeePerGas.eq(0) && (await signer.getBalance()).eq(0)) {\n throw new MUDError(`Attempting to deploy to a chain with non-zero base fee with an account that has no balance.\n If you're deploying to the Lattice testnet, you can fund your account by running 'pnpm mud faucet --address ${await signer.getAddress()}'`);\n }\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 } else if (feeData.gasPrice) {\n // Legacy chains with gasPrice instead of maxFeePerGas\n if (!feeData.gasPrice.eq(0) && (await signer.getBalance()).eq(0)) {\n throw new MUDError(\n `Attempting to deploy to a chain with non-zero gas price with an account that has no balance.`\n );\n }\n\n gasPrice = feeData.gasPrice;\n } else {\n throw new MUDError(\"Can not fetch fee data from RPC\");\n }\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 { 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 glob from \"glob\";\nimport { basename } from \"path\";\n\n/**\n * Get a list of all contract paths/names within the provided src directory\n */\nexport function getExistingContracts(srcDir: string) {\n return glob.sync(`${srcDir}/**/*.sol`).map((path) => ({\n path,\n basename: basename(path, \".sol\"),\n }));\n}\n"],"mappings":"AAAA,OAAS,cAAAA,MAAkB,qCAEpB,IAAMC,GAA2D,CACtE,CAACD,EAAW,KAAK,EAAG,kBACpB,CAACA,EAAW,MAAM,EAAG,kBACrB,CAACA,EAAW,MAAM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Aaf,EAAU,WAAY,OAAO,CAAC,EAAI,CAAC,EAC9Ga,EAAQP,CAAO,EAAI,CACjB,QAASF,EAAe,aAExB,YAAaQ,EAAY,SAASN,CAAO,EAAI,OAAYF,EAAe,WAC1E,EACAO,EAAcX,EAAU,WAAY,KAAK,UAAUa,EAAS,KAAM,CAAC,CAAC,EAEpE,QAAQ,IACNpB,EAAM,QAAQA,EAAM,YAAY;AAAA,iCAAoCO,EAAU,kBAAkBQ;AAAA,CAAgB,CAAC,CACnH,EAGF,eAAQ,IAAIJ,CAAc,EACnBA,CACT","names":["SchemaType","schemaTypesToRecsTypeStrings","resolveAbiOrUserType","SchemaTypeToAbiType","getRecsV1TableOptions","config","tableOptions","tableName","tableData","fields","name","abiOrUserType","schemaType","resolveAbiOrUserType","schemaTypesToRecsTypeStrings","staticResourceData","keySchema","type","valueSchema","TableId","renderRecsV1Tables","options","tables","table","renderDefineComponent","namespace","name","tableId","recsTypeString","path","formatAndWriteTypescript","tsgen","config","outDirectory","fullOutputPath","path","options","getRecsV1TableOptions","output","renderRecsV1Tables","formatAndWriteTypescript","chalk","path","MUDError","loadConfig","existsSync","readFileSync","path","chalk","ethers","abi","getOutDirectory","getScriptDirectory","cast","forge","resolveWithContext","MUDError","encodeSchema","resolveAbiOrUserType","resolveWorldConfig","WorldData","IBaseWorldData","CoreModuleData","KeysWithValueModuleData","KeysInTableModuleData","UniqueEntityModuleData","SnapSyncModuleData","deploy","mudConfig","existingContractNames","deployConfig","resolvedConfig","startTime","worldContractName","namespace","postDeployScript","profile","rpc","privateKey","priorityFeeMultiplier","debug","worldAddress","disableTxWait","pollInterval","forgeOutDirectory","provider","signer","nonce","maxPriorityFeePerGas","maxFeePerGas","gasPrice","setInternalFeePerGas","promises","blockNumber","worldPromise","deployContractByName","deployContract","systemPromises","acc","systemName","defaultModules","modulePromises","module","contractPromises","WorldContract","confirmations","fastTxExecute","toBytes16","tableIds","tableName","name","schema","keySchema","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","remoteNonce","retryCount","maxRetries","resolve","postDeployPath","contractName","bytecode","getContractData","factory","deployPromise","c","error","item","parseComponents","params","param","tupleMatch","contract","func","args","gasLimit","txPromise","tx","data","contractDataPath","multiplier","feeData","input","result","file","namespaceBytes","fileBytes","sigHash","signature","forge","getRpcUrl","getSrcDirectory","existsSync","mkdirSync","readFileSync","writeFileSync","ethers","getChainId","rpc","chainId","glob","basename","getExistingContracts","srcDir","path","deployHandler","args","configPath","printConfig","profile","clean","skipBuild","rpc","getRpcUrl","chalk","forge","srcDir","getSrcDirectory","existingContractNames","getExistingContracts","basename","mudConfig","loadConfig","privateKey","MUDError","deploymentInfo","deploy","chainId","getChainId","outputDir","path","mkdirSync","writeFileSync","localChains","deploys","existsSync","readFileSync"]}
|
package/src/commands/tsgen.ts
DELETED
@@ -1,34 +0,0 @@
|
|
1
|
-
import type { CommandModule } from "yargs";
|
2
|
-
import { loadConfig } from "@latticexyz/config/node";
|
3
|
-
import { StoreConfig } from "@latticexyz/store";
|
4
|
-
import { tsgen } from "../render-ts/tsgen";
|
5
|
-
|
6
|
-
type Options = {
|
7
|
-
configPath: string;
|
8
|
-
out: string;
|
9
|
-
};
|
10
|
-
|
11
|
-
const commandModule: CommandModule<Options, Options> = {
|
12
|
-
command: "tsgen",
|
13
|
-
|
14
|
-
describe: "Autogenerate MUD typescript definitions based on the config file",
|
15
|
-
|
16
|
-
builder(yargs) {
|
17
|
-
return yargs.options({
|
18
|
-
configPath: { type: "string", demandOption: true, desc: "Path to the config file" },
|
19
|
-
out: { type: "string", demandOption: true, desc: "Directory to output MUD typescript definition files" },
|
20
|
-
});
|
21
|
-
},
|
22
|
-
|
23
|
-
async handler(args) {
|
24
|
-
const { configPath, out } = args;
|
25
|
-
|
26
|
-
const config = (await loadConfig(configPath)) as StoreConfig;
|
27
|
-
|
28
|
-
await tsgen(config, out);
|
29
|
-
|
30
|
-
process.exit(0);
|
31
|
-
},
|
32
|
-
};
|
33
|
-
|
34
|
-
export default commandModule;
|
package/src/render-ts/index.ts
DELETED
@@ -1,57 +0,0 @@
|
|
1
|
-
import { StoreConfig } from "@latticexyz/store";
|
2
|
-
import { resolveAbiOrUserType } from "@latticexyz/store/codegen";
|
3
|
-
import { schemaTypesToRecsTypeStrings } from "./schemaTypesToRecsTypeStrings";
|
4
|
-
import { RecsV1TableOptions } from "./types";
|
5
|
-
import { SchemaTypeToAbiType } from "@latticexyz/schema-type/deprecated";
|
6
|
-
import { StaticAbiType } from "@latticexyz/schema-type";
|
7
|
-
|
8
|
-
export function getRecsV1TableOptions(config: StoreConfig): RecsV1TableOptions {
|
9
|
-
const tableOptions = [];
|
10
|
-
for (const tableName of Object.keys(config.tables)) {
|
11
|
-
const tableData = config.tables[tableName];
|
12
|
-
|
13
|
-
const fields = Object.keys(tableData.schema).map((name) => {
|
14
|
-
const abiOrUserType = tableData.schema[name];
|
15
|
-
const { schemaType } = resolveAbiOrUserType(abiOrUserType, config);
|
16
|
-
|
17
|
-
const recsTypeString = schemaTypesToRecsTypeStrings[schemaType];
|
18
|
-
|
19
|
-
return {
|
20
|
-
recsTypeString,
|
21
|
-
name,
|
22
|
-
};
|
23
|
-
});
|
24
|
-
|
25
|
-
// WARNING: skip tables without a static tableId
|
26
|
-
if (tableData.tableIdArgument) continue;
|
27
|
-
const staticResourceData = {
|
28
|
-
namespace: config.namespace,
|
29
|
-
name: tableData.name,
|
30
|
-
};
|
31
|
-
|
32
|
-
// TODO: move user type -> abi type into our config expanding step rather than sprinkled everywhere (https://github.com/latticexyz/mud/issues/1201)
|
33
|
-
const keySchema = Object.fromEntries(
|
34
|
-
Object.entries(tableData.keySchema).map(([name, type]) => [
|
35
|
-
name,
|
36
|
-
SchemaTypeToAbiType[resolveAbiOrUserType(type, config).schemaType] as StaticAbiType,
|
37
|
-
])
|
38
|
-
);
|
39
|
-
const valueSchema = Object.fromEntries(
|
40
|
-
Object.entries(tableData.schema).map(([name, type]) => [
|
41
|
-
name,
|
42
|
-
SchemaTypeToAbiType[resolveAbiOrUserType(type, config).schemaType],
|
43
|
-
])
|
44
|
-
);
|
45
|
-
|
46
|
-
tableOptions.push({
|
47
|
-
tableName,
|
48
|
-
keySchema,
|
49
|
-
valueSchema,
|
50
|
-
fields,
|
51
|
-
staticResourceData,
|
52
|
-
});
|
53
|
-
}
|
54
|
-
return {
|
55
|
-
tables: tableOptions,
|
56
|
-
};
|
57
|
-
}
|
@@ -1,35 +0,0 @@
|
|
1
|
-
import { TableId } from "@latticexyz/common/deprecated";
|
2
|
-
import { RecsV1TableOptions } from "./types";
|
3
|
-
|
4
|
-
export function renderRecsV1Tables(options: RecsV1TableOptions) {
|
5
|
-
const { tables } = options;
|
6
|
-
|
7
|
-
return `/* Autogenerated file. Do not edit manually. */
|
8
|
-
|
9
|
-
import { defineComponent, Type as RecsType, type World } from "@latticexyz/recs";
|
10
|
-
|
11
|
-
export function defineContractComponents(world: World) {
|
12
|
-
return {
|
13
|
-
${tables.map((table) => `${table.tableName}: ${renderDefineComponent(table)},`).join("")}
|
14
|
-
}
|
15
|
-
}
|
16
|
-
`;
|
17
|
-
}
|
18
|
-
|
19
|
-
function renderDefineComponent(table: RecsV1TableOptions["tables"][number]) {
|
20
|
-
const { namespace, name } = table.staticResourceData;
|
21
|
-
const tableId = new TableId(namespace, name);
|
22
|
-
return `
|
23
|
-
defineComponent(world, {
|
24
|
-
${table.fields.map(({ name, recsTypeString }) => `${name}: ${recsTypeString}`).join(",")}
|
25
|
-
}, {
|
26
|
-
id: ${JSON.stringify(tableId.toHex())},
|
27
|
-
metadata: {
|
28
|
-
componentName: ${JSON.stringify(name)},
|
29
|
-
tableName: ${JSON.stringify([namespace, name].join(":"))},
|
30
|
-
keySchema: ${JSON.stringify(table.keySchema)},
|
31
|
-
valueSchema: ${JSON.stringify(table.valueSchema)},
|
32
|
-
},
|
33
|
-
} as const)
|
34
|
-
`;
|
35
|
-
}
|
@@ -1,202 +0,0 @@
|
|
1
|
-
import { SchemaType } from "@latticexyz/schema-type/deprecated";
|
2
|
-
|
3
|
-
export const schemaTypesToRecsTypeStrings: Record<SchemaType, string> = {
|
4
|
-
[SchemaType.UINT8]: "RecsType.Number",
|
5
|
-
[SchemaType.UINT16]: "RecsType.Number",
|
6
|
-
[SchemaType.UINT24]: "RecsType.Number",
|
7
|
-
[SchemaType.UINT32]: "RecsType.Number",
|
8
|
-
[SchemaType.UINT40]: "RecsType.Number",
|
9
|
-
[SchemaType.UINT48]: "RecsType.Number",
|
10
|
-
[SchemaType.UINT56]: "RecsType.BigInt",
|
11
|
-
[SchemaType.UINT64]: "RecsType.BigInt",
|
12
|
-
[SchemaType.UINT72]: "RecsType.BigInt",
|
13
|
-
[SchemaType.UINT80]: "RecsType.BigInt",
|
14
|
-
[SchemaType.UINT88]: "RecsType.BigInt",
|
15
|
-
[SchemaType.UINT96]: "RecsType.BigInt",
|
16
|
-
[SchemaType.UINT104]: "RecsType.BigInt",
|
17
|
-
[SchemaType.UINT112]: "RecsType.BigInt",
|
18
|
-
[SchemaType.UINT120]: "RecsType.BigInt",
|
19
|
-
[SchemaType.UINT128]: "RecsType.BigInt",
|
20
|
-
[SchemaType.UINT136]: "RecsType.BigInt",
|
21
|
-
[SchemaType.UINT144]: "RecsType.BigInt",
|
22
|
-
[SchemaType.UINT152]: "RecsType.BigInt",
|
23
|
-
[SchemaType.UINT160]: "RecsType.BigInt",
|
24
|
-
[SchemaType.UINT168]: "RecsType.BigInt",
|
25
|
-
[SchemaType.UINT176]: "RecsType.BigInt",
|
26
|
-
[SchemaType.UINT184]: "RecsType.BigInt",
|
27
|
-
[SchemaType.UINT192]: "RecsType.BigInt",
|
28
|
-
[SchemaType.UINT200]: "RecsType.BigInt",
|
29
|
-
[SchemaType.UINT208]: "RecsType.BigInt",
|
30
|
-
[SchemaType.UINT216]: "RecsType.BigInt",
|
31
|
-
[SchemaType.UINT224]: "RecsType.BigInt",
|
32
|
-
[SchemaType.UINT232]: "RecsType.BigInt",
|
33
|
-
[SchemaType.UINT240]: "RecsType.BigInt",
|
34
|
-
[SchemaType.UINT248]: "RecsType.BigInt",
|
35
|
-
[SchemaType.UINT256]: "RecsType.BigInt",
|
36
|
-
[SchemaType.INT8]: "RecsType.Number",
|
37
|
-
[SchemaType.INT16]: "RecsType.Number",
|
38
|
-
[SchemaType.INT24]: "RecsType.Number",
|
39
|
-
[SchemaType.INT32]: "RecsType.Number",
|
40
|
-
[SchemaType.INT40]: "RecsType.Number",
|
41
|
-
[SchemaType.INT48]: "RecsType.Number",
|
42
|
-
[SchemaType.INT56]: "RecsType.BigInt",
|
43
|
-
[SchemaType.INT64]: "RecsType.BigInt",
|
44
|
-
[SchemaType.INT72]: "RecsType.BigInt",
|
45
|
-
[SchemaType.INT80]: "RecsType.BigInt",
|
46
|
-
[SchemaType.INT88]: "RecsType.BigInt",
|
47
|
-
[SchemaType.INT96]: "RecsType.BigInt",
|
48
|
-
[SchemaType.INT104]: "RecsType.BigInt",
|
49
|
-
[SchemaType.INT112]: "RecsType.BigInt",
|
50
|
-
[SchemaType.INT120]: "RecsType.BigInt",
|
51
|
-
[SchemaType.INT128]: "RecsType.BigInt",
|
52
|
-
[SchemaType.INT136]: "RecsType.BigInt",
|
53
|
-
[SchemaType.INT144]: "RecsType.BigInt",
|
54
|
-
[SchemaType.INT152]: "RecsType.BigInt",
|
55
|
-
[SchemaType.INT160]: "RecsType.BigInt",
|
56
|
-
[SchemaType.INT168]: "RecsType.BigInt",
|
57
|
-
[SchemaType.INT176]: "RecsType.BigInt",
|
58
|
-
[SchemaType.INT184]: "RecsType.BigInt",
|
59
|
-
[SchemaType.INT192]: "RecsType.BigInt",
|
60
|
-
[SchemaType.INT200]: "RecsType.BigInt",
|
61
|
-
[SchemaType.INT208]: "RecsType.BigInt",
|
62
|
-
[SchemaType.INT216]: "RecsType.BigInt",
|
63
|
-
[SchemaType.INT224]: "RecsType.BigInt",
|
64
|
-
[SchemaType.INT232]: "RecsType.BigInt",
|
65
|
-
[SchemaType.INT240]: "RecsType.BigInt",
|
66
|
-
[SchemaType.INT248]: "RecsType.BigInt",
|
67
|
-
[SchemaType.INT256]: "RecsType.BigInt",
|
68
|
-
[SchemaType.BYTES1]: "RecsType.String",
|
69
|
-
[SchemaType.BYTES2]: "RecsType.String",
|
70
|
-
[SchemaType.BYTES3]: "RecsType.String",
|
71
|
-
[SchemaType.BYTES4]: "RecsType.String",
|
72
|
-
[SchemaType.BYTES5]: "RecsType.String",
|
73
|
-
[SchemaType.BYTES6]: "RecsType.String",
|
74
|
-
[SchemaType.BYTES7]: "RecsType.String",
|
75
|
-
[SchemaType.BYTES8]: "RecsType.String",
|
76
|
-
[SchemaType.BYTES9]: "RecsType.String",
|
77
|
-
[SchemaType.BYTES10]: "RecsType.String",
|
78
|
-
[SchemaType.BYTES11]: "RecsType.String",
|
79
|
-
[SchemaType.BYTES12]: "RecsType.String",
|
80
|
-
[SchemaType.BYTES13]: "RecsType.String",
|
81
|
-
[SchemaType.BYTES14]: "RecsType.String",
|
82
|
-
[SchemaType.BYTES15]: "RecsType.String",
|
83
|
-
[SchemaType.BYTES16]: "RecsType.String",
|
84
|
-
[SchemaType.BYTES17]: "RecsType.String",
|
85
|
-
[SchemaType.BYTES18]: "RecsType.String",
|
86
|
-
[SchemaType.BYTES19]: "RecsType.String",
|
87
|
-
[SchemaType.BYTES20]: "RecsType.String",
|
88
|
-
[SchemaType.BYTES21]: "RecsType.String",
|
89
|
-
[SchemaType.BYTES22]: "RecsType.String",
|
90
|
-
[SchemaType.BYTES23]: "RecsType.String",
|
91
|
-
[SchemaType.BYTES24]: "RecsType.String",
|
92
|
-
[SchemaType.BYTES25]: "RecsType.String",
|
93
|
-
[SchemaType.BYTES26]: "RecsType.String",
|
94
|
-
[SchemaType.BYTES27]: "RecsType.String",
|
95
|
-
[SchemaType.BYTES28]: "RecsType.String",
|
96
|
-
[SchemaType.BYTES29]: "RecsType.String",
|
97
|
-
[SchemaType.BYTES30]: "RecsType.String",
|
98
|
-
[SchemaType.BYTES31]: "RecsType.String",
|
99
|
-
[SchemaType.BYTES32]: "RecsType.String",
|
100
|
-
[SchemaType.BOOL]: "RecsType.Boolean",
|
101
|
-
[SchemaType.ADDRESS]: "RecsType.String",
|
102
|
-
[SchemaType.UINT8_ARRAY]: "RecsType.NumberArray",
|
103
|
-
[SchemaType.UINT16_ARRAY]: "RecsType.NumberArray",
|
104
|
-
[SchemaType.UINT24_ARRAY]: "RecsType.NumberArray",
|
105
|
-
[SchemaType.UINT32_ARRAY]: "RecsType.NumberArray",
|
106
|
-
[SchemaType.UINT40_ARRAY]: "RecsType.NumberArray",
|
107
|
-
[SchemaType.UINT48_ARRAY]: "RecsType.NumberArray",
|
108
|
-
[SchemaType.UINT56_ARRAY]: "RecsType.BigIntArray",
|
109
|
-
[SchemaType.UINT64_ARRAY]: "RecsType.BigIntArray",
|
110
|
-
[SchemaType.UINT72_ARRAY]: "RecsType.BigIntArray",
|
111
|
-
[SchemaType.UINT80_ARRAY]: "RecsType.BigIntArray",
|
112
|
-
[SchemaType.UINT88_ARRAY]: "RecsType.BigIntArray",
|
113
|
-
[SchemaType.UINT96_ARRAY]: "RecsType.BigIntArray",
|
114
|
-
[SchemaType.UINT104_ARRAY]: "RecsType.BigIntArray",
|
115
|
-
[SchemaType.UINT112_ARRAY]: "RecsType.BigIntArray",
|
116
|
-
[SchemaType.UINT120_ARRAY]: "RecsType.BigIntArray",
|
117
|
-
[SchemaType.UINT128_ARRAY]: "RecsType.BigIntArray",
|
118
|
-
[SchemaType.UINT136_ARRAY]: "RecsType.BigIntArray",
|
119
|
-
[SchemaType.UINT144_ARRAY]: "RecsType.BigIntArray",
|
120
|
-
[SchemaType.UINT152_ARRAY]: "RecsType.BigIntArray",
|
121
|
-
[SchemaType.UINT160_ARRAY]: "RecsType.BigIntArray",
|
122
|
-
[SchemaType.UINT168_ARRAY]: "RecsType.BigIntArray",
|
123
|
-
[SchemaType.UINT176_ARRAY]: "RecsType.BigIntArray",
|
124
|
-
[SchemaType.UINT184_ARRAY]: "RecsType.BigIntArray",
|
125
|
-
[SchemaType.UINT192_ARRAY]: "RecsType.BigIntArray",
|
126
|
-
[SchemaType.UINT200_ARRAY]: "RecsType.BigIntArray",
|
127
|
-
[SchemaType.UINT208_ARRAY]: "RecsType.BigIntArray",
|
128
|
-
[SchemaType.UINT216_ARRAY]: "RecsType.BigIntArray",
|
129
|
-
[SchemaType.UINT224_ARRAY]: "RecsType.BigIntArray",
|
130
|
-
[SchemaType.UINT232_ARRAY]: "RecsType.BigIntArray",
|
131
|
-
[SchemaType.UINT240_ARRAY]: "RecsType.BigIntArray",
|
132
|
-
[SchemaType.UINT248_ARRAY]: "RecsType.BigIntArray",
|
133
|
-
[SchemaType.UINT256_ARRAY]: "RecsType.BigIntArray",
|
134
|
-
[SchemaType.INT8_ARRAY]: "RecsType.NumberArray",
|
135
|
-
[SchemaType.INT16_ARRAY]: "RecsType.NumberArray",
|
136
|
-
[SchemaType.INT24_ARRAY]: "RecsType.NumberArray",
|
137
|
-
[SchemaType.INT32_ARRAY]: "RecsType.NumberArray",
|
138
|
-
[SchemaType.INT40_ARRAY]: "RecsType.NumberArray",
|
139
|
-
[SchemaType.INT48_ARRAY]: "RecsType.NumberArray",
|
140
|
-
[SchemaType.INT56_ARRAY]: "RecsType.BigIntArray",
|
141
|
-
[SchemaType.INT64_ARRAY]: "RecsType.BigIntArray",
|
142
|
-
[SchemaType.INT72_ARRAY]: "RecsType.BigIntArray",
|
143
|
-
[SchemaType.INT80_ARRAY]: "RecsType.BigIntArray",
|
144
|
-
[SchemaType.INT88_ARRAY]: "RecsType.BigIntArray",
|
145
|
-
[SchemaType.INT96_ARRAY]: "RecsType.BigIntArray",
|
146
|
-
[SchemaType.INT104_ARRAY]: "RecsType.BigIntArray",
|
147
|
-
[SchemaType.INT112_ARRAY]: "RecsType.BigIntArray",
|
148
|
-
[SchemaType.INT120_ARRAY]: "RecsType.BigIntArray",
|
149
|
-
[SchemaType.INT128_ARRAY]: "RecsType.BigIntArray",
|
150
|
-
[SchemaType.INT136_ARRAY]: "RecsType.BigIntArray",
|
151
|
-
[SchemaType.INT144_ARRAY]: "RecsType.BigIntArray",
|
152
|
-
[SchemaType.INT152_ARRAY]: "RecsType.BigIntArray",
|
153
|
-
[SchemaType.INT160_ARRAY]: "RecsType.BigIntArray",
|
154
|
-
[SchemaType.INT168_ARRAY]: "RecsType.BigIntArray",
|
155
|
-
[SchemaType.INT176_ARRAY]: "RecsType.BigIntArray",
|
156
|
-
[SchemaType.INT184_ARRAY]: "RecsType.BigIntArray",
|
157
|
-
[SchemaType.INT192_ARRAY]: "RecsType.BigIntArray",
|
158
|
-
[SchemaType.INT200_ARRAY]: "RecsType.BigIntArray",
|
159
|
-
[SchemaType.INT208_ARRAY]: "RecsType.BigIntArray",
|
160
|
-
[SchemaType.INT216_ARRAY]: "RecsType.BigIntArray",
|
161
|
-
[SchemaType.INT224_ARRAY]: "RecsType.BigIntArray",
|
162
|
-
[SchemaType.INT232_ARRAY]: "RecsType.BigIntArray",
|
163
|
-
[SchemaType.INT240_ARRAY]: "RecsType.BigIntArray",
|
164
|
-
[SchemaType.INT248_ARRAY]: "RecsType.BigIntArray",
|
165
|
-
[SchemaType.INT256_ARRAY]: "RecsType.BigIntArray",
|
166
|
-
[SchemaType.BYTES1_ARRAY]: "RecsType.StringArray",
|
167
|
-
[SchemaType.BYTES2_ARRAY]: "RecsType.StringArray",
|
168
|
-
[SchemaType.BYTES3_ARRAY]: "RecsType.StringArray",
|
169
|
-
[SchemaType.BYTES4_ARRAY]: "RecsType.StringArray",
|
170
|
-
[SchemaType.BYTES5_ARRAY]: "RecsType.StringArray",
|
171
|
-
[SchemaType.BYTES6_ARRAY]: "RecsType.StringArray",
|
172
|
-
[SchemaType.BYTES7_ARRAY]: "RecsType.StringArray",
|
173
|
-
[SchemaType.BYTES8_ARRAY]: "RecsType.StringArray",
|
174
|
-
[SchemaType.BYTES9_ARRAY]: "RecsType.StringArray",
|
175
|
-
[SchemaType.BYTES10_ARRAY]: "RecsType.StringArray",
|
176
|
-
[SchemaType.BYTES11_ARRAY]: "RecsType.StringArray",
|
177
|
-
[SchemaType.BYTES12_ARRAY]: "RecsType.StringArray",
|
178
|
-
[SchemaType.BYTES13_ARRAY]: "RecsType.StringArray",
|
179
|
-
[SchemaType.BYTES14_ARRAY]: "RecsType.StringArray",
|
180
|
-
[SchemaType.BYTES15_ARRAY]: "RecsType.StringArray",
|
181
|
-
[SchemaType.BYTES16_ARRAY]: "RecsType.StringArray",
|
182
|
-
[SchemaType.BYTES17_ARRAY]: "RecsType.StringArray",
|
183
|
-
[SchemaType.BYTES18_ARRAY]: "RecsType.StringArray",
|
184
|
-
[SchemaType.BYTES19_ARRAY]: "RecsType.StringArray",
|
185
|
-
[SchemaType.BYTES20_ARRAY]: "RecsType.StringArray",
|
186
|
-
[SchemaType.BYTES21_ARRAY]: "RecsType.StringArray",
|
187
|
-
[SchemaType.BYTES22_ARRAY]: "RecsType.StringArray",
|
188
|
-
[SchemaType.BYTES23_ARRAY]: "RecsType.StringArray",
|
189
|
-
[SchemaType.BYTES24_ARRAY]: "RecsType.StringArray",
|
190
|
-
[SchemaType.BYTES25_ARRAY]: "RecsType.StringArray",
|
191
|
-
[SchemaType.BYTES26_ARRAY]: "RecsType.StringArray",
|
192
|
-
[SchemaType.BYTES27_ARRAY]: "RecsType.StringArray",
|
193
|
-
[SchemaType.BYTES28_ARRAY]: "RecsType.StringArray",
|
194
|
-
[SchemaType.BYTES29_ARRAY]: "RecsType.StringArray",
|
195
|
-
[SchemaType.BYTES30_ARRAY]: "RecsType.StringArray",
|
196
|
-
[SchemaType.BYTES31_ARRAY]: "RecsType.StringArray",
|
197
|
-
[SchemaType.BYTES32_ARRAY]: "RecsType.StringArray",
|
198
|
-
[SchemaType.BOOL_ARRAY]: "RecsType.T", // no boolean array
|
199
|
-
[SchemaType.ADDRESS_ARRAY]: "RecsType.StringArray",
|
200
|
-
[SchemaType.BYTES]: "RecsType.String",
|
201
|
-
[SchemaType.STRING]: "RecsType.String",
|
202
|
-
};
|
package/src/render-ts/tsgen.ts
DELETED
@@ -1,12 +0,0 @@
|
|
1
|
-
import path from "path";
|
2
|
-
import { StoreConfig } from "@latticexyz/store";
|
3
|
-
import { formatAndWriteTypescript } from "@latticexyz/common/codegen";
|
4
|
-
import { getRecsV1TableOptions } from "../render-ts/recsV1TableOptions";
|
5
|
-
import { renderRecsV1Tables } from "../render-ts/renderRecsV1Tables";
|
6
|
-
|
7
|
-
export async function tsgen(config: StoreConfig, outDirectory: string) {
|
8
|
-
const fullOutputPath = path.join(outDirectory, `contractComponents.ts`);
|
9
|
-
const options = getRecsV1TableOptions(config);
|
10
|
-
const output = renderRecsV1Tables(options);
|
11
|
-
formatAndWriteTypescript(output, fullOutputPath, "Generated ts definition files");
|
12
|
-
}
|
package/src/render-ts/types.ts
DELETED
@@ -1,17 +0,0 @@
|
|
1
|
-
import { SchemaAbiType, StaticAbiType } from "@latticexyz/schema-type";
|
2
|
-
|
3
|
-
export interface RecsV1TableOptions {
|
4
|
-
tables: {
|
5
|
-
tableName: string;
|
6
|
-
keySchema: Record<string, StaticAbiType>;
|
7
|
-
valueSchema: Record<string, SchemaAbiType>;
|
8
|
-
fields: {
|
9
|
-
recsTypeString: string;
|
10
|
-
name: string;
|
11
|
-
}[];
|
12
|
-
staticResourceData: {
|
13
|
-
namespace: string;
|
14
|
-
name: string;
|
15
|
-
};
|
16
|
-
}[];
|
17
|
-
}
|