Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: remove C2D #2037

Merged
merged 21 commits into from
Jun 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
596 changes: 298 additions & 298 deletions .jest/__fixtures__/datasetsWithAccessDetails.ts

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion content/site.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"link": "/profile"
}
],
"announcement": "[Lock your OCEAN](https://df.oceandao.org/) to get veOCEAN, earn rewards and curate data.",
"announcement": "",
"warning": {
"ctd": "Please note that Compute-to-Data is still in alpha phase."
}
Expand Down
86,893 changes: 41,004 additions & 45,889 deletions package-lock.json

Large diffs are not rendered by default.

104 changes: 52 additions & 52 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,97 +26,97 @@
},
"dependencies": {
"@codemirror/lang-json": "^6.0.1",
"@codemirror/language": "^6.3.1",
"@codemirror/language": "^6.10.1",
"@coingecko/cryptoformat": "^0.5.4",
"@loadable/component": "^5.15.2",
"@loadable/component": "^5.16.4",
"@next/third-parties": "^14.2.3",
"@oceanprotocol/art": "^3.2.0",
"@oceanprotocol/lib": "^3.2.0",
"@oceanprotocol/typographies": "^0.1.0",
"@oceanprotocol/use-dark-mode": "^2.4.3",
"@orbisclub/orbis-sdk": "^0.4.40",
"@orbisclub/orbis-sdk": "^0.4.89",
"@tippyjs/react": "^4.2.6",
"@uiw/react-codemirror": "^4.19.5",
"@uiw/react-codemirror": "4.19.5",
"@urql/exchange-refocus": "^1.0.0",
"axios": "^1.2.0",
"classnames": "^2.3.2",
"axios": "^1.7.2",
"classnames": "^2.5.1",
"connectkit": "^1.3.0",
"date-fns": "^2.29.3",
"date-fns": "^3.6.0",
"decimal.js": "^10.4.3",
"dom-confetti": "^0.2.2",
"ethers": "^5.7.2",
"filesize": "^10.0.7",
"filesize": "^10.1.2",
"formik": "^2.4.2",
"gray-matter": "^4.0.3",
"is-ipfs": "^8.0.1",
"is-ipfs": "^8.0.4",
"is-url-superb": "^6.1.0",
"js-cookie": "^3.0.1",
"match-sorter": "^6.3.1",
"js-cookie": "^3.0.5",
"match-sorter": "^6.3.4",
"myetherwallet-blockies": "^0.1.1",
"next": "^14.2.3",
"npm": "^9.6.5",
"posthog-js": "^1.68.5",
"query-string": "^8.1.0",
"npm": "^10.8.0",
"posthog-js": "^1.135.2",
"query-string": "^9.0.0",
"react": "^18.2.0",
"react-clipboard.js": "^2.0.16",
"react-data-table-component": "^7.5.3",
"react-data-table-component": "^7.6.2",
"react-dom": "^18.2.0",
"react-dotdotdot": "^1.3.1",
"react-modal": "^3.16.1",
"react-paginate": "^8.1.4",
"react-select": "^5.7.0",
"react-spring": "^9.7.1",
"react-string-replace": "^1.1.0",
"react-tabs": "^6.0.0",
"react-toastify": "^9.1.2",
"react-paginate": "^8.2.0",
"react-select": "^5.8.0",
"react-spring": "^9.7.3",
"react-string-replace": "^1.1.1",
"react-tabs": "6.0.0",
"react-toastify": "^10.0.5",
"remark": "^15.0.1",
"remark-gfm": "^4.0.0",
"remark-html": "^16.0.1",
"remove-markdown": "^0.5.0",
"slugify": "^1.6.5",
"slugify": "^1.6.6",
"swr": "^1.3.0",
"urql": "^3.0.3",
"wagmi": "^0.12.12",
"urql": "^3.0.4",
"wagmi": "^0.12.19",
"yup": "^0.32.11"
},
"devDependencies": {
"@storybook/addon-essentials": "^6.5.13",
"@storybook/builder-webpack5": "^6.5.13",
"@storybook/manager-webpack5": "^6.5.13",
"@storybook/react": "^6.5.13",
"@storybook/addon-essentials": "^6.5.16",
"@storybook/builder-webpack5": "^6.5.16",
"@storybook/manager-webpack5": "^6.5.16",
"@storybook/react": "^6.5.16",
"@svgr/webpack": "^6.5.1",
"@testing-library/jest-dom": "^5.16.5",
"@testing-library/jest-dom": "^5.17.0",
"@testing-library/react": "^13.4.0",
"@types/jest": "^29.2.5",
"@types/js-cookie": "^3.0.2",
"@types/loadable__component": "^5.13.4",
"@types/node": "^18.14.2",
"@types/react": "^18.0.25",
"@types/react-dom": "^18.2.1",
"@types/react-modal": "^3.16.2",
"@types/react-paginate": "^7.1.1",
"@types/remove-markdown": "^0.3.2",
"@typescript-eslint/eslint-plugin": "^5.43.0",
"@typescript-eslint/parser": "^5.57.0",
"@uiw/codemirror-themes": "^4.21.12",
"@types/jest": "^29.5.12",
"@types/js-cookie": "^3.0.6",
"@types/loadable__component": "^5.13.9",
"@types/node": "^18.19.33",
"@types/react": "^18.3.3",
"@types/react-dom": "^18.3.0",
"@types/react-modal": "^3.16.3",
"@types/react-paginate": "^7.1.4",
"@types/remove-markdown": "^0.3.4",
"@typescript-eslint/eslint-plugin": "^5.62.0",
"@typescript-eslint/parser": "^5.62.0",
"@uiw/codemirror-themes": "^4.22.1",
"apollo": "^2.34.0",
"cross-env": "^7.0.3",
"eslint": "^8.41.0",
"eslint": "^8.57.0",
"eslint-config-oceanprotocol": "^2.0.4",
"eslint-config-prettier": "^8.8.0",
"eslint-plugin-jest-dom": "^5.0.1",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-jest-dom": "^5.4.0",
"eslint-plugin-prettier": "^4.2.1",
"eslint-plugin-react": "^7.32.2",
"eslint-plugin-react-hooks": "^4.6.0",
"eslint-plugin-testing-library": "^5.10.0",
"eslint-plugin-react": "^7.34.1",
"eslint-plugin-react-hooks": "^4.6.2",
"eslint-plugin-testing-library": "^6.2.2",
"https-browserify": "^1.0.0",
"husky": "^8.0.2",
"jest": "^29.3.1",
"jest-environment-jsdom": "^29.3.1",
"prettier": "^2.8.4",
"husky": "^9.0.11",
"jest": "^29.7.0",
"jest-environment-jsdom": "^29.7.0",
"prettier": "^2.8.8",
"pretty-quick": "^3.1.3",
"process": "^0.11.10",
"serve": "^14.1.2",
"serve": "^14.2.3",
"stream-http": "^3.2.0",
"tsconfig-paths-webpack-plugin": "^4.1.0",
"typescript": "^4.9.3"
Expand Down
12 changes: 0 additions & 12 deletions src/@types/Compute.d.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,8 @@
import { ComputeJob } from '@oceanprotocol/lib'
import { OrdersData_orders_datatoken as OrdersDatatoken } from '../@types/subgraph/OrdersData'

// declaring into global scope to be able to use this as
// ambiant types despite the above imports
declare global {
interface ComputeJobMetaData extends ComputeJob {
assetName: string
assetDtSymbol: string
networkId: number
}

interface AlgorithmOption {
did: string
name: string
Expand All @@ -19,15 +12,10 @@
id: string
serviceIndex: number
datatoken: OrdersDatatoken
tx: any

Check warning on line 15 in src/@types/Compute.d.ts

View workflow job for this annotation

GitHub Actions / test (ubuntu-latest, 18)

Unexpected any. Specify a different type

Check warning on line 15 in src/@types/Compute.d.ts

View workflow job for this annotation

GitHub Actions / test (macos-latest, 18)

Unexpected any. Specify a different type
createdTimestamp: number
}

interface ComputeResults {
computeJobs: ComputeJobMetaData[]
isLoaded: boolean
}

interface totalPriceMap {
value: string
symbol: string
Expand Down
6 changes: 2 additions & 4 deletions src/@types/aquarius/SearchQuery.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,11 @@ export enum SortTermOptions {
// and gets imported in components.

export enum FilterByTypeOptions {
Data = 'dataset',
Algorithm = 'algorithm'
Data = 'dataset'
}

export enum FilterByAccessOptions {
Download = 'access',
Compute = 'compute'
Download = 'access'
}

declare global {
Expand Down
2 changes: 2 additions & 0 deletions src/@utils/aquarius/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ const defaultBaseQueryReturn = {
bool: {
filter: [
{ term: { _index: 'aquarius' } },
{ term: { 'services.type': 'access' } },
{ term: { 'metadata.type': 'dataset' } },
{ terms: { chainId: [1, 3] } },
{ term: { 'purgatory.state': false } },
{ bool: { must_not: [{ term: { 'nft.state': 5 } }] } }
Expand Down
52 changes: 9 additions & 43 deletions src/@utils/aquarius/index.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
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 {
SortDirectionOptions,
SortTermOptions
} from '../../@types/aquarius/SearchQuery'
import { transformAssetToAssetSelection } from '../assetConvertor'

export interface UserSales {
id: string
Expand Down Expand Up @@ -42,7 +40,11 @@ export function getFilterTerm(
export function generateBaseQuery(
baseQueryParams: BaseQueryParams
): SearchQuery {
const filters: unknown[] = [getFilterTerm('_index', 'aquarius')]
const filters: unknown[] = [
getFilterTerm('_index', 'aquarius'),
getFilterTerm('services.type', 'access'),
getFilterTerm('metadata.type', 'dataset')
]
baseQueryParams.filters && filters.push(...baseQueryParams.filters)
baseQueryParams.chainIds &&
filters.push(getFilterTerm('chainId', baseQueryParams.chainIds))
Expand Down Expand Up @@ -206,41 +208,6 @@ export async function getAssetsFromDids(
}
}

export async function getAlgorithmDatasetsForCompute(
algorithmId: string,
datasetProviderUri: string,
datasetChainId?: number,
cancelToken?: CancelToken
): Promise<AssetSelectionAsset[]> {
const baseQueryParams = {
chainIds: [datasetChainId],
nestedQuery: {
must: {
match: {
'services.compute.publisherTrustedAlgorithms.did': {
query: algorithmId
}
}
}
},
sortOptions: {
sortBy: SortTermOptions.Created,
sortDirection: SortDirectionOptions.Descending
}
} as BaseQueryParams

const query = generateBaseQuery(baseQueryParams)
const computeDatasets = await queryMetadata(query, cancelToken)
if (computeDatasets?.totalResults === 0) return []

const datasets = await transformAssetToAssetSelection(
datasetProviderUri,
computeDatasets.results,
[]
)
return datasets
}

export async function getPublishedAssets(
accountId: string,
chainIds: number[],
Expand All @@ -256,9 +223,8 @@ export async function getPublishedAssets(

filters.push(getFilterTerm('nft.state', [0, 4, 5]))
filters.push(getFilterTerm('nft.owner', accountId.toLowerCase()))
accesType !== undefined &&
filters.push(getFilterTerm('services.type', accesType))
type !== undefined && filters.push(getFilterTerm('metadata.type', type))
// filters.push(getFilterTerm('services.type', 'access'))
// filters.push(getFilterTerm('metadata.type', 'dataset'))

const baseQueryParams = {
chainIds,
Expand Down Expand Up @@ -306,8 +272,8 @@ async function getTopPublishers(
const filters: FilterTerm[] = []

accesType !== undefined &&
filters.push(getFilterTerm('services.type', accesType))
type !== undefined && filters.push(getFilterTerm('metadata.type', type))
filters.push(getFilterTerm('services.type', 'access'))
type !== undefined && filters.push(getFilterTerm('metadata.type', 'dataset'))

const baseQueryParams = {
chainIds,
Expand Down
3 changes: 1 addition & 2 deletions src/@utils/assetConvertor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@ export async function transformAssetToAssetSelection(
const algorithmList: AssetSelectionAsset[] = []

for (const asset of assets) {
const algoService =
getServiceByName(asset, 'compute') || getServiceByName(asset, 'access')
const algoService = getServiceByName(asset, 'access')

if (
asset?.stats?.price?.value >= 0 &&
Expand Down
Loading
Loading