@latticexyz/common 2.2.23-c9a7e15b89f6e4486abcb46c3a75c213741816a4 → 2.2.23-cd0fa57c590233c5f099d6e469c46c6b51e2c46d
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/chains.d.ts +7 -0
- package/dist/codegen.d.ts +33 -2
- package/dist/codegen.js +232 -19
- package/dist/codegen.js.map +1 -1
- package/dist/foundry.d.ts +7 -1
- package/dist/foundry.js +4 -0
- package/dist/foundry.js.map +1 -1
- package/dist/internal.d.ts +4 -2
- package/dist/internal.js +1 -0
- package/package.json +4 -4
package/dist/chains.d.ts
CHANGED
|
@@ -26,6 +26,7 @@ declare const mudFoundry: {
|
|
|
26
26
|
apiUrl?: string | undefined;
|
|
27
27
|
};
|
|
28
28
|
} | undefined;
|
|
29
|
+
readonly blockTime?: number | undefined;
|
|
29
30
|
readonly contracts?: {
|
|
30
31
|
[x: string]: viem.ChainContract | {
|
|
31
32
|
[sourceId: number]: viem.ChainContract | undefined;
|
|
@@ -43,6 +44,7 @@ declare const mudFoundry: {
|
|
|
43
44
|
readonly name: "Ether";
|
|
44
45
|
readonly symbol: "ETH";
|
|
45
46
|
};
|
|
47
|
+
readonly experimental_preconfirmationTime?: number | undefined;
|
|
46
48
|
readonly rpcUrls: {
|
|
47
49
|
readonly default: {
|
|
48
50
|
readonly http: readonly ["http://127.0.0.1:8545"];
|
|
@@ -65,6 +67,7 @@ declare const redstone: {
|
|
|
65
67
|
readonly url: "https://explorer.redstone.xyz";
|
|
66
68
|
};
|
|
67
69
|
};
|
|
70
|
+
readonly blockTime: 2000;
|
|
68
71
|
readonly contracts: {
|
|
69
72
|
readonly multicall3: {
|
|
70
73
|
readonly address: "0xca11bde05977b3631167028862be2a173976ca11";
|
|
@@ -114,6 +117,7 @@ declare const redstone: {
|
|
|
114
117
|
readonly name: "Ether";
|
|
115
118
|
readonly symbol: "ETH";
|
|
116
119
|
};
|
|
120
|
+
readonly experimental_preconfirmationTime?: number | undefined;
|
|
117
121
|
readonly rpcUrls: {
|
|
118
122
|
readonly default: {
|
|
119
123
|
readonly http: readonly ["https://rpc.redstonechain.com"];
|
|
@@ -423,6 +427,7 @@ declare const garnet: {
|
|
|
423
427
|
readonly url: "https://explorer.garnetchain.com";
|
|
424
428
|
};
|
|
425
429
|
};
|
|
430
|
+
readonly blockTime: 2000;
|
|
426
431
|
readonly ensTlds?: readonly string[] | undefined;
|
|
427
432
|
readonly id: 17069;
|
|
428
433
|
readonly name: "Garnet Testnet";
|
|
@@ -431,6 +436,7 @@ declare const garnet: {
|
|
|
431
436
|
readonly symbol: "ETH";
|
|
432
437
|
readonly decimals: 18;
|
|
433
438
|
};
|
|
439
|
+
readonly experimental_preconfirmationTime?: number | undefined;
|
|
434
440
|
readonly sourceId: 17000;
|
|
435
441
|
readonly testnet: true;
|
|
436
442
|
readonly custom?: Record<string, unknown> | undefined;
|
|
@@ -731,6 +737,7 @@ declare const pyrope: {
|
|
|
731
737
|
};
|
|
732
738
|
readonly iconUrls: readonly ["https://lattice.xyz/brand/color/pyrope.svg"];
|
|
733
739
|
readonly indexerUrl: "https://indexer.mud.pyropechain.com";
|
|
740
|
+
readonly blockTime: 2000;
|
|
734
741
|
readonly formatters: {
|
|
735
742
|
readonly block: {
|
|
736
743
|
exclude: [] | undefined;
|
package/dist/codegen.d.ts
CHANGED
|
@@ -182,6 +182,11 @@ interface ContractInterfaceError {
|
|
|
182
182
|
name: string;
|
|
183
183
|
parameters: string[];
|
|
184
184
|
}
|
|
185
|
+
interface QualifiedSymbol {
|
|
186
|
+
symbol: string;
|
|
187
|
+
qualifier?: string;
|
|
188
|
+
sourcePath: string;
|
|
189
|
+
}
|
|
185
190
|
/**
|
|
186
191
|
* Parse the contract data to get the functions necessary to generate an interface,
|
|
187
192
|
* and symbols to import from the original contract.
|
|
@@ -189,10 +194,11 @@ interface ContractInterfaceError {
|
|
|
189
194
|
* @param contractName name of the contract
|
|
190
195
|
* @returns interface data
|
|
191
196
|
*/
|
|
192
|
-
declare function contractToInterface(source: string, contractName: string): {
|
|
197
|
+
declare function contractToInterface(source: string, contractName: string, findInheritedSymbol?: (symbol: string) => QualifiedSymbol | undefined): {
|
|
193
198
|
functions: ContractInterfaceFunction[];
|
|
194
199
|
errors: ContractInterfaceError[];
|
|
195
200
|
symbolImports: SymbolImport[];
|
|
201
|
+
qualifiedSymbols: Map<string, QualifiedSymbol>;
|
|
196
202
|
};
|
|
197
203
|
|
|
198
204
|
/**
|
|
@@ -228,4 +234,29 @@ declare function parseSystem(source: string, contractName: string): undefined |
|
|
|
228
234
|
contractType: "contract" | "abstract";
|
|
229
235
|
};
|
|
230
236
|
|
|
231
|
-
|
|
237
|
+
/**
|
|
238
|
+
* Creates a resolver function that can find symbols through contract inheritance chains
|
|
239
|
+
* @param contractPath Path to the contract file
|
|
240
|
+
* @param contractName Name of the contract
|
|
241
|
+
* @returns A function that resolves symbols to their qualified forms
|
|
242
|
+
*/
|
|
243
|
+
declare function createInheritanceResolver(contractPath: string, contractName: string, rootDir: string, remappings?: string[]): Promise<(symbol: string) => QualifiedSymbol | undefined>;
|
|
244
|
+
|
|
245
|
+
/**
|
|
246
|
+
* Apply type qualifiers to function parameters or return types
|
|
247
|
+
* @param params Array of parameter strings (e.g., ["uint256 value", "SomeStruct memory data"])
|
|
248
|
+
* @param typeQualifiers Map of type names to their qualified forms (e.g., "SomeStruct" -> "IParent.SomeStruct")
|
|
249
|
+
* @returns Array of parameters with qualified types applied
|
|
250
|
+
*/
|
|
251
|
+
declare function applyTypeQualifiers(params: string[], typeQualifiers?: Map<string, string>): string[];
|
|
252
|
+
|
|
253
|
+
/**
|
|
254
|
+
* Resolves an import path using forge remappings
|
|
255
|
+
* @param importPath The import path to resolve (e.g., "@latticexyz/store/src/Store.sol")
|
|
256
|
+
* @param remappings Array of forge remapping strings (e.g., ["@latticexyz/=node_modules/@latticexyz/"])
|
|
257
|
+
* @param rootDir The root directory to resolve relative to
|
|
258
|
+
* @returns The resolved file path, or the original path if no remapping applies
|
|
259
|
+
*/
|
|
260
|
+
declare function resolveRemapping(importPath: string, remappings: string[], rootDir: string): string;
|
|
261
|
+
|
|
262
|
+
export { type AbiToInterfaceOptions, type ContractInterfaceError, type ContractInterfaceFunction, type ImportDatum, type QualifiedSymbol, type RenderDynamicField, type RenderEnum, type RenderField, type RenderFieldTypeWrappingData, type RenderKeyTuple, type RenderStaticField, type RenderType, type StaticResourceData, abiToInterface, applyTypeQualifiers, contractToInterface, createInheritanceResolver, formatAndWriteSolidity, formatAndWriteTypescript, formatSolidity, formatTypescript, getLeftPaddingBits, isLeftAligned, parseSystem, renderArguments, renderCommonData, renderEnums, renderImportPath, renderImports, renderList, renderTableId, renderTypeHelpers, renderValueTypeToBytes32, renderWithFieldSuffix, renderWithStore, renderedSolidityHeader, resolveRemapping, schemaTypesToRecsTypeStrings };
|
package/dist/codegen.js
CHANGED
|
@@ -58,16 +58,16 @@ function renderCommonData({
|
|
|
58
58
|
}
|
|
59
59
|
function renderImports(imports) {
|
|
60
60
|
const aggregatedImports = /* @__PURE__ */ new Map();
|
|
61
|
-
for (const { symbol, path:
|
|
62
|
-
if (!aggregatedImports.has(
|
|
63
|
-
aggregatedImports.set(
|
|
61
|
+
for (const { symbol, path: path5 } of imports) {
|
|
62
|
+
if (!aggregatedImports.has(path5)) {
|
|
63
|
+
aggregatedImports.set(path5, /* @__PURE__ */ new Set());
|
|
64
64
|
}
|
|
65
|
-
aggregatedImports.get(
|
|
65
|
+
aggregatedImports.get(path5)?.add(symbol);
|
|
66
66
|
}
|
|
67
67
|
const renderedImports = [];
|
|
68
|
-
for (const [
|
|
68
|
+
for (const [path5, symbols] of aggregatedImports) {
|
|
69
69
|
const renderedSymbols = [...symbols].join(", ");
|
|
70
|
-
renderedImports.push(`import { ${renderedSymbols} } from "${renderImportPath(
|
|
70
|
+
renderedImports.push(`import { ${renderedSymbols} } from "${renderImportPath(path5)}";`);
|
|
71
71
|
}
|
|
72
72
|
return renderedImports.join("\n");
|
|
73
73
|
}
|
|
@@ -540,7 +540,7 @@ import { visit as visit2 } from "@solidity-parser/parser";
|
|
|
540
540
|
function findSymbolImport(ast, symbol) {
|
|
541
541
|
let symbolImport;
|
|
542
542
|
visit2(ast, {
|
|
543
|
-
ImportDirective({ path:
|
|
543
|
+
ImportDirective({ path: path5, symbolAliases }) {
|
|
544
544
|
if (symbolAliases) {
|
|
545
545
|
for (const symbolAndAlias of symbolAliases) {
|
|
546
546
|
const symbolAlias = symbolAndAlias[1] ?? symbolAndAlias[0];
|
|
@@ -548,7 +548,7 @@ function findSymbolImport(ast, symbol) {
|
|
|
548
548
|
symbolImport = {
|
|
549
549
|
// always use the original symbol for interface imports
|
|
550
550
|
symbol: symbolAndAlias[0],
|
|
551
|
-
path:
|
|
551
|
+
path: path5
|
|
552
552
|
};
|
|
553
553
|
return;
|
|
554
554
|
}
|
|
@@ -560,12 +560,18 @@ function findSymbolImport(ast, symbol) {
|
|
|
560
560
|
}
|
|
561
561
|
|
|
562
562
|
// src/codegen/utils/contractToInterface.ts
|
|
563
|
-
function contractToInterface(source, contractName) {
|
|
564
|
-
|
|
563
|
+
function contractToInterface(source, contractName, findInheritedSymbol) {
|
|
564
|
+
let ast;
|
|
565
|
+
try {
|
|
566
|
+
ast = parse(source);
|
|
567
|
+
} catch (error2) {
|
|
568
|
+
throw new MUDError(`Failed to parse contract ${contractName}: ${error2}`);
|
|
569
|
+
}
|
|
565
570
|
const contractNode = findContractNode(ast, contractName);
|
|
566
571
|
let symbolImports = [];
|
|
567
572
|
const functions = [];
|
|
568
573
|
const errors = [];
|
|
574
|
+
const qualifiedSymbols = /* @__PURE__ */ new Map();
|
|
569
575
|
if (!contractNode) {
|
|
570
576
|
throw new MUDError(`Contract not found: ${contractName}`);
|
|
571
577
|
}
|
|
@@ -592,7 +598,7 @@ function contractToInterface(source, contractName) {
|
|
|
592
598
|
});
|
|
593
599
|
for (const { typeName } of parameters.concat(returnParameters ?? [])) {
|
|
594
600
|
const symbols = typeNameToSymbols(typeName);
|
|
595
|
-
symbolImports = symbolImports.concat(symbolsToImports(ast, symbols));
|
|
601
|
+
symbolImports = symbolImports.concat(symbolsToImports(ast, symbols, findInheritedSymbol, qualifiedSymbols));
|
|
596
602
|
}
|
|
597
603
|
}
|
|
598
604
|
} catch (error2) {
|
|
@@ -609,14 +615,15 @@ function contractToInterface(source, contractName) {
|
|
|
609
615
|
});
|
|
610
616
|
for (const parameter of parameters) {
|
|
611
617
|
const symbols = typeNameToSymbols(parameter.typeName);
|
|
612
|
-
symbolImports = symbolImports.concat(symbolsToImports(ast, symbols));
|
|
618
|
+
symbolImports = symbolImports.concat(symbolsToImports(ast, symbols, findInheritedSymbol, qualifiedSymbols));
|
|
613
619
|
}
|
|
614
620
|
}
|
|
615
621
|
});
|
|
616
622
|
return {
|
|
617
623
|
functions,
|
|
618
624
|
errors,
|
|
619
|
-
symbolImports
|
|
625
|
+
symbolImports,
|
|
626
|
+
qualifiedSymbols
|
|
620
627
|
};
|
|
621
628
|
}
|
|
622
629
|
function parseParameter({ name, typeName, storageLocation }) {
|
|
@@ -682,12 +689,37 @@ function typeNameToSymbols(typeName) {
|
|
|
682
689
|
return [];
|
|
683
690
|
}
|
|
684
691
|
}
|
|
685
|
-
function symbolsToImports(ast, symbols) {
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
692
|
+
function symbolsToImports(ast, symbols, findInheritedSymbol, qualifiedSymbols) {
|
|
693
|
+
const imports = [];
|
|
694
|
+
for (const symbol of symbols) {
|
|
695
|
+
const explicitImport = findSymbolImport(ast, symbol);
|
|
696
|
+
if (explicitImport) {
|
|
697
|
+
imports.push(explicitImport);
|
|
698
|
+
continue;
|
|
699
|
+
}
|
|
700
|
+
if (findInheritedSymbol) {
|
|
701
|
+
const inheritedSymbol = findInheritedSymbol(symbol);
|
|
702
|
+
if (inheritedSymbol) {
|
|
703
|
+
if (qualifiedSymbols) {
|
|
704
|
+
qualifiedSymbols.set(symbol, inheritedSymbol);
|
|
705
|
+
}
|
|
706
|
+
if (inheritedSymbol.qualifier) {
|
|
707
|
+
imports.push({
|
|
708
|
+
symbol: inheritedSymbol.qualifier,
|
|
709
|
+
path: inheritedSymbol.sourcePath
|
|
710
|
+
});
|
|
711
|
+
}
|
|
712
|
+
}
|
|
713
|
+
}
|
|
714
|
+
}
|
|
715
|
+
const uniqueImports = /* @__PURE__ */ new Map();
|
|
716
|
+
for (const imp of imports) {
|
|
717
|
+
const key = `${imp.symbol}:${imp.path}`;
|
|
718
|
+
if (!uniqueImports.has(key)) {
|
|
719
|
+
uniqueImports.set(key, imp);
|
|
720
|
+
}
|
|
721
|
+
}
|
|
722
|
+
return Array.from(uniqueImports.values());
|
|
691
723
|
}
|
|
692
724
|
|
|
693
725
|
// src/codegen/utils/format.ts
|
|
@@ -781,9 +813,189 @@ function parseSystem(source, contractName) {
|
|
|
781
813
|
return { contractType };
|
|
782
814
|
}
|
|
783
815
|
}
|
|
816
|
+
|
|
817
|
+
// src/codegen/utils/resolveInheritedSymbols.ts
|
|
818
|
+
import { parse as parse3, visit as visit5 } from "@solidity-parser/parser";
|
|
819
|
+
import { readFile } from "node:fs/promises";
|
|
820
|
+
import path4 from "node:path";
|
|
821
|
+
|
|
822
|
+
// src/codegen/utils/resolveRemapping.ts
|
|
823
|
+
import path3 from "path";
|
|
824
|
+
function resolveRemapping(importPath, remappings, rootDir) {
|
|
825
|
+
const parsedRemappings = remappings.map((remapping) => {
|
|
826
|
+
const [from, to] = remapping.split("=");
|
|
827
|
+
return { from, to };
|
|
828
|
+
});
|
|
829
|
+
parsedRemappings.sort((a, b) => b.from.length - a.from.length);
|
|
830
|
+
for (const { from, to } of parsedRemappings) {
|
|
831
|
+
if (importPath.startsWith(from)) {
|
|
832
|
+
const resolvedPath = importPath.replace(from, to);
|
|
833
|
+
return path3.resolve(rootDir, resolvedPath);
|
|
834
|
+
}
|
|
835
|
+
}
|
|
836
|
+
return importPath;
|
|
837
|
+
}
|
|
838
|
+
|
|
839
|
+
// src/codegen/utils/resolveInheritedSymbols.ts
|
|
840
|
+
async function createInheritanceResolver(contractPath, contractName, rootDir, remappings = []) {
|
|
841
|
+
const resolvedContracts = /* @__PURE__ */ new Map();
|
|
842
|
+
const visitedPaths = /* @__PURE__ */ new Set();
|
|
843
|
+
async function parseContract(filePath, targetContractName) {
|
|
844
|
+
const normalizedPath = path4.resolve(filePath);
|
|
845
|
+
const visitKey = targetContractName ? `${normalizedPath}:${targetContractName}` : normalizedPath;
|
|
846
|
+
if (visitedPaths.has(visitKey)) {
|
|
847
|
+
return void 0;
|
|
848
|
+
}
|
|
849
|
+
visitedPaths.add(visitKey);
|
|
850
|
+
try {
|
|
851
|
+
const source = await readFile(filePath, "utf8");
|
|
852
|
+
let ast;
|
|
853
|
+
try {
|
|
854
|
+
ast = parse3(source);
|
|
855
|
+
} catch (parseError) {
|
|
856
|
+
console.warn(`Warning: Failed to parse ${filePath} for inheritance resolution:`, parseError);
|
|
857
|
+
return void 0;
|
|
858
|
+
}
|
|
859
|
+
const contractsToProcess = [];
|
|
860
|
+
if (targetContractName) {
|
|
861
|
+
const contractNode = findContractNode(ast, targetContractName);
|
|
862
|
+
if (contractNode) {
|
|
863
|
+
contractsToProcess.push(contractNode);
|
|
864
|
+
}
|
|
865
|
+
} else {
|
|
866
|
+
visit5(ast, {
|
|
867
|
+
ContractDefinition(node) {
|
|
868
|
+
contractsToProcess.push(node);
|
|
869
|
+
}
|
|
870
|
+
});
|
|
871
|
+
}
|
|
872
|
+
for (const contractNode of contractsToProcess) {
|
|
873
|
+
const info = {
|
|
874
|
+
baseContracts: [],
|
|
875
|
+
baseContractImports: /* @__PURE__ */ new Map(),
|
|
876
|
+
symbols: /* @__PURE__ */ new Map(),
|
|
877
|
+
filePath: normalizedPath
|
|
878
|
+
};
|
|
879
|
+
if (contractNode.baseContracts) {
|
|
880
|
+
for (const base of contractNode.baseContracts) {
|
|
881
|
+
info.baseContracts.push(base.baseName.namePath);
|
|
882
|
+
}
|
|
883
|
+
}
|
|
884
|
+
visit5(contractNode, {
|
|
885
|
+
StructDefinition(node) {
|
|
886
|
+
if (node.name) {
|
|
887
|
+
info.symbols.set(node.name, { type: "struct", contract: contractNode.name });
|
|
888
|
+
}
|
|
889
|
+
},
|
|
890
|
+
EnumDefinition(node) {
|
|
891
|
+
if (node.name) {
|
|
892
|
+
info.symbols.set(node.name, { type: "enum", contract: contractNode.name });
|
|
893
|
+
}
|
|
894
|
+
},
|
|
895
|
+
CustomErrorDefinition(node) {
|
|
896
|
+
if (node.name) {
|
|
897
|
+
info.symbols.set(node.name, { type: "error", contract: contractNode.name });
|
|
898
|
+
}
|
|
899
|
+
}
|
|
900
|
+
});
|
|
901
|
+
resolvedContracts.set(contractNode.name, info);
|
|
902
|
+
for (const baseName of info.baseContracts) {
|
|
903
|
+
const importInfo = findSymbolImport(ast, baseName);
|
|
904
|
+
if (importInfo) {
|
|
905
|
+
info.baseContractImports.set(baseName, importInfo.path);
|
|
906
|
+
const resolvedPath = importInfo.path.startsWith(".") ? path4.resolve(path4.dirname(filePath), importInfo.path) : resolveRemapping(importInfo.path, remappings, rootDir);
|
|
907
|
+
await parseContract(resolvedPath, baseName);
|
|
908
|
+
}
|
|
909
|
+
}
|
|
910
|
+
}
|
|
911
|
+
return targetContractName ? resolvedContracts.get(targetContractName) : void 0;
|
|
912
|
+
} catch (error2) {
|
|
913
|
+
return void 0;
|
|
914
|
+
}
|
|
915
|
+
}
|
|
916
|
+
await parseContract(contractPath, contractName);
|
|
917
|
+
return (symbol) => {
|
|
918
|
+
const mainInfo = resolvedContracts.get(contractName);
|
|
919
|
+
if (mainInfo?.symbols.has(symbol)) {
|
|
920
|
+
return {
|
|
921
|
+
symbol,
|
|
922
|
+
sourcePath: contractPath
|
|
923
|
+
};
|
|
924
|
+
}
|
|
925
|
+
function searchInheritance(currentContract, visited = /* @__PURE__ */ new Set()) {
|
|
926
|
+
if (visited.has(currentContract)) {
|
|
927
|
+
return void 0;
|
|
928
|
+
}
|
|
929
|
+
visited.add(currentContract);
|
|
930
|
+
const contractInfo = resolvedContracts.get(currentContract);
|
|
931
|
+
if (!contractInfo) {
|
|
932
|
+
return void 0;
|
|
933
|
+
}
|
|
934
|
+
for (const baseName of contractInfo.baseContracts) {
|
|
935
|
+
const baseInfo = resolvedContracts.get(baseName);
|
|
936
|
+
if (baseInfo?.symbols.has(symbol)) {
|
|
937
|
+
let importPath;
|
|
938
|
+
for (const [, info] of resolvedContracts) {
|
|
939
|
+
const baseImportPath = info.baseContractImports.get(baseName);
|
|
940
|
+
if (baseImportPath) {
|
|
941
|
+
importPath = baseImportPath;
|
|
942
|
+
break;
|
|
943
|
+
}
|
|
944
|
+
}
|
|
945
|
+
if (!importPath) {
|
|
946
|
+
throw new Error(
|
|
947
|
+
`Could not find import path for base contract "${baseName}" which defines "${symbol}". Make sure "${baseName}" is properly imported in your contract or its dependencies.`
|
|
948
|
+
);
|
|
949
|
+
}
|
|
950
|
+
return {
|
|
951
|
+
symbol,
|
|
952
|
+
qualifier: baseName,
|
|
953
|
+
sourcePath: importPath
|
|
954
|
+
};
|
|
955
|
+
}
|
|
956
|
+
const result = searchInheritance(baseName, visited);
|
|
957
|
+
if (result) {
|
|
958
|
+
return result;
|
|
959
|
+
}
|
|
960
|
+
}
|
|
961
|
+
return void 0;
|
|
962
|
+
}
|
|
963
|
+
return searchInheritance(contractName);
|
|
964
|
+
};
|
|
965
|
+
}
|
|
966
|
+
|
|
967
|
+
// src/codegen/utils/applyTypeQualifiers.ts
|
|
968
|
+
function applyTypeQualifiers(params, typeQualifiers) {
|
|
969
|
+
if (!typeQualifiers || typeQualifiers.size === 0) {
|
|
970
|
+
return params;
|
|
971
|
+
}
|
|
972
|
+
return params.map((param) => {
|
|
973
|
+
const parts = param.trim().split(/\s+/);
|
|
974
|
+
if (parts.length === 0) return param;
|
|
975
|
+
const type = parts[0];
|
|
976
|
+
const arrayMatch = type.match(/^(.+?)(\[\]|\[\d+\])$/);
|
|
977
|
+
if (arrayMatch) {
|
|
978
|
+
const baseType = arrayMatch[1];
|
|
979
|
+
const arraySuffix = arrayMatch[2];
|
|
980
|
+
if (typeQualifiers.has(baseType)) {
|
|
981
|
+
const qualifiedType = typeQualifiers.get(baseType) + arraySuffix;
|
|
982
|
+
parts[0] = qualifiedType;
|
|
983
|
+
return parts.join(" ");
|
|
984
|
+
}
|
|
985
|
+
} else {
|
|
986
|
+
if (typeQualifiers.has(type)) {
|
|
987
|
+
parts[0] = typeQualifiers.get(type);
|
|
988
|
+
return parts.join(" ");
|
|
989
|
+
}
|
|
990
|
+
}
|
|
991
|
+
return param;
|
|
992
|
+
});
|
|
993
|
+
}
|
|
784
994
|
export {
|
|
785
995
|
abiToInterface,
|
|
996
|
+
applyTypeQualifiers,
|
|
786
997
|
contractToInterface,
|
|
998
|
+
createInheritanceResolver,
|
|
787
999
|
formatAndWriteSolidity,
|
|
788
1000
|
formatAndWriteTypescript,
|
|
789
1001
|
formatSolidity,
|
|
@@ -803,6 +1015,7 @@ export {
|
|
|
803
1015
|
renderWithFieldSuffix,
|
|
804
1016
|
renderWithStore,
|
|
805
1017
|
renderedSolidityHeader,
|
|
1018
|
+
resolveRemapping,
|
|
806
1019
|
schemaTypesToRecsTypeStrings
|
|
807
1020
|
};
|
|
808
1021
|
//# sourceMappingURL=codegen.js.map
|
package/dist/codegen.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/codegen/render-solidity/abiToInterface.ts","../src/codegen/render-solidity/renderImportPath.ts","../src/codegen/render-solidity/common.ts","../src/codegen/render-solidity/renderEnums.ts","../src/codegen/render-solidity/renderTypeHelpers.ts","../src/codegen/render-typescript/schemaTypesToRecsTypeStrings.ts","../src/codegen/utils/contractToInterface.ts","../src/codegen/utils/findContractNode.ts","../src/codegen/utils/findSymbolImport.ts","../src/codegen/utils/format.ts","../src/codegen/utils/formatAndWrite.ts","../src/codegen/debug.ts","../src/codegen/utils/parseSystem.ts"],"sourcesContent":["import { AbiParameter, Hex } from \"viem\";\nimport { Abi, AbiError, AbiFunction, formatAbiItem, formatAbiParameter } from \"abitype\";\nimport { renderedSolidityHeader } from \"./common\";\nimport { hexToResource } from \"../../hexToResource\";\n\nfunction formatParam(param: AbiParameter): string {\n // return param.type === \"string\" || param.type === \"bytes\" || param.type === \"tuple\" || param.type.endsWith(\"]\")\n // ? `${formatAbiParameter(param)} memory`\n // : formatAbiParameter(param);\n return formatAbiParameter(param);\n}\n\nfunction formatFunction(item: AbiFunction): string {\n const params = item.inputs.map(formatParam).join(\", \");\n const returns = item.outputs.map(formatParam).join(\", \");\n return `function ${item.name}(${params}) external${returns.length ? ` returns (${returns})` : \"\"}`;\n}\n\nfunction formatSystemId(systemId: Hex): string {\n const resource = hexToResource(systemId);\n return `\n // equivalent to \\`WorldResourceIdLib.encode({ namespace: ${JSON.stringify(\n resource.namespace,\n )}, name: ${JSON.stringify(resource.name)}, typeId: RESOURCE_SYSTEM });\\`\n ResourceId constant systemId = ResourceId.wrap(${systemId});\n `;\n}\n\nexport type AbiToInterfaceOptions = {\n name: string;\n systemId?: Hex;\n abi: Abi;\n};\n\nexport function abiToInterface({ name, systemId, abi }: AbiToInterfaceOptions): string {\n const imports = systemId ? [`{ ResourceId } from \"@latticexyz/store/src/ResourceId.sol\"`] : [];\n const errors = abi.filter((item): item is AbiError => item.type === \"error\");\n const functions = abi.filter((item): item is AbiFunction => item.type === \"function\");\n\n return `\n ${renderedSolidityHeader}\n\n ${imports.map((item) => `import ${item};`).join(\"\\n\")}\n\n ${systemId ? formatSystemId(systemId) : \"\"}\n\n interface ${name} {\n ${errors.map((item) => `${formatAbiItem(item)};`).join(\"\\n\")}\n\n ${functions\n .map((item) => {\n if ([...item.inputs, ...item.outputs].some((param) => param.type.startsWith(\"tuple\"))) {\n return `// TODO: replace tuple with struct\\n// ${formatFunction(item)};`;\n }\n return `${formatFunction(item)};`;\n })\n .join(\"\\n\")}\n }\n `;\n}\n","import path from \"node:path\";\n\n// This will probably break for backslash-escaped POSIX paths,\n// but we'll worry about that later.\nfunction winToPosix(segment: string): string {\n return segment.replaceAll(path.win32.sep, path.posix.sep);\n}\n\nexport function renderImportPath(basePath: string, ...segments: readonly string[]): string {\n // Solidity compiler expects POSIX paths\n const fullPath = path.posix\n .join(winToPosix(basePath), ...segments.map(winToPosix))\n // remove trailing slash\n .replace(/\\/$/, \"\");\n\n // `path.join` strips the leading `./`\n // so if we started with a relative path, make it relative again\n if (basePath.startsWith(\".\")) {\n const relativePath = \"./\" + fullPath;\n return relativePath.replace(/^(\\.\\/)+\\./, \".\");\n }\n\n return fullPath;\n}\n","import { ImportDatum, StaticResourceData, RenderKeyTuple, RenderType } from \"./types\";\nimport { resourceToHex } from \"../../resourceToHex\";\nimport { hexToResource } from \"../../hexToResource\";\nimport { renderImportPath } from \"./renderImportPath\";\nimport { isDefined } from \"../../utils\";\n\n/**\n * Common header for all codegenerated solidity files\n */\nexport const renderedSolidityHeader = `// SPDX-License-Identifier: MIT\npragma solidity >=0.8.24;\n\n/* Autogenerated file. Do not edit manually. */`;\n\n/**\n * Renders a list of lines\n */\nexport function renderList<T>(list: T[], renderItem: (item: T, index: number) => string): string {\n return internalRenderList(\"\", list, renderItem);\n}\n\n/**\n * Renders a comma-separated list of arguments for solidity functions, ignoring empty and undefined ones\n */\nexport function renderArguments(args: (string | undefined)[]): string {\n return args\n .filter(isDefined)\n .filter((arg) => arg !== \"\")\n .join(\", \");\n}\n\ninterface RenderedCommonData {\n /** `_tableId` variable prefixed with its type (empty string if absent) */\n _typedTableId: string;\n /** Comma-separated table key names prefixed with their types (empty string if 0 keys) */\n _typedKeyArgs: string;\n /** Definition and initialization of the dynamic `_keyTuple` bytes32 array */\n _keyTupleDefinition: string;\n}\n\n/**\n * Renders some solidity statements commonly used within table libraries\n * @param param0.staticResourceData static data about the table library\n * @param param0.keyTuple key tuple of the table library\n * @returns Rendered statement strings\n */\nexport function renderCommonData({\n staticResourceData,\n keyTuple,\n}: {\n staticResourceData?: StaticResourceData;\n keyTuple: RenderKeyTuple[];\n}): RenderedCommonData {\n // static resource means static tableId as well, and no tableId arguments\n const _typedTableId = staticResourceData ? \"\" : \"ResourceId _tableId\";\n const _typedKeyArgs = renderArguments(keyTuple.map(({ name, typeWithLocation }) => `${typeWithLocation} ${name}`));\n\n const _keyTupleDefinition = `\n bytes32[] memory _keyTuple = new bytes32[](${keyTuple.length});\n ${renderList(keyTuple, (key, index) => `_keyTuple[${index}] = ${renderValueTypeToBytes32(key.name, key)};`)}\n `;\n\n return {\n _typedTableId,\n _typedKeyArgs,\n _keyTupleDefinition,\n };\n}\n\n/**\n * 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 // Aggregate symbols by import path, also deduplicating them\n const aggregatedImports = new Map<string, Set<string>>();\n for (const { symbol, path } of imports) {\n if (!aggregatedImports.has(path)) {\n aggregatedImports.set(path, new Set());\n }\n aggregatedImports.get(path)?.add(symbol);\n }\n // Render imports\n const renderedImports = [];\n for (const [path, symbols] of aggregatedImports) {\n const renderedSymbols = [...symbols].join(\", \");\n renderedImports.push(`import { ${renderedSymbols} } from \"${renderImportPath(path)}\";`);\n }\n return renderedImports.join(\"\\n\");\n}\n\ninterface RenderWithStoreCallbackData {\n /** `_store` variable prefixed with its type (undefined if library name) */\n _typedStore: string | undefined;\n /** `_store` variable (undefined if library name) */\n _store: string;\n /** Empty string if storeArgument is false, otherwise `\" (using the specified store)\"` */\n _commentSuffix: string;\n /** Prefix to differentiate different kinds of store usage within methods */\n _methodNamePrefix: string;\n /** Whether FieldLayout variable should be passed to store methods */\n _useExplicitFieldLayout?: boolean;\n}\n\n/**\n * Renders several versions of the callback's result, which access Store in different ways\n * @param storeArgument whether to render a version with `IStore _store` as an argument\n * @param callback renderer for a method which uses store\n * @returns Concatenated results of all callback calls\n */\nexport function renderWithStore(\n storeArgument: boolean,\n callback: (data: RenderWithStoreCallbackData) => string,\n): string {\n let result = \"\";\n result += callback({ _typedStore: undefined, _store: \"StoreSwitch\", _commentSuffix: \"\", _methodNamePrefix: \"\" });\n result += callback({\n _typedStore: undefined,\n _store: \"StoreCore\",\n _commentSuffix: \"\",\n _methodNamePrefix: \"_\",\n _useExplicitFieldLayout: true,\n });\n\n if (storeArgument) {\n result +=\n \"\\n\" +\n callback({\n _typedStore: \"IStore _store\",\n _store: \"_store\",\n _commentSuffix: \" (using the specified store)\",\n _methodNamePrefix: \"\",\n });\n }\n\n return result;\n}\n\n/**\n * Renders several versions of the callback's result, which have different method name suffixes\n * @param withSuffixlessFieldMethods whether to render methods with an empty suffix\n * @param fieldName name of the field which the methods access, used for a suffix\n * @param callback renderer for a method to be suffixed\n * @returns Concatenated results of all callback calls\n */\nexport function renderWithFieldSuffix(\n withSuffixlessFieldMethods: boolean,\n fieldName: string,\n callback: (_methodNameSuffix: string) => string,\n): string {\n const methodNameSuffix = `${fieldName[0].toUpperCase()}${fieldName.slice(1)}`;\n let result = \"\";\n result += callback(methodNameSuffix);\n\n if (withSuffixlessFieldMethods) {\n result += \"\\n\" + callback(\"\");\n }\n\n return result;\n}\n\n/**\n * Renders `_tableId` definition of the given table.\n * @param param0 static resource data needed to construct the table ID\n */\nexport function renderTableId({\n namespace,\n name,\n offchainOnly,\n}: Pick<StaticResourceData, \"namespace\" | \"name\" | \"offchainOnly\">): string {\n const tableId = resourceToHex({\n type: offchainOnly ? \"offchainTable\" : \"table\",\n namespace,\n name,\n });\n // turn table ID back into arguments that would be valid in `WorldResourceIdLib.encode` (like truncated names)\n const resource = hexToResource(tableId);\n return `\n // Hex below is the result of \\`WorldResourceIdLib.encode({ namespace: ${JSON.stringify(\n resource.namespace,\n )}, name: ${JSON.stringify(resource.name)}, typeId: ${offchainOnly ? \"RESOURCE_OFFCHAIN_TABLE\" : \"RESOURCE_TABLE\"} });\\`\n ResourceId constant _tableId = ResourceId.wrap(${tableId});\n `;\n}\n\n/**\n * Renders solidity typecasts to get from the given type to `bytes32`\n * @param name variable name to be typecasted\n * @param param1 type data\n */\nexport function renderValueTypeToBytes32(\n name: string,\n { typeUnwrap, internalTypeId }: Pick<RenderType, \"typeUnwrap\" | \"internalTypeId\">,\n): string {\n const innerText = typeUnwrap.length ? `${typeUnwrap}(${name})` : name;\n\n if (internalTypeId === \"bytes32\") {\n return innerText;\n } else if (/^bytes\\d{1,2}$/.test(internalTypeId)) {\n return `bytes32(${innerText})`;\n } else if (/^uint\\d{1,3}$/.test(internalTypeId)) {\n return `bytes32(uint256(${innerText}))`;\n } else if (/^int\\d{1,3}$/.test(internalTypeId)) {\n return `bytes32(uint256(int256(${innerText})))`;\n } else if (internalTypeId === \"address\") {\n return `bytes32(uint256(uint160(${innerText})))`;\n } else if (internalTypeId === \"bool\") {\n return `_boolToBytes32(${innerText})`;\n } else {\n throw new Error(`Unknown value type id ${internalTypeId}`);\n }\n}\n\n/**\n * Whether the storage representation of the given solidity type is left aligned\n */\nexport function isLeftAligned(field: Pick<RenderType, \"internalTypeId\">): boolean {\n return /^bytes\\d{1,2}$/.test(field.internalTypeId);\n}\n\n/**\n * The number of padding bits in the storage representation of a right-aligned solidity type\n */\nexport function getLeftPaddingBits(field: Pick<RenderType, \"internalTypeId\" | \"staticByteLength\">): number {\n if (isLeftAligned(field)) {\n return 0;\n } else {\n return 256 - field.staticByteLength * 8;\n }\n}\n\n/**\n * Internal helper to render `lineTerminator`-separated list of items mapped by `renderItem`\n */\nfunction internalRenderList<T>(\n lineTerminator: string,\n list: T[],\n renderItem: (item: T, index: number) => string,\n): string {\n return list\n .map((item, index) => renderItem(item, index) + (index === list.length - 1 ? \"\" : lineTerminator))\n .join(\"\\n\");\n}\n","import { renderedSolidityHeader } from \"./common\";\n\n// importing this from config or store would be a cyclic dependency :(\ntype Enums = {\n readonly [name: string]: readonly [string, ...string[]];\n};\n\n/**\n * Render a list of enum data as solidity enum definitions\n */\nexport function renderEnums(enums: Enums): string {\n const enumDefinitions = Object.entries(enums).map(\n ([name, values]) => `\n enum ${name} {\n ${values.join(\", \")}\n }\n `,\n );\n\n return `\n ${renderedSolidityHeader}\n ${enumDefinitions.join(\"\")}\n `;\n}\n","import { RenderField, RenderKeyTuple, RenderType } from \"./types\";\n\n/**\n * Renders the necessary helper functions to typecast to/from the types of given fields and keys\n */\nexport function renderTypeHelpers(options: { fields: RenderField[]; keyTuple: RenderKeyTuple[] }): string {\n const { fields, keyTuple } = options;\n\n let result = \"\";\n\n for (const wrappingHelper of getWrappingHelpers([...fields, ...keyTuple])) {\n result += wrappingHelper;\n }\n\n // bool is special - it's the only primitive value type that can't be typecasted to/from\n if (fields.some(({ internalTypeId }) => internalTypeId.match(\"bool\"))) {\n result += `\n /**\n * @notice Cast a value to a bool.\n * @dev Boolean values are encoded as uint8 (1 = true, 0 = false), but Solidity doesn't allow casting between uint8 and bool.\n * @param value The uint8 value to convert.\n * @return result The boolean value.\n */\n function _toBool(uint8 value) pure returns (bool result) {\n assembly {\n result := value\n }\n }\n `;\n }\n if (keyTuple.some(({ internalTypeId }) => internalTypeId.match(\"bool\"))) {\n result += `\n /**\n * @notice Cast a bool to a bytes32.\n * @dev The boolean value is casted to a bytes32 value with 0 or 1 at the least significant bit.\n */\n function _boolToBytes32(bool value) pure returns (bytes32 result) {\n assembly {\n result := value\n }\n }\n `;\n }\n\n return result;\n}\n\nfunction getWrappingHelpers(array: RenderType[]): string[] {\n const wrappers = new Map<string, string>();\n const unwrappers = new Map<string, string>();\n for (const { typeWrappingData, typeWrap, typeUnwrap, internalTypeId } of array) {\n if (!typeWrappingData) continue;\n const { kind } = typeWrappingData;\n\n if (kind === \"staticArray\") {\n const { elementType, staticLength } = typeWrappingData;\n wrappers.set(typeWrap, renderWrapperStaticArray(typeWrap, elementType, staticLength, internalTypeId));\n unwrappers.set(typeUnwrap, renderUnwrapperStaticArray(typeUnwrap, elementType, staticLength, internalTypeId));\n }\n }\n\n return [...wrappers.values(), ...unwrappers.values()];\n}\n\n/**\n * Renders a function to cast a dynamic array to a static array.\n * @param functionName name of the function to be rendered\n * @param elementType type of the array's element\n * @param staticLength length of the static array\n * @param internalTypeId solidity type name of the dynamic array\n * @returns\n */\nfunction renderWrapperStaticArray(\n functionName: string,\n elementType: string,\n staticLength: number,\n internalTypeId: string,\n): string {\n // WARNING: ensure this still works if changing major solidity versions!\n // (the memory layout for static arrays may change)\n return `\n /**\n * @notice Cast a dynamic array to a static array.\n * @dev In memory static arrays are just dynamic arrays without the 32 length bytes,\n * so this function moves the pointer to the first element of the dynamic array.\n * If the length of the dynamic array is smaller than the static length,\n * the function returns an uninitialized array to avoid memory corruption.\n * @param _value The dynamic array to cast.\n * @return _result The static array.\n */\n function ${functionName}(\n ${internalTypeId} memory _value\n ) pure returns (\n ${elementType}[${staticLength}] memory _result\n ) {\n if (_value.length < ${staticLength}) {\n // return an uninitialized array if the length is smaller than the fixed length to avoid memory corruption\n return _result;\n } else {\n // in memory static arrays are just dynamic arrays without the 32 length bytes\n // (without the length check this could lead to memory corruption)\n assembly {\n _result := add(_value, 0x20)\n }\n }\n }\n `;\n}\n\n/**\n * Renders a function to cast a static array to a dynamic array.\n * @param functionName name of the function to be rendered\n * @param elementType type of the array's element\n * @param staticLength length of the static array\n * @param internalTypeId solidity type name of the dynamic array\n * @returns\n */\nfunction renderUnwrapperStaticArray(\n functionName: string,\n elementType: string,\n staticLength: number,\n internalTypeId: string,\n): string {\n // byte length for memory copying (more efficient than a loop)\n const byteLength = staticLength * 32;\n // TODO to optimize memory usage consider generalizing TightEncoder to a render-time utility\n return `\n /**\n * @notice Copy a static array to a dynamic array.\n * @dev Static arrays don't have a length prefix, so this function copies the memory from the static array to a new dynamic array.\n * @param _value The static array to copy.\n * @return _result The dynamic array.\n */ \n function ${functionName}(\n ${elementType}[${staticLength}] memory _value\n ) pure returns (\n ${internalTypeId} memory _result\n ) {\n _result = new ${internalTypeId}(${staticLength});\n uint256 fromPointer;\n uint256 toPointer;\n assembly {\n fromPointer := _value\n toPointer := add(_result, 0x20)\n }\n Memory.copy(fromPointer, toPointer, ${byteLength});\n }\n `;\n}\n","import { SchemaType } from \"@latticexyz/schema-type/deprecated\";\n\nexport const schemaTypesToRecsTypeStrings: Record<SchemaType, string> = {\n [SchemaType.UINT8]: \"RecsType.Number\",\n [SchemaType.UINT16]: \"RecsType.Number\",\n [SchemaType.UINT24]: \"RecsType.Number\",\n [SchemaType.UINT32]: \"RecsType.Number\",\n [SchemaType.UINT40]: \"RecsType.Number\",\n [SchemaType.UINT48]: \"RecsType.Number\",\n [SchemaType.UINT56]: \"RecsType.BigInt\",\n [SchemaType.UINT64]: \"RecsType.BigInt\",\n [SchemaType.UINT72]: \"RecsType.BigInt\",\n [SchemaType.UINT80]: \"RecsType.BigInt\",\n [SchemaType.UINT88]: \"RecsType.BigInt\",\n [SchemaType.UINT96]: \"RecsType.BigInt\",\n [SchemaType.UINT104]: \"RecsType.BigInt\",\n [SchemaType.UINT112]: \"RecsType.BigInt\",\n [SchemaType.UINT120]: \"RecsType.BigInt\",\n [SchemaType.UINT128]: \"RecsType.BigInt\",\n [SchemaType.UINT136]: \"RecsType.BigInt\",\n [SchemaType.UINT144]: \"RecsType.BigInt\",\n [SchemaType.UINT152]: \"RecsType.BigInt\",\n [SchemaType.UINT160]: \"RecsType.BigInt\",\n [SchemaType.UINT168]: \"RecsType.BigInt\",\n [SchemaType.UINT176]: \"RecsType.BigInt\",\n [SchemaType.UINT184]: \"RecsType.BigInt\",\n [SchemaType.UINT192]: \"RecsType.BigInt\",\n [SchemaType.UINT200]: \"RecsType.BigInt\",\n [SchemaType.UINT208]: \"RecsType.BigInt\",\n [SchemaType.UINT216]: \"RecsType.BigInt\",\n [SchemaType.UINT224]: \"RecsType.BigInt\",\n [SchemaType.UINT232]: \"RecsType.BigInt\",\n [SchemaType.UINT240]: \"RecsType.BigInt\",\n [SchemaType.UINT248]: \"RecsType.BigInt\",\n [SchemaType.UINT256]: \"RecsType.BigInt\",\n [SchemaType.INT8]: \"RecsType.Number\",\n [SchemaType.INT16]: \"RecsType.Number\",\n [SchemaType.INT24]: \"RecsType.Number\",\n [SchemaType.INT32]: \"RecsType.Number\",\n [SchemaType.INT40]: \"RecsType.Number\",\n [SchemaType.INT48]: \"RecsType.Number\",\n [SchemaType.INT56]: \"RecsType.BigInt\",\n [SchemaType.INT64]: \"RecsType.BigInt\",\n [SchemaType.INT72]: \"RecsType.BigInt\",\n [SchemaType.INT80]: \"RecsType.BigInt\",\n [SchemaType.INT88]: \"RecsType.BigInt\",\n [SchemaType.INT96]: \"RecsType.BigInt\",\n [SchemaType.INT104]: \"RecsType.BigInt\",\n [SchemaType.INT112]: \"RecsType.BigInt\",\n [SchemaType.INT120]: \"RecsType.BigInt\",\n [SchemaType.INT128]: \"RecsType.BigInt\",\n [SchemaType.INT136]: \"RecsType.BigInt\",\n [SchemaType.INT144]: \"RecsType.BigInt\",\n [SchemaType.INT152]: \"RecsType.BigInt\",\n [SchemaType.INT160]: \"RecsType.BigInt\",\n [SchemaType.INT168]: \"RecsType.BigInt\",\n [SchemaType.INT176]: \"RecsType.BigInt\",\n [SchemaType.INT184]: \"RecsType.BigInt\",\n [SchemaType.INT192]: \"RecsType.BigInt\",\n [SchemaType.INT200]: \"RecsType.BigInt\",\n [SchemaType.INT208]: \"RecsType.BigInt\",\n [SchemaType.INT216]: \"RecsType.BigInt\",\n [SchemaType.INT224]: \"RecsType.BigInt\",\n [SchemaType.INT232]: \"RecsType.BigInt\",\n [SchemaType.INT240]: \"RecsType.BigInt\",\n [SchemaType.INT248]: \"RecsType.BigInt\",\n [SchemaType.INT256]: \"RecsType.BigInt\",\n [SchemaType.BYTES1]: \"RecsType.String\",\n [SchemaType.BYTES2]: \"RecsType.String\",\n [SchemaType.BYTES3]: \"RecsType.String\",\n [SchemaType.BYTES4]: \"RecsType.String\",\n [SchemaType.BYTES5]: \"RecsType.String\",\n [SchemaType.BYTES6]: \"RecsType.String\",\n [SchemaType.BYTES7]: \"RecsType.String\",\n [SchemaType.BYTES8]: \"RecsType.String\",\n [SchemaType.BYTES9]: \"RecsType.String\",\n [SchemaType.BYTES10]: \"RecsType.String\",\n [SchemaType.BYTES11]: \"RecsType.String\",\n [SchemaType.BYTES12]: \"RecsType.String\",\n [SchemaType.BYTES13]: \"RecsType.String\",\n [SchemaType.BYTES14]: \"RecsType.String\",\n [SchemaType.BYTES15]: \"RecsType.String\",\n [SchemaType.BYTES16]: \"RecsType.String\",\n [SchemaType.BYTES17]: \"RecsType.String\",\n [SchemaType.BYTES18]: \"RecsType.String\",\n [SchemaType.BYTES19]: \"RecsType.String\",\n [SchemaType.BYTES20]: \"RecsType.String\",\n [SchemaType.BYTES21]: \"RecsType.String\",\n [SchemaType.BYTES22]: \"RecsType.String\",\n [SchemaType.BYTES23]: \"RecsType.String\",\n [SchemaType.BYTES24]: \"RecsType.String\",\n [SchemaType.BYTES25]: \"RecsType.String\",\n [SchemaType.BYTES26]: \"RecsType.String\",\n [SchemaType.BYTES27]: \"RecsType.String\",\n [SchemaType.BYTES28]: \"RecsType.String\",\n [SchemaType.BYTES29]: \"RecsType.String\",\n [SchemaType.BYTES30]: \"RecsType.String\",\n [SchemaType.BYTES31]: \"RecsType.String\",\n [SchemaType.BYTES32]: \"RecsType.String\",\n [SchemaType.BOOL]: \"RecsType.Boolean\",\n [SchemaType.ADDRESS]: \"RecsType.String\",\n [SchemaType.UINT8_ARRAY]: \"RecsType.NumberArray\",\n [SchemaType.UINT16_ARRAY]: \"RecsType.NumberArray\",\n [SchemaType.UINT24_ARRAY]: \"RecsType.NumberArray\",\n [SchemaType.UINT32_ARRAY]: \"RecsType.NumberArray\",\n [SchemaType.UINT40_ARRAY]: \"RecsType.NumberArray\",\n [SchemaType.UINT48_ARRAY]: \"RecsType.NumberArray\",\n [SchemaType.UINT56_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.UINT64_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.UINT72_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.UINT80_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.UINT88_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.UINT96_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.UINT104_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.UINT112_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.UINT120_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.UINT128_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.UINT136_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.UINT144_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.UINT152_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.UINT160_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.UINT168_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.UINT176_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.UINT184_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.UINT192_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.UINT200_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.UINT208_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.UINT216_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.UINT224_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.UINT232_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.UINT240_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.UINT248_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.UINT256_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.INT8_ARRAY]: \"RecsType.NumberArray\",\n [SchemaType.INT16_ARRAY]: \"RecsType.NumberArray\",\n [SchemaType.INT24_ARRAY]: \"RecsType.NumberArray\",\n [SchemaType.INT32_ARRAY]: \"RecsType.NumberArray\",\n [SchemaType.INT40_ARRAY]: \"RecsType.NumberArray\",\n [SchemaType.INT48_ARRAY]: \"RecsType.NumberArray\",\n [SchemaType.INT56_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.INT64_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.INT72_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.INT80_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.INT88_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.INT96_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.INT104_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.INT112_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.INT120_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.INT128_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.INT136_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.INT144_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.INT152_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.INT160_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.INT168_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.INT176_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.INT184_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.INT192_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.INT200_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.INT208_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.INT216_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.INT224_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.INT232_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.INT240_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.INT248_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.INT256_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.BYTES1_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.BYTES2_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.BYTES3_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.BYTES4_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.BYTES5_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.BYTES6_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.BYTES7_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.BYTES8_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.BYTES9_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.BYTES10_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.BYTES11_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.BYTES12_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.BYTES13_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.BYTES14_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.BYTES15_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.BYTES16_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.BYTES17_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.BYTES18_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.BYTES19_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.BYTES20_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.BYTES21_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.BYTES22_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.BYTES23_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.BYTES24_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.BYTES25_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.BYTES26_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.BYTES27_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.BYTES28_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.BYTES29_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.BYTES30_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.BYTES31_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.BYTES32_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.BOOL_ARRAY]: \"RecsType.T\", // no boolean array\n [SchemaType.ADDRESS_ARRAY]: \"RecsType.StringArray\",\n [SchemaType.BYTES]: \"RecsType.String\",\n [SchemaType.STRING]: \"RecsType.String\",\n};\n","import { parse, visit } from \"@solidity-parser/parser\";\nimport type { SourceUnit, TypeName, VariableDeclaration } from \"@solidity-parser/parser/dist/src/ast-types\";\nimport { MUDError } from \"../../errors\";\nimport { findContractNode } from \"./findContractNode\";\nimport { SymbolImport, findSymbolImport } from \"./findSymbolImport\";\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\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 source contents of a file with the solidity contract\n * @param contractName name of the contract\n * @returns interface data\n */\nexport function contractToInterface(\n source: string,\n contractName: string,\n): {\n functions: ContractInterfaceFunction[];\n errors: ContractInterfaceError[];\n symbolImports: SymbolImport[];\n} {\n const ast = parse(source);\n const contractNode = findContractNode(ast, contractName);\n let symbolImports: SymbolImport[] = [];\n const functions: ContractInterfaceFunction[] = [];\n const errors: ContractInterfaceError[] = [];\n\n if (!contractNode) {\n throw new MUDError(`Contract not found: ${contractName}`);\n }\n\n visit(contractNode, {\n FunctionDefinition({\n name,\n visibility,\n parameters,\n stateMutability,\n returnParameters,\n isConstructor,\n isFallback,\n isReceiveEther,\n }) {\n try {\n // skip constructor and fallbacks\n if (isConstructor || isFallback || isReceiveEther) return;\n // forbid default visibility (this check might be unnecessary, modern solidity already disallows this)\n if (visibility === \"default\") throw new MUDError(`Visibility is not specified`);\n\n if (visibility === \"external\" || visibility === \"public\") {\n functions.push({\n name: name === null ? \"\" : name,\n parameters: parameters.map(parseParameter),\n stateMutability: stateMutability || \"\",\n returnParameters: returnParameters === null ? [] : returnParameters.map(parseParameter),\n });\n\n for (const { typeName } of parameters.concat(returnParameters ?? [])) {\n const symbols = typeNameToSymbols(typeName);\n symbolImports = symbolImports.concat(symbolsToImports(ast, symbols));\n }\n }\n } catch (error: unknown) {\n if (error instanceof MUDError) {\n error.message = `Function \"${name}\" in contract \"${contractName}\": ${error.message}`;\n }\n throw error;\n }\n },\n CustomErrorDefinition({ name, parameters }) {\n errors.push({\n name,\n parameters: parameters.map(parseParameter),\n });\n\n for (const parameter of parameters) {\n const symbols = typeNameToSymbols(parameter.typeName);\n symbolImports = symbolImports.concat(symbolsToImports(ast, symbols));\n }\n },\n });\n\n return {\n functions,\n errors,\n symbolImports,\n };\n}\n\nfunction 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\nfunction symbolsToImports(ast: SourceUnit, symbols: string[]): SymbolImport[] {\n return symbols.map((symbol) => {\n const symbolImport = findSymbolImport(ast, symbol);\n if (!symbolImport) throw new MUDError(`Symbol \"${symbol}\" has no explicit import`);\n return symbolImport;\n });\n}\n","import { visit } from \"@solidity-parser/parser\";\nimport type { ContractDefinition, SourceUnit } from \"@solidity-parser/parser/dist/src/ast-types\";\n\nexport function findContractNode(ast: SourceUnit, contractName: string): ContractDefinition | undefined {\n let contract: ContractDefinition | undefined = undefined;\n\n visit(ast, {\n ContractDefinition(node) {\n if (node.name === contractName) {\n contract = node;\n }\n },\n });\n\n return contract;\n}\n","import { visit } from \"@solidity-parser/parser\";\nimport type { SourceUnit } from \"@solidity-parser/parser/dist/src/ast-types\";\n\nexport interface SymbolImport {\n symbol: string;\n path: string;\n}\n\n/**\n * Get import for given symbol.\n *\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 ...`\n */\nexport function findSymbolImport(ast: SourceUnit, symbol: string): SymbolImport | undefined {\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 return symbolImport;\n}\n","import prettier from \"prettier\";\nimport prettierPluginSolidity from \"prettier-plugin-solidity\";\n\n/**\n * Formats solidity code using prettier\n * @param content solidity code\n * @param prettierConfigPath optional path to a prettier config\n * @returns formatted solidity code\n */\nexport async function formatSolidity(content: string, prettierConfigPath?: string): Promise<string> {\n let config;\n if (prettierConfigPath) {\n config = await prettier.resolveConfig(prettierConfigPath);\n }\n try {\n return prettier.format(content, {\n plugins: [prettierPluginSolidity],\n parser: \"solidity-parse\",\n\n printWidth: 120,\n semi: true,\n tabWidth: 2,\n useTabs: false,\n bracketSpacing: true,\n\n ...config,\n });\n } catch (error) {\n let message;\n if (error instanceof Error) {\n message = error.message;\n } else {\n message = error;\n }\n console.log(`Error during output formatting: ${message}`);\n return content;\n }\n}\n\n/**\n * Formats typescript code using prettier\n * @param content typescript code\n * @returns formatted typescript code\n */\nexport async function formatTypescript(content: string): Promise<string> {\n return prettier.format(content, {\n parser: \"typescript\",\n });\n}\n","import fs from \"node:fs/promises\";\nimport path from \"node:path\";\nimport { formatSolidity, formatTypescript } from \"./format\";\nimport { debug, error } from \"../debug\";\n\n/**\n * Formats solidity code using prettier and write it to a file\n * @param content solidity code\n * @param fullOutputPath full path to the output file\n * @param logPrefix prefix for debug logs\n */\nexport async function formatAndWriteSolidity(\n content: string,\n fullOutputPath: string,\n logPrefix: string,\n): Promise<void> {\n let output = content;\n try {\n output = await formatSolidity(output);\n } catch (e) {\n error(`Error while attempting to format ${fullOutputPath}`, e);\n }\n await fs.mkdir(path.dirname(fullOutputPath), { recursive: true });\n await fs.writeFile(fullOutputPath, output);\n debug(`${logPrefix}: ${fullOutputPath}`);\n}\n\n/**\n * Formats typescript code using prettier and write it to a file\n * @param output typescript code\n * @param fullOutputPath full path to the output file\n * @param logPrefix prefix for debug logs\n */\nexport async function formatAndWriteTypescript(\n output: string,\n fullOutputPath: string,\n logPrefix: string,\n): Promise<void> {\n const formattedOutput = await formatTypescript(output);\n\n await fs.mkdir(path.dirname(fullOutputPath), { recursive: true });\n\n await fs.writeFile(fullOutputPath, formattedOutput);\n debug(`${logPrefix}: ${fullOutputPath}`);\n}\n","import { debug as parentDebug } from \"../debug\";\n\nexport const debug = parentDebug.extend(\"codegen\");\nexport const error = parentDebug.extend(\"codegen\");\n\n// Pipe debug output to stdout instead of stderr\ndebug.log = console.debug.bind(console);\n\n// Pipe error output to stderr\nerror.log = console.error.bind(console);\n","import { parse, visit } from \"@solidity-parser/parser\";\n\nimport { findContractNode } from \"./findContractNode\";\nimport { findSymbolImport } from \"./findSymbolImport\";\n\nconst baseSystemName = \"System\";\nconst baseSystemPath = \"@latticexyz/world/src/System.sol\";\n\nexport function parseSystem(\n source: string,\n contractName: string,\n): undefined | { contractType: \"contract\" | \"abstract\" } {\n const ast = parse(source);\n const contractNode = findContractNode(ast, contractName);\n if (!contractNode) return;\n\n const contractType = contractNode.kind;\n // skip libraries and interfaces\n // we allow abstract systems here so that we can create system libraries from them but without deploying them\n if (contractType !== \"contract\" && contractType !== \"abstract\") return;\n\n const isSystem = ((): boolean => {\n // if using the System suffix, assume its a system\n if (contractName.endsWith(\"System\") && contractName !== baseSystemName) return true;\n\n // otherwise check if we're inheriting from the base system\n let extendsBaseSystem = false;\n visit(contractNode, {\n InheritanceSpecifier(node) {\n if (node.baseName.namePath === baseSystemName) {\n extendsBaseSystem = true;\n }\n },\n });\n return extendsBaseSystem && findSymbolImport(ast, baseSystemName)?.path === baseSystemPath;\n })();\n\n if (isSystem) {\n return { contractType };\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;AACA,SAAqC,eAAe,0BAA0B;;;ACD9E,OAAO,UAAU;AAIjB,SAAS,WAAW,SAAyB;AAC3C,SAAO,QAAQ,WAAW,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C,OAAM,cAAc;AAAA,MAClB,qBAAqB,MAAM;AACzB,YAAI,KAAK,SAAS,aAAa,gBAAgB;AAC7C,8BAAoB;AAAA,QACtB;AAAA,MACF;AAAA,IACF,CAAC;AACD,WAAO,qBAAqB,iBAAiB,KAAK,cAAc,GAAG,SAAS;AAAA,EAC9E,GAAG;AAEH,MAAI,UAAU;AACZ,WAAO,EAAE,aAAa;AAAA,EACxB;AACF;","names":["path","visit","visit","path","visit","error","error","path","debug","path","debug","parse","visit","parse","visit"]}
|
|
1
|
+
{"version":3,"sources":["../src/codegen/render-solidity/abiToInterface.ts","../src/codegen/render-solidity/renderImportPath.ts","../src/codegen/render-solidity/common.ts","../src/codegen/render-solidity/renderEnums.ts","../src/codegen/render-solidity/renderTypeHelpers.ts","../src/codegen/render-typescript/schemaTypesToRecsTypeStrings.ts","../src/codegen/utils/contractToInterface.ts","../src/codegen/utils/findContractNode.ts","../src/codegen/utils/findSymbolImport.ts","../src/codegen/utils/format.ts","../src/codegen/utils/formatAndWrite.ts","../src/codegen/debug.ts","../src/codegen/utils/parseSystem.ts","../src/codegen/utils/resolveInheritedSymbols.ts","../src/codegen/utils/resolveRemapping.ts","../src/codegen/utils/applyTypeQualifiers.ts"],"sourcesContent":["import { AbiParameter, Hex } from \"viem\";\nimport { Abi, AbiError, AbiFunction, formatAbiItem, formatAbiParameter } from \"abitype\";\nimport { renderedSolidityHeader } from \"./common\";\nimport { hexToResource } from \"../../hexToResource\";\n\nfunction formatParam(param: AbiParameter): string {\n // return param.type === \"string\" || param.type === \"bytes\" || param.type === \"tuple\" || param.type.endsWith(\"]\")\n // ? `${formatAbiParameter(param)} memory`\n // : formatAbiParameter(param);\n return formatAbiParameter(param);\n}\n\nfunction formatFunction(item: AbiFunction): string {\n const params = item.inputs.map(formatParam).join(\", \");\n const returns = item.outputs.map(formatParam).join(\", \");\n return `function ${item.name}(${params}) external${returns.length ? ` returns (${returns})` : \"\"}`;\n}\n\nfunction formatSystemId(systemId: Hex): string {\n const resource = hexToResource(systemId);\n return `\n // equivalent to \\`WorldResourceIdLib.encode({ namespace: ${JSON.stringify(\n resource.namespace,\n )}, name: ${JSON.stringify(resource.name)}, typeId: RESOURCE_SYSTEM });\\`\n ResourceId constant systemId = ResourceId.wrap(${systemId});\n `;\n}\n\nexport type AbiToInterfaceOptions = {\n name: string;\n systemId?: Hex;\n abi: Abi;\n};\n\nexport function abiToInterface({ name, systemId, abi }: AbiToInterfaceOptions): string {\n const imports = systemId ? [`{ ResourceId } from \"@latticexyz/store/src/ResourceId.sol\"`] : [];\n const errors = abi.filter((item): item is AbiError => item.type === \"error\");\n const functions = abi.filter((item): item is AbiFunction => item.type === \"function\");\n\n return `\n ${renderedSolidityHeader}\n\n ${imports.map((item) => `import ${item};`).join(\"\\n\")}\n\n ${systemId ? formatSystemId(systemId) : \"\"}\n\n interface ${name} {\n ${errors.map((item) => `${formatAbiItem(item)};`).join(\"\\n\")}\n\n ${functions\n .map((item) => {\n if ([...item.inputs, ...item.outputs].some((param) => param.type.startsWith(\"tuple\"))) {\n return `// TODO: replace tuple with struct\\n// ${formatFunction(item)};`;\n }\n return `${formatFunction(item)};`;\n })\n .join(\"\\n\")}\n }\n `;\n}\n","import path from \"node:path\";\n\n// This will probably break for backslash-escaped POSIX paths,\n// but we'll worry about that later.\nfunction winToPosix(segment: string): string {\n return segment.replaceAll(path.win32.sep, path.posix.sep);\n}\n\nexport function renderImportPath(basePath: string, ...segments: readonly string[]): string {\n // Solidity compiler expects POSIX paths\n const fullPath = path.posix\n .join(winToPosix(basePath), ...segments.map(winToPosix))\n // remove trailing slash\n .replace(/\\/$/, \"\");\n\n // `path.join` strips the leading `./`\n // so if we started with a relative path, make it relative again\n if (basePath.startsWith(\".\")) {\n const relativePath = \"./\" + fullPath;\n return relativePath.replace(/^(\\.\\/)+\\./, \".\");\n }\n\n return fullPath;\n}\n","import { ImportDatum, StaticResourceData, RenderKeyTuple, RenderType } from \"./types\";\nimport { resourceToHex } from \"../../resourceToHex\";\nimport { hexToResource } from \"../../hexToResource\";\nimport { renderImportPath } from \"./renderImportPath\";\nimport { isDefined } from \"../../utils\";\n\n/**\n * Common header for all codegenerated solidity files\n */\nexport const renderedSolidityHeader = `// SPDX-License-Identifier: MIT\npragma solidity >=0.8.24;\n\n/* Autogenerated file. Do not edit manually. */`;\n\n/**\n * Renders a list of lines\n */\nexport function renderList<T>(list: T[], renderItem: (item: T, index: number) => string): string {\n return internalRenderList(\"\", list, renderItem);\n}\n\n/**\n * Renders a comma-separated list of arguments for solidity functions, ignoring empty and undefined ones\n */\nexport function renderArguments(args: (string | undefined)[]): string {\n return args\n .filter(isDefined)\n .filter((arg) => arg !== \"\")\n .join(\", \");\n}\n\ninterface RenderedCommonData {\n /** `_tableId` variable prefixed with its type (empty string if absent) */\n _typedTableId: string;\n /** Comma-separated table key names prefixed with their types (empty string if 0 keys) */\n _typedKeyArgs: string;\n /** Definition and initialization of the dynamic `_keyTuple` bytes32 array */\n _keyTupleDefinition: string;\n}\n\n/**\n * Renders some solidity statements commonly used within table libraries\n * @param param0.staticResourceData static data about the table library\n * @param param0.keyTuple key tuple of the table library\n * @returns Rendered statement strings\n */\nexport function renderCommonData({\n staticResourceData,\n keyTuple,\n}: {\n staticResourceData?: StaticResourceData;\n keyTuple: RenderKeyTuple[];\n}): RenderedCommonData {\n // static resource means static tableId as well, and no tableId arguments\n const _typedTableId = staticResourceData ? \"\" : \"ResourceId _tableId\";\n const _typedKeyArgs = renderArguments(keyTuple.map(({ name, typeWithLocation }) => `${typeWithLocation} ${name}`));\n\n const _keyTupleDefinition = `\n bytes32[] memory _keyTuple = new bytes32[](${keyTuple.length});\n ${renderList(keyTuple, (key, index) => `_keyTuple[${index}] = ${renderValueTypeToBytes32(key.name, key)};`)}\n `;\n\n return {\n _typedTableId,\n _typedKeyArgs,\n _keyTupleDefinition,\n };\n}\n\n/**\n * 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 // Aggregate symbols by import path, also deduplicating them\n const aggregatedImports = new Map<string, Set<string>>();\n for (const { symbol, path } of imports) {\n if (!aggregatedImports.has(path)) {\n aggregatedImports.set(path, new Set());\n }\n aggregatedImports.get(path)?.add(symbol);\n }\n // Render imports\n const renderedImports = [];\n for (const [path, symbols] of aggregatedImports) {\n const renderedSymbols = [...symbols].join(\", \");\n renderedImports.push(`import { ${renderedSymbols} } from \"${renderImportPath(path)}\";`);\n }\n return renderedImports.join(\"\\n\");\n}\n\ninterface RenderWithStoreCallbackData {\n /** `_store` variable prefixed with its type (undefined if library name) */\n _typedStore: string | undefined;\n /** `_store` variable (undefined if library name) */\n _store: string;\n /** Empty string if storeArgument is false, otherwise `\" (using the specified store)\"` */\n _commentSuffix: string;\n /** Prefix to differentiate different kinds of store usage within methods */\n _methodNamePrefix: string;\n /** Whether FieldLayout variable should be passed to store methods */\n _useExplicitFieldLayout?: boolean;\n}\n\n/**\n * Renders several versions of the callback's result, which access Store in different ways\n * @param storeArgument whether to render a version with `IStore _store` as an argument\n * @param callback renderer for a method which uses store\n * @returns Concatenated results of all callback calls\n */\nexport function renderWithStore(\n storeArgument: boolean,\n callback: (data: RenderWithStoreCallbackData) => string,\n): string {\n let result = \"\";\n result += callback({ _typedStore: undefined, _store: \"StoreSwitch\", _commentSuffix: \"\", _methodNamePrefix: \"\" });\n result += callback({\n _typedStore: undefined,\n _store: \"StoreCore\",\n _commentSuffix: \"\",\n _methodNamePrefix: \"_\",\n _useExplicitFieldLayout: true,\n });\n\n if (storeArgument) {\n result +=\n \"\\n\" +\n callback({\n _typedStore: \"IStore _store\",\n _store: \"_store\",\n _commentSuffix: \" (using the specified store)\",\n _methodNamePrefix: \"\",\n });\n }\n\n return result;\n}\n\n/**\n * Renders several versions of the callback's result, which have different method name suffixes\n * @param withSuffixlessFieldMethods whether to render methods with an empty suffix\n * @param fieldName name of the field which the methods access, used for a suffix\n * @param callback renderer for a method to be suffixed\n * @returns Concatenated results of all callback calls\n */\nexport function renderWithFieldSuffix(\n withSuffixlessFieldMethods: boolean,\n fieldName: string,\n callback: (_methodNameSuffix: string) => string,\n): string {\n const methodNameSuffix = `${fieldName[0].toUpperCase()}${fieldName.slice(1)}`;\n let result = \"\";\n result += callback(methodNameSuffix);\n\n if (withSuffixlessFieldMethods) {\n result += \"\\n\" + callback(\"\");\n }\n\n return result;\n}\n\n/**\n * Renders `_tableId` definition of the given table.\n * @param param0 static resource data needed to construct the table ID\n */\nexport function renderTableId({\n namespace,\n name,\n offchainOnly,\n}: Pick<StaticResourceData, \"namespace\" | \"name\" | \"offchainOnly\">): string {\n const tableId = resourceToHex({\n type: offchainOnly ? \"offchainTable\" : \"table\",\n namespace,\n name,\n });\n // turn table ID back into arguments that would be valid in `WorldResourceIdLib.encode` (like truncated names)\n const resource = hexToResource(tableId);\n return `\n // Hex below is the result of \\`WorldResourceIdLib.encode({ namespace: ${JSON.stringify(\n resource.namespace,\n )}, name: ${JSON.stringify(resource.name)}, typeId: ${offchainOnly ? \"RESOURCE_OFFCHAIN_TABLE\" : \"RESOURCE_TABLE\"} });\\`\n ResourceId constant _tableId = ResourceId.wrap(${tableId});\n `;\n}\n\n/**\n * Renders solidity typecasts to get from the given type to `bytes32`\n * @param name variable name to be typecasted\n * @param param1 type data\n */\nexport function renderValueTypeToBytes32(\n name: string,\n { typeUnwrap, internalTypeId }: Pick<RenderType, \"typeUnwrap\" | \"internalTypeId\">,\n): string {\n const innerText = typeUnwrap.length ? `${typeUnwrap}(${name})` : name;\n\n if (internalTypeId === \"bytes32\") {\n return innerText;\n } else if (/^bytes\\d{1,2}$/.test(internalTypeId)) {\n return `bytes32(${innerText})`;\n } else if (/^uint\\d{1,3}$/.test(internalTypeId)) {\n return `bytes32(uint256(${innerText}))`;\n } else if (/^int\\d{1,3}$/.test(internalTypeId)) {\n return `bytes32(uint256(int256(${innerText})))`;\n } else if (internalTypeId === \"address\") {\n return `bytes32(uint256(uint160(${innerText})))`;\n } else if (internalTypeId === \"bool\") {\n return `_boolToBytes32(${innerText})`;\n } else {\n throw new Error(`Unknown value type id ${internalTypeId}`);\n }\n}\n\n/**\n * Whether the storage representation of the given solidity type is left aligned\n */\nexport function isLeftAligned(field: Pick<RenderType, \"internalTypeId\">): boolean {\n return /^bytes\\d{1,2}$/.test(field.internalTypeId);\n}\n\n/**\n * The number of padding bits in the storage representation of a right-aligned solidity type\n */\nexport function getLeftPaddingBits(field: Pick<RenderType, \"internalTypeId\" | \"staticByteLength\">): number {\n if (isLeftAligned(field)) {\n return 0;\n } else {\n return 256 - field.staticByteLength * 8;\n }\n}\n\n/**\n * Internal helper to render `lineTerminator`-separated list of items mapped by `renderItem`\n */\nfunction internalRenderList<T>(\n lineTerminator: string,\n list: T[],\n renderItem: (item: T, index: number) => string,\n): string {\n return list\n .map((item, index) => renderItem(item, index) + (index === list.length - 1 ? \"\" : lineTerminator))\n .join(\"\\n\");\n}\n","import { renderedSolidityHeader } from \"./common\";\n\n// importing this from config or store would be a cyclic dependency :(\ntype Enums = {\n readonly [name: string]: readonly [string, ...string[]];\n};\n\n/**\n * Render a list of enum data as solidity enum definitions\n */\nexport function renderEnums(enums: Enums): string {\n const enumDefinitions = Object.entries(enums).map(\n ([name, values]) => `\n enum ${name} {\n ${values.join(\", \")}\n }\n `,\n );\n\n return `\n ${renderedSolidityHeader}\n ${enumDefinitions.join(\"\")}\n `;\n}\n","import { RenderField, RenderKeyTuple, RenderType } from \"./types\";\n\n/**\n * Renders the necessary helper functions to typecast to/from the types of given fields and keys\n */\nexport function renderTypeHelpers(options: { fields: RenderField[]; keyTuple: RenderKeyTuple[] }): string {\n const { fields, keyTuple } = options;\n\n let result = \"\";\n\n for (const wrappingHelper of getWrappingHelpers([...fields, ...keyTuple])) {\n result += wrappingHelper;\n }\n\n // bool is special - it's the only primitive value type that can't be typecasted to/from\n if (fields.some(({ internalTypeId }) => internalTypeId.match(\"bool\"))) {\n result += `\n /**\n * @notice Cast a value to a bool.\n * @dev Boolean values are encoded as uint8 (1 = true, 0 = false), but Solidity doesn't allow casting between uint8 and bool.\n * @param value The uint8 value to convert.\n * @return result The boolean value.\n */\n function _toBool(uint8 value) pure returns (bool result) {\n assembly {\n result := value\n }\n }\n `;\n }\n if (keyTuple.some(({ internalTypeId }) => internalTypeId.match(\"bool\"))) {\n result += `\n /**\n * @notice Cast a bool to a bytes32.\n * @dev The boolean value is casted to a bytes32 value with 0 or 1 at the least significant bit.\n */\n function _boolToBytes32(bool value) pure returns (bytes32 result) {\n assembly {\n result := value\n }\n }\n `;\n }\n\n return result;\n}\n\nfunction getWrappingHelpers(array: RenderType[]): string[] {\n const wrappers = new Map<string, string>();\n const unwrappers = new Map<string, string>();\n for (const { typeWrappingData, typeWrap, typeUnwrap, internalTypeId } of array) {\n if (!typeWrappingData) continue;\n const { kind } = typeWrappingData;\n\n if (kind === \"staticArray\") {\n const { elementType, staticLength } = typeWrappingData;\n wrappers.set(typeWrap, renderWrapperStaticArray(typeWrap, elementType, staticLength, internalTypeId));\n unwrappers.set(typeUnwrap, renderUnwrapperStaticArray(typeUnwrap, elementType, staticLength, internalTypeId));\n }\n }\n\n return [...wrappers.values(), ...unwrappers.values()];\n}\n\n/**\n * Renders a function to cast a dynamic array to a static array.\n * @param functionName name of the function to be rendered\n * @param elementType type of the array's element\n * @param staticLength length of the static array\n * @param internalTypeId solidity type name of the dynamic array\n * @returns\n */\nfunction renderWrapperStaticArray(\n functionName: string,\n elementType: string,\n staticLength: number,\n internalTypeId: string,\n): string {\n // WARNING: ensure this still works if changing major solidity versions!\n // (the memory layout for static arrays may change)\n return `\n /**\n * @notice Cast a dynamic array to a static array.\n * @dev In memory static arrays are just dynamic arrays without the 32 length bytes,\n * so this function moves the pointer to the first element of the dynamic array.\n * If the length of the dynamic array is smaller than the static length,\n * the function returns an uninitialized array to avoid memory corruption.\n * @param _value The dynamic array to cast.\n * @return _result The static array.\n */\n function ${functionName}(\n ${internalTypeId} memory _value\n ) pure returns (\n ${elementType}[${staticLength}] memory _result\n ) {\n if (_value.length < ${staticLength}) {\n // return an uninitialized array if the length is smaller than the fixed length to avoid memory corruption\n return _result;\n } else {\n // in memory static arrays are just dynamic arrays without the 32 length bytes\n // (without the length check this could lead to memory corruption)\n assembly {\n _result := add(_value, 0x20)\n }\n }\n }\n `;\n}\n\n/**\n * Renders a function to cast a static array to a dynamic array.\n * @param functionName name of the function to be rendered\n * @param elementType type of the array's element\n * @param staticLength length of the static array\n * @param internalTypeId solidity type name of the dynamic array\n * @returns\n */\nfunction renderUnwrapperStaticArray(\n functionName: string,\n elementType: string,\n staticLength: number,\n internalTypeId: string,\n): string {\n // byte length for memory copying (more efficient than a loop)\n const byteLength = staticLength * 32;\n // TODO to optimize memory usage consider generalizing TightEncoder to a render-time utility\n return `\n /**\n * @notice Copy a static array to a dynamic array.\n * @dev Static arrays don't have a length prefix, so this function copies the memory from the static array to a new dynamic array.\n * @param _value The static array to copy.\n * @return _result The dynamic array.\n */ \n function ${functionName}(\n ${elementType}[${staticLength}] memory _value\n ) pure returns (\n ${internalTypeId} memory _result\n ) {\n _result = new ${internalTypeId}(${staticLength});\n uint256 fromPointer;\n uint256 toPointer;\n assembly {\n fromPointer := _value\n toPointer := add(_result, 0x20)\n }\n Memory.copy(fromPointer, toPointer, ${byteLength});\n }\n `;\n}\n","import { SchemaType } from \"@latticexyz/schema-type/deprecated\";\n\nexport const schemaTypesToRecsTypeStrings: Record<SchemaType, string> = {\n [SchemaType.UINT8]: \"RecsType.Number\",\n [SchemaType.UINT16]: \"RecsType.Number\",\n [SchemaType.UINT24]: \"RecsType.Number\",\n [SchemaType.UINT32]: \"RecsType.Number\",\n [SchemaType.UINT40]: \"RecsType.Number\",\n [SchemaType.UINT48]: \"RecsType.Number\",\n [SchemaType.UINT56]: \"RecsType.BigInt\",\n [SchemaType.UINT64]: \"RecsType.BigInt\",\n [SchemaType.UINT72]: \"RecsType.BigInt\",\n [SchemaType.UINT80]: \"RecsType.BigInt\",\n [SchemaType.UINT88]: \"RecsType.BigInt\",\n [SchemaType.UINT96]: \"RecsType.BigInt\",\n [SchemaType.UINT104]: \"RecsType.BigInt\",\n [SchemaType.UINT112]: \"RecsType.BigInt\",\n [SchemaType.UINT120]: \"RecsType.BigInt\",\n [SchemaType.UINT128]: \"RecsType.BigInt\",\n [SchemaType.UINT136]: \"RecsType.BigInt\",\n [SchemaType.UINT144]: \"RecsType.BigInt\",\n [SchemaType.UINT152]: \"RecsType.BigInt\",\n [SchemaType.UINT160]: \"RecsType.BigInt\",\n [SchemaType.UINT168]: \"RecsType.BigInt\",\n [SchemaType.UINT176]: \"RecsType.BigInt\",\n [SchemaType.UINT184]: \"RecsType.BigInt\",\n [SchemaType.UINT192]: \"RecsType.BigInt\",\n [SchemaType.UINT200]: \"RecsType.BigInt\",\n [SchemaType.UINT208]: \"RecsType.BigInt\",\n [SchemaType.UINT216]: \"RecsType.BigInt\",\n [SchemaType.UINT224]: \"RecsType.BigInt\",\n [SchemaType.UINT232]: \"RecsType.BigInt\",\n [SchemaType.UINT240]: \"RecsType.BigInt\",\n [SchemaType.UINT248]: \"RecsType.BigInt\",\n [SchemaType.UINT256]: \"RecsType.BigInt\",\n [SchemaType.INT8]: \"RecsType.Number\",\n [SchemaType.INT16]: \"RecsType.Number\",\n [SchemaType.INT24]: \"RecsType.Number\",\n [SchemaType.INT32]: \"RecsType.Number\",\n [SchemaType.INT40]: \"RecsType.Number\",\n [SchemaType.INT48]: \"RecsType.Number\",\n [SchemaType.INT56]: \"RecsType.BigInt\",\n [SchemaType.INT64]: \"RecsType.BigInt\",\n [SchemaType.INT72]: \"RecsType.BigInt\",\n [SchemaType.INT80]: \"RecsType.BigInt\",\n [SchemaType.INT88]: \"RecsType.BigInt\",\n [SchemaType.INT96]: \"RecsType.BigInt\",\n [SchemaType.INT104]: \"RecsType.BigInt\",\n [SchemaType.INT112]: \"RecsType.BigInt\",\n [SchemaType.INT120]: \"RecsType.BigInt\",\n [SchemaType.INT128]: \"RecsType.BigInt\",\n [SchemaType.INT136]: \"RecsType.BigInt\",\n [SchemaType.INT144]: \"RecsType.BigInt\",\n [SchemaType.INT152]: \"RecsType.BigInt\",\n [SchemaType.INT160]: \"RecsType.BigInt\",\n [SchemaType.INT168]: \"RecsType.BigInt\",\n [SchemaType.INT176]: \"RecsType.BigInt\",\n [SchemaType.INT184]: \"RecsType.BigInt\",\n [SchemaType.INT192]: \"RecsType.BigInt\",\n [SchemaType.INT200]: \"RecsType.BigInt\",\n [SchemaType.INT208]: \"RecsType.BigInt\",\n [SchemaType.INT216]: \"RecsType.BigInt\",\n [SchemaType.INT224]: \"RecsType.BigInt\",\n [SchemaType.INT232]: \"RecsType.BigInt\",\n [SchemaType.INT240]: \"RecsType.BigInt\",\n [SchemaType.INT248]: \"RecsType.BigInt\",\n [SchemaType.INT256]: \"RecsType.BigInt\",\n [SchemaType.BYTES1]: \"RecsType.String\",\n [SchemaType.BYTES2]: \"RecsType.String\",\n [SchemaType.BYTES3]: \"RecsType.String\",\n [SchemaType.BYTES4]: \"RecsType.String\",\n [SchemaType.BYTES5]: \"RecsType.String\",\n [SchemaType.BYTES6]: \"RecsType.String\",\n [SchemaType.BYTES7]: \"RecsType.String\",\n [SchemaType.BYTES8]: \"RecsType.String\",\n [SchemaType.BYTES9]: \"RecsType.String\",\n [SchemaType.BYTES10]: \"RecsType.String\",\n [SchemaType.BYTES11]: \"RecsType.String\",\n [SchemaType.BYTES12]: \"RecsType.String\",\n [SchemaType.BYTES13]: \"RecsType.String\",\n [SchemaType.BYTES14]: \"RecsType.String\",\n [SchemaType.BYTES15]: \"RecsType.String\",\n [SchemaType.BYTES16]: \"RecsType.String\",\n [SchemaType.BYTES17]: \"RecsType.String\",\n [SchemaType.BYTES18]: \"RecsType.String\",\n [SchemaType.BYTES19]: \"RecsType.String\",\n [SchemaType.BYTES20]: \"RecsType.String\",\n [SchemaType.BYTES21]: \"RecsType.String\",\n [SchemaType.BYTES22]: \"RecsType.String\",\n [SchemaType.BYTES23]: \"RecsType.String\",\n [SchemaType.BYTES24]: \"RecsType.String\",\n [SchemaType.BYTES25]: \"RecsType.String\",\n [SchemaType.BYTES26]: \"RecsType.String\",\n [SchemaType.BYTES27]: \"RecsType.String\",\n [SchemaType.BYTES28]: \"RecsType.String\",\n [SchemaType.BYTES29]: \"RecsType.String\",\n [SchemaType.BYTES30]: \"RecsType.String\",\n [SchemaType.BYTES31]: \"RecsType.String\",\n [SchemaType.BYTES32]: \"RecsType.String\",\n [SchemaType.BOOL]: \"RecsType.Boolean\",\n [SchemaType.ADDRESS]: \"RecsType.String\",\n [SchemaType.UINT8_ARRAY]: \"RecsType.NumberArray\",\n [SchemaType.UINT16_ARRAY]: \"RecsType.NumberArray\",\n [SchemaType.UINT24_ARRAY]: \"RecsType.NumberArray\",\n [SchemaType.UINT32_ARRAY]: \"RecsType.NumberArray\",\n [SchemaType.UINT40_ARRAY]: \"RecsType.NumberArray\",\n [SchemaType.UINT48_ARRAY]: \"RecsType.NumberArray\",\n [SchemaType.UINT56_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.UINT64_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.UINT72_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.UINT80_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.UINT88_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.UINT96_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.UINT104_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.UINT112_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.UINT120_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.UINT128_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.UINT136_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.UINT144_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.UINT152_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.UINT160_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.UINT168_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.UINT176_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.UINT184_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.UINT192_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.UINT200_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.UINT208_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.UINT216_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.UINT224_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.UINT232_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.UINT240_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.UINT248_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.UINT256_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.INT8_ARRAY]: \"RecsType.NumberArray\",\n [SchemaType.INT16_ARRAY]: \"RecsType.NumberArray\",\n [SchemaType.INT24_ARRAY]: \"RecsType.NumberArray\",\n [SchemaType.INT32_ARRAY]: \"RecsType.NumberArray\",\n [SchemaType.INT40_ARRAY]: \"RecsType.NumberArray\",\n [SchemaType.INT48_ARRAY]: \"RecsType.NumberArray\",\n [SchemaType.INT56_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.INT64_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.INT72_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.INT80_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.INT88_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.INT96_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.INT104_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.INT112_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.INT120_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.INT128_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.INT136_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.INT144_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.INT152_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.INT160_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.INT168_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.INT176_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.INT184_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.INT192_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.INT200_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.INT208_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.INT216_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.INT224_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.INT232_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.INT240_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.INT248_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.INT256_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.BYTES1_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.BYTES2_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.BYTES3_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.BYTES4_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.BYTES5_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.BYTES6_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.BYTES7_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.BYTES8_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.BYTES9_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.BYTES10_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.BYTES11_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.BYTES12_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.BYTES13_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.BYTES14_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.BYTES15_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.BYTES16_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.BYTES17_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.BYTES18_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.BYTES19_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.BYTES20_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.BYTES21_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.BYTES22_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.BYTES23_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.BYTES24_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.BYTES25_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.BYTES26_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.BYTES27_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.BYTES28_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.BYTES29_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.BYTES30_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.BYTES31_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.BYTES32_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.BOOL_ARRAY]: \"RecsType.T\", // no boolean array\n [SchemaType.ADDRESS_ARRAY]: \"RecsType.StringArray\",\n [SchemaType.BYTES]: \"RecsType.String\",\n [SchemaType.STRING]: \"RecsType.String\",\n};\n","import { parse, visit } from \"@solidity-parser/parser\";\nimport type { SourceUnit, TypeName, VariableDeclaration } from \"@solidity-parser/parser/dist/src/ast-types\";\nimport { MUDError } from \"../../errors\";\nimport { findContractNode } from \"./findContractNode\";\nimport { SymbolImport, findSymbolImport } from \"./findSymbolImport\";\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\nexport interface QualifiedSymbol {\n symbol: string;\n qualifier?: string; // e.g., \"IParentContract\" for IParentContract.SomeStruct\n sourcePath: 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 source contents of a file with the solidity contract\n * @param contractName name of the contract\n * @returns interface data\n */\nexport function contractToInterface(\n source: string,\n contractName: string,\n findInheritedSymbol?: (symbol: string) => QualifiedSymbol | undefined,\n): {\n functions: ContractInterfaceFunction[];\n errors: ContractInterfaceError[];\n symbolImports: SymbolImport[];\n qualifiedSymbols: Map<string, QualifiedSymbol>;\n} {\n let ast: SourceUnit;\n try {\n ast = parse(source);\n } catch (error) {\n throw new MUDError(`Failed to parse contract ${contractName}: ${error}`);\n }\n const contractNode = findContractNode(ast, contractName);\n let symbolImports: SymbolImport[] = [];\n const functions: ContractInterfaceFunction[] = [];\n const errors: ContractInterfaceError[] = [];\n const qualifiedSymbols = new Map<string, QualifiedSymbol>();\n\n if (!contractNode) {\n throw new MUDError(`Contract not found: ${contractName}`);\n }\n\n visit(contractNode, {\n FunctionDefinition({\n name,\n visibility,\n parameters,\n stateMutability,\n returnParameters,\n isConstructor,\n isFallback,\n isReceiveEther,\n }) {\n try {\n // skip constructor and fallbacks\n if (isConstructor || isFallback || isReceiveEther) return;\n // forbid default visibility (this check might be unnecessary, modern solidity already disallows this)\n if (visibility === \"default\") throw new MUDError(`Visibility is not specified`);\n\n if (visibility === \"external\" || visibility === \"public\") {\n functions.push({\n name: name === null ? \"\" : name,\n parameters: parameters.map(parseParameter),\n stateMutability: stateMutability || \"\",\n returnParameters: returnParameters === null ? [] : returnParameters.map(parseParameter),\n });\n\n for (const { typeName } of parameters.concat(returnParameters ?? [])) {\n const symbols = typeNameToSymbols(typeName);\n symbolImports = symbolImports.concat(symbolsToImports(ast, symbols, findInheritedSymbol, qualifiedSymbols));\n }\n }\n } catch (error: unknown) {\n if (error instanceof MUDError) {\n error.message = `Function \"${name}\" in contract \"${contractName}\": ${error.message}`;\n }\n throw error;\n }\n },\n CustomErrorDefinition({ name, parameters }) {\n errors.push({\n name,\n parameters: parameters.map(parseParameter),\n });\n\n for (const parameter of parameters) {\n const symbols = typeNameToSymbols(parameter.typeName);\n symbolImports = symbolImports.concat(symbolsToImports(ast, symbols, findInheritedSymbol, qualifiedSymbols));\n }\n },\n });\n\n return {\n functions,\n errors,\n symbolImports,\n qualifiedSymbols,\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\nfunction symbolsToImports(\n ast: SourceUnit,\n symbols: string[],\n findInheritedSymbol?: (symbol: string) => QualifiedSymbol | undefined,\n qualifiedSymbols?: Map<string, QualifiedSymbol>,\n): SymbolImport[] {\n const imports: SymbolImport[] = [];\n\n for (const symbol of symbols) {\n // First check explicit imports\n const explicitImport = findSymbolImport(ast, symbol);\n if (explicitImport) {\n imports.push(explicitImport);\n continue;\n }\n\n // Then check inherited symbols\n if (findInheritedSymbol) {\n const inheritedSymbol = findInheritedSymbol(symbol);\n if (inheritedSymbol) {\n // Track qualified symbol\n if (qualifiedSymbols) {\n qualifiedSymbols.set(symbol, inheritedSymbol);\n }\n // Add import for the parent contract if it has a qualifier\n if (inheritedSymbol.qualifier) {\n imports.push({\n symbol: inheritedSymbol.qualifier,\n path: inheritedSymbol.sourcePath,\n });\n }\n }\n }\n }\n\n // Deduplicate imports\n const uniqueImports = new Map<string, SymbolImport>();\n for (const imp of imports) {\n const key = `${imp.symbol}:${imp.path}`;\n if (!uniqueImports.has(key)) {\n uniqueImports.set(key, imp);\n }\n }\n\n return Array.from(uniqueImports.values());\n}\n","import { visit } from \"@solidity-parser/parser\";\nimport type { ContractDefinition, SourceUnit } from \"@solidity-parser/parser/dist/src/ast-types\";\n\nexport function findContractNode(ast: SourceUnit, contractName: string): ContractDefinition | undefined {\n let contract: ContractDefinition | undefined = undefined;\n\n visit(ast, {\n ContractDefinition(node) {\n if (node.name === contractName) {\n contract = node;\n }\n },\n });\n\n return contract;\n}\n","import { visit } from \"@solidity-parser/parser\";\nimport type { SourceUnit } from \"@solidity-parser/parser/dist/src/ast-types\";\n\nexport interface SymbolImport {\n symbol: string;\n path: string;\n}\n\n/**\n * Get import for given symbol.\n *\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 ...`\n */\nexport function findSymbolImport(ast: SourceUnit, symbol: string): SymbolImport | undefined {\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 return symbolImport;\n}\n","import prettier from \"prettier\";\nimport prettierPluginSolidity from \"prettier-plugin-solidity\";\n\n/**\n * Formats solidity code using prettier\n * @param content solidity code\n * @param prettierConfigPath optional path to a prettier config\n * @returns formatted solidity code\n */\nexport async function formatSolidity(content: string, prettierConfigPath?: string): Promise<string> {\n let config;\n if (prettierConfigPath) {\n config = await prettier.resolveConfig(prettierConfigPath);\n }\n try {\n return prettier.format(content, {\n plugins: [prettierPluginSolidity],\n parser: \"solidity-parse\",\n\n printWidth: 120,\n semi: true,\n tabWidth: 2,\n useTabs: false,\n bracketSpacing: true,\n\n ...config,\n });\n } catch (error) {\n let message;\n if (error instanceof Error) {\n message = error.message;\n } else {\n message = error;\n }\n console.log(`Error during output formatting: ${message}`);\n return content;\n }\n}\n\n/**\n * Formats typescript code using prettier\n * @param content typescript code\n * @returns formatted typescript code\n */\nexport async function formatTypescript(content: string): Promise<string> {\n return prettier.format(content, {\n parser: \"typescript\",\n });\n}\n","import fs from \"node:fs/promises\";\nimport path from \"node:path\";\nimport { formatSolidity, formatTypescript } from \"./format\";\nimport { debug, error } from \"../debug\";\n\n/**\n * Formats solidity code using prettier and write it to a file\n * @param content solidity code\n * @param fullOutputPath full path to the output file\n * @param logPrefix prefix for debug logs\n */\nexport async function formatAndWriteSolidity(\n content: string,\n fullOutputPath: string,\n logPrefix: string,\n): Promise<void> {\n let output = content;\n try {\n output = await formatSolidity(output);\n } catch (e) {\n error(`Error while attempting to format ${fullOutputPath}`, e);\n }\n await fs.mkdir(path.dirname(fullOutputPath), { recursive: true });\n await fs.writeFile(fullOutputPath, output);\n debug(`${logPrefix}: ${fullOutputPath}`);\n}\n\n/**\n * Formats typescript code using prettier and write it to a file\n * @param output typescript code\n * @param fullOutputPath full path to the output file\n * @param logPrefix prefix for debug logs\n */\nexport async function formatAndWriteTypescript(\n output: string,\n fullOutputPath: string,\n logPrefix: string,\n): Promise<void> {\n const formattedOutput = await formatTypescript(output);\n\n await fs.mkdir(path.dirname(fullOutputPath), { recursive: true });\n\n await fs.writeFile(fullOutputPath, formattedOutput);\n debug(`${logPrefix}: ${fullOutputPath}`);\n}\n","import { debug as parentDebug } from \"../debug\";\n\nexport const debug = parentDebug.extend(\"codegen\");\nexport const error = parentDebug.extend(\"codegen\");\n\n// Pipe debug output to stdout instead of stderr\ndebug.log = console.debug.bind(console);\n\n// Pipe error output to stderr\nerror.log = console.error.bind(console);\n","import { parse, visit } from \"@solidity-parser/parser\";\n\nimport { findContractNode } from \"./findContractNode\";\nimport { findSymbolImport } from \"./findSymbolImport\";\n\nconst baseSystemName = \"System\";\nconst baseSystemPath = \"@latticexyz/world/src/System.sol\";\n\nexport function parseSystem(\n source: string,\n contractName: string,\n): undefined | { contractType: \"contract\" | \"abstract\" } {\n const ast = parse(source);\n const contractNode = findContractNode(ast, contractName);\n if (!contractNode) return;\n\n const contractType = contractNode.kind;\n // skip libraries and interfaces\n // we allow abstract systems here so that we can create system libraries from them but without deploying them\n if (contractType !== \"contract\" && contractType !== \"abstract\") return;\n\n const isSystem = ((): boolean => {\n // if using the System suffix, assume its a system\n if (contractName.endsWith(\"System\") && contractName !== baseSystemName) return true;\n\n // otherwise check if we're inheriting from the base system\n let extendsBaseSystem = false;\n visit(contractNode, {\n InheritanceSpecifier(node) {\n if (node.baseName.namePath === baseSystemName) {\n extendsBaseSystem = true;\n }\n },\n });\n return extendsBaseSystem && findSymbolImport(ast, baseSystemName)?.path === baseSystemPath;\n })();\n\n if (isSystem) {\n return { contractType };\n }\n}\n","import { parse, visit } from \"@solidity-parser/parser\";\nimport type { SourceUnit, ContractDefinition } from \"@solidity-parser/parser/dist/src/ast-types\";\nimport { readFile } from \"node:fs/promises\";\nimport path from \"node:path\";\nimport { findContractNode } from \"./findContractNode\";\nimport { QualifiedSymbol } from \"./contractToInterface\";\nimport { findSymbolImport } from \"./findSymbolImport\";\nimport { resolveRemapping } from \"./resolveRemapping\";\n\ninterface InheritanceInfo {\n baseContracts: string[];\n baseContractImports: Map<string, string>; // baseName -> import path\n symbols: Map<string, { type: \"struct\" | \"enum\" | \"error\"; contract: string }>;\n filePath?: string; // Track where this contract was defined\n}\n\n/**\n * Creates a resolver function that can find symbols through contract inheritance chains\n * @param contractPath Path to the contract file\n * @param contractName Name of the contract\n * @returns A function that resolves symbols to their qualified forms\n */\nexport async function createInheritanceResolver(\n contractPath: string,\n contractName: string,\n rootDir: string,\n remappings: string[] = [],\n): Promise<(symbol: string) => QualifiedSymbol | undefined> {\n const resolvedContracts = new Map<string, InheritanceInfo>();\n const visitedPaths = new Set<string>();\n\n async function parseContract(filePath: string, targetContractName?: string): Promise<InheritanceInfo | undefined> {\n // Prevent infinite recursion\n const normalizedPath = path.resolve(filePath);\n const visitKey = targetContractName ? `${normalizedPath}:${targetContractName}` : normalizedPath;\n if (visitedPaths.has(visitKey)) {\n return undefined;\n }\n visitedPaths.add(visitKey);\n\n try {\n const source = await readFile(filePath, \"utf8\");\n\n // Try to parse the source\n let ast: SourceUnit;\n try {\n ast = parse(source);\n } catch (parseError) {\n // If parsing fails, log the error and skip this file\n console.warn(`Warning: Failed to parse ${filePath} for inheritance resolution:`, parseError);\n return undefined;\n }\n\n // If targetContractName is specified, find that specific contract\n // Otherwise, process all contracts in the file\n const contractsToProcess: ContractDefinition[] = [];\n\n if (targetContractName) {\n const contractNode = findContractNode(ast, targetContractName);\n if (contractNode) {\n contractsToProcess.push(contractNode);\n }\n } else {\n visit(ast, {\n ContractDefinition(node) {\n contractsToProcess.push(node);\n },\n });\n }\n\n // Process each contract\n for (const contractNode of contractsToProcess) {\n const info: InheritanceInfo = {\n baseContracts: [],\n baseContractImports: new Map(),\n symbols: new Map(),\n filePath: normalizedPath,\n };\n\n // Extract base contracts\n if (contractNode.baseContracts) {\n for (const base of contractNode.baseContracts) {\n info.baseContracts.push(base.baseName.namePath);\n }\n }\n\n // Extract symbols defined in this contract/interface\n visit(contractNode, {\n StructDefinition(node) {\n if (node.name) {\n info.symbols.set(node.name, { type: \"struct\", contract: contractNode.name });\n }\n },\n EnumDefinition(node) {\n if (node.name) {\n info.symbols.set(node.name, { type: \"enum\", contract: contractNode.name });\n }\n },\n CustomErrorDefinition(node) {\n if (node.name) {\n info.symbols.set(node.name, { type: \"error\", contract: contractNode.name });\n }\n },\n });\n\n resolvedContracts.set(contractNode.name, info);\n\n // Recursively process base contracts\n for (const baseName of info.baseContracts) {\n // First check if it's imported\n const importInfo = findSymbolImport(ast, baseName);\n if (importInfo) {\n // Store the original import path\n info.baseContractImports.set(baseName, importInfo.path);\n\n const resolvedPath = importInfo.path.startsWith(\".\")\n ? path.resolve(path.dirname(filePath), importInfo.path)\n : resolveRemapping(importInfo.path, remappings, rootDir);\n\n await parseContract(resolvedPath, baseName);\n }\n }\n }\n\n return targetContractName ? resolvedContracts.get(targetContractName) : undefined;\n } catch (error) {\n // Silently fail if we can't read/parse a file\n return undefined;\n }\n }\n\n // Parse the main contract and its inheritance chain\n await parseContract(contractPath, contractName);\n\n // Create the resolver function\n return (symbol: string): QualifiedSymbol | undefined => {\n // Check if symbol is defined in the main contract\n const mainInfo = resolvedContracts.get(contractName);\n if (mainInfo?.symbols.has(symbol)) {\n // Symbol is defined in main contract, no qualification needed\n return {\n symbol,\n sourcePath: contractPath,\n };\n }\n\n // Search through inheritance chain\n function searchInheritance(currentContract: string, visited: Set<string> = new Set()): QualifiedSymbol | undefined {\n if (visited.has(currentContract)) {\n return undefined;\n }\n visited.add(currentContract);\n\n const contractInfo = resolvedContracts.get(currentContract);\n if (!contractInfo) {\n return undefined;\n }\n\n // Check each base contract\n for (const baseName of contractInfo.baseContracts) {\n const baseInfo = resolvedContracts.get(baseName);\n if (baseInfo?.symbols.has(symbol)) {\n // Found the symbol in a base contract\n // Find the import path for this base contract\n let importPath: string | undefined;\n\n for (const [, info] of resolvedContracts) {\n const baseImportPath = info.baseContractImports.get(baseName);\n if (baseImportPath) {\n importPath = baseImportPath;\n break;\n }\n }\n\n // If we still don't have an import path, throw an error\n if (!importPath) {\n throw new Error(\n `Could not find import path for base contract \"${baseName}\" which defines \"${symbol}\". ` +\n `Make sure \"${baseName}\" is properly imported in your contract or its dependencies.`,\n );\n }\n\n return {\n symbol,\n qualifier: baseName,\n sourcePath: importPath,\n };\n }\n\n // Recursively search in base's bases\n const result = searchInheritance(baseName, visited);\n if (result) {\n return result;\n }\n }\n\n return undefined;\n }\n\n return searchInheritance(contractName);\n };\n}\n","import path from \"path\";\n\n/**\n * Resolves an import path using forge remappings\n * @param importPath The import path to resolve (e.g., \"@latticexyz/store/src/Store.sol\")\n * @param remappings Array of forge remapping strings (e.g., [\"@latticexyz/=node_modules/@latticexyz/\"])\n * @param rootDir The root directory to resolve relative to\n * @returns The resolved file path, or the original path if no remapping applies\n */\nexport function resolveRemapping(importPath: string, remappings: string[], rootDir: string): string {\n // Parse remappings into { from, to } objects\n const parsedRemappings = remappings.map((remapping) => {\n const [from, to] = remapping.split(\"=\");\n return { from, to };\n });\n\n // Sort by length descending to match longest prefix first\n parsedRemappings.sort((a, b) => b.from.length - a.from.length);\n\n // Find the first matching remapping\n for (const { from, to } of parsedRemappings) {\n if (importPath.startsWith(from)) {\n // Replace the prefix with the mapped path\n const resolvedPath = importPath.replace(from, to);\n // Resolve to absolute path\n return path.resolve(rootDir, resolvedPath);\n }\n }\n\n // No remapping found, return original path\n return importPath;\n}\n","/**\n * Apply type qualifiers to function parameters or return types\n * @param params Array of parameter strings (e.g., [\"uint256 value\", \"SomeStruct memory data\"])\n * @param typeQualifiers Map of type names to their qualified forms (e.g., \"SomeStruct\" -> \"IParent.SomeStruct\")\n * @returns Array of parameters with qualified types applied\n */\nexport function applyTypeQualifiers(params: string[], typeQualifiers?: Map<string, string>): string[] {\n if (!typeQualifiers || typeQualifiers.size === 0) {\n return params;\n }\n\n return params.map((param) => {\n // Split parameter into parts (e.g., \"SomeStruct memory myParam\" -> [\"SomeStruct\", \"memory\", \"myParam\"])\n const parts = param.trim().split(/\\s+/);\n if (parts.length === 0) return param;\n\n const type = parts[0];\n\n // Check if this is an array type\n const arrayMatch = type.match(/^(.+?)(\\[\\]|\\[\\d+\\])$/);\n if (arrayMatch) {\n const baseType = arrayMatch[1];\n const arraySuffix = arrayMatch[2];\n\n // Check if base type needs qualification\n if (typeQualifiers.has(baseType)) {\n const qualifiedType = typeQualifiers.get(baseType) + arraySuffix;\n parts[0] = qualifiedType;\n return parts.join(\" \");\n }\n } else {\n // Check if type needs qualification\n if (typeQualifiers.has(type)) {\n parts[0] = typeQualifiers.get(type)!;\n return parts.join(\" \");\n }\n }\n\n return param;\n });\n}\n"],"mappings":";;;;;;;;;;;;;;;AACA,SAAqC,eAAe,0BAA0B;;;ACD9E,OAAO,UAAU;AAIjB,SAAS,WAAW,SAAyB;AAC3C,SAAO,QAAQ,WAAW,KAAK,MAAM,KAAK,KAAK,MAAM,GAAG;AAC1D;AAEO,SAAS,iBAAiB,aAAqB,UAAqC;AAEzF,QAAM,WAAW,KAAK,MACnB,KAAK,WAAW,QAAQ,GAAG,GAAG,SAAS,IAAI,UAAU,CAAC,EAEtD,QAAQ,OAAO,EAAE;AAIpB,MAAI,SAAS,WAAW,GAAG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;AAC7B,YAAM,cAAc,WAAW,CAAC;AAGhC,UAAI,eAAe,IAAI,QAAQ,GAAG;AAChC,cAAM,gBAAgB,eAAe,IAAI,QAAQ,IAAI;AACrD,cAAM,CAAC,IAAI;AACX,eAAO,MAAM,KAAK,GAAG;AAAA,MACvB;AAAA,IACF,OAAO;AAEL,UAAI,eAAe,IAAI,IAAI,GAAG;AAC5B,cAAM,CAAC,IAAI,eAAe,IAAI,IAAI;AAClC,eAAO,MAAM,KAAK,GAAG;AAAA,MACvB;AAAA,IACF;AAEA,WAAO;AAAA,EACT,CAAC;AACH;","names":["path","visit","visit","path","error","visit","error","path","debug","path","debug","parse","visit","parse","visit","parse","visit","path","path","path","parse","visit","error"]}
|
package/dist/foundry.d.ts
CHANGED
|
@@ -40,5 +40,11 @@ declare function getOutDirectory(profile?: string): Promise<string>;
|
|
|
40
40
|
* @returns The rpc url
|
|
41
41
|
*/
|
|
42
42
|
declare function getRpcUrl(profile?: string): Promise<string>;
|
|
43
|
+
/**
|
|
44
|
+
* Get the remappings from forge config.
|
|
45
|
+
* @param profile The foundry profile to use
|
|
46
|
+
* @returns Array of remapping strings (e.g., ["@latticexyz/=node_modules/@latticexyz/"])
|
|
47
|
+
*/
|
|
48
|
+
declare function getRemappings(profile?: string): Promise<string[]>;
|
|
43
49
|
|
|
44
|
-
export { type ForgeConfig, getForgeConfig, getOutDirectory, getRpcUrl, getScriptDirectory, getSrcDirectory, getTestDirectory };
|
|
50
|
+
export { type ForgeConfig, getForgeConfig, getOutDirectory, getRemappings, getRpcUrl, getScriptDirectory, getSrcDirectory, getTestDirectory };
|
package/dist/foundry.js
CHANGED
|
@@ -22,9 +22,13 @@ async function getOutDirectory(profile) {
|
|
|
22
22
|
async function getRpcUrl(profile) {
|
|
23
23
|
return process.env.FOUNDRY_ETH_RPC_URL || process.env.RPC_HTTP_URL || process.env.RPC_URL || (await getForgeConfig(profile)).eth_rpc_url || "http://127.0.0.1:8545";
|
|
24
24
|
}
|
|
25
|
+
async function getRemappings(profile) {
|
|
26
|
+
return (await getForgeConfig(profile)).remappings;
|
|
27
|
+
}
|
|
25
28
|
export {
|
|
26
29
|
getForgeConfig,
|
|
27
30
|
getOutDirectory,
|
|
31
|
+
getRemappings,
|
|
28
32
|
getRpcUrl,
|
|
29
33
|
getScriptDirectory,
|
|
30
34
|
getSrcDirectory,
|
package/dist/foundry.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/foundry/index.ts"],"sourcesContent":["import { execa } from \"execa\";\n\nexport interface ForgeConfig {\n // project\n src: string;\n test: string;\n script: string;\n out: string;\n libs: string[];\n cache: boolean;\n cache_path: string;\n eth_rpc_url: string | null;\n\n // compiler\n remappings: string[];\n\n // all unspecified keys (this interface is far from comprehensive)\n [key: string]: unknown;\n}\n\n/**\n * Get forge config as a parsed json object.\n */\nexport async function getForgeConfig(profile?: string): Promise<ForgeConfig> {\n const { stdout } = await execa(\"forge\", [\"config\", \"--json\"], {\n stdio: [\"inherit\", \"pipe\", \"pipe\"],\n env: { FOUNDRY_PROFILE: profile },\n });\n\n return JSON.parse(stdout) as ForgeConfig;\n}\n\n/**\n * Get the value of \"src\" from forge config.\n * The path to the contract sources relative to the root of the project.\n */\nexport async function getSrcDirectory(profile?: string): Promise<string> {\n return (await getForgeConfig(profile)).src;\n}\n\n/**\n * Get the value of \"script\" from forge config.\n * The path to the contract sources relative to the root of the project.\n */\nexport async function getScriptDirectory(profile?: string): Promise<string> {\n return (await getForgeConfig(profile)).script;\n}\n\n/**\n * Get the value of \"test\" from forge config.\n * The path to the test contract sources relative to the root of the project.\n */\nexport async function getTestDirectory(profile?: string): Promise<string> {\n return (await getForgeConfig(profile)).test;\n}\n\n/**\n * Get the value of \"out\" from forge config.\n * The path to put contract artifacts in, relative to the root of the project.\n */\nexport async function getOutDirectory(profile?: string): Promise<string> {\n return (await getForgeConfig(profile)).out;\n}\n\n/**\n * Get the value of \"eth_rpc_url\" from forge config, default to \"http://127.0.0.1:8545\"\n * @param profile The foundry profile to use\n * @returns The rpc url\n */\nexport async function getRpcUrl(profile?: string): Promise<string> {\n return (\n process.env.FOUNDRY_ETH_RPC_URL ||\n process.env.RPC_HTTP_URL ||\n process.env.RPC_URL ||\n (await getForgeConfig(profile)).eth_rpc_url ||\n \"http://127.0.0.1:8545\"\n );\n}\n"],"mappings":";AAAA,SAAS,aAAa;AAuBtB,eAAsB,eAAe,SAAwC;AAC3E,QAAM,EAAE,OAAO,IAAI,MAAM,MAAM,SAAS,CAAC,UAAU,QAAQ,GAAG;AAAA,IAC5D,OAAO,CAAC,WAAW,QAAQ,MAAM;AAAA,IACjC,KAAK,EAAE,iBAAiB,QAAQ;AAAA,EAClC,CAAC;AAED,SAAO,KAAK,MAAM,MAAM;AAC1B;AAMA,eAAsB,gBAAgB,SAAmC;AACvE,UAAQ,MAAM,eAAe,OAAO,GAAG;AACzC;AAMA,eAAsB,mBAAmB,SAAmC;AAC1E,UAAQ,MAAM,eAAe,OAAO,GAAG;AACzC;AAMA,eAAsB,iBAAiB,SAAmC;AACxE,UAAQ,MAAM,eAAe,OAAO,GAAG;AACzC;AAMA,eAAsB,gBAAgB,SAAmC;AACvE,UAAQ,MAAM,eAAe,OAAO,GAAG;AACzC;AAOA,eAAsB,UAAU,SAAmC;AACjE,SACE,QAAQ,IAAI,uBACZ,QAAQ,IAAI,gBACZ,QAAQ,IAAI,YACX,MAAM,eAAe,OAAO,GAAG,eAChC;AAEJ;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../src/foundry/index.ts"],"sourcesContent":["import { execa } from \"execa\";\n\nexport interface ForgeConfig {\n // project\n src: string;\n test: string;\n script: string;\n out: string;\n libs: string[];\n cache: boolean;\n cache_path: string;\n eth_rpc_url: string | null;\n\n // compiler\n remappings: string[];\n\n // all unspecified keys (this interface is far from comprehensive)\n [key: string]: unknown;\n}\n\n/**\n * Get forge config as a parsed json object.\n */\nexport async function getForgeConfig(profile?: string): Promise<ForgeConfig> {\n const { stdout } = await execa(\"forge\", [\"config\", \"--json\"], {\n stdio: [\"inherit\", \"pipe\", \"pipe\"],\n env: { FOUNDRY_PROFILE: profile },\n });\n\n return JSON.parse(stdout) as ForgeConfig;\n}\n\n/**\n * Get the value of \"src\" from forge config.\n * The path to the contract sources relative to the root of the project.\n */\nexport async function getSrcDirectory(profile?: string): Promise<string> {\n return (await getForgeConfig(profile)).src;\n}\n\n/**\n * Get the value of \"script\" from forge config.\n * The path to the contract sources relative to the root of the project.\n */\nexport async function getScriptDirectory(profile?: string): Promise<string> {\n return (await getForgeConfig(profile)).script;\n}\n\n/**\n * Get the value of \"test\" from forge config.\n * The path to the test contract sources relative to the root of the project.\n */\nexport async function getTestDirectory(profile?: string): Promise<string> {\n return (await getForgeConfig(profile)).test;\n}\n\n/**\n * Get the value of \"out\" from forge config.\n * The path to put contract artifacts in, relative to the root of the project.\n */\nexport async function getOutDirectory(profile?: string): Promise<string> {\n return (await getForgeConfig(profile)).out;\n}\n\n/**\n * Get the value of \"eth_rpc_url\" from forge config, default to \"http://127.0.0.1:8545\"\n * @param profile The foundry profile to use\n * @returns The rpc url\n */\nexport async function getRpcUrl(profile?: string): Promise<string> {\n return (\n process.env.FOUNDRY_ETH_RPC_URL ||\n process.env.RPC_HTTP_URL ||\n process.env.RPC_URL ||\n (await getForgeConfig(profile)).eth_rpc_url ||\n \"http://127.0.0.1:8545\"\n );\n}\n\n/**\n * Get the remappings from forge config.\n * @param profile The foundry profile to use\n * @returns Array of remapping strings (e.g., [\"@latticexyz/=node_modules/@latticexyz/\"])\n */\nexport async function getRemappings(profile?: string): Promise<string[]> {\n return (await getForgeConfig(profile)).remappings;\n}\n"],"mappings":";AAAA,SAAS,aAAa;AAuBtB,eAAsB,eAAe,SAAwC;AAC3E,QAAM,EAAE,OAAO,IAAI,MAAM,MAAM,SAAS,CAAC,UAAU,QAAQ,GAAG;AAAA,IAC5D,OAAO,CAAC,WAAW,QAAQ,MAAM;AAAA,IACjC,KAAK,EAAE,iBAAiB,QAAQ;AAAA,EAClC,CAAC;AAED,SAAO,KAAK,MAAM,MAAM;AAC1B;AAMA,eAAsB,gBAAgB,SAAmC;AACvE,UAAQ,MAAM,eAAe,OAAO,GAAG;AACzC;AAMA,eAAsB,mBAAmB,SAAmC;AAC1E,UAAQ,MAAM,eAAe,OAAO,GAAG;AACzC;AAMA,eAAsB,iBAAiB,SAAmC;AACxE,UAAQ,MAAM,eAAe,OAAO,GAAG;AACzC;AAMA,eAAsB,gBAAgB,SAAmC;AACvE,UAAQ,MAAM,eAAe,OAAO,GAAG;AACzC;AAOA,eAAsB,UAAU,SAAmC;AACjE,SACE,QAAQ,IAAI,uBACZ,QAAQ,IAAI,gBACZ,QAAQ,IAAI,YACX,MAAM,eAAe,OAAO,GAAG,eAChC;AAEJ;AAOA,eAAsB,cAAc,SAAqC;AACvE,UAAQ,MAAM,eAAe,OAAO,GAAG;AACzC;","names":[]}
|
package/dist/internal.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Client, Transport, Chain, Account, Hex, Address } from 'viem';
|
|
1
|
+
import { Client, Transport, Chain, Account, Hex, Address, RpcTransactionReceipt, RpcUserOperationReceipt } from 'viem';
|
|
2
2
|
|
|
3
3
|
declare function waitForTransactions({ client, hashes, debugLabel, }: {
|
|
4
4
|
readonly client: Client<Transport, Chain | undefined, Account>;
|
|
@@ -43,4 +43,6 @@ type WiresawOptions<transport extends Transport> = {
|
|
|
43
43
|
};
|
|
44
44
|
declare function wiresaw<const wiresawTransport extends Transport>(transports?: WiresawOptions<wiresawTransport>): wiresawTransport;
|
|
45
45
|
|
|
46
|
-
|
|
46
|
+
declare function getUserOperationReceipt(userOpHash: Hex, receipt: RpcTransactionReceipt): RpcUserOperationReceipt;
|
|
47
|
+
|
|
48
|
+
export { type Contract, ensureContract, ensureContractsDeployed, ensureDeployer, getContractAddress, getDeployer, getUserOperationReceipt, waitForTransactions, wiresaw };
|
package/dist/internal.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@latticexyz/common",
|
|
3
|
-
"version": "2.2.23-
|
|
3
|
+
"version": "2.2.23-cd0fa57c590233c5f099d6e469c46c6b51e2c46d",
|
|
4
4
|
"description": "Common low level logic shared between packages",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -62,18 +62,18 @@
|
|
|
62
62
|
],
|
|
63
63
|
"dependencies": {
|
|
64
64
|
"@solidity-parser/parser": "^0.16.0",
|
|
65
|
-
"abitype": "1.0.
|
|
65
|
+
"abitype": "1.0.9",
|
|
66
66
|
"debug": "^4.3.4",
|
|
67
67
|
"execa": "^9.5.2",
|
|
68
68
|
"p-queue": "^7.4.1",
|
|
69
69
|
"p-retry": "^5.1.2",
|
|
70
70
|
"prettier": "3.2.5",
|
|
71
71
|
"prettier-plugin-solidity": "1.3.1",
|
|
72
|
-
"@latticexyz/schema-type": "2.2.23-
|
|
72
|
+
"@latticexyz/schema-type": "2.2.23-cd0fa57c590233c5f099d6e469c46c6b51e2c46d"
|
|
73
73
|
},
|
|
74
74
|
"devDependencies": {
|
|
75
75
|
"@types/debug": "^4.1.7",
|
|
76
|
-
"viem": "2.
|
|
76
|
+
"viem": "2.35.1"
|
|
77
77
|
},
|
|
78
78
|
"peerDependencies": {
|
|
79
79
|
"@aws-sdk/client-kms": "3.x",
|