1
0
mirror of https://github.com/oceanprotocol/ocean.js.git synced 2024-11-26 20:39:05 +01:00

fix Balancer PoolFactory

This commit is contained in:
Ahmed Ali 2020-10-20 15:35:23 +02:00
parent 08019706e9
commit b0ef8d7262
2 changed files with 8 additions and 6 deletions

View File

@ -20,7 +20,6 @@ export interface TokensToAdd {
export class Pool extends PoolFactory { export class Pool extends PoolFactory {
public poolABI: AbiItem | AbiItem[] public poolABI: AbiItem | AbiItem[]
public logger: Logger
constructor( constructor(
web3: Web3, web3: Web3,
@ -30,10 +29,9 @@ export class Pool extends PoolFactory {
factoryAddress: string = null, factoryAddress: string = null,
gaslimit?: number gaslimit?: number
) { ) {
super(web3, factoryABI, factoryAddress, gaslimit) super(web3, logger, factoryABI, factoryAddress, gaslimit)
if (poolABI) this.poolABI = poolABI if (poolABI) this.poolABI = poolABI
else this.poolABI = jsonpoolABI.abi as AbiItem[] else this.poolABI = jsonpoolABI.abi as AbiItem[]
this.logger = logger
} }
/** /**

View File

@ -1,5 +1,6 @@
import Web3 from 'web3' import Web3 from 'web3'
import { AbiItem } from 'web3-utils/types' import { AbiItem } from 'web3-utils/types'
import { Logger } from '../utils'
import jsonFactoryABI from '@oceanprotocol/contracts/artifacts/BFactory.json' import jsonFactoryABI from '@oceanprotocol/contracts/artifacts/BFactory.json'
export class PoolFactory { export class PoolFactory {
@ -7,9 +8,11 @@ export class PoolFactory {
public web3: Web3 = null public web3: Web3 = null
public factoryABI: AbiItem | AbiItem[] public factoryABI: AbiItem | AbiItem[]
public factoryAddress: string public factoryAddress: string
public logger: Logger
constructor( constructor(
web3: Web3, web3: Web3,
logger: Logger,
factoryABI: AbiItem | AbiItem[] = null, factoryABI: AbiItem | AbiItem[] = null,
factoryAddress: string = null, factoryAddress: string = null,
gaslimit?: number gaslimit?: number
@ -22,6 +25,7 @@ export class PoolFactory {
this.factoryAddress = factoryAddress this.factoryAddress = factoryAddress
} }
if (gaslimit) this.GASLIMIT_DEFAULT = gaslimit if (gaslimit) this.GASLIMIT_DEFAULT = gaslimit
this.logger = logger
} }
/** /**
@ -29,12 +33,12 @@ export class PoolFactory {
*/ */
async createPool(account: string): Promise<string> { async createPool(account: string): Promise<string> {
if (this.web3 === null) { if (this.web3 === null) {
console.error('ERROR: Web3 object is null') this.logger.error('ERROR: Web3 object is null')
return null return null
} }
if (this.factoryAddress === null) { if (this.factoryAddress === null) {
console.error('ERROR: bfactoryAddress is null') this.logger.error('ERROR: bfactoryAddress is null')
return null return null
} }
@ -51,7 +55,7 @@ export class PoolFactory {
try { try {
pooladdress = transactiondata.events.BPoolRegistered.returnValues[0] pooladdress = transactiondata.events.BPoolRegistered.returnValues[0]
} catch (e) { } 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 return pooladdress
} }