Added waitForTx to missing methods.

This commit is contained in:
David Racero 2020-10-21 11:42:27 +02:00
parent 7ddf18b823
commit 4ee41dbece
3 changed files with 26 additions and 16 deletions

View File

@ -1,6 +1,6 @@
import {Contract, Signer, utils, ethers} from 'ethers'; import {Contract, Signer, utils, ethers} from 'ethers';
import {CommonsConfig} from '../config/commons'; import {CommonsConfig} from '../config/commons';
import {getDb, BRE} from './misc-utils'; import {getDb, BRE, waitForTx} from './misc-utils';
import { import {
tEthereumAddress, tEthereumAddress,
eContractid, eContractid,
@ -101,7 +101,7 @@ export const deployContract = async <ContractType extends Contract>(
const contract = (await (await BRE.ethers.getContractFactory(contractName)).deploy( const contract = (await (await BRE.ethers.getContractFactory(contractName)).deploy(
...args ...args
)) as ContractType; )) as ContractType;
await waitForTx(contract.deployTransaction);
await registerContractInJsonDb(<eContractid>contractName, contract); await registerContractInJsonDb(<eContractid>contractName, contract);
return contract; return contract;
}; };
@ -856,13 +856,15 @@ export const initReserves = async (
} }
console.log('init reserve currency ', assetSymbol); console.log('init reserve currency ', assetSymbol);
await lendingPoolConfigurator.initReserve( await waitForTx(
tokenAddress, await lendingPoolConfigurator.initReserve(
aToken.address, tokenAddress,
stableDebtToken.address, aToken.address,
variableDebtToken.address, stableDebtToken.address,
reserveDecimals, variableDebtToken.address,
rateStrategyContract.address reserveDecimals,
rateStrategyContract.address
)
); );
} catch (e) { } catch (e) {
console.log(`Reserve initialization for ${assetSymbol} failed with error ${e}. Skipped.`); console.log(`Reserve initialization for ${assetSymbol} failed with error ${e}. Skipped.`);

View File

@ -2,6 +2,7 @@ import {iMultiPoolsAssets, IReserveParams, tEthereumAddress} from './types';
import {LendingPool} from '../types/LendingPool'; import {LendingPool} from '../types/LendingPool';
import {LendingPoolConfigurator} from '../types/LendingPoolConfigurator'; import {LendingPoolConfigurator} from '../types/LendingPoolConfigurator';
import {AaveProtocolTestHelpers} from '../types/AaveProtocolTestHelpers'; import {AaveProtocolTestHelpers} from '../types/AaveProtocolTestHelpers';
import {waitForTx} from './misc-utils';
export const enableReservesToBorrow = async ( export const enableReservesToBorrow = async (
reservesParams: iMultiPoolsAssets<IReserveParams>, reservesParams: iMultiPoolsAssets<IReserveParams>,
@ -29,7 +30,12 @@ export const enableReservesToBorrow = async (
continue; continue;
} }
await lendingPoolConfigurator.enableBorrowingOnReserve(tokenAddress, stableBorrowRateEnabled); await waitForTx(
await lendingPoolConfigurator.enableBorrowingOnReserve(
tokenAddress,
stableBorrowRateEnabled
)
);
} catch (e) { } catch (e) {
console.log( console.log(
`Enabling reserve for borrowings for ${assetSymbol} failed with error ${e}. Skipped.` `Enabling reserve for borrowings for ${assetSymbol} failed with error ${e}. Skipped.`
@ -66,11 +72,13 @@ export const enableReservesAsCollateral = async (
} }
try { try {
await lendingPoolConfigurator.enableReserveAsCollateral( await waitForTx(
tokenAddress, await lendingPoolConfigurator.enableReserveAsCollateral(
baseLTVAsCollateral, tokenAddress,
liquidationThreshold, baseLTVAsCollateral,
liquidationBonus liquidationThreshold,
liquidationBonus
)
); );
} catch (e) { } catch (e) {
console.log( console.log(

View File

@ -30,7 +30,7 @@ export const setInitialMarketRatesInRatesOracle = async (
const [, assetAddress] = (Object.entries(assetsAddresses) as [string, string][])[ const [, assetAddress] = (Object.entries(assetsAddresses) as [string, string][])[
assetAddressIndex assetAddressIndex
]; ];
await lendingRateOracleInstance.setMarketBorrowRate(assetAddress, borrowRate); await waitForTx(await lendingRateOracleInstance.setMarketBorrowRate(assetAddress, borrowRate));
console.log('added Market Borrow Rate for: ', assetSymbol); console.log('added Market Borrow Rate for: ', assetSymbol);
} }
}; };