mirror of
https://github.com/oceanprotocol/market.git
synced 2024-11-14 01:04:53 +01:00
consolidate actual app config
This commit is contained in:
parent
4e2b41ce35
commit
1de31e4eff
@ -81,7 +81,7 @@ Files under `/api` are isolated and not part of Gatsby.
|
||||
|
||||
## 🦑 Environment variables
|
||||
|
||||
The `./src/config/ocean.ts` file is setup to prioritize environment variables for setting each Ocean component endpoint. By setting environment variables, you can easily switch between Ocean networks the app connects to, without directly modifying `./src/config/ocean.ts`.
|
||||
The `app.config.js` file is setup to prioritize environment variables for setting each Ocean component endpoint. By setting environment variables, you can easily switch between Ocean networks the app connects to, without directly modifying `app.config.js`.
|
||||
|
||||
For local development, you can use a `.env` file:
|
||||
|
||||
|
19
app.config.js
Normal file
19
app.config.js
Normal file
@ -0,0 +1,19 @@
|
||||
module.exports = {
|
||||
oceanConfig: {
|
||||
nodeUri: process.env.NODE_URI || 'https://pacific.oceanprotocol.com',
|
||||
aquariusUri:
|
||||
process.env.AQUARIUS_URI ||
|
||||
'https://aquarius.marketplace.oceanprotocol.com',
|
||||
brizoUri:
|
||||
process.env.BRIZO_URI || 'https://brizo.marketplace.oceanprotocol.com',
|
||||
brizoAddress:
|
||||
process.env.BRIZO_ADDRESS || '0x00c6A0BC5cD0078d6Cd0b659E8061B404cfa5704',
|
||||
secretStoreUri:
|
||||
process.env.SECRET_STORE_URI || 'https://secret-store.oceanprotocol.com',
|
||||
faucetUri: process.env.FAUCET_URI || 'https://faucet.oceanprotocol.com',
|
||||
ratingUri:
|
||||
process.env.RATING_URI ||
|
||||
'https://rating.pacific.marketplace.dev-ocean.com',
|
||||
verbose: 3
|
||||
}
|
||||
}
|
@ -1,10 +1,11 @@
|
||||
require('dotenv').config()
|
||||
|
||||
const siteConfig = require('./content/site.json')
|
||||
const siteContent = require('./content/site.json')
|
||||
const { oceanConfig } = require('./app.config')
|
||||
|
||||
module.exports = {
|
||||
siteMetadata: {
|
||||
...siteConfig.site
|
||||
...siteContent.site
|
||||
},
|
||||
plugins: [
|
||||
{
|
||||
@ -31,7 +32,7 @@ module.exports = {
|
||||
{
|
||||
resolve: 'gatsby-source-ocean',
|
||||
options: {
|
||||
aquariusUri: 'https://aquarius.marketplace.oceanprotocol.com'
|
||||
aquariusUri: oceanConfig.aquariusUri
|
||||
}
|
||||
},
|
||||
{
|
||||
@ -58,12 +59,12 @@ module.exports = {
|
||||
// https://www.gatsbyjs.org/packages/gatsby-plugin-manifest/#using-with-gatsby-plugin-offline
|
||||
resolve: 'gatsby-plugin-manifest',
|
||||
options: {
|
||||
name: siteConfig.site.siteTitle,
|
||||
short_name: siteConfig.site.siteTitle,
|
||||
name: siteContent.site.siteTitle,
|
||||
short_name: siteContent.site.siteTitle,
|
||||
start_url: '/',
|
||||
background_color: '#ffffff',
|
||||
theme_color: '#141414',
|
||||
icon: siteConfig.site.siteIcon,
|
||||
icon: siteContent.site.siteIcon,
|
||||
display: 'standalone',
|
||||
cache_busting_mode: 'none'
|
||||
}
|
||||
|
@ -1,5 +1,4 @@
|
||||
const path = require('path')
|
||||
// const { config } = require('./src/config/ocean')
|
||||
|
||||
exports.onCreateWebpackConfig = ({ actions }) => {
|
||||
actions.setWebpackConfig({
|
||||
|
@ -2,10 +2,9 @@ const axios = require('axios')
|
||||
|
||||
exports.sourceNodes = async (
|
||||
{ actions, createNodeId, createContentDigest },
|
||||
pluginOptions
|
||||
{ aquariusUri }
|
||||
) => {
|
||||
const { createNode } = actions
|
||||
const { aquariusUri } = pluginOptions
|
||||
|
||||
// Query for all assets to use in creating pages.
|
||||
const result = await axios(`${aquariusUri}/api/v1/aquarius/assets`)
|
||||
@ -29,7 +28,7 @@ exports.sourceNodes = async (
|
||||
internal: {
|
||||
type: 'OceanAsset',
|
||||
contentDigest: createContentDigest(metadata),
|
||||
description: `All data sets queried from ${pluginOptions.aquariusUri}`
|
||||
description: `All data sets queried from ${aquariusUri}`
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -14,7 +14,6 @@ import Button from '../atoms/Button'
|
||||
import { MetaDataMain, Logger } from '@oceanprotocol/squid'
|
||||
import DateCell from '../atoms/Table/DateCell'
|
||||
import DdoLinkCell from '../atoms/Table/DdoLinkCell'
|
||||
import { config } from '../../config/ocean'
|
||||
import shortid from 'shortid'
|
||||
import ActionsCell from '../atoms/Table/ActionsCell'
|
||||
import Tooltip from '../atoms/Tooltip'
|
||||
|
@ -4,7 +4,7 @@ import {
|
||||
} from '@oceanprotocol/squid/dist/node/aquarius/Aquarius'
|
||||
import { priceQueryParamToWei } from '../../../utils'
|
||||
import { Aquarius, Logger } from '@oceanprotocol/squid'
|
||||
import { config } from '../../../config/ocean'
|
||||
import { oceanConfig } from '../../../../app.config'
|
||||
|
||||
export function getSearchQuery(
|
||||
page?: string | string[],
|
||||
@ -52,7 +52,7 @@ export async function getResults(params: any): Promise<QueryResult> {
|
||||
])
|
||||
: undefined
|
||||
|
||||
const aquarius = new Aquarius(config.aquariusUri, Logger)
|
||||
const aquarius = new Aquarius(oceanConfig.aquariusUri, Logger)
|
||||
const queryResult = await aquarius.queryMetadata(
|
||||
getSearchQuery(page, offset, text, tag, priceQuery)
|
||||
)
|
||||
|
@ -1,41 +0,0 @@
|
||||
import { Config } from '@oceanprotocol/squid'
|
||||
|
||||
export enum OceanNetworkChainIds {
|
||||
'Pacific' = 846353,
|
||||
'Nile' = 8995,
|
||||
'Spree' = 8996
|
||||
}
|
||||
|
||||
declare type OceanNetworks =
|
||||
| OceanNetworkChainIds.Pacific
|
||||
| OceanNetworkChainIds.Nile
|
||||
| OceanNetworkChainIds.Spree
|
||||
|
||||
export interface OceanConfig extends Config {
|
||||
faucetUri: string
|
||||
ratingUri: string
|
||||
}
|
||||
|
||||
export const config: OceanConfig = {
|
||||
nodeUri: process.env.NODE_URI || 'https://pacific.oceanprotocol.com',
|
||||
aquariusUri:
|
||||
process.env.AQUARIUS_URI ||
|
||||
'https://aquarius.marketplace.oceanprotocol.com',
|
||||
brizoUri:
|
||||
process.env.BRIZO_URI || 'https://brizo.marketplace.oceanprotocol.com',
|
||||
brizoAddress:
|
||||
process.env.BRIZO_ADDRESS || '0x00c6A0BC5cD0078d6Cd0b659E8061B404cfa5704',
|
||||
secretStoreUri:
|
||||
process.env.SECRET_STORE_URI || 'https://secret-store.oceanprotocol.com',
|
||||
faucetUri: process.env.FAUCET_URI || 'https://faucet.oceanprotocol.com',
|
||||
ratingUri:
|
||||
process.env.RATING_URI ||
|
||||
'https://rating.pacific.marketplace.dev-ocean.com',
|
||||
verbose: 3
|
||||
}
|
||||
|
||||
export const CHAIN_IDS: OceanNetworks[] = [
|
||||
OceanNetworkChainIds.Pacific,
|
||||
OceanNetworkChainIds.Nile,
|
||||
OceanNetworkChainIds.Spree
|
||||
]
|
@ -1,6 +1,6 @@
|
||||
import React, { ReactElement } from 'react'
|
||||
import { Web3Provider, OceanProvider, Config } from '@oceanprotocol/react'
|
||||
import { config } from '../config/ocean'
|
||||
import { oceanConfig } from '../../app.config'
|
||||
|
||||
const wrapRootElement = ({
|
||||
element
|
||||
@ -8,7 +8,7 @@ const wrapRootElement = ({
|
||||
element: ReactElement
|
||||
}): ReactElement => (
|
||||
<Web3Provider>
|
||||
<OceanProvider config={config as Config}>{element}</OceanProvider>
|
||||
<OceanProvider config={oceanConfig as Config}>{element}</OceanProvider>
|
||||
</Web3Provider>
|
||||
)
|
||||
|
||||
|
@ -5,7 +5,7 @@ import Layout from '../../components/Layout'
|
||||
import { PageProps } from 'gatsby'
|
||||
import { MetaDataMarket, ServiceMetaDataMarket } from '../../@types/MetaData'
|
||||
import { Aquarius, Logger } from '@oceanprotocol/squid'
|
||||
import { config } from '../../config/ocean'
|
||||
import { oceanConfig } from '../../../app.config'
|
||||
import { Alert } from '../../components/atoms/Alert'
|
||||
|
||||
export default function AssetRoute(props: PageProps): ReactElement {
|
||||
@ -18,7 +18,7 @@ export default function AssetRoute(props: PageProps): ReactElement {
|
||||
useEffect(() => {
|
||||
async function init() {
|
||||
try {
|
||||
const aquarius = new Aquarius(config.aquariusUri, Logger)
|
||||
const aquarius = new Aquarius(oceanConfig.aquariusUri, Logger)
|
||||
const ddo = await aquarius.retrieveDDO(did)
|
||||
|
||||
if (!ddo) {
|
||||
|
@ -1,6 +1,6 @@
|
||||
import axios from 'axios'
|
||||
import { DID } from '@oceanprotocol/squid'
|
||||
import { config } from '../config/ocean'
|
||||
import { oceanConfig } from '../../app.config'
|
||||
|
||||
export declare type GetRatingResponse = {
|
||||
comment: string
|
||||
@ -8,7 +8,7 @@ export declare type GetRatingResponse = {
|
||||
vote: number
|
||||
}
|
||||
|
||||
const url = config.ratingUri + '/api/v1/rating'
|
||||
const url = oceanConfig.ratingUri + '/api/v1/rating'
|
||||
|
||||
export default async function getAssetRating(
|
||||
did: DID | string,
|
||||
|
@ -1,5 +1,5 @@
|
||||
import axios, { AxiosResponse } from 'axios'
|
||||
import { config } from '../config/ocean'
|
||||
import { oceanConfig } from '../../app.config'
|
||||
|
||||
export interface FaucetResponse {
|
||||
success: boolean
|
||||
@ -13,7 +13,7 @@ export default async function getFromFaucet(
|
||||
try {
|
||||
const response: AxiosResponse = await axios({
|
||||
method: 'POST',
|
||||
url: `${config.faucetUri}/faucet`,
|
||||
url: `${oceanConfig.faucetUri}/faucet`,
|
||||
data: {
|
||||
address: account,
|
||||
agent: 'market'
|
||||
|
@ -1,11 +1,11 @@
|
||||
import axios, { AxiosResponse } from 'axios'
|
||||
import Web3 from 'web3'
|
||||
import { DID } from '@oceanprotocol/squid'
|
||||
import { config } from '../config/ocean'
|
||||
import { oceanConfig } from '../../app.config'
|
||||
|
||||
export declare type RatingResponse = [string, number]
|
||||
|
||||
const url = config.ratingUri + '/api/v1/rating'
|
||||
const url = oceanConfig.ratingUri + '/api/v1/rating'
|
||||
|
||||
export function gethash(message: string) {
|
||||
let hex = ''
|
||||
|
@ -12,8 +12,9 @@
|
||||
"noEmit": true,
|
||||
"sourceMap": true,
|
||||
"noImplicitAny": true,
|
||||
"skipLibCheck": true
|
||||
"skipLibCheck": true,
|
||||
"allowJs": true
|
||||
},
|
||||
"exclude": ["node_modules", "public", ".cache", "*.js"],
|
||||
"include": ["./src/**/*", "./api/**/*", "./tests/**/*"]
|
||||
"include": ["./src/**/*", "./api/**/*", "./tests/**/*", "./app.config.js"]
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user