mirror of
https://github.com/oceanprotocol/market.git
synced 2024-12-02 05:57:29 +01:00
more config refactor
This commit is contained in:
parent
e9f39be9c3
commit
bf0375f58f
@ -1,13 +1,15 @@
|
||||
const { ConfigHelper } = require('@oceanprotocol/lib')
|
||||
|
||||
const oceanConfig = new ConfigHelper().getConfig(
|
||||
process.env.GATSBY_NETWORK || 'rinkeby'
|
||||
)
|
||||
function getDefaultOceanConfig() {
|
||||
return new ConfigHelper().getConfig(
|
||||
process.env.GATSBY_NETWORK || 'rinkeby',
|
||||
process.env.GATSBY_INFURA_PROJECT_ID
|
||||
)
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
const appConfig = {
|
||||
oceanConfig: {
|
||||
...oceanConfig,
|
||||
url: `https://rinkeby.infura.io/${process.env.GATSBY_INFURA_PROJECT_ID}`,
|
||||
...getDefaultOceanConfig(),
|
||||
verbose: 3
|
||||
},
|
||||
// Main, Rinkeby, Kovan
|
||||
@ -15,3 +17,8 @@ module.exports = {
|
||||
networks: [4],
|
||||
infuraProjectId: process.env.GATSBY_INFURA_PROJECT_ID || 'xxx'
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
getDefaultOceanConfig,
|
||||
appConfig
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
require('dotenv').config()
|
||||
|
||||
const siteContent = require('./content/site.json')
|
||||
const appConfig = require('./app.config')
|
||||
const { appConfig } = require('./app.config')
|
||||
|
||||
module.exports = {
|
||||
siteMetadata: {
|
||||
|
12
package-lock.json
generated
12
package-lock.json
generated
@ -3745,14 +3745,14 @@
|
||||
"integrity": "sha512-j4PEZSVtKSqxDYMVh/hd5vk088Bg6a6QkrUMTXN9Q6OIFAMfHM235f1AxaakNrEyK0FKMD908KuJEdfFLRn9Hw=="
|
||||
},
|
||||
"@oceanprotocol/contracts": {
|
||||
"version": "0.3.1",
|
||||
"resolved": "https://registry.npmjs.org/@oceanprotocol/contracts/-/contracts-0.3.1.tgz",
|
||||
"integrity": "sha512-LaOPxTID+iMRaUYneAOyG6jQQL8Gz9XA0jEqXvhJOqB/WL2zySL2StXpXPpMxzFq6APdpbnQ70s4jBgVChBN2w=="
|
||||
"version": "0.3.3",
|
||||
"resolved": "https://registry.npmjs.org/@oceanprotocol/contracts/-/contracts-0.3.3.tgz",
|
||||
"integrity": "sha512-ZQ5RHQWp6xkmATt7Sl12LhnH4dovewgKPX1gGeZoDSyFcmpjMDngtJpDns8jMsaclU61tPScw7K/EmxS1ydiCg=="
|
||||
},
|
||||
"@oceanprotocol/lib": {
|
||||
"version": "0.1.8",
|
||||
"resolved": "https://registry.npmjs.org/@oceanprotocol/lib/-/lib-0.1.8.tgz",
|
||||
"integrity": "sha512-qYaOpPzziMP7dMKEMEchqkB8bZHc/CQy2wR7DLP4X/ke28Z1RNYPgrPOo3by7DMEPbHwzqkpAqMoBlrdNh+MqA==",
|
||||
"version": "0.1.9",
|
||||
"resolved": "https://registry.npmjs.org/@oceanprotocol/lib/-/lib-0.1.9.tgz",
|
||||
"integrity": "sha512-o4qjpoPm5s3NutNfwAV3ALPjAzvWknn6p/aI+GGH2ZtDkDE9zx0k+TqaWCsMaM/3e5v23eCof517y4Hd459EZg==",
|
||||
"requires": {
|
||||
"@ethereum-navigator/navigator": "^0.5.0",
|
||||
"@oceanprotocol/contracts": "^0.3.1",
|
||||
|
@ -21,6 +21,7 @@
|
||||
"dependencies": {
|
||||
"@loadable/component": "^5.13.1",
|
||||
"@oceanprotocol/art": "^3.0.0",
|
||||
"@oceanprotocol/lib": "^0.1.9",
|
||||
"@oceanprotocol/react": "^0.0.27",
|
||||
"@oceanprotocol/typographies": "^0.1.0",
|
||||
"@sindresorhus/slugify": "^1.0.0",
|
||||
|
@ -7,7 +7,7 @@ import { updateQueryStringParameter } from '../../utils'
|
||||
import styles from './AssetList.module.css'
|
||||
import { MetadataMarket } from '../../@types/Metadata'
|
||||
import { DDO } from '@oceanprotocol/lib'
|
||||
import { getOceanConfig } from '../../utils/getConfig'
|
||||
import { getDefaultOceanConfig } from '../../../app.config'
|
||||
|
||||
declare type AssetListProps = {
|
||||
queryResult: QueryResult
|
||||
@ -17,7 +17,7 @@ const AssetList: React.FC<AssetListProps> = ({ queryResult }) => {
|
||||
const location = useLocation()
|
||||
const navigate = useNavigate()
|
||||
|
||||
const { metadataStoreUri } = getOceanConfig()
|
||||
const { metadataStoreUri } = getDefaultOceanConfig()
|
||||
|
||||
// Construct the urls on the pagination links. This is only for UX,
|
||||
// since the links are no <Link> they will not work by itself.
|
||||
|
@ -6,11 +6,11 @@ import AssetList from '../organisms/AssetList'
|
||||
import { QueryResult } from '@oceanprotocol/lib/dist/node/metadatastore/MetadataStore'
|
||||
import Container from '../atoms/Container'
|
||||
import Loader from '../atoms/Loader'
|
||||
import { getOceanConfig } from '../../utils/getConfig'
|
||||
import { getDefaultOceanConfig } from '../../../app.config'
|
||||
|
||||
async function getLatestAssets() {
|
||||
try {
|
||||
const { metadataStoreUri } = getOceanConfig()
|
||||
const { metadataStoreUri } = getDefaultOceanConfig()
|
||||
const metadataStore = new MetadataStore(metadataStoreUri, Logger)
|
||||
|
||||
const result = await metadataStore.queryMetadata({
|
||||
|
@ -6,7 +6,7 @@ import { MetadataMarket, ServiceMetadataMarket } from '../../@types/Metadata'
|
||||
import { MetadataStore, Logger, DDO } from '@oceanprotocol/lib'
|
||||
import Alert from '../../components/atoms/Alert'
|
||||
import Loader from '../../components/atoms/Loader'
|
||||
import { getOceanConfig } from '../../utils/getConfig'
|
||||
import { getDefaultOceanConfig } from '../../../app.config'
|
||||
|
||||
export default function PageTemplateAssetDetails({
|
||||
did,
|
||||
@ -23,7 +23,7 @@ export default function PageTemplateAssetDetails({
|
||||
useEffect(() => {
|
||||
async function init() {
|
||||
try {
|
||||
const { metadataStoreUri } = getOceanConfig()
|
||||
const { metadataStoreUri } = getDefaultOceanConfig()
|
||||
const metadataStore = new MetadataStore(metadataStoreUri, Logger)
|
||||
const ddo = await metadataStore.retrieveDDO(did)
|
||||
setDdo(ddo)
|
||||
|
@ -4,7 +4,7 @@ import {
|
||||
} from '@oceanprotocol/lib/dist/node/metadatastore/MetadataStore'
|
||||
import { priceQueryParamToWei } from '../../../utils'
|
||||
import { MetadataStore, Logger } from '@oceanprotocol/lib'
|
||||
import { getOceanConfig } from '../../../utils/getConfig'
|
||||
import { getDefaultOceanConfig } from '../../../../app.config'
|
||||
|
||||
export function getSearchQuery(
|
||||
page?: string | string[],
|
||||
@ -52,7 +52,7 @@ export async function getResults(params: any): Promise<QueryResult> {
|
||||
])
|
||||
: undefined
|
||||
|
||||
const { metadataStoreUri } = getOceanConfig()
|
||||
const { metadataStoreUri } = getDefaultOceanConfig()
|
||||
const metadataStore = new MetadataStore(metadataStoreUri, Logger)
|
||||
const queryResult = await metadataStore.queryMetadata(
|
||||
getSearchQuery(page, offset, text, tag, priceQuery)
|
||||
|
@ -1,13 +1,13 @@
|
||||
import React, { ReactElement } from 'react'
|
||||
import { OceanProvider } from '@oceanprotocol/react'
|
||||
import { oceanConfig } from '../../app.config'
|
||||
import { appConfig } from '../../app.config'
|
||||
|
||||
const wrapRootElement = ({
|
||||
element
|
||||
}: {
|
||||
element: ReactElement
|
||||
}): ReactElement => (
|
||||
<OceanProvider config={oceanConfig}>{element}</OceanProvider>
|
||||
<OceanProvider config={appConfig.oceanConfig}>{element}</OceanProvider>
|
||||
)
|
||||
|
||||
export default wrapRootElement
|
||||
|
@ -1,5 +0,0 @@
|
||||
import { ConfigHelper, Config } from '@oceanprotocol/lib'
|
||||
|
||||
export function getOceanConfig(): Config {
|
||||
return new ConfigHelper().getConfig(process.env.GATSBY_NETWORK || 'rinkeby')
|
||||
}
|
@ -1,5 +1,7 @@
|
||||
import { OceanProviderValue } from '@oceanprotocol/react'
|
||||
import { networks, infuraProjectId } from '../../app.config'
|
||||
import { appConfig } from '../../app.config'
|
||||
|
||||
const { infuraProjectId, networks } = appConfig
|
||||
|
||||
const web3ModalTheme = {
|
||||
background: 'var(--brand-white)',
|
||||
|
Loading…
Reference in New Issue
Block a user