Skip to content

Commit

Permalink
debug: using local signer
Browse files Browse the repository at this point in the history
  • Loading branch information
viraj124 committed Sep 25, 2024
1 parent e72e984 commit 70c66f9
Showing 1 changed file with 76 additions and 8 deletions.
84 changes: 76 additions & 8 deletions packages/solidity-contracts/scripts/hardhat/verifyDeployment.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
import { task } from 'hardhat/config';
import { HardhatRuntimeEnvironment } from 'hardhat/types';
import { config as dotEnvConfig } from 'dotenv';

dotEnvConfig();

task('verify-deployment', 'Verifies the deployed contract bytecode').setAction(
async (taskArgs: any, hre: HardhatRuntimeEnvironment): Promise<void> => {
Expand Down Expand Up @@ -27,10 +30,36 @@ task('verify-deployment', 'Verifies the deployed contract bytecode').setAction(
const localHardhat = require('hardhat');
await localHardhat.run('compile');

// localHardhat.artifacts.readArtifact(deployment.linkedData.factory)


// localHardhat.


const rpcUrl = 'https://rpc.tenderly.co/fork/3fe27079-c302-4397-a43e-602cc4887dca'; // Replace with your custom RPC URL
localHardhat.ethers.provider = new localHardhat.ethers.JsonRpcProvider(rpcUrl);

// const accounts = await hre.ethers.getSigners()
// const wallet = localHardhat.ethers.Wallet.fromPhrase('test test test test test test test test test test test junk');
// console.log(await wallet.getBalance())
// Create a provider and signer
// const provider = new localHardhat.ethers.JsonRpcProvider(rpcUrl);


let [signer] = await localHardhat.ethers.getSigners();

// if (process.env.CONTRACTS_DEPLOYER_KEY) signer = new localHardhat.ethers.Wallet(wallet.privateKey, provider);

// const balance = await signer.getBalance();
// console.log(await (await localHardhat.ethers.provider.getBalance(wallet.address).toString()));


const ContractFactory = await localHardhat.ethers.getContractFactory(
deployment.linkedData.factory
deployment.linkedData.factory, signer
);



if (!deployment.linkedData.isProxy) {
console.log('--- Validating Upgrade...');
await localHardhat.upgrades.validateUpgrade(
Expand All @@ -47,20 +76,59 @@ task('verify-deployment', 'Verifies the deployed contract bytecode').setAction(

console.log('--- Fetching local deployment bytecode...');
let localBytecode: string;
if (!deployment.linkedData.isProxy) {
localBytecode = await (
await hre.artifacts.readArtifact(deployment.linkedData.factory)
).deployedBytecode;
} else continue;
let localAddress;
// if (!deployment.linkedData.isProxy) {

const proxyfactory = await localHardhat.ethers.getContractFactory(
contractName, signer
);
const proxy = await localHardhat.upgrades.deployProxy(proxyfactory, [], {
initializer: 'initialize',
constructorArgs: deployment.linkedData.constructorArgs,
});

await proxy.waitForDeployment();


const contract = await localHardhat.upgrades.upgradeProxy(
deployment.address,
ContractFactory,
{
kind: 'uups',
constructorArgs: deployment.linkedData.constructorArgs,
}
);

console.log('--- Upgrade successful');
await contract.waitForDeployment();
localAddress = await contract.getAddress();

localBytecode = await hre.ethers.provider.getCode(
localAddress
);


// new hre.ethers.JsonRpcSigner()
// // const factory = hre.ethers.getContractFactory
// // localBytecode =
// // ContractFactory.bytecode
// // localBytecode = await (
// // await hre.artifacts.readArtifact(deployment.linkedData.factory)
// // ).deployedBytecode;
// await hre.tenderlyNetwork.setFork("https://dashboard.tenderly.co/Viraz/vir/fork/3fe27079-c302-4397-a43e-602cc4887dca");
// await hre.tenderlyNetwork.initializeFork()


// } else continue;

console.log('--- Comparing bytecodes...');
console.log(
'--- Deployed bytecode: ',
hre.ethers.keccak256(deployedBytecode)
deployedBytecode
);
console.log(
'--- Local bytecode: ',
hre.ethers.keccak256(localBytecode)
localBytecode
);

if (
Expand Down

0 comments on commit 70c66f9

Please sign in to comment.