mirror of
https://github.com/oceanprotocol/ocean.js.git
synced 2024-11-26 20:39:05 +01:00
handle error messages
This commit is contained in:
parent
7ec2cb38e4
commit
d574782b14
@ -82,7 +82,7 @@ export class Pool extends PoolFactory {
|
|||||||
)
|
)
|
||||||
.send({ from: account, gas: this.GASLIMIT_DEFAULT })
|
.send({ from: account, gas: this.GASLIMIT_DEFAULT })
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error('Pool.setup failed:' + e)
|
console.error(`ERROR: Failed to setup a pool: ${e.message}`)
|
||||||
}
|
}
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
@ -134,7 +134,7 @@ export class Pool extends PoolFactory {
|
|||||||
.approve(spender, amount)
|
.approve(spender, amount)
|
||||||
.send({ from: account, gas: this.GASLIMIT_DEFAULT })
|
.send({ from: account, gas: this.GASLIMIT_DEFAULT })
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error(e)
|
console.error(`ERRPR: Failed to approve spender to spend tokens : ${e.message}`)
|
||||||
}
|
}
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
@ -152,7 +152,7 @@ export class Pool extends PoolFactory {
|
|||||||
const balance = await token.methods.balanceOf(account).call()
|
const balance = await token.methods.balanceOf(account).call()
|
||||||
result = this.web3.utils.fromWei(balance)
|
result = this.web3.utils.fromWei(balance)
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error(e)
|
console.error(`ERROR: Failed to get shares of pool : ${e.message}`)
|
||||||
}
|
}
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
@ -190,7 +190,7 @@ export class Pool extends PoolFactory {
|
|||||||
)
|
)
|
||||||
.send({ from: account, gas: this.GASLIMIT_DEFAULT })
|
.send({ from: account, gas: this.GASLIMIT_DEFAULT })
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error(e)
|
console.error(`ERROR: Failed to add tokens to pool: ${e.message}`)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -215,7 +215,7 @@ export class Pool extends PoolFactory {
|
|||||||
.setSwapFee(this.web3.utils.toWei(fee))
|
.setSwapFee(this.web3.utils.toWei(fee))
|
||||||
.send({ from: account, gas: this.GASLIMIT_DEFAULT })
|
.send({ from: account, gas: this.GASLIMIT_DEFAULT })
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error(e)
|
console.error(`ERROR: Failed to set pool swap fee: ${e.message}`)
|
||||||
}
|
}
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
@ -235,7 +235,7 @@ export class Pool extends PoolFactory {
|
|||||||
.finalize()
|
.finalize()
|
||||||
.send({ from: account, gas: this.GASLIMIT_DEFAULT })
|
.send({ from: account, gas: this.GASLIMIT_DEFAULT })
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error(e)
|
console.error(`ERROR: Failed to finalize pool: ${e.message}`)
|
||||||
}
|
}
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
@ -251,7 +251,7 @@ export class Pool extends PoolFactory {
|
|||||||
try {
|
try {
|
||||||
result = await pool.methods.getNumTokens().call()
|
result = await pool.methods.getNumTokens().call()
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error(e)
|
console.error(`ERROR: Failed to get number of tokens: ${e.message}`)
|
||||||
}
|
}
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
@ -268,7 +268,7 @@ export class Pool extends PoolFactory {
|
|||||||
const result = await pool.methods.totalSupply().call()
|
const result = await pool.methods.totalSupply().call()
|
||||||
amount = this.web3.utils.fromWei(result)
|
amount = this.web3.utils.fromWei(result)
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error(e)
|
console.error(`ERROR: Failed to get total supply of pool shares: ${e.message}`)
|
||||||
}
|
}
|
||||||
return amount
|
return amount
|
||||||
}
|
}
|
||||||
@ -284,7 +284,7 @@ export class Pool extends PoolFactory {
|
|||||||
try {
|
try {
|
||||||
result = await pool.methods.getCurrentTokens().call()
|
result = await pool.methods.getCurrentTokens().call()
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error(e)
|
console.error(`ERROR: Failed to get tokens composing this pool: ${e.message}`)
|
||||||
}
|
}
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
@ -300,7 +300,7 @@ export class Pool extends PoolFactory {
|
|||||||
try {
|
try {
|
||||||
result = await pool.methods.getFinalTokens().call()
|
result = await pool.methods.getFinalTokens().call()
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error(e)
|
console.error(`ERROR: Failed to get the final tokens composing this pool`)
|
||||||
}
|
}
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
@ -316,7 +316,7 @@ export class Pool extends PoolFactory {
|
|||||||
try {
|
try {
|
||||||
result = await pool.methods.getController().call()
|
result = await pool.methods.getController().call()
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error(e)
|
console.error(`ERROR: Failed to get pool controller address: ${e.message}`)
|
||||||
}
|
}
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
@ -342,7 +342,7 @@ export class Pool extends PoolFactory {
|
|||||||
.setController(controllerAddress)
|
.setController(controllerAddress)
|
||||||
.send({ from: account, gas: this.GASLIMIT_DEFAULT })
|
.send({ from: account, gas: this.GASLIMIT_DEFAULT })
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error(e)
|
console.error(`ERROR: Failed to set pool controller: ${e.message}`)
|
||||||
}
|
}
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
@ -359,7 +359,7 @@ export class Pool extends PoolFactory {
|
|||||||
try {
|
try {
|
||||||
result = await pool.methods.isBound(token).call()
|
result = await pool.methods.isBound(token).call()
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error(e)
|
console.error(`ERROR: Failed to check if a token bounded to a pool: ${e.message}`)
|
||||||
}
|
}
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
@ -377,7 +377,7 @@ export class Pool extends PoolFactory {
|
|||||||
const result = await pool.methods.getBalance(token).call()
|
const result = await pool.methods.getBalance(token).call()
|
||||||
amount = this.web3.utils.fromWei(result)
|
amount = this.web3.utils.fromWei(result)
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error(e)
|
console.error(`ERROR: Failed to get how many tokens are in the pool: ${e.message}`)
|
||||||
}
|
}
|
||||||
return amount
|
return amount
|
||||||
}
|
}
|
||||||
@ -393,7 +393,7 @@ export class Pool extends PoolFactory {
|
|||||||
try {
|
try {
|
||||||
result = await pool.methods.isFinalized().call()
|
result = await pool.methods.isFinalized().call()
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error(e)
|
console.error(`ERROR: Failed to check whether pool is finalized: ${e.message}`)
|
||||||
}
|
}
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
@ -410,7 +410,7 @@ export class Pool extends PoolFactory {
|
|||||||
const result = await pool.methods.getSwapFee().call()
|
const result = await pool.methods.getSwapFee().call()
|
||||||
fee = this.web3.utils.fromWei(result)
|
fee = this.web3.utils.fromWei(result)
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error(e)
|
console.error(`ERROR: Failed to get pool fee: ${e.message}`)
|
||||||
}
|
}
|
||||||
return fee
|
return fee
|
||||||
}
|
}
|
||||||
@ -428,7 +428,7 @@ export class Pool extends PoolFactory {
|
|||||||
const result = await pool.methods.getNormalizedWeight(token).call()
|
const result = await pool.methods.getNormalizedWeight(token).call()
|
||||||
weight = this.web3.utils.fromWei(result)
|
weight = this.web3.utils.fromWei(result)
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error(e)
|
console.error(`ERROR: Failed to get normalized weight of a token: ${e.message}`)
|
||||||
}
|
}
|
||||||
return weight
|
return weight
|
||||||
}
|
}
|
||||||
@ -446,7 +446,7 @@ export class Pool extends PoolFactory {
|
|||||||
const result = await pool.methods.getDenormalizedWeight(token).call()
|
const result = await pool.methods.getDenormalizedWeight(token).call()
|
||||||
weight = this.web3.utils.fromWei(result)
|
weight = this.web3.utils.fromWei(result)
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error(e)
|
console.error('ERROR: Failed to get denormalized weight of a token in pool')
|
||||||
}
|
}
|
||||||
return weight
|
return weight
|
||||||
}
|
}
|
||||||
@ -463,7 +463,7 @@ export class Pool extends PoolFactory {
|
|||||||
const result = await pool.methods.getTotalDenormalizedWeight().call()
|
const result = await pool.methods.getTotalDenormalizedWeight().call()
|
||||||
weight = this.web3.utils.fromWei(result)
|
weight = this.web3.utils.fromWei(result)
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error(e)
|
console.error('ERROR: Failed to get total denormalized weight in pool')
|
||||||
}
|
}
|
||||||
return weight
|
return weight
|
||||||
}
|
}
|
||||||
@ -503,7 +503,7 @@ export class Pool extends PoolFactory {
|
|||||||
)
|
)
|
||||||
.send({ from: account, gas: this.GASLIMIT_DEFAULT })
|
.send({ from: account, gas: this.GASLIMIT_DEFAULT })
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error(e)
|
console.error(`ERROR: Failed to swap exact amount in : ${e.message}`)
|
||||||
}
|
}
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
@ -543,7 +543,7 @@ export class Pool extends PoolFactory {
|
|||||||
)
|
)
|
||||||
.send({ from: account, gas: this.GASLIMIT_DEFAULT })
|
.send({ from: account, gas: this.GASLIMIT_DEFAULT })
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error(e)
|
console.error(`ERROR: Failed to swap exact amount out: ${e.message}`)
|
||||||
}
|
}
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
@ -580,7 +580,7 @@ export class Pool extends PoolFactory {
|
|||||||
.joinPool(this.web3.utils.toWei(poolAmountOut), weiMaxAmountsIn)
|
.joinPool(this.web3.utils.toWei(poolAmountOut), weiMaxAmountsIn)
|
||||||
.send({ from: account, gas: this.GASLIMIT_DEFAULT })
|
.send({ from: account, gas: this.GASLIMIT_DEFAULT })
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error(e)
|
console.error(`ERROR: Failed to join pool: ${e.message}`)
|
||||||
}
|
}
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
@ -614,7 +614,7 @@ export class Pool extends PoolFactory {
|
|||||||
.exitPool(this.web3.utils.toWei(poolAmountIn), weiMinAmountsOut)
|
.exitPool(this.web3.utils.toWei(poolAmountIn), weiMinAmountsOut)
|
||||||
.send({ from: account, gas: this.GASLIMIT_DEFAULT })
|
.send({ from: account, gas: this.GASLIMIT_DEFAULT })
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error(e)
|
console.error(`ERROR: Failed to exit pool: ${e.message}`)
|
||||||
}
|
}
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
@ -648,7 +648,7 @@ export class Pool extends PoolFactory {
|
|||||||
)
|
)
|
||||||
.send({ from: account, gas: this.GASLIMIT_DEFAULT })
|
.send({ from: account, gas: this.GASLIMIT_DEFAULT })
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error(e)
|
console.error(`ERROR: Failed to pay tokens in order to join the pool: ${e.message}`)
|
||||||
}
|
}
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
@ -682,7 +682,7 @@ export class Pool extends PoolFactory {
|
|||||||
)
|
)
|
||||||
.send({ from: account, gas: this.GASLIMIT_DEFAULT })
|
.send({ from: account, gas: this.GASLIMIT_DEFAULT })
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error(e)
|
console.error('ERROR: Failed to join swap pool amount out')
|
||||||
}
|
}
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
@ -716,7 +716,7 @@ export class Pool extends PoolFactory {
|
|||||||
)
|
)
|
||||||
.send({ from: account, gas: this.GASLIMIT_DEFAULT })
|
.send({ from: account, gas: this.GASLIMIT_DEFAULT })
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error(e)
|
console.error(`ERROR: Failed to pay pool shares into the pool: ${e.message}`)
|
||||||
}
|
}
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
@ -750,7 +750,7 @@ export class Pool extends PoolFactory {
|
|||||||
)
|
)
|
||||||
.send({ from: account, gas: this.GASLIMIT_DEFAULT })
|
.send({ from: account, gas: this.GASLIMIT_DEFAULT })
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error(e)
|
console.error(`ERROR: Failed to specify token amount out that will get out of the pool. ${e.message}`)
|
||||||
}
|
}
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
@ -773,7 +773,7 @@ export class Pool extends PoolFactory {
|
|||||||
const result = await pool.methods.getSpotPrice(tokenIn, tokenOut).call()
|
const result = await pool.methods.getSpotPrice(tokenIn, tokenOut).call()
|
||||||
price = this.web3.utils.fromWei(result)
|
price = this.web3.utils.fromWei(result)
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error(e)
|
console.error('ERROR: Failed to get spot price of swapping tokenIn to tokenOut')
|
||||||
}
|
}
|
||||||
return price
|
return price
|
||||||
}
|
}
|
||||||
@ -796,7 +796,7 @@ export class Pool extends PoolFactory {
|
|||||||
const result = await pool.methods.getSpotPriceSansFee(tokenIn, tokenOut).call()
|
const result = await pool.methods.getSpotPriceSansFee(tokenIn, tokenOut).call()
|
||||||
price = this.web3.utils.fromWei(result)
|
price = this.web3.utils.fromWei(result)
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error(e)
|
console.error(`ERROR: Failed to get spot price of swapping tokenIn to tokenOut without fees: ${e.message}`)
|
||||||
}
|
}
|
||||||
return price
|
return price
|
||||||
}
|
}
|
||||||
@ -825,7 +825,7 @@ export class Pool extends PoolFactory {
|
|||||||
.call()
|
.call()
|
||||||
amount = this.web3.utils.fromWei(result)
|
amount = this.web3.utils.fromWei(result)
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error(e)
|
console.error(`ERROR: Failed to calculate input token-pair amount giving output token-pair amount: ${e.message}`)
|
||||||
}
|
}
|
||||||
return amount
|
return amount
|
||||||
}
|
}
|
||||||
@ -854,7 +854,7 @@ export class Pool extends PoolFactory {
|
|||||||
.call()
|
.call()
|
||||||
amount = this.web3.utils.fromWei(result)
|
amount = this.web3.utils.fromWei(result)
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error(e)
|
console.error(`ERROR: Failed to calculate output token-pair amount giving the input token-pair amount : ${e.message}`)
|
||||||
}
|
}
|
||||||
return amount
|
return amount
|
||||||
}
|
}
|
||||||
@ -883,7 +883,7 @@ export class Pool extends PoolFactory {
|
|||||||
.call()
|
.call()
|
||||||
amount = this.web3.utils.fromWei(result)
|
amount = this.web3.utils.fromWei(result)
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error(e)
|
console.error(`ERROR: Failed to calculate PoolOutGivenSingleIn : ${e.message}`)
|
||||||
}
|
}
|
||||||
return amount
|
return amount
|
||||||
}
|
}
|
||||||
@ -912,7 +912,7 @@ export class Pool extends PoolFactory {
|
|||||||
.call()
|
.call()
|
||||||
amount = this.web3.utils.fromWei(result)
|
amount = this.web3.utils.fromWei(result)
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error(e)
|
console.error(`ERROR: Failed to calculate SingleInGivenPoolOut : ${e.message}`)
|
||||||
}
|
}
|
||||||
return amount
|
return amount
|
||||||
}
|
}
|
||||||
@ -941,7 +941,7 @@ export class Pool extends PoolFactory {
|
|||||||
.call()
|
.call()
|
||||||
amount = this.web3.utils.fromWei(result)
|
amount = this.web3.utils.fromWei(result)
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error(e)
|
console.error(`ERROR: Failed to calculate SingleOutGivenPoolIn : ${e.message}`)
|
||||||
}
|
}
|
||||||
return amount
|
return amount
|
||||||
}
|
}
|
||||||
@ -970,7 +970,7 @@ export class Pool extends PoolFactory {
|
|||||||
.call()
|
.call()
|
||||||
amount = this.web3.utils.fromWei(result)
|
amount = this.web3.utils.fromWei(result)
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error(e)
|
console.error(`ERROR: Failed to calculate PoolInGivenSingleOut : ${e.message}`)
|
||||||
}
|
}
|
||||||
return amount
|
return amount
|
||||||
}
|
}
|
||||||
|
@ -29,12 +29,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('Web3 object is null')
|
console.error('ERROR: Web3 object is null')
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.factoryAddress === null) {
|
if (this.factoryAddress === null) {
|
||||||
console.error('bfactoryAddress is null')
|
console.error('ERROR: bfactoryAddress is null')
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -51,7 +51,7 @@ export class PoolFactory {
|
|||||||
try {
|
try {
|
||||||
pooladdress = transactiondata.events.BPoolRegistered.returnValues[0]
|
pooladdress = transactiondata.events.BPoolRegistered.returnValues[0]
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error(e)
|
console.error(`ERROR: Failed to create new pool: ${e.message}`)
|
||||||
}
|
}
|
||||||
return pooladdress
|
return pooladdress
|
||||||
}
|
}
|
||||||
|
@ -92,7 +92,7 @@ export class DataTokens {
|
|||||||
const estGas = await factory.methods
|
const estGas = await factory.methods
|
||||||
.createToken(metadataCacheUri, name, symbol, this.web3.utils.toWei(cap))
|
.createToken(metadataCacheUri, name, symbol, this.web3.utils.toWei(cap))
|
||||||
.estimateGas(function (err: string, estGas: string) {
|
.estimateGas(function (err: string, estGas: string) {
|
||||||
if (err) console.log('Datatokens: ' + err)
|
if (err) console.error(`ERROR: Datatokens : ${err}`)
|
||||||
return estGas
|
return estGas
|
||||||
})
|
})
|
||||||
// Invoke createToken function of the contract
|
// Invoke createToken function of the contract
|
||||||
@ -108,7 +108,7 @@ export class DataTokens {
|
|||||||
try {
|
try {
|
||||||
tokenAddress = trxReceipt.events.TokenCreated.returnValues[0]
|
tokenAddress = trxReceipt.events.TokenCreated.returnValues[0]
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error(e)
|
console.error(`ERROR: Failed to create datatoken : ${e.message}`)
|
||||||
}
|
}
|
||||||
return tokenAddress
|
return tokenAddress
|
||||||
}
|
}
|
||||||
@ -157,7 +157,7 @@ export class DataTokens {
|
|||||||
const estGas = await datatoken.methods
|
const estGas = await datatoken.methods
|
||||||
.mint(destAddress, this.web3.utils.toWei(amount))
|
.mint(destAddress, this.web3.utils.toWei(amount))
|
||||||
.estimateGas(function (err, estGas) {
|
.estimateGas(function (err, estGas) {
|
||||||
if (err) console.log('Datatokens: ' + err)
|
if (err) console.error(`ERROR: Datatokens : ${err}`)
|
||||||
return estGas
|
return estGas
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -373,7 +373,7 @@ export class DataTokens {
|
|||||||
.send({ from: address, gas: 600000 })
|
.send({ from: address, gas: 600000 })
|
||||||
return trxReceipt
|
return trxReceipt
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error(e)
|
console.error(`ERROR: Failed to start order : ${e.message}`)
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -91,7 +91,7 @@ export class OceanFixedRateExchange {
|
|||||||
})
|
})
|
||||||
exchangeId = trxReceipt.events.ExchangeCreated.returnValues[0]
|
exchangeId = trxReceipt.events.ExchangeCreated.returnValues[0]
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error(e)
|
console.error(`ERROR: Failed to create new exchange: ${e.message}`)
|
||||||
}
|
}
|
||||||
return exchangeId
|
return exchangeId
|
||||||
}
|
}
|
||||||
@ -144,7 +144,7 @@ export class OceanFixedRateExchange {
|
|||||||
})
|
})
|
||||||
return trxReceipt
|
return trxReceipt
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error(e)
|
console.error(`ERROR: Failed to buy datatokens: ${e.message}`)
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -178,7 +178,7 @@ export class OceanFixedRateExchange {
|
|||||||
.setRate(exchangeId, this.web3.utils.toWei(String(newRate)))
|
.setRate(exchangeId, this.web3.utils.toWei(String(newRate)))
|
||||||
.estimateGas(function (err, estGas) {
|
.estimateGas(function (err, estGas) {
|
||||||
if (err) {
|
if (err) {
|
||||||
// console.log('FixedPriceExchange: ' + err)
|
console.error(`ERROR: FixedPriceExchange: ${err.message}`)
|
||||||
return DEFAULT_GAS_LIMIT
|
return DEFAULT_GAS_LIMIT
|
||||||
}
|
}
|
||||||
return estGas
|
return estGas
|
||||||
@ -214,7 +214,7 @@ export class OceanFixedRateExchange {
|
|||||||
.toggleExchangeState(exchangeId)
|
.toggleExchangeState(exchangeId)
|
||||||
.estimateGas(function (err, estGas) {
|
.estimateGas(function (err, estGas) {
|
||||||
if (err) {
|
if (err) {
|
||||||
// console.log('FixedPriceExchange: ' + err)
|
console.error(`ERROR: FixedPriceExchange: ${err.message}`)
|
||||||
estGas = DEFAULT_GAS_LIMIT
|
estGas = DEFAULT_GAS_LIMIT
|
||||||
}
|
}
|
||||||
return estGas
|
return estGas
|
||||||
@ -248,7 +248,7 @@ export class OceanFixedRateExchange {
|
|||||||
.toggleExchangeState(exchangeId)
|
.toggleExchangeState(exchangeId)
|
||||||
.estimateGas(function (err, estGas) {
|
.estimateGas(function (err, estGas) {
|
||||||
if (err) {
|
if (err) {
|
||||||
// console.log('FixedPriceExchange: ' + err)
|
console.error(`ERROR: FixedPriceExchange: ${err.message}`)
|
||||||
estGas = DEFAULT_GAS_LIMIT
|
estGas = DEFAULT_GAS_LIMIT
|
||||||
}
|
}
|
||||||
return estGas
|
return estGas
|
||||||
|
@ -100,14 +100,14 @@ export class OnChainMetadataCache {
|
|||||||
consumerAccount: string
|
consumerAccount: string
|
||||||
): Promise<TransactionReceipt> {
|
): Promise<TransactionReceipt> {
|
||||||
if (!this.DDOContract) {
|
if (!this.DDOContract) {
|
||||||
console.error('Missing DDOContract')
|
console.error('ERROR: Missing DDOContract')
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
/* const estGas = await this.DDOContract.methods
|
/* const estGas = await this.DDOContract.methods
|
||||||
.create(didZeroX(did), flags, data)
|
.create(didZeroX(did), flags, data)
|
||||||
.estimateGas(function (err, estGas) {
|
.estimateGas(function (err, estGas) {
|
||||||
if (err) console.log('OnChainMetadataCacheEstimateGas: ' + err)
|
if (err) console.error('ERROR: OnChainMetadataCacheEstimateGas: ' + err)
|
||||||
return estGas
|
return estGas
|
||||||
})
|
})
|
||||||
*/
|
*/
|
||||||
@ -116,7 +116,7 @@ export class OnChainMetadataCache {
|
|||||||
.send({ from: consumerAccount })
|
.send({ from: consumerAccount })
|
||||||
return trxReceipt
|
return trxReceipt
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error(e.message)
|
console.error(`ERROR: Failed to publish raw DDO : ${e.message}`)
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -136,7 +136,7 @@ export class OnChainMetadataCache {
|
|||||||
consumerAccount: string
|
consumerAccount: string
|
||||||
): Promise<TransactionReceipt> {
|
): Promise<TransactionReceipt> {
|
||||||
if (!this.DDOContract) {
|
if (!this.DDOContract) {
|
||||||
console.error('Missing DDOContract')
|
console.error('ERROR: Missing DDOContract')
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
@ -145,7 +145,7 @@ export class OnChainMetadataCache {
|
|||||||
.send({ from: consumerAccount })
|
.send({ from: consumerAccount })
|
||||||
return trxReceipt
|
return trxReceipt
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error(e)
|
console.error(`ERROR: Failed to update raw DDO : ${e.message}`)
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -171,7 +171,7 @@ export class OnChainMetadataCache {
|
|||||||
})
|
})
|
||||||
return trxReceipt
|
return trxReceipt
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error(e)
|
console.error(`ERROR: Failed to transfer DDO ownership : ${e.message}`)
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -201,7 +201,7 @@ export class OnChainMetadataCache {
|
|||||||
hex += '' + hexChar[(message[i] >> 4) & 0x0f] + hexChar[message[i] & 0x0f]
|
hex += '' + hexChar[(message[i] >> 4) & 0x0f] + hexChar[message[i] & 0x0f]
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error(e)
|
console.error(`ERROR: Failed to get hex message value : ${e.message}`)
|
||||||
}
|
}
|
||||||
const hexMessage = '0x' + hex
|
const hexMessage = '0x' + hex
|
||||||
return hexMessage
|
return hexMessage
|
||||||
|
@ -111,7 +111,7 @@ export default class Account extends Instantiable {
|
|||||||
})
|
})
|
||||||
result = this.web3.utils.fromWei(await token.methods.balanceOf(this.id).call())
|
result = this.web3.utils.fromWei(await token.methods.balanceOf(this.id).call())
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error(e)
|
console.error(`ERROR: Failed to get the balance: ${e.message}`)
|
||||||
}
|
}
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
@ -498,7 +498,7 @@ export class Assets extends Instantiable {
|
|||||||
const totalCost = new BigNumber(String(providerData.numTokens))
|
const totalCost = new BigNumber(String(providerData.numTokens))
|
||||||
if (balance.isLessThan(totalCost)) {
|
if (balance.isLessThan(totalCost)) {
|
||||||
console.error(
|
console.error(
|
||||||
'Not enough funds. Needed ' +
|
'ERROR: Not enough funds Needed ' +
|
||||||
totalCost.toString() +
|
totalCost.toString() +
|
||||||
' but balance is ' +
|
' but balance is ' +
|
||||||
balance.toString()
|
balance.toString()
|
||||||
@ -515,7 +515,7 @@ export class Assets extends Instantiable {
|
|||||||
)
|
)
|
||||||
if (txid) return txid.transactionHash
|
if (txid) return txid.transactionHash
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error(e)
|
console.error(`ERROR: Failed to order: ${e.message}`)
|
||||||
}
|
}
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
@ -572,7 +572,6 @@ export class Assets extends Instantiable {
|
|||||||
consumeUrl += `&tokenAddress=${dtAddress}`
|
consumeUrl += `&tokenAddress=${dtAddress}`
|
||||||
consumeUrl += `&transferTxId=${txId}`
|
consumeUrl += `&transferTxId=${txId}`
|
||||||
const serviceConnector = new WebServiceConnector(this.logger)
|
const serviceConnector = new WebServiceConnector(this.logger)
|
||||||
console.log(consumeUrl)
|
|
||||||
try {
|
try {
|
||||||
await serviceConnector.downloadFile(consumeUrl)
|
await serviceConnector.downloadFile(consumeUrl)
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
@ -580,7 +579,6 @@ export class Assets extends Instantiable {
|
|||||||
this.logger.error(e)
|
this.logger.error(e)
|
||||||
throw e
|
throw e
|
||||||
}
|
}
|
||||||
|
|
||||||
return serviceEndpoint
|
return serviceEndpoint
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -395,7 +395,7 @@ export class Compute extends Instantiable {
|
|||||||
// check if raw algo is allowed
|
// check if raw algo is allowed
|
||||||
if (service.attributes.main.privacy)
|
if (service.attributes.main.privacy)
|
||||||
if (!service.attributes.main.privacy.allowRawAlgorithm) {
|
if (!service.attributes.main.privacy.allowRawAlgorithm) {
|
||||||
console.error('This service does not allow Raw Algo')
|
console.error('ERROR: This service does not allow raw algorithm')
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -407,7 +407,7 @@ export class Compute extends Instantiable {
|
|||||||
if (
|
if (
|
||||||
!service.attributes.main.privacy.trustedAlgorithms.includes(algorithmDid)
|
!service.attributes.main.privacy.trustedAlgorithms.includes(algorithmDid)
|
||||||
) {
|
) {
|
||||||
console.error('This service does not allow this Algo')
|
console.error('ERROR: This service does not allow this algorithm')
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -91,7 +91,7 @@ export class ConfigHelper {
|
|||||||
|
|
||||||
return configAddresses
|
return configAddresses
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error(`Could not load local contract address file: ${e.message}`)
|
console.error(`ERROR: Could not load local contract address file: ${e.message}`)
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user