diff --git a/src/@context/Asset.tsx b/src/@context/Asset.tsx index d492cfa6f..ba1eb5d28 100644 --- a/src/@context/Asset.tsx +++ b/src/@context/Asset.tsx @@ -111,7 +111,8 @@ function AssetProvider({ setDDO(ddo) setTitle(ddo.metadata.name) setOwner(ddo.nft.owner) - setIsInPurgatory(ddo.purgatory.state === true) + // TODO: restore asset purgatory once Aquarius supports it, ref #953 + // setIsInPurgatory(ddo.purgatory.state === true) await setPurgatory(ddo.id) } init() diff --git a/src/@types/aquarius/SearchQuery.ts b/src/@types/aquarius/SearchQuery.ts index 2bfa29459..e8b062ee7 100644 --- a/src/@types/aquarius/SearchQuery.ts +++ b/src/@types/aquarius/SearchQuery.ts @@ -4,7 +4,7 @@ export enum SortDirectionOptions { } export enum SortTermOptions { - Created = 'created', + Created = 'metadata.created', Relevance = '_score' } diff --git a/src/@utils/aquarius.ts b/src/@utils/aquarius.ts index 2ed876859..7c73bdf93 100644 --- a/src/@utils/aquarius.ts +++ b/src/@utils/aquarius.ts @@ -48,7 +48,7 @@ export function generateBaseQuery( getFilterTerm('_index', 'aquarius'), ...(baseQueryParams.ignorePurgatory ? [] - : [getFilterTerm('isInPurgatory', 'false')]) + : [getFilterTerm('stats.isInPurgatory', 'false')]) ] } } @@ -95,7 +95,7 @@ export async function queryMetadata( ): Promise { try { const response: AxiosResponse = await axios.post( - `${metadataCacheUri}/api/v1/aquarius/assets/query`, + `${metadataCacheUri}/api/aquarius/assets/query`, { ...query }, { cancelToken } ) @@ -116,7 +116,7 @@ export async function retrieveDDO( ): Promise { try { const response: AxiosResponse = await axios.get( - `${metadataCacheUri}/api/v1/aquarius/assets/ddo/${did}`, + `${metadataCacheUri}/api/aquarius/assets/ddo/${did}`, { cancelToken } ) if (!response || response.status !== 200 || !response.data) return @@ -138,7 +138,7 @@ export async function getAssetsNames( ): Promise> { try { const response: AxiosResponse> = await axios.post( - `${metadataCacheUri}/api/v1/aquarius/assets/names`, + `${metadataCacheUri}/api/aquarius/assets/names`, { didList }, { cancelToken } ) @@ -297,11 +297,10 @@ export async function getPublishedAssets( const filters: FilterTerm[] = [] - filters.push(getFilterTerm('publicKey.owner', accountId.toLowerCase())) + filters.push(getFilterTerm('nft.owner', accountId.toLowerCase())) accesType !== undefined && - filters.push(getFilterTerm('service.type', accesType)) - type !== undefined && - filters.push(getFilterTerm('service.attributes.main.type', type)) + filters.push(getFilterTerm('services.type', accesType)) + type !== undefined && filters.push(getFilterTerm('metadata.type', type)) const baseQueryParams = { chainIds, diff --git a/src/components/Asset/AssetActions/index.tsx b/src/components/Asset/AssetActions/index.tsx index d4e3f7d38..6dd4bdeb2 100644 --- a/src/components/Asset/AssetActions/index.tsx +++ b/src/components/Asset/AssetActions/index.tsx @@ -26,7 +26,7 @@ export default function AssetActions({ }): ReactElement { const { accountId, balance } = useWeb3() const { isAssetNetwork } = useAsset() - const { values } = useFormikContext() + const formikState = useFormikContext() const [isBalanceSufficient, setIsBalanceSufficient] = useState() const [dtBalance, setDtBalance] = useState() @@ -64,9 +64,10 @@ export default function AssetActions({ async function initFileInfo() { setFileIsLoading(true) - const asset = values?.services?.[0].files?.[0].url || ddo.id + const asset = formikState?.values?.services?.[0].files?.[0].url || ddo.id const providerUrl = - values?.services[0].providerUrl.url || oceanConfig.providerUri + formikState?.values?.services[0].providerUrl.url || + oceanConfig.providerUri try { const fileInfoResponse = await getFileInfo(asset, providerUrl) @@ -77,7 +78,7 @@ export default function AssetActions({ } } initFileInfo() - }, [ddo, isMounted, newCancelToken, values?.services]) + }, [ddo, isMounted, newCancelToken, formikState?.values?.services]) // Get and set user DT balance useEffect(() => { diff --git a/src/components/Home/index.tsx b/src/components/Home/index.tsx index 96b592d75..9c87aacd2 100644 --- a/src/components/Home/index.tsx +++ b/src/components/Home/index.tsx @@ -114,12 +114,13 @@ export default function HomePage(): ReactElement { const baseParams = { chainIds: chainIds, - esPaginationOptions: { size: 9 }, + esPaginationOptions: { + size: 9 + }, sortOptions: { sortBy: SortTermOptions.Created } as SortOptions } as BaseQueryParams - setQueryLatest(generateBaseQuery(baseParams)) }, [chainIds]) @@ -143,7 +144,10 @@ export default function HomePage(): ReactElement { title="Recently Published" query={queryLatest} action={ - } diff --git a/src/components/Search/index.tsx b/src/components/Search/index.tsx index 2e798bdf6..1c93b0aaf 100644 --- a/src/components/Search/index.tsx +++ b/src/components/Search/index.tsx @@ -41,7 +41,12 @@ export default function SearchPage({ (page: number) => { const { pathname, query } = router const newUrl = updateQueryStringParameter( - pathname + query, + pathname + + '?' + + JSON.stringify(query) + .replace(/"|{|}/g, '') + .replace(/:/g, '=') + .replace(/,/g, '&'), 'page', `${page}` ) diff --git a/src/components/Search/utils.ts b/src/components/Search/utils.ts index 72c5d560f..9ed0fa850 100644 --- a/src/components/Search/utils.ts +++ b/src/components/Search/utils.ts @@ -47,14 +47,14 @@ export function getSearchQuery( const emptySearchTerm = text === undefined || text === '' let searchTerm = owner - ? `(publicKey.owner:${owner})` + ? `(nft.owner:${owner})` : tags ? // eslint-disable-next-line no-useless-escape - `(service.attributes.additionalInformation.tags:\"${tags}\")` - : categories - ? // eslint-disable-next-line no-useless-escape - `(service.attributes.additionalInformation.categories:\"${categories}\")` - : text || '' + `(metadata.tags:\"${tags}\")` + : // : categories + // ? // eslint-disable-next-line no-useless-escape + // `(service.attributes.additionalInformation.categories:\"${categories}\")` + text || '' searchTerm = searchTerm.trim() const modifiedSearchTerm = searchTerm.split(' ').join(' OR ').trim() @@ -68,14 +68,14 @@ export function getSearchQuery( : '**' const searchFields = [ 'id', - 'publicKey.owner', - 'dataToken', - 'dataTokenInfo.name', - 'dataTokenInfo.symbol', - 'service.attributes.main.name^10', - 'service.attributes.main.author', - 'service.attributes.additionalInformation.description', - 'service.attributes.additionalInformation.tags' + 'nft.owner', + 'datatokens.address', + 'datatokens.name', + 'datatokens.symbol', + 'metadata.name^10', + 'metadata.author', + 'metadata.description', + 'metadata.tags' ] const nestedQuery = { @@ -123,9 +123,9 @@ export function getSearchQuery( const filters: FilterTerm[] = [] accessType !== undefined && - filters.push(getFilterTerm('service.type', accessType)) + filters.push(getFilterTerm('nft.type', accessType)) serviceType !== undefined && - filters.push(getFilterTerm('service.attributes.main.type', serviceType)) + filters.push(getFilterTerm('metadata.type', serviceType)) const baseQueryParams = { chainIds, @@ -139,7 +139,6 @@ export function getSearchQuery( } as BaseQueryParams const query = generateBaseQuery(baseQueryParams) - return query }