@latticexyz/common 2.0.0-next.15 → 2.0.0-next.16
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
|
@@ -73,9 +73,7 @@ declare function renderCommonData({ staticResourceData, keyTuple, }: {
|
|
|
73
73
|
staticResourceData?: StaticResourceData;
|
|
74
74
|
keyTuple: RenderKeyTuple[];
|
|
75
75
|
}): {
|
|
76
|
-
_tableId: string;
|
|
77
76
|
_typedTableId: string;
|
|
78
|
-
_keyArgs: string;
|
|
79
77
|
_typedKeyArgs: string;
|
|
80
78
|
_keyTupleDefinition: string;
|
|
81
79
|
};
|
|
@@ -96,7 +94,13 @@ declare function renderRelativeImports(imports: RelativeImportDatum[]): string;
|
|
|
96
94
|
* Identical symbols from different paths are NOT handled, they should be checked before rendering.
|
|
97
95
|
*/
|
|
98
96
|
declare function renderAbsoluteImports(imports: AbsoluteImportDatum[]): string;
|
|
99
|
-
declare function renderWithStore(storeArgument: boolean, callback: (
|
|
97
|
+
declare function renderWithStore(storeArgument: boolean, callback: (data: {
|
|
98
|
+
_typedStore: string | undefined;
|
|
99
|
+
_store: string;
|
|
100
|
+
_commentSuffix: string;
|
|
101
|
+
_methodNamePrefix: string;
|
|
102
|
+
_useExplicitFieldLayout?: boolean;
|
|
103
|
+
}) => string): string;
|
|
100
104
|
declare function renderWithFieldSuffix(withSuffixlessFieldMethods: boolean, fieldName: string, callback: (_methodNameSuffix: string) => string): string;
|
|
101
105
|
declare function renderTableId({ namespace, name, offchainOnly, tableIdName }: StaticResourceData): {
|
|
102
106
|
hardcodedTableId: string;
|
package/dist/codegen.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import{a as
|
|
1
|
+
import{a as l}from"./chunk-TCWGPC6G.js";import{a as p}from"./chunk-UPQEB2HW.js";import X from"path";import{parse as j,visit as _}from"@solidity-parser/parser";function ne(r,t){let n=j(r),i=!1,s=[],o=[],y=[];if(_(n,{ContractDefinition({name:a}){a===t&&(i=!0)},FunctionDefinition({name:a,visibility:T,parameters:c,stateMutability:R,returnParameters:g,isConstructor:M,isFallback:L,isReceiveEther:k},u){if(u!==void 0&&u.type==="ContractDefinition"&&u.name===t)try{if(M||L||k)return;if(T==="default")throw new p("Visibility is not specified");if(T==="external"||T==="public"){o.push({name:a===null?"":a,parameters:c.map(m),stateMutability:R||"",returnParameters:g===null?[]:g.map(m)});for(let{typeName:I}of c.concat(g??[])){let W=f(I);s=s.concat(N(n,W))}}}catch(I){throw I instanceof p&&(I.message=`Function "${a}" in contract "${t}": ${I.message}`),I}},CustomErrorDefinition({name:a,parameters:T}){y.push({name:a===null?"":a,parameters:T.map(m)});for(let c of T){let R=f(c.typeName);s=s.concat(N(n,R))}}}),!i)throw new p(`Contract not found: ${t}`);return{functions:o,errors:y,symbolImports:s}}function m({name:r,typeName:t,storageLocation:n}){let i="",{name:s,stateMutability:o}=b(t);return i+=s,o!==null&&(i+=` ${o}`),n!==null&&(i+=` ${n}`),r!==null&&(i+=` ${r}`),i}function b(r){if(r===null)return{name:"",stateMutability:null};if(r.type==="ElementaryTypeName")return{name:r.name,stateMutability:r.stateMutability};if(r.type==="UserDefinedTypeName")return{name:r.namePath,stateMutability:null};if(r.type==="ArrayTypeName"){let t="";r.length?.type==="NumberLiteral"?t=r.length.number:r.length?.type==="Identifier"&&(t=r.length.name);let{name:n,stateMutability:i}=b(r.baseTypeName);return{name:`${n}[${t}]`,stateMutability:i}}else throw new p(`Invalid typeName.type ${r.type}`)}function f(r){if(r?.type==="UserDefinedTypeName")return[r.namePath.split(".")[0]];if(r?.type==="ArrayTypeName"){let t=f(r.baseTypeName);if(r.length?.type==="Identifier"){let n=r.length.name;t.push(n.split(".")[0])}return t}else return[]}function N(r,t){let n=[];for(let i of t){let s;if(_(r,{ImportDirective({path:o,symbolAliases:y}){if(y)for(let a of y){let T=a[1]||a[0];if(i===T){s={symbol:a[0],path:o};return}}}}),s)n.push(s);else throw new p(`Symbol "${i}" has no explicit import`)}return n}import{parse as O,visit as H}from"@solidity-parser/parser";function h(r,t,n){let i=O(r),s=n.at(0)===".",o={};return H(i,{TypeDefinition({name:y,definition:a},T){if(a.name.includes("fixed"))throw new p("Fixed point numbers are not supported by MUD");if(t.includes(y)){if(y in o)throw new p(`File has multiple user types with the same name: ${y}`);T?.type==="ContractDefinition"?o[y]={typeId:`${T.name}.${y}`,internalTypeId:a.name,importSymbol:T.name,fromPath:n,isRelativePath:s}:o[y]={typeId:y,internalTypeId:a.name,importSymbol:y,fromPath:n,isRelativePath:s}}}}),o}import d from"prettier";import K from"prettier-plugin-solidity";async function U(r,t){let n;t&&(n=await d.resolveConfig(t));try{return d.format(r,{plugins:[K],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}`),r}}async function E(r){return d.format(r,{parser:"typescript"})}import{mkdir as x,writeFile as $}from"fs/promises";import{dirname as w}from"path";var A=l.extend("codegen"),V=l.extend("codegen");A.log=console.debug.bind(console);V.log=console.error.bind(console);async function le(r,t,n){let i=await U(r);await x(w(t),{recursive:!0}),await $(t,i),A(`${n}: ${t}`)}async function me(r,t,n){let i=await E(r);await x(w(t),{recursive:!0}),await $(t,i),A(`${n}: ${t}`)}import{readFileSync as v}from"fs";import z from"path";function _e(r,t,n){let i={};for(let[o,{filePath:y}]of Object.entries(r))y in i||(i[y]=[]),i[y].push(o);let s={};for(let[o,y]of Object.entries(i)){let{filePath:a,data:T}=G(t,o,n),c=h(T,y,a);for(let[R,g]of Object.entries(c))if(g.internalTypeId!==r[R].internalType)throw new p(`User type "${R}" has internal type "${g.internalTypeId}" but config specifies "${r[R].internalType}"`);s={...s,...c}}return s}function G(r,t,n){if(t.at(0)===".")return{filePath:"./"+z.relative(r,t),data:v(t,"utf8")};{let i=t;for(let[s,o]of n)if(i.includes(s)){i=i.replace(s,o);break}return{filePath:t,data:v(i,"utf8")}}}function B(r){return r.replace(/\\/g,"/")}var D=`// SPDX-License-Identifier: MIT
|
|
2
2
|
pragma solidity >=0.8.21;
|
|
3
3
|
|
|
4
|
-
/* Autogenerated file. Do not edit manually. */`;function S(r,t){return
|
|
4
|
+
/* Autogenerated file. Do not edit manually. */`;function S(r,t){return F("",r,t)}function Y(r){let t=r.filter(n=>n!==void 0&&n!=="");return F(",",t,n=>n)}function Fe({staticResourceData:r,keyTuple:t}){let n=r?"":"ResourceId _tableId",i=Y(t.map(({name:o,typeWithLocation:y})=>`${y} ${o}`)),s=`
|
|
5
5
|
bytes32[] memory _keyTuple = new bytes32[](${t.length});
|
|
6
|
-
${S(t,(y
|
|
7
|
-
`;return{
|
|
8
|
-
`)}function
|
|
9
|
-
`+t("IStore _store","_store"," (using the specified store)","
|
|
6
|
+
${S(t,(o,y)=>`_keyTuple[${y}] = ${q(o.name,o)};`)}
|
|
7
|
+
`;return{_typedTableId:n,_typedKeyArgs:i,_keyTupleDefinition:s}}function P(r,t){return B("./"+X.relative("./"+t,"./"+r))}function Me(r){return C(r.map(t=>"path"in t?t:{symbol:t.symbol,path:P(t.fromPath,t.usedInPath)}))}function Le(r){return C(r.map(({symbol:t,fromPath:n,usedInPath:i})=>({symbol:t,path:P(n,i)})))}function C(r){let t=new Map;for(let{symbol:i,path:s}of r)t.has(s)||t.set(s,new Set),t.get(s)?.add(i);let n=[];for(let[i,s]of t){let o=[...s].join(", ");n.push(`import { ${o} } from "${B(i)}";`)}return n.join(`
|
|
8
|
+
`)}function ke(r,t){let n="";return n+=t({_typedStore:void 0,_store:"StoreSwitch",_commentSuffix:"",_methodNamePrefix:""}),n+=t({_typedStore:void 0,_store:"StoreCore",_commentSuffix:"",_methodNamePrefix:"_",_useExplicitFieldLayout:!0}),r&&(n+=`
|
|
9
|
+
`+t({_typedStore:"IStore _store",_store:"_store",_commentSuffix:" (using the specified store)",_methodNamePrefix:""})),n}function We(r,t,n){let i=`${t[0].toUpperCase()}${t.slice(1)}`,s="";return s+=n(i),r&&(s+=`
|
|
10
10
|
`+n("")),s}function je({namespace:r,name:t,offchainOnly:n,tableIdName:i}){let s=`
|
|
11
11
|
ResourceId.wrap(
|
|
12
12
|
bytes32(
|
|
@@ -20,10 +20,10 @@ pragma solidity >=0.8.21;
|
|
|
20
20
|
`,o=`
|
|
21
21
|
ResourceId constant _tableId = ${s};
|
|
22
22
|
ResourceId constant ${i} = _tableId;
|
|
23
|
-
`;return{hardcodedTableId:s,tableIdDefinition:o}}function q(r,{typeUnwrap:t,internalTypeId:n}){let i=t.length?`${t}(${r})`:r;if(n==="bytes32")return i;if(
|
|
23
|
+
`;return{hardcodedTableId:s,tableIdDefinition:o}}function q(r,{typeUnwrap:t,internalTypeId:n}){let i=t.length?`${t}(${r})`:r;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 J(r){return/^bytes\d{1,2}$/.test(r.internalTypeId)}function Oe(r){return J(r)?0:256-r.staticByteLength*8}function F(r,t,n){return t.map((i,s)=>n(i,s)+(s===t.length-1?"":r)).join(`
|
|
24
24
|
`)}function Ve(r){let t=D;return t+=S(r,({name:n,memberNames:i})=>`
|
|
25
25
|
enum ${n} {
|
|
26
|
-
${
|
|
26
|
+
${Y(i)}
|
|
27
27
|
}
|
|
28
28
|
`),t}function Ge(r){let{fields:t,keyTuple:n}=r,i="";for(let s of Q([...t,...n]))i+=s;return t.some(({internalTypeId:s})=>s.match("bool"))&&(i+=`
|
|
29
29
|
/**
|
|
@@ -47,7 +47,7 @@ pragma solidity >=0.8.21;
|
|
|
47
47
|
result := value
|
|
48
48
|
}
|
|
49
49
|
}
|
|
50
|
-
`),i}function Q(r){let t=new Map,n=new Map;for(let{typeWrappingData:i,typeWrap:s,typeUnwrap:o,internalTypeId:
|
|
50
|
+
`),i}function Q(r){let t=new Map,n=new Map;for(let{typeWrappingData:i,typeWrap:s,typeUnwrap:o,internalTypeId:y}of r){if(!i)continue;let{kind:a}=i;if(a==="staticArray"){let{elementType:T,staticLength:c}=i;t.set(s,Z(s,T,c,y)),n.set(o,ee(o,T,c,y))}}return[...t.values(),...n.values()]}function Z(r,t,n,i){return`
|
|
51
51
|
/**
|
|
52
52
|
* @notice Cast a dynamic array to a static array.
|
|
53
53
|
* @dev In memory static arrays are just dynamic arrays without the 32 length bytes,
|
|
@@ -94,5 +94,5 @@ pragma solidity >=0.8.21;
|
|
|
94
94
|
}
|
|
95
95
|
Memory.copy(fromPointer, toPointer, ${s});
|
|
96
96
|
}
|
|
97
|
-
`}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{ne as contractToInterface,h as extractUserTypes,le as formatAndWriteSolidity,me as formatAndWriteTypescript,U as formatSolidity,E as formatTypescript,Oe as getLeftPaddingBits,J as isLeftAligned,
|
|
97
|
+
`}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{ne as contractToInterface,h as extractUserTypes,le as formatAndWriteSolidity,me as formatAndWriteTypescript,U as formatSolidity,E as formatTypescript,Oe as getLeftPaddingBits,J as isLeftAligned,_e as loadAndExtractUserTypes,B as posixPath,C as renderAbsoluteImports,Y as renderArguments,Fe as renderCommonData,Ve as renderEnums,Me as renderImports,S as renderList,Le as renderRelativeImports,je as renderTableId,Ge as renderTypeHelpers,q as renderValueTypeToBytes32,We as renderWithFieldSuffix,ke as renderWithStore,D as renderedSolidityHeader,rt as schemaTypesToRecsTypeStrings,P as solidityRelativeImportPath};
|
|
98
98
|
//# sourceMappingURL=codegen.js.map
|
package/dist/codegen.js.map
CHANGED
|
@@ -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\";\n\nexport const renderedSolidityHeader = `// SPDX-License-Identifier: MIT\npragma solidity >=0.8.21;\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\nexport function renderCommonData({\n staticResourceData,\n keyTuple,\n}: {\n staticResourceData?: StaticResourceData;\n keyTuple: RenderKeyTuple[];\n}): {\n _tableId: string;\n _typedTableId: string;\n _keyArgs: string;\n _typedKeyArgs: string;\n _keyTupleDefinition: string;\n} {\n // static resource means static tableId as well, and no tableId arguments\n const _tableId = staticResourceData ? \"\" : \"_tableId\";\n const _typedTableId = staticResourceData ? \"\" : \"ResourceId _tableId\";\n\n const _keyArgs = renderArguments(keyTuple.map(({ name }) => name));\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 _tableId,\n _typedTableId,\n _keyArgs,\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\nexport function renderWithStore(\n storeArgument: boolean,\n callback: (\n _typedStore: string | undefined,\n _store: string,\n _commentSuffix: string,\n _untypedStore: string | undefined,\n _methodPrefix: string,\n _internal?: boolean\n ) => string\n): string {\n let result = \"\";\n result += callback(undefined, \"StoreSwitch\", \"\", undefined, \"\");\n result += callback(undefined, \"StoreCore\", \"\", undefined, \"_\", true);\n\n if (storeArgument) {\n result += \"\\n\" + callback(\"IStore _store\", \"_store\", \" (using the specified store)\", \"_store\", \"\");\n }\n\n return result;\n}\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\nexport function renderTableId({ namespace, name, offchainOnly, tableIdName }: StaticResourceData): {\n hardcodedTableId: string;\n tableIdDefinition: string;\n} {\n const hardcodedTableId = `\n ResourceId.wrap(\n bytes32(\n abi.encodePacked(\n ${offchainOnly ? \"RESOURCE_OFFCHAIN_TABLE\" : \"RESOURCE_TABLE\"},\n bytes14(\"${namespace}\"),\n bytes16(\"${name}\")\n )\n )\n )\n `;\n\n const tableIdDefinition = `\n ResourceId constant _tableId = ${hardcodedTableId};\n ResourceId constant ${tableIdName} = _tableId;\n `;\n return {\n hardcodedTableId,\n tableIdDefinition,\n };\n}\n\nexport function renderValueTypeToBytes32(name: string, { typeUnwrap, internalTypeId }: RenderType): string {\n const innerText = typeUnwrap.length ? `${typeUnwrap}(${name})` : name;\n\n if (internalTypeId === \"bytes32\") {\n return innerText;\n } else if (internalTypeId.match(/^bytes\\d{1,2}$/)) {\n return `bytes32(${innerText})`;\n } else if (internalTypeId.match(/^uint\\d{1,3}$/)) {\n return `bytes32(uint256(${innerText}))`;\n } else if (internalTypeId.match(/^int\\d{1,3}$/)) {\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\nexport function isLeftAligned(field: Pick<RenderType, \"internalTypeId\">): boolean {\n return field.internalTypeId.match(/^bytes\\d{1,2}$/) !== null;\n}\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\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 { SourceUnit, TypeName, VariableDeclaration } 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 let withContract = false;\n let symbolImports: SymbolImport[] = [];\n const functions: ContractInterfaceFunction[] = [];\n const errors: ContractInterfaceError[] = [];\n\n visit(ast, {\n ContractDefinition({ name }) {\n if (name === contractName) {\n withContract = true;\n }\n },\n FunctionDefinition(\n { name, visibility, parameters, stateMutability, returnParameters, isConstructor, isFallback, isReceiveEther },\n parent\n ) {\n if (parent !== undefined && parent.type === \"ContractDefinition\" && parent.name === contractName) {\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 },\n CustomErrorDefinition({ name, parameters }) {\n errors.push({\n name: name === null ? \"\" : 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 if (!withContract) {\n throw new MUDError(`Contract not found: ${contractName}`);\n }\n\n return {\n functions,\n errors,\n symbolImports,\n };\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 typeId: string;\n internalTypeId: string;\n importSymbol: string;\n fromPath: string;\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 */\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\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\nexport async function formatTypescript(content: string): Promise<string> {\n return prettier.format(content, {\n parser: \"typescript\",\n });\n}\n","import { mkdir, writeFile } from \"fs/promises\";\nimport { dirname } from \"path\";\nimport { formatSolidity, formatTypescript } from \"./format\";\nimport { debug } from \"../debug\";\n\nexport async function formatAndWriteSolidity(output: string, fullOutputPath: string, logPrefix: string): Promise<void> {\n const formattedOutput = await formatSolidity(output);\n\n await mkdir(dirname(fullOutputPath), { recursive: true });\n\n await writeFile(fullOutputPath, formattedOutput);\n debug(`${logPrefix}: ${fullOutputPath}`);\n}\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 mkdir(dirname(fullOutputPath), { recursive: true });\n\n await 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\";\n\nexport type UserType = {\n filePath: string;\n internalType: SchemaAbiType;\n};\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 = Object.assign(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 { renderArguments, renderList, renderedSolidityHeader } from \"./common\";\nimport { RenderEnum } from \"./types\";\n\nexport function renderEnums(enums: RenderEnum[]): string {\n let result = renderedSolidityHeader;\n\n result += renderList(\n enums,\n ({ name, memberNames }) => `\n enum ${name} {\n ${renderArguments(memberNames)}\n }\n `\n );\n\n return result;\n}\n","import { RenderField, RenderKeyTuple, RenderType } from \"./types\";\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\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\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":"gFAAA,OAAOA,MAAU,OCAjB,OAAS,SAAAC,EAAO,SAAAC,MAAa,0BA4BtB,SAASC,GACdC,EACAC,EAKA,CACA,IAAMC,EAAMC,E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C5B,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","withContract","symbolImports","functions","errors","visit","name","visibility","parameters","stateMutability","returnParameters","isConstructor","isFallback","isReceiveEther","parent","MUDError","parseParameter","typeName","symbols","typeNameToSymbols","symbolsToImports","error","parameter","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","mkdir","writeFile","dirname","debug","error","formatAndWriteSolidity","output","fullOutputPath","logPrefix","formattedOutput","formatSolidity","mkdir","dirname","writeFile","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","_tableId","_typedTableId","_keyArgs","name","_typedKeyArgs","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","tableIdName","hardcodedTableId","tableIdDefinition","typeUnwrap","internalTypeId","innerText","isLeftAligned","field","getLeftPaddingBits","lineTerminator","item","renderEnums","enums","result","renderedSolidityHeader","renderList","name","memberNames","renderArguments","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/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\";\n\nexport const renderedSolidityHeader = `// SPDX-License-Identifier: MIT\npragma solidity >=0.8.21;\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\nexport function renderCommonData({\n staticResourceData,\n keyTuple,\n}: {\n staticResourceData?: StaticResourceData;\n keyTuple: RenderKeyTuple[];\n}): {\n _typedTableId: string;\n _typedKeyArgs: string;\n _keyTupleDefinition: string;\n} {\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\nexport function renderWithStore(\n storeArgument: boolean,\n callback: (data: {\n _typedStore: string | undefined;\n _store: string;\n _commentSuffix: string;\n _methodNamePrefix: string;\n _useExplicitFieldLayout?: boolean;\n }) => 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\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\nexport function renderTableId({ namespace, name, offchainOnly, tableIdName }: StaticResourceData): {\n hardcodedTableId: string;\n tableIdDefinition: string;\n} {\n const hardcodedTableId = `\n ResourceId.wrap(\n bytes32(\n abi.encodePacked(\n ${offchainOnly ? \"RESOURCE_OFFCHAIN_TABLE\" : \"RESOURCE_TABLE\"},\n bytes14(\"${namespace}\"),\n bytes16(\"${name}\")\n )\n )\n )\n `;\n\n const tableIdDefinition = `\n ResourceId constant _tableId = ${hardcodedTableId};\n ResourceId constant ${tableIdName} = _tableId;\n `;\n return {\n hardcodedTableId,\n tableIdDefinition,\n };\n}\n\nexport function renderValueTypeToBytes32(name: string, { typeUnwrap, internalTypeId }: RenderType): 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\nexport function isLeftAligned(field: Pick<RenderType, \"internalTypeId\">): boolean {\n return /^bytes\\d{1,2}$/.test(field.internalTypeId);\n}\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\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 { SourceUnit, TypeName, VariableDeclaration } 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 let withContract = false;\n let symbolImports: SymbolImport[] = [];\n const functions: ContractInterfaceFunction[] = [];\n const errors: ContractInterfaceError[] = [];\n\n visit(ast, {\n ContractDefinition({ name }) {\n if (name === contractName) {\n withContract = true;\n }\n },\n FunctionDefinition(\n { name, visibility, parameters, stateMutability, returnParameters, isConstructor, isFallback, isReceiveEther },\n parent\n ) {\n if (parent !== undefined && parent.type === \"ContractDefinition\" && parent.name === contractName) {\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 },\n CustomErrorDefinition({ name, parameters }) {\n errors.push({\n name: name === null ? \"\" : 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 if (!withContract) {\n throw new MUDError(`Contract not found: ${contractName}`);\n }\n\n return {\n functions,\n errors,\n symbolImports,\n };\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 typeId: string;\n internalTypeId: string;\n importSymbol: string;\n fromPath: string;\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 */\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\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\nexport async function formatTypescript(content: string): Promise<string> {\n return prettier.format(content, {\n parser: \"typescript\",\n });\n}\n","import { mkdir, writeFile } from \"fs/promises\";\nimport { dirname } from \"path\";\nimport { formatSolidity, formatTypescript } from \"./format\";\nimport { debug } from \"../debug\";\n\nexport async function formatAndWriteSolidity(output: string, fullOutputPath: string, logPrefix: string): Promise<void> {\n const formattedOutput = await formatSolidity(output);\n\n await mkdir(dirname(fullOutputPath), { recursive: true });\n\n await writeFile(fullOutputPath, formattedOutput);\n debug(`${logPrefix}: ${fullOutputPath}`);\n}\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 mkdir(dirname(fullOutputPath), { recursive: true });\n\n await 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\";\n\nexport type UserType = {\n filePath: string;\n internalType: SchemaAbiType;\n};\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 { renderArguments, renderList, renderedSolidityHeader } from \"./common\";\nimport { RenderEnum } from \"./types\";\n\nexport function renderEnums(enums: RenderEnum[]): string {\n let result = renderedSolidityHeader;\n\n result += renderList(\n enums,\n ({ name, memberNames }) => `\n enum ${name} {\n ${renderArguments(memberNames)}\n }\n `\n );\n\n return result;\n}\n","import { RenderField, RenderKeyTuple, RenderType } from \"./types\";\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\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\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":"gFAAA,OAAOA,MAAU,OCAjB,OAAS,SAAAC,EAAO,SAAAC,MAAa,0BA4BtB,SAASC,GACdC,EACAC,EAKA,CACA,IAAMC,EAAMC,EAAMH,CAAI,EAElBI,EAAe,GACfC,EAAgC,CAAC,EAC/BC,EAAyC,CAAC,EAC1CC,EAAmC,CAAC,EAqD1C,GAnDAC,EAAMN,EAAK,CACT,mBAAmB,CAAE,KAAAO,CAAK,EAAG,CACvBA,IAASR,IACXG,EAAe,GAEnB,EACA,mBACE,CAAE,KAAAK,EAAM,WAAAC,EAAY,WAAAC,EAAY,gBAAAC,EAAiB,iBAAAC,EAAkB,cAAAC,EAAe,WAAAC,EAAY,eAAAC,CAAe,EAC7GC,EACA,CACA,GAAIA,IAAW,QAAaA,EAAO,OAAS,sBAAwBA,EAAO,OAAShB,EAClF,GAAI,CAEF,GAAIa,GAAiBC,GAAcC,EAAgB,OA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W,aAAa,EAAG,uBAC5B,CAACA,EAAW,KAAK,EAAG,kBACpB,CAACA,EAAW,MAAM,EAAG,iBACvB","names":["path","parse","visit","contractToInterface","data","contractName","ast","parse","withContract","symbolImports","functions","errors","visit","name","visibility","parameters","stateMutability","returnParameters","isConstructor","isFallback","isReceiveEther","parent","MUDError","parseParameter","typeName","symbols","typeNameToSymbols","symbolsToImports","error","parameter","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","mkdir","writeFile","dirname","debug","error","formatAndWriteSolidity","output","fullOutputPath","logPrefix","formattedOutput","formatSolidity","mkdir","dirname","writeFile","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","tableIdName","hardcodedTableId","tableIdDefinition","typeUnwrap","internalTypeId","innerText","isLeftAligned","field","getLeftPaddingBits","lineTerminator","item","renderEnums","enums","result","renderedSolidityHeader","renderList","name","memberNames","renderArguments","renderTypeHelpers","options","fields","keyTuple","result","wrappingHelper","getWrappingHelpers","internalTypeId","array","wrappers","unwrappers","typeWrappingData","typeWrap","typeUnwrap","kind","elementType","staticLength","renderWrapperStaticArray","renderUnwrapperStaticArray","functionName","byteLength","SchemaType","schemaTypesToRecsTypeStrings"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@latticexyz/common",
|
|
3
|
-
"version": "2.0.0-next.
|
|
3
|
+
"version": "2.0.0-next.16",
|
|
4
4
|
"description": "Common low level logic shared between packages",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -52,7 +52,7 @@
|
|
|
52
52
|
"prettier": "^2.8.4",
|
|
53
53
|
"prettier-plugin-solidity": "1.1.3",
|
|
54
54
|
"viem": "1.14.0",
|
|
55
|
-
"@latticexyz/schema-type": "2.0.0-next.
|
|
55
|
+
"@latticexyz/schema-type": "2.0.0-next.16"
|
|
56
56
|
},
|
|
57
57
|
"devDependencies": {
|
|
58
58
|
"@types/debug": "^4.1.7",
|
|
@@ -36,17 +36,12 @@ export function renderCommonData({
|
|
|
36
36
|
staticResourceData?: StaticResourceData;
|
|
37
37
|
keyTuple: RenderKeyTuple[];
|
|
38
38
|
}): {
|
|
39
|
-
_tableId: string;
|
|
40
39
|
_typedTableId: string;
|
|
41
|
-
_keyArgs: string;
|
|
42
40
|
_typedKeyArgs: string;
|
|
43
41
|
_keyTupleDefinition: string;
|
|
44
42
|
} {
|
|
45
43
|
// static resource means static tableId as well, and no tableId arguments
|
|
46
|
-
const _tableId = staticResourceData ? "" : "_tableId";
|
|
47
44
|
const _typedTableId = staticResourceData ? "" : "ResourceId _tableId";
|
|
48
|
-
|
|
49
|
-
const _keyArgs = renderArguments(keyTuple.map(({ name }) => name));
|
|
50
45
|
const _typedKeyArgs = renderArguments(keyTuple.map(({ name, typeWithLocation }) => `${typeWithLocation} ${name}`));
|
|
51
46
|
|
|
52
47
|
const _keyTupleDefinition = `
|
|
@@ -55,9 +50,7 @@ export function renderCommonData({
|
|
|
55
50
|
`;
|
|
56
51
|
|
|
57
52
|
return {
|
|
58
|
-
_tableId,
|
|
59
53
|
_typedTableId,
|
|
60
|
-
_keyArgs,
|
|
61
54
|
_typedKeyArgs,
|
|
62
55
|
_keyTupleDefinition,
|
|
63
56
|
};
|
|
@@ -127,21 +120,33 @@ export function renderAbsoluteImports(imports: AbsoluteImportDatum[]): string {
|
|
|
127
120
|
|
|
128
121
|
export function renderWithStore(
|
|
129
122
|
storeArgument: boolean,
|
|
130
|
-
callback: (
|
|
131
|
-
_typedStore: string | undefined
|
|
132
|
-
_store: string
|
|
133
|
-
_commentSuffix: string
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
) => string
|
|
123
|
+
callback: (data: {
|
|
124
|
+
_typedStore: string | undefined;
|
|
125
|
+
_store: string;
|
|
126
|
+
_commentSuffix: string;
|
|
127
|
+
_methodNamePrefix: string;
|
|
128
|
+
_useExplicitFieldLayout?: boolean;
|
|
129
|
+
}) => string
|
|
138
130
|
): string {
|
|
139
131
|
let result = "";
|
|
140
|
-
result += callback(undefined, "StoreSwitch", "",
|
|
141
|
-
result += callback(
|
|
132
|
+
result += callback({ _typedStore: undefined, _store: "StoreSwitch", _commentSuffix: "", _methodNamePrefix: "" });
|
|
133
|
+
result += callback({
|
|
134
|
+
_typedStore: undefined,
|
|
135
|
+
_store: "StoreCore",
|
|
136
|
+
_commentSuffix: "",
|
|
137
|
+
_methodNamePrefix: "_",
|
|
138
|
+
_useExplicitFieldLayout: true,
|
|
139
|
+
});
|
|
142
140
|
|
|
143
141
|
if (storeArgument) {
|
|
144
|
-
result +=
|
|
142
|
+
result +=
|
|
143
|
+
"\n" +
|
|
144
|
+
callback({
|
|
145
|
+
_typedStore: "IStore _store",
|
|
146
|
+
_store: "_store",
|
|
147
|
+
_commentSuffix: " (using the specified store)",
|
|
148
|
+
_methodNamePrefix: "",
|
|
149
|
+
});
|
|
145
150
|
}
|
|
146
151
|
|
|
147
152
|
return result;
|
|
@@ -194,11 +199,11 @@ export function renderValueTypeToBytes32(name: string, { typeUnwrap, internalTyp
|
|
|
194
199
|
|
|
195
200
|
if (internalTypeId === "bytes32") {
|
|
196
201
|
return innerText;
|
|
197
|
-
} else if (
|
|
202
|
+
} else if (/^bytes\d{1,2}$/.test(internalTypeId)) {
|
|
198
203
|
return `bytes32(${innerText})`;
|
|
199
|
-
} else if (
|
|
204
|
+
} else if (/^uint\d{1,3}$/.test(internalTypeId)) {
|
|
200
205
|
return `bytes32(uint256(${innerText}))`;
|
|
201
|
-
} else if (
|
|
206
|
+
} else if (/^int\d{1,3}$/.test(internalTypeId)) {
|
|
202
207
|
return `bytes32(uint256(int256(${innerText})))`;
|
|
203
208
|
} else if (internalTypeId === "address") {
|
|
204
209
|
return `bytes32(uint256(uint160(${innerText})))`;
|
|
@@ -210,7 +215,7 @@ export function renderValueTypeToBytes32(name: string, { typeUnwrap, internalTyp
|
|
|
210
215
|
}
|
|
211
216
|
|
|
212
217
|
export function isLeftAligned(field: Pick<RenderType, "internalTypeId">): boolean {
|
|
213
|
-
return
|
|
218
|
+
return /^bytes\d{1,2}$/.test(field.internalTypeId);
|
|
214
219
|
}
|
|
215
220
|
|
|
216
221
|
export function getLeftPaddingBits(field: Pick<RenderType, "internalTypeId" | "staticByteLength">): number {
|