@show-karma/karma-gap-sdk 0.3.16 → 0.3.17

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -51,6 +51,15 @@ export declare abstract class Fetcher extends AxiosGQL {
51
51
  * @returns
52
52
  */
53
53
  abstract communitiesOf(address: Hex, withGrants?: boolean): Promise<Community[]>;
54
+ /**
55
+ * Fetch all available communities (admin) with details for a grantee;
56
+ *
57
+ * If search is defined, will try to find communities by the search string.
58
+ * @param address grantee address
59
+ * @param withGrants if true, will get community grants.
60
+ * @returns
61
+ */
62
+ abstract communitiesAdminOf(address: Hex, withGrants?: boolean): Promise<Community[]>;
54
63
  /**
55
64
  * Fetch a set of communities by their ids.
56
65
  * @param uids
@@ -30,6 +30,7 @@ export declare class GapEasClient extends Fetcher {
30
30
  dependentsOf(parentSchema: TSchemaName, parentUid: Hex): Promise<Attestation[]>;
31
31
  communities(search?: string): Promise<Community[]>;
32
32
  communitiesOf(address?: Hex): Promise<Community[]>;
33
+ communitiesAdminOf(address?: Hex): Promise<Community[]>;
33
34
  communitiesByIds(uids: Hex[]): Promise<Community[]>;
34
35
  communitiesDetails(communities: Community[]): Promise<Community[]>;
35
36
  communityBySlug(slug: string): Promise<Community>;
@@ -91,6 +91,15 @@ class GapEasClient extends Fetcher_1.Fetcher {
91
91
  return [];
92
92
  return this.communitiesDetails(communities);
93
93
  }
94
+ async communitiesAdminOf(address) {
95
+ const [community] = this.gap.findManySchemas(['Community']);
96
+ const query = gql_queries_1.gqlQueries.attestationsTo(community.uid, address);
97
+ const { schema: { attestations }, } = await this.query(query);
98
+ const communities = Attestation_1.Attestation.fromInterface(attestations, this.network.name);
99
+ if (!communities.length)
100
+ return [];
101
+ return this.communitiesDetails(communities);
102
+ }
94
103
  async communitiesByIds(uids) {
95
104
  if (!uids.length)
96
105
  return [];
@@ -11,6 +11,7 @@ export declare class GapIndexerClient extends Fetcher {
11
11
  attestationsTo(schemaName: TSchemaName, recipient: `0x${string}`): Promise<IAttestation[]>;
12
12
  communities(search?: string): Promise<Community[]>;
13
13
  communitiesOf(address: Hex, withGrants: boolean): Promise<Community[]>;
14
+ communitiesAdminOf(address: Hex, withGrants: boolean): Promise<Community[]>;
14
15
  communitiesByIds(uids: `0x${string}`[]): Promise<Community[]>;
15
16
  communityBySlug(slug: string): Promise<Community>;
16
17
  communityById(uid: `0x${string}`): Promise<Community>;
@@ -20,6 +20,7 @@ const Endpoints = {
20
20
  grants: (address) => `/grantees/${address}/grants`,
21
21
  projects: (address) => `/grantees/${address}/projects`,
22
22
  communities: (address, withGrants) => `/grantees/${address}/communities${withGrants ? '?withGrants=true' : ''}`,
23
+ communitiesAdmin: (address, withGrants) => `/grantees/${address}/communities/admin${withGrants ? '?withGrants=true' : ''}`,
23
24
  },
24
25
  grants: {
25
26
  all: () => '/grants',
@@ -73,6 +74,10 @@ class GapIndexerClient extends Fetcher_1.Fetcher {
73
74
  const { data } = await this.client.get(Endpoints.grantees.communities(address, withGrants));
74
75
  return entities_1.Community.from(data, this.gap.network);
75
76
  }
77
+ async communitiesAdminOf(address, withGrants) {
78
+ const { data } = await this.client.get(Endpoints.grantees.communitiesAdmin(address, withGrants));
79
+ return entities_1.Community.from(data, this.gap.network);
80
+ }
76
81
  communitiesByIds(uids) {
77
82
  throw new Error('Method not implemented.');
78
83
  }
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "publishConfig": {
4
4
  "access": "public"
5
5
  },
6
- "version": "0.3.16",
6
+ "version": "0.3.17",
7
7
  "description": "Simple and easy interface between EAS and Karma GAP.",
8
8
  "main": "./index.js",
9
9
  "author": "KarmaHQ",