From b0ef8d7262c677c5e1b3d4ac615f971400249fc0 Mon Sep 17 00:00:00 2001 From: Ahmed Ali Date: Tue, 20 Oct 2020 15:35:23 +0200 Subject: [PATCH] fix Balancer PoolFactory --- src/balancer/Pool.ts | 4 +--- src/balancer/PoolFactory.ts | 10 +++++++--- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/balancer/Pool.ts b/src/balancer/Pool.ts index 2947cf2e..3f84d08b 100644 --- a/src/balancer/Pool.ts +++ b/src/balancer/Pool.ts @@ -20,7 +20,6 @@ export interface TokensToAdd { export class Pool extends PoolFactory { public poolABI: AbiItem | AbiItem[] - public logger: Logger constructor( web3: Web3, @@ -30,10 +29,9 @@ export class Pool extends PoolFactory { factoryAddress: string = null, gaslimit?: number ) { - super(web3, factoryABI, factoryAddress, gaslimit) + super(web3, logger, factoryABI, factoryAddress, gaslimit) if (poolABI) this.poolABI = poolABI else this.poolABI = jsonpoolABI.abi as AbiItem[] - this.logger = logger } /** diff --git a/src/balancer/PoolFactory.ts b/src/balancer/PoolFactory.ts index 19c614d9..77ba5d99 100644 --- a/src/balancer/PoolFactory.ts +++ b/src/balancer/PoolFactory.ts @@ -1,5 +1,6 @@ import Web3 from 'web3' import { AbiItem } from 'web3-utils/types' +import { Logger } from '../utils' import jsonFactoryABI from '@oceanprotocol/contracts/artifacts/BFactory.json' export class PoolFactory { @@ -7,9 +8,11 @@ export class PoolFactory { public web3: Web3 = null public factoryABI: AbiItem | AbiItem[] public factoryAddress: string + public logger: Logger constructor( web3: Web3, + logger: Logger, factoryABI: AbiItem | AbiItem[] = null, factoryAddress: string = null, gaslimit?: number @@ -22,6 +25,7 @@ export class PoolFactory { this.factoryAddress = factoryAddress } if (gaslimit) this.GASLIMIT_DEFAULT = gaslimit + this.logger = logger } /** @@ -29,12 +33,12 @@ export class PoolFactory { */ async createPool(account: string): Promise { if (this.web3 === null) { - console.error('ERROR: Web3 object is null') + this.logger.error('ERROR: Web3 object is null') return null } if (this.factoryAddress === null) { - console.error('ERROR: bfactoryAddress is null') + this.logger.error('ERROR: bfactoryAddress is null') return null } @@ -51,7 +55,7 @@ export class PoolFactory { try { pooladdress = transactiondata.events.BPoolRegistered.returnValues[0] } catch (e) { - console.error(`ERROR: Failed to create new pool: ${e.message}`) + this.logger.error(`ERROR: Failed to create new pool: ${e.message}`) } return pooladdress }