mirror of
https://github.com/oceanprotocol/ocean.js.git
synced 2024-11-26 20:39:05 +01:00
metadataStore → metadataCache
This commit is contained in:
parent
5c2cef618e
commit
d0b4bb537e
@ -57,7 +57,7 @@ const defaultConfig: Config = new ConfigHelper().getConfig(
|
|||||||
|
|
||||||
const config = {
|
const config = {
|
||||||
...defaultConfig,
|
...defaultConfig,
|
||||||
metadataStoreUri: 'https://your-metadata-store.com',
|
metadataCacheUri: 'https://your-metadata-cache.com',
|
||||||
providerUri: 'https://your-provider.com'
|
providerUri: 'https://your-provider.com'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -44,7 +44,7 @@ const datatokensTemplate = require('@oceanprotocol/contracts/artifacts/DataToken
|
|||||||
|
|
||||||
// Alice's config
|
// Alice's config
|
||||||
const config = {
|
const config = {
|
||||||
metadataStoreUri: 'http://aquarius:5000',
|
metadataCacheUri: 'http://aquarius:5000',
|
||||||
providerUri: 'http://localhost:8030',
|
providerUri: 'http://localhost:8030',
|
||||||
nodeUri: `http://localhost:${process.env.ETH_PORT || 8545}`,
|
nodeUri: `http://localhost:${process.env.ETH_PORT || 8545}`,
|
||||||
verbose: LogLevel.Error,
|
verbose: LogLevel.Error,
|
||||||
@ -60,7 +60,7 @@ datatoken = new DataTokens(
|
|||||||
datatokensTemplate.abi,
|
datatokensTemplate.abi,
|
||||||
web3
|
web3
|
||||||
)
|
)
|
||||||
const data = { t: 1, url: ocean.config.metadataStoreUri }
|
const data = { t: 1, url: ocean.config.metadataCacheUri }
|
||||||
const blob = JSON.stringify(data)
|
const blob = JSON.stringify(data)
|
||||||
|
|
||||||
const dataTokenAddress = await datatoken.create(blob, alice.getId())
|
const dataTokenAddress = await datatoken.create(blob, alice.getId())
|
||||||
|
@ -64,7 +64,7 @@ export class DataTokens {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Create new datatoken
|
* Create new datatoken
|
||||||
* @param {String} metaDataStoreURI
|
* @param {String} metadataCacheUri
|
||||||
* @param {String} address
|
* @param {String} address
|
||||||
* @param {String} cap Maximum cap (Number) - will be converted to wei
|
* @param {String} cap Maximum cap (Number) - will be converted to wei
|
||||||
* @param {String} name Token name
|
* @param {String} name Token name
|
||||||
@ -72,7 +72,7 @@ export class DataTokens {
|
|||||||
* @return {Promise<string>} datatoken address
|
* @return {Promise<string>} datatoken address
|
||||||
*/
|
*/
|
||||||
public async create(
|
public async create(
|
||||||
metaDataStoreURI: string,
|
metadataCacheUri: string,
|
||||||
address: string,
|
address: string,
|
||||||
cap?: string,
|
cap?: string,
|
||||||
name?: string,
|
name?: string,
|
||||||
@ -90,14 +90,14 @@ export class DataTokens {
|
|||||||
from: address
|
from: address
|
||||||
})
|
})
|
||||||
const estGas = await factory.methods
|
const estGas = await factory.methods
|
||||||
.createToken(metaDataStoreURI, name, symbol, this.web3.utils.toWei(cap))
|
.createToken(metadataCacheUri, name, symbol, this.web3.utils.toWei(cap))
|
||||||
.estimateGas(function (err: string, estGas: string) {
|
.estimateGas(function (err: string, estGas: string) {
|
||||||
if (err) console.log('Datatokens: ' + err)
|
if (err) console.log('Datatokens: ' + err)
|
||||||
return estGas
|
return estGas
|
||||||
})
|
})
|
||||||
// Invoke createToken function of the contract
|
// Invoke createToken function of the contract
|
||||||
const trxReceipt = await factory.methods
|
const trxReceipt = await factory.methods
|
||||||
.createToken(metaDataStoreURI, name, symbol, this.web3.utils.toWei(cap))
|
.createToken(metadataCacheUri, name, symbol, this.web3.utils.toWei(cap))
|
||||||
.send({
|
.send({
|
||||||
from: address,
|
from: address,
|
||||||
gas: estGas + 1,
|
gas: estGas + 1,
|
||||||
|
@ -3,7 +3,7 @@ import Account from './ocean/Account'
|
|||||||
import DID from './ocean/DID'
|
import DID from './ocean/DID'
|
||||||
import { Ocean } from './ocean/Ocean'
|
import { Ocean } from './ocean/Ocean'
|
||||||
import { LoggerInstance as Logger } from './utils/Logger'
|
import { LoggerInstance as Logger } from './utils/Logger'
|
||||||
import { MetadataStore } from './metadatastore/MetadataStore'
|
import { MetadataCache } from './metadatacache/MetadataCache'
|
||||||
import { DataTokens } from './datatokens/Datatokens'
|
import { DataTokens } from './datatokens/Datatokens'
|
||||||
import { ConfigHelper } from './utils/ConfigHelper'
|
import { ConfigHelper } from './utils/ConfigHelper'
|
||||||
|
|
||||||
@ -27,7 +27,7 @@ export {
|
|||||||
Config,
|
Config,
|
||||||
DID,
|
DID,
|
||||||
Logger,
|
Logger,
|
||||||
MetadataStore,
|
MetadataCache,
|
||||||
DataTokens,
|
DataTokens,
|
||||||
utils,
|
utils,
|
||||||
ConfigHelper
|
ConfigHelper
|
||||||
|
@ -23,27 +23,27 @@ export interface SearchQuery {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Provides an interface with Metadata Store.
|
* Provides an interface with Metadata Cache.
|
||||||
* Metadata Store provides an off-chain database store for metadata about data assets.
|
* Metadata Cache provides an off-chain database cache for on-chain metadata about data assets.
|
||||||
*/
|
*/
|
||||||
export class MetadataStore {
|
export class MetadataCache {
|
||||||
public fetch: WebServiceConnector
|
public fetch: WebServiceConnector
|
||||||
private logger: Logger
|
private logger: Logger
|
||||||
private metadataStoreUri: string
|
private metadataCacheUri: string
|
||||||
|
|
||||||
private get url() {
|
private get url() {
|
||||||
return this.metadataStoreUri
|
return this.metadataCacheUri
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Instantiate Metadata Store (independently of Ocean) for off-chain interaction.
|
* Instantiate Metadata Cache (independently of Ocean) for off-chain interaction.
|
||||||
* @param {String} metadataStoreUri
|
* @param {String} metadataCacheUri
|
||||||
* @param {Logger} logger
|
* @param {Logger} logger
|
||||||
*/
|
*/
|
||||||
constructor(metadataStoreUri: string, logger: Logger) {
|
constructor(metadataCacheUri: string, logger: Logger) {
|
||||||
this.fetch = new WebServiceConnector(logger)
|
this.fetch = new WebServiceConnector(logger)
|
||||||
this.logger = logger
|
this.logger = logger
|
||||||
this.metadataStoreUri = metadataStoreUri
|
this.metadataCacheUri = metadataCacheUri
|
||||||
}
|
}
|
||||||
|
|
||||||
public async getVersionInfo(): Promise<any> {
|
public async getVersionInfo(): Promise<any> {
|
@ -11,10 +11,10 @@ import { didZeroX } from '../utils'
|
|||||||
import { LZMA } from 'lzma/src/lzma-c'
|
import { LZMA } from 'lzma/src/lzma-c'
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Provides an interface with Metadata Store.
|
* Provides an interface with Metadata Cache.
|
||||||
* Metadata Store provides an off-chain database store for metadata about data assets.
|
* Metadata Cache provides an off-chain database store for metadata about data assets.
|
||||||
*/
|
*/
|
||||||
export class OnChainMetadataStore {
|
export class OnChainMetadataCache {
|
||||||
public DDOContractAddress: string
|
public DDOContractAddress: string
|
||||||
public DDOContractABI: AbiItem | AbiItem[]
|
public DDOContractABI: AbiItem | AbiItem[]
|
||||||
public web3: Web3
|
public web3: Web3
|
||||||
@ -107,7 +107,7 @@ export class OnChainMetadataStore {
|
|||||||
/* const estGas = await this.DDOContract.methods
|
/* const estGas = await this.DDOContract.methods
|
||||||
.create(didZeroX(did), flags, data)
|
.create(didZeroX(did), flags, data)
|
||||||
.estimateGas(function (err, estGas) {
|
.estimateGas(function (err, estGas) {
|
||||||
if (err) console.log('OnChainMetadataStoreEstimateGas: ' + err)
|
if (err) console.log('OnChainMetadataCacheEstimateGas: ' + err)
|
||||||
return estGas
|
return estGas
|
||||||
})
|
})
|
||||||
*/
|
*/
|
@ -18,7 +18,7 @@ export class Config {
|
|||||||
* Metadata Store URL.
|
* Metadata Store URL.
|
||||||
* @type {string}
|
* @type {string}
|
||||||
*/
|
*/
|
||||||
public metadataStoreUri?: string
|
public metadataCacheUri?: string
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Provider URL.
|
* Provider URL.
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import { SearchQuery, QueryResult } from '../metadatastore/MetadataStore'
|
import { SearchQuery, QueryResult } from '../metadatacache/MetadataCache'
|
||||||
import { DDO } from '../ddo/DDO'
|
import { DDO } from '../ddo/DDO'
|
||||||
import { Metadata } from '../ddo/interfaces/Metadata'
|
import { Metadata } from '../ddo/interfaces/Metadata'
|
||||||
import {
|
import {
|
||||||
@ -97,8 +97,8 @@ export class Assets extends Instantiable {
|
|||||||
if (!dtAddress) {
|
if (!dtAddress) {
|
||||||
this.logger.log('Creating datatoken')
|
this.logger.log('Creating datatoken')
|
||||||
observer.next(CreateProgressStep.CreatingDataToken)
|
observer.next(CreateProgressStep.CreatingDataToken)
|
||||||
const metadataStoreURI = this.ocean.metadatastore.getURI()
|
const metadataCacheUri = this.ocean.metadatacache.getURI()
|
||||||
const jsonBlob = { t: 1, url: metadataStoreURI }
|
const jsonBlob = { t: 1, url: metadataCacheUri }
|
||||||
const { datatokens } = this.ocean
|
const { datatokens } = this.ocean
|
||||||
|
|
||||||
dtAddress = await datatokens.create(
|
dtAddress = await datatokens.create(
|
||||||
@ -199,8 +199,8 @@ export class Assets extends Instantiable {
|
|||||||
observer.next(CreateProgressStep.ProofGenerated)
|
observer.next(CreateProgressStep.ProofGenerated)
|
||||||
this.logger.log('Storing DDO')
|
this.logger.log('Storing DDO')
|
||||||
observer.next(CreateProgressStep.StoringDdo)
|
observer.next(CreateProgressStep.StoringDdo)
|
||||||
// const storedDdo = await this.ocean.metadatastore.storeDDO(ddo)
|
// const storedDdo = await this.ocean.metadatacache.storeDDO(ddo)
|
||||||
const storeTx = await this.ocean.OnChainMetadataStore.publish(
|
const storeTx = await this.ocean.OnChainMetadataCache.publish(
|
||||||
ddo.id,
|
ddo.id,
|
||||||
ddo,
|
ddo,
|
||||||
publisher.getId()
|
publisher.getId()
|
||||||
@ -218,7 +218,7 @@ export class Assets extends Instantiable {
|
|||||||
* @return {Promise<string[]>} List of DIDs.
|
* @return {Promise<string[]>} List of DIDs.
|
||||||
*/
|
*/
|
||||||
public async ownerAssets(owner: string): Promise<QueryResult> {
|
public async ownerAssets(owner: string): Promise<QueryResult> {
|
||||||
return this.ocean.metadatastore.getOwnerAssets(owner)
|
return this.ocean.metadatacache.getOwnerAssets(owner)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -227,7 +227,7 @@ export class Assets extends Instantiable {
|
|||||||
* @return {Promise<DDO>}
|
* @return {Promise<DDO>}
|
||||||
*/
|
*/
|
||||||
public async resolve(did: string): Promise<DDO> {
|
public async resolve(did: string): Promise<DDO> {
|
||||||
return this.ocean.metadatastore.retrieveDDO(did)
|
return this.ocean.metadatacache.retrieveDDO(did)
|
||||||
}
|
}
|
||||||
|
|
||||||
public async resolveByDTAddress(
|
public async resolveByDTAddress(
|
||||||
@ -247,7 +247,7 @@ export class Assets extends Instantiable {
|
|||||||
},
|
},
|
||||||
text: dtAddress
|
text: dtAddress
|
||||||
} as SearchQuery
|
} as SearchQuery
|
||||||
return (await this.ocean.metadatastore.queryMetadata(searchQuery)).results
|
return (await this.ocean.metadatacache.queryMetadata(searchQuery)).results
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -262,7 +262,7 @@ export class Assets extends Instantiable {
|
|||||||
newMetadata: EditableMetadata,
|
newMetadata: EditableMetadata,
|
||||||
account: Account
|
account: Account
|
||||||
): Promise<DDO> {
|
): Promise<DDO> {
|
||||||
const oldDdo = await this.ocean.metadatastore.retrieveDDO(did)
|
const oldDdo = await this.ocean.metadatacache.retrieveDDO(did)
|
||||||
let i
|
let i
|
||||||
for (i = 0; i < oldDdo.service.length; i++) {
|
for (i = 0; i < oldDdo.service.length; i++) {
|
||||||
if (oldDdo.service[i].type === 'metadata') {
|
if (oldDdo.service[i].type === 'metadata') {
|
||||||
@ -287,7 +287,7 @@ export class Assets extends Instantiable {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
const storeTx = await this.ocean.OnChainMetadataStore.update(
|
const storeTx = await this.ocean.OnChainMetadataCache.update(
|
||||||
oldDdo.id,
|
oldDdo.id,
|
||||||
oldDdo,
|
oldDdo,
|
||||||
account.getId()
|
account.getId()
|
||||||
@ -310,7 +310,7 @@ export class Assets extends Instantiable {
|
|||||||
computePrivacy: ServiceComputePrivacy,
|
computePrivacy: ServiceComputePrivacy,
|
||||||
account: Account
|
account: Account
|
||||||
): Promise<DDO> {
|
): Promise<DDO> {
|
||||||
const oldDdo = await this.ocean.metadatastore.retrieveDDO(did)
|
const oldDdo = await this.ocean.metadatacache.retrieveDDO(did)
|
||||||
if (oldDdo.service[serviceIndex].type !== 'compute') return null
|
if (oldDdo.service[serviceIndex].type !== 'compute') return null
|
||||||
oldDdo.service[serviceIndex].attributes.main.privacy.allowRawAlgorithm =
|
oldDdo.service[serviceIndex].attributes.main.privacy.allowRawAlgorithm =
|
||||||
computePrivacy.allowRawAlgorithm
|
computePrivacy.allowRawAlgorithm
|
||||||
@ -318,7 +318,7 @@ export class Assets extends Instantiable {
|
|||||||
computePrivacy.allowNetworkAccess
|
computePrivacy.allowNetworkAccess
|
||||||
oldDdo.service[serviceIndex].attributes.main.privacy.trustedAlgorithms =
|
oldDdo.service[serviceIndex].attributes.main.privacy.trustedAlgorithms =
|
||||||
computePrivacy.trustedAlgorithms
|
computePrivacy.trustedAlgorithms
|
||||||
const storeTx = await this.ocean.OnChainMetadataStore.update(
|
const storeTx = await this.ocean.OnChainMetadataCache.update(
|
||||||
oldDdo.id,
|
oldDdo.id,
|
||||||
oldDdo,
|
oldDdo,
|
||||||
account.getId()
|
account.getId()
|
||||||
@ -353,7 +353,7 @@ export class Assets extends Instantiable {
|
|||||||
* @return {Promise<QueryResult>}
|
* @return {Promise<QueryResult>}
|
||||||
*/
|
*/
|
||||||
public async query(query: SearchQuery): Promise<QueryResult> {
|
public async query(query: SearchQuery): Promise<QueryResult> {
|
||||||
return this.ocean.metadatastore.queryMetadata(query)
|
return this.ocean.metadatacache.queryMetadata(query)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -362,7 +362,7 @@ export class Assets extends Instantiable {
|
|||||||
* @return {Promise<QueryResult>}
|
* @return {Promise<QueryResult>}
|
||||||
*/
|
*/
|
||||||
public async search(text: string): Promise<QueryResult> {
|
public async search(text: string): Promise<QueryResult> {
|
||||||
return this.ocean.metadatastore.queryMetadata({
|
return this.ocean.metadatacache.queryMetadata({
|
||||||
text,
|
text,
|
||||||
page: 1,
|
page: 1,
|
||||||
offset: 100,
|
offset: 100,
|
||||||
|
@ -357,7 +357,7 @@ export class Compute extends Instantiable {
|
|||||||
publishOutput: output.publishOutput,
|
publishOutput: output.publishOutput,
|
||||||
providerAddress: output.providerAddress || this.config.providerAddress,
|
providerAddress: output.providerAddress || this.config.providerAddress,
|
||||||
providerUri: output.providerUri || this.config.providerUri,
|
providerUri: output.providerUri || this.config.providerUri,
|
||||||
metadataUri: output.metadataUri || this.config.metadataStoreUri,
|
metadataUri: output.metadataUri || this.config.metadataCacheUri,
|
||||||
nodeUri: output.nodeUri || this.config.nodeUri,
|
nodeUri: output.nodeUri || this.config.nodeUri,
|
||||||
owner: output.owner || consumerAccount.getId()
|
owner: output.owner || consumerAccount.getId()
|
||||||
}
|
}
|
||||||
|
@ -2,8 +2,8 @@ import { Accounts } from './Accounts'
|
|||||||
import { Assets } from './Assets'
|
import { Assets } from './Assets'
|
||||||
import { Versions } from './Versions'
|
import { Versions } from './Versions'
|
||||||
import { OceanUtils } from './utils/Utils'
|
import { OceanUtils } from './utils/Utils'
|
||||||
import { MetadataStore } from '../metadatastore/MetadataStore'
|
import { MetadataCache } from '../metadatacache/MetadataCache'
|
||||||
import { OnChainMetadataStore } from '../metadatastore/OnChainMetaData'
|
import { OnChainMetadataCache } from '../metadatacache/OnChainMetaDataCache'
|
||||||
import { Provider } from '../provider/Provider'
|
import { Provider } from '../provider/Provider'
|
||||||
import { DataTokens } from '../datatokens/Datatokens'
|
import { DataTokens } from '../datatokens/Datatokens'
|
||||||
import { Network } from '../datatokens/Network'
|
import { Network } from '../datatokens/Network'
|
||||||
@ -37,8 +37,8 @@ export class Ocean extends Instantiable {
|
|||||||
instance.utils = await OceanUtils.getInstance(instanceConfig)
|
instance.utils = await OceanUtils.getInstance(instanceConfig)
|
||||||
|
|
||||||
instance.provider = new Provider(instanceConfig)
|
instance.provider = new Provider(instanceConfig)
|
||||||
instance.metadatastore = new MetadataStore(
|
instance.metadatacache = new MetadataCache(
|
||||||
instanceConfig.config.metadataStoreUri,
|
instanceConfig.config.metadataCacheUri,
|
||||||
instanceConfig.logger
|
instanceConfig.logger
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -65,7 +65,7 @@ export class Ocean extends Instantiable {
|
|||||||
instanceConfig.config.fixedRateExchangeAddressABI,
|
instanceConfig.config.fixedRateExchangeAddressABI,
|
||||||
instanceConfig.config.oceanTokenAddress
|
instanceConfig.config.oceanTokenAddress
|
||||||
)
|
)
|
||||||
instance.OnChainMetadataStore = new OnChainMetadataStore(
|
instance.OnChainMetadataCache = new OnChainMetadataCache(
|
||||||
instanceConfig.config.web3Provider,
|
instanceConfig.config.web3Provider,
|
||||||
instanceConfig.config.metadataContractAddress,
|
instanceConfig.config.metadataContractAddress,
|
||||||
instanceConfig.config.metadataContractABI
|
instanceConfig.config.metadataContractABI
|
||||||
@ -94,15 +94,15 @@ export class Ocean extends Instantiable {
|
|||||||
public web3Provider: any
|
public web3Provider: any
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* MetadataStore instance.
|
* MetadataCache instance.
|
||||||
* @type {MetadataStore}
|
* @type {MetadataCache}
|
||||||
*/
|
*/
|
||||||
public metadatastore: MetadataStore
|
public metadatacache: MetadataCache
|
||||||
/**
|
/**
|
||||||
* OnChainMetadataStore instance.
|
* OnChainMetadataCache instance.
|
||||||
* @type {OnChainMetadataStore}
|
* @type {OnChainMetadataCache}
|
||||||
*/
|
*/
|
||||||
public OnChainMetadataStore: OnChainMetadataStore
|
public OnChainMetadataCache: OnChainMetadataCache
|
||||||
/**
|
/**
|
||||||
* Ocean account submodule
|
* Ocean account submodule
|
||||||
* @type {Accounts}
|
* @type {Accounts}
|
||||||
|
@ -18,7 +18,7 @@ export interface OceanPlatformTech {
|
|||||||
|
|
||||||
export interface OceanPlatformVersions {
|
export interface OceanPlatformVersions {
|
||||||
lib: OceanPlatformTech
|
lib: OceanPlatformTech
|
||||||
metadataStore: OceanPlatformTech
|
metadataCache: OceanPlatformTech
|
||||||
provider: OceanPlatformTech
|
provider: OceanPlatformTech
|
||||||
status: {
|
status: {
|
||||||
ok: boolean
|
ok: boolean
|
||||||
@ -49,17 +49,17 @@ export class Versions extends Instantiable {
|
|||||||
status: OceanPlatformTechStatus.Working
|
status: OceanPlatformTechStatus.Working
|
||||||
}
|
}
|
||||||
|
|
||||||
// MetadataStore
|
// MetadataCache
|
||||||
try {
|
try {
|
||||||
const { software: name, version } = await this.ocean.metadatastore.getVersionInfo()
|
const { software: name, version } = await this.ocean.metadatacache.getVersionInfo()
|
||||||
versions.metadataStore = {
|
versions.metadataCache = {
|
||||||
name,
|
name,
|
||||||
status: OceanPlatformTechStatus.Working,
|
status: OceanPlatformTechStatus.Working,
|
||||||
version
|
version
|
||||||
}
|
}
|
||||||
} catch {
|
} catch {
|
||||||
versions.metadataStore = {
|
versions.metadataCache = {
|
||||||
name: 'MetadataStore',
|
name: 'MetadataCache',
|
||||||
status: OceanPlatformTechStatus.Stopped
|
status: OceanPlatformTechStatus.Stopped
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -22,7 +22,7 @@ const configs: ConfigHelperConfig[] = [
|
|||||||
network: 'unknown',
|
network: 'unknown',
|
||||||
nodeUri: 'http://localhost:8545',
|
nodeUri: 'http://localhost:8545',
|
||||||
factoryAddress: null,
|
factoryAddress: null,
|
||||||
metadataStoreUri: 'http://127.0.0.1:5000',
|
metadataCacheUri: 'http://127.0.0.1:5000',
|
||||||
providerUri: 'http://127.0.0.1:8030',
|
providerUri: 'http://127.0.0.1:8030',
|
||||||
poolFactoryAddress: null,
|
poolFactoryAddress: null,
|
||||||
fixedRateExchangeAddress: null,
|
fixedRateExchangeAddress: null,
|
||||||
@ -34,7 +34,7 @@ const configs: ConfigHelperConfig[] = [
|
|||||||
network: 'development',
|
network: 'development',
|
||||||
nodeUri: 'http://localhost:8545',
|
nodeUri: 'http://localhost:8545',
|
||||||
factoryAddress: null,
|
factoryAddress: null,
|
||||||
metadataStoreUri: 'http://127.0.0.1:5000',
|
metadataCacheUri: 'http://127.0.0.1:5000',
|
||||||
providerUri: 'http://127.0.0.1:8030',
|
providerUri: 'http://127.0.0.1:8030',
|
||||||
poolFactoryAddress: null,
|
poolFactoryAddress: null,
|
||||||
fixedRateExchangeAddress: null,
|
fixedRateExchangeAddress: null,
|
||||||
@ -46,7 +46,7 @@ const configs: ConfigHelperConfig[] = [
|
|||||||
nodeUri: 'https://rinkeby.infura.io/v3',
|
nodeUri: 'https://rinkeby.infura.io/v3',
|
||||||
factoryAddress: '0x3fd7A00106038Fb5c802c6d63fa7147Fe429E83a',
|
factoryAddress: '0x3fd7A00106038Fb5c802c6d63fa7147Fe429E83a',
|
||||||
oceanTokenAddress: '0x8967BCF84170c91B0d24D4302C2376283b0B3a07',
|
oceanTokenAddress: '0x8967BCF84170c91B0d24D4302C2376283b0B3a07',
|
||||||
metadataStoreUri: 'https://aquarius.rinkeby.v3.dev-ocean.com',
|
metadataCacheUri: 'https://aquarius.rinkeby.v3.dev-ocean.com',
|
||||||
providerUri: 'https://provider.rinkeby.v3.dev-ocean.com',
|
providerUri: 'https://provider.rinkeby.v3.dev-ocean.com',
|
||||||
poolFactoryAddress: '0x53eDF9289B0898e1652Ce009AACf8D25fA9A42F8',
|
poolFactoryAddress: '0x53eDF9289B0898e1652Ce009AACf8D25fA9A42F8',
|
||||||
fixedRateExchangeAddress: '0xeD1DfC5F3a589CfC4E8B91C1fbfC18FC6699Fbde',
|
fixedRateExchangeAddress: '0xeD1DfC5F3a589CfC4E8B91C1fbfC18FC6699Fbde',
|
||||||
@ -58,7 +58,7 @@ const configs: ConfigHelperConfig[] = [
|
|||||||
nodeUri: 'https://mainnet.infura.io/v3',
|
nodeUri: 'https://mainnet.infura.io/v3',
|
||||||
factoryAddress: '0x1234',
|
factoryAddress: '0x1234',
|
||||||
oceanTokenAddress: '0x7AFeBBB46fDb47ed17b22ed075Cde2447694fB9e',
|
oceanTokenAddress: '0x7AFeBBB46fDb47ed17b22ed075Cde2447694fB9e',
|
||||||
metadataStoreUri: null,
|
metadataCacheUri: null,
|
||||||
providerUri: null,
|
providerUri: null,
|
||||||
poolFactoryAddress: null,
|
poolFactoryAddress: null,
|
||||||
fixedRateExchangeAddress: null,
|
fixedRateExchangeAddress: null,
|
||||||
@ -86,7 +86,7 @@ export class ConfigHelper {
|
|||||||
fixedRateExchangeAddress: FixedRateExchange,
|
fixedRateExchangeAddress: FixedRateExchange,
|
||||||
metadataContractAddress: Metadata,
|
metadataContractAddress: Metadata,
|
||||||
oceanTokenAddress: Ocean,
|
oceanTokenAddress: Ocean,
|
||||||
...(process.env.AQUARIUS_URI && { metadataStoreUri: process.env.AQUARIUS_URI })
|
...(process.env.AQUARIUS_URI && { metadataCacheUri: process.env.AQUARIUS_URI })
|
||||||
}
|
}
|
||||||
|
|
||||||
return configAddresses
|
return configAddresses
|
||||||
|
@ -77,7 +77,7 @@ describe('Compute flow', () => {
|
|||||||
owner = (await ocean.accounts.list())[0]
|
owner = (await ocean.accounts.list())[0]
|
||||||
alice = (await ocean.accounts.list())[1]
|
alice = (await ocean.accounts.list())[1]
|
||||||
bob = (await ocean.accounts.list())[2]
|
bob = (await ocean.accounts.list())[2]
|
||||||
data = { t: 1, url: config.metadataStoreUri }
|
data = { t: 1, url: config.metadataCacheUri }
|
||||||
blob = JSON.stringify(data)
|
blob = JSON.stringify(data)
|
||||||
await contracts.deployContracts(owner.getId())
|
await contracts.deployContracts(owner.getId())
|
||||||
})
|
})
|
||||||
|
@ -55,7 +55,7 @@ describe('Marketplace flow', () => {
|
|||||||
alice = (await ocean.accounts.list())[1]
|
alice = (await ocean.accounts.list())[1]
|
||||||
bob = (await ocean.accounts.list())[2]
|
bob = (await ocean.accounts.list())[2]
|
||||||
marketplace = (await ocean.accounts.list())[3]
|
marketplace = (await ocean.accounts.list())[3]
|
||||||
data = { t: 1, url: config.metadataStoreUri }
|
data = { t: 1, url: config.metadataCacheUri }
|
||||||
blob = JSON.stringify(data)
|
blob = JSON.stringify(data)
|
||||||
await contracts.deployContracts(owner.getId())
|
await contracts.deployContracts(owner.getId())
|
||||||
})
|
})
|
||||||
|
@ -7,7 +7,7 @@ LoggerInstance.setLevel(LogLevel.Error)
|
|||||||
const web3 = new Web3('http://127.0.0.1:8545')
|
const web3 = new Web3('http://127.0.0.1:8545')
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
metadataStoreUri: 'http://aquarius:5000',
|
metadataCacheUri: 'http://aquarius:5000',
|
||||||
providerUri: 'http://localhost:8030',
|
providerUri: 'http://localhost:8030',
|
||||||
nodeUri: `http://localhost:${process.env.ETH_PORT || 8545}`,
|
nodeUri: `http://localhost:${process.env.ETH_PORT || 8545}`,
|
||||||
verbose: LogLevel.Error,
|
verbose: LogLevel.Error,
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
import { MetadataStore } from '../../../src/metadatastore/MetadataStore'
|
import { MetadataCache } from '../../../src/metadatacache/MetadataCache'
|
||||||
import { DDO } from '../../../src/ddo/DDO'
|
import { DDO } from '../../../src/ddo/DDO'
|
||||||
import DID from '../../../src/ocean/DID'
|
import DID from '../../../src/ocean/DID'
|
||||||
|
|
||||||
const ddoStore: Map<string, any> = new Map<string, any>()
|
const ddoStore: Map<string, any> = new Map<string, any>()
|
||||||
|
|
||||||
export default class MetadataStoreMock extends MetadataStore {
|
export default class MetadataCacheMock extends MetadataCache {
|
||||||
public async getAccessUrl(accessToken: any, payload: any): Promise<string> {
|
public async getAccessUrl(accessToken: any, payload: any): Promise<string> {
|
||||||
return 'http://test/test'
|
return 'http://test/test'
|
||||||
}
|
}
|
@ -4,7 +4,7 @@ import { LoggerInstance, LogLevel } from '../../src/utils'
|
|||||||
LoggerInstance.setLevel(LogLevel.Error)
|
LoggerInstance.setLevel(LogLevel.Error)
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
metadataStoreUri: 'http://localhost:5000',
|
metadataCacheUri: 'http://localhost:5000',
|
||||||
providerUri: 'http://localhost:8030',
|
providerUri: 'http://localhost:8030',
|
||||||
nodeUri: `http://localhost:${process.env.ETH_PORT || 8545}`,
|
nodeUri: `http://localhost:${process.env.ETH_PORT || 8545}`,
|
||||||
parityUri: 'http://localhost:9545',
|
parityUri: 'http://localhost:9545',
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import { assert, spy, use } from 'chai'
|
import { assert, spy, use } from 'chai'
|
||||||
import spies from 'chai-spies'
|
import spies from 'chai-spies'
|
||||||
import { Ocean } from '../../../src/ocean/Ocean'
|
import { Ocean } from '../../../src/ocean/Ocean'
|
||||||
import { MetadataStore, SearchQuery } from '../../../src/metadatastore/MetadataStore'
|
import { MetadataCache, SearchQuery } from '../../../src/metadatacache/MetadataCache'
|
||||||
import { DDO } from '../../../src/ddo/DDO'
|
import { DDO } from '../../../src/ddo/DDO'
|
||||||
import DID from '../../../src/ocean/DID'
|
import DID from '../../../src/ocean/DID'
|
||||||
import config from '../config'
|
import config from '../config'
|
||||||
@ -10,13 +10,13 @@ import { responsify, getSearchResults } from '../helpers'
|
|||||||
|
|
||||||
use(spies)
|
use(spies)
|
||||||
|
|
||||||
describe('MetadataStore', () => {
|
describe('MetadataCache', () => {
|
||||||
let ocean: Ocean
|
let ocean: Ocean
|
||||||
let metadataStore: MetadataStore
|
let metadataCache: MetadataCache
|
||||||
|
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
ocean = await Ocean.getInstance(config)
|
ocean = await Ocean.getInstance(config)
|
||||||
metadataStore = ocean.metadatastore // eslint-disable-line prefer-destructuring
|
metadataCache = ocean.metadatacache // eslint-disable-line prefer-destructuring
|
||||||
})
|
})
|
||||||
|
|
||||||
afterEach(() => {
|
afterEach(() => {
|
||||||
@ -37,9 +37,9 @@ describe('MetadataStore', () => {
|
|||||||
} as SearchQuery
|
} as SearchQuery
|
||||||
|
|
||||||
it('should query metadata', async () => {
|
it('should query metadata', async () => {
|
||||||
spy.on(metadataStore.fetch, 'post', () => responsify(getSearchResults([new DDO()])))
|
spy.on(metadataCache.fetch, 'post', () => responsify(getSearchResults([new DDO()])))
|
||||||
|
|
||||||
const result = await metadataStore.queryMetadata(query)
|
const result = await metadataCache.queryMetadata(query)
|
||||||
assert.typeOf(result.results, 'array')
|
assert.typeOf(result.results, 'array')
|
||||||
assert.lengthOf(result.results, 1)
|
assert.lengthOf(result.results, 1)
|
||||||
assert.equal(result.page, 0)
|
assert.equal(result.page, 0)
|
||||||
@ -48,7 +48,7 @@ describe('MetadataStore', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
it('should query metadata with a new instance', async () => {
|
it('should query metadata with a new instance', async () => {
|
||||||
const metadatastoreNew = new MetadataStore(config.metadataStoreUri, LoggerInstance)
|
const metadatastoreNew = new MetadataCache(config.metadataCacheUri, LoggerInstance)
|
||||||
spy.on(metadatastoreNew.fetch, 'post', () =>
|
spy.on(metadatastoreNew.fetch, 'post', () =>
|
||||||
responsify(getSearchResults([new DDO()]))
|
responsify(getSearchResults([new DDO()]))
|
||||||
)
|
)
|
||||||
@ -62,9 +62,9 @@ describe('MetadataStore', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
it('should query metadata and return real ddo', async () => {
|
it('should query metadata and return real ddo', async () => {
|
||||||
spy.on(metadataStore.fetch, 'post', () => responsify(getSearchResults([new DDO()])))
|
spy.on(metadataCache.fetch, 'post', () => responsify(getSearchResults([new DDO()])))
|
||||||
|
|
||||||
const result = await metadataStore.queryMetadata(query)
|
const result = await metadataCache.queryMetadata(query)
|
||||||
assert.typeOf(result.results, 'array')
|
assert.typeOf(result.results, 'array')
|
||||||
assert.lengthOf(result.results, 1)
|
assert.lengthOf(result.results, 1)
|
||||||
assert.isDefined(result.results[0].findServiceById)
|
assert.isDefined(result.results[0].findServiceById)
|
||||||
@ -78,9 +78,9 @@ describe('MetadataStore', () => {
|
|||||||
id: did.getId()
|
id: did.getId()
|
||||||
})
|
})
|
||||||
|
|
||||||
spy.on(metadataStore.fetch, 'post', () => responsify(ddo))
|
spy.on(metadataCache.fetch, 'post', () => responsify(ddo))
|
||||||
|
|
||||||
const result: DDO = await metadataStore.storeDDO(ddo)
|
const result: DDO = await metadataCache.storeDDO(ddo)
|
||||||
assert(result)
|
assert(result)
|
||||||
assert(result.id === ddo.id)
|
assert(result.id === ddo.id)
|
||||||
})
|
})
|
||||||
@ -93,15 +93,15 @@ describe('MetadataStore', () => {
|
|||||||
id: did.getId()
|
id: did.getId()
|
||||||
})
|
})
|
||||||
|
|
||||||
spy.on(metadataStore.fetch, 'post', () => responsify(ddo))
|
spy.on(metadataCache.fetch, 'post', () => responsify(ddo))
|
||||||
spy.on(metadataStore.fetch, 'get', () => responsify(ddo))
|
spy.on(metadataCache.fetch, 'get', () => responsify(ddo))
|
||||||
|
|
||||||
const storageResult: DDO = await metadataStore.storeDDO(ddo)
|
const storageResult: DDO = await metadataCache.storeDDO(ddo)
|
||||||
assert(storageResult)
|
assert(storageResult)
|
||||||
|
|
||||||
assert(storageResult.id === did.getId())
|
assert(storageResult.id === did.getId())
|
||||||
|
|
||||||
const restrieveResult: DDO = await metadataStore.retrieveDDO(did)
|
const restrieveResult: DDO = await metadataCache.retrieveDDO(did)
|
||||||
assert(restrieveResult)
|
assert(restrieveResult)
|
||||||
|
|
||||||
assert(restrieveResult.id === did.getId())
|
assert(restrieveResult.id === did.getId())
|
@ -1,7 +1,7 @@
|
|||||||
import { assert, spy, use } from 'chai'
|
import { assert, spy, use } from 'chai'
|
||||||
import spies from 'chai-spies'
|
import spies from 'chai-spies'
|
||||||
|
|
||||||
import { SearchQuery, MetadataStore } from '../../../src/metadatastore/MetadataStore'
|
import { SearchQuery, MetadataCache } from '../../../src/metadatacache/MetadataCache'
|
||||||
import { Ocean } from '../../../src/ocean/Ocean'
|
import { Ocean } from '../../../src/ocean/Ocean'
|
||||||
import config from '../config'
|
import config from '../config'
|
||||||
import { DDO } from '../../../src/lib'
|
import { DDO } from '../../../src/lib'
|
||||||
@ -11,11 +11,11 @@ use(spies)
|
|||||||
|
|
||||||
describe('Assets', () => {
|
describe('Assets', () => {
|
||||||
let ocean: Ocean
|
let ocean: Ocean
|
||||||
let metadataStore: MetadataStore
|
let metadataCache: MetadataCache
|
||||||
|
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
ocean = await Ocean.getInstance(config)
|
ocean = await Ocean.getInstance(config)
|
||||||
metadataStore = ocean.metadatastore // eslint-disable-line prefer-destructuring
|
metadataCache = ocean.metadatacache // eslint-disable-line prefer-destructuring
|
||||||
})
|
})
|
||||||
|
|
||||||
afterEach(() => {
|
afterEach(() => {
|
||||||
@ -35,7 +35,7 @@ describe('Assets', () => {
|
|||||||
}
|
}
|
||||||
} as SearchQuery
|
} as SearchQuery
|
||||||
|
|
||||||
spy.on(metadataStore.fetch, 'post', () => responsify(getSearchResults([new DDO()])))
|
spy.on(metadataCache.fetch, 'post', () => responsify(getSearchResults([new DDO()])))
|
||||||
const assets = await ocean.assets.query(query)
|
const assets = await ocean.assets.query(query)
|
||||||
|
|
||||||
assert.typeOf(assets.results, 'array')
|
assert.typeOf(assets.results, 'array')
|
||||||
@ -47,7 +47,7 @@ describe('Assets', () => {
|
|||||||
describe('#search()', () => {
|
describe('#search()', () => {
|
||||||
it('should search for assets', async () => {
|
it('should search for assets', async () => {
|
||||||
const text = 'office'
|
const text = 'office'
|
||||||
spy.on(metadataStore.fetch, 'post', () => responsify(getSearchResults([new DDO()])))
|
spy.on(metadataCache.fetch, 'post', () => responsify(getSearchResults([new DDO()])))
|
||||||
const assets = await ocean.assets.search(text)
|
const assets = await ocean.assets.search(text)
|
||||||
|
|
||||||
assert.typeOf(assets.results, 'array')
|
assert.typeOf(assets.results, 'array')
|
||||||
|
Loading…
x
Reference in New Issue
Block a user