mirror of
https://github.com/oceanprotocol/ocean.js.git
synced 2024-11-26 20:39:05 +01:00
Merge pull request #320 from oceanprotocol/fix/asset-create
Fix asset create
This commit is contained in:
commit
af69f097b8
@ -70,18 +70,18 @@ export class Assets extends Instantiable {
|
||||
symbol?: string,
|
||||
providerUri?: string
|
||||
): SubscribablePromise<CreateProgressStep, DDO> {
|
||||
if (!isAddress(dtAddress)) {
|
||||
if (dtAddress && !isAddress(dtAddress)) {
|
||||
this.logger.error(
|
||||
`Passed Data Token address ${dtAddress} is not valid. Aborting publishing.`
|
||||
)
|
||||
return null
|
||||
}
|
||||
|
||||
this.logger.log('Creating asset')
|
||||
return new SubscribablePromise(async (observer) => {
|
||||
if (services.length === 0) {
|
||||
this.logger.log('You have no services. Are you sure about this?')
|
||||
}
|
||||
|
||||
if (!dtAddress) {
|
||||
this.logger.log('Creating datatoken')
|
||||
observer.next(CreateProgressStep.CreatingDataToken)
|
||||
@ -394,7 +394,7 @@ export class Assets extends Instantiable {
|
||||
/**
|
||||
* Creates an access service
|
||||
* @param {Account} creator
|
||||
* @param {String} cost number of datatokens needed for this service, expressed in wei
|
||||
* @param {String} cost number of datatokens needed for this service
|
||||
* @param {String} datePublished
|
||||
* @param {Number} timeout
|
||||
* @return {Promise<string>} service
|
||||
@ -495,7 +495,7 @@ export class Assets extends Instantiable {
|
||||
await datatokens.balance(providerData.dataToken, consumerAddress)
|
||||
)
|
||||
const totalCost = new BigNumber(String(providerData.numTokens))
|
||||
if (balance.isLessThanOrEqualTo(totalCost)) {
|
||||
if (balance.isLessThan(totalCost)) {
|
||||
console.error(
|
||||
'Not enough funds. Needed ' +
|
||||
totalCost.toString() +
|
||||
|
@ -1,15 +1,15 @@
|
||||
import { AbiItem } from 'web3-utils/types'
|
||||
import datatokensTemplate from '@oceanprotocol/contracts/artifacts/DataTokenTemplate.json'
|
||||
import factory from '@oceanprotocol/contracts/artifacts/DTFactory.json'
|
||||
import { assert, spy, use } from 'chai'
|
||||
import spies from 'chai-spies'
|
||||
import { TestContractHandler } from '../TestContractHandler'
|
||||
import Web3 from 'web3'
|
||||
import { AbiItem } from 'web3-utils/types'
|
||||
import { DataTokens } from '../../src/datatokens/Datatokens'
|
||||
import { Account, EditableMetadata, ServiceAccess, ServiceCommon } from '../../src/lib'
|
||||
import { Ocean } from '../../src/ocean/Ocean'
|
||||
import { ConfigHelper } from '../../src/utils/ConfigHelper'
|
||||
import { TestContractHandler } from '../TestContractHandler'
|
||||
|
||||
import Web3 from 'web3'
|
||||
import factory from '@oceanprotocol/contracts/artifacts/DTFactory.json'
|
||||
import datatokensTemplate from '@oceanprotocol/contracts/artifacts/DataTokenTemplate.json'
|
||||
import { Account, EditableMetadata, ServiceAccess, ServiceCommon } from '../../src/lib'
|
||||
const web3 = new Web3('http://127.0.0.1:8545')
|
||||
|
||||
function sleep(ms: number) {
|
||||
@ -248,7 +248,7 @@ describe('Marketplace flow', () => {
|
||||
timeout
|
||||
)
|
||||
|
||||
spy.on(datatoken, 'create', () => null)
|
||||
spy.on(ocean.datatokens, 'create', () => Promise.resolve(null))
|
||||
ddo = await ocean.assets.create(asset, alice, [service1])
|
||||
assert.equal(ddo, null)
|
||||
})
|
||||
|
Loading…
x
Reference in New Issue
Block a user