From 4ee41dbece2e286e06340e9f7d7ce44ff2ca22bc Mon Sep 17 00:00:00 2001 From: David Racero Date: Wed, 21 Oct 2020 11:42:27 +0200 Subject: [PATCH] Added waitForTx to missing methods. --- helpers/contracts-helpers.ts | 20 +++++++++++--------- helpers/init-helpers.ts | 20 ++++++++++++++------ helpers/oracles-helpers.ts | 2 +- 3 files changed, 26 insertions(+), 16 deletions(-) diff --git a/helpers/contracts-helpers.ts b/helpers/contracts-helpers.ts index 77730b04..6cb94d84 100644 --- a/helpers/contracts-helpers.ts +++ b/helpers/contracts-helpers.ts @@ -1,6 +1,6 @@ import {Contract, Signer, utils, ethers} from 'ethers'; import {CommonsConfig} from '../config/commons'; -import {getDb, BRE} from './misc-utils'; +import {getDb, BRE, waitForTx} from './misc-utils'; import { tEthereumAddress, eContractid, @@ -101,7 +101,7 @@ export const deployContract = async ( const contract = (await (await BRE.ethers.getContractFactory(contractName)).deploy( ...args )) as ContractType; - + await waitForTx(contract.deployTransaction); await registerContractInJsonDb(contractName, contract); return contract; }; @@ -856,13 +856,15 @@ export const initReserves = async ( } console.log('init reserve currency ', assetSymbol); - await lendingPoolConfigurator.initReserve( - tokenAddress, - aToken.address, - stableDebtToken.address, - variableDebtToken.address, - reserveDecimals, - rateStrategyContract.address + await waitForTx( + await lendingPoolConfigurator.initReserve( + tokenAddress, + aToken.address, + stableDebtToken.address, + variableDebtToken.address, + reserveDecimals, + rateStrategyContract.address + ) ); } catch (e) { console.log(`Reserve initialization for ${assetSymbol} failed with error ${e}. Skipped.`); diff --git a/helpers/init-helpers.ts b/helpers/init-helpers.ts index 6e049c51..ede2bbc3 100644 --- a/helpers/init-helpers.ts +++ b/helpers/init-helpers.ts @@ -2,6 +2,7 @@ import {iMultiPoolsAssets, IReserveParams, tEthereumAddress} from './types'; import {LendingPool} from '../types/LendingPool'; import {LendingPoolConfigurator} from '../types/LendingPoolConfigurator'; import {AaveProtocolTestHelpers} from '../types/AaveProtocolTestHelpers'; +import {waitForTx} from './misc-utils'; export const enableReservesToBorrow = async ( reservesParams: iMultiPoolsAssets, @@ -29,7 +30,12 @@ export const enableReservesToBorrow = async ( continue; } - await lendingPoolConfigurator.enableBorrowingOnReserve(tokenAddress, stableBorrowRateEnabled); + await waitForTx( + await lendingPoolConfigurator.enableBorrowingOnReserve( + tokenAddress, + stableBorrowRateEnabled + ) + ); } catch (e) { console.log( `Enabling reserve for borrowings for ${assetSymbol} failed with error ${e}. Skipped.` @@ -66,11 +72,13 @@ export const enableReservesAsCollateral = async ( } try { - await lendingPoolConfigurator.enableReserveAsCollateral( - tokenAddress, - baseLTVAsCollateral, - liquidationThreshold, - liquidationBonus + await waitForTx( + await lendingPoolConfigurator.enableReserveAsCollateral( + tokenAddress, + baseLTVAsCollateral, + liquidationThreshold, + liquidationBonus + ) ); } catch (e) { console.log( diff --git a/helpers/oracles-helpers.ts b/helpers/oracles-helpers.ts index b3439df9..f5b5941d 100644 --- a/helpers/oracles-helpers.ts +++ b/helpers/oracles-helpers.ts @@ -30,7 +30,7 @@ export const setInitialMarketRatesInRatesOracle = async ( const [, assetAddress] = (Object.entries(assetsAddresses) as [string, string][])[ assetAddressIndex ]; - await lendingRateOracleInstance.setMarketBorrowRate(assetAddress, borrowRate); + await waitForTx(await lendingRateOracleInstance.setMarketBorrowRate(assetAddress, borrowRate)); console.log('added Market Borrow Rate for: ', assetSymbol); } };