diff --git a/codegen.yml b/codegen.yml index a3035ff2c..6aa6e583d 100644 --- a/codegen.yml +++ b/codegen.yml @@ -1,16 +1,16 @@ overwrite: true schema: 'https://subgraph.rinkeby.oceanprotocol.com/subgraphs/name/oceanprotocol/ocean-subgraph' documents: - - './src/utils/subgraph.ts' - - './src/components/pages/History/PoolShares.tsx' - - './src/components/pages/History/Downloads.tsx' - - './src/components/pages/History/ComputeJobs/index.tsx' - - './src/components/organisms/AssetContent/EditHistory.tsx' - # - './src/components/organisms/AssetActions/Pool/index.tsx' - - './src/components/organisms/AssetActions/Pool/Graph.tsx' - - './src/components/organisms/AssetActions/Consume.tsx' - - './src/components/molecules/PoolTransactions.tsx' - - './src/components/molecules/MarketStats.tsx' + - './src/@utils/aquarius.ts' + - './src/@utils/subgraph.ts' + - './src/@context/Profile.tsx' + - './src/components/@shared/PoolTransactions/index.tsx' + - './src/components/@shared/Asset/AssetActions/Consume.tsx' + - './src/components/@shared/Asset/AssetActions/Pool/index.tsx' + - './src/components/@shared/Asset/AssetActions/Pool/Graph.tsx' + - './src/components/@shared/Asset/AssetContent/EditHistory.tsx' + - './src/components/Profile/Header/Stats.tsx' + - './src/components/Profile/History/PoolShares.tsx' generates: ./src/@types/graph.types.ts: plugins: diff --git a/gatsby-browser.js b/gatsby-browser.js index a594aeb8c..877965e26 100644 --- a/gatsby-browser.js +++ b/gatsby-browser.js @@ -1,5 +1,5 @@ -import wrapPageElementWithStyles from './src/components/wrapPageElement' -import wrapRootElementWithProviders from './src/components/wrapRootElement' +import wrapPageElementWithStyles from './src/components/App/wrapPageElement' +import ContextProviders from './src/components/App/ContextProviders' export const wrapPageElement = wrapPageElementWithStyles -export const wrapRootElement = wrapRootElementWithProviders +export const wrapRootElement = ContextProviders diff --git a/gatsby-node.js b/gatsby-node.js index 6440a0c04..a5cad9208 100644 --- a/gatsby-node.js +++ b/gatsby-node.js @@ -1,5 +1,6 @@ -const createFields = require('./gatsby/createFields') +const createMarkdownFields = require('./gatsby/createMarkdownFields') const createMarkdownPages = require('./gatsby/createMarkdownPages') +const createTypes = require('./gatsby/createTypes') const execSync = require('child_process').execSync const path = require('path') @@ -8,7 +9,7 @@ execSync(`node ./scripts/write-repo-metadata > repo-metadata.json`, { stdio: 'inherit' }) -// Generate GraphQl typings for urql +// Generate GraphQL typings for urql // execSync(`npm run graphql:graphTypes`, { stdio: 'inherit' }) // Generate Apollo typings @@ -22,33 +23,12 @@ execSync( } ) -//Extend ContentJson to support optional field "optionalCookies" in gdpr.json -//Extend PublishJsonData to support optional fields for disclaimers exports.sourceNodes = ({ actions }) => { - const { createTypes } = actions - 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) + createTypes(actions) } exports.onCreateNode = ({ node, actions, getNode }) => { - createFields(node, actions, getNode) + createMarkdownFields(node, actions, getNode) } exports.createPages = async ({ graphql, actions }) => { diff --git a/gatsby-ssr.js b/gatsby-ssr.js index a594aeb8c..877965e26 100644 --- a/gatsby-ssr.js +++ b/gatsby-ssr.js @@ -1,5 +1,5 @@ -import wrapPageElementWithStyles from './src/components/wrapPageElement' -import wrapRootElementWithProviders from './src/components/wrapRootElement' +import wrapPageElementWithStyles from './src/components/App/wrapPageElement' +import ContextProviders from './src/components/App/ContextProviders' export const wrapPageElement = wrapPageElementWithStyles -export const wrapRootElement = wrapRootElementWithProviders +export const wrapRootElement = ContextProviders diff --git a/gatsby/createFields.js b/gatsby/createMarkdownFields.js similarity index 100% rename from gatsby/createFields.js rename to gatsby/createMarkdownFields.js diff --git a/gatsby/createTypes.js b/gatsby/createTypes.js new file mode 100644 index 000000000..9c5fd2137 --- /dev/null +++ b/gatsby/createTypes.js @@ -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 diff --git a/src/@context/Profile.tsx b/src/@context/Profile.tsx index 62fa145cc..0599b1e14 100644 --- a/src/@context/Profile.tsx +++ b/src/@context/Profile.tsx @@ -15,16 +15,13 @@ import { import { useUserPreferences } from './UserPreferences' import { PoolShares_poolShares as PoolShare } from '../@types/apollo/PoolShares' import { DDO, Logger } from '@oceanprotocol/lib' -import { getDownloadAssets, getPublishedAssets } from '../utils/aquarius' - getPublishedAssets -} from '@utils/aquarius' +import { getDownloadAssets, getPublishedAssets } from '@utils/aquarius' import { useSiteMetadata } from '@hooks/useSiteMetadata' import { accountTruncate } from '@utils/web3' import axios, { CancelToken } from 'axios' import ethereumAddress from 'ethereum-address' import get3BoxProfile from '@utils/profile' import web3 from 'web3' -import { DownloadedAsset } from '../models/aquarius/DownloadedAsset' interface ProfileProviderValue { profile: Profile diff --git a/src/@context/Web3.tsx b/src/@context/Web3.tsx index ebc0af0d8..df9ea090e 100644 --- a/src/@context/Web3.tsx +++ b/src/@context/Web3.tsx @@ -13,14 +13,12 @@ import { infuraProjectId as infuraId, portisId } from '../../app.config' import WalletConnectProvider from '@walletconnect/web3-provider' import { Logger } from '@oceanprotocol/lib' import { isBrowser } from '@utils/index' -import { - EthereumListsChain, - getNetworkDataById, - getNetworkDisplayName -} from '@utils/web3' import { getEnsName } from '@utils/ens' import { getOceanBalance } from '@utils/ocean' -import useNetworkMetadata from '@hooks/useNetworkMetadata' +import useNetworkMetadata, { + getNetworkDataById, + getNetworkDisplayName +} from '@hooks/useNetworkMetadata' interface Web3ProviderValue { web3: Web3 diff --git a/src/@hooks/useNetworkMetadata/constants.ts b/src/@hooks/useNetworkMetadata/constants.ts new file mode 100644 index 000000000..795eaed51 --- /dev/null +++ b/src/@hooks/useNetworkMetadata/constants.ts @@ -0,0 +1,20 @@ +import { getOceanConfig } from '@utils/ocean' + +const configGaiaX = getOceanConfig(2021000) + +export const networkDataGaiaX: EthereumListsChain = { + name: 'GAIA-X Testnet', + chainId: 2021000, + shortName: 'GAIA-X', + chain: 'GAIA-X', + network: 'testnet', + networkId: 2021000, + nativeCurrency: { name: 'Gaia-X', symbol: 'GX', decimals: 18 }, + rpc: [configGaiaX.nodeUri], + faucets: [ + 'https://faucet.gaiaxtestnet.oceanprotocol.com/', + 'https://faucet.gx.gaiaxtestnet.oceanprotocol.com/' + ], + infoURL: 'https://www.gaia-x.eu', + explorers: [{ url: '' }] +} diff --git a/src/@hooks/useNetworkMetadata.ts b/src/@hooks/useNetworkMetadata/index.ts similarity index 82% rename from src/@hooks/useNetworkMetadata.ts rename to src/@hooks/useNetworkMetadata/index.ts index d7104ab7d..2ac5d5daa 100644 --- a/src/@hooks/useNetworkMetadata.ts +++ b/src/@hooks/useNetworkMetadata/index.ts @@ -1,9 +1,5 @@ import { useStaticQuery, graphql } from 'gatsby' -import { EthereumListsChain } from '@utils/web3' - -export interface UseNetworkMetadata { - networksList: { node: EthereumListsChain }[] -} +import { UseNetworkMetadata } from './types' const networksQuery = graphql` query { @@ -36,3 +32,5 @@ export default function useNetworkMetadata(): UseNetworkMetadata { return { networksList } } + +export * from './utils' diff --git a/src/@hooks/useNetworkMetadata/types.ts b/src/@hooks/useNetworkMetadata/types.ts new file mode 100644 index 000000000..4895f8069 --- /dev/null +++ b/src/@hooks/useNetworkMetadata/types.ts @@ -0,0 +1,3 @@ +export interface UseNetworkMetadata { + networksList: { node: EthereumListsChain }[] +} diff --git a/src/@hooks/useNetworkMetadata/utils.ts b/src/@hooks/useNetworkMetadata/utils.ts new file mode 100644 index 000000000..05becac7f --- /dev/null +++ b/src/@hooks/useNetworkMetadata/utils.ts @@ -0,0 +1,68 @@ +import { networkDataGaiaX } from './constants' + +export function getNetworkDisplayName( + data: EthereumListsChain, + networkId: number +): string { + let displayName + + switch (networkId) { + case 137: + displayName = 'Polygon' + break + case 1287: + displayName = 'Moonbase Alpha' + break + case 1285: + displayName = 'Moonriver' + break + case 80001: + displayName = 'Polygon Mumbai' + break + case 8996: + displayName = 'Development' + break + default: + displayName = data + ? `${data.chain} ${data.network === 'mainnet' ? '' : data.network}` + : 'Unknown' + break + } + + return displayName +} + +export function getNetworkDataById( + data: { node: EthereumListsChain }[], + networkId: number +): EthereumListsChain { + if (!networkId) return + const networkData = data.filter( + ({ node }: { node: EthereumListsChain }) => node.chainId === networkId + ) + + return networkId === 2021000 ? networkDataGaiaX : networkData[0]?.node +} + +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 +} diff --git a/src/@hooks/useSiteMetadata/index.ts b/src/@hooks/useSiteMetadata/index.ts index 22fc2f2d0..bccb91b55 100644 --- a/src/@hooks/useSiteMetadata/index.ts +++ b/src/@hooks/useSiteMetadata/index.ts @@ -1,5 +1,5 @@ import { useStaticQuery, graphql } from 'gatsby' -import { UseSiteMetadata } from './_types' +import { UseSiteMetadata } from './types' const query = graphql` query { diff --git a/src/@hooks/useSiteMetadata/_types.ts b/src/@hooks/useSiteMetadata/types.ts similarity index 100% rename from src/@hooks/useSiteMetadata/_types.ts rename to src/@hooks/useSiteMetadata/types.ts diff --git a/src/@types/NetworkMetadata.d.ts b/src/@types/NetworkMetadata.d.ts new file mode 100644 index 000000000..d93aa82c0 --- /dev/null +++ b/src/@types/NetworkMetadata.d.ts @@ -0,0 +1,21 @@ +interface EthereumListsChain { + name: string + chainId: number + shortName: string + chain: string + network: string + networkId: number + nativeCurrency: { name: string; symbol: string; decimals: number } + rpc: string[] + infoURL: string + faucets: string[] + explorers: [{ url: string }] +} + +interface NetworkObject { + chainId: number + name: string + nativeCurrency: string + explorers: [{ url: string }] + urlList: string[] +} diff --git a/src/@types/aquarius/BaseQueryParams.d.ts b/src/@types/aquarius/BaseQueryParams.d.ts new file mode 100644 index 000000000..658b73f4d --- /dev/null +++ b/src/@types/aquarius/BaseQueryParams.d.ts @@ -0,0 +1,13 @@ +interface EsPaginationOptions { + from?: number + size?: number +} + +interface BaseQueryParams { + chainIds: number[] + nestedQuery?: any + esPaginationOptions?: EsPaginationOptions + sortOptions?: SortOptions + filters?: FilterTerm[] + ignorePurgatory?: boolean +} diff --git a/src/@types/aquarius/DownloadedAsset.d.ts b/src/@types/aquarius/DownloadedAsset.d.ts new file mode 100644 index 000000000..97a2052bf --- /dev/null +++ b/src/@types/aquarius/DownloadedAsset.d.ts @@ -0,0 +1,12 @@ +import { DDO } from '@oceanprotocol/lib' + +// declaring into global scope to be able to use this as +// ambiant types despite the above imports +declare global { + interface DownloadedAsset { + dtSymbol: string + timestamp: number + networkId: number + ddo: DDO + } +} diff --git a/src/@types/MetaData.d.ts b/src/@types/aquarius/MetaData.d.ts similarity index 100% rename from src/@types/MetaData.d.ts rename to src/@types/aquarius/MetaData.d.ts diff --git a/src/@types/aquarius/PagedAssets.d.ts b/src/@types/aquarius/PagedAssets.d.ts new file mode 100644 index 000000000..008d940a9 --- /dev/null +++ b/src/@types/aquarius/PagedAssets.d.ts @@ -0,0 +1,12 @@ +import { DDO } from '@oceanprotocol/lib' + +// declaring into global scope to be able to use this as +// ambiant types despite the above imports +declare global { + interface PagedAssets { + results: DDO[] + page: number + totalPages: number + totalResults: number + } +} diff --git a/src/@types/aquarius/SearchQuery.ts b/src/@types/aquarius/SearchQuery.ts new file mode 100644 index 000000000..2bfa29459 --- /dev/null +++ b/src/@types/aquarius/SearchQuery.ts @@ -0,0 +1,47 @@ +export enum SortDirectionOptions { + Ascending = 'asc', + Descending = 'desc' +} + +export enum SortTermOptions { + Created = 'created', + Relevance = '_score' +} + +// Note: could not figure out how to get `enum` to be ambiant +// as final compiled js won't have it then. +// Only export/import works for that, so this file is NOT .d.ts file ending +// and gets imported in components. + +export enum FilterByTypeOptions { + Data = 'dataset', + Algorithm = 'algorithm' +} + +export enum FilterByAccessOptions { + Download = 'access', + Compute = 'compute' +} + +declare global { + interface SortOptions { + sortBy: SortTermOptions + sortDirection?: SortDirectionOptions + } + + interface FilterTerm { + [property: string]: { + [property: string]: string | number | boolean | number[] | string[] + } + } + + type Filters = FilterByTypeOptions | FilterByAccessOptions + + interface SearchQuery { + from?: number + size?: number + // eslint-disable-next-line @typescript-eslint/no-explicit-any + query: any + sort?: { [jsonPath: string]: SortDirectionOptions } + } +} diff --git a/src/@types/aquarius/SearchResponse.d.ts b/src/@types/aquarius/SearchResponse.d.ts new file mode 100644 index 000000000..2d2a02f97 --- /dev/null +++ b/src/@types/aquarius/SearchResponse.d.ts @@ -0,0 +1,46 @@ +/* eslint-disable @typescript-eslint/no-explicit-any */ +/* eslint-disable camelcase */ +import { DDO } from '@oceanprotocol/lib' + +// declaring into global scope to be able to use this as +// ambiant types despite the above imports +declare global { + interface Explanation { + value: number + description: string + details: Explanation[] + } + + interface ShardsResponse { + total: number + successful: number + failed: number + skipped: number + } + + interface SearchResponse { + took: number + timed_out: boolean + _scroll_id?: string | undefined + _shards: ShardsResponse + hits: { + total: number + max_score: number + hits: Array<{ + _index: string + _type: string + _id: string + _score: number + _source: DDO + _version?: number | undefined + _explanation?: Explanation | undefined + fields?: any + highlight?: any + inner_hits?: any + matched_queries?: string[] | undefined + sort?: string[] | undefined + }> + } + aggregations?: any + } +} diff --git a/src/@utils/aquarius.ts b/src/@utils/aquarius.ts index 017991771..71c7f2916 100644 --- a/src/@utils/aquarius.ts +++ b/src/@utils/aquarius.ts @@ -4,19 +4,11 @@ import { Logger, publisherTrustedAlgorithm as PublisherTrustedAlgorithm } from '@oceanprotocol/lib/' - import { AssetSelectionAsset } from '@shared/Form/FormFields/AssetSelection' import { PriceList, getAssetsPriceList } from './subgraph' import axios, { CancelToken, AxiosResponse } from 'axios' import { OrdersData_tokenOrders as OrdersData } from '../@types/apollo/OrdersData' import { metadataCacheUri } from '../../app.config' -import { DownloadedAsset } from '../models/aquarius/DownloadedAsset' -import { SearchQuery } from '../models/aquarius/SearchQuery' -import { SearchResponse } from '../models/aquarius/SearchResponse' -import { PagedAssets } from '../models/PagedAssets' -import { SortDirectionOptions, SortTermOptions } from '../models/SortAndFilters' -import { FilterTerm } from '../models/aquarius/FilterTerm' -import { BaseQueryParams } from '../models/aquarius/BaseQueryParams' export const MAXIMUM_NUMBER_OF_PAGES_WITH_RESULTS = 476 diff --git a/src/@utils/cleanupContentType.ts b/src/@utils/cleanupContentType.ts index 66cd920d4..c3075ca82 100644 --- a/src/@utils/cleanupContentType.ts +++ b/src/@utils/cleanupContentType.ts @@ -1,4 +1,4 @@ -const cleanupContentType = (contentType: string): string => { +export default function cleanupContentType(contentType: string): string { // strip away the `charset=utf-8` const contentSplit = contentType.split(';')[0] // strip away the 'application/' part @@ -39,5 +39,3 @@ const cleanupContentType = (contentType: string): string => { return contentTypeCleaned } - -export default cleanupContentType diff --git a/src/@utils/compute.ts b/src/@utils/compute.ts index 5d2dc84ab..398a521bc 100644 --- a/src/@utils/compute.ts +++ b/src/@utils/compute.ts @@ -15,8 +15,6 @@ import { CancelToken } from 'axios' import { gql } from 'urql' import { queryMetadata, getFilterTerm, generateBaseQuery } from './aquarius' import { fetchDataForMultipleChains } from './subgraph' -import { OrdersData_tokenOrders_datatokenId as OrdersDatatoken } from '../@types/apollo/OrdersData' -import { BaseQueryParams } from '../models/aquarius/BaseQueryParams' const getComputeOrders = gql` query ComputeOrders($user: String!) { diff --git a/src/@utils/index.ts b/src/@utils/index.ts index 79e0c374b..a07ba65fe 100644 --- a/src/@utils/index.ts +++ b/src/@utils/index.ts @@ -1,43 +1,6 @@ -export function updateQueryStringParameter( - uri: string, - key: string, - newValue: string -): string { - const regex = new RegExp('([?&])' + key + '=.*?(&|$)', 'i') - const separator = uri.indexOf('?') !== -1 ? '&' : '?' - - if (uri.match(regex)) { - return uri.replace(regex, '$1' + key + '=' + newValue + '$2') - } else { - return uri + separator + key + '=' + newValue - } -} - -export function prettySize( - bytes: number, - separator = ' ', - postFix = '' -): string { - if (bytes) { - const sizes = ['Bytes', 'KB', 'MB', 'GB', 'TB'] - const i = Math.min( - Math.floor(Math.log(bytes) / Math.log(1024)), - sizes.length - 1 - ) - return `${(bytes / 1024 ** i).toFixed(i ? 1 : 0)}${separator}${ - sizes[i] - }${postFix}` - } - return 'n/a' -} - // Boolean value that will be true if we are inside a browser, false otherwise export const isBrowser = typeof window !== 'undefined' -export function toStringNoMS(date: Date): string { - return date.toISOString().replace(/\.[0-9]{3}Z/, 'Z') -} - export function sleep(ms: number): Promise { return new Promise((resolve) => { setTimeout(resolve, ms) diff --git a/src/@utils/metadata.ts b/src/@utils/metadata.ts index 26d75e6fc..573963385 100644 --- a/src/@utils/metadata.ts +++ b/src/@utils/metadata.ts @@ -1,11 +1,14 @@ import axios from 'axios' import { toast } from 'react-toastify' import isUrl from 'is-url-superb' -import { toStringNoMS } from '.' import slugify from '@sindresorhus/slugify' import { DDO, MetadataAlgorithm, Logger } from '@oceanprotocol/lib' import { FormPublishData } from '../components/Publish/_types' +export function dateToStringNoMS(date: Date): string { + return date.toISOString().replace(/\.[0-9]{3}Z/, 'Z') +} + export function transformTags(value: string): string[] { const originalTags = value?.split(',') const transformedTags = originalTags?.map((tag) => slugify(tag).toLowerCase()) @@ -106,7 +109,7 @@ export function transformPublishFormToMetadata( }: Partial, ddo?: DDO ): MetadataMarket { - const currentTime = toStringNoMS(new Date()) + const currentTime = dateToStringNoMS(new Date()) const metadata: MetadataMarket = { main: { @@ -204,7 +207,7 @@ export function transformPublishAlgorithmFormToMetadata( }: Partial, ddo?: DDO ): MetadataMarket { - const currentTime = toStringNoMS(new Date()) + const currentTime = dateToStringNoMS(new Date()) const fileUrl = typeof files !== 'string' && files[0].url const algorithmLanguage = getAlgorithmFileExtension(fileUrl) const algorithm = getAlgorithmComponent( diff --git a/src/@utils/subgraph.ts b/src/@utils/subgraph.ts index d3c8d3ee6..6b08c3f1e 100644 --- a/src/@utils/subgraph.ts +++ b/src/@utils/subgraph.ts @@ -2,7 +2,6 @@ import { gql, OperationResult, TypedDocumentNode, OperationContext } from 'urql' import { DDO, Logger } from '@oceanprotocol/lib' import { getUrqlClientInstance } from '@context/UrqlProvider' import { getOceanConfig } from './ocean' -import web3 from 'web3' import { AssetsPoolPrice, AssetsPoolPrice_pools as AssetsPoolPricePool diff --git a/src/@utils/web3.ts b/src/@utils/web3.ts index fee282a6f..db4825e02 100644 --- a/src/@utils/web3.ts +++ b/src/@utils/web3.ts @@ -1,47 +1,7 @@ +import { getNetworkDisplayName } from '@hooks/useNetworkMetadata' import { Logger } from '@oceanprotocol/lib' import { getOceanConfig } from './ocean' -export interface EthereumListsChain { - name: string - chainId: number - shortName: string - chain: string - network: string - networkId: number - nativeCurrency: { name: string; symbol: string; decimals: number } - rpc: string[] - infoURL: string - faucets: string[] - explorers: [{ url: string }] -} - -export interface NetworkObject { - chainId: number - name: string - nativeCurrency: string - explorers: [{ url: string }] - urlList: string[] -} - -const configGaiaX = getOceanConfig(2021000) - -export const networkDataGaiaX: EthereumListsChain = { - name: 'GAIA-X Testnet', - chainId: 2021000, - shortName: 'GAIA-X', - chain: 'GAIA-X', - network: 'testnet', - networkId: 2021000, - nativeCurrency: { name: 'Gaia-X', symbol: 'GX', decimals: 18 }, - rpc: [configGaiaX.nodeUri], - faucets: [ - 'https://faucet.gaiaxtestnet.oceanprotocol.com/', - 'https://faucet.gx.gaiaxtestnet.oceanprotocol.com/' - ], - infoURL: 'https://www.gaia-x.eu', - explorers: [{ url: '' }] -} - export function accountTruncate(account: string): string { if (!account) return const middle = account.substring(6, 38) @@ -49,50 +9,6 @@ export function accountTruncate(account: string): string { return truncated } -export function getNetworkDisplayName( - data: EthereumListsChain, - networkId: number -): string { - let displayName - - switch (networkId) { - case 137: - displayName = 'Polygon' - break - case 1287: - displayName = 'Moonbase Alpha' - break - case 1285: - displayName = 'Moonriver' - break - case 80001: - displayName = 'Polygon Mumbai' - break - case 8996: - displayName = 'Development' - break - default: - displayName = data - ? `${data.chain} ${data.network === 'mainnet' ? '' : data.network}` - : 'Unknown' - break - } - - return displayName -} - -export function getNetworkDataById( - data: { node: EthereumListsChain }[], - networkId: number -): EthereumListsChain { - if (!networkId) return - const networkData = data.filter( - ({ node }: { node: EthereumListsChain }) => node.chainId === networkId - ) - - return networkId === 2021000 ? networkDataGaiaX : networkData[0]?.node -} - export async function addCustomNetwork( web3Provider: any, network: EthereumListsChain diff --git a/src/components/@shared/AssetList/AssetList.tsx b/src/components/@shared/AssetList/AssetList.tsx index edcb792c1..b03560707 100644 --- a/src/components/@shared/AssetList/AssetList.tsx +++ b/src/components/@shared/AssetList/AssetList.tsx @@ -5,7 +5,7 @@ import styles from './AssetList.module.css' import { DDO } from '@oceanprotocol/lib' import classNames from 'classnames/bind' import { getAssetsBestPrices, AssetListPrices } from '@utils/subgraph' -import Loader from '../atoms/Loader' +import Loader from '@shared/atoms/Loader' import { useUserPreferences } from '@context/UserPreferences' import { useIsMounted } from '@hooks/useIsMounted' diff --git a/src/components/@shared/Form/FormFields/FilesInput/Info.tsx b/src/components/@shared/Form/FormFields/FilesInput/Info.tsx index c3468eb50..772f154a2 100644 --- a/src/components/@shared/Form/FormFields/FilesInput/Info.tsx +++ b/src/components/@shared/Form/FormFields/FilesInput/Info.tsx @@ -1,6 +1,6 @@ import React, { ReactElement, useEffect } from 'react' 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 styles from './Info.module.css' import { useField, useFormikContext } from 'formik' diff --git a/src/components/@shared/Form/FormFields/FilesInput/utils.ts b/src/components/@shared/Form/FormFields/FilesInput/utils.ts new file mode 100644 index 000000000..b5fc4cb63 --- /dev/null +++ b/src/components/@shared/Form/FormFields/FilesInput/utils.ts @@ -0,0 +1,17 @@ +export function prettySize( + bytes: number, + separator = ' ', + postFix = '' +): string { + if (bytes) { + const sizes = ['Bytes', 'KB', 'MB', 'GB', 'TB'] + const i = Math.min( + Math.floor(Math.log(bytes) / Math.log(1024)), + sizes.length - 1 + ) + return `${(bytes / 1024 ** i).toFixed(i ? 1 : 0)}${separator}${ + sizes[i] + }${postFix}` + } + return 'n/a' +} diff --git a/src/components/@shared/NetworkName/index.tsx b/src/components/@shared/NetworkName/index.tsx index 84c9dd216..6a12a93ce 100644 --- a/src/components/@shared/NetworkName/index.tsx +++ b/src/components/@shared/NetworkName/index.tsx @@ -1,7 +1,9 @@ import React, { ReactElement } from 'react' -import { getNetworkDataById, getNetworkDisplayName } from '@utils/web3' import styles from './index.module.css' -import useNetworkMetadata from '@hooks/useNetworkMetadata' +import useNetworkMetadata, { + getNetworkDataById, + getNetworkDisplayName +} from '@hooks/useNetworkMetadata' import { NetworkIcon } from './NetworkIcon' export default function NetworkName({ diff --git a/src/components/@shared/WalletNetworkSwitcher/index.tsx b/src/components/@shared/WalletNetworkSwitcher/index.tsx index 5d69af6ad..b0aa316a4 100644 --- a/src/components/@shared/WalletNetworkSwitcher/index.tsx +++ b/src/components/@shared/WalletNetworkSwitcher/index.tsx @@ -1,13 +1,12 @@ import React, { ReactElement } from 'react' import { useWeb3 } from '@context/Web3' -import { - addCustomNetwork, - getNetworkDisplayName, - getNetworkDataById -} from '@utils/web3' +import { addCustomNetwork } from '@utils/web3' import Button from '@shared/atoms/Button' import styles from './index.module.css' -import useNetworkMetadata from '@hooks/useNetworkMetadata' +import useNetworkMetadata, { + getNetworkDataById, + getNetworkDisplayName +} from '@hooks/useNetworkMetadata' import { useAsset } from '@context/Asset' export default function WalletNetworkSwitcher(): ReactElement { diff --git a/src/components/wrapRootElement.tsx b/src/components/App/ContextProviders.tsx similarity index 87% rename from src/components/wrapRootElement.tsx rename to src/components/App/ContextProviders.tsx index 64a3cefba..8cc30ac80 100644 --- a/src/components/wrapRootElement.tsx +++ b/src/components/App/ContextProviders.tsx @@ -5,7 +5,8 @@ import PricesProvider from '@context/Prices' import UrqlProvider from '@context/UrqlProvider' import ConsentProvider from '@context/CookieConsent' -export default function wrapRootElement({ +// Referenced in gatsby-browser.js & gatsby-ssr.js +export default function ContextProviders({ element }: { element: ReactElement diff --git a/src/components/App.module.css b/src/components/App/index.module.css similarity index 82% rename from src/components/App.module.css rename to src/components/App/index.module.css index 3cc090b9d..bf1726fc4 100644 --- a/src/components/App.module.css +++ b/src/components/App/index.module.css @@ -1,7 +1,6 @@ .app { height: 100%; - background: url('../../node_modules/@oceanprotocol/art/waves/waves.svg') - no-repeat center 13.5rem; + background: url('@oceanprotocol/art/waves/waves.svg') no-repeat center 13.5rem; /* sticky footer technique */ display: flex; diff --git a/src/components/App.tsx b/src/components/App/index.tsx similarity index 87% rename from src/components/App.tsx rename to src/components/App/index.tsx index 85b722e26..dd5079e60 100644 --- a/src/components/App.tsx +++ b/src/components/App/index.tsx @@ -1,15 +1,15 @@ import React, { ReactElement } from 'react' import { graphql, PageProps, useStaticQuery } from 'gatsby' import Alert from '@shared/atoms/Alert' -import Footer from './Footer/Footer' -import Header from './Header' -import StylesGlobal from '../stylesGlobal/StylesGlobal' +import Footer from '../Footer/Footer' +import Header from '../Header' +import StylesGlobal from '../../stylesGlobal/StylesGlobal' import { useWeb3 } from '@context/Web3' import { useSiteMetadata } from '@hooks/useSiteMetadata' import { useAccountPurgatory } from '@hooks/useAccountPurgatory' import AnnouncementBanner from '@shared/AnnouncementBanner' -import PrivacyPreferenceCenter from './Privacy/PrivacyPreferenceCenter' -import styles from './App.module.css' +import PrivacyPreferenceCenter from '../Privacy/PrivacyPreferenceCenter' +import styles from './index.module.css' const contentQuery = graphql` query AppQuery { diff --git a/src/components/wrapPageElement.tsx b/src/components/App/wrapPageElement.tsx similarity index 74% rename from src/components/wrapPageElement.tsx rename to src/components/App/wrapPageElement.tsx index 8146c238c..4249735c8 100644 --- a/src/components/wrapPageElement.tsx +++ b/src/components/App/wrapPageElement.tsx @@ -1,7 +1,8 @@ import { PageProps } from 'gatsby' import React, { ReactElement } from 'react' -import App from './App' +import App from '.' +// Gatsby-specific, referenced in gatsby-browser.js & gatsby-ssr.js const wrapPageElement = ({ element, props diff --git a/src/components/Asset/AssetActions/AssetActionHistoryTable.tsx b/src/components/Asset/AssetActions/AssetActionHistoryTable.tsx index 5e8d7dec7..76d8399f4 100644 --- a/src/components/Asset/AssetActions/AssetActionHistoryTable.tsx +++ b/src/components/Asset/AssetActions/AssetActionHistoryTable.tsx @@ -12,6 +12,7 @@ export default function AssetActionHistoryTable({ children: ReactNode }): ReactElement { const [open, setOpen] = useState(false) + function handleClick() { setOpen(!open) } diff --git a/src/components/Asset/AssetActions/Compute/index.tsx b/src/components/Asset/AssetActions/Compute/index.tsx index 0424e60f6..347a0006b 100644 --- a/src/components/Asset/AssetActions/Compute/index.tsx +++ b/src/components/Asset/AssetActions/Compute/index.tsx @@ -17,6 +17,7 @@ import { useAsset } from '@context/Asset' import { generateBaseQuery, getFilterTerm, + queryMetadata, transformDDOToAssetSelection } from '@utils/aquarius' import { Formik } from 'formik' @@ -29,7 +30,6 @@ import axios from 'axios' import FormStartComputeDataset from './FormComputeDataset' import styles from './index.module.css' import SuccessConfetti from '@shared/SuccessConfetti' -import Button from '@shared/atoms/Button' import { secondsToString } from '@utils/metadata' import { AssetSelectionAsset } from '@shared/Form/FormFields/AssetSelection' import AlgorithmDatasetsListForCompute from '../../AssetContent/AlgorithmDatasetsListForCompute' @@ -38,15 +38,6 @@ import AssetActionHistoryTable from '../AssetActionHistoryTable' import ComputeJobs from '../../../Profile/History/ComputeJobs' import { useCancelToken } from '@hooks/useCancelToken' import { useIsMounted } from '@hooks/useIsMounted' -import { BaseQueryParams } from '../../../../models/aquarius/BaseQueryParams' -import { SortTermOptions } from '../../../../models/SortAndFilters' -import { SearchQuery } from '../../../../models/aquarius/SearchQuery' - -const SuccessAction = () => ( - -) export default function Compute({ dtBalance, diff --git a/src/components/Asset/AssetActions/Edit/FormEditComputeDataset.tsx b/src/components/Asset/AssetActions/Edit/FormEditComputeDataset.tsx index 16f191c66..6da9fa9a8 100644 --- a/src/components/Asset/AssetActions/Edit/FormEditComputeDataset.tsx +++ b/src/components/Asset/AssetActions/Edit/FormEditComputeDataset.tsx @@ -15,8 +15,6 @@ import { publisherTrustedAlgorithm as PublisherTrustedAlgorithm } from '@oceanpr import { useSiteMetadata } from '@hooks/useSiteMetadata' import FormActions from './FormActions' import { useCancelToken } from '@hooks/useCancelToken' -import { BaseQueryParams } from '../../../../models/aquarius/BaseQueryParams' -import { SortTermOptions } from '../../../../models/SortAndFilters' export default function FormEditComputeDataset({ data, diff --git a/src/components/Asset/AssetContent/index.tsx b/src/components/Asset/AssetContent/index.tsx index 04bc91c64..e97733e30 100644 --- a/src/components/Asset/AssetContent/index.tsx +++ b/src/components/Asset/AssetContent/index.tsx @@ -17,7 +17,6 @@ import MetaMain from './MetaMain' import EditHistory from './EditHistory' import { useWeb3 } from '@context/Web3' import styles from './index.module.css' -import { useSiteMetadata } from '@hooks/useSiteMetadata' import NetworkName from '@shared/NetworkName' export interface AssetContentProps { @@ -51,11 +50,8 @@ export default function AssetContent(props: AssetContentProps): ReactElement { const [showEdit, setShowEdit] = useState() const [isComputeType, setIsComputeType] = useState(false) const [showEditCompute, setShowEditCompute] = useState() - const [showEditAdvancedSettings, setShowEditAdvancedSettings] = - useState() const [isOwner, setIsOwner] = useState(false) const { ddo, price, metadata, type } = useAsset() - const { appConfig } = useSiteMetadata() useEffect(() => { if (!accountId || !owner) return diff --git a/src/components/Footer/MarketStats.tsx b/src/components/Footer/MarketStats.tsx index 01c0f0bef..e34d608c8 100644 --- a/src/components/Footer/MarketStats.tsx +++ b/src/components/Footer/MarketStats.tsx @@ -6,10 +6,11 @@ import Tooltip from '@shared/atoms/Tooltip' import NetworkName from '@shared/NetworkName' import { fetchData, getSubgraphUri } from '@utils/subgraph' import { useSiteMetadata } from '@hooks/useSiteMetadata' -import useNetworkMetadata from '@hooks/useNetworkMetadata' +import useNetworkMetadata, { + filterNetworksByType +} from '@hooks/useNetworkMetadata' import { Logger } from '@oceanprotocol/lib' import styles from './MarketStats.module.css' -import { filterNetworksByType } from '../Header/UserPreferences/Networks' const getTotalPoolsValues = gql` query PoolsData { diff --git a/src/components/Header/Menu.tsx b/src/components/Header/Menu.tsx index 47ebd4638..10a8595ca 100644 --- a/src/components/Header/Menu.tsx +++ b/src/components/Header/Menu.tsx @@ -2,13 +2,13 @@ import React, { ReactElement } from 'react' import { Link } from 'gatsby' import { useLocation } from '@reach/router' import loadable from '@loadable/component' -import styles from './Menu.module.css' import { useSiteMetadata } from '@hooks/useSiteMetadata' -import UserPreferences from './UserPreferences' import Badge from '@shared/atoms/Badge' import Logo from '@shared/atoms/Logo' +import UserPreferences from './UserPreferences' import Networks from './UserPreferences/Networks' import SearchBar from './SearchBar' +import styles from './Menu.module.css' const Wallet = loadable(() => import('./Wallet')) diff --git a/src/components/Header/UserPreferences/Networks/index.tsx b/src/components/Header/UserPreferences/Networks/index.tsx index c9481c41d..f775bc869 100644 --- a/src/components/Header/UserPreferences/Networks/index.tsx +++ b/src/components/Header/UserPreferences/Networks/index.tsx @@ -2,39 +2,17 @@ import React, { ReactElement } from 'react' import Label from '@shared/Form/Input/Label' import { useSiteMetadata } from '@hooks/useSiteMetadata' import FormHelp from '@shared/Form/Input/Help' -import { EthereumListsChain, getNetworkDataById } from '@utils/web3' import Tooltip from '@shared/atoms/Tooltip' import { ReactComponent as Caret } from '@images/caret.svg' import { ReactComponent as Network } from '@images/network.svg' import NetworksList from './NetworksList' import stylesIndex 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' -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 { const { networksList } = useNetworkMetadata() const { appConfig } = useSiteMetadata() diff --git a/src/components/Header/Wallet/Details.tsx b/src/components/Header/Wallet/Details.tsx index 8941ac95e..706c71d00 100644 --- a/src/components/Header/Wallet/Details.tsx +++ b/src/components/Header/Wallet/Details.tsx @@ -5,10 +5,9 @@ import Button from '@shared/atoms/Button' import AddToken from '@shared/AddToken' import Conversion from '@shared/Price/Conversion' import { useWeb3 } from '@context/Web3' - -import styles from './Details.module.css' import { getOceanConfig } from '@utils/ocean' import Web3Feedback from '@shared/Web3Feedback' +import styles from './Details.module.css' export default function Details(): ReactElement { const { diff --git a/src/components/Home/Bookmarks.tsx b/src/components/Home/Bookmarks.tsx index 67e8852aa..b5f6747b2 100644 --- a/src/components/Home/Bookmarks.tsx +++ b/src/components/Home/Bookmarks.tsx @@ -11,19 +11,6 @@ import { CancelToken } from 'axios' import { useSiteMetadata } from '@hooks/useSiteMetadata' 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 = [ { name: 'Data Set', diff --git a/src/components/Home/Home.tsx b/src/components/Home/Home.tsx index 0cc7fedf8..6bf1e8828 100644 --- a/src/components/Home/Home.tsx +++ b/src/components/Home/Home.tsx @@ -13,10 +13,7 @@ import { useUserPreferences } from '@context/UserPreferences' import styles from './Home.module.css' import { useIsMounted } from '@hooks/useIsMounted' import { useCancelToken } from '@hooks/useCancelToken' -import { SearchQuery } from '../../models/aquarius/SearchQuery' -import { SortOptions, SortTermOptions } from '../../models/SortAndFilters' -import { BaseQueryParams } from '../../models/aquarius/BaseQueryParams' -import { PagedAssets } from '../../models/PagedAssets' +import { SortOptions, SortTermOptions } from '../../@types/aquarius/SearchQuery' async function getQueryHighest( chainIds: number[] @@ -141,19 +138,17 @@ export default function HomePage(): ReactElement { /> )} - {queryLatest && ( - - All data sets and algorithms → - - } - /> - )} - - - + {queryLatest && ( + + All data sets and algorithms → + + } + /> + )} + ) } diff --git a/src/components/Profile/History/Downloads.tsx b/src/components/Profile/History/Downloads.tsx index 84a6176a5..e9320a278 100644 --- a/src/components/Profile/History/Downloads.tsx +++ b/src/components/Profile/History/Downloads.tsx @@ -4,7 +4,7 @@ import Time from '@shared/atoms/Time' import AssetTitle from '@shared/AssetList/AssetListTitle' import NetworkName from '@shared/NetworkName' import { useProfile } from '@context/Profile' -import { DownloadedAsset } from '@utils/aquarius' + const columns = [ { name: 'Data Set', diff --git a/src/components/Profile/History/PublishedList.tsx b/src/components/Profile/History/PublishedList.tsx index 0407a9584..6823f8d5a 100644 --- a/src/components/Profile/History/PublishedList.tsx +++ b/src/components/Profile/History/PublishedList.tsx @@ -6,7 +6,7 @@ import { useSiteMetadata } from '@hooks/useSiteMetadata' import { useUserPreferences } from '@context/UserPreferences' import styles from './PublishedList.module.css' import { useCancelToken } from '@hooks/useCancelToken' -import { PagedAssets } from '../../../../models/PagedAssets' +import Filters from '../../Search/Filters' export default function PublishedList({ accountId diff --git a/src/components/Search/Filters.tsx b/src/components/Search/Filters.tsx index 2e38cbde6..376a69ba1 100644 --- a/src/components/Search/Filters.tsx +++ b/src/components/Search/Filters.tsx @@ -2,12 +2,12 @@ import React, { ReactElement, useState } from 'react' import { useNavigate } from '@reach/router' import classNames from 'classnames/bind' import { addExistingParamsToUrl } from './utils' +import Button from '@shared/atoms/Button' +import styles from './Filters.module.css' import { FilterByAccessOptions, FilterByTypeOptions -} from '../../../models/SortAndFilters' -import Button from '@shared/atoms/Button' -import styles from './Filters.module.css' +} from '../../@types/aquarius/SearchQuery' const cx = classNames.bind(styles) diff --git a/src/components/Search/index.tsx b/src/components/Search/index.tsx index eb60e9a11..4164b61d8 100644 --- a/src/components/Search/index.tsx +++ b/src/components/Search/index.tsx @@ -3,13 +3,11 @@ import AssetList from '@shared/AssetList/AssetList' import queryString from 'query-string' import Filters from './Filters' import Sort from './sort' -import { getResults } from './utils' +import { getResults, updateQueryStringParameter } from './utils' import { navigate } from 'gatsby' -import { updateQueryStringParameter } from '@utils/index' import { useUserPreferences } from '@context/UserPreferences' import { useCancelToken } from '@hooks/useCancelToken' import styles from './index.module.css' -import { PagedAssets } from '../../../models/PagedAssets' export default function SearchPage({ location, @@ -78,33 +76,33 @@ export default function SearchPage({ return ( <> -
-
- - -
-
-
- +
+ +
- +
+
+ +
+ ) } diff --git a/src/components/Search/sort.tsx b/src/components/Search/sort.tsx index 5a61be1e5..66a8e2668 100644 --- a/src/components/Search/sort.tsx +++ b/src/components/Search/sort.tsx @@ -7,7 +7,7 @@ import classNames from 'classnames/bind' import { SortDirectionOptions, SortTermOptions -} from '../../../models/SortAndFilters' +} from '../../@types/aquarius/SearchQuery' const cx = classNames.bind(styles) diff --git a/src/components/Search/utils.ts b/src/components/Search/utils.ts index 27d15b407..f8ec4eea9 100644 --- a/src/components/Search/utils.ts +++ b/src/components/Search/utils.ts @@ -6,13 +6,25 @@ import { } from '@utils/aquarius' import queryString from 'query-string' import { CancelToken } from 'axios' -import { BaseQueryParams } from '../../../models/aquarius/BaseQueryParams' -import { SearchQuery } from '../../../models/aquarius/SearchQuery' -import { FilterTerm } from '../../../models/aquarius/FilterTerm' import { SortDirectionOptions, SortTermOptions -} from '../../../models/SortAndFilters' +} from '../../@types/aquarius/SearchQuery' + +export function updateQueryStringParameter( + uri: string, + key: string, + newValue: string +): string { + const regex = new RegExp('([?&])' + key + '=.*?(&|$)', 'i') + const separator = uri.indexOf('?') !== -1 ? '&' : '?' + + if (uri.match(regex)) { + return uri.replace(regex, '$1' + key + '=' + newValue + '$2') + } else { + return uri + separator + key + '=' + newValue + } +} export function escapeESReservedChars(text: string): string { return text?.replace(/([!*+\-=<>&|()\\[\]{}^~?:\\/"])/g, '\\$1') diff --git a/src/models/PagedAssets.ts b/src/models/PagedAssets.ts deleted file mode 100644 index 9ad191858..000000000 --- a/src/models/PagedAssets.ts +++ /dev/null @@ -1,8 +0,0 @@ -import { DDO } from '@oceanprotocol/lib' - -export interface PagedAssets { - results: DDO[] - page: number - totalPages: number - totalResults: number -} diff --git a/src/models/SortAndFilters.ts b/src/models/SortAndFilters.ts deleted file mode 100644 index 18bc0ba35..000000000 --- a/src/models/SortAndFilters.ts +++ /dev/null @@ -1,26 +0,0 @@ -export enum SortDirectionOptions { - Ascending = 'asc', - Descending = 'desc' -} - -export enum SortTermOptions { - Created = 'created', - Relevance = '_score' -} - -export enum FilterByTypeOptions { - Data = 'dataset', - Algorithm = 'algorithm' -} - -export enum FilterByAccessOptions { - Download = 'access', - Compute = 'compute' -} - -export interface SortOptions { - sortBy: SortTermOptions - sortDirection?: SortDirectionOptions -} - -export type Filters = FilterByTypeOptions | FilterByAccessOptions diff --git a/src/models/aquarius/BaseQueryParams.ts b/src/models/aquarius/BaseQueryParams.ts deleted file mode 100644 index 0546dc13e..000000000 --- a/src/models/aquarius/BaseQueryParams.ts +++ /dev/null @@ -1,12 +0,0 @@ -import { SortOptions } from '../SortAndFilters' -import { EsPaginationOptions } from './EsPaginationOptions' -import { FilterTerm } from './FilterTerm' - -export interface BaseQueryParams { - chainIds: number[] - nestedQuery?: any - esPaginationOptions?: EsPaginationOptions - sortOptions?: SortOptions - filters?: FilterTerm[] - ignorePurgatory?: boolean -} diff --git a/src/models/aquarius/DownloadedAsset.ts b/src/models/aquarius/DownloadedAsset.ts deleted file mode 100644 index 79ebbe041..000000000 --- a/src/models/aquarius/DownloadedAsset.ts +++ /dev/null @@ -1,8 +0,0 @@ -import { DDO } from '@oceanprotocol/lib' - -export interface DownloadedAsset { - dtSymbol: string - timestamp: number - networkId: number - ddo: DDO -} diff --git a/src/models/aquarius/EsPaginationOptions.ts b/src/models/aquarius/EsPaginationOptions.ts deleted file mode 100644 index caa93ed2e..000000000 --- a/src/models/aquarius/EsPaginationOptions.ts +++ /dev/null @@ -1,4 +0,0 @@ -export interface EsPaginationOptions { - from?: number - size?: number -} diff --git a/src/models/aquarius/FilterTerm.ts b/src/models/aquarius/FilterTerm.ts deleted file mode 100644 index 7e2944690..000000000 --- a/src/models/aquarius/FilterTerm.ts +++ /dev/null @@ -1,5 +0,0 @@ -export interface FilterTerm { - [property: string]: { - [property: string]: string | number | boolean | number[] | string[] - } -} diff --git a/src/models/aquarius/SearchQuery.ts b/src/models/aquarius/SearchQuery.ts deleted file mode 100644 index b6eb68902..000000000 --- a/src/models/aquarius/SearchQuery.ts +++ /dev/null @@ -1,8 +0,0 @@ -import { SortDirectionOptions } from '../SortAndFilters' -export interface SearchQuery { - from?: number - size?: number - // eslint-disable-next-line @typescript-eslint/no-explicit-any - query: any - sort?: { [jsonPath: string]: SortDirectionOptions } -} diff --git a/src/models/aquarius/SearchResponse.ts b/src/models/aquarius/SearchResponse.ts deleted file mode 100644 index eef2fdfee..000000000 --- a/src/models/aquarius/SearchResponse.ts +++ /dev/null @@ -1,41 +0,0 @@ -/* eslint-disable @typescript-eslint/no-explicit-any */ -/* eslint-disable camelcase */ -import { DDO } from '@oceanprotocol/lib' - -export interface Explanation { - value: number - description: string - details: Explanation[] -} -export interface ShardsResponse { - total: number - successful: number - failed: number - skipped: number -} - -export interface SearchResponse { - took: number - timed_out: boolean - _scroll_id?: string | undefined - _shards: ShardsResponse - hits: { - total: number - max_score: number - hits: Array<{ - _index: string - _type: string - _id: string - _score: number - _source: DDO - _version?: number | undefined - _explanation?: Explanation | undefined - fields?: any - highlight?: any - inner_hits?: any - matched_queries?: string[] | undefined - sort?: string[] | undefined - }> - } - aggregations?: any -} diff --git a/vercel.json b/vercel.json index 37613bcf7..3cab6b7c0 100644 --- a/vercel.json +++ b/vercel.json @@ -1 +1,6 @@ -{ "rewrites": [{ "source": "/asset/:did", "destination": "/asset/" }] } +{ + "rewrites": [ + { "source": "/asset/:did", "destination": "/asset/" }, + { "source": "/profile/:account", "destination": "/profile/" } + ] +}