11import { task } from 'hardhat/config' ;
2- import { UiPoolDataProviderFactory } from '../../types' ;
3- import { verifyContract } from '../../helpers/contracts-helpers' ;
4- import { eContractid } from '../../helpers/types' ;
5-
2+ import { eContractid , eEthereumNetwork , eNetwork , ePolygonNetwork } from '../../helpers/types' ;
3+ import { deployUiPoolDataProvider } from '../../helpers/contracts-deployments' ;
4+ import { exit } from 'process' ;
65
76task ( `deploy-${ eContractid . UiPoolDataProvider } ` , `Deploys the UiPoolDataProvider contract` )
87 . addFlag ( 'verify' , 'Verify UiPoolDataProvider contract via Etherscan API.' )
@@ -11,8 +10,11 @@ task(`deploy-${eContractid.UiPoolDataProvider}`, `Deploys the UiPoolDataProvider
1110 if ( ! localBRE . network . config . chainId ) {
1211 throw new Error ( 'INVALID_CHAIN_ID' ) ;
1312 }
13+ const network = localBRE . network . name ;
1414
15- const addressesByNetwork = {
15+ const addressesByNetwork : {
16+ [ key : string ] : { incentivesController : string ; aaveOracle : string } ;
17+ } = {
1618 [ eEthereumNetwork . kovan ] : {
1719 incentivesController : '0x0000000000000000000000000000000000000000' ,
1820 aaveOracle : '0x8fb777d67e9945e2c01936e319057f9d41d559e6' ,
@@ -30,18 +32,25 @@ task(`deploy-${eContractid.UiPoolDataProvider}`, `Deploys the UiPoolDataProvider
3032 aaveOracle : '0xC365C653f7229894F93994CD0b30947Ab69Ff1D5' ,
3133 } ,
3234 } ;
35+ const supportedNetworks = Object . keys ( addressesByNetwork ) ;
36+
37+ if ( ! supportedNetworks . includes ( network ) ) {
38+ console . error (
39+ `[task][error] Network "${ network } " not supported, please use one of: ${ supportedNetworks . join ( ) } `
40+ ) ;
41+ exit ( 2 ) ;
42+ }
43+
44+ const oracle = addressesByNetwork [ network ] . aaveOracle ;
45+ const incentivesController = addressesByNetwork [ network ] . aaveOracle ;
3346
3447 console . log ( `\n- UiPoolDataProvider deployment` ) ;
3548
36- console . log ( `\tDeploying UiPoolDataProvider implementation ...` ) ;
37- const uiPoolDataProvider = await new UiPoolDataProviderFactory (
38- await localBRE . ethers . provider . getSigner ( )
39- ) . deploy ( ) ;
40- await uiPoolDataProvider . deployTransaction . wait ( ) ;
41- console . log ( 'uiPoolDataProvider.address' , uiPoolDataProvider . address ) ;
42- if ( verify ) {
43- await verifyContract ( eContractid . UiPoolDataProvider , uiPoolDataProvider , [ ] ) ;
44- }
49+ const uiPoolDataProvider = await deployUiPoolDataProvider (
50+ [ incentivesController , oracle ] ,
51+ verify
52+ ) ;
4553
54+ console . log ( 'UiPoolDataProvider deployed at:' , uiPoolDataProvider . address ) ;
4655 console . log ( `\tFinished UiPoolDataProvider deployment` ) ;
4756 } ) ;
0 commit comments