From b7462c6be27d24c9dccdb3ac3adb2fcb542ffbdf Mon Sep 17 00:00:00 2001 From: David Racero Date: Wed, 12 May 2021 10:15:41 +0200 Subject: [PATCH] feat: update UiPoolDataProvider task to match other tasks code style. Fix old reference of verifyContract at deployUiPoolDataProvider function. --- helpers/contracts-deployments.ts | 4 +- .../deployments/deploy-UiPoolDataProvider.ts | 37 ++++++++++++------- 2 files changed, 25 insertions(+), 16 deletions(-) diff --git a/helpers/contracts-deployments.ts b/helpers/contracts-deployments.ts index 68024d2a..6ae58383 100644 --- a/helpers/contracts-deployments.ts +++ b/helpers/contracts-deployments.ts @@ -56,6 +56,7 @@ import { linkBytecode, insertContractAddressInDb, deployContract, + verifyContract, } from './contracts-helpers'; import { StableAndVariableTokensHelperFactory } from '../types/StableAndVariableTokensHelperFactory'; import { MintableDelegationERC20 } from '../types/MintableDelegationERC20'; @@ -63,7 +64,6 @@ import { readArtifact as buidlerReadArtifact } from '@nomiclabs/buidler/plugins' import { HardhatRuntimeEnvironment } from 'hardhat/types'; import { LendingPoolLibraryAddresses } from '../types/LendingPoolFactory'; import { UiPoolDataProvider } from '../types'; -import { verifyContract } from './etherscan-verification'; export const deployUiPoolDataProvider = async ( [incentivesController, aaveOracle]: [tEthereumAddress, tEthereumAddress], @@ -73,7 +73,7 @@ export const deployUiPoolDataProvider = async ( const args: string[] = [incentivesController, aaveOracle]; const instance = await deployContract(id, args); if (verify) { - await verifyContract(instance.address, args); + await verifyContract(id, instance, args); } return instance; }; diff --git a/tasks/deployments/deploy-UiPoolDataProvider.ts b/tasks/deployments/deploy-UiPoolDataProvider.ts index b43b0b5d..7696ddb9 100644 --- a/tasks/deployments/deploy-UiPoolDataProvider.ts +++ b/tasks/deployments/deploy-UiPoolDataProvider.ts @@ -1,8 +1,7 @@ import { task } from 'hardhat/config'; -import { UiPoolDataProviderFactory } from '../../types'; -import { verifyContract } from '../../helpers/contracts-helpers'; -import { eContractid } from '../../helpers/types'; - +import { eContractid, eEthereumNetwork, eNetwork, ePolygonNetwork } from '../../helpers/types'; +import { deployUiPoolDataProvider } from '../../helpers/contracts-deployments'; +import { exit } from 'process'; task(`deploy-${eContractid.UiPoolDataProvider}`, `Deploys the UiPoolDataProvider contract`) .addFlag('verify', 'Verify UiPoolDataProvider contract via Etherscan API.') @@ -11,8 +10,11 @@ task(`deploy-${eContractid.UiPoolDataProvider}`, `Deploys the UiPoolDataProvider if (!localBRE.network.config.chainId) { throw new Error('INVALID_CHAIN_ID'); } + const network = localBRE.network.name; - const addressesByNetwork = { + const addressesByNetwork: { + [key: string]: { incentivesController: string; aaveOracle: string }; + } = { [eEthereumNetwork.kovan]: { incentivesController: '0x0000000000000000000000000000000000000000', aaveOracle: '0x8fb777d67e9945e2c01936e319057f9d41d559e6', @@ -30,18 +32,25 @@ task(`deploy-${eContractid.UiPoolDataProvider}`, `Deploys the UiPoolDataProvider aaveOracle: '0xC365C653f7229894F93994CD0b30947Ab69Ff1D5', }, }; + const supportedNetworks = Object.keys(addressesByNetwork); + + if (!supportedNetworks.includes(network)) { + console.error( + `[task][error] Network "${network}" not supported, please use one of: ${supportedNetworks.join()}` + ); + exit(2); + } + + const oracle = addressesByNetwork[network].aaveOracle; + const incentivesController = addressesByNetwork[network].aaveOracle; console.log(`\n- UiPoolDataProvider deployment`); - console.log(`\tDeploying UiPoolDataProvider implementation ...`); - const uiPoolDataProvider = await new UiPoolDataProviderFactory( - await localBRE.ethers.provider.getSigner() - ).deploy(); - await uiPoolDataProvider.deployTransaction.wait(); - console.log('uiPoolDataProvider.address', uiPoolDataProvider.address); - if (verify) { - await verifyContract(eContractid.UiPoolDataProvider, uiPoolDataProvider, []); - } + const uiPoolDataProvider = await deployUiPoolDataProvider( + [incentivesController, oracle], + verify + ); + console.log('UiPoolDataProvider deployed at:', uiPoolDataProvider.address); console.log(`\tFinished UiPoolDataProvider deployment`); });