diff --git a/CHANGELOG.md b/CHANGELOG.md index fdf107f..482278a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,14 @@ All notable changes to this project will be documented in this file. Dates are d Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog). +#### [v1.4.6](https://github.com/nevermined-io/components-catalog/compare/v1.4.5...v1.4.6) + +> 17 May 2023 + +- Fix/fix price type [`#296`](https://github.com/nevermined-io/components-catalog/pull/296) +- fix price type [`4fa17ef`](https://github.com/nevermined-io/components-catalog/commit/4fa17ef4c4386fd67d63a7dfc6f4cd175d29d297) +- Adding v1.4.5 Changelog updates [`6bc7b49`](https://github.com/nevermined-io/components-catalog/commit/6bc7b492fb50363cb7bdd0627bff6dbd6fca6562) + #### [v1.4.5](https://github.com/nevermined-io/components-catalog/compare/v1.4.4...v1.4.5) > 17 May 2023 diff --git a/catalog/package.json b/catalog/package.json index 806ca7c..69e7678 100644 --- a/catalog/package.json +++ b/catalog/package.json @@ -1,6 +1,6 @@ { "name": "@nevermined-io/catalog", - "version": "1.4.6", + "version": "1.5.0", "main": "./dist/index.js", "types": "./dist/index.d.ts", "dependencies": { diff --git a/catalog/src/catalog.tsx b/catalog/src/catalog.tsx index fc12899..fe6d1f0 100644 --- a/catalog/src/catalog.tsx +++ b/catalog/src/catalog.tsx @@ -36,6 +36,7 @@ import { getSubscriptionsAndServices, getSubscriptionsAndDatasets, executeWithProgressEvent, + emptyQueryResult, } from './utils' import { _getCryptoConfig, _getDTPInstance, _grantAccess } from './utils/dtp' import { getAddressTokenSigner, isTokenValid, newMarketplaceApiToken } from './utils/marketplace_token' @@ -125,7 +126,7 @@ export const NeverminedProvider = ({ children, config, verbose }: NeverminedProv const [{ sdk }, dispatch] = useReducer(neverminedReducer, initialState) const [isLoading, setIsLoading] = useState(true) // eslint-disable-next-line - const [error, setError] = useState(undefined) + const [sdkError, setSdkError] = useState(undefined) useEffect(() => { const loadNevermined = async (): Promise => { @@ -138,7 +139,7 @@ export const NeverminedProvider = ({ children, config, verbose }: NeverminedProv if (success) { dispatch({ type: 'SET_SDK', payload: { sdk: data } }) } - setError(error) + setSdkError(error) setIsLoading(false) } loadNevermined() @@ -216,14 +217,14 @@ export const NeverminedProvider = ({ children, config, verbose }: NeverminedProv } }, - getPublishedSubscriptions: async (searchOptions?: SearchOptions): Promise => { + getPublishedSubscriptions: async (searchOptions?: SearchOptions): Promise => { try { const account = await getCurrentAccount(sdk) const query = await sdk.search.subscriptionsCreated(account, searchOptions?.offset, searchOptions?.page, searchOptions?.sort, searchOptions?.appId) - return query.results - } catch { + return query + } catch (error) { verbose && Logger.error(error) - return [] + return emptyQueryResult } }, @@ -250,14 +251,14 @@ export const NeverminedProvider = ({ children, config, verbose }: NeverminedProv } }, - getPurchasedSubscriptions: async (searchOptions?: SearchOptions): Promise => { + getPurchasedSubscriptions: async (searchOptions?: SearchOptions): Promise => { try { const account = await getCurrentAccount(sdk) const query = await sdk.search.subscriptionsPurchased(account, searchOptions?.offset, searchOptions?.page, searchOptions?.sort, searchOptions?.appId) - return query.results + return query } catch (error) { verbose && Logger.error(error) - return [] + return emptyQueryResult } }, @@ -284,23 +285,23 @@ export const NeverminedProvider = ({ children, config, verbose }: NeverminedProv } }, - getAssociatedServices: async (did: string, searchOptions?: SearchOptions): Promise => { + getAssociatedServices: async (did: string, searchOptions?: SearchOptions): Promise => { try { const query = await sdk.search.servicesBySubscription(did, searchOptions?.offset, searchOptions?.page, searchOptions?.sort, searchOptions?.appId) - return query.results + return query } catch (error) { verbose && Logger.error(error) - return [] + return emptyQueryResult } }, - getAssociatedDatasets: async (did: string, searchOptions?: SearchOptions): Promise => { + getAssociatedDatasets: async (did: string, searchOptions?: SearchOptions): Promise => { try { const query = await sdk.search.datasetsBySubscription(did, searchOptions?.offset, searchOptions?.page, searchOptions?.sort, searchOptions?.appId) - return query.results + return query } catch (error) { verbose && Logger.error(error) - return [] + return emptyQueryResult } }, @@ -695,19 +696,16 @@ export const NeverminedProvider = ({ children, config, verbose }: NeverminedProv ) transferResult = ercType === 721 - ? await sdk.nfts721.transferForDelegate( + ? await sdk.nfts721.claim( agreementId, nftHolder, buyer.getId(), - nftAmount, - ercType ) - : await sdk.nfts1155.transferForDelegate( + : await sdk.nfts1155.claim( agreementId, nftHolder, buyer.getId(), nftAmount, - ercType ) } } catch (error) { @@ -727,7 +725,7 @@ export const NeverminedProvider = ({ children, config, verbose }: NeverminedProv const IState = { sdk, isLoadingSDK: isLoading, - sdkError: error, + sdkError, subscribe, assets, account, diff --git a/catalog/src/types/index.ts b/catalog/src/types/index.ts index 1f56985..5bc953c 100644 --- a/catalog/src/types/index.ts +++ b/catalog/src/types/index.ts @@ -18,6 +18,7 @@ import { CreateProgressStep, RoyaltyKind, OrderProgressStep, + MetaDataExternalResource, } from '@nevermined-io/sdk' import { CryptoConfig } from '@nevermined-io/sdk-dtp' @@ -422,21 +423,21 @@ export interface AccountModule { * @param searchOptions options for customize result * @returns published subscriptions */ - getPublishedSubscriptions: (searchOptions?: SearchOptions) => Promise + getPublishedSubscriptions: (searchOptions?: SearchOptions) => Promise /** * Get all the services associated a subscription * @param address the subscription address * @param searchOptions options for customize result * @returns associated services to subscriptions */ - getAssociatedServices: (did: string, searchOptions?: SearchOptions) => Promise + getAssociatedServices: (did: string, searchOptions?: SearchOptions) => Promise /** * Get all the datasets associated to a subscription * @param address the subscription address * @param searchOptions options for customize result * @returns associated datasets to subscriptions */ - getAssociatedDatasets: (did: string, searchOptions?: SearchOptions) => Promise + getAssociatedDatasets: (did: string, searchOptions?: SearchOptions) => Promise /** * Get all the published subscriptions and services associated from the wallet address passed * @param searchOptions options for customize result @@ -458,7 +459,7 @@ export interface AccountModule { * @param searchOptions options for customize result * @returns purchased subscriptions */ - getPurchasedSubscriptions: (searchOptions?: SearchOptions) => Promise + getPurchasedSubscriptions: (searchOptions?: SearchOptions) => Promise /** * Get all the purchased subscriptions and services associated from the wallet address passed * @param searchOptions options for customize result @@ -770,7 +771,7 @@ export interface AssetPublishParams { /** Price of the asset */ price: string /** Files to download after buy the asset */ - assetFiles: AssetFile[] + assetFiles: MetaDataExternalResource[] } /** Metadata of the file */ @@ -988,10 +989,10 @@ export interface Credentials { export interface SubscriptionsAndServicesDDOs { subscription: DDO - services: DDO[] + services: QueryResult } export interface SubscriptionsAndDatasetsDDOs { subscription: DDO - datasets: DDO[] + datasets: QueryResult } diff --git a/catalog/src/utils/index.ts b/catalog/src/utils/index.ts index c90d326..c31ae81 100644 --- a/catalog/src/utils/index.ts +++ b/catalog/src/utils/index.ts @@ -4,6 +4,7 @@ import { ERCType, MarketplaceAPIToken, NeverminedOptions, + QueryResult, SearchOptions, SubscribablePromise, } from '../types' @@ -191,7 +192,7 @@ export const getSubscriptionsAndServices = async ( return { subscription: ddo, - services: query.results, + services: query, } }), ) @@ -214,7 +215,7 @@ export const getSubscriptionsAndDatasets = async ( return { subscription: ddo, - datasets: query.results, + datasets: query, } }), ) @@ -241,3 +242,10 @@ export const getNewSdkInstance = async ( ): Promise => { return Nevermined.getInstance({ ...config, marketplaceAuthToken: tokenData.token }) } + +export const emptyQueryResult: QueryResult = { + results: [], + totalResults: {}, + page: 0, + totalPages: 0, +} diff --git a/catalog/unit-tests/catalog/catalog.account.spec.tsx b/catalog/unit-tests/catalog/catalog.account.spec.tsx index 5c93783..d833ad2 100644 --- a/catalog/unit-tests/catalog/catalog.account.spec.tsx +++ b/catalog/unit-tests/catalog/catalog.account.spec.tsx @@ -548,7 +548,7 @@ describe('Nevermined account', () => { try { const result = await account.getPublishedSubscriptions() - setSubscriptions([...result]) + setSubscriptions([...result.results]) } catch (error: any) { console.error(error.message) } @@ -601,7 +601,7 @@ describe('Nevermined account', () => { await waitFor(() => { expect(result.current).toStrictEqual([{ subscription: ddo, - services: [ddo2, ddo3] + services: { results: [ddo2, ddo3] } }]) }) }) @@ -623,7 +623,7 @@ describe('Nevermined account', () => { try { const result = await account.getPurchasedSubscriptions() - setSubscriptions([...result]) + setSubscriptions([...result.results]) } catch (error: any) { console.error(error.message) } @@ -676,7 +676,7 @@ describe('Nevermined account', () => { await waitFor(() => { expect(result.current).toStrictEqual([{ subscription: ddo, - services: [ddo2, ddo3] + services: {results: [ddo2, ddo3]} }]) }) }) @@ -698,7 +698,7 @@ describe('Nevermined account', () => { try { const result = await account.getAssociatedServices(ddo.id) - setServices([...result]) + setServices([...result.results]) } catch (error: any) { console.error(error.message) } @@ -751,7 +751,9 @@ describe('Nevermined account', () => { await waitFor(() => { expect(result.current).toStrictEqual([{ subscription: ddo, - datasets: [ddo4, ddo5] + datasets: { + results: [ddo4, ddo5] + } }]) }) }) @@ -790,7 +792,9 @@ describe('Nevermined account', () => { await waitFor(() => { expect(result.current).toStrictEqual([{ subscription: ddo, - datasets: [ddo4, ddo5] + datasets: { + results: [ddo4, ddo5] + } }]) }) }) @@ -812,7 +816,7 @@ describe('Nevermined account', () => { try { const result = await account.getAssociatedDatasets(ddo.id) - setDatasets([...result]) + setDatasets([...result.results]) } catch (error: any) { console.error(error.message) } diff --git a/catalog/unit-tests/mockups.ts b/catalog/unit-tests/mockups.ts index 3d08d47..3dffc2a 100644 --- a/catalog/unit-tests/mockups.ts +++ b/catalog/unit-tests/mockups.ts @@ -1027,7 +1027,7 @@ export const nevermined = { }), create: async () => ddo, createWithRoyalties: async () => ddo, - transferForDelegate: async () => true, + claim: async () => true, }, nfts721: { ownerOf: async () => walletAddress, @@ -1066,7 +1066,7 @@ export const nevermined = { }), create: async () => ddo, createWithRoyalties: async () => ddo, - transferForDelegate: async () => true, + claim: async () => true, }, search: { subscriptionsCreated: () => ({ results: [ddo] }), diff --git a/providers/package.json b/providers/package.json index fbcd43a..74139cc 100644 --- a/providers/package.json +++ b/providers/package.json @@ -1,7 +1,7 @@ { "name": "@nevermined-io/providers", "private": false, - "version": "1.4.6", + "version": "1.5.0", "main": "./dist/index.js", "types": "./dist/index.d.ts", "dependencies": {