@show-karma/karma-gap-sdk 0.1.37 → 0.1.39
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.
- package/core/class/Fetcher.d.ts +9 -0
- package/core/class/GraphQL/GapEasClient.d.ts +1 -0
- package/core/class/GraphQL/GapEasClient.js +9 -0
- package/core/class/entities/Grant.d.ts +1 -0
- package/core/class/entities/Grant.js +4 -0
- package/core/class/karma-indexer/GapIndexerClient.d.ts +2 -1
- package/core/class/karma-indexer/GapIndexerClient.js +5 -0
- package/package.json +1 -1
package/core/class/Fetcher.d.ts
CHANGED
|
@@ -38,6 +38,15 @@ export declare abstract class Fetcher extends AxiosGQL {
|
|
|
38
38
|
* @returns
|
|
39
39
|
*/
|
|
40
40
|
abstract communities(search?: string): Promise<Community[]>;
|
|
41
|
+
/**
|
|
42
|
+
* Fetch all available communities with details for a grantee;
|
|
43
|
+
*
|
|
44
|
+
* If search is defined, will try to find communities by the search string.
|
|
45
|
+
* @param address grantee address
|
|
46
|
+
* @param withGrants if true, will get community grants.
|
|
47
|
+
* @returns
|
|
48
|
+
*/
|
|
49
|
+
abstract communitiesOf(address: Hex, withGrants?: boolean): Promise<Community[]>;
|
|
41
50
|
/**
|
|
42
51
|
* Fetch a set of communities by their ids.
|
|
43
52
|
* @param uids
|
|
@@ -29,6 +29,7 @@ export declare class GapEasClient extends Fetcher {
|
|
|
29
29
|
*/
|
|
30
30
|
dependentsOf(parentSchema: TSchemaName, parentUid: Hex): Promise<Attestation[]>;
|
|
31
31
|
communities(search?: string): Promise<Community[]>;
|
|
32
|
+
communitiesOf(address?: Hex): Promise<Community[]>;
|
|
32
33
|
communitiesByIds(uids: Hex[]): Promise<Community[]>;
|
|
33
34
|
communitiesDetails(communities: Community[]): Promise<Community[]>;
|
|
34
35
|
communityBySlug(slug: string): Promise<Community>;
|
|
@@ -82,6 +82,15 @@ class GapEasClient extends Fetcher_1.Fetcher {
|
|
|
82
82
|
return [];
|
|
83
83
|
return this.communitiesDetails(communities);
|
|
84
84
|
}
|
|
85
|
+
async communitiesOf(address) {
|
|
86
|
+
const [community] = GapSchema_1.GapSchema.findMany(['Community']);
|
|
87
|
+
const query = gql_queries_1.gqlQueries.attestationsTo(community.uid, address);
|
|
88
|
+
const { schema: { attestations }, } = await this.query(query);
|
|
89
|
+
const communities = Attestation_1.Attestation.fromInterface(attestations);
|
|
90
|
+
if (!communities.length)
|
|
91
|
+
return [];
|
|
92
|
+
return this.communitiesDetails(communities);
|
|
93
|
+
}
|
|
85
94
|
async communitiesByIds(uids) {
|
|
86
95
|
if (!uids.length)
|
|
87
96
|
return [];
|
|
@@ -18,6 +18,7 @@ export declare class Grant extends Attestation<IGrant> {
|
|
|
18
18
|
milestones: Milestone[];
|
|
19
19
|
community: Community;
|
|
20
20
|
updates: GrantUpdate[];
|
|
21
|
+
members: string[];
|
|
21
22
|
completed?: GrantCompleted;
|
|
22
23
|
project?: Project;
|
|
23
24
|
verify(signer: SignerOrProvider): Promise<void>;
|
|
@@ -17,6 +17,7 @@ class Grant extends Attestation_1.Attestation {
|
|
|
17
17
|
this.verified = false;
|
|
18
18
|
this.milestones = [];
|
|
19
19
|
this.updates = [];
|
|
20
|
+
this.members = [];
|
|
20
21
|
}
|
|
21
22
|
async verify(signer) {
|
|
22
23
|
const eas = GAP_1.GAP.eas.connect(signer);
|
|
@@ -187,6 +188,9 @@ class Grant extends Attestation_1.Attestation {
|
|
|
187
188
|
const { community } = attestation;
|
|
188
189
|
grant.community = Community_1.Community.from([community])[0];
|
|
189
190
|
}
|
|
191
|
+
if (attestation.members) {
|
|
192
|
+
grant.members = attestation.members;
|
|
193
|
+
}
|
|
190
194
|
return grant;
|
|
191
195
|
});
|
|
192
196
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { TSchemaName, IAttestation } from 'core/types';
|
|
1
|
+
import { TSchemaName, IAttestation, Hex } from 'core/types';
|
|
2
2
|
import { Attestation } from '../Attestation';
|
|
3
3
|
import { GapSchema } from '../GapSchema';
|
|
4
4
|
import { Fetcher } from '../Fetcher';
|
|
@@ -10,6 +10,7 @@ export declare class GapIndexerClient extends Fetcher {
|
|
|
10
10
|
attestationsOf(schemaName: TSchemaName, attester: `0x${string}`): Promise<IAttestation[]>;
|
|
11
11
|
attestationsTo(schemaName: TSchemaName, recipient: `0x${string}`): Promise<IAttestation[]>;
|
|
12
12
|
communities(search?: string): Promise<Community[]>;
|
|
13
|
+
communitiesOf(address: Hex, withGrants: boolean): Promise<Community[]>;
|
|
13
14
|
communitiesByIds(uids: `0x${string}`[]): Promise<Community[]>;
|
|
14
15
|
communityBySlug(slug: string): Promise<Community>;
|
|
15
16
|
communityById(uid: `0x${string}`): Promise<Community>;
|
|
@@ -20,6 +20,7 @@ const Endpoints = {
|
|
|
20
20
|
byAddress: (address) => `/grantees/${address}`,
|
|
21
21
|
grants: (address) => `/grantees/${address}/grants`,
|
|
22
22
|
projects: (address) => `/grantees/${address}/projects`,
|
|
23
|
+
communities: (address, withGrants) => `/grantees/${address}/communities${withGrants ? '?withGrants=true' : ''}`,
|
|
23
24
|
},
|
|
24
25
|
grants: {
|
|
25
26
|
all: () => '/grants',
|
|
@@ -69,6 +70,10 @@ class GapIndexerClient extends Fetcher_1.Fetcher {
|
|
|
69
70
|
});
|
|
70
71
|
return entities_1.Community.from(data);
|
|
71
72
|
}
|
|
73
|
+
async communitiesOf(address, withGrants) {
|
|
74
|
+
const { data } = await this.client.get(Endpoints.grantees.communities(address, withGrants));
|
|
75
|
+
return entities_1.Community.from(data);
|
|
76
|
+
}
|
|
72
77
|
communitiesByIds(uids) {
|
|
73
78
|
throw new Error('Method not implemented.');
|
|
74
79
|
}
|