diff --git a/tasks/make_spec.ts b/tasks/make_spec.ts index 6e550eb..57f098f 100644 --- a/tasks/make_spec.ts +++ b/tasks/make_spec.ts @@ -1,7 +1,6 @@ import fs from 'fs'; import path from 'path'; import { task } from "hardhat/config"; - import { InitialContractsConfiguration, NetworkConfiguration } from './types'; const ProxyContractName = "TransparentUpgradeableProxy"; @@ -17,6 +16,8 @@ task("make_spec_hbbft", "used to make a spec file") console.log("initial funding address: ", taskArgs.initialFundAddress); console.log("Using initial contracts file: ", taskArgs.initContracts); + let blocscoutVerificationScript = "#!/bin/sh\n"; + const initialContracts = InitialContractsConfiguration.fromFile(taskArgs.initContracts); const networkConfig = NetworkConfiguration.create(taskArgs.initDataFile); @@ -49,7 +50,7 @@ task("make_spec_hbbft", "used to make a spec file") const initializerArgs = initialContracts.getContractInitializerArgs(contractName, networkConfig); await initialContracts.core[i].compileContract(hre); - await initialContracts.core[i].compileProxy( + let initializerDataHex = await initialContracts.core[i].compileProxy( hre, ProxyContractName, initialContracts.core[i].implementationAddress!, // address _logic, @@ -57,6 +58,16 @@ task("make_spec_hbbft", "used to make a spec file") initializerArgs // bytes _data ); + // example: + // npx hardhat verify --network alpha3 0x1000000000000000000000000000000000000000 + let implementationAddress = initialContracts.core[i].implementationAddress + let proxyAddress = initialContracts.core[i].proxyAddress; + blocscoutVerificationScript += `### ${contractName} ###\n`; + blocscoutVerificationScript += `echo "verifying ${contractName} on ${implementationAddress}"\n`; + blocscoutVerificationScript += `npx hardhat verify --network alpha3 ${implementationAddress}\n`; + blocscoutVerificationScript += `echo "verifying proxy for ${contractName} on ${proxyAddress}"\n`; + blocscoutVerificationScript += `npx hardhat verify --network alpha3 ${proxyAddress} ${implementationAddress} ${networkConfig.owner} ${initializerDataHex}\n`; + const contractSpec = initialContracts.core[i].toSpecAccount(taskArgs.useUpgradeProxy, 0); spec.accounts = { @@ -89,7 +100,9 @@ task("make_spec_hbbft", "used to make a spec file") console.log('Saving spec_hbbft.json file ...'); fs.writeFileSync(path.join(__dirname, '..', 'spec_hbbft.json'), JSON.stringify(spec, null, ' '), 'utf-8'); - + let blockscoutVerifyFile = path.join(__dirname, '..', 'blockscout_verify.sh') + console.log("Storing batch file for blockscout verification: ", blockscoutVerifyFile); + fs.writeFileSync(blockscoutVerifyFile, blocscoutVerificationScript, "utf-8"); console.log('Done'); }); diff --git a/tasks/types.ts b/tasks/types.ts index 7c31aab..4a89ca1 100644 --- a/tasks/types.ts +++ b/tasks/types.ts @@ -207,6 +207,7 @@ export class CoreContract { return this.proxyAddress !== ''; } + // returns hex encoded initializer data. async compileProxy( hre: HardhatRuntimeEnvironment, proxyContractName: string, @@ -221,6 +222,8 @@ export class CoreContract { const tx = await proxyFactory.getDeployTransaction(logicAddress, ownerAddress, initializerData); this.proxyBytecode = tx.data; + + return initializerData; } async compileContract(hre: HardhatRuntimeEnvironment) {