Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use hardhat deploy #15

Merged
merged 20 commits into from
Apr 29, 2024
Merged
Show file tree
Hide file tree
Changes from 19 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,6 @@ node_modules
# solidity-coverage files
/coverage
/coverage.json

/deployments/hardhat
/deployments/localhost
zguesmi marked this conversation as resolved.
Show resolved Hide resolved
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Changelog

## vNEXT
- Use hardhat deploy. (#15)
- Upload coverage reports to Codecov. (#14)
- Clean some TODOs. (#13)
- Match orders through voucher. (#12)
Expand Down
54 changes: 54 additions & 0 deletions deploy/deploy.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
// SPDX-FileCopyrightText: 2024 IEXEC BLOCKCHAIN TECH <[email protected]>
// SPDX-License-Identifier: Apache-2.0

import { deployments, ethers } from 'hardhat';
import * as voucherHubUtils from '../scripts/voucherHubUtils';
import * as voucherUtils from '../scripts/voucherUtils';
import { UpgradeableBeacon } from '../typechain-types';

export default async function () {
// const {deployments} = hre;
// const {deploy} = deployments;
zguesmi marked this conversation as resolved.
Show resolved Hide resolved
const iexecPoco = '0x123456789a123456789b123456789b123456789d'; // TODO: Change it
const [admin, assetEligibilityManager, voucherManager] = await ethers.getSigners();
await deployAll(
admin.address,
assetEligibilityManager.address,
voucherManager.address,
iexecPoco,
);
}

async function deployAll(
beaconOwner: string,
assetEligibilityManager: string,
voucherManager: string,
iexecPoco: string,
): Promise<string> {
// Deploy Voucher beacon and implementation.
const beacon: UpgradeableBeacon = await voucherUtils.deployBeaconAndImplementation(beaconOwner);
const beaconAddress = await beacon.getAddress();
console.log(`UpgradeableBeacon: ${beaconAddress}`);
console.log(`Voucher implementation: ${await beacon.implementation()}`);
// Deploy VoucherHub.
const voucherHub = await voucherHubUtils.deployHub(
assetEligibilityManager,
voucherManager,
iexecPoco,
beaconAddress,
);
const voucherHubAddress = await voucherHub.getAddress();
console.log(`VoucherHub: ${voucherHubAddress}`);
// Check
if ((await voucherHub.getVoucherBeacon()) !== beaconAddress) {
throw new Error('Deployment error');
}
// Save VoucherHub in deployments folder because
// hardhat-deploy#deploy() is not used.
await deployments.save('VoucherHub', {
// TODO save abi.
abi: [],
address: voucherHubAddress,
});
return voucherHubAddress;
}
1 change: 1 addition & 0 deletions hardhat.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import '@nomicfoundation/hardhat-toolbox';
import '@openzeppelin/hardhat-upgrades';
import 'hardhat-dependency-compiler';
import 'hardhat-deploy';
import { HardhatUserConfig } from 'hardhat/config';
import {
HARDHAT_NETWORK_MNEMONIC,
Expand Down
Loading