Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(cli): fix verify with sourcify for dependencies #2750

Merged
merged 12 commits into from
Apr 27, 2024
189 changes: 105 additions & 84 deletions packages/cli/src/verify.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { getDeployer } from "./deploy/getDeployer";
import { MUDError } from "@latticexyz/common/errors";
import { salt } from "./deploy/common";
import { getStorageAt } from "viem/actions";
import { execa } from "execa";

type VerifyOptions = {
client: Client<Transport, Chain | undefined>;
Expand Down Expand Up @@ -73,94 +74,114 @@ export async function verify({
),
);

Object.entries(
usesProxy ? getWorldProxyFactoryContracts(deployerAddress) : getWorldFactoryContracts(deployerAddress),
).map(([name, { bytecode }]) =>
verifyQueue.add(() =>
verifyContract(
{
name,
rpc,
verifier,
verifierUrl,
address: getCreate2Address({
from: deployerAddress,
bytecode: bytecode,
salt,
}),
},
{
profile: foundryProfile,
cwd: "node_modules/@latticexyz/world",
},
).catch((error) => {
console.error(`Error verifying world factory contract ${name}:`, error);
}),
),
);
{
const cwd = "node_modules/@latticexyz/world";

modules.map(({ name, bytecode }) =>
verifyQueue.add(() =>
verifyContract(
{
name: name,
rpc,
verifier,
verifierUrl,
address: getCreate2Address({
from: deployerAddress,
bytecode: bytecode,
salt,
}),
},
{
profile: foundryProfile,
cwd: "node_modules/@latticexyz/world-modules",
},
).catch((error) => {
console.error(`Error verifying module contract ${name}:`, error);
}),
),
);
await execa("npm", ["install"], {
cwd,
});
yonadaa marked this conversation as resolved.
Show resolved Hide resolved

// If the world was deployed as a Proxy, verify the proxy and implementation.
if (usesProxy) {
const implementationAddress = sliceHex(implementationStorage, -20);

verifyQueue.add(() =>
verifyContract(
{ name: "WorldProxy", rpc, verifier, verifierUrl, address: worldAddress },
{
profile: foundryProfile,
cwd: "node_modules/@latticexyz/world",
},
).catch((error) => {
console.error(`Error verifying WorldProxy contract:`, error);
}),
Object.entries(
usesProxy ? getWorldProxyFactoryContracts(deployerAddress) : getWorldFactoryContracts(deployerAddress),
).map(([name, { bytecode }]) =>
verifyQueue.add(() =>
verifyContract(
{
name,
rpc,
verifier,
verifierUrl,
address: getCreate2Address({
from: deployerAddress,
bytecode: bytecode,
salt,
}),
},
{
profile: foundryProfile,
cwd,
},
holic marked this conversation as resolved.
Show resolved Hide resolved
).catch((error) => {
console.error(`Error verifying world factory contract ${name}:`, error);
}),
),
);
}

verifyQueue.add(() =>
verifyContract(
{ name: "World", rpc, verifier, verifierUrl, address: implementationAddress },
{
profile: foundryProfile,
cwd: "node_modules/@latticexyz/world",
},
).catch((error) => {
console.error(`Error verifying World contract:`, error);
}),
);
} else {
verifyQueue.add(() =>
verifyContract(
{ name: "World", rpc, verifier, verifierUrl, address: worldAddress },
{
profile: foundryProfile,
cwd: "node_modules/@latticexyz/world",
},
).catch((error) => {
console.error(`Error verifying World contract:`, error);
}),
{
const cwd = "node_modules/@latticexyz/world-modules";

await execa("npm", ["install"], {
cwd,
});

modules.map(({ name, bytecode }) =>
verifyQueue.add(() =>
verifyContract(
{
name: name,
rpc,
verifier,
verifierUrl,
address: getCreate2Address({
from: deployerAddress,
bytecode: bytecode,
salt,
}),
},
{
profile: foundryProfile,
cwd,
},
).catch((error) => {
console.error(`Error verifying module contract ${name}:`, error);
}),
),
);
}

{
const cwd = "node_modules/@latticexyz/world";

// If the world was deployed as a Proxy, verify the proxy and implementation.
if (usesProxy) {
const implementationAddress = sliceHex(implementationStorage, -20);

verifyQueue.add(() =>
verifyContract(
{ name: "WorldProxy", rpc, verifier, verifierUrl, address: worldAddress },
{
profile: foundryProfile,
cwd,
},
).catch((error) => {
console.error(`Error verifying WorldProxy contract:`, error);
}),
);

verifyQueue.add(() =>
verifyContract(
{ name: "World", rpc, verifier, verifierUrl, address: implementationAddress },
{
profile: foundryProfile,
cwd,
},
).catch((error) => {
console.error(`Error verifying World contract:`, error);
}),
);
} else {
verifyQueue.add(() =>
verifyContract(
{ name: "World", rpc, verifier, verifierUrl, address: worldAddress },
{
profile: foundryProfile,
cwd: "node_modules/@latticexyz/world",
},
).catch((error) => {
console.error(`Error verifying World contract:`, error);
}),
);
}
}
}
8 changes: 7 additions & 1 deletion packages/schema-type/.npmignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,10 @@
!dist/**
!src/**
!package.json
!README.md
!README.md

!out/**/*.json
!out/**/*.abi.json
!out/**/*.abi.json.d.ts
!cache/solidity-files-cache.json
!foundry.toml
2 changes: 2 additions & 0 deletions packages/store/.npmignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
!out/**/*.json
!out/**/*.abi.json
!out/**/*.abi.json.d.ts
!cache/solidity-files-cache.json
!foundry.toml
!src/**
!ts/**
!mud.config.ts
Expand Down
2 changes: 2 additions & 0 deletions packages/world-modules/.npmignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
!out/**/*.json
!out/**/*.abi.json
!out/**/*.abi.json.d.ts
!cache/solidity-files-cache.json
!foundry.toml
!src/**
!ts/**
!package.json
Expand Down
2 changes: 2 additions & 0 deletions packages/world/.npmignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
!out/**/*.json
!out/**/*.abi.json
!out/**/*.abi.json.d.ts
!cache/solidity-files-cache.json
!foundry.toml
!src/**
!test/MudTest.t.sol
!ts/**
Expand Down
Loading