Skip to content

Commit

Permalink
Fx code & add tx hash to json out
Browse files Browse the repository at this point in the history
  • Loading branch information
elshan-eth committed Dec 6, 2024
1 parent da4283e commit df9d6ac
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 18 deletions.
6 changes: 5 additions & 1 deletion deployment-txs/mainnet.json
Original file line number Diff line number Diff line change
Expand Up @@ -173,5 +173,9 @@
"0x201efd508c8DfE9DE1a13c2452863A78CB2a86Cc": "0x1e14baaeb10fc3a6b689e77ec34e8c5e8e21853f6e23257459dd99c35b6ff06b",
"0x527d0E14acc53FB040DeBeae1cAb973D23FB3568": "0x44d82009c125f39bd2bbd1f723e7284e4226d5d752a66b18536e5d92c37b0c82",
"0xB9d01CA61b9C181dA1051bFDd28e1097e920AB14": "0x2794463090a850910415b88df0f756e01e0838c8782e83a89389992c17469513",
"0x89Ef89Fd9a6ec73bcE588F309C1F65C406d2891C": "0xb85dd153e2e12599487632277c99375af44402e6c6053d47fa622a7a02d71691"
"0x89Ef89Fd9a6ec73bcE588F309C1F65C406d2891C": "0xb85dd153e2e12599487632277c99375af44402e6c6053d47fa622a7a02d71691",
"0xbA1333333333a1BA1108E8412f11850A5C319bA9": "0x49a4986a672bcc20eecf99a3603f0099b19ab663eebe5dd5fe04808c380147b4",
"0x0E8B07657D719B86e06bF0806D6729e3D528C9A9": "0x49a4986a672bcc20eecf99a3603f0099b19ab663eebe5dd5fe04808c380147b4",
"0x35fFB749B273bEb20F40f35EdeB805012C539864": "0x49a4986a672bcc20eecf99a3603f0099b19ab663eebe5dd5fe04808c380147b4",
"0xa731C23D7c95436Baaae9D52782f966E1ed07cc8": "0x49a4986a672bcc20eecf99a3603f0099b19ab663eebe5dd5fe04808c380147b4"
}
6 changes: 5 additions & 1 deletion deployment-txs/sepolia.json
Original file line number Diff line number Diff line change
Expand Up @@ -86,5 +86,9 @@
"0x7532d5a3bE916e4a4D900240F49F0BABd4FD855C": "0xe42c9cdc05ab3de2b8698ed32e56dce0f85c1017099aa965784d8023fb29d012",
"0xFc253B433B7225AC7736EAbDF4115F7252aECb91": "0x45579023de61bae57ba62a72a50783509afa7c47f466150b3d5f134d220624b6",
"0xd67F485C07D258B3e93835a3799d862ffcB55923": "0x48d803b01baf630543481ca6eefca5dc269d8670cf44afd08dcba3792a48710f",
"0x7373C5b9610d43466395617c428eCAA5b47ac5AA": "0x00dcc321792c060560757aea332ba6247d84c0365f535105229ea75b8d9d3f9d"
"0x7373C5b9610d43466395617c428eCAA5b47ac5AA": "0x00dcc321792c060560757aea332ba6247d84c0365f535105229ea75b8d9d3f9d",
"0xbA1333333333a1BA1108E8412f11850A5C319bA9": "0xe9ab355e0f5987453c48b3fe64f7c63ae4ba6dc5a85d1e43fb3a066dffe16a81",
"0x0E8B07657D719B86e06bF0806D6729e3D528C9A9": "0xe9ab355e0f5987453c48b3fe64f7c63ae4ba6dc5a85d1e43fb3a066dffe16a81",
"0x35fFB749B273bEb20F40f35EdeB805012C539864": "0xe9ab355e0f5987453c48b3fe64f7c63ae4ba6dc5a85d1e43fb3a066dffe16a81",
"0xa731C23D7c95436Baaae9D52782f966E1ed07cc8": "0xe9ab355e0f5987453c48b3fe64f7c63ae4ba6dc5a85d1e43fb3a066dffe16a81"
}
24 changes: 8 additions & 16 deletions src/task.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import { Contract, ethers } from 'ethers';
import { hexToBytes, Address } from '@ethereumjs/util';
import { Chain, Common, Hardfork } from '@ethereumjs/common';
import { EVM } from '@ethereumjs/evm';
import { DefaultStateManager } from '@ethereumjs/statemanager';
import { getContractAddress } from '@ethersproject/address';
import { SignerWithAddress } from '@nomiclabs/hardhat-ethers/signers';

Expand All @@ -29,8 +28,6 @@ import { getContractDeploymentTransactionHash, saveContractDeploymentTransaction
import { getTaskActionIds } from './actionId';
import { getArtifactFromContractOutput } from './artifact';
import { getSigner } from './signers';
import { Block } from '@ethereumjs/evm/dist/cjs/types';
import { zeroAddress } from 'ethereumjs-util';

// Maps to ../v2 and ../v3.
const VERSION_ROOTS = ['v2', 'v3'].map((version) => path.resolve(__dirname, `../${version}`));
Expand Down Expand Up @@ -155,7 +152,6 @@ export default class Task {
logger.success(`Deploy contracts using factory...`);

from = from || (await getSigner());

const receipt = await from?.sendTransaction(populatedDeployTransaction);

return await receipt.wait();
Expand All @@ -169,16 +165,14 @@ export default class Task {
const { ethers } = await import('hardhat');

if (deployTransaction == null) {
// All contracts are deployed by the one factory transaction, so we can find the transaction hash by the first element
const deployedAddress = this.output()[contractsInfo[0].name];
const deploymentTxHash = getContractDeploymentTransactionHash(deployedAddress, this.network);
deployTransaction = await ethers.provider.getTransactionReceipt(deploymentTxHash);
}

const evm = await this.createEVM();

for (const contractInfo of contractsInfo) {
const instance = await this.instanceAt(contractInfo.name, contractInfo.expectedAddress);

const isDeployedBytecodeValid = await this.checkBytecodeAndSaveEVMState(
evm,
deployTransaction,
Expand All @@ -187,16 +181,21 @@ export default class Task {
contractInfo.args
);

if (isDeployedBytecodeValid && this.mode === TaskMode.CHECK) {
logger.success(`Verified contract '${contractInfo.name}' on network '${this.network}' of task '${this.id}'`);
}

if (isDeployedBytecodeValid == false) {
throw Error(
`Contract ${contractInfo.name} at ${contractInfo.expectedAddress} does not match expected bytecode.`
`Contract ${contractInfo.name} at ${contractInfo.expectedAddress} does not match expected bytecode with abi.`
);
}

if (this.mode === TaskMode.CHECK) {
continue;
}

const instance = await this.instanceAt(contractInfo.name, contractInfo.expectedAddress);
this.save({ [contractInfo.name]: instance });
logger.success(`Contract ${contractInfo.name} attached at ${contractInfo.expectedAddress}`);

Expand All @@ -207,15 +206,8 @@ export default class Task {
this.network
);
}
}

if (this.mode === TaskMode.CHECK) {
return;
}

for (const contractInfo of contractsInfo) {
const { name, expectedAddress, args } = contractInfo;
await this.verify(name, expectedAddress, args);
await this.verify(contractInfo.name, contractInfo.expectedAddress, contractInfo.args);
}
}

Expand Down

0 comments on commit df9d6ac

Please sign in to comment.