Skip to content

Commit

Permalink
Verify contracts
Browse files Browse the repository at this point in the history
  • Loading branch information
jeremyjams committed Sep 23, 2024
1 parent 3e26775 commit d6e97de
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 19 deletions.
45 changes: 26 additions & 19 deletions deploy/deploy.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// SPDX-FileCopyrightText: 2024 IEXEC BLOCKCHAIN TECH <[email protected]>
// SPDX-License-Identifier: Apache-2.0

import { ContractFactory } from 'ethers';
import { deployments, ethers, upgrades } from 'hardhat';
import { HardhatRuntimeEnvironment } from 'hardhat/types';
import deploymentConfig from '../config/deployment';
Expand Down Expand Up @@ -63,34 +64,34 @@ async function deployAllWithFactory(
const genericFactory = GenericFactory_shanghai__factory.connect(factoryAddress, adminSigner);
console.log(`Factory: ${factoryAddress}`);
console.log(`Salt: ${salt}`);
const voucherImplAddress = await deployWithFactory('VoucherImpl', Voucher__factory.bytecode);
const voucherImplAddress = await deployWithFactory('VoucherImpl', new Voucher__factory(), []);
const voucherUpgradableBeaconAddress = await deployWithFactory(
'VoucherUpgradeableBeacon',
await new UpgradeableBeacon__factory()
.getDeployTransaction(voucherImplAddress, admin)
.then((tx) => tx.data),
new UpgradeableBeacon__factory(),
[voucherImplAddress, admin],
);

// Proxy needs to be registered in case an upgrade is performed later
await upgrades.forceImport(voucherUpgradableBeaconAddress, new Voucher__factory());
// Deploy VoucherHub implementation and proxy
const voucherHubImplAddress = await deployWithFactory(
'VoucherHubImpl',
VoucherHub__factory.bytecode,
new VoucherHub__factory(),
[],
);
const voucherHubERC1967ProxyAddress = await deployWithFactory(
'VoucherHubERC1967Proxy',
await new ERC1967Proxy__factory()
.getDeployTransaction(
voucherHubImplAddress,
VoucherHub__factory.createInterface().encodeFunctionData('initialize', [
admin,
manager,
minter,
iexecPoco,
voucherUpgradableBeaconAddress,
]),
)
.then((tx) => tx.data),
new ERC1967Proxy__factory(),
[
voucherHubImplAddress,
VoucherHub__factory.createInterface().encodeFunctionData('initialize', [
admin,
manager,
minter,
iexecPoco,
voucherUpgradableBeaconAddress,
]),
],
);
await upgrades.forceImport(voucherHubERC1967ProxyAddress, new VoucherHub__factory());
return {
Expand All @@ -104,7 +105,12 @@ async function deployAllWithFactory(
* @param bytecode Contract bytecode
* @returns instance address
*/
async function deployWithFactory(name: string, bytecode: string) {
async function deployWithFactory(
name: string,
contractFactory: ContractFactory,
constructorArgs: any[],
) {
let bytecode = (await contractFactory.getDeployTransaction(...constructorArgs)).data;
const contractAddress = await genericFactory.predictAddress(bytecode, salt);
let justDeployed = false;
if ((await ethers.provider.getCode(contractAddress)) == '0x') {
Expand All @@ -113,8 +119,9 @@ async function deployAllWithFactory(
}
console.log(`${name}: ${contractAddress} ${justDeployed ? '' : '(previously deployed)'}`);
await deployments.save(name, {
abi: [],
abi: (contractFactory as any).constructor.abi,
address: contractAddress,
args: constructorArgs,
});
return contractAddress;
}
Expand Down
17 changes: 17 additions & 0 deletions hardhat.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,23 @@ const config: HardhatUserConfig = {
},
gasPrice: 0, // Get closer to Bellecour network
},
bellecour: {
chainId: 134,
url: 'https://bellecour.iex.ec',
accounts: {
mnemonic: process.env.PROD_MNEMONIC || '',
},
gasPrice: 0,
gas: 6700000,
// npx hardhat --network bellecour etherscan-verify
// See: https://github.com/wighawag/hardhat-deploy?tab=readme-ov-file#4-hardhat-etherscan-verify
verify: {
etherscan: {
apiUrl: 'https://blockscout.bellecour.iex.ec/api',
apiKey: 'https://blockscout.bellecour.iex.ec/',
},
},
},
},
namedAccounts: {
deployer: {
Expand Down

0 comments on commit d6e97de

Please sign in to comment.