Skip to content

Commit

Permalink
Revert change in getContractData
Browse files Browse the repository at this point in the history
  • Loading branch information
vdrg committed Oct 22, 2024
1 parent 067f736 commit d4d4f3a
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 14 deletions.
3 changes: 1 addition & 2 deletions packages/cli/src/commands/verify.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,7 @@ const commandModule: CommandModule<Options, Options> = {
// TODO: replace with `resolveConfig` and support for linked libs
const configSystems = await resolveSystems({ rootDir, config });
const systems = configSystems.map((system) => {
const contractDataPath = path.join(outDir, `${system.name}.sol`, `${system.name}.json`);
const contractData = getContractData(contractDataPath);
const contractData = getContractData(`${system.name}.sol`, system.name, outDir);
return {
name: system.name,
bytecode: contractData.bytecode,
Expand Down
3 changes: 1 addition & 2 deletions packages/cli/src/deploy/findLibraries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,7 @@ export function findLibraries(forgeOutDirs: string | string[]): Library[] {
);

return orderedByDeps.map((library) => {
const contractDataPath = path.join(library.forgeOutDir, path.basename(library.path), `${library.name}.json`);
const contractData = getContractData(contractDataPath);
const contractData = getContractData(path.basename(library.path), library.name, library.forgeOutDir);
return {
path: library.path,
name: library.name,
Expand Down
6 changes: 2 additions & 4 deletions packages/cli/src/deploy/resolveConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,7 @@ export async function resolveConfig({

const libraries = findLibraries([forgeOutDir, ...moduleOutDirs]);

const baseSystemPath = path.join(forgeOutDir, "System.sol", "System.json");
const baseSystemContractData = getContractData(baseSystemPath);
const baseSystemContractData = getContractData("System.sol", "System", forgeOutDir);
const baseSystemFunctions = baseSystemContractData.abi
.filter((item): item is typeof item & { type: "function" } => item.type === "function")
.map(toFunctionSignature);
Expand All @@ -59,8 +58,7 @@ export async function resolveConfig({
);
}

const contractDataPath = path.join(forgeOutDir, `${system.label}.sol`, `${system.label}.json`);
const contractData = getContractData(contractDataPath);
const contractData = getContractData(`${system.label}.sol`, system.label, forgeOutDir);

// TODO: replace this with manifest
const worldFunctions = system.deploy.registerWorldFunctions
Expand Down
13 changes: 7 additions & 6 deletions packages/cli/src/utils/getContractData.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { readFileSync } from "fs";
import path from "path";
import { MUDError } from "@latticexyz/common/errors";
import { Abi, Hex, size } from "viem";
import { LibraryPlaceholder } from "../deploy/common";
Expand All @@ -8,14 +9,14 @@ import { findPlaceholders } from "./findPlaceholders";
* Load the contract's abi and bytecode from the file system
* @param contractName: Name of the contract to load
*/
export function getContractData(contractDataPath: string): {
bytecode: Hex;
placeholders: readonly LibraryPlaceholder[];
abi: Abi;
deployedBytecodeSize: number;
} {
export function getContractData(
filename: string,
contractName: string,
forgeOutDirectory: string,
): { bytecode: Hex; placeholders: readonly LibraryPlaceholder[]; abi: Abi; deployedBytecodeSize: number } {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
let data: any;
const contractDataPath = path.join(forgeOutDirectory, filename, contractName + ".json");
try {
data = JSON.parse(readFileSync(contractDataPath, "utf8"));
} catch (error) {
Expand Down

0 comments on commit d4d4f3a

Please sign in to comment.