Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix/Error-messages #367

Merged
merged 2 commits into from
Oct 19, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
70 changes: 35 additions & 35 deletions src/balancer/Pool.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ export class Pool extends PoolFactory {
)
.send({ from: account, gas: this.GASLIMIT_DEFAULT })
} catch (e) {
console.error('Pool.setup failed:' + e)
console.error(`ERROR: Failed to setup a pool: ${e.message}`)
}
return result
}
Expand Down Expand Up @@ -134,7 +134,7 @@ export class Pool extends PoolFactory {
.approve(spender, amount)
.send({ from: account, gas: this.GASLIMIT_DEFAULT })
} catch (e) {
console.error(e)
console.error(`ERRPR: Failed to approve spender to spend tokens : ${e.message}`)
}
return result
}
Expand All @@ -152,7 +152,7 @@ export class Pool extends PoolFactory {
const balance = await token.methods.balanceOf(account).call()
result = this.web3.utils.fromWei(balance)
} catch (e) {
console.error(e)
console.error(`ERROR: Failed to get shares of pool : ${e.message}`)
}
return result
}
Expand Down Expand Up @@ -190,7 +190,7 @@ export class Pool extends PoolFactory {
)
.send({ from: account, gas: this.GASLIMIT_DEFAULT })
} catch (e) {
console.error(e)
console.error(`ERROR: Failed to add tokens to pool: ${e.message}`)
}
}
}
Expand All @@ -215,7 +215,7 @@ export class Pool extends PoolFactory {
.setSwapFee(this.web3.utils.toWei(fee))
.send({ from: account, gas: this.GASLIMIT_DEFAULT })
} catch (e) {
console.error(e)
console.error(`ERROR: Failed to set pool swap fee: ${e.message}`)
}
return result
}
Expand All @@ -235,7 +235,7 @@ export class Pool extends PoolFactory {
.finalize()
.send({ from: account, gas: this.GASLIMIT_DEFAULT })
} catch (e) {
console.error(e)
console.error(`ERROR: Failed to finalize pool: ${e.message}`)
}
return result
}
Expand All @@ -251,7 +251,7 @@ export class Pool extends PoolFactory {
try {
result = await pool.methods.getNumTokens().call()
} catch (e) {
console.error(e)
console.error(`ERROR: Failed to get number of tokens: ${e.message}`)
}
return result
}
Expand All @@ -268,7 +268,7 @@ export class Pool extends PoolFactory {
const result = await pool.methods.totalSupply().call()
amount = this.web3.utils.fromWei(result)
} catch (e) {
console.error(e)
console.error(`ERROR: Failed to get total supply of pool shares: ${e.message}`)
}
return amount
}
Expand All @@ -284,7 +284,7 @@ export class Pool extends PoolFactory {
try {
result = await pool.methods.getCurrentTokens().call()
} catch (e) {
console.error(e)
console.error(`ERROR: Failed to get tokens composing this pool: ${e.message}`)
}
return result
}
Expand All @@ -300,7 +300,7 @@ export class Pool extends PoolFactory {
try {
result = await pool.methods.getFinalTokens().call()
} catch (e) {
console.error(e)
console.error(`ERROR: Failed to get the final tokens composing this pool`)
}
return result
}
Expand All @@ -316,7 +316,7 @@ export class Pool extends PoolFactory {
try {
result = await pool.methods.getController().call()
} catch (e) {
console.error(e)
console.error(`ERROR: Failed to get pool controller address: ${e.message}`)
}
return result
}
Expand All @@ -342,7 +342,7 @@ export class Pool extends PoolFactory {
.setController(controllerAddress)
.send({ from: account, gas: this.GASLIMIT_DEFAULT })
} catch (e) {
console.error(e)
console.error(`ERROR: Failed to set pool controller: ${e.message}`)
}
return result
}
Expand All @@ -359,7 +359,7 @@ export class Pool extends PoolFactory {
try {
result = await pool.methods.isBound(token).call()
} catch (e) {
console.error(e)
console.error(`ERROR: Failed to check if a token bounded to a pool: ${e.message}`)
}
return result
}
Expand All @@ -377,7 +377,7 @@ export class Pool extends PoolFactory {
const result = await pool.methods.getBalance(token).call()
amount = this.web3.utils.fromWei(result)
} catch (e) {
console.error(e)
console.error(`ERROR: Failed to get how many tokens are in the pool: ${e.message}`)
}
return amount
}
Expand All @@ -393,7 +393,7 @@ export class Pool extends PoolFactory {
try {
result = await pool.methods.isFinalized().call()
} catch (e) {
console.error(e)
console.error(`ERROR: Failed to check whether pool is finalized: ${e.message}`)
}
return result
}
Expand All @@ -410,7 +410,7 @@ export class Pool extends PoolFactory {
const result = await pool.methods.getSwapFee().call()
fee = this.web3.utils.fromWei(result)
} catch (e) {
console.error(e)
console.error(`ERROR: Failed to get pool fee: ${e.message}`)
}
return fee
}
Expand All @@ -428,7 +428,7 @@ export class Pool extends PoolFactory {
const result = await pool.methods.getNormalizedWeight(token).call()
weight = this.web3.utils.fromWei(result)
} catch (e) {
console.error(e)
console.error(`ERROR: Failed to get normalized weight of a token: ${e.message}`)
}
return weight
}
Expand All @@ -446,7 +446,7 @@ export class Pool extends PoolFactory {
const result = await pool.methods.getDenormalizedWeight(token).call()
weight = this.web3.utils.fromWei(result)
} catch (e) {
console.error(e)
console.error('ERROR: Failed to get denormalized weight of a token in pool')
}
return weight
}
Expand All @@ -463,7 +463,7 @@ export class Pool extends PoolFactory {
const result = await pool.methods.getTotalDenormalizedWeight().call()
weight = this.web3.utils.fromWei(result)
} catch (e) {
console.error(e)
console.error('ERROR: Failed to get total denormalized weight in pool')
}
return weight
}
Expand Down Expand Up @@ -503,7 +503,7 @@ export class Pool extends PoolFactory {
)
.send({ from: account, gas: this.GASLIMIT_DEFAULT })
} catch (e) {
console.error(e)
console.error(`ERROR: Failed to swap exact amount in : ${e.message}`)
}
return result
}
Expand Down Expand Up @@ -543,7 +543,7 @@ export class Pool extends PoolFactory {
)
.send({ from: account, gas: this.GASLIMIT_DEFAULT })
} catch (e) {
console.error(e)
console.error(`ERROR: Failed to swap exact amount out: ${e.message}`)
}
return result
}
Expand Down Expand Up @@ -580,7 +580,7 @@ export class Pool extends PoolFactory {
.joinPool(this.web3.utils.toWei(poolAmountOut), weiMaxAmountsIn)
.send({ from: account, gas: this.GASLIMIT_DEFAULT })
} catch (e) {
console.error(e)
console.error(`ERROR: Failed to join pool: ${e.message}`)
}
return result
}
Expand Down Expand Up @@ -614,7 +614,7 @@ export class Pool extends PoolFactory {
.exitPool(this.web3.utils.toWei(poolAmountIn), weiMinAmountsOut)
.send({ from: account, gas: this.GASLIMIT_DEFAULT })
} catch (e) {
console.error(e)
console.error(`ERROR: Failed to exit pool: ${e.message}`)
}
return result
}
Expand Down Expand Up @@ -648,7 +648,7 @@ export class Pool extends PoolFactory {
)
.send({ from: account, gas: this.GASLIMIT_DEFAULT })
} catch (e) {
console.error(e)
console.error(`ERROR: Failed to pay tokens in order to join the pool: ${e.message}`)
}
return result
}
Expand Down Expand Up @@ -682,7 +682,7 @@ export class Pool extends PoolFactory {
)
.send({ from: account, gas: this.GASLIMIT_DEFAULT })
} catch (e) {
console.error(e)
console.error('ERROR: Failed to join swap pool amount out')
}
return result
}
Expand Down Expand Up @@ -716,7 +716,7 @@ export class Pool extends PoolFactory {
)
.send({ from: account, gas: this.GASLIMIT_DEFAULT })
} catch (e) {
console.error(e)
console.error(`ERROR: Failed to pay pool shares into the pool: ${e.message}`)
}
return result
}
Expand Down Expand Up @@ -750,7 +750,7 @@ export class Pool extends PoolFactory {
)
.send({ from: account, gas: this.GASLIMIT_DEFAULT })
} catch (e) {
console.error(e)
console.error('ERROR: Failed to exitswapExternAmountOut')
}
return result
}
Expand All @@ -773,7 +773,7 @@ export class Pool extends PoolFactory {
const result = await pool.methods.getSpotPrice(tokenIn, tokenOut).call()
price = this.web3.utils.fromWei(result)
} catch (e) {
console.error(e)
console.error('ERROR: Failed to get spot price of swapping tokenIn to tokenOut')
}
return price
}
Expand All @@ -796,7 +796,7 @@ export class Pool extends PoolFactory {
const result = await pool.methods.getSpotPriceSansFee(tokenIn, tokenOut).call()
price = this.web3.utils.fromWei(result)
} catch (e) {
console.error(e)
console.error('ERROR: Failed to getSpotPriceSansFee')
}
return price
}
Expand Down Expand Up @@ -825,7 +825,7 @@ export class Pool extends PoolFactory {
.call()
amount = this.web3.utils.fromWei(result)
} catch (e) {
console.error(e)
console.error('ERROR: Failed to calcInGivenOut')
}
return amount
}
Expand Down Expand Up @@ -854,7 +854,7 @@ export class Pool extends PoolFactory {
.call()
amount = this.web3.utils.fromWei(result)
} catch (e) {
console.error(e)
console.error('ERROR: Failed to calcOutGivenIn')
}
return amount
}
Expand Down Expand Up @@ -883,7 +883,7 @@ export class Pool extends PoolFactory {
.call()
amount = this.web3.utils.fromWei(result)
} catch (e) {
console.error(e)
console.error(`ERROR: Failed to calculate PoolOutGivenSingleIn : ${e.message}`)
}
return amount
}
Expand Down Expand Up @@ -912,7 +912,7 @@ export class Pool extends PoolFactory {
.call()
amount = this.web3.utils.fromWei(result)
} catch (e) {
console.error(e)
console.error(`ERROR: Failed to calculate SingleInGivenPoolOut : ${e.message}`)
}
return amount
}
Expand Down Expand Up @@ -941,7 +941,7 @@ export class Pool extends PoolFactory {
.call()
amount = this.web3.utils.fromWei(result)
} catch (e) {
console.error(e)
console.error(`ERROR: Failed to calculate SingleOutGivenPoolIn : ${e.message}`)
}
return amount
}
Expand Down Expand Up @@ -970,7 +970,7 @@ export class Pool extends PoolFactory {
.call()
amount = this.web3.utils.fromWei(result)
} catch (e) {
console.error(e)
console.error(`ERROR: Failed to calculate PoolInGivenSingleOut : ${e.message}`)
}
return amount
}
Expand Down
6 changes: 3 additions & 3 deletions src/balancer/PoolFactory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,12 @@ export class PoolFactory {
*/
async createPool(account: string): Promise<string> {
if (this.web3 === null) {
console.error('Web3 object is null')
console.error('ERROR: Web3 object is null')
return null
}

if (this.factoryAddress === null) {
console.error('bfactoryAddress is null')
console.error('ERROR: bfactoryAddress is null')
return null
}

Expand All @@ -51,7 +51,7 @@ export class PoolFactory {
try {
pooladdress = transactiondata.events.BPoolRegistered.returnValues[0]
} catch (e) {
console.error(e)
console.error(`ERROR: Failed to create new pool: ${e.message}`)
}
return pooladdress
}
Expand Down
8 changes: 4 additions & 4 deletions src/datatokens/Datatokens.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ export class DataTokens {
const estGas = await factory.methods
.createToken(metadataCacheUri, name, symbol, this.web3.utils.toWei(cap))
.estimateGas(function (err: string, estGas: string) {
if (err) console.log('Datatokens: ' + err)
if (err) console.error(`ERROR: Datatokens : ${err}`)
return estGas
})
// Invoke createToken function of the contract
Expand All @@ -108,7 +108,7 @@ export class DataTokens {
try {
tokenAddress = trxReceipt.events.TokenCreated.returnValues[0]
} catch (e) {
console.error(e)
console.error(`ERROR: Failed to create datatoken : ${e.message}`)
}
return tokenAddress
}
Expand Down Expand Up @@ -157,7 +157,7 @@ export class DataTokens {
const estGas = await datatoken.methods
.mint(destAddress, this.web3.utils.toWei(amount))
.estimateGas(function (err, estGas) {
if (err) console.log('Datatokens: ' + err)
if (err) console.error(`ERROR: Datatokens : ${err}`)
return estGas
})

Expand Down Expand Up @@ -373,7 +373,7 @@ export class DataTokens {
.send({ from: address, gas: 600000 })
return trxReceipt
} catch (e) {
console.error(e)
console.error(`ERROR: Failed to start order : ${e.message}`)
return null
}
}
Expand Down
Loading