Prevent to hang if missing address at db json

This commit is contained in:
David Racero 2020-12-02 10:58:44 +01:00
parent 04c49117b8
commit 39f71f9610
3 changed files with 54 additions and 110 deletions

View File

@ -320,8 +320,8 @@ export const getLendingPoolCollateralManager = async (address?: tEthereumAddress
await getFirstSigner()
);
export const getAddressById = async (id: string) =>
(await getDb().get(`${id}.${DRE.network.name}`).value()).address;
export const getAddressById = async (id: string): Promise<tEthereumAddress | undefined> =>
(await getDb().get(`${id}.${DRE.network.name}`).value())?.address || undefined;
export const getAaveOracle = async (address?: tEthereumAddress) =>
await AaveOracleFactory.connect(

View File

@ -1,3 +1,4 @@
import { error } from 'console';
import { zeroAddress } from 'ethereumjs-util';
import { task } from 'hardhat/config';
import {
@ -105,80 +106,12 @@ task('verify:general', 'Deploy oracles for dev enviroment')
console.log('\n- Verifying Lending Pool Collateral Manager Proxy...\n');
await verifyContract(lendingPoolCollateralManager.address, []);
// Tokens verification
const DAI = getParamPerNetwork(ReserveAssets, network).DAI;
const stableDebtDai = await getAddressById('stableDebtDAI');
const variableDebtDai = await getAddressById('variableDebtDAI');
const aDAI = await getAddressById('aDAI');
const {
stableDebtTokenAddress,
variableDebtTokenAddress,
aTokenAddress,
interestRateStrategyAddress,
} = await lendingPoolProxy.getReserveData(DAI);
const {
baseVariableBorrowRate,
variableRateSlope1,
variableRateSlope2,
stableRateSlope1,
stableRateSlope2,
} = ReservesConfig.DAI;
// Proxy Stable Debt
console.log('\n- Verifying DAI Stable Debt Token proxy...\n');
await verifyContract(stableDebtTokenAddress, [lendingPoolConfigurator.address]);
// Proxy Variable Debt
console.log('\n- Verifying DAI Variable Debt Token proxy...\n');
await verifyContract(variableDebtTokenAddress, [lendingPoolConfigurator.address]);
// Proxy aToken
console.log('\n- Verifying aDAI Token proxy...\n');
await verifyContract(aTokenAddress, [lendingPoolConfigurator.address]);
// Strategy Rate
console.log('\n- Verifying Strategy rate...\n');
await verifyContract(interestRateStrategyAddress, [
addressesProvider.address,
baseVariableBorrowRate,
variableRateSlope1,
variableRateSlope2,
stableRateSlope1,
stableRateSlope2,
]);
// aToken
console.log('\n- Verifying aToken...\n');
await verifyContract(aDAI, [
lendingPoolProxy.address,
DAI,
treasuryAddress,
'Aave interest bearing DAI',
'aDAI',
ZERO_ADDRESS,
]);
// stableDebtToken
console.log('\n- Verifying StableDebtToken...\n');
await verifyContract(stableDebtDai, [
lendingPoolProxy.address,
DAI,
'Aave stable debt bearing DAI',
'stableDebtDAI',
ZERO_ADDRESS,
]);
// variableDebtToken
console.log('\n- Verifying VariableDebtToken...\n');
await verifyContract(variableDebtDai, [
lendingPoolProxy.address,
DAI,
'Aave variable debt bearing DAI',
'variableDebtDAI',
ZERO_ADDRESS,
]);
// DelegatedAwareAToken
console.log('\n- Verifying DelegatedAwareAToken...\n');
const UNI = getParamPerNetwork(ReserveAssets, network).UNI;
const aUNI = await getAddressById('aUNI');
if (aUNI) {
console.log('Verifying aUNI');
await verifyContract(aUNI, [
lendingPoolProxy.address,
UNI,
@ -187,4 +120,8 @@ task('verify:general', 'Deploy oracles for dev enviroment')
'aUNI',
ZERO_ADDRESS,
]);
} else {
console.error('Missing aUNI address at JSON DB. Skipping...');
}
console.log('Finished verifications.');
});

View File

@ -83,7 +83,7 @@ task('verify:tokens', 'Deploy oracles for dev enviroment')
const variableDebt = await getAddressById(`variableDebt${token}`);
const aToken = await getAddressById(`a${token}`);
// aToken
if (aToken) {
console.log('\n- Verifying aToken...\n');
await verifyContract(aToken, [
lendingPoolProxy.address,
@ -93,8 +93,10 @@ task('verify:tokens', 'Deploy oracles for dev enviroment')
`a${token}`,
ZERO_ADDRESS,
]);
// stableDebtToken
} else {
console.error(`Skipping aToken verify for ${token}. Missing address at JSON DB.`);
}
if (stableDebt) {
console.log('\n- Verifying StableDebtToken...\n');
await verifyContract(stableDebt, [
lendingPoolProxy.address,
@ -103,8 +105,10 @@ task('verify:tokens', 'Deploy oracles for dev enviroment')
`stableDebt${token}`,
ZERO_ADDRESS,
]);
// variableDebtToken
} else {
console.error(`Skipping stable debt verify for ${token}. Missing address at JSON DB.`);
}
if (variableDebt) {
console.log('\n- Verifying VariableDebtToken...\n');
await verifyContract(variableDebt, [
lendingPoolProxy.address,
@ -113,5 +117,8 @@ task('verify:tokens', 'Deploy oracles for dev enviroment')
`variableDebt${token}`,
ZERO_ADDRESS,
]);
} else {
console.error(`Skipping variable debt verify for ${token}. Missing address at JSON DB.`);
}
}
});