mirror of
https://github.com/oceanprotocol/ocean.js.git
synced 2024-11-26 20:39:05 +01:00
fix DataTokens
This commit is contained in:
parent
b0ef8d7262
commit
c4d6b48896
@ -3,7 +3,7 @@ import { AbiItem } from 'web3-utils/types'
|
||||
|
||||
import defaultFactoryABI from '@oceanprotocol/contracts/artifacts/DTFactory.json'
|
||||
import defaultDatatokensABI from '@oceanprotocol/contracts/artifacts/DataTokenTemplate.json'
|
||||
|
||||
import { Logger } from '../utils'
|
||||
import wordListDefault from '../data/words.json'
|
||||
import { TransactionReceipt } from 'web3-core'
|
||||
import BigNumber from 'bignumber.js'
|
||||
@ -16,7 +16,7 @@ export class DataTokens {
|
||||
public factoryABI: AbiItem | AbiItem[]
|
||||
public datatokensABI: AbiItem | AbiItem[]
|
||||
public web3: Web3
|
||||
|
||||
private logger: Logger
|
||||
/**
|
||||
* Instantiate DataTokens (independently of Ocean).
|
||||
* @param {String} factoryAddress
|
||||
@ -28,12 +28,14 @@ export class DataTokens {
|
||||
factoryAddress: string,
|
||||
factoryABI: AbiItem | AbiItem[],
|
||||
datatokensABI: AbiItem | AbiItem[],
|
||||
web3: Web3
|
||||
web3: Web3,
|
||||
logger: Logger
|
||||
) {
|
||||
this.factoryAddress = factoryAddress
|
||||
this.factoryABI = factoryABI || (defaultFactoryABI.abi as AbiItem[])
|
||||
this.datatokensABI = datatokensABI || (defaultDatatokensABI.abi as AbiItem[])
|
||||
this.web3 = web3
|
||||
this.logger = logger
|
||||
}
|
||||
|
||||
/**
|
||||
@ -108,7 +110,7 @@ export class DataTokens {
|
||||
try {
|
||||
tokenAddress = trxReceipt.events.TokenCreated.returnValues[0]
|
||||
} catch (e) {
|
||||
console.error(`ERROR: Failed to create datatoken : ${e.message}`)
|
||||
this.logger.error(`ERROR: Failed to create datatoken : ${e.message}`)
|
||||
}
|
||||
return tokenAddress
|
||||
}
|
||||
@ -373,7 +375,7 @@ export class DataTokens {
|
||||
.send({ from: address, gas: 600000 })
|
||||
return trxReceipt
|
||||
} catch (e) {
|
||||
console.error(`ERROR: Failed to start order : ${e.message}`)
|
||||
this.logger.error(`ERROR: Failed to start order : ${e.message}`)
|
||||
return null
|
||||
}
|
||||
}
|
||||
|
@ -50,7 +50,8 @@ export class Ocean extends Instantiable {
|
||||
instanceConfig.config.factoryAddress,
|
||||
instanceConfig.config.factoryABI,
|
||||
instanceConfig.config.datatokensABI,
|
||||
instanceConfig.config.web3Provider
|
||||
instanceConfig.config.web3Provider,
|
||||
instanceConfig.logger
|
||||
)
|
||||
instance.pool = new OceanPool(
|
||||
instanceConfig.config.web3Provider,
|
||||
|
@ -2,7 +2,7 @@ import { assert } from 'chai'
|
||||
import { AbiItem } from 'web3-utils/types'
|
||||
import { TestContractHandler } from '../TestContractHandler'
|
||||
import { DataTokens } from '../../src/datatokens/Datatokens'
|
||||
|
||||
import { LoggerInstance } from '../../src/utils'
|
||||
import Web3 from 'web3'
|
||||
import factory from '@oceanprotocol/contracts/artifacts/DTFactory.json'
|
||||
import datatokensTemplate from '@oceanprotocol/contracts/artifacts/DataTokenTemplate.json'
|
||||
@ -38,7 +38,8 @@ describe('DataTokens', () => {
|
||||
contracts.factoryAddress,
|
||||
factory.abi as AbiItem[],
|
||||
datatokensTemplate.abi as AbiItem[],
|
||||
web3
|
||||
web3,
|
||||
LoggerInstance
|
||||
)
|
||||
assert(datatoken !== null)
|
||||
})
|
||||
|
@ -75,7 +75,8 @@ describe('Balancer flow', () => {
|
||||
contracts.factoryAddress,
|
||||
factory.abi as AbiItem[],
|
||||
datatokensTemplate.abi as AbiItem[],
|
||||
web3
|
||||
web3,
|
||||
LoggerInstance
|
||||
)
|
||||
assert(datatoken !== null)
|
||||
})
|
||||
@ -90,7 +91,8 @@ describe('Balancer flow', () => {
|
||||
contracts.factoryAddress,
|
||||
factory.abi as AbiItem[],
|
||||
datatokensTemplate.abi as AbiItem[],
|
||||
web3
|
||||
web3,
|
||||
LoggerInstance
|
||||
)
|
||||
oceanTokenAddress = await oceandatatoken.create(
|
||||
blob,
|
||||
|
@ -10,6 +10,7 @@ import factory from '@oceanprotocol/contracts/artifacts/DTFactory.json'
|
||||
import datatokensTemplate from '@oceanprotocol/contracts/artifacts/DataTokenTemplate.json'
|
||||
|
||||
import FixedRateExchangeContract = require('@oceanprotocol/contracts/artifacts/FixedRateExchange.json')
|
||||
import { Logger } from '../../../src/lib'
|
||||
const web3 = new Web3('http://127.0.0.1:8545')
|
||||
|
||||
describe('FixedRateExchange flow', () => {
|
||||
@ -66,7 +67,8 @@ describe('FixedRateExchange flow', () => {
|
||||
contracts.factoryAddress,
|
||||
factory.abi as AbiItem[],
|
||||
datatokensTemplate.abi as AbiItem[],
|
||||
web3
|
||||
web3,
|
||||
LoggerInstance
|
||||
)
|
||||
assert(datatoken !== null)
|
||||
})
|
||||
@ -89,7 +91,8 @@ describe('FixedRateExchange flow', () => {
|
||||
contracts.factoryAddress,
|
||||
factory.abi as AbiItem[],
|
||||
datatokensTemplate.abi as AbiItem[],
|
||||
web3
|
||||
web3,
|
||||
LoggerInstance
|
||||
)
|
||||
oceanTokenAddress = await oceandatatoken.create(
|
||||
blob,
|
||||
@ -208,7 +211,6 @@ describe('FixedRateExchange flow', () => {
|
||||
if (consoleDebug) console.log('Bob ocean balance:' + balance)
|
||||
})
|
||||
it('Alice should update the rate', async () => {
|
||||
// console.log(await FixedRateClass.getLogger())
|
||||
const tx = await FixedRateClass.setRate(aliceExchangeId, updatedPriceRate, alice)
|
||||
assert(tx !== null)
|
||||
})
|
||||
|
Loading…
x
Reference in New Issue
Block a user