Skip to content

Commit

Permalink
Move matechWithCreationTx address comparison after match
Browse files Browse the repository at this point in the history
  • Loading branch information
kuzdogan committed Feb 23, 2023
1 parent ec8806a commit 603a30b
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions packages/lib-sourcify/src/lib/verification.ts
Original file line number Diff line number Diff line change
Expand Up @@ -257,16 +257,6 @@ export async function matchWithCreationTx(
const creatorTx = await getTx(creatorTxHash, sourcifyChain);
const creatorTxData = creatorTx.input;

// Initially we need to check if this contract creation tx actually yields the same contract address https://github.com/ethereum/sourcify/issues/887
const createdContractAddress = getContractAddress({
from: creatorTx.from,
nonce: creatorTx.nonce,
});
if (createdContractAddress.toLowerCase() !== address.toLowerCase()) {
match.message = `The address being verified ${address} doesn't match the address of the contract ${createdContractAddress} that will be created by the transaction ${creatorTxHash}.`;
return;
}

// The reason why this uses `startsWith` instead of `===` is that creationTxData may contain constructor arguments at the end part.
// Replace the library placeholders in the recompiled bytecode with values from the deployed bytecode
const { replaced, libraryMap } = addLibraryAddresses(
Expand Down Expand Up @@ -294,6 +284,16 @@ export async function matchWithCreationTx(
}

if (match.status) {
// we need to check if this contract creation tx actually yields the same contract address https://github.com/ethereum/sourcify/issues/887
const createdContractAddress = getContractAddress({
from: creatorTx.from,
nonce: creatorTx.nonce,
});
if (createdContractAddress.toLowerCase() !== address.toLowerCase()) {
match.status = null;
match.message = `The address being verified ${address} doesn't match the expected ddress of the contract ${createdContractAddress} that will be created by the transaction ${creatorTxHash}.`;
return;
}
match.libraryMap = libraryMap;
const abiEncodedConstructorArguments =
extractAbiEncodedConstructorArguments(
Expand Down

0 comments on commit 603a30b

Please sign in to comment.