diff --git a/README.md b/README.md index da9cef78..6c160392 100644 --- a/README.md +++ b/README.md @@ -45,6 +45,13 @@ npm i ``` +Generate metadata: +```bash + +./scripts/get-metadata.js > src/metadata.json + +``` + # Testing Run tests with diff --git a/package-lock.json b/package-lock.json index 79f50e65..974ec4ac 100644 --- a/package-lock.json +++ b/package-lock.json @@ -4885,60 +4885,6 @@ "resolved": "https://registry.npmjs.org/etag/-/etag-1.8.1.tgz", "integrity": "sha1-Qa4u62XvpiJorr/qg6x9eSmbCIc=" }, - "eth-block-tracker": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/eth-block-tracker/-/eth-block-tracker-3.0.1.tgz", - "integrity": "sha512-WUVxWLuhMmsfenfZvFO5sbl1qFY2IqUlw/FPVmjjdElpqLsZtSG+wPe9Dz7W/sB6e80HgFKknOmKk2eNlznHug==", - "dev": true, - "requires": { - "eth-query": "^2.1.0", - "ethereumjs-tx": "^1.3.3", - "ethereumjs-util": "^5.1.3", - "ethjs-util": "^0.1.3", - "json-rpc-engine": "^3.6.0", - "pify": "^2.3.0", - "tape": "^4.6.3" - }, - "dependencies": { - "ethereumjs-tx": { - "version": "1.3.7", - "resolved": "https://registry.npmjs.org/ethereumjs-tx/-/ethereumjs-tx-1.3.7.tgz", - "integrity": "sha512-wvLMxzt1RPhAQ9Yi3/HKZTn0FZYpnsmQdbKYfUUpi4j1SEIcbkd9tndVjcPrufY3V7j2IebOpC00Zp2P/Ay2kA==", - "dev": true, - "requires": { - "ethereum-common": "^0.0.18", - "ethereumjs-util": "^5.0.0" - } - }, - "ethereumjs-util": { - "version": "5.2.0", - "resolved": "https://registry.npmjs.org/ethereumjs-util/-/ethereumjs-util-5.2.0.tgz", - "integrity": "sha512-CJAKdI0wgMbQFLlLRtZKGcy/L6pzVRgelIZqRqNbuVFM3K9VEnyfbcvz0ncWMRNCe4kaHWjwRYQcYMucmwsnWA==", - "dev": true, - "requires": { - "bn.js": "^4.11.0", - "create-hash": "^1.1.2", - "ethjs-util": "^0.1.3", - "keccak": "^1.0.2", - "rlp": "^2.0.0", - "safe-buffer": "^5.1.1", - "secp256k1": "^3.0.1" - } - }, - "keccak": { - "version": "1.4.0", - "resolved": "https://registry.npmjs.org/keccak/-/keccak-1.4.0.tgz", - "integrity": "sha512-eZVaCpblK5formjPjeTBik7TAg+pqnDrMHIffSvi9Lh7PQgM1+hSzakUeZFCk9DVVG0dacZJuaz2ntwlzZUIBw==", - "dev": true, - "requires": { - "bindings": "^1.2.1", - "inherits": "^2.0.3", - "nan": "^2.2.1", - "safe-buffer": "^5.1.0" - } - } - } - }, "eth-ens-namehash": { "version": "2.0.8", "resolved": "https://registry.npmjs.org/eth-ens-namehash/-/eth-ens-namehash-2.0.8.tgz", @@ -11923,7 +11869,6 @@ "backoff": "^2.5.0", "clone": "^2.0.0", "cross-fetch": "^2.1.0", - "eth-block-tracker": "^4.2.0", "eth-json-rpc-infura": "^3.1.0", "eth-sig-util": "^1.4.2", "ethereumjs-block": "^1.2.2", diff --git a/src/ocean/Account.ts b/src/ocean/Account.ts index 18376b24..4d316d0f 100644 --- a/src/ocean/Account.ts +++ b/src/ocean/Account.ts @@ -4,7 +4,7 @@ import { Instantiable, InstantiableConfig } from '../Instantiable.abstract' /** * Account information. */ -export default class Accounts extends Instantiable { +export default class Account extends Instantiable { private password?: string private token?: string diff --git a/src/provider/Provider.ts b/src/provider/Provider.ts index 36fb9db3..11ab090f 100644 --- a/src/provider/Provider.ts +++ b/src/provider/Provider.ts @@ -3,7 +3,7 @@ import { noZeroX } from '../utils' import { Instantiable, InstantiableConfig } from '../Instantiable.abstract' import { DDO } from '../ddo/DDO' -const apiPath = '/api/v1/services/' +const apiPath = '/api/v1/provider/services' /** * Provides an interface for provider service. diff --git a/test/integration/Marketplaceflow.test.ts b/test/integration/Marketplaceflow.test.ts index 10a3af60..b5018b91 100644 --- a/test/integration/Marketplaceflow.test.ts +++ b/test/integration/Marketplaceflow.test.ts @@ -1,8 +1,9 @@ import { TestContractHandler } from '../TestContractHandler' import { DataTokens } from '../../src/datatokens/Datatokens' import { Ocean } from '../../src/ocean/Ocean' -import { Config } from '../../src/models/Config' -import Accounts from "../../src/ocean/Account" // ?? +import config from './config' + +// import Accounts from "../../src/ocean/Account" const Web3 = require('web3') const web3 = new Web3('http://127.0.0.1:8545') @@ -12,7 +13,9 @@ const datatokensTemplate = require('@oceanprotocol/contracts/artifacts/developme describe('Marketplace flow', () => { let owner let bob + let alice let asset + let accounts let marketplace let marketOcean let contracts @@ -22,7 +25,7 @@ describe('Marketplace flow', () => { let service1 let service2 - let alice = new Accounts() + let ocean const tokenAmount = 100 const transferAmount = 2 @@ -37,18 +40,26 @@ describe('Marketplace flow', () => { factory.bytecode, web3 ) - await contracts.getAccounts() - owner = contracts.accounts[0] - bob = contracts.accounts[2] - marketplace = contracts.accounts[3] - await alice.setId(contracts.accounts[1]) - await alice.setPassword("0x4a608ef70ce229351d37be7b07ddd7a3ce46709911cf8c8c4bcabd8a6c563711") + ocean = await Ocean.getInstance(config) + + owner = (await ocean.accounts.list())[0] + alice = (await ocean.accounts.list())[1] + bob = (await ocean.accounts.list())[2] + marketplace = (await ocean.accounts.list())[3] + + await contracts.deployContracts(owner.getId()) - await contracts.deployContracts(owner) }) it('Alice publishes a datatoken contract', async () => { + datatoken = new DataTokens( + contracts.factoryAddress, + factory.abi, + datatokensTemplate.abi, + web3 + ) + tokenAddress = await datatoken.create(blob, alice.getId()) }) @@ -69,47 +80,35 @@ describe('Marketplace flow', () => { }) it('Alice publishes a dataset', async () => { - // Alice creates a Datatoken - datatoken = new DataTokens( - contracts.factoryAddress, - factory.abi, - datatokensTemplate.abi, - web3 - ) - - const config = new Config() - const ocean = await Ocean.getInstance(config) - - tokenAddress = await datatoken.create(blob, alice.getId()) asset = await ocean.assets.create(asset, alice, [], tokenAddress) }) - it('Alice mints 100 tokens', async () => { - await datatoken.mint(tokenAddress, alice.getId(), tokenAmount) - }) + // it('Alice mints 100 tokens', async () => { + // await datatoken.mint(tokenAddress, alice.getId(), tokenAmount) + // }) - it('Marketplace posts asset for sale', async () => { - const config = new Config() - marketOcean = await Ocean.getInstance(config) + // it('Marketplace posts asset for sale', async () => { + // const config = new Config() + // marketOcean = await Ocean.getInstance(config) - service1 = marketOcean.assets.getService('download') - service2 = marketOcean.assets.getService('access') + // service1 = marketOcean.assets.getService('download') + // service2 = marketOcean.assets.getService('access') - }) + // }) - it('Bob gets datatokens', async () => { - const ts = await datatoken.transfer(tokenAddress, bob, transferAmount, alice) - transactionId = ts.transactionHash - }) + // it('Bob gets datatokens', async () => { + // const ts = await datatoken.transfer(tokenAddress, bob, transferAmount, alice) + // transactionId = ts.transactionHash + // }) - it('Bob consumes asset 1', async () => { - const config = new Config() - const ocean = await Ocean.getInstance(config) - await ocean.assets.download(asset.did, service1.index, bob, '~/my-datasets') - }) + // it('Bob consumes asset 1', async () => { + // const config = new Config() + // const ocean = await Ocean.getInstance(config) + // await ocean.assets.download(asset.did, service1.index, bob, '~/my-datasets') + // }) - it('Bob consumes asset 2', async () => { - // TODO - }) + // it('Bob consumes asset 2', async () => { + // // TODO + // }) }) }) diff --git a/test/integration/config.ts b/test/integration/config.ts new file mode 100644 index 00000000..b4fc22ed --- /dev/null +++ b/test/integration/config.ts @@ -0,0 +1,17 @@ +import { Config, LogLevel } from '../../src/models/Config' +import { LoggerInstance } from '../../src/utils' + +LoggerInstance.setLevel(LogLevel.Error) + +const Web3 = require('web3') +const web3 = new Web3('http://127.0.0.1:8545') + +export default { + metadataStoreUri: 'http://localhost:5000', + providerUri: 'http://localhost:8030', + nodeUri: `http://localhost:${process.env.ETH_PORT || 8545}`, + parityUri: 'http://localhost:9545', + secretStoreUri: 'http://localhost:12001', + verbose: LogLevel.Error, + web3Provider: web3 +} as Config