mirror of
https://github.com/oceanprotocol/market.git
synced 2024-12-02 05:57:29 +01:00
more refactor
This commit is contained in:
parent
c023f45138
commit
70470a9459
27
gatsby/createTypes.js
Normal file
27
gatsby/createTypes.js
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
function createTypes(actions) {
|
||||||
|
const { createTypes } = actions
|
||||||
|
|
||||||
|
// Extend ContentJson to support optional field "optionalCookies" in gdpr.json
|
||||||
|
// Extend PublishJsonData to support optional fields for disclaimers
|
||||||
|
const typeDefs = `
|
||||||
|
type ContentJson implements Node {
|
||||||
|
accept: String
|
||||||
|
reject: String
|
||||||
|
close: String
|
||||||
|
configure: String
|
||||||
|
optionalCookies: [Cookie!]
|
||||||
|
}
|
||||||
|
type Cookie {
|
||||||
|
title: String!
|
||||||
|
desc: String!
|
||||||
|
cookieName: String!
|
||||||
|
}
|
||||||
|
type PublishJsonData implements Node {
|
||||||
|
disclaimer: String
|
||||||
|
disclaimerValues: [String!]
|
||||||
|
}
|
||||||
|
`
|
||||||
|
createTypes(typeDefs)
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = createTypes
|
@ -15,16 +15,9 @@ import {
|
|||||||
import { useUserPreferences } from './UserPreferences'
|
import { useUserPreferences } from './UserPreferences'
|
||||||
import { PoolShares_poolShares as PoolShare } from '../@types/apollo/PoolShares'
|
import { PoolShares_poolShares as PoolShare } from '../@types/apollo/PoolShares'
|
||||||
import { DDO, Logger } from '@oceanprotocol/lib'
|
import { DDO, Logger } from '@oceanprotocol/lib'
|
||||||
<<<<<<< HEAD:src/@context/Profile.tsx
|
|
||||||
import { getDownloadAssets, getPublishedAssets } from '@utils/aquarius'
|
import { getDownloadAssets, getPublishedAssets } from '@utils/aquarius'
|
||||||
import { useSiteMetadata } from '@hooks/useSiteMetadata'
|
import { useSiteMetadata } from '@hooks/useSiteMetadata'
|
||||||
import { accountTruncate } from '@utils/web3'
|
import { accountTruncate } from '@utils/web3'
|
||||||
=======
|
|
||||||
import { getDownloadAssets, getPublishedAssets } from '../utils/aquarius'
|
|
||||||
import { useSiteMetadata } from '../hooks/useSiteMetadata'
|
|
||||||
import { Profile } from '../@types/Profile'
|
|
||||||
import { accountTruncate } from '../utils/web3'
|
|
||||||
>>>>>>> 14d71ad2 (reorganize all the things):src/context/Profile.tsx
|
|
||||||
import axios, { CancelToken } from 'axios'
|
import axios, { CancelToken } from 'axios'
|
||||||
import ethereumAddress from 'ethereum-address'
|
import ethereumAddress from 'ethereum-address'
|
||||||
import get3BoxProfile from '@utils/profile'
|
import get3BoxProfile from '@utils/profile'
|
||||||
|
@ -18,14 +18,7 @@ import { getOceanBalance } from '@utils/ocean'
|
|||||||
import useNetworkMetadata, {
|
import useNetworkMetadata, {
|
||||||
getNetworkDataById,
|
getNetworkDataById,
|
||||||
getNetworkDisplayName
|
getNetworkDisplayName
|
||||||
<<<<<<< HEAD:src/@context/Web3.tsx
|
|
||||||
} from '@hooks/useNetworkMetadata'
|
} from '@hooks/useNetworkMetadata'
|
||||||
=======
|
|
||||||
} from '../utils/web3'
|
|
||||||
import { getEnsName } from '../utils/ens'
|
|
||||||
import { getOceanBalance } from '../utils/ocean'
|
|
||||||
import useNetworkMetadata from '../hooks/useNetworkMetadata'
|
|
||||||
>>>>>>> 14d71ad2 (reorganize all the things):src/context/Web3.tsx
|
|
||||||
|
|
||||||
interface Web3ProviderValue {
|
interface Web3ProviderValue {
|
||||||
web3: Web3
|
web3: Web3
|
||||||
|
@ -1,8 +1,35 @@
|
|||||||
|
import { useStaticQuery, graphql } from 'gatsby'
|
||||||
import { UseNetworkMetadata } from './types'
|
import { UseNetworkMetadata } from './types'
|
||||||
import networkdata from '../../../content/networks-metadata.json'
|
|
||||||
|
const networksQuery = graphql`
|
||||||
|
query {
|
||||||
|
allNetworksMetadataJson {
|
||||||
|
edges {
|
||||||
|
node {
|
||||||
|
chain
|
||||||
|
network
|
||||||
|
networkId
|
||||||
|
chainId
|
||||||
|
rpc
|
||||||
|
explorers {
|
||||||
|
url
|
||||||
|
}
|
||||||
|
nativeCurrency {
|
||||||
|
name
|
||||||
|
symbol
|
||||||
|
decimals
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
`
|
||||||
|
|
||||||
export default function useNetworkMetadata(): UseNetworkMetadata {
|
export default function useNetworkMetadata(): UseNetworkMetadata {
|
||||||
const networksList: EthereumListsChain[] = networkdata
|
const data = useStaticQuery(networksQuery)
|
||||||
|
const networksList: { node: EthereumListsChain }[] =
|
||||||
|
data.allNetworksMetadataJson.edges
|
||||||
|
|
||||||
return { networksList }
|
return { networksList }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import React, { ReactElement, useEffect } from 'react'
|
import React, { ReactElement, useEffect } from 'react'
|
||||||
import { File as FileMetadata } from '@oceanprotocol/lib/dist/node/ddo/interfaces/File'
|
import { File as FileMetadata } from '@oceanprotocol/lib/dist/node/ddo/interfaces/File'
|
||||||
import { prettySize } from '@utils/index'
|
import { prettySize } from './utils'
|
||||||
import cleanupContentType from '@utils/cleanupContentType'
|
import cleanupContentType from '@utils/cleanupContentType'
|
||||||
import styles from './Info.module.css'
|
import styles from './Info.module.css'
|
||||||
import { useField, useFormikContext } from 'formik'
|
import { useField, useFormikContext } from 'formik'
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
import React, { ReactElement } from 'react'
|
import React, { ReactElement } from 'react'
|
||||||
import { useWeb3 } from '@context/Web3'
|
import { useWeb3 } from '@context/Web3'
|
||||||
<<<<<<< HEAD:src/components/@shared/WalletNetworkSwitcher/index.tsx
|
|
||||||
import { addCustomNetwork } from '@utils/web3'
|
import { addCustomNetwork } from '@utils/web3'
|
||||||
import Button from '@shared/atoms/Button'
|
import Button from '@shared/atoms/Button'
|
||||||
import styles from './index.module.css'
|
import styles from './index.module.css'
|
||||||
@ -8,7 +7,6 @@ import useNetworkMetadata, {
|
|||||||
getNetworkDataById,
|
getNetworkDataById,
|
||||||
getNetworkDisplayName
|
getNetworkDisplayName
|
||||||
} from '@hooks/useNetworkMetadata'
|
} from '@hooks/useNetworkMetadata'
|
||||||
=======
|
|
||||||
import {
|
import {
|
||||||
addCustomNetwork,
|
addCustomNetwork,
|
||||||
getNetworkDisplayName,
|
getNetworkDisplayName,
|
||||||
@ -17,7 +15,6 @@ import {
|
|||||||
import Button from '@shared/atoms/Button'
|
import Button from '@shared/atoms/Button'
|
||||||
import styles from './WalletNetworkSwitcher.module.css'
|
import styles from './WalletNetworkSwitcher.module.css'
|
||||||
import useNetworkMetadata from '@hooks/useNetworkMetadata'
|
import useNetworkMetadata from '@hooks/useNetworkMetadata'
|
||||||
>>>>>>> 14d71ad2 (reorganize all the things):src/components/@shared/WalletNetworkSwitcher.tsx
|
|
||||||
import { useAsset } from '@context/Asset'
|
import { useAsset } from '@context/Asset'
|
||||||
|
|
||||||
export default function WalletNetworkSwitcher(): ReactElement {
|
export default function WalletNetworkSwitcher(): ReactElement {
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
.app {
|
.app {
|
||||||
height: 100%;
|
height: 100%;
|
||||||
background: url('../../../node_modules/@oceanprotocol/art/waves/waves.svg')
|
background: url('../../../node_modules/@oceanprotocol/art/waves/waves.svg')
|
||||||
no-repeat center 13.5rem;
|
|
||||||
|
|
||||||
/* sticky footer technique */
|
/* sticky footer technique */
|
||||||
display: flex;
|
display: flex;
|
||||||
|
@ -1,50 +1,69 @@
|
|||||||
import React, { ReactElement } from 'react'
|
import React, { ReactElement } from 'react'
|
||||||
|
import { graphql, PageProps, useStaticQuery } from 'gatsby'
|
||||||
import Alert from '@shared/atoms/Alert'
|
import Alert from '@shared/atoms/Alert'
|
||||||
import Footer from '../Footer/Footer'
|
import Footer from '../Footer/Footer'
|
||||||
import Header from '../Header'
|
import Header from '../Header'
|
||||||
|
import StylesGlobal from '../../stylesGlobal/StylesGlobal'
|
||||||
import { useWeb3 } from '@context/Web3'
|
import { useWeb3 } from '@context/Web3'
|
||||||
import { useSiteMetadata } from '@hooks/useSiteMetadata'
|
import { useSiteMetadata } from '@hooks/useSiteMetadata'
|
||||||
import { useAccountPurgatory } from '@hooks/useAccountPurgatory'
|
import { useAccountPurgatory } from '@hooks/useAccountPurgatory'
|
||||||
import AnnouncementBanner from '@shared/AnnouncementBanner'
|
import AnnouncementBanner from '@shared/AnnouncementBanner'
|
||||||
import PrivacyPreferenceCenter from '../Privacy/PrivacyPreferenceCenter'
|
import PrivacyPreferenceCenter from '../Privacy/PrivacyPreferenceCenter'
|
||||||
import styles from './index.module.css'
|
import styles from './index.module.css'
|
||||||
import { ToastContainer } from 'react-toastify'
|
|
||||||
import { useRouter } from 'next/router'
|
const contentQuery = graphql`
|
||||||
// import waves from '@oceanprotocol/art/waves/waves.png'
|
query AppQuery {
|
||||||
import content from '../../../content/purgatory.json'
|
purgatory: allFile(filter: { relativePath: { eq: "purgatory.json" } }) {
|
||||||
|
edges {
|
||||||
|
node {
|
||||||
|
childContentJson {
|
||||||
|
account {
|
||||||
|
title
|
||||||
|
description
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
`
|
||||||
|
|
||||||
export default function App({
|
export default function App({
|
||||||
children
|
children,
|
||||||
|
...props
|
||||||
}: {
|
}: {
|
||||||
children: ReactElement
|
children: ReactElement
|
||||||
}): ReactElement {
|
}): ReactElement {
|
||||||
const router = useRouter()
|
const data = useStaticQuery(contentQuery)
|
||||||
|
const purgatory = data.purgatory.edges[0].node.childContentJson.account
|
||||||
|
|
||||||
const { warning, appConfig } = useSiteMetadata()
|
const { warning, appConfig } = useSiteMetadata()
|
||||||
const { accountId } = useWeb3()
|
const { accountId } = useWeb3()
|
||||||
const { isInPurgatory, purgatoryData } = useAccountPurgatory(accountId)
|
const { isInPurgatory, purgatoryData } = useAccountPurgatory(accountId)
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={styles.app}>
|
<StylesGlobal>
|
||||||
{router.pathname === '/' && <AnnouncementBanner text={warning.main} />}
|
<div className={styles.app}>
|
||||||
<Header />
|
{(props as PageProps).uri === '/' && (
|
||||||
|
<AnnouncementBanner text={warning.main} />
|
||||||
|
)}
|
||||||
|
<Header />
|
||||||
|
|
||||||
{isInPurgatory && (
|
{isInPurgatory && (
|
||||||
<Alert
|
<Alert
|
||||||
title={content.account.title}
|
title={purgatory.title}
|
||||||
badge={`Reason: ${purgatoryData?.reason}`}
|
badge={`Reason: ${purgatoryData?.reason}`}
|
||||||
text={content.account.description}
|
text={purgatory.description}
|
||||||
state="error"
|
state="error"
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
<main className={styles.main}>{children}</main>
|
<main className={styles.main}>{children}</main>
|
||||||
<Footer />
|
<Footer />
|
||||||
|
|
||||||
{appConfig.privacyPreferenceCenter === 'true' && (
|
{appConfig.privacyPreferenceCenter === 'true' && (
|
||||||
<PrivacyPreferenceCenter style="small" />
|
<PrivacyPreferenceCenter style="small" />
|
||||||
)}
|
)}
|
||||||
|
</div>
|
||||||
<ToastContainer position="bottom-right" newestOnTop />
|
</StylesGlobal>
|
||||||
</div>
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -17,6 +17,7 @@ import { useAsset } from '@context/Asset'
|
|||||||
import {
|
import {
|
||||||
generateBaseQuery,
|
generateBaseQuery,
|
||||||
getFilterTerm,
|
getFilterTerm,
|
||||||
|
queryMetadata,
|
||||||
transformDDOToAssetSelection
|
transformDDOToAssetSelection
|
||||||
} from '@utils/aquarius'
|
} from '@utils/aquarius'
|
||||||
import { Formik } from 'formik'
|
import { Formik } from 'formik'
|
||||||
|
@ -11,7 +11,6 @@ import useNetworkMetadata, {
|
|||||||
} from '@hooks/useNetworkMetadata'
|
} from '@hooks/useNetworkMetadata'
|
||||||
import { Logger } from '@oceanprotocol/lib'
|
import { Logger } from '@oceanprotocol/lib'
|
||||||
import styles from './MarketStats.module.css'
|
import styles from './MarketStats.module.css'
|
||||||
import { filterNetworksByType } from '../Header/UserPreferences/Networks'
|
|
||||||
|
|
||||||
const getTotalPoolsValues = gql`
|
const getTotalPoolsValues = gql`
|
||||||
query PoolsData {
|
query PoolsData {
|
||||||
|
@ -2,39 +2,17 @@ import React, { ReactElement } from 'react'
|
|||||||
import Label from '@shared/Form/Input/Label'
|
import Label from '@shared/Form/Input/Label'
|
||||||
import { useSiteMetadata } from '@hooks/useSiteMetadata'
|
import { useSiteMetadata } from '@hooks/useSiteMetadata'
|
||||||
import FormHelp from '@shared/Form/Input/Help'
|
import FormHelp from '@shared/Form/Input/Help'
|
||||||
import { EthereumListsChain, getNetworkDataById } from '@utils/web3'
|
|
||||||
import Tooltip from '@shared/atoms/Tooltip'
|
import Tooltip from '@shared/atoms/Tooltip'
|
||||||
import { ReactComponent as Caret } from '@images/caret.svg'
|
import { ReactComponent as Caret } from '@images/caret.svg'
|
||||||
import { ReactComponent as Network } from '@images/network.svg'
|
import { ReactComponent as Network } from '@images/network.svg'
|
||||||
import NetworksList from './NetworksList'
|
import NetworksList from './NetworksList'
|
||||||
import stylesIndex from '../index.module.css'
|
import stylesIndex from '../index.module.css'
|
||||||
import styles from './index.module.css'
|
import styles from './index.module.css'
|
||||||
import useNetworkMetadata from '@hooks/useNetworkMetadata'
|
import useNetworkMetadata, {
|
||||||
|
filterNetworksByType
|
||||||
|
} from '@hooks/useNetworkMetadata'
|
||||||
import { useUserPreferences } from '@context/UserPreferences'
|
import { useUserPreferences } from '@context/UserPreferences'
|
||||||
|
|
||||||
export function filterNetworksByType(
|
|
||||||
type: 'mainnet' | 'testnet',
|
|
||||||
chainIds: number[],
|
|
||||||
networksList: { node: EthereumListsChain }[]
|
|
||||||
): number[] {
|
|
||||||
const finalNetworks = chainIds.filter((chainId: number) => {
|
|
||||||
const networkData = getNetworkDataById(networksList, chainId)
|
|
||||||
|
|
||||||
// HEADS UP! Only networkData.network === 'mainnet' is consistent
|
|
||||||
// while not every test network in the network data has 'testnet'
|
|
||||||
// in its place. So for the 'testnet' case filter for all non-'mainnet'.
|
|
||||||
//
|
|
||||||
// HEADS UP NO. 2! We hack in mainnet detection for moonriver as their
|
|
||||||
// network data uses the `network` key wrong over in
|
|
||||||
// https://github.com/ethereum-lists/chains/blob/master/_data/chains/eip155-1285.json
|
|
||||||
//
|
|
||||||
return type === 'mainnet'
|
|
||||||
? networkData.network === type || networkData.network === 'moonriver'
|
|
||||||
: networkData.network !== 'mainnet' && networkData.network !== 'moonriver'
|
|
||||||
})
|
|
||||||
return finalNetworks
|
|
||||||
}
|
|
||||||
|
|
||||||
export default function Networks(): ReactElement {
|
export default function Networks(): ReactElement {
|
||||||
const { networksList } = useNetworkMetadata()
|
const { networksList } = useNetworkMetadata()
|
||||||
const { appConfig } = useSiteMetadata()
|
const { appConfig } = useSiteMetadata()
|
||||||
|
@ -11,19 +11,6 @@ import { CancelToken } from 'axios'
|
|||||||
import { useSiteMetadata } from '@hooks/useSiteMetadata'
|
import { useSiteMetadata } from '@hooks/useSiteMetadata'
|
||||||
import { useCancelToken } from '@hooks/useCancelToken'
|
import { useCancelToken } from '@hooks/useCancelToken'
|
||||||
|
|
||||||
async function getAssetsBookmarked(
|
|
||||||
bookmarks: string[],
|
|
||||||
chainIds: number[],
|
|
||||||
cancelToken: CancelToken
|
|
||||||
) {
|
|
||||||
try {
|
|
||||||
const result = await retrieveDDOListByDIDs(bookmarks, chainIds, cancelToken)
|
|
||||||
return result
|
|
||||||
} catch (error) {
|
|
||||||
Logger.error(error.message)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const columns = [
|
const columns = [
|
||||||
{
|
{
|
||||||
name: 'Data Set',
|
name: 'Data Set',
|
||||||
|
@ -10,25 +10,14 @@ import {
|
|||||||
import { getHighestLiquidityDatatokens } from '@utils/subgraph'
|
import { getHighestLiquidityDatatokens } from '@utils/subgraph'
|
||||||
import { DDO, Logger } from '@oceanprotocol/lib'
|
import { DDO, Logger } from '@oceanprotocol/lib'
|
||||||
import { useUserPreferences } from '@context/UserPreferences'
|
import { useUserPreferences } from '@context/UserPreferences'
|
||||||
<<<<<<< HEAD:src/components/Home/index.tsx
|
|
||||||
import styles from './index.module.css'
|
import styles from './index.module.css'
|
||||||
import { useIsMounted } from '@hooks/useIsMounted'
|
import { useIsMounted } from '@hooks/useIsMounted'
|
||||||
import { useCancelToken } from '@hooks/useCancelToken'
|
import { useCancelToken } from '@hooks/useCancelToken'
|
||||||
import { SortTermOptions } from '../../@types/aquarius/SearchQuery'
|
import { SortTermOptions } from '../../@types/aquarius/SearchQuery'
|
||||||
=======
|
|
||||||
import styles from './Home.module.css'
|
|
||||||
import { useIsMounted } from '@hooks/useIsMounted'
|
|
||||||
import { useCancelToken } from '@hooks/useCancelToken'
|
|
||||||
import { SearchQuery } from '../../models/aquarius/SearchQuery'
|
|
||||||
import { SortTermOptions } from '../../models/SortAndFilters'
|
|
||||||
import { BaseQueryParams } from '../../models/aquarius/BaseQueryParams'
|
|
||||||
import { PagedAssets } from '../../models/PagedAssets'
|
|
||||||
>>>>>>> 14d71ad2 (reorganize all the things):src/components/Home/Home.tsx
|
|
||||||
|
|
||||||
async function getQueryHighest(
|
async function getQueryHighest(
|
||||||
chainIds: number[]
|
chainIds: number[]
|
||||||
): Promise<[SearchQuery, string[]]> {
|
): Promise<[SearchQuery, string[]]> {
|
||||||
const dtList = await getHighestLiquidityDatatokens(chainIds)
|
|
||||||
const dtList = await getHighestLiquidityDatatokens(chainIds)
|
const dtList = await getHighestLiquidityDatatokens(chainIds)
|
||||||
const baseQueryParams = {
|
const baseQueryParams = {
|
||||||
chainIds,
|
chainIds,
|
||||||
|
@ -8,10 +8,19 @@ import UrqlProvider from '@context/UrqlProvider'
|
|||||||
import ConsentProvider from '@context/CookieConsent'
|
import ConsentProvider from '@context/CookieConsent'
|
||||||
import App from 'src/components/App'
|
import App from 'src/components/App'
|
||||||
|
|
||||||
|
<<<<<<< HEAD:src/pages/_app.tsx
|
||||||
import '@oceanprotocol/typographies/css/ocean-typo.css'
|
import '@oceanprotocol/typographies/css/ocean-typo.css'
|
||||||
import '../stylesGlobal/styles.css'
|
import '../stylesGlobal/styles.css'
|
||||||
|
|
||||||
function MyApp({ Component, pageProps }: AppProps): ReactElement {
|
function MyApp({ Component, pageProps }: AppProps): ReactElement {
|
||||||
|
=======
|
||||||
|
// Referenced in gatsby-browser.js & gatsby-ssr.js
|
||||||
|
export default function ContextProviders({
|
||||||
|
element
|
||||||
|
}: {
|
||||||
|
element: ReactElement
|
||||||
|
}): ReactElement {
|
||||||
|
>>>>>>> 4a56991b (more refactor):src/components/App/ContextProviders.tsx
|
||||||
return (
|
return (
|
||||||
<Web3Provider>
|
<Web3Provider>
|
||||||
<UrqlProvider>
|
<UrqlProvider>
|
||||||
|
Loading…
Reference in New Issue
Block a user