Skip to content

Commit

Permalink
fix Balancer PoolFactory
Browse files Browse the repository at this point in the history
  • Loading branch information
0x3bfc committed Oct 20, 2020
1 parent 0801970 commit b0ef8d7
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
4 changes: 1 addition & 3 deletions src/balancer/Pool.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ export interface TokensToAdd {

export class Pool extends PoolFactory {
public poolABI: AbiItem | AbiItem[]
public logger: Logger

constructor(
web3: Web3,
Expand All @@ -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
}

/**
Expand Down
10 changes: 7 additions & 3 deletions src/balancer/PoolFactory.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
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 {
public GASLIMIT_DEFAULT = 5000000
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
Expand All @@ -22,19 +25,20 @@ export class PoolFactory {
this.factoryAddress = factoryAddress
}
if (gaslimit) this.GASLIMIT_DEFAULT = gaslimit
this.logger = logger
}

/**
* Creates a new pool
*/
async createPool(account: string): Promise<string> {
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
}

Expand All @@ -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
}
Expand Down

0 comments on commit b0ef8d7

Please sign in to comment.