@latticexyz/common 3.0.0-main-fb1cfef0c → 3.0.0-main-69eb63b59

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/codegen.d.ts CHANGED
@@ -93,7 +93,10 @@ declare function renderCommonData({ staticResourceData, keyTuple, }: {
93
93
  staticResourceData?: StaticResourceData;
94
94
  keyTuple: RenderKeyTuple[];
95
95
  }): RenderedCommonData;
96
- /** For 2 paths which are relative to a common root, create a relative import path from one to another */
96
+ /**
97
+ * For 2 paths which are relative to a common root, create a relative import path from one to another
98
+ * @deprecated Use `renderImportPath` instead.
99
+ */
97
100
  declare function solidityRelativeImportPath(fromPath: string, usedInPath: string): string;
98
101
  /**
99
102
  * Aggregates, deduplicates and renders imports for symbols per path.
@@ -165,6 +168,8 @@ type Enums = {
165
168
  */
166
169
  declare function renderEnums(enums: Enums): string;
167
170
 
171
+ declare function renderImportPath(basePath: string, ...segments: readonly string[]): string;
172
+
168
173
  /**
169
174
  * Renders the necessary helper functions to typecast to/from the types of given fields and keys
170
175
  */
@@ -272,4 +277,4 @@ declare function loadAndExtractUserTypes(userTypes: Record<string, UserType>, ou
272
277
  */
273
278
  declare function posixPath(path: string): string;
274
279
 
275
- export { AbsoluteImportDatum, ContractInterfaceError, ContractInterfaceFunction, ImportDatum, RelativeImportDatum, RenderDynamicField, RenderEnum, RenderField, RenderFieldTypeWrappingData, RenderKeyTuple, RenderStaticField, RenderType, SolidityUserDefinedType, StaticResourceData, UserType, contractToInterface, extractUserTypes, formatAndWriteSolidity, formatAndWriteTypescript, formatSolidity, formatTypescript, getLeftPaddingBits, isLeftAligned, loadAndExtractUserTypes, posixPath, renderAbsoluteImports, renderArguments, renderCommonData, renderEnums, renderImports, renderList, renderRelativeImports, renderTableId, renderTypeHelpers, renderValueTypeToBytes32, renderWithFieldSuffix, renderWithStore, renderedSolidityHeader, schemaTypesToRecsTypeStrings, solidityRelativeImportPath };
280
+ export { AbsoluteImportDatum, ContractInterfaceError, ContractInterfaceFunction, ImportDatum, RelativeImportDatum, RenderDynamicField, RenderEnum, RenderField, RenderFieldTypeWrappingData, RenderKeyTuple, RenderStaticField, RenderType, SolidityUserDefinedType, StaticResourceData, UserType, contractToInterface, extractUserTypes, formatAndWriteSolidity, formatAndWriteTypescript, formatSolidity, formatTypescript, getLeftPaddingBits, isLeftAligned, loadAndExtractUserTypes, posixPath, renderAbsoluteImports, renderArguments, renderCommonData, renderEnums, renderImportPath, renderImports, renderList, renderRelativeImports, renderTableId, renderTypeHelpers, renderValueTypeToBytes32, renderWithFieldSuffix, renderWithStore, renderedSolidityHeader, schemaTypesToRecsTypeStrings, solidityRelativeImportPath };
package/dist/codegen.js CHANGED
@@ -1,24 +1,24 @@
1
- import{c as N,e as Y}from"./chunk-DDEUATTE.js";import{a as m}from"./chunk-TCWGPC6G.js";import{a as p}from"./chunk-UPQEB2HW.js";import J from"path";import{parse as _,visit as d}from"@solidity-parser/parser";function ie(t,r){let n=_(t),i=W(_(t),r),s=[],o=[],a=[];if(!i)throw new p(`Contract not found: ${r}`);return d(i,{FunctionDefinition({name:y,visibility:T,parameters:c,stateMutability:R,returnParameters:g,isConstructor:F,isFallback:M,isReceiveEther:k}){try{if(F||M||k)return;if(T==="default")throw new p("Visibility is not specified");if(T==="external"||T==="public"){o.push({name:y===null?"":y,parameters:c.map(l),stateMutability:R||"",returnParameters:g===null?[]:g.map(l)});for(let{typeName:I}of c.concat(g??[])){let L=f(I);s=s.concat(b(n,L))}}}catch(I){throw I instanceof p&&(I.message=`Function "${y}" in contract "${r}": ${I.message}`),I}},CustomErrorDefinition({name:y,parameters:T}){a.push({name:y,parameters:T.map(l)});for(let c of T){let R=f(c.typeName);s=s.concat(b(n,R))}}}),{functions:o,errors:a,symbolImports:s}}function W(t,r){let n;return d(t,{ContractDefinition(i){i.name===r&&(n=i)}}),n}function l({name:t,typeName:r,storageLocation:n}){let i="",{name:s,stateMutability:o}=h(r);return i+=s,o!==null&&(i+=` ${o}`),n!==null&&(i+=` ${n}`),t!==null&&(i+=` ${t}`),i}function h(t){if(t===null)return{name:"",stateMutability:null};if(t.type==="ElementaryTypeName")return{name:t.name,stateMutability:t.stateMutability};if(t.type==="UserDefinedTypeName")return{name:t.namePath,stateMutability:null};if(t.type==="ArrayTypeName"){let r="";t.length?.type==="NumberLiteral"?r=t.length.number:t.length?.type==="Identifier"&&(r=t.length.name);let{name:n,stateMutability:i}=h(t.baseTypeName);return{name:`${n}[${r}]`,stateMutability:i}}else throw new p(`Invalid typeName.type ${t.type}`)}function f(t){if(t?.type==="UserDefinedTypeName")return[t.namePath.split(".")[0]];if(t?.type==="ArrayTypeName"){let r=f(t.baseTypeName);if(t.length?.type==="Identifier"){let n=t.length.name;r.push(n.split(".")[0])}return r}else return[]}function b(t,r){let n=[];for(let i of r){let s;if(d(t,{ImportDirective({path:o,symbolAliases:a}){if(a)for(let y of a){let T=y[1]||y[0];if(i===T){s={symbol:y[0],path:o};return}}}}),s)n.push(s);else throw new p(`Symbol "${i}" has no explicit import`)}return n}import{parse as j,visit as O}from"@solidity-parser/parser";function U(t,r,n){let i=j(t),s=n.at(0)===".",o={};return O(i,{TypeDefinition({name:a,definition:y},T){if(y.name.includes("fixed"))throw new p("Fixed point numbers are not supported by MUD");if(r.includes(a)){if(a in o)throw new p(`File has multiple user types with the same name: ${a}`);T?.type==="ContractDefinition"?o[a]={typeId:`${T.name}.${a}`,internalTypeId:y.name,importSymbol:T.name,fromPath:n,isRelativePath:s}:o[a]={typeId:a,internalTypeId:y.name,importSymbol:a,fromPath:n,isRelativePath:s}}}}),o}import B from"prettier";import H from"prettier-plugin-solidity";async function E(t,r){let n;r&&(n=await B.resolveConfig(r));try{return B.format(t,{plugins:[H],parser:"solidity-parse",printWidth:120,semi:!0,tabWidth:2,useTabs:!1,bracketSpacing:!0,...n})}catch(i){let s;return i instanceof Error?s=i.message:s=i,console.log(`Error during output formatting: ${s}`),t}}async function x(t){return B.format(t,{parser:"typescript"})}import u from"node:fs/promises";import $ from"node:path";var A=m.extend("codegen"),K=m.extend("codegen");A.log=console.debug.bind(console);K.log=console.error.bind(console);async function le(t,r,n){let i=await E(t);await u.mkdir($.dirname(r),{recursive:!0}),await u.writeFile(r,i),A(`${n}: ${r}`)}async function fe(t,r,n){let i=await x(t);await u.mkdir($.dirname(r),{recursive:!0}),await u.writeFile(r,i),A(`${n}: ${r}`)}import{readFileSync as w}from"fs";import V from"path";function be(t,r,n){let i={};for(let[o,{filePath:a}]of Object.entries(t))a in i||(i[a]=[]),i[a].push(o);let s={};for(let[o,a]of Object.entries(i)){let{filePath:y,data:T}=z(r,o,n),c=U(T,a,y);for(let[R,g]of Object.entries(c))if(g.internalTypeId!==t[R].internalType)throw new p(`User type "${R}" has internal type "${g.internalTypeId}" but config specifies "${t[R].internalType}"`);s={...s,...c}}return s}function z(t,r,n){if(r.at(0)===".")return{filePath:"./"+V.relative(t,r),data:w(r,"utf8")};{let i=r;for(let[s,o]of n)if(i.includes(s)){i=i.replace(s,o);break}return{filePath:r,data:w(i,"utf8")}}}function S(t){return t.replace(/\\/g,"/")}var v=`// SPDX-License-Identifier: MIT
1
+ import{c as N,e as Y}from"./chunk-DDEUATTE.js";import{a as m}from"./chunk-TCWGPC6G.js";import{a as T}from"./chunk-UPQEB2HW.js";import q from"path";import{parse as _,visit as d}from"@solidity-parser/parser";function ae(t,r){let n=_(t),i=H(_(t),r),s=[],o=[],a=[];if(!i)throw new T(`Contract not found: ${r}`);return d(i,{FunctionDefinition({name:y,visibility:p,parameters:c,stateMutability:R,returnParameters:g,isConstructor:W,isFallback:L,isReceiveEther:j}){try{if(W||L||j)return;if(p==="default")throw new T("Visibility is not specified");if(p==="external"||p==="public"){o.push({name:y===null?"":y,parameters:c.map(l),stateMutability:R||"",returnParameters:g===null?[]:g.map(l)});for(let{typeName:I}of c.concat(g??[])){let O=f(I);s=s.concat(b(n,O))}}}catch(I){throw I instanceof T&&(I.message=`Function "${y}" in contract "${r}": ${I.message}`),I}},CustomErrorDefinition({name:y,parameters:p}){a.push({name:y,parameters:p.map(l)});for(let c of p){let R=f(c.typeName);s=s.concat(b(n,R))}}}),{functions:o,errors:a,symbolImports:s}}function H(t,r){let n;return d(t,{ContractDefinition(i){i.name===r&&(n=i)}}),n}function l({name:t,typeName:r,storageLocation:n}){let i="",{name:s,stateMutability:o}=h(r);return i+=s,o!==null&&(i+=` ${o}`),n!==null&&(i+=` ${n}`),t!==null&&(i+=` ${t}`),i}function h(t){if(t===null)return{name:"",stateMutability:null};if(t.type==="ElementaryTypeName")return{name:t.name,stateMutability:t.stateMutability};if(t.type==="UserDefinedTypeName")return{name:t.namePath,stateMutability:null};if(t.type==="ArrayTypeName"){let r="";t.length?.type==="NumberLiteral"?r=t.length.number:t.length?.type==="Identifier"&&(r=t.length.name);let{name:n,stateMutability:i}=h(t.baseTypeName);return{name:`${n}[${r}]`,stateMutability:i}}else throw new T(`Invalid typeName.type ${t.type}`)}function f(t){if(t?.type==="UserDefinedTypeName")return[t.namePath.split(".")[0]];if(t?.type==="ArrayTypeName"){let r=f(t.baseTypeName);if(t.length?.type==="Identifier"){let n=t.length.name;r.push(n.split(".")[0])}return r}else return[]}function b(t,r){let n=[];for(let i of r){let s;if(d(t,{ImportDirective({path:o,symbolAliases:a}){if(a)for(let y of a){let p=y[1]||y[0];if(i===p){s={symbol:y[0],path:o};return}}}}),s)n.push(s);else throw new T(`Symbol "${i}" has no explicit import`)}return n}import{parse as K,visit as V}from"@solidity-parser/parser";function U(t,r,n){let i=K(t),s=n.at(0)===".",o={};return V(i,{TypeDefinition({name:a,definition:y},p){if(y.name.includes("fixed"))throw new T("Fixed point numbers are not supported by MUD");if(r.includes(a)){if(a in o)throw new T(`File has multiple user types with the same name: ${a}`);p?.type==="ContractDefinition"?o[a]={typeId:`${p.name}.${a}`,internalTypeId:y.name,importSymbol:p.name,fromPath:n,isRelativePath:s}:o[a]={typeId:a,internalTypeId:y.name,importSymbol:a,fromPath:n,isRelativePath:s}}}}),o}import B from"prettier";import z from"prettier-plugin-solidity";async function E(t,r){let n;r&&(n=await B.resolveConfig(r));try{return B.format(t,{plugins:[z],parser:"solidity-parse",printWidth:120,semi:!0,tabWidth:2,useTabs:!1,bracketSpacing:!0,...n})}catch(i){let s;return i instanceof Error?s=i.message:s=i,console.log(`Error during output formatting: ${s}`),t}}async function x(t){return B.format(t,{parser:"typescript"})}import A from"node:fs/promises";import $ from"node:path";var u=m.extend("codegen"),J=m.extend("codegen");u.log=console.debug.bind(console);J.log=console.error.bind(console);async function Be(t,r,n){let i=await E(t);await A.mkdir($.dirname(r),{recursive:!0}),await A.writeFile(r,i),u(`${n}: ${r}`)}async function Se(t,r,n){let i=await x(t);await A.mkdir($.dirname(r),{recursive:!0}),await A.writeFile(r,i),u(`${n}: ${r}`)}import{readFileSync as w}from"fs";import G from"path";function Ee(t,r,n){let i={};for(let[o,{filePath:a}]of Object.entries(t))a in i||(i[a]=[]),i[a].push(o);let s={};for(let[o,a]of Object.entries(i)){let{filePath:y,data:p}=X(r,o,n),c=U(p,a,y);for(let[R,g]of Object.entries(c))if(g.internalTypeId!==t[R].internalType)throw new T(`User type "${R}" has internal type "${g.internalTypeId}" but config specifies "${t[R].internalType}"`);s={...s,...c}}return s}function X(t,r,n){if(r.at(0)===".")return{filePath:"./"+G.relative(t,r),data:w(r,"utf8")};{let i=r;for(let[s,o]of n)if(i.includes(s)){i=i.replace(s,o);break}return{filePath:r,data:w(i,"utf8")}}}function v(t){return t.replace(/\\/g,"/")}import S from"node:path";function D(t){return t.replaceAll(S.win32.sep,S.posix.sep)}function P(t,...r){let n=S.posix.join(D(t),...r.map(D)).replace(/\/$/,"");return t.startsWith(".")?("./"+n).replace(/^(\.\/)+\./,"."):n}var C=`// SPDX-License-Identifier: MIT
2
2
  pragma solidity >=0.8.24;
3
3
 
4
- /* Autogenerated file. Do not edit manually. */`;function G(t,r){return C("",t,r)}function X(t){let r=t.filter(n=>n!==void 0&&n!=="");return C(",",r,n=>n)}function Le({staticResourceData:t,keyTuple:r}){let n=t?"":"ResourceId _tableId",i=X(r.map(({name:o,typeWithLocation:a})=>`${a} ${o}`)),s=`
4
+ /* Autogenerated file. Do not edit manually. */`;function Q(t,r){return k("",t,r)}function Z(t){let r=t.filter(n=>n!==void 0&&n!=="");return k(",",r,n=>n)}function Ve({staticResourceData:t,keyTuple:r}){let n=t?"":"ResourceId _tableId",i=Z(r.map(({name:o,typeWithLocation:a})=>`${a} ${o}`)),s=`
5
5
  bytes32[] memory _keyTuple = new bytes32[](${r.length});
6
- ${G(r,(o,a)=>`_keyTuple[${a}] = ${q(o.name,o)};`)}
7
- `;return{_typedTableId:n,_typedKeyArgs:i,_keyTupleDefinition:s}}function D(t,r){return S("./"+J.relative("./"+r,"./"+t))}function We(t){return P(t.map(r=>"path"in r?r:{symbol:r.symbol,path:D(r.fromPath,r.usedInPath)}))}function je(t){return P(t.map(({symbol:r,fromPath:n,usedInPath:i})=>({symbol:r,path:D(n,i)})))}function P(t){let r=new Map;for(let{symbol:i,path:s}of t)r.has(s)||r.set(s,new Set),r.get(s)?.add(i);let n=[];for(let[i,s]of r){let o=[...s].join(", ");n.push(`import { ${o} } from "${S(i)}";`)}return n.join(`
8
- `)}function Oe(t,r){let n="";return n+=r({_typedStore:void 0,_store:"StoreSwitch",_commentSuffix:"",_methodNamePrefix:""}),n+=r({_typedStore:void 0,_store:"StoreCore",_commentSuffix:"",_methodNamePrefix:"_",_useExplicitFieldLayout:!0}),t&&(n+=`
9
- `+r({_typedStore:"IStore _store",_store:"_store",_commentSuffix:" (using the specified store)",_methodNamePrefix:""})),n}function He(t,r,n){let i=`${r[0].toUpperCase()}${r.slice(1)}`,s="";return s+=n(i),t&&(s+=`
10
- `+n("")),s}function Ke({namespace:t,name:r,offchainOnly:n}){let i=N({type:n?"offchainTable":"table",namespace:t,name:r}),s=Y(i);return`
6
+ ${Q(r,(o,a)=>`_keyTuple[${a}] = ${ee(o.name,o)};`)}
7
+ `;return{_typedTableId:n,_typedKeyArgs:i,_keyTupleDefinition:s}}function F(t,r){return v("./"+q.relative("./"+r,"./"+t))}function ze(t){return M(t.map(r=>"path"in r?r:{symbol:r.symbol,path:F(r.fromPath,r.usedInPath)}))}function Je(t){return M(t.map(({symbol:r,fromPath:n,usedInPath:i})=>({symbol:r,path:F(n,i)})))}function M(t){let r=new Map;for(let{symbol:i,path:s}of t)r.has(s)||r.set(s,new Set),r.get(s)?.add(i);let n=[];for(let[i,s]of r){let o=[...s].join(", ");n.push(`import { ${o} } from "${P(i)}";`)}return n.join(`
8
+ `)}function Ge(t,r){let n="";return n+=r({_typedStore:void 0,_store:"StoreSwitch",_commentSuffix:"",_methodNamePrefix:""}),n+=r({_typedStore:void 0,_store:"StoreCore",_commentSuffix:"",_methodNamePrefix:"_",_useExplicitFieldLayout:!0}),t&&(n+=`
9
+ `+r({_typedStore:"IStore _store",_store:"_store",_commentSuffix:" (using the specified store)",_methodNamePrefix:""})),n}function Xe(t,r,n){let i=`${r[0].toUpperCase()}${r.slice(1)}`,s="";return s+=n(i),t&&(s+=`
10
+ `+n("")),s}function qe({namespace:t,name:r,offchainOnly:n}){let i=N({type:n?"offchainTable":"table",namespace:t,name:r}),s=Y(i);return`
11
11
  // Hex below is the result of \`WorldResourceIdLib.encode({ namespace: ${JSON.stringify(s.namespace)}, name: ${JSON.stringify(s.name)}, typeId: ${n?"RESOURCE_OFFCHAIN_TABLE":"RESOURCE_TABLE"} });\`
12
12
  ResourceId constant _tableId = ResourceId.wrap(${i});
13
- `}function q(t,{typeUnwrap:r,internalTypeId:n}){let i=r.length?`${r}(${t})`:t;if(n==="bytes32")return i;if(/^bytes\d{1,2}$/.test(n))return`bytes32(${i})`;if(/^uint\d{1,3}$/.test(n))return`bytes32(uint256(${i}))`;if(/^int\d{1,3}$/.test(n))return`bytes32(uint256(int256(${i})))`;if(n==="address")return`bytes32(uint256(uint160(${i})))`;if(n==="bool")return`_boolToBytes32(${i})`;throw new Error(`Unknown value type id ${n}`)}function Q(t){return/^bytes\d{1,2}$/.test(t.internalTypeId)}function Ve(t){return Q(t)?0:256-t.staticByteLength*8}function C(t,r,n){return r.map((i,s)=>n(i,s)+(s===r.length-1?"":t)).join(`
14
- `)}function Ge(t){let r=Object.entries(t).map(([n,i])=>`
13
+ `}function ee(t,{typeUnwrap:r,internalTypeId:n}){let i=r.length?`${r}(${t})`:t;if(n==="bytes32")return i;if(/^bytes\d{1,2}$/.test(n))return`bytes32(${i})`;if(/^uint\d{1,3}$/.test(n))return`bytes32(uint256(${i}))`;if(/^int\d{1,3}$/.test(n))return`bytes32(uint256(int256(${i})))`;if(n==="address")return`bytes32(uint256(uint160(${i})))`;if(n==="bool")return`_boolToBytes32(${i})`;throw new Error(`Unknown value type id ${n}`)}function te(t){return/^bytes\d{1,2}$/.test(t.internalTypeId)}function Qe(t){return te(t)?0:256-t.staticByteLength*8}function k(t,r,n){return r.map((i,s)=>n(i,s)+(s===r.length-1?"":t)).join(`
14
+ `)}function tt(t){let r=Object.entries(t).map(([n,i])=>`
15
15
  enum ${n} {
16
16
  ${i.join(", ")}
17
17
  }
18
18
  `);return`
19
- ${v}
19
+ ${C}
20
20
  ${r.join("")}
21
- `}function qe(t){let{fields:r,keyTuple:n}=t,i="";for(let s of Z([...r,...n]))i+=s;return r.some(({internalTypeId:s})=>s.match("bool"))&&(i+=`
21
+ `}function nt(t){let{fields:r,keyTuple:n}=t,i="";for(let s of re([...r,...n]))i+=s;return r.some(({internalTypeId:s})=>s.match("bool"))&&(i+=`
22
22
  /**
23
23
  * @notice Cast a value to a bool.
24
24
  * @dev Boolean values are encoded as uint8 (1 = true, 0 = false), but Solidity doesn't allow casting between uint8 and bool.
@@ -40,7 +40,7 @@ pragma solidity >=0.8.24;
40
40
  result := value
41
41
  }
42
42
  }
43
- `),i}function Z(t){let r=new Map,n=new Map;for(let{typeWrappingData:i,typeWrap:s,typeUnwrap:o,internalTypeId:a}of t){if(!i)continue;let{kind:y}=i;if(y==="staticArray"){let{elementType:T,staticLength:c}=i;r.set(s,ee(s,T,c,a)),n.set(o,te(o,T,c,a))}}return[...r.values(),...n.values()]}function ee(t,r,n,i){return`
43
+ `),i}function re(t){let r=new Map,n=new Map;for(let{typeWrappingData:i,typeWrap:s,typeUnwrap:o,internalTypeId:a}of t){if(!i)continue;let{kind:y}=i;if(y==="staticArray"){let{elementType:p,staticLength:c}=i;r.set(s,ne(s,p,c,a)),n.set(o,ie(o,p,c,a))}}return[...r.values(),...n.values()]}function ne(t,r,n,i){return`
44
44
  /**
45
45
  * @notice Cast a dynamic array to a static array.
46
46
  * @dev In memory static arrays are just dynamic arrays without the 32 length bytes,
@@ -66,7 +66,7 @@ pragma solidity >=0.8.24;
66
66
  }
67
67
  }
68
68
  }
69
- `}function te(t,r,n,i){let s=n*32;return`
69
+ `}function ie(t,r,n,i){let s=n*32;return`
70
70
  /**
71
71
  * @notice Copy a static array to a dynamic array.
72
72
  * @dev Static arrays don't have a length prefix, so this function copies the memory from the static array to a new dynamic array.
@@ -87,5 +87,5 @@ pragma solidity >=0.8.24;
87
87
  }
88
88
  Memory.copy(fromPointer, toPointer, ${s});
89
89
  }
90
- `}import{SchemaType as e}from"@latticexyz/schema-type/deprecated";var st={[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.BigIntArray",[e.BYTES2_ARRAY]:"RecsType.BigIntArray",[e.BYTES3_ARRAY]:"RecsType.BigIntArray",[e.BYTES4_ARRAY]:"RecsType.BigIntArray",[e.BYTES5_ARRAY]:"RecsType.BigIntArray",[e.BYTES6_ARRAY]:"RecsType.BigIntArray",[e.BYTES7_ARRAY]:"RecsType.BigIntArray",[e.BYTES8_ARRAY]:"RecsType.BigIntArray",[e.BYTES9_ARRAY]:"RecsType.BigIntArray",[e.BYTES10_ARRAY]:"RecsType.BigIntArray",[e.BYTES11_ARRAY]:"RecsType.BigIntArray",[e.BYTES12_ARRAY]:"RecsType.BigIntArray",[e.BYTES13_ARRAY]:"RecsType.BigIntArray",[e.BYTES14_ARRAY]:"RecsType.BigIntArray",[e.BYTES15_ARRAY]:"RecsType.BigIntArray",[e.BYTES16_ARRAY]:"RecsType.BigIntArray",[e.BYTES17_ARRAY]:"RecsType.BigIntArray",[e.BYTES18_ARRAY]:"RecsType.BigIntArray",[e.BYTES19_ARRAY]:"RecsType.BigIntArray",[e.BYTES20_ARRAY]:"RecsType.BigIntArray",[e.BYTES21_ARRAY]:"RecsType.BigIntArray",[e.BYTES22_ARRAY]:"RecsType.BigIntArray",[e.BYTES23_ARRAY]:"RecsType.BigIntArray",[e.BYTES24_ARRAY]:"RecsType.BigIntArray",[e.BYTES25_ARRAY]:"RecsType.BigIntArray",[e.BYTES26_ARRAY]:"RecsType.BigIntArray",[e.BYTES27_ARRAY]:"RecsType.BigIntArray",[e.BYTES28_ARRAY]:"RecsType.BigIntArray",[e.BYTES29_ARRAY]:"RecsType.BigIntArray",[e.BYTES30_ARRAY]:"RecsType.BigIntArray",[e.BYTES31_ARRAY]:"RecsType.BigIntArray",[e.BYTES32_ARRAY]:"RecsType.BigIntArray",[e.BOOL_ARRAY]:"RecsType.T",[e.ADDRESS_ARRAY]:"RecsType.StringArray",[e.BYTES]:"RecsType.String",[e.STRING]:"RecsType.String"};export{ie as contractToInterface,U as extractUserTypes,le as formatAndWriteSolidity,fe as formatAndWriteTypescript,E as formatSolidity,x as formatTypescript,Ve as getLeftPaddingBits,Q as isLeftAligned,be as loadAndExtractUserTypes,S as posixPath,P as renderAbsoluteImports,X as renderArguments,Le as renderCommonData,Ge as renderEnums,We as renderImports,G as renderList,je as renderRelativeImports,Ke as renderTableId,qe as renderTypeHelpers,q as renderValueTypeToBytes32,He as renderWithFieldSuffix,Oe as renderWithStore,v as renderedSolidityHeader,st as schemaTypesToRecsTypeStrings,D as solidityRelativeImportPath};
90
+ `}import{SchemaType as e}from"@latticexyz/schema-type/deprecated";var Rt={[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.BigIntArray",[e.BYTES2_ARRAY]:"RecsType.BigIntArray",[e.BYTES3_ARRAY]:"RecsType.BigIntArray",[e.BYTES4_ARRAY]:"RecsType.BigIntArray",[e.BYTES5_ARRAY]:"RecsType.BigIntArray",[e.BYTES6_ARRAY]:"RecsType.BigIntArray",[e.BYTES7_ARRAY]:"RecsType.BigIntArray",[e.BYTES8_ARRAY]:"RecsType.BigIntArray",[e.BYTES9_ARRAY]:"RecsType.BigIntArray",[e.BYTES10_ARRAY]:"RecsType.BigIntArray",[e.BYTES11_ARRAY]:"RecsType.BigIntArray",[e.BYTES12_ARRAY]:"RecsType.BigIntArray",[e.BYTES13_ARRAY]:"RecsType.BigIntArray",[e.BYTES14_ARRAY]:"RecsType.BigIntArray",[e.BYTES15_ARRAY]:"RecsType.BigIntArray",[e.BYTES16_ARRAY]:"RecsType.BigIntArray",[e.BYTES17_ARRAY]:"RecsType.BigIntArray",[e.BYTES18_ARRAY]:"RecsType.BigIntArray",[e.BYTES19_ARRAY]:"RecsType.BigIntArray",[e.BYTES20_ARRAY]:"RecsType.BigIntArray",[e.BYTES21_ARRAY]:"RecsType.BigIntArray",[e.BYTES22_ARRAY]:"RecsType.BigIntArray",[e.BYTES23_ARRAY]:"RecsType.BigIntArray",[e.BYTES24_ARRAY]:"RecsType.BigIntArray",[e.BYTES25_ARRAY]:"RecsType.BigIntArray",[e.BYTES26_ARRAY]:"RecsType.BigIntArray",[e.BYTES27_ARRAY]:"RecsType.BigIntArray",[e.BYTES28_ARRAY]:"RecsType.BigIntArray",[e.BYTES29_ARRAY]:"RecsType.BigIntArray",[e.BYTES30_ARRAY]:"RecsType.BigIntArray",[e.BYTES31_ARRAY]:"RecsType.BigIntArray",[e.BYTES32_ARRAY]:"RecsType.BigIntArray",[e.BOOL_ARRAY]:"RecsType.T",[e.ADDRESS_ARRAY]:"RecsType.StringArray",[e.BYTES]:"RecsType.String",[e.STRING]:"RecsType.String"};export{ae as contractToInterface,U as extractUserTypes,Be as formatAndWriteSolidity,Se as formatAndWriteTypescript,E as formatSolidity,x as formatTypescript,Qe as getLeftPaddingBits,te as isLeftAligned,Ee as loadAndExtractUserTypes,v as posixPath,M as renderAbsoluteImports,Z as renderArguments,Ve as renderCommonData,tt as renderEnums,P as renderImportPath,ze as renderImports,Q as renderList,Je as renderRelativeImports,qe as renderTableId,nt as renderTypeHelpers,ee as renderValueTypeToBytes32,Xe as renderWithFieldSuffix,Ge as renderWithStore,C as renderedSolidityHeader,Rt as schemaTypesToRecsTypeStrings,F as solidityRelativeImportPath};
91
91
  //# sourceMappingURL=codegen.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/codegen/render-solidity/common.ts","../src/codegen/utils/contractToInterface.ts","../src/codegen/utils/extractUserTypes.ts","../src/codegen/utils/format.ts","../src/codegen/utils/formatAndWrite.ts","../src/codegen/debug.ts","../src/codegen/utils/loadUserTypesFile.ts","../src/codegen/utils/posixPath.ts","../src/codegen/render-solidity/renderEnums.ts","../src/codegen/render-solidity/renderTypeHelpers.ts","../src/codegen/render-typescript/schemaTypesToRecsTypeStrings.ts"],"sourcesContent":["import path from \"path\";\nimport {\n AbsoluteImportDatum,\n RelativeImportDatum,\n ImportDatum,\n StaticResourceData,\n RenderKeyTuple,\n RenderType,\n} from \"./types\";\nimport { posixPath } from \"../utils\";\nimport { resourceToHex } from \"../../resourceToHex\";\nimport { hexToResource } from \"../../hexToResource\";\n\n/**\n * Common header for all codegenerated solidity files\n */\nexport const renderedSolidityHeader = `// SPDX-License-Identifier: MIT\npragma solidity >=0.8.24;\n\n/* Autogenerated file. Do not edit manually. */`;\n\n/**\n * Renders a list of lines\n */\nexport function renderList<T>(list: T[], renderItem: (item: T, index: number) => string): string {\n return internalRenderList(\"\", list, renderItem);\n}\n\n/**\n * Renders a comma-separated list of arguments for solidity functions, ignoring empty and undefined ones\n */\nexport function renderArguments(args: (string | undefined)[]): string {\n const filteredArgs = args.filter((arg) => arg !== undefined && arg !== \"\") as string[];\n return internalRenderList(\",\", filteredArgs, (arg) => arg);\n}\n\ninterface RenderedCommonData {\n /** `_tableId` variable prefixed with its type (empty string if absent) */\n _typedTableId: string;\n /** Comma-separated table key names prefixed with their types (empty string if 0 keys) */\n _typedKeyArgs: string;\n /** Definition and initialization of the dynamic `_keyTuple` bytes32 array */\n _keyTupleDefinition: string;\n}\n\n/**\n * Renders some solidity statements commonly used within table libraries\n * @param param0.staticResourceData static data about the table library\n * @param param0.keyTuple key tuple of the table library\n * @returns Rendered statement strings\n */\nexport function renderCommonData({\n staticResourceData,\n keyTuple,\n}: {\n staticResourceData?: StaticResourceData;\n keyTuple: RenderKeyTuple[];\n}): RenderedCommonData {\n // static resource means static tableId as well, and no tableId arguments\n const _typedTableId = staticResourceData ? \"\" : \"ResourceId _tableId\";\n const _typedKeyArgs = renderArguments(keyTuple.map(({ name, typeWithLocation }) => `${typeWithLocation} ${name}`));\n\n const _keyTupleDefinition = `\n bytes32[] memory _keyTuple = new bytes32[](${keyTuple.length});\n ${renderList(keyTuple, (key, index) => `_keyTuple[${index}] = ${renderValueTypeToBytes32(key.name, key)};`)}\n `;\n\n return {\n _typedTableId,\n _typedKeyArgs,\n _keyTupleDefinition,\n };\n}\n\n/** For 2 paths which are relative to a common root, create a relative import path from one to another */\nexport function solidityRelativeImportPath(fromPath: string, usedInPath: string): string {\n // 1st \"./\" must be added because path strips it,\n // but solidity expects it unless there's \"../\" (\"./../\" is fine).\n // 2nd and 3rd \"./\" forcefully avoid absolute paths (everything is relative to `src`).\n return posixPath(\"./\" + path.relative(\"./\" + usedInPath, \"./\" + fromPath));\n}\n\n/**\n * Aggregates, deduplicates and renders imports for symbols per path.\n * Identical symbols from different paths are NOT handled, they should be checked before rendering.\n */\nexport function renderImports(imports: ImportDatum[]): string {\n return renderAbsoluteImports(\n imports.map((importDatum) => {\n if (\"path\" in importDatum) {\n return importDatum;\n } else {\n return {\n symbol: importDatum.symbol,\n path: solidityRelativeImportPath(importDatum.fromPath, importDatum.usedInPath),\n };\n }\n }),\n );\n}\n\n/**\n * Aggregates, deduplicates and renders imports for symbols per path.\n * Identical symbols from different paths are NOT handled, they should be checked before rendering.\n */\nexport function renderRelativeImports(imports: RelativeImportDatum[]): string {\n return renderAbsoluteImports(\n imports.map(({ symbol, fromPath, usedInPath }) => ({\n symbol,\n path: solidityRelativeImportPath(fromPath, usedInPath),\n })),\n );\n}\n\n/**\n * Aggregates, deduplicates and renders imports for symbols per path.\n * Identical symbols from different paths are NOT handled, they should be checked before rendering.\n */\nexport function renderAbsoluteImports(imports: AbsoluteImportDatum[]): string {\n // Aggregate symbols by import path, also deduplicating them\n const aggregatedImports = new Map<string, Set<string>>();\n for (const { symbol, path } of imports) {\n if (!aggregatedImports.has(path)) {\n aggregatedImports.set(path, new Set());\n }\n aggregatedImports.get(path)?.add(symbol);\n }\n // Render imports\n const renderedImports = [];\n for (const [path, symbols] of aggregatedImports) {\n const renderedSymbols = [...symbols].join(\", \");\n renderedImports.push(`import { ${renderedSymbols} } from \"${posixPath(path)}\";`);\n }\n return renderedImports.join(\"\\n\");\n}\n\ninterface RenderWithStoreCallbackData {\n /** `_store` variable prefixed with its type (undefined if library name) */\n _typedStore: string | undefined;\n /** `_store` variable (undefined if library name) */\n _store: string;\n /** Empty string if storeArgument is false, otherwise `\" (using the specified store)\"` */\n _commentSuffix: string;\n /** Prefix to differentiate different kinds of store usage within methods */\n _methodNamePrefix: string;\n /** Whether FieldLayout variable should be passed to store methods */\n _useExplicitFieldLayout?: boolean;\n}\n\n/**\n * Renders several versions of the callback's result, which access Store in different ways\n * @param storeArgument whether to render a version with `IStore _store` as an argument\n * @param callback renderer for a method which uses store\n * @returns Concatenated results of all callback calls\n */\nexport function renderWithStore(\n storeArgument: boolean,\n callback: (data: RenderWithStoreCallbackData) => string,\n): string {\n let result = \"\";\n result += callback({ _typedStore: undefined, _store: \"StoreSwitch\", _commentSuffix: \"\", _methodNamePrefix: \"\" });\n result += callback({\n _typedStore: undefined,\n _store: \"StoreCore\",\n _commentSuffix: \"\",\n _methodNamePrefix: \"_\",\n _useExplicitFieldLayout: true,\n });\n\n if (storeArgument) {\n result +=\n \"\\n\" +\n callback({\n _typedStore: \"IStore _store\",\n _store: \"_store\",\n _commentSuffix: \" (using the specified store)\",\n _methodNamePrefix: \"\",\n });\n }\n\n return result;\n}\n\n/**\n * Renders several versions of the callback's result, which have different method name suffixes\n * @param withSuffixlessFieldMethods whether to render methods with an empty suffix\n * @param fieldName name of the field which the methods access, used for a suffix\n * @param callback renderer for a method to be suffixed\n * @returns Concatenated results of all callback calls\n */\nexport function renderWithFieldSuffix(\n withSuffixlessFieldMethods: boolean,\n fieldName: string,\n callback: (_methodNameSuffix: string) => string,\n): string {\n const methodNameSuffix = `${fieldName[0].toUpperCase()}${fieldName.slice(1)}`;\n let result = \"\";\n result += callback(methodNameSuffix);\n\n if (withSuffixlessFieldMethods) {\n result += \"\\n\" + callback(\"\");\n }\n\n return result;\n}\n\n/**\n * Renders `_tableId` definition of the given table.\n * @param param0 static resource data needed to construct the table ID\n */\nexport function renderTableId({\n namespace,\n name,\n offchainOnly,\n}: Pick<StaticResourceData, \"namespace\" | \"name\" | \"offchainOnly\">): string {\n const tableId = resourceToHex({\n type: offchainOnly ? \"offchainTable\" : \"table\",\n namespace,\n name,\n });\n // turn table ID back into arguments that would be valid in `WorldResourceIdLib.encode` (like truncated names)\n const resource = hexToResource(tableId);\n return `\n // Hex below is the result of \\`WorldResourceIdLib.encode({ namespace: ${JSON.stringify(\n resource.namespace,\n )}, name: ${JSON.stringify(resource.name)}, typeId: ${offchainOnly ? \"RESOURCE_OFFCHAIN_TABLE\" : \"RESOURCE_TABLE\"} });\\`\n ResourceId constant _tableId = ResourceId.wrap(${tableId});\n `;\n}\n\n/**\n * Renders solidity typecasts to get from the given type to `bytes32`\n * @param name variable name to be typecasted\n * @param param1 type data\n */\nexport function renderValueTypeToBytes32(\n name: string,\n { typeUnwrap, internalTypeId }: Pick<RenderType, \"typeUnwrap\" | \"internalTypeId\">,\n): string {\n const innerText = typeUnwrap.length ? `${typeUnwrap}(${name})` : name;\n\n if (internalTypeId === \"bytes32\") {\n return innerText;\n } else if (/^bytes\\d{1,2}$/.test(internalTypeId)) {\n return `bytes32(${innerText})`;\n } else if (/^uint\\d{1,3}$/.test(internalTypeId)) {\n return `bytes32(uint256(${innerText}))`;\n } else if (/^int\\d{1,3}$/.test(internalTypeId)) {\n return `bytes32(uint256(int256(${innerText})))`;\n } else if (internalTypeId === \"address\") {\n return `bytes32(uint256(uint160(${innerText})))`;\n } else if (internalTypeId === \"bool\") {\n return `_boolToBytes32(${innerText})`;\n } else {\n throw new Error(`Unknown value type id ${internalTypeId}`);\n }\n}\n\n/**\n * Whether the storage representation of the given solidity type is left aligned\n */\nexport function isLeftAligned(field: Pick<RenderType, \"internalTypeId\">): boolean {\n return /^bytes\\d{1,2}$/.test(field.internalTypeId);\n}\n\n/**\n * The number of padding bits in the storage representation of a right-aligned solidity type\n */\nexport function getLeftPaddingBits(field: Pick<RenderType, \"internalTypeId\" | \"staticByteLength\">): number {\n if (isLeftAligned(field)) {\n return 0;\n } else {\n return 256 - field.staticByteLength * 8;\n }\n}\n\n/**\n * Internal helper to render `lineTerminator`-separated list of items mapped by `renderItem`\n */\nfunction internalRenderList<T>(\n lineTerminator: string,\n list: T[],\n renderItem: (item: T, index: number) => string,\n): string {\n return list\n .map((item, index) => renderItem(item, index) + (index === list.length - 1 ? \"\" : lineTerminator))\n .join(\"\\n\");\n}\n","import { parse, visit } from \"@solidity-parser/parser\";\nimport type {\n ContractDefinition,\n SourceUnit,\n TypeName,\n VariableDeclaration,\n} from \"@solidity-parser/parser/dist/src/ast-types\";\nimport { MUDError } from \"../../errors\";\n\nexport interface ContractInterfaceFunction {\n name: string;\n parameters: string[];\n stateMutability: string;\n returnParameters: string[];\n}\n\nexport interface ContractInterfaceError {\n name: string;\n parameters: string[];\n}\n\ninterface SymbolImport {\n symbol: string;\n path: string;\n}\n\n/**\n * Parse the contract data to get the functions necessary to generate an interface,\n * and symbols to import from the original contract.\n * @param data contents of a file with the solidity contract\n * @param contractName name of the contract\n * @returns interface data\n */\nexport function contractToInterface(\n data: string,\n contractName: string,\n): {\n functions: ContractInterfaceFunction[];\n errors: ContractInterfaceError[];\n symbolImports: SymbolImport[];\n} {\n const ast = parse(data);\n\n const contractNode = findContractNode(parse(data), contractName);\n let symbolImports: SymbolImport[] = [];\n const functions: ContractInterfaceFunction[] = [];\n const errors: ContractInterfaceError[] = [];\n\n if (!contractNode) {\n throw new MUDError(`Contract not found: ${contractName}`);\n }\n\n visit(contractNode, {\n FunctionDefinition({\n name,\n visibility,\n parameters,\n stateMutability,\n returnParameters,\n isConstructor,\n isFallback,\n isReceiveEther,\n }) {\n try {\n // skip constructor and fallbacks\n if (isConstructor || isFallback || isReceiveEther) return;\n // forbid default visibility (this check might be unnecessary, modern solidity already disallows this)\n if (visibility === \"default\") throw new MUDError(`Visibility is not specified`);\n\n if (visibility === \"external\" || visibility === \"public\") {\n functions.push({\n name: name === null ? \"\" : name,\n parameters: parameters.map(parseParameter),\n stateMutability: stateMutability || \"\",\n returnParameters: returnParameters === null ? [] : returnParameters.map(parseParameter),\n });\n\n for (const { typeName } of parameters.concat(returnParameters ?? [])) {\n const symbols = typeNameToSymbols(typeName);\n symbolImports = symbolImports.concat(symbolsToImports(ast, symbols));\n }\n }\n } catch (error: unknown) {\n if (error instanceof MUDError) {\n error.message = `Function \"${name}\" in contract \"${contractName}\": ${error.message}`;\n }\n throw error;\n }\n },\n CustomErrorDefinition({ name, parameters }) {\n errors.push({\n name,\n parameters: parameters.map(parseParameter),\n });\n\n for (const parameter of parameters) {\n const symbols = typeNameToSymbols(parameter.typeName);\n symbolImports = symbolImports.concat(symbolsToImports(ast, symbols));\n }\n },\n });\n\n return {\n functions,\n errors,\n symbolImports,\n };\n}\n\nfunction findContractNode(ast: SourceUnit, contractName: string): ContractDefinition | undefined {\n let contract = undefined;\n\n visit(ast, {\n ContractDefinition(node) {\n if (node.name === contractName) {\n contract = node;\n }\n },\n });\n\n return contract;\n}\n\nfunction parseParameter({ name, typeName, storageLocation }: VariableDeclaration): string {\n let typedNameWithLocation = \"\";\n\n const { name: flattenedTypeName, stateMutability } = flattenTypeName(typeName);\n // type name (e.g. uint256)\n typedNameWithLocation += flattenedTypeName;\n // optional mutability (e.g. address payable)\n if (stateMutability !== null) {\n typedNameWithLocation += ` ${stateMutability}`;\n }\n // location, when relevant (e.g. string memory)\n if (storageLocation !== null) {\n typedNameWithLocation += ` ${storageLocation}`;\n }\n // optional variable name\n if (name !== null) {\n typedNameWithLocation += ` ${name}`;\n }\n\n return typedNameWithLocation;\n}\n\nfunction flattenTypeName(typeName: TypeName | null): { name: string; stateMutability: string | null } {\n if (typeName === null) {\n return {\n name: \"\",\n stateMutability: null,\n };\n }\n if (typeName.type === \"ElementaryTypeName\") {\n return {\n name: typeName.name,\n stateMutability: typeName.stateMutability,\n };\n } else if (typeName.type === \"UserDefinedTypeName\") {\n return {\n name: typeName.namePath,\n stateMutability: null,\n };\n } else if (typeName.type === \"ArrayTypeName\") {\n let length = \"\";\n if (typeName.length?.type === \"NumberLiteral\") {\n length = typeName.length.number;\n } else if (typeName.length?.type === \"Identifier\") {\n length = typeName.length.name;\n }\n\n const { name, stateMutability } = flattenTypeName(typeName.baseTypeName);\n return {\n name: `${name}[${length}]`,\n stateMutability,\n };\n } else {\n // TODO function types are unsupported but could be useful\n throw new MUDError(`Invalid typeName.type ${typeName.type}`);\n }\n}\n\n// Get symbols that need to be imported for given typeName\nfunction typeNameToSymbols(typeName: TypeName | null): string[] {\n if (typeName?.type === \"UserDefinedTypeName\") {\n // split is needed to get a library, if types are internal to it\n const symbol = typeName.namePath.split(\".\")[0];\n return [symbol];\n } else if (typeName?.type === \"ArrayTypeName\") {\n const symbols = typeNameToSymbols(typeName.baseTypeName);\n // array types can also use symbols (constants) for length\n if (typeName.length?.type === \"Identifier\") {\n const innerTypeName = typeName.length.name;\n symbols.push(innerTypeName.split(\".\")[0]);\n }\n return symbols;\n } else {\n return [];\n }\n}\n\n// Get imports for given symbols.\n// To avoid circular dependencies of interfaces on their implementations,\n// symbols used for args/returns must always be imported from an auxiliary file.\n// To avoid parsing the entire project to build dependencies,\n// symbols must be imported with an explicit `import { symbol } from ...`\nfunction symbolsToImports(ast: SourceUnit, symbols: string[]): SymbolImport[] {\n const imports: SymbolImport[] = [];\n\n for (const symbol of symbols) {\n let symbolImport: SymbolImport | undefined;\n\n visit(ast, {\n ImportDirective({ path, symbolAliases }) {\n if (symbolAliases) {\n for (const symbolAndAlias of symbolAliases) {\n // either check the alias, or the original symbol if there's no alias\n const symbolAlias = symbolAndAlias[1] || symbolAndAlias[0];\n if (symbol === symbolAlias) {\n symbolImport = {\n // always use the original symbol for interface imports\n symbol: symbolAndAlias[0],\n path,\n };\n return;\n }\n }\n }\n },\n });\n\n if (symbolImport) {\n imports.push(symbolImport);\n } else {\n throw new MUDError(`Symbol \"${symbol}\" has no explicit import`);\n }\n }\n\n return imports;\n}\n","import { parse, visit } from \"@solidity-parser/parser\";\nimport { MUDError } from \"../../errors\";\n\nexport interface SolidityUserDefinedType {\n /** Fully-qualified name of the user-defined type (may include a library name as prefix) */\n typeId: string;\n /** Name of the wrapped primitive type */\n internalTypeId: string;\n /** Symbol which must be imported to use the type (either the type name, or the library name where the type is defined) */\n importSymbol: string;\n /** Path to the solidity file which contains the user type */\n fromPath: string;\n /** Whether `fromPath` is relative */\n isRelativePath: boolean;\n}\n\n/**\n * Parse the solidity data to extract user-defined type information.\n * @param data contents of a solidity file with the user types declarations\n * @param userTypeNames names of the user types to extract\n * @param fromPath path to the solidity file from which the user types are extracted\n * @returns record of type names mapped to the extracted type information\n */\nexport function extractUserTypes(\n data: string,\n userTypeNames: string[],\n fromPath: string,\n): Record<string, SolidityUserDefinedType> {\n const ast = parse(data);\n\n const isRelativePath = fromPath.at(0) === \".\";\n const userDefinedTypes: Record<string, SolidityUserDefinedType> = {};\n\n visit(ast, {\n TypeDefinition({ name, definition }, parent) {\n if (definition.name.includes(\"fixed\")) throw new MUDError(`Fixed point numbers are not supported by MUD`);\n if (userTypeNames.includes(name)) {\n if (name in userDefinedTypes) {\n throw new MUDError(`File has multiple user types with the same name: ${name}`);\n }\n\n if (parent?.type === \"ContractDefinition\") {\n userDefinedTypes[name] = {\n typeId: `${parent.name}.${name}`,\n internalTypeId: definition.name,\n importSymbol: parent.name,\n fromPath,\n isRelativePath,\n };\n } else {\n userDefinedTypes[name] = {\n typeId: name,\n internalTypeId: definition.name,\n importSymbol: name,\n fromPath,\n isRelativePath,\n };\n }\n }\n },\n });\n\n return userDefinedTypes;\n}\n","import prettier from \"prettier\";\nimport prettierPluginSolidity from \"prettier-plugin-solidity\";\n\n/**\n * Formats solidity code using prettier\n * @param content solidity code\n * @param prettierConfigPath optional path to a prettier config\n * @returns formatted solidity code\n */\nexport async function formatSolidity(content: string, prettierConfigPath?: string): Promise<string> {\n let config;\n if (prettierConfigPath) {\n config = await prettier.resolveConfig(prettierConfigPath);\n }\n try {\n return prettier.format(content, {\n plugins: [prettierPluginSolidity],\n parser: \"solidity-parse\",\n\n printWidth: 120,\n semi: true,\n tabWidth: 2,\n useTabs: false,\n bracketSpacing: true,\n\n ...config,\n });\n } catch (error) {\n let message;\n if (error instanceof Error) {\n message = error.message;\n } else {\n message = error;\n }\n console.log(`Error during output formatting: ${message}`);\n return content;\n }\n}\n\n/**\n * Formats typescript code using prettier\n * @param content typescript code\n * @returns formatted typescript code\n */\nexport async function formatTypescript(content: string): Promise<string> {\n return prettier.format(content, {\n parser: \"typescript\",\n });\n}\n","import fs from \"node:fs/promises\";\nimport path from \"node:path\";\nimport { formatSolidity, formatTypescript } from \"./format\";\nimport { debug } from \"../debug\";\n\n/**\n * Formats solidity code using prettier and write it to a file\n * @param output solidity code\n * @param fullOutputPath full path to the output file\n * @param logPrefix prefix for debug logs\n */\nexport async function formatAndWriteSolidity(output: string, fullOutputPath: string, logPrefix: string): Promise<void> {\n const formattedOutput = await formatSolidity(output);\n\n await fs.mkdir(path.dirname(fullOutputPath), { recursive: true });\n\n await fs.writeFile(fullOutputPath, formattedOutput);\n debug(`${logPrefix}: ${fullOutputPath}`);\n}\n\n/**\n * Formats typescript code using prettier and write it to a file\n * @param output typescript code\n * @param fullOutputPath full path to the output file\n * @param logPrefix prefix for debug logs\n */\nexport async function formatAndWriteTypescript(\n output: string,\n fullOutputPath: string,\n logPrefix: string,\n): Promise<void> {\n const formattedOutput = await formatTypescript(output);\n\n await fs.mkdir(path.dirname(fullOutputPath), { recursive: true });\n\n await fs.writeFile(fullOutputPath, formattedOutput);\n debug(`${logPrefix}: ${fullOutputPath}`);\n}\n","import { debug as parentDebug } from \"../debug\";\n\nexport const debug = parentDebug.extend(\"codegen\");\nexport const error = parentDebug.extend(\"codegen\");\n\n// Pipe debug output to stdout instead of stderr\ndebug.log = console.debug.bind(console);\n\n// Pipe error output to stderr\nerror.log = console.error.bind(console);\n","import { readFileSync } from \"fs\";\nimport path from \"path\";\nimport { SolidityUserDefinedType, extractUserTypes } from \"./extractUserTypes\";\nimport { MUDError } from \"../../errors\";\nimport { SchemaAbiType } from \"@latticexyz/schema-type/internal\";\n\nexport type UserType = {\n filePath: string;\n internalType: SchemaAbiType;\n};\n\n/**\n * Load the user type files and extract type information from them.\n * @param userTypes record of user type data mapped by type names\n * @param outputBaseDirectory base path to the output directory\n * @param remappings solc remappings\n * @returns record of the user type information mapped by type names\n */\nexport function loadAndExtractUserTypes(\n userTypes: Record<string, UserType>,\n outputBaseDirectory: string,\n remappings: [string, string][],\n): Record<string, SolidityUserDefinedType> {\n const userTypesPerFile: Record<string, string[]> = {};\n for (const [userTypeName, { filePath: unresolvedFilePath }] of Object.entries(userTypes)) {\n if (!(unresolvedFilePath in userTypesPerFile)) {\n userTypesPerFile[unresolvedFilePath] = [];\n }\n userTypesPerFile[unresolvedFilePath].push(userTypeName);\n }\n let extractedUserTypes: Record<string, SolidityUserDefinedType> = {};\n for (const [unresolvedFilePath, userTypeNames] of Object.entries(userTypesPerFile)) {\n const { filePath, data } = loadUserTypesFile(outputBaseDirectory, unresolvedFilePath, remappings);\n const userTypesInFile = extractUserTypes(data, userTypeNames, filePath);\n\n // Verify the actual user type matches the internalType specified in the config\n for (const [userTypeName, userType] of Object.entries(userTypesInFile)) {\n if (userType.internalTypeId !== userTypes[userTypeName].internalType) {\n throw new MUDError(\n `User type \"${userTypeName}\" has internal type \"${userType.internalTypeId}\" but config specifies \"${userTypes[userTypeName].internalType}\"`,\n );\n }\n }\n\n extractedUserTypes = { ...extractedUserTypes, ...userTypesInFile };\n }\n return extractedUserTypes;\n}\n\nfunction loadUserTypesFile(\n outputBaseDirectory: string,\n unresolvedFilePath: string,\n remappings: [string, string][],\n): {\n filePath: string;\n data: string;\n} {\n if (unresolvedFilePath.at(0) === \".\") {\n const relativePath = path.relative(outputBaseDirectory, unresolvedFilePath);\n return {\n filePath: \"./\" + relativePath, // solc doesn't like relative paths without \"./\"\n data: readFileSync(unresolvedFilePath, \"utf8\"),\n };\n } else {\n // apply remappings to read the file via node\n let remappedFilePath = unresolvedFilePath;\n for (const [from, to] of remappings) {\n if (remappedFilePath.includes(from)) {\n remappedFilePath = remappedFilePath.replace(from, to);\n break;\n }\n }\n\n return {\n filePath: unresolvedFilePath,\n data: readFileSync(remappedFilePath, \"utf8\"),\n };\n }\n}\n","/**\n * Explicitly normalize a given path to a posix path (using `/` as separator).\n * This should be used for generating Solidity files that will be consumed by solc,\n * because solc expects `/` as path separator, but path.join produces `\\` if the user is on windows.\n */\nexport function posixPath(path: string): string {\n return path.replace(/\\\\/g, \"/\");\n}\n","import { renderedSolidityHeader } from \"./common\";\n\n// importing this from config or store would be a cyclic dependency :(\ntype Enums = {\n readonly [name: string]: readonly [string, ...string[]];\n};\n\n/**\n * Render a list of enum data as solidity enum definitions\n */\nexport function renderEnums(enums: Enums): string {\n const enumDefinitions = Object.entries(enums).map(\n ([name, values]) => `\n enum ${name} {\n ${values.join(\", \")}\n }\n `,\n );\n\n return `\n ${renderedSolidityHeader}\n ${enumDefinitions.join(\"\")}\n `;\n}\n","import { RenderField, RenderKeyTuple, RenderType } from \"./types\";\n\n/**\n * Renders the necessary helper functions to typecast to/from the types of given fields and keys\n */\nexport function renderTypeHelpers(options: { fields: RenderField[]; keyTuple: RenderKeyTuple[] }): string {\n const { fields, keyTuple } = options;\n\n let result = \"\";\n\n for (const wrappingHelper of getWrappingHelpers([...fields, ...keyTuple])) {\n result += wrappingHelper;\n }\n\n // bool is special - it's the only primitive value type that can't be typecasted to/from\n if (fields.some(({ internalTypeId }) => internalTypeId.match(\"bool\"))) {\n result += `\n /**\n * @notice Cast a value to a bool.\n * @dev Boolean values are encoded as uint8 (1 = true, 0 = false), but Solidity doesn't allow casting between uint8 and bool.\n * @param value The uint8 value to convert.\n * @return result The boolean value.\n */\n function _toBool(uint8 value) pure returns (bool result) {\n assembly {\n result := value\n }\n }\n `;\n }\n if (keyTuple.some(({ internalTypeId }) => internalTypeId.match(\"bool\"))) {\n result += `\n /**\n * @notice Cast a bool to a bytes32.\n * @dev The boolean value is casted to a bytes32 value with 0 or 1 at the least significant bit.\n */\n function _boolToBytes32(bool value) pure returns (bytes32 result) {\n assembly {\n result := value\n }\n }\n `;\n }\n\n return result;\n}\n\nfunction getWrappingHelpers(array: RenderType[]): string[] {\n const wrappers = new Map<string, string>();\n const unwrappers = new Map<string, string>();\n for (const { typeWrappingData, typeWrap, typeUnwrap, internalTypeId } of array) {\n if (!typeWrappingData) continue;\n const { kind } = typeWrappingData;\n\n if (kind === \"staticArray\") {\n const { elementType, staticLength } = typeWrappingData;\n wrappers.set(typeWrap, renderWrapperStaticArray(typeWrap, elementType, staticLength, internalTypeId));\n unwrappers.set(typeUnwrap, renderUnwrapperStaticArray(typeUnwrap, elementType, staticLength, internalTypeId));\n }\n }\n\n return [...wrappers.values(), ...unwrappers.values()];\n}\n\n/**\n * Renders a function to cast a dynamic array to a static array.\n * @param functionName name of the function to be rendered\n * @param elementType type of the array's element\n * @param staticLength length of the static array\n * @param internalTypeId solidity type name of the dynamic array\n * @returns\n */\nfunction renderWrapperStaticArray(\n functionName: string,\n elementType: string,\n staticLength: number,\n internalTypeId: string,\n): string {\n // WARNING: ensure this still works if changing major solidity versions!\n // (the memory layout for static arrays may change)\n return `\n /**\n * @notice Cast a dynamic array to a static array.\n * @dev In memory static arrays are just dynamic arrays without the 32 length bytes,\n * so this function moves the pointer to the first element of the dynamic array.\n * If the length of the dynamic array is smaller than the static length,\n * the function returns an uninitialized array to avoid memory corruption.\n * @param _value The dynamic array to cast.\n * @return _result The static array.\n */\n function ${functionName}(\n ${internalTypeId} memory _value\n ) pure returns (\n ${elementType}[${staticLength}] memory _result\n ) {\n if (_value.length < ${staticLength}) {\n // return an uninitialized array if the length is smaller than the fixed length to avoid memory corruption\n return _result;\n } else {\n // in memory static arrays are just dynamic arrays without the 32 length bytes\n // (without the length check this could lead to memory corruption)\n assembly {\n _result := add(_value, 0x20)\n }\n }\n }\n `;\n}\n\n/**\n * Renders a function to cast a static array to a dynamic array.\n * @param functionName name of the function to be rendered\n * @param elementType type of the array's element\n * @param staticLength length of the static array\n * @param internalTypeId solidity type name of the dynamic array\n * @returns\n */\nfunction renderUnwrapperStaticArray(\n functionName: string,\n elementType: string,\n staticLength: number,\n internalTypeId: string,\n): string {\n // byte length for memory copying (more efficient than a loop)\n const byteLength = staticLength * 32;\n // TODO to optimize memory usage consider generalizing TightEncoder to a render-time utility\n return `\n /**\n * @notice Copy a static array to a dynamic array.\n * @dev Static arrays don't have a length prefix, so this function copies the memory from the static array to a new dynamic array.\n * @param _value The static array to copy.\n * @return _result The dynamic array.\n */ \n function ${functionName}(\n ${elementType}[${staticLength}] memory _value\n ) pure returns (\n ${internalTypeId} memory _result\n ) {\n _result = new ${internalTypeId}(${staticLength});\n uint256 fromPointer;\n uint256 toPointer;\n assembly {\n fromPointer := _value\n toPointer := add(_result, 0x20)\n }\n Memory.copy(fromPointer, toPointer, ${byteLength});\n }\n `;\n}\n","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.BigIntArray\",\n [SchemaType.BYTES2_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.BYTES3_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.BYTES4_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.BYTES5_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.BYTES6_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.BYTES7_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.BYTES8_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.BYTES9_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.BYTES10_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.BYTES11_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.BYTES12_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.BYTES13_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.BYTES14_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.BYTES15_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.BYTES16_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.BYTES17_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.BYTES18_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.BYTES19_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.BYTES20_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.BYTES21_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.BYTES22_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.BYTES23_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.BYTES24_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.BYTES25_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.BYTES26_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.BYTES27_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.BYTES28_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.BYTES29_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.BYTES30_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.BYTES31_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.BYTES32_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.BOOL_ARRAY]: \"RecsType.T\", // no boolean array\n [SchemaType.ADDRESS_ARRAY]: \"RecsType.StringArray\",\n [SchemaType.BYTES]: \"Rec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AAW,aAAa,EAAG,uBAC5B,CAACA,EAAW,aAAa,EAAG,uBAC5B,CAACA,EAAW,aAAa,EAAG,uBAC5B,CAACA,EAAW,aAAa,EAAG,uBAC5B,CAACA,EAAW,aAAa,EAAG,uBAC5B,CAACA,EAAW,aAAa,EAAG,uBAC5B,CAACA,EAAW,aAAa,EAAG,uBAC5B,CAACA,EAAW,aAAa,EAAG,uBAC5B,CAACA,EAAW,aAAa,EAAG,uBAC5B,CAACA,EAAW,aAAa,EAAG,uBAC5B,CAACA,EAAW,aAAa,EAAG,uBAC5B,CAACA,EAAW,aAAa,EAAG,uBAC5B,CAACA,EAAW,aAAa,EAAG,uBAC5B,CAACA,EAAW,aAAa,EAAG,uBAC5B,CAACA,EAAW,aAAa,EAAG,uBAC5B,CAACA,EAAW,aAAa,EAAG,uBAC5B,CAACA,EAAW,aAAa,EAAG,uBAC5B,CAACA,EAAW,aAAa,EAAG,uBAC5B,CAACA,EAAW,aAAa,EAAG,uBAC5B,CAACA,EAAW,aAAa,EAAG,uBAC5B,CAACA,EAAW,aAAa,EAAG,uBAC5B,CAACA,EAAW,UAAU,EAAG,aACzB,CAACA,EAAW,aAAa,EAAG,uBAC5B,CAACA,EAAW,KAAK,EAAG,kBACpB,CAACA,EAAW,MAAM,EAAG,iBACvB","names":["path","parse","visit","contractToInterface","data","contractName","ast","parse","contractNode","findContractNode","symbolImports","functions","errors","MUDError","visit","name","visibility","parameters","stateMutability","returnParameters","isConstructor","isFallback","isReceiveEther","parseParameter","typeName","symbols","typeNameToSymbols","symbolsToImports","error","parameter","contract","node","storageLocation","typedNameWithLocation","flattenedTypeName","flattenTypeName","length","innerTypeName","imports","symbol","symbolImport","path","symbolAliases","symbolAndAlias","symbolAlias","parse","visit","extractUserTypes","data","userTypeNames","fromPath","ast","parse","isRelativePath","userDefinedTypes","visit","name","definition","parent","MUDError","prettier","prettierPluginSolidity","formatSolidity","content","prettierConfigPath","config","error","message","formatTypescript","fs","path","debug","error","formatAndWriteSolidity","output","fullOutputPath","logPrefix","formattedOutput","formatSolidity","fs","path","debug","formatAndWriteTypescript","formatTypescript","readFileSync","path","loadAndExtractUserTypes","userTypes","outputBaseDirectory","remappings","userTypesPerFile","userTypeName","unresolvedFilePath","extractedUserTypes","userTypeNames","filePath","data","loadUserTypesFile","userTypesInFile","extractUserTypes","userType","MUDError","path","readFileSync","remappedFilePath","from","to","posixPath","path","renderedSolidityHeader","renderList","list","renderItem","internalRenderList","renderArguments","args","filteredArgs","arg","renderCommonData","staticResourceData","keyTuple","_typedTableId","_typedKeyArgs","name","typeWithLocation","_keyTupleDefinition","key","index","renderValueTypeToBytes32","solidityRelativeImportPath","fromPath","usedInPath","posixPath","path","renderImports","imports","renderAbsoluteImports","importDatum","renderRelativeImports","symbol","aggregatedImports","renderedImports","symbols","renderedSymbols","renderWithStore","storeArgument","callback","result","renderWithFieldSuffix","withSuffixlessFieldMethods","fieldName","methodNameSuffix","renderTableId","namespace","offchainOnly","tableId","resourceToHex","resource","hexToResource","typeUnwrap","internalTypeId","innerText","isLeftAligned","field","getLeftPaddingBits","lineTerminator","item","renderEnums","enums","enumDefinitions","name","values","renderedSolidityHeader","renderTypeHelpers","options","fields","keyTuple","result","wrappingHelper","getWrappingHelpers","internalTypeId","array","wrappers","unwrappers","typeWrappingData","typeWrap","typeUnwrap","kind","elementType","staticLength","renderWrapperStaticArray","renderUnwrapperStaticArray","functionName","byteLength","SchemaType","schemaTypesToRecsTypeStrings"]}
1
+ {"version":3,"sources":["../src/codegen/render-solidity/common.ts","../src/codegen/utils/contractToInterface.ts","../src/codegen/utils/extractUserTypes.ts","../src/codegen/utils/format.ts","../src/codegen/utils/formatAndWrite.ts","../src/codegen/debug.ts","../src/codegen/utils/loadUserTypesFile.ts","../src/codegen/utils/posixPath.ts","../src/codegen/render-solidity/renderImportPath.ts","../src/codegen/render-solidity/renderEnums.ts","../src/codegen/render-solidity/renderTypeHelpers.ts","../src/codegen/render-typescript/schemaTypesToRecsTypeStrings.ts"],"sourcesContent":["import path from \"path\";\nimport {\n AbsoluteImportDatum,\n RelativeImportDatum,\n ImportDatum,\n StaticResourceData,\n RenderKeyTuple,\n RenderType,\n} from \"./types\";\nimport { posixPath } from \"../utils\";\nimport { resourceToHex } from \"../../resourceToHex\";\nimport { hexToResource } from \"../../hexToResource\";\nimport { renderImportPath } from \"./renderImportPath\";\n\n/**\n * Common header for all codegenerated solidity files\n */\nexport const renderedSolidityHeader = `// SPDX-License-Identifier: MIT\npragma solidity >=0.8.24;\n\n/* Autogenerated file. Do not edit manually. */`;\n\n/**\n * Renders a list of lines\n */\nexport function renderList<T>(list: T[], renderItem: (item: T, index: number) => string): string {\n return internalRenderList(\"\", list, renderItem);\n}\n\n/**\n * Renders a comma-separated list of arguments for solidity functions, ignoring empty and undefined ones\n */\nexport function renderArguments(args: (string | undefined)[]): string {\n const filteredArgs = args.filter((arg) => arg !== undefined && arg !== \"\") as string[];\n return internalRenderList(\",\", filteredArgs, (arg) => arg);\n}\n\ninterface RenderedCommonData {\n /** `_tableId` variable prefixed with its type (empty string if absent) */\n _typedTableId: string;\n /** Comma-separated table key names prefixed with their types (empty string if 0 keys) */\n _typedKeyArgs: string;\n /** Definition and initialization of the dynamic `_keyTuple` bytes32 array */\n _keyTupleDefinition: string;\n}\n\n/**\n * Renders some solidity statements commonly used within table libraries\n * @param param0.staticResourceData static data about the table library\n * @param param0.keyTuple key tuple of the table library\n * @returns Rendered statement strings\n */\nexport function renderCommonData({\n staticResourceData,\n keyTuple,\n}: {\n staticResourceData?: StaticResourceData;\n keyTuple: RenderKeyTuple[];\n}): RenderedCommonData {\n // static resource means static tableId as well, and no tableId arguments\n const _typedTableId = staticResourceData ? \"\" : \"ResourceId _tableId\";\n const _typedKeyArgs = renderArguments(keyTuple.map(({ name, typeWithLocation }) => `${typeWithLocation} ${name}`));\n\n const _keyTupleDefinition = `\n bytes32[] memory _keyTuple = new bytes32[](${keyTuple.length});\n ${renderList(keyTuple, (key, index) => `_keyTuple[${index}] = ${renderValueTypeToBytes32(key.name, key)};`)}\n `;\n\n return {\n _typedTableId,\n _typedKeyArgs,\n _keyTupleDefinition,\n };\n}\n\n/**\n * For 2 paths which are relative to a common root, create a relative import path from one to another\n * @deprecated Use `renderImportPath` instead.\n */\nexport function solidityRelativeImportPath(fromPath: string, usedInPath: string): string {\n // 1st \"./\" must be added because path strips it,\n // but solidity expects it unless there's \"../\" (\"./../\" is fine).\n // 2nd and 3rd \"./\" forcefully avoid absolute paths (everything is relative to `src`).\n return posixPath(\"./\" + path.relative(\"./\" + usedInPath, \"./\" + fromPath));\n}\n\n/**\n * Aggregates, deduplicates and renders imports for symbols per path.\n * Identical symbols from different paths are NOT handled, they should be checked before rendering.\n */\nexport function renderImports(imports: ImportDatum[]): string {\n return renderAbsoluteImports(\n imports.map((importDatum) => {\n if (\"path\" in importDatum) {\n return importDatum;\n } else {\n return {\n symbol: importDatum.symbol,\n path: solidityRelativeImportPath(importDatum.fromPath, importDatum.usedInPath),\n };\n }\n }),\n );\n}\n\n/**\n * Aggregates, deduplicates and renders imports for symbols per path.\n * Identical symbols from different paths are NOT handled, they should be checked before rendering.\n */\nexport function renderRelativeImports(imports: RelativeImportDatum[]): string {\n return renderAbsoluteImports(\n imports.map(({ symbol, fromPath, usedInPath }) => ({\n symbol,\n path: solidityRelativeImportPath(fromPath, usedInPath),\n })),\n );\n}\n\n/**\n * Aggregates, deduplicates and renders imports for symbols per path.\n * Identical symbols from different paths are NOT handled, they should be checked before rendering.\n */\nexport function renderAbsoluteImports(imports: AbsoluteImportDatum[]): string {\n // Aggregate symbols by import path, also deduplicating them\n const aggregatedImports = new Map<string, Set<string>>();\n for (const { symbol, path } of imports) {\n if (!aggregatedImports.has(path)) {\n aggregatedImports.set(path, new Set());\n }\n aggregatedImports.get(path)?.add(symbol);\n }\n // Render imports\n const renderedImports = [];\n for (const [path, symbols] of aggregatedImports) {\n const renderedSymbols = [...symbols].join(\", \");\n renderedImports.push(`import { ${renderedSymbols} } from \"${renderImportPath(path)}\";`);\n }\n return renderedImports.join(\"\\n\");\n}\n\ninterface RenderWithStoreCallbackData {\n /** `_store` variable prefixed with its type (undefined if library name) */\n _typedStore: string | undefined;\n /** `_store` variable (undefined if library name) */\n _store: string;\n /** Empty string if storeArgument is false, otherwise `\" (using the specified store)\"` */\n _commentSuffix: string;\n /** Prefix to differentiate different kinds of store usage within methods */\n _methodNamePrefix: string;\n /** Whether FieldLayout variable should be passed to store methods */\n _useExplicitFieldLayout?: boolean;\n}\n\n/**\n * Renders several versions of the callback's result, which access Store in different ways\n * @param storeArgument whether to render a version with `IStore _store` as an argument\n * @param callback renderer for a method which uses store\n * @returns Concatenated results of all callback calls\n */\nexport function renderWithStore(\n storeArgument: boolean,\n callback: (data: RenderWithStoreCallbackData) => string,\n): string {\n let result = \"\";\n result += callback({ _typedStore: undefined, _store: \"StoreSwitch\", _commentSuffix: \"\", _methodNamePrefix: \"\" });\n result += callback({\n _typedStore: undefined,\n _store: \"StoreCore\",\n _commentSuffix: \"\",\n _methodNamePrefix: \"_\",\n _useExplicitFieldLayout: true,\n });\n\n if (storeArgument) {\n result +=\n \"\\n\" +\n callback({\n _typedStore: \"IStore _store\",\n _store: \"_store\",\n _commentSuffix: \" (using the specified store)\",\n _methodNamePrefix: \"\",\n });\n }\n\n return result;\n}\n\n/**\n * Renders several versions of the callback's result, which have different method name suffixes\n * @param withSuffixlessFieldMethods whether to render methods with an empty suffix\n * @param fieldName name of the field which the methods access, used for a suffix\n * @param callback renderer for a method to be suffixed\n * @returns Concatenated results of all callback calls\n */\nexport function renderWithFieldSuffix(\n withSuffixlessFieldMethods: boolean,\n fieldName: string,\n callback: (_methodNameSuffix: string) => string,\n): string {\n const methodNameSuffix = `${fieldName[0].toUpperCase()}${fieldName.slice(1)}`;\n let result = \"\";\n result += callback(methodNameSuffix);\n\n if (withSuffixlessFieldMethods) {\n result += \"\\n\" + callback(\"\");\n }\n\n return result;\n}\n\n/**\n * Renders `_tableId` definition of the given table.\n * @param param0 static resource data needed to construct the table ID\n */\nexport function renderTableId({\n namespace,\n name,\n offchainOnly,\n}: Pick<StaticResourceData, \"namespace\" | \"name\" | \"offchainOnly\">): string {\n const tableId = resourceToHex({\n type: offchainOnly ? \"offchainTable\" : \"table\",\n namespace,\n name,\n });\n // turn table ID back into arguments that would be valid in `WorldResourceIdLib.encode` (like truncated names)\n const resource = hexToResource(tableId);\n return `\n // Hex below is the result of \\`WorldResourceIdLib.encode({ namespace: ${JSON.stringify(\n resource.namespace,\n )}, name: ${JSON.stringify(resource.name)}, typeId: ${offchainOnly ? \"RESOURCE_OFFCHAIN_TABLE\" : \"RESOURCE_TABLE\"} });\\`\n ResourceId constant _tableId = ResourceId.wrap(${tableId});\n `;\n}\n\n/**\n * Renders solidity typecasts to get from the given type to `bytes32`\n * @param name variable name to be typecasted\n * @param param1 type data\n */\nexport function renderValueTypeToBytes32(\n name: string,\n { typeUnwrap, internalTypeId }: Pick<RenderType, \"typeUnwrap\" | \"internalTypeId\">,\n): string {\n const innerText = typeUnwrap.length ? `${typeUnwrap}(${name})` : name;\n\n if (internalTypeId === \"bytes32\") {\n return innerText;\n } else if (/^bytes\\d{1,2}$/.test(internalTypeId)) {\n return `bytes32(${innerText})`;\n } else if (/^uint\\d{1,3}$/.test(internalTypeId)) {\n return `bytes32(uint256(${innerText}))`;\n } else if (/^int\\d{1,3}$/.test(internalTypeId)) {\n return `bytes32(uint256(int256(${innerText})))`;\n } else if (internalTypeId === \"address\") {\n return `bytes32(uint256(uint160(${innerText})))`;\n } else if (internalTypeId === \"bool\") {\n return `_boolToBytes32(${innerText})`;\n } else {\n throw new Error(`Unknown value type id ${internalTypeId}`);\n }\n}\n\n/**\n * Whether the storage representation of the given solidity type is left aligned\n */\nexport function isLeftAligned(field: Pick<RenderType, \"internalTypeId\">): boolean {\n return /^bytes\\d{1,2}$/.test(field.internalTypeId);\n}\n\n/**\n * The number of padding bits in the storage representation of a right-aligned solidity type\n */\nexport function getLeftPaddingBits(field: Pick<RenderType, \"internalTypeId\" | \"staticByteLength\">): number {\n if (isLeftAligned(field)) {\n return 0;\n } else {\n return 256 - field.staticByteLength * 8;\n }\n}\n\n/**\n * Internal helper to render `lineTerminator`-separated list of items mapped by `renderItem`\n */\nfunction internalRenderList<T>(\n lineTerminator: string,\n list: T[],\n renderItem: (item: T, index: number) => string,\n): string {\n return list\n .map((item, index) => renderItem(item, index) + (index === list.length - 1 ? \"\" : lineTerminator))\n .join(\"\\n\");\n}\n","import { parse, visit } from \"@solidity-parser/parser\";\nimport type {\n ContractDefinition,\n SourceUnit,\n TypeName,\n VariableDeclaration,\n} from \"@solidity-parser/parser/dist/src/ast-types\";\nimport { MUDError } from \"../../errors\";\n\nexport interface ContractInterfaceFunction {\n name: string;\n parameters: string[];\n stateMutability: string;\n returnParameters: string[];\n}\n\nexport interface ContractInterfaceError {\n name: string;\n parameters: string[];\n}\n\ninterface SymbolImport {\n symbol: string;\n path: string;\n}\n\n/**\n * Parse the contract data to get the functions necessary to generate an interface,\n * and symbols to import from the original contract.\n * @param data contents of a file with the solidity contract\n * @param contractName name of the contract\n * @returns interface data\n */\nexport function contractToInterface(\n data: string,\n contractName: string,\n): {\n functions: ContractInterfaceFunction[];\n errors: ContractInterfaceError[];\n symbolImports: SymbolImport[];\n} {\n const ast = parse(data);\n\n const contractNode = findContractNode(parse(data), contractName);\n let symbolImports: SymbolImport[] = [];\n const functions: ContractInterfaceFunction[] = [];\n const errors: ContractInterfaceError[] = [];\n\n if (!contractNode) {\n throw new MUDError(`Contract not found: ${contractName}`);\n }\n\n visit(contractNode, {\n FunctionDefinition({\n name,\n visibility,\n parameters,\n stateMutability,\n returnParameters,\n isConstructor,\n isFallback,\n isReceiveEther,\n }) {\n try {\n // skip constructor and fallbacks\n if (isConstructor || isFallback || isReceiveEther) return;\n // forbid default visibility (this check might be unnecessary, modern solidity already disallows this)\n if (visibility === \"default\") throw new MUDError(`Visibility is not specified`);\n\n if (visibility === \"external\" || visibility === \"public\") {\n functions.push({\n name: name === null ? \"\" : name,\n parameters: parameters.map(parseParameter),\n stateMutability: stateMutability || \"\",\n returnParameters: returnParameters === null ? [] : returnParameters.map(parseParameter),\n });\n\n for (const { typeName } of parameters.concat(returnParameters ?? [])) {\n const symbols = typeNameToSymbols(typeName);\n symbolImports = symbolImports.concat(symbolsToImports(ast, symbols));\n }\n }\n } catch (error: unknown) {\n if (error instanceof MUDError) {\n error.message = `Function \"${name}\" in contract \"${contractName}\": ${error.message}`;\n }\n throw error;\n }\n },\n CustomErrorDefinition({ name, parameters }) {\n errors.push({\n name,\n parameters: parameters.map(parseParameter),\n });\n\n for (const parameter of parameters) {\n const symbols = typeNameToSymbols(parameter.typeName);\n symbolImports = symbolImports.concat(symbolsToImports(ast, symbols));\n }\n },\n });\n\n return {\n functions,\n errors,\n symbolImports,\n };\n}\n\nfunction findContractNode(ast: SourceUnit, contractName: string): ContractDefinition | undefined {\n let contract = undefined;\n\n visit(ast, {\n ContractDefinition(node) {\n if (node.name === contractName) {\n contract = node;\n }\n },\n });\n\n return contract;\n}\n\nfunction parseParameter({ name, typeName, storageLocation }: VariableDeclaration): string {\n let typedNameWithLocation = \"\";\n\n const { name: flattenedTypeName, stateMutability } = flattenTypeName(typeName);\n // type name (e.g. uint256)\n typedNameWithLocation += flattenedTypeName;\n // optional mutability (e.g. address payable)\n if (stateMutability !== null) {\n typedNameWithLocation += ` ${stateMutability}`;\n }\n // location, when relevant (e.g. string memory)\n if (storageLocation !== null) {\n typedNameWithLocation += ` ${storageLocation}`;\n }\n // optional variable name\n if (name !== null) {\n typedNameWithLocation += ` ${name}`;\n }\n\n return typedNameWithLocation;\n}\n\nfunction flattenTypeName(typeName: TypeName | null): { name: string; stateMutability: string | null } {\n if (typeName === null) {\n return {\n name: \"\",\n stateMutability: null,\n };\n }\n if (typeName.type === \"ElementaryTypeName\") {\n return {\n name: typeName.name,\n stateMutability: typeName.stateMutability,\n };\n } else if (typeName.type === \"UserDefinedTypeName\") {\n return {\n name: typeName.namePath,\n stateMutability: null,\n };\n } else if (typeName.type === \"ArrayTypeName\") {\n let length = \"\";\n if (typeName.length?.type === \"NumberLiteral\") {\n length = typeName.length.number;\n } else if (typeName.length?.type === \"Identifier\") {\n length = typeName.length.name;\n }\n\n const { name, stateMutability } = flattenTypeName(typeName.baseTypeName);\n return {\n name: `${name}[${length}]`,\n stateMutability,\n };\n } else {\n // TODO function types are unsupported but could be useful\n throw new MUDError(`Invalid typeName.type ${typeName.type}`);\n }\n}\n\n// Get symbols that need to be imported for given typeName\nfunction typeNameToSymbols(typeName: TypeName | null): string[] {\n if (typeName?.type === \"UserDefinedTypeName\") {\n // split is needed to get a library, if types are internal to it\n const symbol = typeName.namePath.split(\".\")[0];\n return [symbol];\n } else if (typeName?.type === \"ArrayTypeName\") {\n const symbols = typeNameToSymbols(typeName.baseTypeName);\n // array types can also use symbols (constants) for length\n if (typeName.length?.type === \"Identifier\") {\n const innerTypeName = typeName.length.name;\n symbols.push(innerTypeName.split(\".\")[0]);\n }\n return symbols;\n } else {\n return [];\n }\n}\n\n// Get imports for given symbols.\n// To avoid circular dependencies of interfaces on their implementations,\n// symbols used for args/returns must always be imported from an auxiliary file.\n// To avoid parsing the entire project to build dependencies,\n// symbols must be imported with an explicit `import { symbol } from ...`\nfunction symbolsToImports(ast: SourceUnit, symbols: string[]): SymbolImport[] {\n const imports: SymbolImport[] = [];\n\n for (const symbol of symbols) {\n let symbolImport: SymbolImport | undefined;\n\n visit(ast, {\n ImportDirective({ path, symbolAliases }) {\n if (symbolAliases) {\n for (const symbolAndAlias of symbolAliases) {\n // either check the alias, or the original symbol if there's no alias\n const symbolAlias = symbolAndAlias[1] || symbolAndAlias[0];\n if (symbol === symbolAlias) {\n symbolImport = {\n // always use the original symbol for interface imports\n symbol: symbolAndAlias[0],\n path,\n };\n return;\n }\n }\n }\n },\n });\n\n if (symbolImport) {\n imports.push(symbolImport);\n } else {\n throw new MUDError(`Symbol \"${symbol}\" has no explicit import`);\n }\n }\n\n return imports;\n}\n","import { parse, visit } from \"@solidity-parser/parser\";\nimport { MUDError } from \"../../errors\";\n\nexport interface SolidityUserDefinedType {\n /** Fully-qualified name of the user-defined type (may include a library name as prefix) */\n typeId: string;\n /** Name of the wrapped primitive type */\n internalTypeId: string;\n /** Symbol which must be imported to use the type (either the type name, or the library name where the type is defined) */\n importSymbol: string;\n /** Path to the solidity file which contains the user type */\n fromPath: string;\n /** Whether `fromPath` is relative */\n isRelativePath: boolean;\n}\n\n/**\n * Parse the solidity data to extract user-defined type information.\n * @param data contents of a solidity file with the user types declarations\n * @param userTypeNames names of the user types to extract\n * @param fromPath path to the solidity file from which the user types are extracted\n * @returns record of type names mapped to the extracted type information\n */\nexport function extractUserTypes(\n data: string,\n userTypeNames: string[],\n fromPath: string,\n): Record<string, SolidityUserDefinedType> {\n const ast = parse(data);\n\n const isRelativePath = fromPath.at(0) === \".\";\n const userDefinedTypes: Record<string, SolidityUserDefinedType> = {};\n\n visit(ast, {\n TypeDefinition({ name, definition }, parent) {\n if (definition.name.includes(\"fixed\")) throw new MUDError(`Fixed point numbers are not supported by MUD`);\n if (userTypeNames.includes(name)) {\n if (name in userDefinedTypes) {\n throw new MUDError(`File has multiple user types with the same name: ${name}`);\n }\n\n if (parent?.type === \"ContractDefinition\") {\n userDefinedTypes[name] = {\n typeId: `${parent.name}.${name}`,\n internalTypeId: definition.name,\n importSymbol: parent.name,\n fromPath,\n isRelativePath,\n };\n } else {\n userDefinedTypes[name] = {\n typeId: name,\n internalTypeId: definition.name,\n importSymbol: name,\n fromPath,\n isRelativePath,\n };\n }\n }\n },\n });\n\n return userDefinedTypes;\n}\n","import prettier from \"prettier\";\nimport prettierPluginSolidity from \"prettier-plugin-solidity\";\n\n/**\n * Formats solidity code using prettier\n * @param content solidity code\n * @param prettierConfigPath optional path to a prettier config\n * @returns formatted solidity code\n */\nexport async function formatSolidity(content: string, prettierConfigPath?: string): Promise<string> {\n let config;\n if (prettierConfigPath) {\n config = await prettier.resolveConfig(prettierConfigPath);\n }\n try {\n return prettier.format(content, {\n plugins: [prettierPluginSolidity],\n parser: \"solidity-parse\",\n\n printWidth: 120,\n semi: true,\n tabWidth: 2,\n useTabs: false,\n bracketSpacing: true,\n\n ...config,\n });\n } catch (error) {\n let message;\n if (error instanceof Error) {\n message = error.message;\n } else {\n message = error;\n }\n console.log(`Error during output formatting: ${message}`);\n return content;\n }\n}\n\n/**\n * Formats typescript code using prettier\n * @param content typescript code\n * @returns formatted typescript code\n */\nexport async function formatTypescript(content: string): Promise<string> {\n return prettier.format(content, {\n parser: \"typescript\",\n });\n}\n","import fs from \"node:fs/promises\";\nimport path from \"node:path\";\nimport { formatSolidity, formatTypescript } from \"./format\";\nimport { debug } from \"../debug\";\n\n/**\n * Formats solidity code using prettier and write it to a file\n * @param output solidity code\n * @param fullOutputPath full path to the output file\n * @param logPrefix prefix for debug logs\n */\nexport async function formatAndWriteSolidity(output: string, fullOutputPath: string, logPrefix: string): Promise<void> {\n const formattedOutput = await formatSolidity(output);\n\n await fs.mkdir(path.dirname(fullOutputPath), { recursive: true });\n\n await fs.writeFile(fullOutputPath, formattedOutput);\n debug(`${logPrefix}: ${fullOutputPath}`);\n}\n\n/**\n * Formats typescript code using prettier and write it to a file\n * @param output typescript code\n * @param fullOutputPath full path to the output file\n * @param logPrefix prefix for debug logs\n */\nexport async function formatAndWriteTypescript(\n output: string,\n fullOutputPath: string,\n logPrefix: string,\n): Promise<void> {\n const formattedOutput = await formatTypescript(output);\n\n await fs.mkdir(path.dirname(fullOutputPath), { recursive: true });\n\n await fs.writeFile(fullOutputPath, formattedOutput);\n debug(`${logPrefix}: ${fullOutputPath}`);\n}\n","import { debug as parentDebug } from \"../debug\";\n\nexport const debug = parentDebug.extend(\"codegen\");\nexport const error = parentDebug.extend(\"codegen\");\n\n// Pipe debug output to stdout instead of stderr\ndebug.log = console.debug.bind(console);\n\n// Pipe error output to stderr\nerror.log = console.error.bind(console);\n","import { readFileSync } from \"fs\";\nimport path from \"path\";\nimport { SolidityUserDefinedType, extractUserTypes } from \"./extractUserTypes\";\nimport { MUDError } from \"../../errors\";\nimport { SchemaAbiType } from \"@latticexyz/schema-type/internal\";\n\nexport type UserType = {\n filePath: string;\n internalType: SchemaAbiType;\n};\n\n/**\n * Load the user type files and extract type information from them.\n * @param userTypes record of user type data mapped by type names\n * @param outputBaseDirectory base path to the output directory\n * @param remappings solc remappings\n * @returns record of the user type information mapped by type names\n */\nexport function loadAndExtractUserTypes(\n userTypes: Record<string, UserType>,\n outputBaseDirectory: string,\n remappings: [string, string][],\n): Record<string, SolidityUserDefinedType> {\n const userTypesPerFile: Record<string, string[]> = {};\n for (const [userTypeName, { filePath: unresolvedFilePath }] of Object.entries(userTypes)) {\n if (!(unresolvedFilePath in userTypesPerFile)) {\n userTypesPerFile[unresolvedFilePath] = [];\n }\n userTypesPerFile[unresolvedFilePath].push(userTypeName);\n }\n let extractedUserTypes: Record<string, SolidityUserDefinedType> = {};\n for (const [unresolvedFilePath, userTypeNames] of Object.entries(userTypesPerFile)) {\n const { filePath, data } = loadUserTypesFile(outputBaseDirectory, unresolvedFilePath, remappings);\n const userTypesInFile = extractUserTypes(data, userTypeNames, filePath);\n\n // Verify the actual user type matches the internalType specified in the config\n for (const [userTypeName, userType] of Object.entries(userTypesInFile)) {\n if (userType.internalTypeId !== userTypes[userTypeName].internalType) {\n throw new MUDError(\n `User type \"${userTypeName}\" has internal type \"${userType.internalTypeId}\" but config specifies \"${userTypes[userTypeName].internalType}\"`,\n );\n }\n }\n\n extractedUserTypes = { ...extractedUserTypes, ...userTypesInFile };\n }\n return extractedUserTypes;\n}\n\nfunction loadUserTypesFile(\n outputBaseDirectory: string,\n unresolvedFilePath: string,\n remappings: [string, string][],\n): {\n filePath: string;\n data: string;\n} {\n if (unresolvedFilePath.at(0) === \".\") {\n const relativePath = path.relative(outputBaseDirectory, unresolvedFilePath);\n return {\n filePath: \"./\" + relativePath, // solc doesn't like relative paths without \"./\"\n data: readFileSync(unresolvedFilePath, \"utf8\"),\n };\n } else {\n // apply remappings to read the file via node\n let remappedFilePath = unresolvedFilePath;\n for (const [from, to] of remappings) {\n if (remappedFilePath.includes(from)) {\n remappedFilePath = remappedFilePath.replace(from, to);\n break;\n }\n }\n\n return {\n filePath: unresolvedFilePath,\n data: readFileSync(remappedFilePath, \"utf8\"),\n };\n }\n}\n","/**\n * Explicitly normalize a given path to a posix path (using `/` as separator).\n * This should be used for generating Solidity files that will be consumed by solc,\n * because solc expects `/` as path separator, but path.join produces `\\` if the user is on windows.\n */\nexport function posixPath(path: string): string {\n return path.replace(/\\\\/g, \"/\");\n}\n","import path from \"node:path\";\n\n// This will probably break for backslash-escaped POSIX paths,\n// but we'll worry about that later.\nfunction winToPosix(segment: string): string {\n return segment.replaceAll(path.win32.sep, path.posix.sep);\n}\n\nexport function renderImportPath(basePath: string, ...segments: readonly string[]): string {\n // Solidity compiler expects POSIX paths\n const fullPath = path.posix\n .join(winToPosix(basePath), ...segments.map(winToPosix))\n // remove trailing slash\n .replace(/\\/$/, \"\");\n\n // `path.join` strips the leading `./`\n // so if we started with a relative path, make it relative again\n if (basePath.startsWith(\".\")) {\n const relativePath = \"./\" + fullPath;\n return relativePath.replace(/^(\\.\\/)+\\./, \".\");\n }\n\n return fullPath;\n}\n","import { renderedSolidityHeader } from \"./common\";\n\n// importing this from config or store would be a cyclic dependency :(\ntype Enums = {\n readonly [name: string]: readonly [string, ...string[]];\n};\n\n/**\n * Render a list of enum data as solidity enum definitions\n */\nexport function renderEnums(enums: Enums): string {\n const enumDefinitions = Object.entries(enums).map(\n ([name, values]) => `\n enum ${name} {\n ${values.join(\", \")}\n }\n `,\n );\n\n return `\n ${renderedSolidityHeader}\n ${enumDefinitions.join(\"\")}\n `;\n}\n","import { RenderField, RenderKeyTuple, RenderType } from \"./types\";\n\n/**\n * Renders the necessary helper functions to typecast to/from the types of given fields and keys\n */\nexport function renderTypeHelpers(options: { fields: RenderField[]; keyTuple: RenderKeyTuple[] }): string {\n const { fields, keyTuple } = options;\n\n let result = \"\";\n\n for (const wrappingHelper of getWrappingHelpers([...fields, ...keyTuple])) {\n result += wrappingHelper;\n }\n\n // bool is special - it's the only primitive value type that can't be typecasted to/from\n if (fields.some(({ internalTypeId }) => internalTypeId.match(\"bool\"))) {\n result += `\n /**\n * @notice Cast a value to a bool.\n * @dev Boolean values are encoded as uint8 (1 = true, 0 = false), but Solidity doesn't allow casting between uint8 and bool.\n * @param value The uint8 value to convert.\n * @return result The boolean value.\n */\n function _toBool(uint8 value) pure returns (bool result) {\n assembly {\n result := value\n }\n }\n `;\n }\n if (keyTuple.some(({ internalTypeId }) => internalTypeId.match(\"bool\"))) {\n result += `\n /**\n * @notice Cast a bool to a bytes32.\n * @dev The boolean value is casted to a bytes32 value with 0 or 1 at the least significant bit.\n */\n function _boolToBytes32(bool value) pure returns (bytes32 result) {\n assembly {\n result := value\n }\n }\n `;\n }\n\n return result;\n}\n\nfunction getWrappingHelpers(array: RenderType[]): string[] {\n const wrappers = new Map<string, string>();\n const unwrappers = new Map<string, string>();\n for (const { typeWrappingData, typeWrap, typeUnwrap, internalTypeId } of array) {\n if (!typeWrappingData) continue;\n const { kind } = typeWrappingData;\n\n if (kind === \"staticArray\") {\n const { elementType, staticLength } = typeWrappingData;\n wrappers.set(typeWrap, renderWrapperStaticArray(typeWrap, elementType, staticLength, internalTypeId));\n unwrappers.set(typeUnwrap, renderUnwrapperStaticArray(typeUnwrap, elementType, staticLength, internalTypeId));\n }\n }\n\n return [...wrappers.values(), ...unwrappers.values()];\n}\n\n/**\n * Renders a function to cast a dynamic array to a static array.\n * @param functionName name of the function to be rendered\n * @param elementType type of the array's element\n * @param staticLength length of the static array\n * @param internalTypeId solidity type name of the dynamic array\n * @returns\n */\nfunction renderWrapperStaticArray(\n functionName: string,\n elementType: string,\n staticLength: number,\n internalTypeId: string,\n): string {\n // WARNING: ensure this still works if changing major solidity versions!\n // (the memory layout for static arrays may change)\n return `\n /**\n * @notice Cast a dynamic array to a static array.\n * @dev In memory static arrays are just dynamic arrays without the 32 length bytes,\n * so this function moves the pointer to the first element of the dynamic array.\n * If the length of the dynamic array is smaller than the static length,\n * the function returns an uninitialized array to avoid memory corruption.\n * @param _value The dynamic array to cast.\n * @return _result The static array.\n */\n function ${functionName}(\n ${internalTypeId} memory _value\n ) pure returns (\n ${elementType}[${staticLength}] memory _result\n ) {\n if (_value.length < ${staticLength}) {\n // return an uninitialized array if the length is smaller than the fixed length to avoid memory corruption\n return _result;\n } else {\n // in memory static arrays are just dynamic arrays without the 32 length bytes\n // (without the length check this could lead to memory corruption)\n assembly {\n _result := add(_value, 0x20)\n }\n }\n }\n `;\n}\n\n/**\n * Renders a function to cast a static array to a dynamic array.\n * @param functionName name of the function to be rendered\n * @param elementType type of the array's element\n * @param staticLength length of the static array\n * @param internalTypeId solidity type name of the dynamic array\n * @returns\n */\nfunction renderUnwrapperStaticArray(\n functionName: string,\n elementType: string,\n staticLength: number,\n internalTypeId: string,\n): string {\n // byte length for memory copying (more efficient than a loop)\n const byteLength = staticLength * 32;\n // TODO to optimize memory usage consider generalizing TightEncoder to a render-time utility\n return `\n /**\n * @notice Copy a static array to a dynamic array.\n * @dev Static arrays don't have a length prefix, so this function copies the memory from the static array to a new dynamic array.\n * @param _value The static array to copy.\n * @return _result The dynamic array.\n */ \n function ${functionName}(\n ${elementType}[${staticLength}] memory _value\n ) pure returns (\n ${internalTypeId} memory _result\n ) {\n _result = new ${internalTypeId}(${staticLength});\n uint256 fromPointer;\n uint256 toPointer;\n assembly {\n fromPointer := _value\n toPointer := add(_result, 0x20)\n }\n Memory.copy(fromPointer, toPointer, ${byteLength});\n }\n `;\n}\n","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.BigIntArray\",\n [SchemaType.BYTES2_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.BYTES3_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.BYTES4_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.BYTES5_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.BYTES6_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.BYTES7_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.BYTES8_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.BYTES9_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.BYTES10_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.BYTES11_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.BYTES12_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.BYTES13_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.BYTES14_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.BYTES15_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.BYTES16_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.BYTES17_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.BYTES18_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.BYTES19_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.BYTES20_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.BYTES21_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.BYTES22_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.BYTES23_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.BYTES24_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.BYTES25_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.BYTES26_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.BYTES27_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.BYTES28_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.BYTES29_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.BYTES30_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.BYTES31_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.BYTES32_ARRAY]: \"RecsType.BigIntArray\",\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"],"mappings":"+HAAA,OAAOA,MAAU,OCAjB,OAAS,SAAAC,EAAO,SAAAC,MAAa,0BAiCtB,SAASC,G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ACA,EAAW,YAAY,EAAG,uBAC3B,CAACA,EAAW,YAAY,EAAG,uBAC3B,CAACA,EAAW,YAAY,EAAG,uBAC3B,CAACA,EAAW,YAAY,EAAG,uBAC3B,CAACA,EAAW,YAAY,EAAG,uBAC3B,CAACA,EAAW,aAAa,EAAG,uBAC5B,CAACA,EAAW,aAAa,EAAG,uBAC5B,CAACA,EAAW,aAAa,EAAG,uBAC5B,CAACA,EAAW,aAAa,EAAG,uBAC5B,CAACA,EAAW,aAAa,EAAG,uBAC5B,CAACA,EAAW,aAAa,EAAG,uBAC5B,CAACA,EAAW,aAAa,EAAG,uBAC5B,CAACA,EAAW,aAAa,EAAG,uBAC5B,CAACA,EAAW,aAAa,EAAG,uBAC5B,CAACA,EAAW,aAAa,EAAG,uBAC5B,CAACA,EAAW,aAAa,EAAG,uBAC5B,CAACA,EAAW,aAAa,EAAG,uBAC5B,CAACA,EAAW,aAAa,EAAG,uBAC5B,CAACA,EAAW,aAAa,EAAG,uBAC5B,CAACA,EAAW,aAAa,EAAG,uBAC5B,CAACA,EAAW,aAAa,EAAG,uBAC5B,CAACA,EAAW,aAAa,EAAG,uBAC5B,CAACA,EAAW,aAAa,EAAG,uBAC5B,CAACA,EAAW,aAAa,EAAG,uBAC5B,CAACA,EAAW,aAAa,EAAG,uBAC5B,CAACA,EAAW,aAAa,EAAG,uBAC5B,CAACA,EAAW,aAAa,EAAG,uBAC5B,CAACA,EAAW,aAAa,EAAG,uBAC5B,CAACA,EAAW,UAAU,EAAG,aACzB,CAACA,EAAW,aAAa,EAAG,uBAC5B,CAACA,EAAW,KAAK,EAAG,kBACpB,CAACA,EAAW,MAAM,EAAG,iBACvB","names":["path","parse","visit","contractToInterface","data","contractName","ast","parse","contractNode","findContractNode","symbolImports","functions","errors","MUDError","visit","name","visibility","parameters","stateMutability","returnParameters","isConstructor","isFallback","isReceiveEther","parseParameter","typeName","symbols","typeNameToSymbols","symbolsToImports","error","parameter","contract","node","storageLocation","typedNameWithLocation","flattenedTypeName","flattenTypeName","length","innerTypeName","imports","symbol","symbolImport","path","symbolAliases","symbolAndAlias","symbolAlias","parse","visit","extractUserTypes","data","userTypeNames","fromPath","ast","parse","isRelativePath","userDefinedTypes","visit","name","definition","parent","MUDError","prettier","prettierPluginSolidity","formatSolidity","content","prettierConfigPath","config","error","message","formatTypescript","fs","path","debug","error","formatAndWriteSolidity","output","fullOutputPath","logPrefix","formattedOutput","formatSolidity","fs","path","debug","formatAndWriteTypescript","formatTypescript","readFileSync","path","loadAndExtractUserTypes","userTypes","outputBaseDirectory","remappings","userTypesPerFile","userTypeName","unresolvedFilePath","extractedUserTypes","userTypeNames","filePath","data","loadUserTypesFile","userTypesInFile","extractUserTypes","userType","MUDError","path","readFileSync","remappedFilePath","from","to","posixPath","path","path","winToPosix","segment","renderImportPath","basePath","segments","fullPath","renderedSolidityHeader","renderList","list","renderItem","internalRenderList","renderArguments","args","filteredArgs","arg","renderCommonData","staticResourceData","keyTuple","_typedTableId","_typedKeyArgs","name","typeWithLocation","_keyTupleDefinition","key","index","renderValueTypeToBytes32","solidityRelativeImportPath","fromPath","usedInPath","posixPath","path","renderImports","imports","renderAbsoluteImports","importDatum","renderRelativeImports","symbol","aggregatedImports","renderedImports","symbols","renderedSymbols","renderImportPath","renderWithStore","storeArgument","callback","result","renderWithFieldSuffix","withSuffixlessFieldMethods","fieldName","methodNameSuffix","renderTableId","namespace","offchainOnly","tableId","resourceToHex","resource","hexToResource","typeUnwrap","internalTypeId","innerText","isLeftAligned","field","getLeftPaddingBits","lineTerminator","item","renderEnums","enums","enumDefinitions","name","values","renderedSolidityHeader","renderTypeHelpers","options","fields","keyTuple","result","wrappingHelper","getWrappingHelpers","internalTypeId","array","wrappers","unwrappers","typeWrappingData","typeWrap","typeUnwrap","kind","elementType","staticLength","renderWrapperStaticArray","renderUnwrapperStaticArray","functionName","byteLength","SchemaType","schemaTypesToRecsTypeStrings"]}
package/dist/foundry.d.ts CHANGED
@@ -40,12 +40,6 @@ declare function getOutDirectory(profile?: string): Promise<string>;
40
40
  * @returns The rpc url
41
41
  */
42
42
  declare function getRpcUrl(profile?: string): Promise<string>;
43
- /**
44
- * Get the value of "remappings" from forge config
45
- * @param profile The foundry profile to use
46
- * @returns The array of remapping tuples `[from, to]`
47
- */
48
- declare function getRemappings(profile?: string): Promise<[string, string][]>;
49
43
  /**
50
44
  * Execute a forge command
51
45
  * @param args The arguments to pass to forge
@@ -72,4 +66,4 @@ declare function cast(args: string[], options?: {
72
66
  */
73
67
  declare function anvil(args: string[]): Promise<string>;
74
68
 
75
- export { ForgeConfig, anvil, cast, forge, getForgeConfig, getOutDirectory, getRemappings, getRpcUrl, getScriptDirectory, getSrcDirectory, getTestDirectory };
69
+ export { ForgeConfig, anvil, cast, forge, getForgeConfig, getOutDirectory, getRpcUrl, getScriptDirectory, getSrcDirectory, getTestDirectory };
package/dist/foundry.js CHANGED
@@ -1,3 +1,3 @@
1
- import{execa as s}from"execa";async function n(r){let{stdout:t}=await s("forge",["config","--json"],{stdio:["inherit","pipe","pipe"],env:{FOUNDRY_PROFILE:r}});return JSON.parse(t)}async function u(r){return(await n(r)).src}async function f(r){return(await n(r)).script}async function l(r){return(await n(r)).test}async function m(r){return(await n(r)).out}async function y(r){return(await n(r)).eth_rpc_url||"http://127.0.0.1:8545"}async function w(r){return(await n(r)).remappings.map(t=>t.trim().split("="))}async function P(r,t){let i={env:{FOUNDRY_PROFILE:t?.profile,...t?.env},stdout:"inherit",stderr:"pipe",cwd:t?.cwd};await(t?.silent?s("forge",r,i):o("forge",r,i))}async function x(r,t){return o("cast",r,{env:{FOUNDRY_PROFILE:t?.profile}})}async function d(r){return o("anvil",r)}async function o(r,t,i){let g=`${r} ${t.join(" ")}`;try{console.log(`running "${g}"`);let{stdout:e}=await s(r,t,{stdout:"pipe",stderr:"pipe",...i});return e}catch(e){let c=e?.stderr||e?.message||"";throw c+=`
2
- Error running "${g}"`,new Error(c)}}export{d as anvil,x as cast,P as forge,n as getForgeConfig,m as getOutDirectory,w as getRemappings,y as getRpcUrl,f as getScriptDirectory,u as getSrcDirectory,l as getTestDirectory};
1
+ import{execa as s}from"execa";async function n(r){let{stdout:t}=await s("forge",["config","--json"],{stdio:["inherit","pipe","pipe"],env:{FOUNDRY_PROFILE:r}});return JSON.parse(t)}async function u(r){return(await n(r)).src}async function f(r){return(await n(r)).script}async function l(r){return(await n(r)).test}async function y(r){return(await n(r)).out}async function m(r){return(await n(r)).eth_rpc_url||"http://127.0.0.1:8545"}async function w(r,t){let i={env:{FOUNDRY_PROFILE:t?.profile,...t?.env},stdout:"inherit",stderr:"pipe",cwd:t?.cwd};await(t?.silent?s("forge",r,i):o("forge",r,i))}async function P(r,t){return o("cast",r,{env:{FOUNDRY_PROFILE:t?.profile}})}async function d(r){return o("anvil",r)}async function o(r,t,i){let g=`${r} ${t.join(" ")}`;try{console.log(`running "${g}"`);let{stdout:e}=await s(r,t,{stdout:"pipe",stderr:"pipe",...i});return e}catch(e){let c=e?.stderr||e?.message||"";throw c+=`
2
+ Error running "${g}"`,new Error(c)}}export{d as anvil,P as cast,w as forge,n as getForgeConfig,y as getOutDirectory,m as getRpcUrl,f as getScriptDirectory,u as getSrcDirectory,l as getTestDirectory};
3
3
  //# sourceMappingURL=foundry.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/foundry/index.ts"],"sourcesContent":["import { execa, Options } from \"execa\";\n\nexport interface ForgeConfig {\n // project\n src: string;\n test: string;\n script: string;\n out: string;\n libs: string[];\n cache: boolean;\n cache_path: string;\n eth_rpc_url: string | null;\n\n // compiler\n remappings: string[];\n\n // all unspecified keys (this interface is far from comprehensive)\n [key: string]: unknown;\n}\n\n/**\n * Get forge config as a parsed json object.\n */\nexport async function getForgeConfig(profile?: string): Promise<ForgeConfig> {\n const { stdout } = await execa(\"forge\", [\"config\", \"--json\"], {\n stdio: [\"inherit\", \"pipe\", \"pipe\"],\n env: { FOUNDRY_PROFILE: profile },\n });\n\n return JSON.parse(stdout) as ForgeConfig;\n}\n\n/**\n * Get the value of \"src\" from forge config.\n * The path to the contract sources relative to the root of the project.\n */\nexport async function getSrcDirectory(profile?: string): Promise<string> {\n return (await getForgeConfig(profile)).src;\n}\n\n/**\n * Get the value of \"script\" from forge config.\n * The path to the contract sources relative to the root of the project.\n */\nexport async function getScriptDirectory(profile?: string): Promise<string> {\n return (await getForgeConfig(profile)).script;\n}\n\n/**\n * Get the value of \"test\" from forge config.\n * The path to the test contract sources relative to the root of the project.\n */\nexport async function getTestDirectory(profile?: string): Promise<string> {\n return (await getForgeConfig(profile)).test;\n}\n\n/**\n * Get the value of \"out\" from forge config.\n * The path to put contract artifacts in, relative to the root of the project.\n */\nexport async function getOutDirectory(profile?: string): Promise<string> {\n return (await getForgeConfig(profile)).out;\n}\n\n/**\n * Get the value of \"eth_rpc_url\" from forge config, default to \"http://127.0.0.1:8545\"\n * @param profile The foundry profile to use\n * @returns The rpc url\n */\nexport async function getRpcUrl(profile?: string): Promise<string> {\n return (await getForgeConfig(profile)).eth_rpc_url || \"http://127.0.0.1:8545\";\n}\n\n/**\n * Get the value of \"remappings\" from forge config\n * @param profile The foundry profile to use\n * @returns The array of remapping tuples `[from, to]`\n */\nexport async function getRemappings(profile?: string): Promise<[string, string][]> {\n return (await getForgeConfig(profile)).remappings.map((line) => line.trim().split(\"=\")) as [string, string][];\n}\n\n/**\n * Execute a forge command\n * @param args The arguments to pass to forge\n * @param options { profile?: The foundry profile to use; silent?: If true, nothing will be logged to the console }\n */\nexport async function forge(\n args: string[],\n options?: { profile?: string; silent?: boolean; env?: NodeJS.ProcessEnv; cwd?: string },\n): Promise<void> {\n const execOptions: Options<string> = {\n env: { FOUNDRY_PROFILE: options?.profile, ...options?.env },\n stdout: \"inherit\",\n stderr: \"pipe\",\n cwd: options?.cwd,\n };\n\n await (options?.silent ? execa(\"forge\", args, execOptions) : execLog(\"forge\", args, execOptions));\n}\n\n/**\n * Execute a cast command\n * @param args The arguments to pass to cast\n * @returns Stdout of the command\n */\nexport async function cast(args: string[], options?: { profile?: string }): Promise<string> {\n return execLog(\"cast\", args, {\n env: { FOUNDRY_PROFILE: options?.profile },\n });\n}\n\n/**\n * Start an anvil chain\n * @param args The arguments to pass to anvil\n * @returns Stdout of the command\n */\nexport async function anvil(args: string[]): Promise<string> {\n return execLog(\"anvil\", args);\n}\n\n/**\n * Executes the given command, returns the stdout, and logs the command to the console.\n * Throws an error if the command fails.\n * @param command The command to execute\n * @param args The arguments to pass to the command\n * @returns The stdout of the command\n */\nasync function execLog(command: string, args: string[], options?: Options<string>): Promise<string> {\n const commandString = `${command} ${args.join(\" \")}`;\n try {\n console.log(`running \"${commandString}\"`);\n const { stdout } = await execa(command, args, { stdout: \"pipe\", stderr: \"pipe\", ...options });\n return stdout;\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n } catch (error: any) {\n let errorMessage = error?.stderr || error?.message || \"\";\n errorMessage += `\\nError running \"${commandString}\"`;\n throw new Error(errorMessage);\n }\n}\n"],"mappings":"AAAA,OAAS,SAAAA,MAAsB,QAuB/B,eAAsBC,EAAeC,EAAwC,CAC3E,GAAM,CAAE,OAAAC,CAAO,EAAI,MAAMH,EAAM,QAAS,CAAC,SAAU,QAAQ,EAAG,CAC5D,MAAO,CAAC,UAAW,OAAQ,MAAM,EACjC,IAAK,CAAE,gBAAiBE,CAAQ,CAClC,CAAC,EAED,OAAO,KAAK,MAAMC,CAAM,CAC1B,CAMA,eAAsBC,EAAgBF,EAAmC,CACvE,OAAQ,MAAMD,EAAeC,CAAO,GAAG,GACzC,CAMA,eAAsBG,EAAmBH,EAAmC,CAC1E,OAAQ,MAAMD,EAAeC,CAAO,GAAG,MACzC,CAMA,eAAsBI,EAAiBJ,EAAmC,CACxE,OAAQ,MAAMD,EAAeC,CAAO,GAAG,IACzC,CAMA,eAAsBK,EAAgBL,EAAmC,CACvE,OAAQ,MAAMD,EAAeC,CAAO,GAAG,GACzC,CAOA,eAAsBM,EAAUN,EAAmC,CACjE,OAAQ,MAAMD,EAAeC,CAAO,GAAG,aAAe,uBACxD,CAOA,eAAsBO,EAAcP,EAA+C,CACjF,OAAQ,MAAMD,EAAeC,CAAO,GAAG,WAAW,IAAKQ,GAASA,EAAK,KAAK,EAAE,MAAM,GAAG,CAAC,CACxF,CAOA,eAAsBC,EACpBC,EACAC,EACe,CACf,IAAMC,EAA+B,CACnC,IAAK,CAAE,gBAAiBD,GAAS,QAAS,GAAGA,GAAS,GAAI,EAC1D,OAAQ,UACR,OAAQ,OACR,IAAKA,GAAS,GAChB,EAEA,MAAOA,GAAS,OAASb,EAAM,QAASY,EAAME,CAAW,EAAIC,EAAQ,QAASH,EAAME,CAAW,EACjG,CAOA,eAAsBE,EAAKJ,EAAgBC,EAAiD,CAC1F,OAAOE,EAAQ,OAAQH,EAAM,CAC3B,IAAK,CAAE,gBAAiBC,GAAS,OAAQ,CAC3C,CAAC,CACH,CAOA,eAAsBI,EAAML,EAAiC,CAC3D,OAAOG,EAAQ,QAASH,CAAI,CAC9B,CASA,eAAeG,EAAQG,EAAiBN,EAAgBC,EAA4C,CAClG,IAAMM,EAAgB,GAAGD,KAAWN,EAAK,KAAK,GAAG,IACjD,GAAI,CACF,QAAQ,IAAI,YAAYO,IAAgB,EACxC,GAAM,CAAE,OAAAhB,CAAO,EAAI,MAAMH,EAAMkB,EAASN,EAAM,CAAE,OAAQ,OAAQ,OAAQ,OAAQ,GAAGC,CAAQ,CAAC,EAC5F,OAAOV,CAET,OAASiB,EAAP,CACA,IAAIC,EAAeD,GAAO,QAAUA,GAAO,SAAW,GACtD,MAAAC,GAAgB;AAAA,iBAAoBF,KAC9B,IAAI,MAAME,CAAY,CAC9B,CACF","names":["execa","getForgeConfig","profile","stdout","getSrcDirectory","getScriptDirectory","getTestDirectory","getOutDirectory","getRpcUrl","getRemappings","line","forge","args","options","execOptions","execLog","cast","anvil","command","commandString","error","errorMessage"]}
1
+ {"version":3,"sources":["../src/foundry/index.ts"],"sourcesContent":["import { execa, Options } from \"execa\";\n\nexport interface ForgeConfig {\n // project\n src: string;\n test: string;\n script: string;\n out: string;\n libs: string[];\n cache: boolean;\n cache_path: string;\n eth_rpc_url: string | null;\n\n // compiler\n remappings: string[];\n\n // all unspecified keys (this interface is far from comprehensive)\n [key: string]: unknown;\n}\n\n/**\n * Get forge config as a parsed json object.\n */\nexport async function getForgeConfig(profile?: string): Promise<ForgeConfig> {\n const { stdout } = await execa(\"forge\", [\"config\", \"--json\"], {\n stdio: [\"inherit\", \"pipe\", \"pipe\"],\n env: { FOUNDRY_PROFILE: profile },\n });\n\n return JSON.parse(stdout) as ForgeConfig;\n}\n\n/**\n * Get the value of \"src\" from forge config.\n * The path to the contract sources relative to the root of the project.\n */\nexport async function getSrcDirectory(profile?: string): Promise<string> {\n return (await getForgeConfig(profile)).src;\n}\n\n/**\n * Get the value of \"script\" from forge config.\n * The path to the contract sources relative to the root of the project.\n */\nexport async function getScriptDirectory(profile?: string): Promise<string> {\n return (await getForgeConfig(profile)).script;\n}\n\n/**\n * Get the value of \"test\" from forge config.\n * The path to the test contract sources relative to the root of the project.\n */\nexport async function getTestDirectory(profile?: string): Promise<string> {\n return (await getForgeConfig(profile)).test;\n}\n\n/**\n * Get the value of \"out\" from forge config.\n * The path to put contract artifacts in, relative to the root of the project.\n */\nexport async function getOutDirectory(profile?: string): Promise<string> {\n return (await getForgeConfig(profile)).out;\n}\n\n/**\n * Get the value of \"eth_rpc_url\" from forge config, default to \"http://127.0.0.1:8545\"\n * @param profile The foundry profile to use\n * @returns The rpc url\n */\nexport async function getRpcUrl(profile?: string): Promise<string> {\n return (await getForgeConfig(profile)).eth_rpc_url || \"http://127.0.0.1:8545\";\n}\n\n/**\n * Execute a forge command\n * @param args The arguments to pass to forge\n * @param options { profile?: The foundry profile to use; silent?: If true, nothing will be logged to the console }\n */\nexport async function forge(\n args: string[],\n options?: { profile?: string; silent?: boolean; env?: NodeJS.ProcessEnv; cwd?: string },\n): Promise<void> {\n const execOptions: Options<string> = {\n env: { FOUNDRY_PROFILE: options?.profile, ...options?.env },\n stdout: \"inherit\",\n stderr: \"pipe\",\n cwd: options?.cwd,\n };\n\n await (options?.silent ? execa(\"forge\", args, execOptions) : execLog(\"forge\", args, execOptions));\n}\n\n/**\n * Execute a cast command\n * @param args The arguments to pass to cast\n * @returns Stdout of the command\n */\nexport async function cast(args: string[], options?: { profile?: string }): Promise<string> {\n return execLog(\"cast\", args, {\n env: { FOUNDRY_PROFILE: options?.profile },\n });\n}\n\n/**\n * Start an anvil chain\n * @param args The arguments to pass to anvil\n * @returns Stdout of the command\n */\nexport async function anvil(args: string[]): Promise<string> {\n return execLog(\"anvil\", args);\n}\n\n/**\n * Executes the given command, returns the stdout, and logs the command to the console.\n * Throws an error if the command fails.\n * @param command The command to execute\n * @param args The arguments to pass to the command\n * @returns The stdout of the command\n */\nasync function execLog(command: string, args: string[], options?: Options<string>): Promise<string> {\n const commandString = `${command} ${args.join(\" \")}`;\n try {\n console.log(`running \"${commandString}\"`);\n const { stdout } = await execa(command, args, { stdout: \"pipe\", stderr: \"pipe\", ...options });\n return stdout;\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n } catch (error: any) {\n let errorMessage = error?.stderr || error?.message || \"\";\n errorMessage += `\\nError running \"${commandString}\"`;\n throw new Error(errorMessage);\n }\n}\n"],"mappings":"AAAA,OAAS,SAAAA,MAAsB,QAuB/B,eAAsBC,EAAeC,EAAwC,CAC3E,GAAM,CAAE,OAAAC,CAAO,EAAI,MAAMH,EAAM,QAAS,CAAC,SAAU,QAAQ,EAAG,CAC5D,MAAO,CAAC,UAAW,OAAQ,MAAM,EACjC,IAAK,CAAE,gBAAiBE,CAAQ,CAClC,CAAC,EAED,OAAO,KAAK,MAAMC,CAAM,CAC1B,CAMA,eAAsBC,EAAgBF,EAAmC,CACvE,OAAQ,MAAMD,EAAeC,CAAO,GAAG,GACzC,CAMA,eAAsBG,EAAmBH,EAAmC,CAC1E,OAAQ,MAAMD,EAAeC,CAAO,GAAG,MACzC,CAMA,eAAsBI,EAAiBJ,EAAmC,CACxE,OAAQ,MAAMD,EAAeC,CAAO,GAAG,IACzC,CAMA,eAAsBK,EAAgBL,EAAmC,CACvE,OAAQ,MAAMD,EAAeC,CAAO,GAAG,GACzC,CAOA,eAAsBM,EAAUN,EAAmC,CACjE,OAAQ,MAAMD,EAAeC,CAAO,GAAG,aAAe,uBACxD,CAOA,eAAsBO,EACpBC,EACAC,EACe,CACf,IAAMC,EAA+B,CACnC,IAAK,CAAE,gBAAiBD,GAAS,QAAS,GAAGA,GAAS,GAAI,EAC1D,OAAQ,UACR,OAAQ,OACR,IAAKA,GAAS,GAChB,EAEA,MAAOA,GAAS,OAASX,EAAM,QAASU,EAAME,CAAW,EAAIC,EAAQ,QAASH,EAAME,CAAW,EACjG,CAOA,eAAsBE,EAAKJ,EAAgBC,EAAiD,CAC1F,OAAOE,EAAQ,OAAQH,EAAM,CAC3B,IAAK,CAAE,gBAAiBC,GAAS,OAAQ,CAC3C,CAAC,CACH,CAOA,eAAsBI,EAAML,EAAiC,CAC3D,OAAOG,EAAQ,QAASH,CAAI,CAC9B,CASA,eAAeG,EAAQG,EAAiBN,EAAgBC,EAA4C,CAClG,IAAMM,EAAgB,GAAGD,KAAWN,EAAK,KAAK,GAAG,IACjD,GAAI,CACF,QAAQ,IAAI,YAAYO,IAAgB,EACxC,GAAM,CAAE,OAAAd,CAAO,EAAI,MAAMH,EAAMgB,EAASN,EAAM,CAAE,OAAQ,OAAQ,OAAQ,OAAQ,GAAGC,CAAQ,CAAC,EAC5F,OAAOR,CAET,OAASe,EAAP,CACA,IAAIC,EAAeD,GAAO,QAAUA,GAAO,SAAW,GACtD,MAAAC,GAAgB;AAAA,iBAAoBF,KAC9B,IAAI,MAAME,CAAY,CAC9B,CACF","names":["execa","getForgeConfig","profile","stdout","getSrcDirectory","getScriptDirectory","getTestDirectory","getOutDirectory","getRpcUrl","forge","args","options","execOptions","execLog","cast","anvil","command","commandString","error","errorMessage"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@latticexyz/common",
3
- "version": "3.0.0-main-fb1cfef0c",
3
+ "version": "3.0.0-main-69eb63b59",
4
4
  "description": "Common low level logic shared between packages",
5
5
  "repository": {
6
6
  "type": "git",
@@ -65,7 +65,7 @@
65
65
  "prettier": "3.2.5",
66
66
  "prettier-plugin-solidity": "1.3.1",
67
67
  "viem": "2.9.20",
68
- "@latticexyz/schema-type": "3.0.0-main-fb1cfef0c"
68
+ "@latticexyz/schema-type": "3.0.0-main-69eb63b59"
69
69
  },
70
70
  "devDependencies": {
71
71
  "@types/debug": "^4.1.7",