Skip to content

Commit

Permalink
update verify
Browse files Browse the repository at this point in the history
  • Loading branch information
holic committed May 8, 2024
1 parent e831937 commit fb733f1
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 66 deletions.
14 changes: 2 additions & 12 deletions packages/cli/src/commands/verify.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ import { worldToV1 } from "@latticexyz/world/config/v2";
import { getOutDirectory, getRpcUrl, getSrcDirectory } from "@latticexyz/common/foundry";
import { getExistingContracts } from "../utils/getExistingContracts";
import { getContractData } from "../utils/getContractData";
import { defaultModuleContracts } from "../utils/defaultModuleContracts";
import { Hex, createWalletClient, http } from "viem";
import chalk from "chalk";
import { configToModules } from "../deploy/configToModules";

const verifyOptions = {
deployerAddress: {
Expand Down Expand Up @@ -82,17 +82,7 @@ const commandModule: CommandModule<Options, Options> = {
};
});

// Get modules
const modules = config.modules.map((mod) => {
const contractData =
defaultModuleContracts.find((defaultMod) => defaultMod.name === mod.name) ??
getContractData(`${mod.name}.sol`, mod.name, outDir);

return {
name: mod.name,
bytecode: contractData.bytecode,
};
});
const modules = await configToModules(configV2, outDir);

await verify({
client,
Expand Down
1 change: 0 additions & 1 deletion packages/cli/src/deploy/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,6 @@ export type Module = DeterministicContract & {
readonly name: string;
readonly installAsRoot: boolean;
readonly installData: Hex; // TODO: figure out better naming for this
readonly abi: Abi;
};

export type ConfigInput = StoreConfig & WorldConfig;
Expand Down
3 changes: 2 additions & 1 deletion packages/cli/src/deploy/configToModules.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export async function configToModules<config extends World>(
config: config,
forgeOutDir: string,
): Promise<readonly Module[]> {
// TODO: this now expects namespaced tables when used with `resolveTableId`, ideally we replace args with something more strongly typed
// this expects a namespaced table name when used with `resolveTableId`
const resolveContext = {
tableIds: Object.fromEntries(
Object.entries(config.tables).map(([tableName, table]) => [tableName, hexToBytes(table.tableId)]),
Expand Down Expand Up @@ -54,6 +54,7 @@ export async function configToModules<config extends World>(
const name = path.basename(artifactPath, ".json");
const artifact = await getContractArtifact({ artifactPath });

// TODO: replace args with something more strongly typed
const installArgs = mod.args
.map((arg) => resolveWithContext(arg, resolveContext))
.map((arg) => {
Expand Down
39 changes: 0 additions & 39 deletions packages/cli/src/utils/defaultModuleContracts.ts

This file was deleted.

24 changes: 11 additions & 13 deletions packages/cli/src/verify.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import PQueue from "p-queue";
import { getWorldProxyFactoryContracts } from "./deploy/getWorldProxyFactoryContracts";
import { getDeployer } from "./deploy/getDeployer";
import { MUDError } from "@latticexyz/common/errors";
import { salt } from "./deploy/common";
import { Module, salt } from "./deploy/common";
import { getStorageAt } from "viem/actions";
import { execa } from "execa";

Expand All @@ -15,7 +15,7 @@ type VerifyOptions = {
verifier: string;
verifierUrl?: string;
systems: { name: string; bytecode: Hex }[];
modules: { name: string; bytecode: Hex }[];
modules: readonly Module[];
worldAddress: Hex;
/**
* Address of determinstic deployment proxy: https://github.com/Arachnid/deterministic-deployment-proxy
Expand All @@ -39,7 +39,7 @@ export async function verify({
}: VerifyOptions): Promise<void> {
const deployerAddress = initialDeployerAddress ?? (await getDeployer(client));
if (!deployerAddress) {
throw new MUDError(`No deployer`);
throw new MUDError("No deployer address provided or found.");
}

// If the proxy implementation storage slot is set on the World, the World was deployed as a proxy.
Expand Down Expand Up @@ -104,24 +104,22 @@ export async function verify({
),
);

modules.map(({ name, bytecode }) =>
verifyQueue.add(() =>
modules.map(({ name, prepareDeploy }) => {
const { address } = prepareDeploy(deployerAddress, []);
return verifyQueue.add(() =>
verifyContract({
// TODO: figure out dir from artifactPath via import.meta.resolve?
cwd: "node_modules/@latticexyz/world-modules",
name: name,
name,
rpc,
verifier,
verifierUrl,
address: getCreate2Address({
from: deployerAddress,
bytecode: bytecode,
salt,
}),
address,
}).catch((error) => {
console.error(`Error verifying module contract ${name}:`, error);
}),
),
);
);
});

// If the world was deployed as a Proxy, verify the proxy and implementation.
if (usesProxy) {
Expand Down

0 comments on commit fb733f1

Please sign in to comment.