feat: added the permission manager deployment script

This commit is contained in:
The3D 2021-05-17 21:36:52 +02:00
parent e735d31a34
commit 026d16f44e
2 changed files with 45 additions and 1 deletions

View File

@ -0,0 +1,45 @@
import { task } from 'hardhat/config';
import { PermissionManagerFactory } from '../../types';
import { verifyContract } from '../../helpers/contracts-helpers';
import { eContractid } from '../../helpers/types';
import { insertContractAddressInDb } from '../../helpers/contracts-helpers';
import { getLendingPoolAddressesProvider } from '../../helpers/contracts-getters';
import { waitForTx } from '../../helpers/misc-utils';
import { ethers } from 'ethers';
task(`deploy-permission-manager`, `Deploys the PermissionManager contract`)
.addFlag('verify', 'Verify PermissionManager contract via Etherscan API.')
.setAction(async ({ verify }, localBRE) => {
await localBRE.run('set-DRE');
if (!localBRE.network.config.chainId) {
throw new Error('INVALID_CHAIN_ID');
}
console.log(`\n- PermissionManager deployment`);
console.log(`\tDeploying PermissionManager implementation ...`);
const permissionManagerInstance = await new PermissionManagerFactory(
await localBRE.ethers.provider.getSigner()
).deploy();
await permissionManagerInstance.deployTransaction.wait();
console.log('Permission manager address', permissionManagerInstance.address);
await verifyContract(eContractid.PermissionManager, permissionManagerInstance, []);
// register the permission manager in the addresses provider
const addressesProvider = await getLendingPoolAddressesProvider();
const permissionManagerHash = ethers.utils.keccak256(ethers.utils.toUtf8Bytes("PERMISSION_MANAGER"));
await waitForTx(await addressesProvider.setAddress(permissionManagerHash, permissionManagerInstance.address));
// store the permission manager contract in the DB
await insertContractAddressInDb(
eContractid.PermissionManager,
permissionManagerInstance.address
);
console.log(`\tFinished PermissionManager implementation deployment`);
});

View File

@ -19,7 +19,6 @@ import { loadPoolConfig, ConfigNames } from '../../helpers/configuration';
task('full:deploy-lending-pool', 'Deploy lending pool for dev enviroment')
.addFlag('verify', 'Verify contracts at Etherscan')
.addParam('pool', `Pool name to retrieve configuration, supported: ${Object.values(ConfigNames)}`)
.addParam('lendingPoolImpl')
.setAction(async ({ verify, pool }, DRE: HardhatRuntimeEnvironment) => {
try {
await DRE.run('set-DRE');