diff --git a/src/datatokens/Datatokens.ts b/src/datatokens/Datatokens.ts index 22f7fb00..cde50a1c 100644 --- a/src/datatokens/Datatokens.ts +++ b/src/datatokens/Datatokens.ts @@ -119,14 +119,14 @@ export class DataTokens { * @param {String} toAddress * @param {string} amount Number of datatokens, as number. Will be converted to wei * @param {String} address - * @return {Promise} transactionId + * @return {Promise} transactionId */ public async approve( dataTokenAddress: string, spender: string, amount: string, address: string - ): Promise { + ): Promise { const datatoken = new this.web3.eth.Contract(this.datatokensABI, dataTokenAddress, { from: address }) @@ -142,14 +142,14 @@ export class DataTokens { * @param {String} address * @param {String} amount Number of datatokens, as number. Will be converted to wei * @param {String} toAddress - only if toAddress is different from the minter - * @return {Promise} transactionId + * @return {Promise} transactionId */ public async mint( dataTokenAddress: string, address: string, amount: string, toAddress?: string - ): Promise { + ): Promise { const destAddress = toAddress || address const datatoken = new this.web3.eth.Contract(this.datatokensABI, dataTokenAddress, { from: address @@ -178,14 +178,14 @@ export class DataTokens { * @param {String} toAddress * @param {String} amount Number of datatokens, as number. Will be converted to wei * @param {String} address - * @return {Promise} transactionId + * @return {Promise} transactionId */ public async transfer( dataTokenAddress: string, toAddress: string, amount: string, address: string - ): Promise { + ): Promise { return this.transferToken(dataTokenAddress, toAddress, amount, address) } @@ -195,14 +195,14 @@ export class DataTokens { * @param {String} toAddress * @param {String} amount Number of datatokens, as number. Will be converted to wei * @param {String} address - * @return {Promise} transactionId + * @return {Promise} transactionId */ public async transferToken( dataTokenAddress: string, toAddress: string, amount: string, address: string - ): Promise { + ): Promise { const weiAmount = this.web3.utils.toWei(amount) return this.transferWei(dataTokenAddress, toAddress, weiAmount, address) } @@ -213,14 +213,14 @@ export class DataTokens { * @param {String} toAddress * @param {String} amount Number of datatokens, as number. Expressed as wei * @param {String} address - * @return {Promise} transactionId + * @return {Promise} transactionId */ public async transferWei( dataTokenAddress: string, toAddress: string, amount: string, address: string - ): Promise { + ): Promise { const datatoken = new this.web3.eth.Contract(this.datatokensABI, dataTokenAddress, { from: address }) diff --git a/test/integration/ComputeFlow.test.ts b/test/integration/ComputeFlow.test.ts index 7eb17b78..58e890bf 100644 --- a/test/integration/ComputeFlow.test.ts +++ b/test/integration/ComputeFlow.test.ts @@ -5,7 +5,7 @@ import { Ocean } from '../../src/ocean/Ocean' import { ConfigHelper } from '../../src/utils/ConfigHelper' import { assert } from 'chai' -import { ServiceComputePrivacy } from '../../src/ddo/interfaces/Service' +import { ServiceCommon, ServiceComputePrivacy } from '../../src/ddo/interfaces/Service' import Web3 from 'web3' import factory from '@oceanprotocol/contracts/artifacts/DTFactory.json' import datatokensTemplate from '@oceanprotocol/contracts/artifacts/DataTokenTemplate.json' @@ -27,14 +27,14 @@ describe('Compute flow', () => { let datasetWithTrustedAlgo let algorithmAsset let contracts - let datatoken + let datatoken: DataTokens let tokenAddress let tokenAddressNoRawAlgo let tokenAddressWithTrustedAlgo let tokenAddressAlgorithm - let price + let price: string let ocean - let computeService + let computeService: ServiceCommon let data let blob let jobId @@ -77,7 +77,7 @@ describe('Compute flow', () => { owner = (await ocean.accounts.list())[0] alice = (await ocean.accounts.list())[1] bob = (await ocean.accounts.list())[2] - data = { t: 1, url: ocean.config.metadataStoreUri } + data = { t: 1, url: config.metadataStoreUri } blob = JSON.stringify(data) await contracts.deployContracts(owner.getId()) }) diff --git a/test/integration/Marketplaceflow.test.ts b/test/integration/Marketplaceflow.test.ts index b827bad0..d84ee4b0 100644 --- a/test/integration/Marketplaceflow.test.ts +++ b/test/integration/Marketplaceflow.test.ts @@ -9,10 +9,10 @@ import { ConfigHelper } from '../../src/utils/ConfigHelper' import Web3 from 'web3' import factory from '@oceanprotocol/contracts/artifacts/DTFactory.json' import datatokensTemplate from '@oceanprotocol/contracts/artifacts/DataTokenTemplate.json' -import { EditableMetadata } from '../../src/lib' +import { Account, EditableMetadata, ServiceAccess, ServiceCommon } from '../../src/lib' const web3 = new Web3('http://127.0.0.1:8545') -function sleep(ms) { +function sleep(ms: number) { return new Promise((resolve) => { setTimeout(resolve, ms) }) @@ -21,19 +21,19 @@ function sleep(ms) { use(spies) describe('Marketplace flow', () => { - let owner - let bob + let owner: Account + let bob: Account let ddo - let alice + let alice: Account let asset - let marketplace - let contracts - let datatoken - let tokenAddress - let service1 - let price - let ocean - let accessService + let marketplace: Account + let contracts: TestContractHandler + let datatoken: DataTokens + let tokenAddress: string + let service1: ServiceAccess + let price: string + let ocean: Ocean + let accessService: ServiceCommon let data let blob @@ -55,7 +55,7 @@ describe('Marketplace flow', () => { alice = (await ocean.accounts.list())[1] bob = (await ocean.accounts.list())[2] marketplace = (await ocean.accounts.list())[3] - data = { t: 1, url: ocean.config.metadataStoreUri } + data = { t: 1, url: config.metadataStoreUri } blob = JSON.stringify(data) await contracts.deployContracts(owner.getId()) }) @@ -156,8 +156,8 @@ describe('Marketplace flow', () => { it('Marketplace posts asset for sale', async () => { accessService = await ocean.assets.getServiceByType(ddo.id, 'access') - price = 20 - assert.equal(accessService.attributes.main.cost * price, 200) + price = '20' + assert.equal(accessService.attributes.main.cost * Number(price), 200) }) it('Bob gets datatokens', async () => { @@ -199,9 +199,9 @@ describe('Marketplace flow', () => { assert(balanceBefore === balanceAfter) }) - it('owner can list there assets', async () => { + it('owner can list their assets', async () => { const assets = await ocean.assets.ownerAssets(alice.getId()) - assert(assets.length > 0) + assert(assets.results.length > 0) }) it('Alice updates metadata', async () => { diff --git a/test/integration/Provider.test.ts b/test/integration/Provider.test.ts index e3ddcb24..8a6ceb3c 100644 --- a/test/integration/Provider.test.ts +++ b/test/integration/Provider.test.ts @@ -3,16 +3,17 @@ import config from './config' import { assert } from 'console' describe('Provider tests', () => { - let ocean + let ocean: Ocean + it('Initialize Ocean', async () => { ocean = await Ocean.getInstance(config) }) it('Alice tests invalid provider', async () => { - const valid = ocean.provider.isValidProvider('http://example.net') + const valid = await ocean.provider.isValidProvider('http://example.net') assert(valid === false) }) it('Alice tests valid provider', async () => { - const valid = ocean.provider.isValidProvider('http://127.0.0.1:8030') + const valid = await ocean.provider.isValidProvider('http://127.0.0.1:8030') assert(valid === true) }) }) diff --git a/test/integration/Simpleflow.test.ts b/test/integration/Simpleflow.test.ts index 26409b98..6ec1389e 100644 --- a/test/integration/Simpleflow.test.ts +++ b/test/integration/Simpleflow.test.ts @@ -8,13 +8,14 @@ import datatokensTemplate from '@oceanprotocol/contracts/artifacts/DataTokenTemp const web3 = new Web3('http://127.0.0.1:8545') describe('Simple flow', () => { - let owner - let bob - let alice - let contracts - let datatoken - let tokenAddress - let transactionId + let owner: string + let bob: string + let alice: string + let contracts: TestContractHandler + let datatoken: DataTokens + let tokenAddress: string + let transactionId: string + const tokenAmount = '100' const transferAmount = '1' const blob = 'http://localhost:8030/api/v1/services/consume'