From 8265ed0d3236f1d0a5a65bb6af640686da48138d Mon Sep 17 00:00:00 2001 From: Ruggero Cino Date: Wed, 24 Jul 2024 12:01:53 +0200 Subject: [PATCH 1/3] feat: Add includeMetadata parameter to getPlugin and getPlugins functions --- modules/client/CHANGELOG.md | 5 +++++ modules/client/package.json | 2 +- modules/client/src/internal/client/methods.ts | 21 ++++++++++++++++--- modules/client/src/types.ts | 1 + 4 files changed, 25 insertions(+), 4 deletions(-) diff --git a/modules/client/CHANGELOG.md b/modules/client/CHANGELOG.md index 46919a16..f1d58af6 100644 --- a/modules/client/CHANGELOG.md +++ b/modules/client/CHANGELOG.md @@ -19,6 +19,11 @@ TEMPLATE: ## [UPCOMING] +## [1.26.1] + +### Changed +- Add `includeMetadata` optional parameter to `getPlugin` and `getPlugins` functions which defaults to `true`. + ## [1.25.1] ### Fixed diff --git a/modules/client/package.json b/modules/client/package.json index 81576c5d..c6852172 100644 --- a/modules/client/package.json +++ b/modules/client/package.json @@ -1,7 +1,7 @@ { "name": "@aragon/sdk-client", "author": "Aragon Association", - "version": "1.25.1", + "version": "1.26.0", "license": "MIT", "main": "dist/index.js", "module": "dist/sdk-client.esm.js", diff --git a/modules/client/src/internal/client/methods.ts b/modules/client/src/internal/client/methods.ts index b67bc008..11bceeb9 100644 --- a/modules/client/src/internal/client/methods.ts +++ b/modules/client/src/internal/client/methods.ts @@ -966,7 +966,16 @@ export class ClientMethods extends ClientCore implements IClientMethods { private async getPluginRepo( pluginRepo: SubgraphPluginRepo, + inlcudeMetadata?: boolean, ): Promise { + if (!inlcudeMetadata) { + return toPluginRepo( + pluginRepo, + EMPTY_RELEASE_METADATA_LINK, + EMPTY_BUILD_METADATA_LINK + ); + } + let releaseMetadata: PluginRepoReleaseMetadata; // releases are ordered son the index 0 will be the latest const releaseIpfsUri = pluginRepo?.releases[0]?.metadata; @@ -1006,6 +1015,7 @@ export class ClientMethods extends ClientCore implements IClientMethods { * - direction = SortDirection.ASC * - sortBy = PluginSortBy.SUBDOMAIN * - subdomain + * @param {boolean} [includeMetadata=true] * @return {(Promise)} * @memberof ClientMethods */ @@ -1015,6 +1025,7 @@ export class ClientMethods extends ClientCore implements IClientMethods { direction = SortDirection.ASC, sortBy = PluginSortBy.SUBDOMAIN, subdomain, + includeMetadata = true, }: PluginQueryParams = {}): Promise { await PluginQuerySchema.strict().validate({ limit, @@ -1046,7 +1057,7 @@ export class ClientMethods extends ClientCore implements IClientMethods { return Promise.all( pluginRepos.map( (pluginRepo: SubgraphPluginRepoListItem) => { - return this.getPluginRepo(pluginRepo); + return this.getPluginRepo(pluginRepo, includeMetadata); }, ), ); @@ -1055,10 +1066,14 @@ export class ClientMethods extends ClientCore implements IClientMethods { * Get plugin details given an address, release and build * * @param {string} pluginAddress + * @param {boolean} [includeMetadata=true] * @return {Promise} * @memberof ClientMethods */ - public async getPlugin(pluginAddress: string): Promise { + public async getPlugin( + pluginAddress: string, + includeMetadata: boolean = true + ): Promise { await AddressOrEnsSchema.strict().validate(pluginAddress); const name = "plugin version"; const query = QueryPlugin; @@ -1069,7 +1084,7 @@ export class ClientMethods extends ClientCore implements IClientMethods { name, }); // get release metadata - return this.getPluginRepo(pluginRepo); + return this.getPluginRepo(pluginRepo, includeMetadata); } /** * Returns the protocol version of a contract diff --git a/modules/client/src/types.ts b/modules/client/src/types.ts index 1f09a5db..ad8e834e 100644 --- a/modules/client/src/types.ts +++ b/modules/client/src/types.ts @@ -79,6 +79,7 @@ export enum PluginSortBy { export type PluginQueryParams = Pagination & { sortBy?: PluginSortBy; subdomain?: string; + includeMetadata?: boolean; }; /* Plugin repos */ From 441220bdb365ede4a18171e7f1f91fb33e7f6e94 Mon Sep 17 00:00:00 2001 From: Ruggero Cino Date: Wed, 24 Jul 2024 12:07:05 +0200 Subject: [PATCH 2/3] Update interfaces.ts --- modules/client/src/internal/interfaces.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/client/src/internal/interfaces.ts b/modules/client/src/internal/interfaces.ts index fb994324..2c018cbe 100644 --- a/modules/client/src/internal/interfaces.ts +++ b/modules/client/src/internal/interfaces.ts @@ -78,9 +78,9 @@ export interface IClientMethods { /** Retrieves metadata for many daos */ getDaos: (params: DaoQueryParams) => Promise; /** retrieves the plugin details given an address, release and build */ - getPlugin: (pluginAddress: string) => Promise; + getPlugin: (pluginAddress: string, includeMetadata?: boolean) => Promise; /** Retrieves the list of plugins available on the PluginRegistry */ - getPlugins: (params?: PluginQueryParams) => Promise; + getPlugins: (params?: PluginQueryParams, includeMetadata?: boolean) => Promise; /** Prepare uninstallation of a plugin */ prepareUninstallation: ( params: PrepareUninstallationParams, From 06e160867e5ca31189d4487ac12211b8e98652cf Mon Sep 17 00:00:00 2001 From: Ruggero Cino Date: Wed, 24 Jul 2024 12:09:49 +0200 Subject: [PATCH 3/3] Update CHANGELOG.md --- modules/client/CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/client/CHANGELOG.md b/modules/client/CHANGELOG.md index f1d58af6..7ff3b59e 100644 --- a/modules/client/CHANGELOG.md +++ b/modules/client/CHANGELOG.md @@ -19,7 +19,7 @@ TEMPLATE: ## [UPCOMING] -## [1.26.1] +## [1.26.0] ### Changed - Add `includeMetadata` optional parameter to `getPlugin` and `getPlugins` functions which defaults to `true`.