-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
fcbde2b
commit 51a4471
Showing
10 changed files
with
107 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,15 @@ | ||
// SPDX-FileCopyrightText: 2024 IEXEC BLOCKCHAIN TECH <[email protected]> | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
const deploymentConfig = require('./deployment.json') as DeploymentConfig; | ||
export default deploymentConfig; | ||
import deploymentConfigRaw from './deployment.json'; | ||
|
||
export type DeploymentConfig = { | ||
[chainId: string]: { | ||
factory: boolean; | ||
salt: string; | ||
pocoAddress: string; | ||
voucherHubAddress?: string; //some chains used doesn't have the voucher deployed | ||
}; | ||
}; | ||
|
||
export default deploymentConfigRaw as DeploymentConfig; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,12 @@ | ||
// SPDX-FileCopyrightText: 2024 IEXEC BLOCKCHAIN TECH <[email protected]> | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
import * as helpers from '@nomicfoundation/hardhat-network-helpers'; | ||
import { ContractFactory } from 'ethers'; | ||
import { deployments, ethers, upgrades } from 'hardhat'; | ||
import { HardhatRuntimeEnvironment } from 'hardhat/types'; | ||
import deploymentConfig from '../config/deployment'; | ||
import { env } from '../config/env'; | ||
import { mineBlockIfOnLocalFork } from '../scripts/utils/mineBlockIfOnLocalFork'; | ||
import * as voucherHubUtils from '../scripts/voucherHubUtils'; | ||
import * as voucherUtils from '../scripts/voucherUtils'; | ||
import { | ||
|
@@ -19,14 +19,7 @@ import { | |
} from '../typechain-types'; | ||
|
||
export default async function (hre: HardhatRuntimeEnvironment) { | ||
if (env.IS_LOCAL_FORK) { | ||
/** | ||
* This fixes following issue when deploying to a local Bellecour fork: | ||
* `ProviderError: No known hardfork for execution on historical block [...] in chain with id 134.` | ||
* See: https://github.com/NomicFoundation/hardhat/issues/5511#issuecomment-2288072104 | ||
*/ | ||
await helpers.mine(); | ||
} | ||
mineBlockIfOnLocalFork(); | ||
const { deployer, manager, minter } = await hre.getNamedAccounts(); | ||
await deployAll(deployer, manager, minter); | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import { ethers, upgrades } from 'hardhat'; | ||
import { env } from '../config/env'; | ||
import { getDeploymentConfig } from '../deploy/deploy'; | ||
import { mineBlockIfOnLocalFork } from './utils/mineBlockIfOnLocalFork'; | ||
import { upgradeProxy } from './voucherHubUtils'; | ||
|
||
async function upgradeVoucherHub() { | ||
console.log(`Upgrading VoucherHub contract ...`); | ||
mineBlockIfOnLocalFork(); | ||
|
||
const chainId = (await ethers.provider.getNetwork()).chainId.toString(); | ||
console.log('ChainId:', chainId); | ||
|
||
const config = await getDeploymentConfig(Number(chainId)); | ||
const voucherHubProxyAddress = config.voucherHubAddress || env.IEXEC_VOUCHER_HUB_ADDRESS; | ||
if (!voucherHubProxyAddress) { | ||
throw new Error(`No VoucherHub deployed on the target chain ${chainId}`); | ||
} | ||
console.log( | ||
'Current implementation address:', | ||
await upgrades.erc1967.getImplementationAddress(voucherHubProxyAddress), | ||
); | ||
|
||
const voucherHubFactoryUpgrade = await ethers.getContractFactory('VoucherHub'); | ||
await upgradeProxy(voucherHubProxyAddress, voucherHubFactoryUpgrade); | ||
|
||
// Fetch new implementation address | ||
const implementationAddress = | ||
await upgrades.erc1967.getImplementationAddress(voucherHubProxyAddress); | ||
console.log( | ||
`VoucherHub upgraded successfully ✅! New implementation address (VoucherHub.sol): ${implementationAddress}`, | ||
); | ||
} | ||
|
||
upgradeVoucherHub().catch((error) => { | ||
console.error(error); | ||
process.exitCode = 1; | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import * as helpers from '@nomicfoundation/hardhat-network-helpers'; | ||
import { env } from '../../config/env'; | ||
|
||
/** | ||
* This function is used to force mining if we are one a local fork | ||
*/ | ||
export async function mineBlockIfOnLocalFork() { | ||
if (env.IS_LOCAL_FORK) { | ||
/** | ||
* This fixes following issue when deploying to a local Bellecour fork: | ||
* `ProviderError: No known hardfork for execution on historical block [...] in chain with id 134.` | ||
* See: https://github.com/NomicFoundation/hardhat/issues/5511#issuecomment-2288072104 | ||
*/ | ||
await helpers.mine(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters