@show-karma/karma-gap-sdk 0.1.36 → 0.1.38
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
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { Hex, IAttestation, TSchemaName } from
|
|
2
|
-
import { Attestation } from
|
|
3
|
-
import { Community, Grant, MemberOf, Milestone, Project } from
|
|
4
|
-
import { Grantee } from
|
|
5
|
-
import { AxiosGQL } from
|
|
1
|
+
import { Hex, IAttestation, TSchemaName } from 'core/types';
|
|
2
|
+
import { Attestation } from './Attestation';
|
|
3
|
+
import { Community, Grant, MemberOf, Milestone, Project } from './entities';
|
|
4
|
+
import { Grantee } from './types/attestations';
|
|
5
|
+
import { AxiosGQL } from './GraphQL/AxiosGQL';
|
|
6
6
|
export declare abstract class Fetcher extends AxiosGQL {
|
|
7
7
|
/**
|
|
8
8
|
* Fetch a single attestation by its UID.
|
|
@@ -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
|
|
@@ -129,4 +138,10 @@ export declare abstract class Fetcher extends AxiosGQL {
|
|
|
129
138
|
* @returns
|
|
130
139
|
*/
|
|
131
140
|
abstract slugExists(slug: string): Promise<boolean>;
|
|
141
|
+
/**
|
|
142
|
+
* Get grants for a project by an external uid
|
|
143
|
+
* > Works only for the indexed projects
|
|
144
|
+
* @param projectExtId
|
|
145
|
+
*/
|
|
146
|
+
abstract grantsForExtProject(projectExtId: string): Promise<Grant[]>;
|
|
132
147
|
}
|
|
@@ -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>;
|
|
@@ -59,5 +60,6 @@ export declare class GapEasClient extends Fetcher {
|
|
|
59
60
|
* @param value
|
|
60
61
|
*/
|
|
61
62
|
private getSearchFieldString;
|
|
63
|
+
grantsForExtProject(projectExtId: string): Promise<Grant[]>;
|
|
62
64
|
}
|
|
63
65
|
export {};
|
|
@@ -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 [];
|
|
@@ -416,5 +425,9 @@ class GapEasClient extends Fetcher_1.Fetcher {
|
|
|
416
425
|
String.raw `\\\\\"${field}\\\\\": \\\\\"${value}\\\\\"`,
|
|
417
426
|
];
|
|
418
427
|
}
|
|
428
|
+
async grantsForExtProject(projectExtId) {
|
|
429
|
+
console.error(new Error('Grants for external project is only supported by a custom indexer. Check https://github.com/show-karma/karma-gap-sdk for more information.'));
|
|
430
|
+
return [];
|
|
431
|
+
}
|
|
419
432
|
}
|
|
420
433
|
exports.GapEasClient = GapEasClient;
|
|
@@ -1,15 +1,16 @@
|
|
|
1
|
-
import { TSchemaName, IAttestation } from
|
|
2
|
-
import { Attestation } from
|
|
3
|
-
import { GapSchema } from
|
|
4
|
-
import { Fetcher } from
|
|
5
|
-
import { Community, Project, Grant, Milestone, MemberOf } from
|
|
6
|
-
import { Grantee } from
|
|
1
|
+
import { TSchemaName, IAttestation, Hex } from 'core/types';
|
|
2
|
+
import { Attestation } from '../Attestation';
|
|
3
|
+
import { GapSchema } from '../GapSchema';
|
|
4
|
+
import { Fetcher } from '../Fetcher';
|
|
5
|
+
import { Community, Project, Grant, Milestone, MemberOf } from '../entities';
|
|
6
|
+
import { Grantee } from '../types/attestations';
|
|
7
7
|
export declare class GapIndexerClient extends Fetcher {
|
|
8
8
|
attestation<T = unknown>(uid: `0x${string}`): Promise<Attestation<T, GapSchema>>;
|
|
9
9
|
attestations(schemaName: TSchemaName, search?: string): Promise<IAttestation[]>;
|
|
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>;
|
|
@@ -21,6 +22,7 @@ export declare class GapIndexerClient extends Fetcher {
|
|
|
21
22
|
grantees(): Promise<Grantee[]>;
|
|
22
23
|
grantsOf(grantee: `0x${string}`, withCommunity?: boolean): Promise<Grant[]>;
|
|
23
24
|
grantsFor(projects: Project[], withCommunity?: boolean): Promise<Grant[]>;
|
|
25
|
+
grantsForExtProject(projectExtId: string): Promise<Grant[]>;
|
|
24
26
|
grantsByCommunity(uid: `0x${string}`): Promise<Grant[]>;
|
|
25
27
|
milestonesOf(grants: Grant[]): Promise<Milestone[]>;
|
|
26
28
|
membersOf(projects: Project[]): Promise<MemberOf[]>;
|
|
@@ -7,26 +7,28 @@ const Fetcher_1 = require("../Fetcher");
|
|
|
7
7
|
const entities_1 = require("../entities");
|
|
8
8
|
const Endpoints = {
|
|
9
9
|
attestations: {
|
|
10
|
-
all: () =>
|
|
10
|
+
all: () => '/attestations',
|
|
11
11
|
byUid: (uid) => `/attestations/${uid}`,
|
|
12
12
|
},
|
|
13
13
|
communities: {
|
|
14
|
-
all: () =>
|
|
14
|
+
all: () => '/communities',
|
|
15
15
|
byUidOrSlug: (uidOrSlug) => `/communities/${uidOrSlug}`,
|
|
16
16
|
grants: (uidOrSlug) => `/communities/${uidOrSlug}/grants`,
|
|
17
17
|
},
|
|
18
18
|
grantees: {
|
|
19
|
-
all: () =>
|
|
19
|
+
all: () => '/grantees',
|
|
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
|
-
all: () =>
|
|
26
|
+
all: () => '/grants',
|
|
26
27
|
byUid: (uid) => `/grants/${uid}`,
|
|
28
|
+
byExternalId: (id) => `/grants/external-id/${id}`,
|
|
27
29
|
},
|
|
28
30
|
project: {
|
|
29
|
-
all: () =>
|
|
31
|
+
all: () => '/projects',
|
|
30
32
|
byUidOrSlug: (uidOrSlug) => `/projects/${uidOrSlug}`,
|
|
31
33
|
grants: (uidOrSlug) => `/projects/${uidOrSlug}/grants`,
|
|
32
34
|
milestones: (uidOrSlug) => `/projects/${uidOrSlug}/milestones`,
|
|
@@ -36,14 +38,14 @@ class GapIndexerClient extends Fetcher_1.Fetcher {
|
|
|
36
38
|
async attestation(uid) {
|
|
37
39
|
const { data } = await this.client.get(Endpoints.attestations.byUid(uid));
|
|
38
40
|
if (!data)
|
|
39
|
-
throw new Error(
|
|
41
|
+
throw new Error('Attestation not found');
|
|
40
42
|
return Attestation_1.Attestation.fromInterface([data])[0];
|
|
41
43
|
}
|
|
42
44
|
async attestations(schemaName, search) {
|
|
43
45
|
const { data } = await this.client.get(Endpoints.attestations.all(), {
|
|
44
46
|
params: {
|
|
45
|
-
|
|
46
|
-
|
|
47
|
+
'filter[schemaUID]': GapSchema_1.GapSchema.get(schemaName).uid,
|
|
48
|
+
'filter[data]': search,
|
|
47
49
|
},
|
|
48
50
|
});
|
|
49
51
|
return data || [];
|
|
@@ -51,8 +53,8 @@ class GapIndexerClient extends Fetcher_1.Fetcher {
|
|
|
51
53
|
async attestationsOf(schemaName, attester) {
|
|
52
54
|
const { data } = await this.client.get(Endpoints.attestations.all(), {
|
|
53
55
|
params: {
|
|
54
|
-
|
|
55
|
-
|
|
56
|
+
'filter[schemaUID]': GapSchema_1.GapSchema.get(schemaName).uid,
|
|
57
|
+
'filter[recipient]': attester,
|
|
56
58
|
},
|
|
57
59
|
});
|
|
58
60
|
return data || [];
|
|
@@ -63,13 +65,17 @@ class GapIndexerClient extends Fetcher_1.Fetcher {
|
|
|
63
65
|
async communities(search) {
|
|
64
66
|
const { data } = await this.client.get(Endpoints.communities.all(), {
|
|
65
67
|
params: {
|
|
66
|
-
|
|
68
|
+
'filter[name]': search,
|
|
67
69
|
},
|
|
68
70
|
});
|
|
69
71
|
return entities_1.Community.from(data);
|
|
70
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
|
+
}
|
|
71
77
|
communitiesByIds(uids) {
|
|
72
|
-
throw new Error(
|
|
78
|
+
throw new Error('Method not implemented.');
|
|
73
79
|
}
|
|
74
80
|
async communityBySlug(slug) {
|
|
75
81
|
const { data } = await this.client.get(Endpoints.communities.byUidOrSlug(slug));
|
|
@@ -88,7 +94,7 @@ class GapIndexerClient extends Fetcher_1.Fetcher {
|
|
|
88
94
|
async projects(name) {
|
|
89
95
|
const { data } = await this.client.get(Endpoints.project.all(), {
|
|
90
96
|
params: {
|
|
91
|
-
|
|
97
|
+
'filter[title]': name,
|
|
92
98
|
},
|
|
93
99
|
});
|
|
94
100
|
return entities_1.Project.from(data);
|
|
@@ -113,6 +119,10 @@ class GapIndexerClient extends Fetcher_1.Fetcher {
|
|
|
113
119
|
const { data } = await this.client.get(Endpoints.project.grants(projects[0].uid));
|
|
114
120
|
return entities_1.Grant.from(data);
|
|
115
121
|
}
|
|
122
|
+
async grantsForExtProject(projectExtId) {
|
|
123
|
+
const { data } = await this.client.get(Endpoints.grants.byExternalId(projectExtId));
|
|
124
|
+
return entities_1.Grant.from(data);
|
|
125
|
+
}
|
|
116
126
|
async grantsByCommunity(uid) {
|
|
117
127
|
const { data } = await this.client.get(Endpoints.communities.grants(uid));
|
|
118
128
|
return entities_1.Grant.from(data);
|
|
@@ -122,7 +132,7 @@ class GapIndexerClient extends Fetcher_1.Fetcher {
|
|
|
122
132
|
return entities_1.Milestone.from(data);
|
|
123
133
|
}
|
|
124
134
|
async membersOf(projects) {
|
|
125
|
-
throw new Error(
|
|
135
|
+
throw new Error('Method not implemented.');
|
|
126
136
|
}
|
|
127
137
|
async slugExists(slug) {
|
|
128
138
|
try {
|