mirror of
https://github.com/oceanprotocol/ocean.js.git
synced 2024-11-26 20:39:05 +01:00
fix error messages
This commit is contained in:
parent
b01908a7bd
commit
ca733f2a06
@ -1,9 +1,9 @@
|
|||||||
|
import { Logger } from '../utils'
|
||||||
import defaultFixedRateExchangeABI from '@oceanprotocol/contracts/artifacts/FixedRateExchange.json'
|
import defaultFixedRateExchangeABI from '@oceanprotocol/contracts/artifacts/FixedRateExchange.json'
|
||||||
import BigNumber from 'bignumber.js'
|
import BigNumber from 'bignumber.js'
|
||||||
import { TransactionReceipt } from 'web3-core'
|
import { TransactionReceipt } from 'web3-core'
|
||||||
import { Contract, EventData } from 'web3-eth-contract'
|
import { Contract, EventData } from 'web3-eth-contract'
|
||||||
import { AbiItem } from 'web3-utils/types'
|
import { AbiItem } from 'web3-utils/types'
|
||||||
import { Logger } from '../utils'
|
|
||||||
import Web3 from 'web3'
|
import Web3 from 'web3'
|
||||||
|
|
||||||
export interface FixedPriceExchange {
|
export interface FixedPriceExchange {
|
||||||
@ -42,10 +42,10 @@ export class OceanFixedRateExchange {
|
|||||||
*/
|
*/
|
||||||
constructor(
|
constructor(
|
||||||
web3: Web3,
|
web3: Web3,
|
||||||
|
logger: Logger,
|
||||||
fixedRateExchangeAddress: string = null,
|
fixedRateExchangeAddress: string = null,
|
||||||
fixedRateExchangeABI: AbiItem | AbiItem[] = null,
|
fixedRateExchangeABI: AbiItem | AbiItem[] = null,
|
||||||
oceanAddress: string = null,
|
oceanAddress: string = null
|
||||||
logger: Logger
|
|
||||||
) {
|
) {
|
||||||
this.web3 = web3
|
this.web3 = web3
|
||||||
this.fixedRateExchangeAddress = fixedRateExchangeAddress
|
this.fixedRateExchangeAddress = fixedRateExchangeAddress
|
||||||
@ -182,7 +182,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) {
|
||||||
this.logger.error(`ERROR: FixedPriceExchange: ${err.message}`)
|
console.error(`ERROR: FixedPriceExchange: ${err.message}`)
|
||||||
return DEFAULT_GAS_LIMIT
|
return DEFAULT_GAS_LIMIT
|
||||||
}
|
}
|
||||||
return estGas
|
return estGas
|
||||||
@ -218,12 +218,13 @@ export class OceanFixedRateExchange {
|
|||||||
.toggleExchangeState(exchangeId)
|
.toggleExchangeState(exchangeId)
|
||||||
.estimateGas(function (err, estGas) {
|
.estimateGas(function (err, estGas) {
|
||||||
if (err) {
|
if (err) {
|
||||||
this.logger.error(`ERROR: FixedPriceExchange: ${err.message}`)
|
console.error(`ERROR: FixedPriceExchange: ${err.message}`)
|
||||||
estGas = DEFAULT_GAS_LIMIT
|
estGas = DEFAULT_GAS_LIMIT
|
||||||
}
|
}
|
||||||
return estGas
|
return estGas
|
||||||
})
|
})
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
this.logger.error(`ERROR: FixedPriceExchange: ${e.message}`)
|
||||||
estGas = DEFAULT_GAS_LIMIT
|
estGas = DEFAULT_GAS_LIMIT
|
||||||
}
|
}
|
||||||
const trxReceipt = await this.contract.methods.toggleExchangeState(exchangeId).send({
|
const trxReceipt = await this.contract.methods.toggleExchangeState(exchangeId).send({
|
||||||
@ -252,12 +253,13 @@ export class OceanFixedRateExchange {
|
|||||||
.toggleExchangeState(exchangeId)
|
.toggleExchangeState(exchangeId)
|
||||||
.estimateGas(function (err, estGas) {
|
.estimateGas(function (err, estGas) {
|
||||||
if (err) {
|
if (err) {
|
||||||
this.logger.error(`ERROR: FixedPriceExchange: ${err.message}`)
|
console.error(`ERROR: FixedPriceExchange: ${err.message}`)
|
||||||
estGas = DEFAULT_GAS_LIMIT
|
estGas = DEFAULT_GAS_LIMIT
|
||||||
}
|
}
|
||||||
return estGas
|
return estGas
|
||||||
})
|
})
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
this.logger.error(`ERROR: FixedPriceExchange: ${e.message}`)
|
||||||
estGas = DEFAULT_GAS_LIMIT
|
estGas = DEFAULT_GAS_LIMIT
|
||||||
}
|
}
|
||||||
const trxReceipt = await this.contract.methods.toggleExchangeState(exchangeId).send({
|
const trxReceipt = await this.contract.methods.toggleExchangeState(exchangeId).send({
|
||||||
|
@ -61,10 +61,10 @@ export class Ocean extends Instantiable {
|
|||||||
)
|
)
|
||||||
instance.fixedRateExchange = new OceanFixedRateExchange(
|
instance.fixedRateExchange = new OceanFixedRateExchange(
|
||||||
instanceConfig.config.web3Provider,
|
instanceConfig.config.web3Provider,
|
||||||
|
instanceConfig.logger,
|
||||||
instanceConfig.config.fixedRateExchangeAddress,
|
instanceConfig.config.fixedRateExchangeAddress,
|
||||||
instanceConfig.config.fixedRateExchangeAddressABI,
|
instanceConfig.config.fixedRateExchangeAddressABI,
|
||||||
instanceConfig.config.oceanTokenAddress,
|
instanceConfig.config.oceanTokenAddress
|
||||||
instanceConfig.logger
|
|
||||||
)
|
)
|
||||||
instance.OnChainMetadataCache = new OnChainMetadataCache(
|
instance.OnChainMetadataCache = new OnChainMetadataCache(
|
||||||
instanceConfig.config.web3Provider,
|
instanceConfig.config.web3Provider,
|
||||||
|
@ -4,7 +4,7 @@ import { TestContractHandler } from '../../TestContractHandler'
|
|||||||
import { FixedPricedContractHandler } from '../../FixedPriceContractHandler'
|
import { FixedPricedContractHandler } from '../../FixedPriceContractHandler'
|
||||||
import { DataTokens } from '../../../src/datatokens/Datatokens'
|
import { DataTokens } from '../../../src/datatokens/Datatokens'
|
||||||
import { OceanFixedRateExchange } from '../../../src/exchange/FixedRateExchange'
|
import { OceanFixedRateExchange } from '../../../src/exchange/FixedRateExchange'
|
||||||
import { Logger } from '../../../src/utils'
|
import { LoggerInstance } from '../../../src/utils'
|
||||||
import Web3 from 'web3'
|
import Web3 from 'web3'
|
||||||
import factory from '@oceanprotocol/contracts/artifacts/DTFactory.json'
|
import factory from '@oceanprotocol/contracts/artifacts/DTFactory.json'
|
||||||
import datatokensTemplate from '@oceanprotocol/contracts/artifacts/DataTokenTemplate.json'
|
import datatokensTemplate from '@oceanprotocol/contracts/artifacts/DataTokenTemplate.json'
|
||||||
@ -105,10 +105,10 @@ describe('FixedRateExchange flow', () => {
|
|||||||
it('should initialize FixedExchangeRate class', async () => {
|
it('should initialize FixedExchangeRate class', async () => {
|
||||||
FixedRateClass = new OceanFixedRateExchange(
|
FixedRateClass = new OceanFixedRateExchange(
|
||||||
web3,
|
web3,
|
||||||
|
LoggerInstance,
|
||||||
FixedRateExchangeAddress,
|
FixedRateExchangeAddress,
|
||||||
FixedRateExchangeContract.abi as AbiItem[],
|
FixedRateExchangeContract.abi as AbiItem[],
|
||||||
oceanTokenAddress,
|
oceanTokenAddress
|
||||||
new Logger()
|
|
||||||
)
|
)
|
||||||
assert(FixedRateClass !== null)
|
assert(FixedRateClass !== null)
|
||||||
})
|
})
|
||||||
@ -208,6 +208,7 @@ describe('FixedRateExchange flow', () => {
|
|||||||
if (consoleDebug) console.log('Bob ocean balance:' + balance)
|
if (consoleDebug) console.log('Bob ocean balance:' + balance)
|
||||||
})
|
})
|
||||||
it('Alice should update the rate', async () => {
|
it('Alice should update the rate', async () => {
|
||||||
|
// console.log(await FixedRateClass.getLogger())
|
||||||
const tx = await FixedRateClass.setRate(aliceExchangeId, updatedPriceRate, alice)
|
const tx = await FixedRateClass.setRate(aliceExchangeId, updatedPriceRate, alice)
|
||||||
assert(tx !== null)
|
assert(tx !== null)
|
||||||
})
|
})
|
||||||
|
Loading…
x
Reference in New Issue
Block a user