mirror of
https://github.com/oceanprotocol/ocean.js.git
synced 2024-11-26 20:39:05 +01:00
wip ocean.assets.create
This commit is contained in:
parent
67eaca6c56
commit
712bb76dbc
@ -45,6 +45,13 @@ npm i
|
|||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
|
Generate metadata:
|
||||||
|
```bash
|
||||||
|
|
||||||
|
./scripts/get-metadata.js > src/metadata.json
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||
# Testing
|
# Testing
|
||||||
|
|
||||||
Run tests with
|
Run tests with
|
||||||
|
55
package-lock.json
generated
55
package-lock.json
generated
@ -4885,60 +4885,6 @@
|
|||||||
"resolved": "https://registry.npmjs.org/etag/-/etag-1.8.1.tgz",
|
"resolved": "https://registry.npmjs.org/etag/-/etag-1.8.1.tgz",
|
||||||
"integrity": "sha1-Qa4u62XvpiJorr/qg6x9eSmbCIc="
|
"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": {
|
"eth-ens-namehash": {
|
||||||
"version": "2.0.8",
|
"version": "2.0.8",
|
||||||
"resolved": "https://registry.npmjs.org/eth-ens-namehash/-/eth-ens-namehash-2.0.8.tgz",
|
"resolved": "https://registry.npmjs.org/eth-ens-namehash/-/eth-ens-namehash-2.0.8.tgz",
|
||||||
@ -11923,7 +11869,6 @@
|
|||||||
"backoff": "^2.5.0",
|
"backoff": "^2.5.0",
|
||||||
"clone": "^2.0.0",
|
"clone": "^2.0.0",
|
||||||
"cross-fetch": "^2.1.0",
|
"cross-fetch": "^2.1.0",
|
||||||
"eth-block-tracker": "^4.2.0",
|
|
||||||
"eth-json-rpc-infura": "^3.1.0",
|
"eth-json-rpc-infura": "^3.1.0",
|
||||||
"eth-sig-util": "^1.4.2",
|
"eth-sig-util": "^1.4.2",
|
||||||
"ethereumjs-block": "^1.2.2",
|
"ethereumjs-block": "^1.2.2",
|
||||||
|
@ -4,7 +4,7 @@ import { Instantiable, InstantiableConfig } from '../Instantiable.abstract'
|
|||||||
/**
|
/**
|
||||||
* Account information.
|
* Account information.
|
||||||
*/
|
*/
|
||||||
export default class Accounts extends Instantiable {
|
export default class Account extends Instantiable {
|
||||||
private password?: string
|
private password?: string
|
||||||
|
|
||||||
private token?: string
|
private token?: string
|
||||||
|
@ -3,7 +3,7 @@ import { noZeroX } from '../utils'
|
|||||||
import { Instantiable, InstantiableConfig } from '../Instantiable.abstract'
|
import { Instantiable, InstantiableConfig } from '../Instantiable.abstract'
|
||||||
import { DDO } from '../ddo/DDO'
|
import { DDO } from '../ddo/DDO'
|
||||||
|
|
||||||
const apiPath = '/api/v1/services/'
|
const apiPath = '/api/v1/provider/services'
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Provides an interface for provider service.
|
* Provides an interface for provider service.
|
||||||
|
@ -1,8 +1,9 @@
|
|||||||
import { TestContractHandler } from '../TestContractHandler'
|
import { TestContractHandler } from '../TestContractHandler'
|
||||||
import { DataTokens } from '../../src/datatokens/Datatokens'
|
import { DataTokens } from '../../src/datatokens/Datatokens'
|
||||||
import { Ocean } from '../../src/ocean/Ocean'
|
import { Ocean } from '../../src/ocean/Ocean'
|
||||||
import { Config } from '../../src/models/Config'
|
import config from './config'
|
||||||
import Accounts from "../../src/ocean/Account" // ??
|
|
||||||
|
// import Accounts from "../../src/ocean/Account"
|
||||||
|
|
||||||
const Web3 = require('web3')
|
const Web3 = require('web3')
|
||||||
const web3 = new Web3('http://127.0.0.1:8545')
|
const web3 = new Web3('http://127.0.0.1:8545')
|
||||||
@ -12,7 +13,9 @@ const datatokensTemplate = require('@oceanprotocol/contracts/artifacts/developme
|
|||||||
describe('Marketplace flow', () => {
|
describe('Marketplace flow', () => {
|
||||||
let owner
|
let owner
|
||||||
let bob
|
let bob
|
||||||
|
let alice
|
||||||
let asset
|
let asset
|
||||||
|
let accounts
|
||||||
let marketplace
|
let marketplace
|
||||||
let marketOcean
|
let marketOcean
|
||||||
let contracts
|
let contracts
|
||||||
@ -22,7 +25,7 @@ describe('Marketplace flow', () => {
|
|||||||
let service1
|
let service1
|
||||||
let service2
|
let service2
|
||||||
|
|
||||||
let alice = new Accounts()
|
let ocean
|
||||||
|
|
||||||
const tokenAmount = 100
|
const tokenAmount = 100
|
||||||
const transferAmount = 2
|
const transferAmount = 2
|
||||||
@ -37,18 +40,26 @@ describe('Marketplace flow', () => {
|
|||||||
factory.bytecode,
|
factory.bytecode,
|
||||||
web3
|
web3
|
||||||
)
|
)
|
||||||
await contracts.getAccounts()
|
|
||||||
owner = contracts.accounts[0]
|
|
||||||
bob = contracts.accounts[2]
|
|
||||||
marketplace = contracts.accounts[3]
|
|
||||||
|
|
||||||
await alice.setId(contracts.accounts[1])
|
ocean = await Ocean.getInstance(config)
|
||||||
await alice.setPassword("0x4a608ef70ce229351d37be7b07ddd7a3ce46709911cf8c8c4bcabd8a6c563711")
|
|
||||||
|
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 () => {
|
it('Alice publishes a datatoken contract', async () => {
|
||||||
|
datatoken = new DataTokens(
|
||||||
|
contracts.factoryAddress,
|
||||||
|
factory.abi,
|
||||||
|
datatokensTemplate.abi,
|
||||||
|
web3
|
||||||
|
)
|
||||||
|
|
||||||
tokenAddress = await datatoken.create(blob, alice.getId())
|
tokenAddress = await datatoken.create(blob, alice.getId())
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -69,47 +80,35 @@ describe('Marketplace flow', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
it('Alice publishes a dataset', async () => {
|
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)
|
asset = await ocean.assets.create(asset, alice, [], tokenAddress)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('Alice mints 100 tokens', async () => {
|
// it('Alice mints 100 tokens', async () => {
|
||||||
await datatoken.mint(tokenAddress, alice.getId(), tokenAmount)
|
// await datatoken.mint(tokenAddress, alice.getId(), tokenAmount)
|
||||||
})
|
// })
|
||||||
|
|
||||||
it('Marketplace posts asset for sale', async () => {
|
// it('Marketplace posts asset for sale', async () => {
|
||||||
const config = new Config()
|
// const config = new Config()
|
||||||
marketOcean = await Ocean.getInstance(config)
|
// marketOcean = await Ocean.getInstance(config)
|
||||||
|
|
||||||
service1 = marketOcean.assets.getService('download')
|
// service1 = marketOcean.assets.getService('download')
|
||||||
service2 = marketOcean.assets.getService('access')
|
// service2 = marketOcean.assets.getService('access')
|
||||||
|
|
||||||
})
|
// })
|
||||||
|
|
||||||
it('Bob gets datatokens', async () => {
|
// it('Bob gets datatokens', async () => {
|
||||||
const ts = await datatoken.transfer(tokenAddress, bob, transferAmount, alice)
|
// const ts = await datatoken.transfer(tokenAddress, bob, transferAmount, alice)
|
||||||
transactionId = ts.transactionHash
|
// transactionId = ts.transactionHash
|
||||||
})
|
// })
|
||||||
|
|
||||||
it('Bob consumes asset 1', async () => {
|
// it('Bob consumes asset 1', async () => {
|
||||||
const config = new Config()
|
// const config = new Config()
|
||||||
const ocean = await Ocean.getInstance(config)
|
// const ocean = await Ocean.getInstance(config)
|
||||||
await ocean.assets.download(asset.did, service1.index, bob, '~/my-datasets')
|
// await ocean.assets.download(asset.did, service1.index, bob, '~/my-datasets')
|
||||||
})
|
// })
|
||||||
|
|
||||||
it('Bob consumes asset 2', async () => {
|
// it('Bob consumes asset 2', async () => {
|
||||||
// TODO
|
// // TODO
|
||||||
})
|
// })
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
17
test/integration/config.ts
Normal file
17
test/integration/config.ts
Normal file
@ -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
|
Loading…
x
Reference in New Issue
Block a user