Skip to content

Commit

Permalink
feat: Add includeMetadata parameter to getPlugin and getPlugins funct…
Browse files Browse the repository at this point in the history
…ions
  • Loading branch information
cgero-eth committed Jul 24, 2024
1 parent e201774 commit 8265ed0
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 4 deletions.
5 changes: 5 additions & 0 deletions modules/client/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion modules/client/package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
21 changes: 18 additions & 3 deletions modules/client/src/internal/client/methods.ts
Original file line number Diff line number Diff line change
Expand Up @@ -966,7 +966,16 @@ export class ClientMethods extends ClientCore implements IClientMethods {

private async getPluginRepo(
pluginRepo: SubgraphPluginRepo,
inlcudeMetadata?: boolean,
): Promise<PluginRepo> {
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;
Expand Down Expand Up @@ -1006,6 +1015,7 @@ export class ClientMethods extends ClientCore implements IClientMethods {
* - direction = SortDirection.ASC
* - sortBy = PluginSortBy.SUBDOMAIN
* - subdomain
* @param {boolean} [includeMetadata=true]
* @return {(Promise<PluginRepo[] | null>)}
* @memberof ClientMethods
*/
Expand All @@ -1015,6 +1025,7 @@ export class ClientMethods extends ClientCore implements IClientMethods {
direction = SortDirection.ASC,
sortBy = PluginSortBy.SUBDOMAIN,
subdomain,
includeMetadata = true,
}: PluginQueryParams = {}): Promise<PluginRepoListItem[]> {
await PluginQuerySchema.strict().validate({
limit,
Expand Down Expand Up @@ -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);
},
),
);
Expand All @@ -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<PluginRepo>}
* @memberof ClientMethods
*/
public async getPlugin(pluginAddress: string): Promise<PluginRepo> {
public async getPlugin(
pluginAddress: string,
includeMetadata: boolean = true
): Promise<PluginRepo> {
await AddressOrEnsSchema.strict().validate(pluginAddress);
const name = "plugin version";
const query = QueryPlugin;
Expand All @@ -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
Expand Down
1 change: 1 addition & 0 deletions modules/client/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ export enum PluginSortBy {
export type PluginQueryParams = Pagination & {
sortBy?: PluginSortBy;
subdomain?: string;
includeMetadata?: boolean;
};

/* Plugin repos */
Expand Down

0 comments on commit 8265ed0

Please sign in to comment.