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

package updates & technical debt cleanup (#1771)

* package updates

* bump Next.js

* update for Next.js v13 new `Link` behavior

* see https://nextjs.org/docs/upgrading#link-component

* test tweaks, simplify getNetworkDisplayName()

* modify codeclimate excludes

* test tweaks and cleanup

* more cleanup

* switch to Node.js v18

* back to Node.js v16

* temporarily run CI against Node.js v16 & v18

* update codeowners

* fixtures fixes for asset price

* switch to Node.js v18

* package updates

* remark updates, typescript and test fixes

* fix

* test run fixes

* yet another lockfileVersion update

* package updates

* test run fixes
This commit is contained in:
Matthias Kretschmann 2022-12-01 09:09:40 +00:00 committed by GitHub
parent b58cb36e00
commit 1b612e4194
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
68 changed files with 49121 additions and 2255 deletions

View File

@ -42,7 +42,7 @@ exclude_patterns:
- '**/*.d.ts'
- '**/@types/'
- '**/_types.*'
- '**/*.stories.tsx'
- '**/*.test.tsx'
- '**/*.stories.*'
- '**/*.test.*'
- '.storybook/'
- '.jest/'

2
.github/CODEOWNERS vendored
View File

@ -1 +1 @@
* @mihaisc @kremalicious @claudiaHash @bogdanfazakas @EnzoVezzaro
* @jamiehewitt15 @mihaisc @kremalicious @bogdanfazakas @EnzoVezzaro

View File

@ -4,7 +4,6 @@ on:
push:
branches:
- main
- v4
- v3
tags:
- '**'
@ -20,7 +19,7 @@ jobs:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
node: ['16']
node: ['18']
steps:
- uses: actions/checkout@v3
@ -47,7 +46,7 @@ jobs:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
node: ['16']
node: ['18']
steps:
- uses: actions/checkout@v3
@ -82,7 +81,7 @@ jobs:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: '16'
node-version: '18'
- name: Cache node_modules
uses: actions/cache@v3
env:
@ -110,7 +109,7 @@ jobs:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
node: ['16']
node: ['18']
steps:
- uses: actions/checkout@v3

1
.gitignore vendored
View File

@ -8,6 +8,7 @@ coverage
.next
.artifacts
.vercel
.swc
repo-metadata.json
networks-metadata.json
src/@types/subgraph

View File

@ -1574,4 +1574,4 @@ export const assets: AssetExtended[] = [
validOrderTx: null
}
}
]
]

3
.jest/__mocks__/tar.ts Normal file
View File

@ -0,0 +1,3 @@
// mocked, as this module makes Jest go all
// "Uncaught SyntaxError: Octal escape sequences are not allowed in strict mode"
export default jest.fn().mockImplementation(() => 'hello')

View File

@ -9,13 +9,13 @@ const createJestConfig = nextJest({
const customJestConfig = {
rootDir: '../',
// Add more setup options before each test is run
setupFilesAfterEnv: ['<rootDir>/.jest/jest.setup.js'],
setupFilesAfterEnv: ['<rootDir>/.jest/jest.setup.tsx'],
// if using TypeScript with a baseUrl set to the root directory then you need the below for alias' to work
moduleDirectories: ['node_modules', '<rootDir>/src'],
testEnvironment: 'jest-environment-jsdom',
testEnvironment: 'jsdom',
moduleNameMapper: {
'^.+\\.(svg)$': '<rootDir>/.jest/__mocks__/svgrMock.tsx',
// '^@/components/(.*)$': '<rootDir>/components/$1',
'@components/(.*)$': '<rootDir>/src/components/$1',
'@shared(.*)$': '<rootDir>/src/components/@shared/$1',
'@hooks/(.*)$': '<rootDir>/src/@hooks/$1',
'@context/(.*)$': '<rootDir>/src/@context/$1',
@ -29,8 +29,25 @@ const customJestConfig = {
'!src/**/*.{stories,test}.{ts,tsx}',
'!src/@types/**/*.{ts,tsx}'
],
testPathIgnorePatterns: ['node_modules', '\\.cache', '.next', 'coverage']
// Add ignores so ESM packages are not transformed by Jest
// note: this does not work with Next.js, hence workaround further down
// see: https://github.com/vercel/next.js/issues/35634#issuecomment-1115250297
// transformIgnorePatterns: ['node_modules/(?!(uuid|remark)/)'],
testPathIgnorePatterns: [
'<rootDir>/node_modules/',
'<rootDir>/.next/',
'<rootDir>/coverage'
]
}
// createJestConfig is exported this way to ensure that next/jest can load the Next.js config which is async
module.exports = createJestConfig(customJestConfig)
// https://github.com/vercel/next.js/issues/35634#issuecomment-1115250297
async function jestConfig() {
const nextJestConfig = await createJestConfig(customJestConfig)()
// Add ignores for specific ESM packages so they are transformed by Jest
// /node_modules/ is the first pattern
nextJestConfig.transformIgnorePatterns[0] = '/node_modules/(?!uuid|remark)/'
return nextJestConfig
}
module.exports = jestConfig

View File

@ -1,3 +0,0 @@
import '@testing-library/jest-dom/extend-expect'
import './__mocks__/matchMedia'
import './__mocks__/hooksMocks'

20
.jest/jest.setup.tsx Normal file
View File

@ -0,0 +1,20 @@
import '@testing-library/jest-dom/extend-expect'
import { jest } from '@jest/globals'
import './__mocks__/matchMedia'
import './__mocks__/hooksMocks'
jest.mock('next/router', () => ({
useRouter: jest.fn().mockImplementation(() => ({
route: '/',
pathname: '/'
}))
}))
// jest.mock('next/head', () => {
// return {
// __esModule: true,
// default: ({ children }: { children: Array<React.ReactElement> }) => {
// return <>{children}</>
// }
// }
// })

2
.nvmrc
View File

@ -1 +1 @@
16
18

View File

@ -253,7 +253,7 @@ export default function NetworkName(): ReactElement {
const { networkId, isTestnet } = useWeb3()
const { networksList } = useNetworkMetadata()
const networkData = getNetworkDataById(networksList, networkId)
const networkName = getNetworkDisplayName(networkData, networkId)
const networkName = getNetworkDisplayName(networkData)
return (
<>

50519
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -32,12 +32,12 @@
"@tippyjs/react": "^4.2.6",
"@urql/exchange-refocus": "^1.0.0",
"@walletconnect/web3-provider": "^1.8.0",
"axios": "^1.1.3",
"axios": "^1.2.0",
"classnames": "^2.3.2",
"date-fns": "^2.29.3",
"decimal.js": "^10.3.1",
"decimal.js": "^10.4.2",
"dom-confetti": "^0.2.2",
"dotenv": "^16.0.1",
"dotenv": "^16.0.3",
"filesize": "^10.0.5",
"formik": "^2.2.9",
"gray-matter": "^4.0.3",
@ -46,28 +46,28 @@
"js-cookie": "^3.0.1",
"match-sorter": "^6.3.1",
"myetherwallet-blockies": "^0.1.1",
"next": "12.3.1",
"next": "13.0.5",
"query-string": "^7.1.1",
"react": "^18.2.0",
"react-clipboard.js": "^2.0.16",
"react-data-table-component": "^7.5.2",
"react-dom": "^18.1.0",
"react-data-table-component": "^7.5.3",
"react-dom": "^18.2.0",
"react-dotdotdot": "^1.3.1",
"react-modal": "^3.15.1",
"react-paginate": "^8.1.3",
"react-select": "^5.4.0",
"react-spring": "^9.5.2",
"react-modal": "^3.16.1",
"react-paginate": "^8.1.4",
"react-select": "^5.6.1",
"react-spring": "^9.5.5",
"react-tabs": "^5.1.0",
"react-toastify": "^9.0.4",
"remark": "^13.0.0",
"remark-gfm": "^1.0.0",
"remark-html": "^13.0.1",
"react-toastify": "^9.1.1",
"remark": "^14.0.2",
"remark-gfm": "^3.0.1",
"remark-html": "^15.0.1",
"remove-markdown": "^0.5.0",
"slugify": "^1.6.5",
"swr": "^1.3.0",
"urql": "^3.0.3",
"web3": "^1.8.0",
"web3modal": "^1.9.9",
"web3": "^1.8.1",
"web3modal": "^1.9.10",
"yup": "^0.32.11"
},
"devDependencies": {
@ -78,37 +78,38 @@
"@svgr/webpack": "^6.5.1",
"@testing-library/jest-dom": "^5.16.5",
"@testing-library/react": "^13.4.0",
"@types/jest": "^29.2.3",
"@types/js-cookie": "^3.0.2",
"@types/loadable__component": "^5.13.4",
"@types/node": "^18.8.5",
"@types/react": "^18.0.21",
"@types/react-dom": "^18.0.5",
"@types/react": "^18.0.25",
"@types/react-dom": "^18.0.9",
"@types/react-modal": "^3.13.1",
"@types/react-paginate": "^7.1.1",
"@types/remove-markdown": "^0.3.1",
"@typescript-eslint/eslint-plugin": "^5.42.0",
"@typescript-eslint/parser": "^5.42.0",
"@typescript-eslint/eslint-plugin": "^5.43.0",
"@typescript-eslint/parser": "^5.43.0",
"apollo": "^2.34.0",
"cross-env": "^7.0.3",
"eslint": "^8.25.0",
"eslint": "^8.28.0",
"eslint-config-oceanprotocol": "^2.0.4",
"eslint-config-prettier": "^8.5.0",
"eslint-plugin-jest-dom": "^4.0.2",
"eslint-plugin-jest-dom": "^4.0.3",
"eslint-plugin-prettier": "^4.2.1",
"eslint-plugin-react": "^7.31.10",
"eslint-plugin-react": "^7.31.11",
"eslint-plugin-react-hooks": "^4.6.0",
"eslint-plugin-testing-library": "^5.7.2",
"eslint-plugin-testing-library": "^5.9.1",
"https-browserify": "^1.0.0",
"husky": "^8.0.1",
"jest": "^29.1.2",
"jest-environment-jsdom": "^29.2.2",
"prettier": "^2.7.1",
"husky": "^8.0.2",
"jest": "^29.3.1",
"jest-environment-jsdom": "^29.3.1",
"prettier": "^2.8.0",
"pretty-quick": "^3.1.3",
"process": "^0.11.10",
"serve": "^14.0.1",
"serve": "^14.1.2",
"stream-http": "^3.2.0",
"tsconfig-paths-webpack-plugin": "^4.0.0",
"typescript": "^4.8.4"
"typescript": "^4.9.3"
},
"overrides": {
"graphql": "15.8.0"
@ -118,7 +119,7 @@
"url": "https://github.com/oceanprotocol/market"
},
"engines": {
"node": "16"
"node": "18"
},
"browserslist": [
">0.2%",

View File

@ -9,7 +9,7 @@ import React, {
} from 'react'
import { Config, LoggerInstance, Purgatory } from '@oceanprotocol/lib'
import { CancelToken } from 'axios'
import { retrieveAsset } from '@utils/aquarius'
import { getAsset } from '@utils/aquarius'
import { useWeb3 } from './Web3'
import { useCancelToken } from '@hooks/useCancelToken'
import { getOceanConfig, getDevelopmentConfig } from '@utils/ocean'
@ -66,7 +66,7 @@ function AssetProvider({
LoggerInstance.log('[asset] Fetching asset...')
setLoading(true)
const asset = await retrieveAsset(did, token)
const asset = await getAsset(did, token)
if (!asset) {
setError(

View File

@ -7,7 +7,7 @@ import React, {
useEffect,
useState
} from 'react'
import { OpcQuery } from 'src/@types/subgraph/OpcQuery'
import { OpcQuery } from '../../../src/@types/subgraph/OpcQuery'
import { OperationResult } from 'urql'
import { opcQuery } from './_queries'
import { MarketMetadataProviderValue, OpcFee } from './_types'

View File

@ -307,7 +307,7 @@ function Web3Provider({ children }: { children: ReactNode }): ReactElement {
)
// Construct network display name
const networkDisplayName = getNetworkDisplayName(networkData, networkId)
const networkDisplayName = getNetworkDisplayName(networkData)
setNetworkDisplayName(networkDisplayName)
setIsTestnet(getNetworkType(networkData) !== NetworkType.Mainnet)

View File

@ -0,0 +1,43 @@
import { getNetworkType, getNetworkDisplayName } from './utils'
describe('useNetworkMetadata/utils', () => {
test('getNetworkType returns mainnet', () => {
const type = getNetworkType({
name: 'Eth',
title: 'Eth'
// eslint-disable-next-line @typescript-eslint/no-explicit-any
} as any)
expect(type).toBe('mainnet')
})
test('getNetworkType returns testnet if "Test" is in name', () => {
const type = getNetworkType({
name: 'Testnet',
title: 'Testnet'
// eslint-disable-next-line @typescript-eslint/no-explicit-any
} as any)
expect(type).toBe('testnet')
})
test('getNetworkDisplayName returns correct values', () => {
/* eslint-disable @typescript-eslint/no-explicit-any */
const type1 = getNetworkDisplayName({
chainId: 1,
chain: 'ETH',
name: 'Ethereum Mainnet'
} as any)
expect(type1).toBe('ETH')
const type2 = getNetworkDisplayName({ chainId: 80001 } as any)
expect(type2).toBe('Mumbai')
const type3 = getNetworkDisplayName({ chainId: 8996 } as any)
expect(type3).toBe('Development')
const type4 = getNetworkDisplayName({ chainId: 2021000 } as any)
expect(type4).toBe('GAIA-X')
/* eslint-enable @typescript-eslint/no-explicit-any */
})
})

View File

@ -11,9 +11,8 @@ export function getNetworkType(network: EthereumListsChain): string {
// We hack in mainnet detection for moonriver.
if (
network &&
!network.name.includes('Testnet') &&
!network.title?.includes('Testnet') &&
network.name !== 'Moonbase Alpha'
!network.name?.includes('Testnet') &&
!network.title?.includes('Testnet')
) {
return NetworkType.Mainnet
} else {
@ -21,19 +20,13 @@ export function getNetworkType(network: EthereumListsChain): string {
}
}
export function getNetworkDisplayName(
data: EthereumListsChain,
networkId: number
): string {
export function getNetworkDisplayName(data: EthereumListsChain): string {
let displayName
switch (networkId) {
switch (data.chainId) {
case 137:
displayName = 'Polygon'
break
case 1287:
displayName = 'Moonbase'
break
case 1285:
displayName = 'Moonriver'
break
@ -43,9 +36,6 @@ export function getNetworkDisplayName(
case 8996:
displayName = 'Development'
break
case 3:
displayName = 'Ropsten'
break
case 5:
displayName = 'Görli'
break
@ -54,7 +44,9 @@ export function getNetworkDisplayName(
break
default:
displayName = data
? `${data.chain} ${getNetworkType(data) === 'mainnet' ? '' : data.name}`
? `${data.chain}${
getNetworkType(data) === 'mainnet' ? '' : ` ${data.name}`
}`
: 'Unknown'
break
}

View File

@ -0,0 +1,70 @@
import {
SortDirectionOptions,
SortTermOptions
} from '../../@types/aquarius/SearchQuery'
import { escapeEsReservedCharacters, getFilterTerm, generateBaseQuery } from '.'
const defaultBaseQueryReturn = {
from: 0,
query: {
bool: {
filter: [
{ terms: { chainId: [1, 3] } },
{ term: { _index: 'aquarius' } },
{ term: { 'purgatory.state': false } },
{ bool: { must_not: [{ term: { 'nft.state': 5 } }] } }
]
}
},
size: 1000
}
describe('@utils/aquarius', () => {
test('escapeEsReservedCharacters', () => {
expect(escapeEsReservedCharacters('<')).toBe('\\<')
})
test('getFilterTerm with string value', () => {
expect(getFilterTerm('hello', 'world')).toStrictEqual({
term: { hello: 'world' }
})
})
test('getFilterTerm with array value', () => {
expect(getFilterTerm('hello', ['world', 'domination'])).toStrictEqual({
terms: { hello: ['world', 'domination'] }
})
})
test('generateBaseQuery', () => {
expect(generateBaseQuery({ chainIds: [1, 3] })).toStrictEqual(
defaultBaseQueryReturn
)
})
test('generateBaseQuery aggs are passed through', () => {
expect(
generateBaseQuery({ chainIds: [1, 3], aggs: 'hello world' })
).toStrictEqual({
...defaultBaseQueryReturn,
aggs: 'hello world'
})
})
test('generateBaseQuery sortOptions are passed through', () => {
expect(
generateBaseQuery({
chainIds: [1, 3],
sortOptions: {
sortBy: SortTermOptions.Created,
sortDirection: SortDirectionOptions.Ascending
}
})
).toStrictEqual({
...defaultBaseQueryReturn,
sort: {
'nft.created': 'asc'
}
})
})
})

View File

@ -1,13 +1,13 @@
import { Asset, LoggerInstance } from '@oceanprotocol/lib'
import { AssetSelectionAsset } from '@shared/FormInput/InputElement/AssetSelection'
import axios, { CancelToken, AxiosResponse } from 'axios'
import { OrdersData_orders as OrdersData } from '../@types/subgraph/OrdersData'
import { metadataCacheUri } from '../../app.config'
import { OrdersData_orders as OrdersData } from '../../@types/subgraph/OrdersData'
import { metadataCacheUri } from '../../../app.config'
import {
SortDirectionOptions,
SortTermOptions
} from '../@types/aquarius/SearchQuery'
import { transformAssetToAssetSelection } from './assetConvertor'
} from '../../@types/aquarius/SearchQuery'
import { transformAssetToAssetSelection } from '../assetConvertor'
export interface UserSales {
id: string
@ -55,13 +55,13 @@ export function generateBaseQuery(
...(baseQueryParams.filters || []),
baseQueryParams.chainIds
? getFilterTerm('chainId', baseQueryParams.chainIds)
: '',
: [],
getFilterTerm('_index', 'aquarius'),
...(baseQueryParams.ignorePurgatory
? ''
? []
: [getFilterTerm('purgatory.state', false)]),
...(baseQueryParams.ignoreState
? ''
? []
: [
{
bool: {
@ -143,7 +143,7 @@ export async function queryMetadata(
}
}
export async function retrieveAsset(
export async function getAsset(
did: string,
cancelToken: CancelToken
): Promise<Asset> {
@ -186,73 +186,7 @@ export async function getAssetsNames(
}
}
export async function getAssetsFromDidList(
didList: string[],
chainIds: number[],
cancelToken: CancelToken
): Promise<PagedAssets> {
try {
if (!didList.length) return
const baseParams = {
chainIds,
filters: [getFilterTerm('_id', didList)],
ignorePurgatory: true
} as BaseQueryParams
const query = generateBaseQuery(baseParams)
const queryResult = await queryMetadata(query, cancelToken)
return queryResult
} catch (error) {
LoggerInstance.error(error.message)
}
}
export async function getAssetsFromDtList(
dtList: string[],
chainIds: number[],
cancelToken: CancelToken
): Promise<Asset[]> {
try {
if (!dtList.length) return
const baseParams = {
chainIds,
filters: [getFilterTerm('services.datatokenAddress', dtList)],
ignorePurgatory: true
} as BaseQueryParams
const query = generateBaseQuery(baseParams)
const queryResult = await queryMetadata(query, cancelToken)
return queryResult?.results
} catch (error) {
LoggerInstance.error(error.message)
}
}
export async function getAssetsFromNftList(
nftList: string[],
chainIds: number[],
cancelToken: CancelToken
): Promise<Asset[]> {
try {
if (!(nftList.length > 0)) return
const baseParams = {
chainIds,
filters: [getFilterTerm('nftAddress', nftList)],
ignorePurgatory: true
} as BaseQueryParams
const query = generateBaseQuery(baseParams)
const queryResult = await queryMetadata(query, cancelToken)
return queryResult?.results
} catch (error) {
LoggerInstance.error(error.message)
}
}
export async function retrieveDDOListByDIDs(
export async function getAssetsFromDids(
didList: string[],
chainIds: number[],
cancelToken: CancelToken
@ -368,7 +302,7 @@ export async function getPublishedAssets(
}
}
export async function getTopPublishers(
async function getTopPublishers(
chainIds: number[],
cancelToken: CancelToken,
page?: number,

View File

@ -17,7 +17,7 @@ import {
queryMetadata,
getFilterTerm,
generateBaseQuery,
retrieveDDOListByDIDs
getAssetsFromDids
} from './aquarius'
import { fetchDataForMultipleChains } from './subgraph'
import { getServiceById, getServiceByName } from './ddo'
@ -338,7 +338,7 @@ export async function createTrustedAlgorithmList(
if (!selectedAlgorithms || selectedAlgorithms.length === 0)
return trustedAlgorithms
const selectedAssets = await retrieveDDOListByDIDs(
const selectedAssets = await getAssetsFromDids(
selectedAlgorithms,
[assetChainId],
cancelToken
@ -393,31 +393,3 @@ export async function transformComputeFormToServiceComputeOptions(
return privacy
}
export async function checkComputeResourcesValidity(
asset: Asset,
accountId: string,
computeEnvMaxJobDuration: number,
datasetTimeout?: number,
algorithmTimeout?: number,
cancelToken?: CancelToken
): Promise<boolean> {
const jobs = await getComputeJobs(
[asset?.chainId],
accountId,
asset,
cancelToken
)
if (jobs.computeJobs.length <= 0) return false
const inputValues = []
computeEnvMaxJobDuration && inputValues.push(computeEnvMaxJobDuration * 60)
datasetTimeout && inputValues.push(datasetTimeout)
algorithmTimeout && inputValues.push(algorithmTimeout)
const minValue = Math.min(...inputValues)
const jobStartDate = new Date(
parseInt(jobs.computeJobs[0].dateCreated) * 1000
)
jobStartDate.setMinutes(jobStartDate.getMinutes() + Math.floor(minValue / 60))
const currentTime = new Date().getTime() / 1000
return Math.floor(jobStartDate.getTime() / 1000) > currentTime
}

View File

@ -1,5 +1,7 @@
import { getEnsName, getEnsAddress, getEnsProfile } from './ens'
import { getEnsName, getEnsAddress, getEnsProfile } from '.'
// TODO: this directly hits the ENS registry, which is not ideal
// so we need to rewrite this to mock responses instead for more reliable test runs.
describe('@utils/ens', () => {
jest.setTimeout(10000)
jest.retryTimes(2)

View File

@ -1,4 +1,4 @@
import { fetchData } from './fetch'
import { fetchData } from '../fetch'
const apiUrl = 'https://ens-proxy.oceanprotocol.com/api'

View File

@ -3,12 +3,6 @@ import { Asset } from '@oceanprotocol/lib'
// Boolean value that will be true if we are inside a browser, false otherwise
export const isBrowser = typeof window !== 'undefined'
export function sleep(ms: number): Promise<void> {
return new Promise((resolve) => {
setTimeout(resolve, ms)
})
}
export function removeItemFromArray<T>(arr: Array<T>, value: T): Array<T> {
const index = arr.indexOf(value)
if (index > -1) {

View File

@ -1,4 +1,4 @@
import remark from 'remark'
import { remark } from 'remark'
import remarkHtml from 'remark-html'
import remarkGfm from 'remark-gfm'
@ -6,7 +6,7 @@ export function markdownToHtml(markdown: string): string {
const result = remark()
.use(remarkGfm)
.use(remarkHtml) // serializes through remark-rehype and rehype-stringify
.processSync(markdown).contents
.processSync(markdown)
return result.toString()
}

View File

@ -1,4 +1,4 @@
import { sanitizeUrl } from './url'
import { sanitizeUrl } from '.'
describe('@utils/url', () => {
test('sanitizeUrl', () => {

View File

@ -1,7 +1,7 @@
import { AllLockedQuery } from 'src/@types/subgraph/AllLockedQuery'
import { OwnAllocationsQuery } from 'src/@types/subgraph/OwnAllocationsQuery'
import { NftOwnAllocationQuery } from 'src/@types/subgraph/NftOwnAllocationQuery'
import { OceanLockedQuery } from 'src/@types/subgraph/OceanLockedQuery'
import { AllLockedQuery } from '../../src/@types/subgraph/AllLockedQuery'
import { OwnAllocationsQuery } from '../../src/@types/subgraph/OwnAllocationsQuery'
import { NftOwnAllocationQuery } from '../../src/@types/subgraph/NftOwnAllocationQuery'
import { OceanLockedQuery } from '../../src/@types/subgraph/OceanLockedQuery'
import { gql, OperationResult } from 'urql'
import { fetchData, getQueryContext } from './subgraph'
import axios from 'axios'
@ -11,9 +11,6 @@ import {
getNetworkType,
NetworkType
} from '@hooks/useNetworkMetadata'
import { getAssetsFromNftList } from './aquarius'
import { chainIdsSupported } from '../../app.config'
import { Asset } from '@oceanprotocol/lib'
const AllLocked = gql`
query AllLockedQuery {
@ -80,6 +77,7 @@ export function getVeChainNetworkIds(assetNetworkIds: number[]): number[] {
})
return veNetworkIds
}
export async function getNftOwnAllocation(
userAddress: string,
nftAddress: string,
@ -177,17 +175,3 @@ export async function getOwnAllocations(
return allocations
}
export async function getOwnAssetsWithAllocation(
networkIds: number[],
userAddress: string
): Promise<Asset[]> {
const allocations = await getOwnAllocations(networkIds, userAddress)
const assets = await getAssetsFromNftList(
allocations.map((x) => x.nftAddress),
chainIdsSupported,
null
)
return assets
}

View File

@ -33,7 +33,7 @@ export async function addCustomNetwork(
const newNetworkData = {
chainId: `0x${network.chainId.toString(16)}`,
chainName: getNetworkDisplayName(network, network.chainId),
chainName: getNetworkDisplayName(network),
nativeCurrency: network.nativeCurrency,
rpcUrls: network.rpc,
blockExplorerUrls

View File

@ -41,9 +41,7 @@ export default function AssetListTitle({
return (
<h3 className={styles.title}>
<Link href={`/asset/${did || asset?.id}`}>
<a>{assetTitle}</a>
</Link>
<Link href={`/asset/${did || asset?.id}`}>{assetTitle}</Link>
</h3>
)
}

View File

@ -35,83 +35,77 @@ export default function AssetTeaser({
return (
<article className={`${styles.teaser} ${styles[type]}`}>
<Link href={`/asset/${asset.id}`}>
<a className={styles.link}>
<aside className={styles.detailLine}>
<AssetType
className={styles.typeLabel}
type={type}
accessType={accessType}
/>
<span className={styles.typeLabel}>
{datatokens[0]?.symbol.substring(0, 9)}
</span>
<NetworkName
networkId={asset.chainId}
className={styles.typeLabel}
/>
</aside>
<header className={styles.header}>
<Dotdotdot tagName="h1" clamp={3} className={styles.title}>
{name.slice(0, 200)}
<Link href={`/asset/${asset.id}`} className={styles.link}>
<aside className={styles.detailLine}>
<AssetType
className={styles.typeLabel}
type={type}
accessType={accessType}
/>
<span className={styles.typeLabel}>
{datatokens[0]?.symbol.substring(0, 9)}
</span>
<NetworkName networkId={asset.chainId} className={styles.typeLabel} />
</aside>
<header className={styles.header}>
<Dotdotdot tagName="h1" clamp={3} className={styles.title}>
{name.slice(0, 200)}
</Dotdotdot>
{!noPublisher && <Publisher account={owner} minimal />}
</header>
{!noDescription && (
<div className={styles.content}>
<Dotdotdot tagName="p" clamp={3}>
{removeMarkdown(description?.substring(0, 300) || '')}
</Dotdotdot>
{!noPublisher && <Publisher account={owner} minimal />}
</header>
{!noDescription && (
<div className={styles.content}>
<Dotdotdot tagName="p" clamp={3}>
{removeMarkdown(description?.substring(0, 300) || '')}
</Dotdotdot>
</div>
)}
{!noPrice && (
<div className={styles.price}>
{isUnsupportedPricing || !asset.services.length ? (
<strong>No pricing schema available</strong>
</div>
)}
{!noPrice && (
<div className={styles.price}>
{isUnsupportedPricing || !asset.services.length ? (
<strong>No pricing schema available</strong>
) : (
<Price accessDetails={asset.accessDetails} size="small" />
)}
</div>
)}
<footer className={styles.footer}>
{allocated && allocated > 0 ? (
<span className={styles.typeLabel}>
{allocated < 0 ? (
''
) : (
<Price accessDetails={asset.accessDetails} size="small" />
<>
<strong>{formatNumber(allocated, locale, '0')}</strong>{' '}
veOCEAN
</>
)}
</div>
)}
<footer className={styles.footer}>
{allocated && allocated > 0 ? (
<span className={styles.typeLabel}>
{allocated < 0 ? (
''
) : (
<>
<strong>{formatNumber(allocated, locale, '0')}</strong>{' '}
veOCEAN
</>
)}
</span>
) : null}
{orders && orders > 0 ? (
<span className={styles.typeLabel}>
{orders < 0 ? (
'N/A'
) : (
<>
<strong>{orders}</strong> {orders === 1 ? 'sale' : 'sales'}
</>
)}
</span>
) : null}
{asset.views && asset.views > 0 ? (
<span className={styles.typeLabel}>
{asset.views < 0 ? (
'N/A'
) : (
<>
<strong>{asset.views}</strong>{' '}
{asset.views === 1 ? 'view' : 'views'}
</>
)}
</span>
) : null}
</footer>
</a>
</span>
) : null}
{orders && orders > 0 ? (
<span className={styles.typeLabel}>
{orders < 0 ? (
'N/A'
) : (
<>
<strong>{orders}</strong> {orders === 1 ? 'sale' : 'sales'}
</>
)}
</span>
) : null}
{asset.views && asset.views > 0 ? (
<span className={styles.typeLabel}>
{asset.views < 0 ? (
'N/A'
) : (
<>
<strong>{asset.views}</strong>{' '}
{asset.views === 1 ? 'view' : 'views'}
</>
)}
</span>
) : null}
</footer>
</Link>
</article>
)

View File

@ -2,7 +2,7 @@ import React, { ReactElement, useState } from 'react'
import { useField, useFormikContext } from 'formik'
import UrlInput from '../URLInput'
import { InputProps } from '@shared/FormInput'
import { FormPublishData } from 'src/components/Publish/_types'
import { FormPublishData } from '@components/Publish/_types'
import { LoggerInstance } from '@oceanprotocol/lib'
import ImageInfo from './Info'
import { getContainerChecksum } from '@utils/docker'

View File

@ -6,7 +6,7 @@ import FileInfo from '../FilesInput/Info'
import styles from './index.module.css'
import Button from '@shared/atoms/Button'
import { LoggerInstance, ProviderInstance } from '@oceanprotocol/lib'
import { FormPublishData } from 'src/components/Publish/_types'
import { FormPublishData } from '@components/Publish/_types'
import { getOceanConfig } from '@utils/ocean'
import { useWeb3 } from '@context/Web3'
import axios from 'axios'

View File

@ -17,7 +17,7 @@ export default function NetworkName({
}): ReactElement {
const { networksList } = useNetworkMetadata()
const networkData = getNetworkDataById(networksList, networkId)
const networkName = getNetworkDisplayName(networkData, networkId)
const networkName = getNetworkDisplayName(networkData)
return (
<span

View File

@ -41,8 +41,8 @@ export default function Publisher({
name
) : (
<>
<Link href={`/profile/${account}`}>
<a title="Show profile page.">{name}</a>
<Link href={`/profile/${account}`} title="Show profile page.">
{name}
</Link>
</>
)}

View File

@ -18,10 +18,10 @@ export default function WalletNetworkSwitcher(): ReactElement {
const walletNetworkData = getNetworkDataById(networksList, networkId)
const ddoNetworkName = (
<strong>{getNetworkDisplayName(ddoNetworkData, asset.chainId)}</strong>
<strong>{getNetworkDisplayName(ddoNetworkData)}</strong>
)
const walletNetworkName = (
<strong>{getNetworkDisplayName(walletNetworkData, networkId)}</strong>
<strong>{getNetworkDisplayName(walletNetworkData)}</strong>
)
async function switchWalletNetwork() {

View File

@ -1,5 +1,4 @@
import React, { ReactElement, useEffect, useState } from 'react'
import { useWeb3 } from '@context/Web3'
import Status from '@shared/atoms/Status'
import styles from './index.module.css'
import WalletNetworkSwitcher from '../WalletNetworkSwitcher'

View File

@ -41,10 +41,8 @@ export default function Button({
})
return to ? (
<Link href={to}>
<a className={styleClasses} {...props}>
{children}
</a>
<Link href={to} className={styleClasses} {...props}>
{children}
</Link>
) : href ? (
<a href={href} className={styleClasses} {...props}>

View File

@ -15,10 +15,12 @@ const Tag = ({ tag, noLinks }: { tag: string; noLinks?: boolean }) => {
return noLinks ? (
<span className={styles.tag}>{tag}</span>
) : (
<Link href={`/search?tags=${urlEncodedTag}&sort=_score&sortOrder=desc`}>
<a className={styles.tag} title={tag}>
{tag}
</a>
<Link
href={`/search?tags=${urlEncodedTag}&sort=_score&sortOrder=desc`}
className={styles.tag}
title={tag}
>
{tag}
</Link>
)
}

View File

@ -24,24 +24,26 @@ export default function AssetComputeSelection({
<Empty />
) : (
assets.map((asset: AssetSelectionAsset) => (
<Link href={`/asset/${asset.did}`} key={asset.did}>
<a className={styles.row}>
<div className={styles.info}>
<h3 className={styles.title}>
<Dotdotdot clamp={1} tagName="span">
{asset.name}
</Dotdotdot>
</h3>
<Dotdotdot clamp={1} tagName="code" className={styles.did}>
{asset.symbol} | {asset.did}
<Link
href={`/asset/${asset.did}`}
key={asset.did}
className={styles.row}
>
<div className={styles.info}>
<h3 className={styles.title}>
<Dotdotdot clamp={1} tagName="span">
{asset.name}
</Dotdotdot>
</div>
<PriceUnit
price={Number(asset.price)}
size="small"
className={styles.price}
/>
</a>
</h3>
<Dotdotdot clamp={1} tagName="code" className={styles.did}>
{asset.symbol} | {asset.did}
</Dotdotdot>
</div>
<PriceUnit
price={Number(asset.price)}
size="small"
className={styles.price}
/>
</Link>
))
)}

View File

@ -10,7 +10,7 @@ export default function ComputeHistory({
}: {
title: string
children: ReactNode
refetchJobs?: any
refetchJobs?: React.Dispatch<React.SetStateAction<boolean>>
}): ReactElement {
const [open, setOpen] = useState(false)

View File

@ -13,7 +13,7 @@ import { useCancelToken } from '@hooks/useCancelToken'
import { useIsMounted } from '@hooks/useIsMounted'
import styles from './index.module.css'
import { useFormikContext } from 'formik'
import { FormPublishData } from 'src/components/Publish/_types'
import { FormPublishData } from '@components/Publish/_types'
import { getTokenBalanceFromSymbol } from '@utils/web3'
import AssetStats from './AssetStats'

View File

@ -3,7 +3,7 @@ import Tooltip from '@shared/atoms/Tooltip'
import { decodeTokenURI } from '@utils/nft'
import { useFormikContext } from 'formik'
import React from 'react'
import { FormPublishData } from 'src/components/Publish/_types'
import { FormPublishData } from '@components/Publish/_types'
import Logo from '@shared/atoms/Logo'
import NftTooltip from './NftTooltip'
import styles from './index.module.css'

View File

@ -5,7 +5,7 @@ import FormActions from './FormActions'
jest.mock('formik')
describe('src/components/Asset/Edit/FormActions.tsx', () => {
describe('@components/Asset/Edit/FormActions.tsx', () => {
it('renders fixed price', () => {
const isValid = true
;(useFormikContext as jest.Mock).mockReturnValue([isValid])

View File

@ -3,7 +3,7 @@ import { Field, Form, useFormikContext } from 'formik'
import Input from '@shared/FormInput'
import FormActions from './FormActions'
import { useAsset } from '@context/Asset'
import { FormPublishData } from 'src/components/Publish/_types'
import { FormPublishData } from '@components/Publish/_types'
import { getFileInfo } from '@utils/provider'
import { getFieldContent } from '@utils/form'

View File

@ -24,17 +24,11 @@ export default function Links() {
</Fragment>
))}
<Link href="/imprint">
<a>Imprint</a>
</Link>
<Link href="/imprint">Imprint</Link>
{' — '}
<Link href="/terms">
<a>Terms</a>
</Link>
<Link href="/terms">Terms</Link>
{' — '}
<Link href={privacyPolicySlug}><