1
0
mirror of https://github.com/oceanprotocol/market.git synced 2024-12-02 05:57:29 +01:00

metadataStore → metadataCache, package updates

This commit is contained in:
Matthias Kretschmann 2020-10-13 17:05:57 +02:00
parent aeb26b89c5
commit 93179c8c37
Signed by: m
GPG Key ID: 606EEEF3C479A91F
13 changed files with 353 additions and 331 deletions

View File

@ -2,5 +2,5 @@
GATSBY_NETWORK="rinkeby" GATSBY_NETWORK="rinkeby"
#GATSBY_INFURA_PROJECT_ID="xxx" #GATSBY_INFURA_PROJECT_ID="xxx"
#GATSBY_METADATA_STORE_URI="xxx" #GATSBY_METADATA_CACHE_URI="xxx"
#GATSBY_MARKET_FEE_ADDRESS="0xxx" #GATSBY_MARKET_FEE_ADDRESS="0xxx"

View File

@ -1,7 +1,7 @@
module.exports = { module.exports = {
network: process.env.GATSBY_NETWORK || 'rinkeby', network: process.env.GATSBY_NETWORK || 'rinkeby',
infuraProjectId: process.env.GATSBY_INFURA_PROJECT_ID || 'xxx', infuraProjectId: process.env.GATSBY_INFURA_PROJECT_ID || 'xxx',
metadataStoreUri: process.env.GATSBY_METADATA_STORE_URI, metadataCacheUri: process.env.GATSBY_METADATA_CACHE_URI,
// The ETH address the marketplace fee will be sent to. // The ETH address the marketplace fee will be sent to.
marketFeeAddress: marketFeeAddress:
process.env.GATSBY_MARKET_FEE_ADDRESS || process.env.GATSBY_MARKET_FEE_ADDRESS ||

586
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -22,15 +22,15 @@
"@coingecko/cryptoformat": "^0.4.2", "@coingecko/cryptoformat": "^0.4.2",
"@loadable/component": "5.13.1", "@loadable/component": "5.13.1",
"@oceanprotocol/art": "^3.0.0", "@oceanprotocol/art": "^3.0.0",
"@oceanprotocol/lib": "^0.5.6", "@oceanprotocol/lib": "^0.6.0",
"@oceanprotocol/react": "^0.1.4", "@oceanprotocol/react": "^0.2.0",
"@oceanprotocol/typographies": "^0.1.0", "@oceanprotocol/typographies": "^0.1.0",
"@sindresorhus/slugify": "^1.0.0", "@sindresorhus/slugify": "^1.0.0",
"@tippyjs/react": "^4.2.0", "@tippyjs/react": "^4.2.0",
"@toruslabs/torus-embed": "^1.8.5", "@toruslabs/torus-embed": "^1.8.6",
"@types/classnames": "^2.2.10", "@types/classnames": "^2.2.10",
"@vercel/node": "^1.8.4", "@vercel/node": "^1.8.4",
"@walletconnect/web3-provider": "^1.3.0", "@walletconnect/web3-provider": "^1.3.1",
"axios": "^0.20.0", "axios": "^0.20.0",
"classnames": "^2.2.6", "classnames": "^2.2.6",
"date-fns": "^2.16.1", "date-fns": "^2.16.1",
@ -40,12 +40,12 @@
"ethereum-blockies": "github:MyEtherWallet/blockies", "ethereum-blockies": "github:MyEtherWallet/blockies",
"filesize": "^6.1.0", "filesize": "^6.1.0",
"formik": "^2.2.0", "formik": "^2.2.0",
"gatsby": "^2.24.73", "gatsby": "^2.24.76",
"gatsby-image": "^2.4.21", "gatsby-image": "^2.4.21",
"gatsby-plugin-manifest": "^2.4.34", "gatsby-plugin-manifest": "^2.4.34",
"gatsby-plugin-react-helmet": "^3.3.14", "gatsby-plugin-react-helmet": "^3.3.14",
"gatsby-plugin-remove-trailing-slashes": "^2.3.13", "gatsby-plugin-remove-trailing-slashes": "^2.3.13",
"gatsby-plugin-sharp": "^2.6.40", "gatsby-plugin-sharp": "^2.6.42",
"gatsby-plugin-svgr": "^2.0.2", "gatsby-plugin-svgr": "^2.0.2",
"gatsby-plugin-webpack-size": "^1.0.0", "gatsby-plugin-webpack-size": "^1.0.0",
"gatsby-source-filesystem": "^2.3.34", "gatsby-source-filesystem": "^2.3.34",
@ -60,7 +60,7 @@
"query-string": "^6.13.5", "query-string": "^6.13.5",
"react": "^16.13.1", "react": "^16.13.1",
"react-data-table-component": "^6.11.5", "react-data-table-component": "^6.11.5",
"react-datepicker": "^3.2.2", "react-datepicker": "^3.3.0",
"react-dom": "^16.13.1", "react-dom": "^16.13.1",
"react-dotdotdot": "^1.3.1", "react-dotdotdot": "^1.3.1",
"react-dropzone": "^11.2.0", "react-dropzone": "^11.2.0",
@ -91,7 +91,7 @@
"@types/lodash.debounce": "^4.0.3", "@types/lodash.debounce": "^4.0.3",
"@types/lodash.omit": "^4.5.6", "@types/lodash.omit": "^4.5.6",
"@types/node": "^14.11.8", "@types/node": "^14.11.8",
"@types/react": "^16.9.51", "@types/react": "^16.9.52",
"@types/react-datepicker": "^3.1.1", "@types/react-datepicker": "^3.1.1",
"@types/react-helmet": "^6.1.0", "@types/react-helmet": "^6.1.0",
"@types/react-paginate": "^6.2.1", "@types/react-paginate": "^6.2.1",
@ -99,18 +99,18 @@
"@types/remove-markdown": "^0.1.1", "@types/remove-markdown": "^0.1.1",
"@types/shortid": "0.0.29", "@types/shortid": "0.0.29",
"@types/yup": "^0.29.8", "@types/yup": "^0.29.8",
"@typescript-eslint/eslint-plugin": "^4.4.0", "@typescript-eslint/eslint-plugin": "^4.4.1",
"@typescript-eslint/parser": "^4.4.0", "@typescript-eslint/parser": "^4.4.1",
"babel-loader": "^8.1.0", "babel-loader": "^8.1.0",
"babel-preset-react-app": "^9.1.2", "babel-preset-react-app": "^9.1.2",
"eslint": "^7.10.0", "eslint": "^7.11.0",
"eslint-config-oceanprotocol": "^1.5.0", "eslint-config-oceanprotocol": "^1.5.0",
"eslint-config-prettier": "^6.12.0", "eslint-config-prettier": "^6.12.0",
"eslint-plugin-prettier": "^3.1.4", "eslint-plugin-prettier": "^3.1.4",
"eslint-plugin-react": "^7.21.3", "eslint-plugin-react": "^7.21.4",
"eslint-plugin-react-hooks": "^4.1.2", "eslint-plugin-react-hooks": "^4.1.2",
"identity-obj-proxy": "^3.0.0", "identity-obj-proxy": "^3.0.0",
"jest": "^26.5.2", "jest": "^26.5.3",
"prettier": "^2.1.2", "prettier": "^2.1.2",
"serve": "^11.3.2", "serve": "^11.3.2",
"source-map-explorer": "^2.5.0", "source-map-explorer": "^2.5.0",

View File

@ -1,6 +1,6 @@
import AssetTeaser from '../molecules/AssetTeaser' import AssetTeaser from '../molecules/AssetTeaser'
import React from 'react' import React from 'react'
import { QueryResult } from '@oceanprotocol/lib/dist/node/metadatastore/MetadataStore' import { QueryResult } from '@oceanprotocol/lib/dist/node/metadatacache/MetadataCache'
import { useLocation, useNavigate } from '@reach/router' import { useLocation, useNavigate } from '@reach/router'
import Pagination from '../molecules/Pagination' import Pagination from '../molecules/Pagination'
import { updateQueryStringParameter } from '../../utils' import { updateQueryStringParameter } from '../../utils'
@ -57,7 +57,7 @@ const AssetList: React.FC<AssetListProps> = ({ queryResult }) => {
}) })
) : ( ) : (
<div className={styles.empty}> <div className={styles.empty}>
No results found in {config.metadataStoreUri} No results found in {config.metadataCacheUri}
</div> </div>
)} )}
</div> </div>

View File

@ -1,5 +1,5 @@
import { Logger } from '@oceanprotocol/lib' import { Logger } from '@oceanprotocol/lib'
import { QueryResult } from '@oceanprotocol/lib/dist/node/metadatastore/MetadataStore' import { QueryResult } from '@oceanprotocol/lib/dist/node/metadatacache/MetadataCache'
import { useOcean } from '@oceanprotocol/react' import { useOcean } from '@oceanprotocol/react'
import React, { ReactElement, useEffect, useState } from 'react' import React, { ReactElement, useEffect, useState } from 'react'
import Loader from '../../atoms/Loader' import Loader from '../../atoms/Loader'

View File

@ -1,12 +1,12 @@
import React, { ReactElement, useEffect, useState } from 'react' import React, { ReactElement, useEffect, useState } from 'react'
import SearchBar from '../molecules/SearchBar' import SearchBar from '../molecules/SearchBar'
import styles from './Home.module.css' import styles from './Home.module.css'
import { MetadataStore, Logger } from '@oceanprotocol/lib' import { MetadataCache, Logger } from '@oceanprotocol/lib'
import AssetList from '../organisms/AssetList' import AssetList from '../organisms/AssetList'
import { import {
QueryResult, QueryResult,
SearchQuery SearchQuery
} from '@oceanprotocol/lib/dist/node/metadatastore/MetadataStore' } from '@oceanprotocol/lib/dist/node/metadatacache/MetadataCache'
import Container from '../atoms/Container' import Container from '../atoms/Container'
import Loader from '../atoms/Loader' import Loader from '../atoms/Loader'
import { useOcean } from '@oceanprotocol/react' import { useOcean } from '@oceanprotocol/react'
@ -25,10 +25,10 @@ const queryLatest = {
sort: { created: -1 } sort: { created: -1 }
} }
async function getAssets(query: SearchQuery, metadataStoreUri: string) { async function getAssets(query: SearchQuery, metadataCacheUri: string) {
try { try {
const metadataStore = new MetadataStore(metadataStoreUri, Logger) const metadataCache = new MetadataCache(metadataCacheUri, Logger)
const result = await metadataStore.queryMetadata(query) const result = await metadataCache.queryMetadata(query)
return result return result
} catch (error) { } catch (error) {
@ -46,19 +46,19 @@ export default function HomePage(): ReactElement {
async function init() { async function init() {
const queryResultHighest = await getAssets( const queryResultHighest = await getAssets(
queryHighest, queryHighest,
config.metadataStoreUri config.metadataCacheUri
) )
setQueryResultHighest(queryResultHighest) setQueryResultHighest(queryResultHighest)
const queryResultLatest = await getAssets( const queryResultLatest = await getAssets(
queryLatest, queryLatest,
config.metadataStoreUri config.metadataCacheUri
) )
setQueryResultLatest(queryResultLatest) setQueryResultLatest(queryResultLatest)
setLoading(false) setLoading(false)
} }
init() init()
}, [config.metadataStoreUri]) }, [config.metadataCacheUri])
return ( return (
<> <>

View File

@ -3,7 +3,7 @@ import { Router } from '@reach/router'
import AssetContent from '../../components/organisms/AssetContent' import AssetContent from '../../components/organisms/AssetContent'
import Layout from '../../components/Layout' import Layout from '../../components/Layout'
import { MetadataMarket } from '../../@types/MetaData' import { MetadataMarket } from '../../@types/MetaData'
import { MetadataStore, Logger, DDO } from '@oceanprotocol/lib' import { MetadataCache, Logger, DDO } from '@oceanprotocol/lib'
import Alert from '../../components/atoms/Alert' import Alert from '../../components/atoms/Alert'
import Loader from '../../components/atoms/Loader' import Loader from '../../components/atoms/Loader'
import { useOcean } from '@oceanprotocol/react' import { useOcean } from '@oceanprotocol/react'
@ -24,12 +24,12 @@ export default function PageTemplateAssetDetails({
useEffect(() => { useEffect(() => {
async function init() { async function init() {
try { try {
const metadataStore = new MetadataStore(config.metadataStoreUri, Logger) const metadataCache = new MetadataCache(config.metadataCacheUri, Logger)
const ddo = await metadataStore.retrieveDDO(did) const ddo = await metadataCache.retrieveDDO(did)
if (!ddo) { if (!ddo) {
setTitle('Could not retrieve asset') setTitle('Could not retrieve asset')
setError('The DDO was not found in MetadataStore.') setError('The DDO was not found in MetadataCache.')
return return
} }
@ -44,7 +44,7 @@ export default function PageTemplateAssetDetails({
} }
} }
init() init()
}, [did, config.metadataStoreUri]) }, [did, config.metadataCacheUri])
return did && metadata ? ( return did && metadata ? (
<Layout title={title} uri={uri}> <Layout title={title} uri={uri}>

View File

@ -1,5 +1,5 @@
import React, { ReactElement, useState, useEffect } from 'react' import React, { ReactElement, useState, useEffect } from 'react'
import { QueryResult } from '@oceanprotocol/lib/dist/node/metadatastore/MetadataStore' import { QueryResult } from '@oceanprotocol/lib/dist/node/metadatacache/MetadataCache'
import SearchBar from '../../molecules/SearchBar' import SearchBar from '../../molecules/SearchBar'
import AssetList from '../../organisms/AssetList' import AssetList from '../../organisms/AssetList'
import styles from './index.module.css' import styles from './index.module.css'
@ -28,12 +28,12 @@ export default function SearchPage({
useEffect(() => { useEffect(() => {
async function initSearch() { async function initSearch() {
setLoading(true) setLoading(true)
const queryResult = await getResults(parsed, config.metadataStoreUri) const queryResult = await getResults(parsed, config.metadataCacheUri)
setQueryResult(queryResult) setQueryResult(queryResult)
setLoading(false) setLoading(false)
} }
initSearch() initSearch()
}, [text, tag, page, config.metadataStoreUri]) }, [text, tag, page, config.metadataCacheUri])
return ( return (
<section className={styles.grid}> <section className={styles.grid}>

View File

@ -1,8 +1,8 @@
import { import {
SearchQuery, SearchQuery,
QueryResult QueryResult
} from '@oceanprotocol/lib/dist/node/metadatastore/MetadataStore' } from '@oceanprotocol/lib/dist/node/metadatacache/MetadataCache'
import { MetadataStore, Logger } from '@oceanprotocol/lib' import { MetadataCache, Logger } from '@oceanprotocol/lib'
export function getSearchQuery( export function getSearchQuery(
page?: string | string[], page?: string | string[],
@ -30,12 +30,12 @@ export function getSearchQuery(
export async function getResults( export async function getResults(
params: { text?: string; tag?: string; page?: string; offset?: string }, params: { text?: string; tag?: string; page?: string; offset?: string },
metadataStoreUri: string metadataCacheUri: string
): Promise<QueryResult> { ): Promise<QueryResult> {
const { text, tag, page, offset } = params const { text, tag, page, offset } = params
const metadataStore = new MetadataStore(metadataStoreUri, Logger) const metadataCache = new MetadataCache(metadataCacheUri, Logger)
const queryResult = await metadataStore.queryMetadata( const queryResult = await metadataCache.queryMetadata(
getSearchQuery(page, offset, text, tag) getSearchQuery(page, offset, text, tag)
) )

View File

@ -5,7 +5,7 @@ import appConfig from '../../app.config'
import { Logger } from '@oceanprotocol/lib' import { Logger } from '@oceanprotocol/lib'
export function NetworkMonitor(): ReactElement { export function NetworkMonitor(): ReactElement {
const { metadataStoreUri } = appConfig const { metadataCacheUri } = appConfig
const { connect, web3Provider } = useOcean() const { connect, web3Provider } = useOcean()
useEffect(() => { useEffect(() => {
@ -16,8 +16,8 @@ export function NetworkMonitor(): ReactElement {
const newConfig = { const newConfig = {
...initialConfig, ...initialConfig,
// add metadataStoreUri only when defined // add metadataCacheUri only when defined
...(metadataStoreUri && { metadataStoreUri }) ...(metadataCacheUri && { metadataCacheUri })
} }
try { try {
@ -32,7 +32,7 @@ export function NetworkMonitor(): ReactElement {
return () => { return () => {
web3Provider.removeListener('chainChanged', handleNetworkChanged) web3Provider.removeListener('chainChanged', handleNetworkChanged)
} }
}, [web3Provider, connect, metadataStoreUri]) }, [web3Provider, connect, metadataCacheUri])
return <></> return <></>
} }

View File

@ -24,13 +24,13 @@ export default function wrapRootElement({
}: { }: {
element: ReactElement element: ReactElement
}): ReactElement { }): ReactElement {
const { metadataStoreUri, network } = appConfig const { metadataCacheUri, network } = appConfig
const oceanInitialConfig = getOceanConfig(network) const oceanInitialConfig = getOceanConfig(network)
const initialConfig = { const initialConfig = {
...oceanInitialConfig, ...oceanInitialConfig,
// add metadataStoreUri only when defined // add metadataCacheUri only when defined
...(metadataStoreUri && { metadataStoreUri }) ...(metadataCacheUri && { metadataCacheUri })
} }
return ( return (

View File

@ -1,6 +1,6 @@
import ddo from '../../__fixtures__/ddo' import ddo from '../../__fixtures__/ddo'
const metadataStore = { const metadataCache = {
queryMetadata: () => { queryMetadata: () => {
return { return {
results: [] as any[], results: [] as any[],
@ -11,13 +11,13 @@ const metadataStore = {
} }
const libMock = { const libMock = {
MetadataStore: () => metadataStore, MetadataStore: () => metadataCache,
DDO: () => ddo, DDO: () => ddo,
ocean: { ocean: {
accounts: { accounts: {
list: () => ['xxx', 'xxx'] list: () => ['xxx', 'xxx']
}, },
metadataStore, metadataCache,
// compute: { // compute: {
// status: (account: string) => { // status: (account: string) => {
// return [job] // return [job]