Skip to content
This repository was archived by the owner on Oct 19, 2023. It is now read-only.
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
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion catalog/package.json
Original file line number Diff line number Diff line change
@@ -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": {
Expand Down
40 changes: 19 additions & 21 deletions catalog/src/catalog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -125,7 +126,7 @@ export const NeverminedProvider = ({ children, config, verbose }: NeverminedProv
const [{ sdk }, dispatch] = useReducer(neverminedReducer, initialState)
const [isLoading, setIsLoading] = useState<boolean>(true)
// eslint-disable-next-line
const [error, setError] = useState<any>(undefined)
const [sdkError, setSdkError] = useState<any>(undefined)

useEffect(() => {
const loadNevermined = async (): Promise<void> => {
Expand All @@ -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()
Expand Down Expand Up @@ -216,14 +217,14 @@ export const NeverminedProvider = ({ children, config, verbose }: NeverminedProv
}
},

getPublishedSubscriptions: async (searchOptions?: SearchOptions): Promise<DDO[]> => {
getPublishedSubscriptions: async (searchOptions?: SearchOptions): Promise<QueryResult> => {
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
}
},

Expand All @@ -250,14 +251,14 @@ export const NeverminedProvider = ({ children, config, verbose }: NeverminedProv
}
},

getPurchasedSubscriptions: async (searchOptions?: SearchOptions): Promise<DDO[]> => {
getPurchasedSubscriptions: async (searchOptions?: SearchOptions): Promise<QueryResult> => {
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
}
},

Expand All @@ -284,23 +285,23 @@ export const NeverminedProvider = ({ children, config, verbose }: NeverminedProv
}
},

getAssociatedServices: async (did: string, searchOptions?: SearchOptions): Promise<DDO[]> => {
getAssociatedServices: async (did: string, searchOptions?: SearchOptions): Promise<QueryResult> => {
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<DDO[]> => {
getAssociatedDatasets: async (did: string, searchOptions?: SearchOptions): Promise<QueryResult> => {
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
}
},

Expand Down Expand Up @@ -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) {
Expand All @@ -727,7 +725,7 @@ export const NeverminedProvider = ({ children, config, verbose }: NeverminedProv
const IState = {
sdk,
isLoadingSDK: isLoading,
sdkError: error,
sdkError,
subscribe,
assets,
account,
Expand Down
15 changes: 8 additions & 7 deletions catalog/src/types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import {
CreateProgressStep,
RoyaltyKind,
OrderProgressStep,
MetaDataExternalResource,
} from '@nevermined-io/sdk'
import { CryptoConfig } from '@nevermined-io/sdk-dtp'

Expand Down Expand Up @@ -422,21 +423,21 @@ export interface AccountModule {
* @param searchOptions options for customize result
* @returns published subscriptions
*/
getPublishedSubscriptions: (searchOptions?: SearchOptions) => Promise<DDO[]>
getPublishedSubscriptions: (searchOptions?: SearchOptions) => Promise<QueryResult>
/**
* 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<DDO[]>
getAssociatedServices: (did: string, searchOptions?: SearchOptions) => Promise<QueryResult>
/**
* 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<DDO[]>
getAssociatedDatasets: (did: string, searchOptions?: SearchOptions) => Promise<QueryResult>
/**
* Get all the published subscriptions and services associated from the wallet address passed
* @param searchOptions options for customize result
Expand All @@ -458,7 +459,7 @@ export interface AccountModule {
* @param searchOptions options for customize result
* @returns purchased subscriptions
*/
getPurchasedSubscriptions: (searchOptions?: SearchOptions) => Promise<DDO[]>
getPurchasedSubscriptions: (searchOptions?: SearchOptions) => Promise<QueryResult>
/**
* Get all the purchased subscriptions and services associated from the wallet address passed
* @param searchOptions options for customize result
Expand Down Expand Up @@ -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 */
Expand Down Expand Up @@ -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
}
12 changes: 10 additions & 2 deletions catalog/src/utils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import {
ERCType,
MarketplaceAPIToken,
NeverminedOptions,
QueryResult,
SearchOptions,
SubscribablePromise,
} from '../types'
Expand Down Expand Up @@ -191,7 +192,7 @@ export const getSubscriptionsAndServices = async (

return {
subscription: ddo,
services: query.results,
services: query,
}
}),
)
Expand All @@ -214,7 +215,7 @@ export const getSubscriptionsAndDatasets = async (

return {
subscription: ddo,
datasets: query.results,
datasets: query,
}
}),
)
Expand All @@ -241,3 +242,10 @@ export const getNewSdkInstance = async (
): Promise<Nevermined> => {
return Nevermined.getInstance({ ...config, marketplaceAuthToken: tokenData.token })
}

export const emptyQueryResult: QueryResult = {
results: [],
totalResults: {},
page: 0,
totalPages: 0,
}
20 changes: 12 additions & 8 deletions catalog/unit-tests/catalog/catalog.account.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down Expand Up @@ -601,7 +601,7 @@ describe('Nevermined account', () => {
await waitFor(() => {
expect(result.current).toStrictEqual([{
subscription: ddo,
services: [ddo2, ddo3]
services: { results: [ddo2, ddo3] }
}])
})
})
Expand All @@ -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)
}
Expand Down Expand Up @@ -676,7 +676,7 @@ describe('Nevermined account', () => {
await waitFor(() => {
expect(result.current).toStrictEqual([{
subscription: ddo,
services: [ddo2, ddo3]
services: {results: [ddo2, ddo3]}
}])
})
})
Expand All @@ -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)
}
Expand Down Expand Up @@ -751,7 +751,9 @@ describe('Nevermined account', () => {
await waitFor(() => {
expect(result.current).toStrictEqual([{
subscription: ddo,
datasets: [ddo4, ddo5]
datasets: {
results: [ddo4, ddo5]
}
}])
})
})
Expand Down Expand Up @@ -790,7 +792,9 @@ describe('Nevermined account', () => {
await waitFor(() => {
expect(result.current).toStrictEqual([{
subscription: ddo,
datasets: [ddo4, ddo5]
datasets: {
results: [ddo4, ddo5]
}
}])
})
})
Expand All @@ -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)
}
Expand Down
4 changes: 2 additions & 2 deletions catalog/unit-tests/mockups.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1027,7 +1027,7 @@ export const nevermined = {
}),
create: async () => ddo,
createWithRoyalties: async () => ddo,
transferForDelegate: async () => true,
claim: async () => true,
},
nfts721: {
ownerOf: async () => walletAddress,
Expand Down Expand Up @@ -1066,7 +1066,7 @@ export const nevermined = {
}),
create: async () => ddo,
createWithRoyalties: async () => ddo,
transferForDelegate: async () => true,
claim: async () => true,
},
search: {
subscriptionsCreated: () => ({ results: [ddo] }),
Expand Down
2 changes: 1 addition & 1 deletion providers/package.json
Original file line number Diff line number Diff line change
@@ -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": {
Expand Down