@show-karma/karma-gap-sdk 0.3.22 → 0.3.24
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/Attestation.js +1 -1
- package/core/class/entities/Community.d.ts +2 -4
- package/core/class/entities/Grant.d.ts +2 -4
- package/core/class/entities/GrantUpdate.d.ts +1 -1
- package/core/class/entities/Milestone.d.ts +2 -4
- package/core/class/entities/Project.d.ts +2 -4
- package/core/class/karma-indexer/GapIndexerClient.d.ts +2 -0
- package/core/class/karma-indexer/GapIndexerClient.js +26 -47
- package/core/class/karma-indexer/api/GapIndexerApi.d.ts +43 -0
- package/core/class/karma-indexer/api/GapIndexerApi.js +154 -0
- package/core/class/karma-indexer/api/types.d.ts +159 -0
- package/core/class/karma-indexer/api/types.js +2 -0
- package/package.json +1 -1
|
@@ -194,7 +194,7 @@ class Attestation {
|
|
|
194
194
|
this._data.type = this.type;
|
|
195
195
|
this.schema.setValue('json', JSON.stringify(this._data));
|
|
196
196
|
}
|
|
197
|
-
if (remoteClient) {
|
|
197
|
+
if (remoteClient && JSON.stringify(this._data)?.length > 1500) {
|
|
198
198
|
const cid = await remoteClient.save(this._data, this.schema.name);
|
|
199
199
|
const encodedData = remoteClient.encode(cid);
|
|
200
200
|
this.schema.setValue('json', JSON.stringify(encodedData));
|
|
@@ -3,8 +3,7 @@ import { CommunityDetails, ICommunityDetails } from '../types/attestations';
|
|
|
3
3
|
import { Project } from './Project';
|
|
4
4
|
import { MultiAttestPayload, SignerOrProvider, TNetwork } from 'core/types';
|
|
5
5
|
import { Grant } from './Grant';
|
|
6
|
-
|
|
7
|
-
}
|
|
6
|
+
import { ICommunityResponse } from '../karma-indexer/api/types';
|
|
8
7
|
export interface ICommunity {
|
|
9
8
|
community: true;
|
|
10
9
|
}
|
|
@@ -31,6 +30,5 @@ export declare class Community extends Attestation<ICommunity> {
|
|
|
31
30
|
* @param details
|
|
32
31
|
*/
|
|
33
32
|
attest(signer: SignerOrProvider, details?: ICommunityDetails): Promise<void>;
|
|
34
|
-
static from(attestations:
|
|
33
|
+
static from(attestations: ICommunityResponse[], network: TNetwork): Community[];
|
|
35
34
|
}
|
|
36
|
-
export {};
|
|
@@ -4,9 +4,8 @@ import { IMilestone, Milestone } from './Milestone';
|
|
|
4
4
|
import { GapSchema } from '../GapSchema';
|
|
5
5
|
import { Hex, MultiAttestPayload, SignerOrProvider, TNetwork } from 'core/types';
|
|
6
6
|
import { Community } from './Community';
|
|
7
|
+
import { IGrantResponse } from '../karma-indexer/api/types';
|
|
7
8
|
import { GrantUpdate, IGrantUpdate } from './GrantUpdate';
|
|
8
|
-
interface _Grant extends Grant {
|
|
9
|
-
}
|
|
10
9
|
export interface IGrant {
|
|
11
10
|
communityUID: Hex;
|
|
12
11
|
}
|
|
@@ -56,6 +55,5 @@ export declare class Grant extends Attestation<IGrant> {
|
|
|
56
55
|
* Validate if the grant has a valid reference to a community.
|
|
57
56
|
*/
|
|
58
57
|
protected assertPayload(): boolean;
|
|
59
|
-
static from(attestations:
|
|
58
|
+
static from(attestations: IGrantResponse[], network: TNetwork): Grant[];
|
|
60
59
|
}
|
|
61
|
-
export {};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { SignerOrProvider, TNetwork } from '../../../core/types';
|
|
2
2
|
import { Attestation } from '../Attestation';
|
|
3
|
-
interface _IGrantUpdate extends GrantUpdate {
|
|
3
|
+
export interface _IGrantUpdate extends GrantUpdate {
|
|
4
4
|
}
|
|
5
5
|
export interface IGrantUpdate {
|
|
6
6
|
title: string;
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import { MultiAttestPayload, SignerOrProvider, TNetwork } from '../../types';
|
|
2
2
|
import { Attestation } from '../Attestation';
|
|
3
3
|
import { GapSchema } from '../GapSchema';
|
|
4
|
+
import { IMilestoneResponse } from '../karma-indexer/api/types';
|
|
4
5
|
import { MilestoneCompleted } from '../types/attestations';
|
|
5
|
-
interface _Milestone extends Milestone {
|
|
6
|
-
}
|
|
7
6
|
export interface IMilestone {
|
|
8
7
|
title: string;
|
|
9
8
|
startsAt?: number;
|
|
@@ -79,7 +78,7 @@ export declare class Milestone extends Attestation<IMilestone> implements IMiles
|
|
|
79
78
|
* Attest the status of the milestone as approved, rejected or completed.
|
|
80
79
|
*/
|
|
81
80
|
private attestStatus;
|
|
82
|
-
static from(attestations:
|
|
81
|
+
static from(attestations: IMilestoneResponse[], network: TNetwork): Milestone[];
|
|
83
82
|
/**
|
|
84
83
|
* Verify this milestone. If the milestone is not completed or already verified,
|
|
85
84
|
* it will throw an error.
|
|
@@ -88,4 +87,3 @@ export declare class Milestone extends Attestation<IMilestone> implements IMiles
|
|
|
88
87
|
*/
|
|
89
88
|
verify(signer: SignerOrProvider, reason?: string): Promise<void>;
|
|
90
89
|
}
|
|
91
|
-
export {};
|
|
@@ -3,8 +3,7 @@ import { Grantee, MemberDetails, ProjectDetails, ProjectEndorsement, ProjectImpa
|
|
|
3
3
|
import { Hex, MultiAttestPayload, SignerOrProvider, TNetwork } from 'core/types';
|
|
4
4
|
import { Grant } from './Grant';
|
|
5
5
|
import { MemberOf } from './MemberOf';
|
|
6
|
-
|
|
7
|
-
}
|
|
6
|
+
import { IProjectResponse } from '../karma-indexer/api/types';
|
|
8
7
|
export interface IProject {
|
|
9
8
|
project: true;
|
|
10
9
|
}
|
|
@@ -72,8 +71,7 @@ export declare class Project extends Attestation<IProject> {
|
|
|
72
71
|
* @param signer
|
|
73
72
|
*/
|
|
74
73
|
removeAllMembers(signer: SignerOrProvider): Promise<void>;
|
|
75
|
-
static from(attestations:
|
|
74
|
+
static from(attestations: IProjectResponse[], network: TNetwork): Project[];
|
|
76
75
|
attestImpact(signer: SignerOrProvider, data: ProjectImpact): Promise<void>;
|
|
77
76
|
attestEndorsement(signer: SignerOrProvider, data?: ProjectEndorsement): Promise<void>;
|
|
78
77
|
}
|
|
79
|
-
export {};
|
|
@@ -5,6 +5,8 @@ import { Fetcher } from '../Fetcher';
|
|
|
5
5
|
import { Community, Project, Grant, Milestone, MemberOf } from '../entities';
|
|
6
6
|
import { Grantee } from '../types/attestations';
|
|
7
7
|
export declare class GapIndexerClient extends Fetcher {
|
|
8
|
+
private apiClient;
|
|
9
|
+
constructor(params: any);
|
|
8
10
|
attestation<T = unknown>(uid: `0x${string}`): Promise<Attestation<T, GapSchema>>;
|
|
9
11
|
attestations(schemaName: TSchemaName, search?: string): Promise<IAttestation[]>;
|
|
10
12
|
attestationsOf(schemaName: TSchemaName, attester: `0x${string}`): Promise<IAttestation[]>;
|
|
@@ -4,6 +4,7 @@ exports.GapIndexerClient = void 0;
|
|
|
4
4
|
const Attestation_1 = require("../Attestation");
|
|
5
5
|
const Fetcher_1 = require("../Fetcher");
|
|
6
6
|
const entities_1 = require("../entities");
|
|
7
|
+
const GapIndexerApi_1 = require("./api/GapIndexerApi");
|
|
7
8
|
const Endpoints = {
|
|
8
9
|
attestations: {
|
|
9
10
|
all: () => '/attestations',
|
|
@@ -35,43 +36,35 @@ const Endpoints = {
|
|
|
35
36
|
},
|
|
36
37
|
};
|
|
37
38
|
class GapIndexerClient extends Fetcher_1.Fetcher {
|
|
39
|
+
constructor(params) {
|
|
40
|
+
super(params);
|
|
41
|
+
this.apiClient = new GapIndexerApi_1.GapIndexerApi(params);
|
|
42
|
+
}
|
|
38
43
|
async attestation(uid) {
|
|
39
|
-
const { data } = await this.
|
|
44
|
+
const { data } = await this.apiClient.attestation(uid);
|
|
40
45
|
if (!data)
|
|
41
46
|
throw new Error('Attestation not found');
|
|
42
47
|
return Attestation_1.Attestation.fromInterface([data], this.gap.network)[0];
|
|
43
48
|
}
|
|
44
49
|
async attestations(schemaName, search) {
|
|
45
|
-
const
|
|
46
|
-
|
|
47
|
-
'filter[schemaUID]': this.gap.findSchema(schemaName).uid,
|
|
48
|
-
'filter[data]': search,
|
|
49
|
-
},
|
|
50
|
-
});
|
|
50
|
+
const schemaUID = this.gap.findSchema(schemaName).uid;
|
|
51
|
+
const { data } = await this.apiClient.attestations(schemaUID, search);
|
|
51
52
|
return data || [];
|
|
52
53
|
}
|
|
53
54
|
async attestationsOf(schemaName, attester) {
|
|
54
|
-
const
|
|
55
|
-
|
|
56
|
-
'filter[schemaUID]': this.gap.findSchema(schemaName).uid,
|
|
57
|
-
'filter[recipient]': attester,
|
|
58
|
-
},
|
|
59
|
-
});
|
|
55
|
+
const schemaUID = this.gap.findSchema(schemaName).uid;
|
|
56
|
+
const { data } = await this.apiClient.attestationsOf(schemaUID, attester);
|
|
60
57
|
return data || [];
|
|
61
58
|
}
|
|
62
59
|
attestationsTo(schemaName, recipient) {
|
|
63
60
|
return this.attestationsOf(schemaName, recipient);
|
|
64
61
|
}
|
|
65
62
|
async communities(search) {
|
|
66
|
-
const { data } = await this.
|
|
67
|
-
params: {
|
|
68
|
-
'filter[name]': search,
|
|
69
|
-
},
|
|
70
|
-
});
|
|
63
|
+
const { data } = await this.apiClient.communities(search);
|
|
71
64
|
return entities_1.Community.from(data, this.gap.network);
|
|
72
65
|
}
|
|
73
66
|
async communitiesOf(address, withGrants) {
|
|
74
|
-
const { data } = await this.
|
|
67
|
+
const { data } = await this.apiClient.communitiesOf(address, withGrants);
|
|
75
68
|
return entities_1.Community.from(data, this.gap.network);
|
|
76
69
|
}
|
|
77
70
|
async communitiesAdminOf(address, withGrants) {
|
|
@@ -82,78 +75,64 @@ class GapIndexerClient extends Fetcher_1.Fetcher {
|
|
|
82
75
|
throw new Error('Method not implemented.');
|
|
83
76
|
}
|
|
84
77
|
async communityBySlug(slug) {
|
|
85
|
-
const { data } = await this.
|
|
78
|
+
const { data } = await this.apiClient.communityBySlug(slug);
|
|
86
79
|
return entities_1.Community.from([data], this.gap.network)[0];
|
|
87
80
|
}
|
|
88
81
|
communityById(uid) {
|
|
89
82
|
return this.communityBySlug(uid);
|
|
90
83
|
}
|
|
91
84
|
async projectBySlug(slug) {
|
|
92
|
-
const { data } = await this.
|
|
85
|
+
const { data } = await this.apiClient.projectBySlug(slug);
|
|
93
86
|
return entities_1.Project.from([data], this.gap.network)[0];
|
|
94
87
|
}
|
|
95
88
|
projectById(uid) {
|
|
96
89
|
return this.projectBySlug(uid);
|
|
97
90
|
}
|
|
98
91
|
async searchProjects(query) {
|
|
99
|
-
const { data } = await this.
|
|
100
|
-
params: {
|
|
101
|
-
q: query,
|
|
102
|
-
},
|
|
103
|
-
});
|
|
92
|
+
const { data } = await this.apiClient.searchProjects(query);
|
|
104
93
|
return entities_1.Project.from(data, this.gap.network);
|
|
105
94
|
}
|
|
106
95
|
async projects(name) {
|
|
107
|
-
const { data } = await this.
|
|
108
|
-
params: {
|
|
109
|
-
'filter[title]': name,
|
|
110
|
-
},
|
|
111
|
-
});
|
|
96
|
+
const { data } = await this.apiClient.projects(name);
|
|
112
97
|
return entities_1.Project.from(data, this.gap.network);
|
|
113
98
|
}
|
|
114
99
|
async projectsOf(grantee) {
|
|
115
|
-
const { data } = await this.
|
|
100
|
+
const { data } = await this.apiClient.projectsOf(grantee);
|
|
116
101
|
return entities_1.Project.from(data, this.gap.network);
|
|
117
102
|
}
|
|
118
103
|
async grantee(address) {
|
|
119
|
-
const { data } = await this.
|
|
104
|
+
const { data } = await this.apiClient.grantee(address);
|
|
120
105
|
return data;
|
|
121
106
|
}
|
|
122
107
|
async grantees() {
|
|
123
|
-
const { data } = await this.
|
|
124
|
-
return data;
|
|
108
|
+
const { data } = await this.apiClient.grantees();
|
|
109
|
+
return data; // TODO: Remove this casting after the api is fixed
|
|
125
110
|
}
|
|
126
111
|
async grantsOf(grantee, withCommunity) {
|
|
127
|
-
const { data } = await this.
|
|
112
|
+
const { data } = await this.apiClient.grantsOf(grantee, withCommunity);
|
|
128
113
|
return entities_1.Grant.from(data, this.gap.network);
|
|
129
114
|
}
|
|
130
115
|
async grantsFor(projects, withCommunity) {
|
|
131
|
-
const { data } = await this.
|
|
116
|
+
const { data } = await this.apiClient.grantsFor(projects[0].uid, withCommunity);
|
|
132
117
|
return entities_1.Grant.from(data, this.gap.network);
|
|
133
118
|
}
|
|
134
119
|
async grantsForExtProject(projectExtId) {
|
|
135
|
-
const { data } = await this.
|
|
120
|
+
const { data } = await this.apiClient.grantsForExtProject(projectExtId);
|
|
136
121
|
return entities_1.Grant.from(data, this.gap.network);
|
|
137
122
|
}
|
|
138
123
|
async grantsByCommunity(uid) {
|
|
139
|
-
const { data } = await this.
|
|
124
|
+
const { data } = await this.apiClient.grantsByCommunity(uid);
|
|
140
125
|
return entities_1.Grant.from(data, this.gap.network);
|
|
141
126
|
}
|
|
142
127
|
async milestonesOf(grants) {
|
|
143
|
-
const { data } = await this.
|
|
128
|
+
const { data } = await this.apiClient.milestonesOf(grants[0].uid);
|
|
144
129
|
return entities_1.Milestone.from(data, this.gap.network);
|
|
145
130
|
}
|
|
146
131
|
async membersOf(projects) {
|
|
147
132
|
throw new Error('Method not implemented.');
|
|
148
133
|
}
|
|
149
134
|
async slugExists(slug) {
|
|
150
|
-
|
|
151
|
-
await this.client.get(Endpoints.project.byUidOrSlug(slug));
|
|
152
|
-
return true;
|
|
153
|
-
}
|
|
154
|
-
catch {
|
|
155
|
-
return false;
|
|
156
|
-
}
|
|
135
|
+
return await this.apiClient.slugExists(slug);
|
|
157
136
|
}
|
|
158
137
|
}
|
|
159
138
|
exports.GapIndexerClient = GapIndexerClient;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { AxiosGQL } from "../../GraphQL/AxiosGQL";
|
|
2
|
+
import { Hex, IAttestationResponse, ICommunityResponse, IGrantResponse, IProjectResponse } from "./types";
|
|
3
|
+
export declare class GapIndexerApi extends AxiosGQL {
|
|
4
|
+
constructor(url: string);
|
|
5
|
+
attestation(uid: Hex): Promise<import("axios").AxiosResponse<IAttestationResponse, any>>;
|
|
6
|
+
attestations(schemaUID: string, search?: string): Promise<import("axios").AxiosResponse<IAttestationResponse[], any>>;
|
|
7
|
+
attestationsOf(schemaUID: string, attester: Hex): Promise<import("axios").AxiosResponse<IAttestationResponse[], any>>;
|
|
8
|
+
/**
|
|
9
|
+
* Community
|
|
10
|
+
*/
|
|
11
|
+
communities(search?: string): Promise<import("axios").AxiosResponse<ICommunityResponse[], any>>;
|
|
12
|
+
communitiesOf(address: Hex, withGrants: boolean): Promise<import("axios").AxiosResponse<ICommunityResponse[], any>>;
|
|
13
|
+
communityBySlug(slug: string): Promise<import("axios").AxiosResponse<ICommunityResponse, any>>;
|
|
14
|
+
/**
|
|
15
|
+
* Project
|
|
16
|
+
*/
|
|
17
|
+
projectBySlug(slug: string): Promise<import("axios").AxiosResponse<IProjectResponse, any>>;
|
|
18
|
+
searchProjects(query: string): Promise<import("axios").AxiosResponse<IProjectResponse[], any>>;
|
|
19
|
+
projects(name?: string): Promise<import("axios").AxiosResponse<IProjectResponse[], any>>;
|
|
20
|
+
projectsOf(grantee: Hex): Promise<import("axios").AxiosResponse<IProjectResponse[], any>>;
|
|
21
|
+
/**
|
|
22
|
+
* Grantee
|
|
23
|
+
*/
|
|
24
|
+
grantee(address: Hex): Promise<import("axios").AxiosResponse<any, any>>;
|
|
25
|
+
grantees(): Promise<import("axios").AxiosResponse<{
|
|
26
|
+
[key: `0x${string}`]: {
|
|
27
|
+
grants: number;
|
|
28
|
+
projects: number;
|
|
29
|
+
};
|
|
30
|
+
}, any>>;
|
|
31
|
+
/**
|
|
32
|
+
* Grant
|
|
33
|
+
*/
|
|
34
|
+
grantsOf(grantee: Hex, withCommunity?: boolean): Promise<import("axios").AxiosResponse<IGrantResponse[], any>>;
|
|
35
|
+
grantsFor(uid: string, withCommunity?: boolean): Promise<import("axios").AxiosResponse<IGrantResponse[], any>>;
|
|
36
|
+
grantsForExtProject(projectExtId: string): Promise<import("axios").AxiosResponse<IGrantResponse[], any>>;
|
|
37
|
+
grantsByCommunity(uid: Hex): Promise<import("axios").AxiosResponse<IGrantResponse[], any>>;
|
|
38
|
+
/**
|
|
39
|
+
* Milestone
|
|
40
|
+
*/
|
|
41
|
+
milestonesOf(uid: Hex): Promise<import("axios").AxiosResponse<any, any>>;
|
|
42
|
+
slugExists(slug: string): Promise<boolean>;
|
|
43
|
+
}
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.GapIndexerApi = void 0;
|
|
4
|
+
const AxiosGQL_1 = require("../../GraphQL/AxiosGQL");
|
|
5
|
+
const Endpoints = {
|
|
6
|
+
attestations: {
|
|
7
|
+
all: () => "/attestations",
|
|
8
|
+
byUid: (uid) => `/attestations/${uid}`,
|
|
9
|
+
},
|
|
10
|
+
communities: {
|
|
11
|
+
all: () => "/communities",
|
|
12
|
+
byUidOrSlug: (uidOrSlug) => `/communities/${uidOrSlug}`,
|
|
13
|
+
grants: (uidOrSlug) => `/communities/${uidOrSlug}/grants`,
|
|
14
|
+
},
|
|
15
|
+
grantees: {
|
|
16
|
+
all: () => "/grantees",
|
|
17
|
+
byAddress: (address) => `/grantees/${address}`,
|
|
18
|
+
grants: (address) => `/grantees/${address}/grants`,
|
|
19
|
+
projects: (address) => `/grantees/${address}/projects`,
|
|
20
|
+
communities: (address, withGrants) => `/grantees/${address}/communities${withGrants ? "?withGrants=true" : ""}`,
|
|
21
|
+
},
|
|
22
|
+
grants: {
|
|
23
|
+
all: () => "/grants",
|
|
24
|
+
byUid: (uid) => `/grants/${uid}`,
|
|
25
|
+
byExternalId: (id) => `/grants/external-id/${id}`,
|
|
26
|
+
},
|
|
27
|
+
project: {
|
|
28
|
+
all: () => "/projects",
|
|
29
|
+
byUidOrSlug: (uidOrSlug) => `/projects/${uidOrSlug}`,
|
|
30
|
+
grants: (uidOrSlug) => `/projects/${uidOrSlug}/grants`,
|
|
31
|
+
milestones: (uidOrSlug) => `/projects/${uidOrSlug}/milestones`,
|
|
32
|
+
},
|
|
33
|
+
};
|
|
34
|
+
class GapIndexerApi extends AxiosGQL_1.AxiosGQL {
|
|
35
|
+
constructor(url) {
|
|
36
|
+
super(url);
|
|
37
|
+
}
|
|
38
|
+
async attestation(uid) {
|
|
39
|
+
const response = await this.client.get(Endpoints.attestations.byUid(uid));
|
|
40
|
+
return response;
|
|
41
|
+
}
|
|
42
|
+
async attestations(schemaUID, search) {
|
|
43
|
+
const response = await this.client.get(Endpoints.attestations.all(), {
|
|
44
|
+
params: {
|
|
45
|
+
"filter[schemaUID]": schemaUID,
|
|
46
|
+
"filter[data]": search,
|
|
47
|
+
},
|
|
48
|
+
});
|
|
49
|
+
return response;
|
|
50
|
+
}
|
|
51
|
+
async attestationsOf(schemaUID, attester) {
|
|
52
|
+
const response = await this.client.get(Endpoints.attestations.all(), {
|
|
53
|
+
params: {
|
|
54
|
+
"filter[schemaUID]": schemaUID,
|
|
55
|
+
"filter[recipient]": attester,
|
|
56
|
+
},
|
|
57
|
+
});
|
|
58
|
+
return response;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Community
|
|
62
|
+
*/
|
|
63
|
+
async communities(search) {
|
|
64
|
+
const response = await this.client.get(Endpoints.communities.all(), {
|
|
65
|
+
params: {
|
|
66
|
+
"filter[name]": search,
|
|
67
|
+
},
|
|
68
|
+
});
|
|
69
|
+
return response;
|
|
70
|
+
}
|
|
71
|
+
async communitiesOf(address, withGrants) {
|
|
72
|
+
const response = await this.client.get(Endpoints.grantees.communities(address, withGrants));
|
|
73
|
+
return response;
|
|
74
|
+
}
|
|
75
|
+
async communityBySlug(slug) {
|
|
76
|
+
const response = await this.client.get(Endpoints.communities.byUidOrSlug(slug));
|
|
77
|
+
return response;
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Project
|
|
81
|
+
*/
|
|
82
|
+
async projectBySlug(slug) {
|
|
83
|
+
const response = await this.client.get(Endpoints.project.byUidOrSlug(slug));
|
|
84
|
+
return response;
|
|
85
|
+
}
|
|
86
|
+
async searchProjects(query) {
|
|
87
|
+
const response = await this.client.get(Endpoints.project.all(), {
|
|
88
|
+
params: {
|
|
89
|
+
q: query,
|
|
90
|
+
},
|
|
91
|
+
});
|
|
92
|
+
return response;
|
|
93
|
+
}
|
|
94
|
+
async projects(name) {
|
|
95
|
+
const response = await this.client.get(Endpoints.project.all(), {
|
|
96
|
+
params: {
|
|
97
|
+
"filter[title]": name,
|
|
98
|
+
},
|
|
99
|
+
});
|
|
100
|
+
return response;
|
|
101
|
+
}
|
|
102
|
+
async projectsOf(grantee) {
|
|
103
|
+
const response = await this.client.get(Endpoints.grantees.projects(grantee));
|
|
104
|
+
return response;
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Grantee
|
|
108
|
+
*/
|
|
109
|
+
async grantee(address) {
|
|
110
|
+
// TODO: update response type when the endpoint works
|
|
111
|
+
const response = await this.client.get(Endpoints.grantees.byAddress(address));
|
|
112
|
+
return response;
|
|
113
|
+
}
|
|
114
|
+
async grantees() {
|
|
115
|
+
const response = await this.client.get(Endpoints.grantees.all());
|
|
116
|
+
return response;
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* Grant
|
|
120
|
+
*/
|
|
121
|
+
async grantsOf(grantee, withCommunity) {
|
|
122
|
+
const response = await this.client.get(Endpoints.grantees.grants(grantee));
|
|
123
|
+
return response;
|
|
124
|
+
}
|
|
125
|
+
async grantsFor(uid, withCommunity) {
|
|
126
|
+
const response = await this.client.get(Endpoints.project.grants(uid));
|
|
127
|
+
return response;
|
|
128
|
+
}
|
|
129
|
+
async grantsForExtProject(projectExtId) {
|
|
130
|
+
const response = await this.client.get(Endpoints.grants.byExternalId(projectExtId));
|
|
131
|
+
return response;
|
|
132
|
+
}
|
|
133
|
+
async grantsByCommunity(uid) {
|
|
134
|
+
const response = await this.client.get(Endpoints.communities.grants(uid));
|
|
135
|
+
return response;
|
|
136
|
+
}
|
|
137
|
+
/**
|
|
138
|
+
* Milestone
|
|
139
|
+
*/
|
|
140
|
+
async milestonesOf(uid) {
|
|
141
|
+
const response = await this.client.get(Endpoints.project.milestones(uid));
|
|
142
|
+
return response;
|
|
143
|
+
}
|
|
144
|
+
async slugExists(slug) {
|
|
145
|
+
try {
|
|
146
|
+
await this.client.get(Endpoints.project.byUidOrSlug(slug));
|
|
147
|
+
return true;
|
|
148
|
+
}
|
|
149
|
+
catch (err) {
|
|
150
|
+
return false;
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
exports.GapIndexerApi = GapIndexerApi;
|
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
export type Hex = `0x${string}`;
|
|
2
|
+
export type JSONStr = string;
|
|
3
|
+
export type ExternalLink = {
|
|
4
|
+
type: string;
|
|
5
|
+
url: string;
|
|
6
|
+
};
|
|
7
|
+
export interface ITag {
|
|
8
|
+
name: string;
|
|
9
|
+
}
|
|
10
|
+
export interface IAttestationResponse {
|
|
11
|
+
id: string;
|
|
12
|
+
uid: Hex;
|
|
13
|
+
schemaUID: Hex;
|
|
14
|
+
refUID: Hex;
|
|
15
|
+
attester: Hex;
|
|
16
|
+
recipient: Hex;
|
|
17
|
+
revoked: boolean;
|
|
18
|
+
revocationTime?: number;
|
|
19
|
+
createdAt: any;
|
|
20
|
+
updatedAt: any;
|
|
21
|
+
chainID: number;
|
|
22
|
+
type: string;
|
|
23
|
+
data: any;
|
|
24
|
+
decodedDataJson: JSONStr;
|
|
25
|
+
isOffchain: any;
|
|
26
|
+
revocable: any;
|
|
27
|
+
schemaId: Hex;
|
|
28
|
+
}
|
|
29
|
+
export interface ISummaryProject {
|
|
30
|
+
title: string;
|
|
31
|
+
slug?: string;
|
|
32
|
+
uid: Hex;
|
|
33
|
+
}
|
|
34
|
+
export interface IMilestoneCompleted extends IAttestationResponse {
|
|
35
|
+
type: "approved" | "rejected" | "completed";
|
|
36
|
+
reason?: string;
|
|
37
|
+
}
|
|
38
|
+
export interface IMilestoneResponse extends IAttestationResponse {
|
|
39
|
+
type: "Milestone";
|
|
40
|
+
completed?: IMilestoneCompleted;
|
|
41
|
+
approved?: IMilestoneCompleted;
|
|
42
|
+
rejected?: IMilestoneCompleted;
|
|
43
|
+
verified?: IMilestoneCompleted[];
|
|
44
|
+
data: {
|
|
45
|
+
title: string;
|
|
46
|
+
description: string;
|
|
47
|
+
endsAt: number;
|
|
48
|
+
type: "milestone";
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
export interface IGrantUpdate extends IAttestationResponse {
|
|
52
|
+
data: {
|
|
53
|
+
text: string;
|
|
54
|
+
title: string;
|
|
55
|
+
type: "grant-update";
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
export interface IGrantDetails extends IAttestationResponse {
|
|
59
|
+
type: "GrantDetails";
|
|
60
|
+
data: {
|
|
61
|
+
title: string;
|
|
62
|
+
amount: string;
|
|
63
|
+
description: string;
|
|
64
|
+
proposalURL: string;
|
|
65
|
+
assetAndChainId?: [Hex, number];
|
|
66
|
+
payoutAddress: Hex;
|
|
67
|
+
questions: {
|
|
68
|
+
type: string;
|
|
69
|
+
query: string;
|
|
70
|
+
explanation: string;
|
|
71
|
+
}[];
|
|
72
|
+
startDate: number;
|
|
73
|
+
type: "grant-details";
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
export interface IGrantResponse extends IAttestationResponse {
|
|
77
|
+
type: "Grant";
|
|
78
|
+
data: {
|
|
79
|
+
communityUID: Hex;
|
|
80
|
+
};
|
|
81
|
+
details?: IGrantDetails;
|
|
82
|
+
milestones: IMilestoneResponse[];
|
|
83
|
+
completed?: IGrantUpdate;
|
|
84
|
+
project: ISummaryProject;
|
|
85
|
+
updates: IGrantUpdate[];
|
|
86
|
+
community: ICommunityResponse;
|
|
87
|
+
members: Hex[];
|
|
88
|
+
categories?: string[];
|
|
89
|
+
}
|
|
90
|
+
export interface IMemberDetails extends IAttestationResponse {
|
|
91
|
+
name: string;
|
|
92
|
+
profilePictureURL: string;
|
|
93
|
+
}
|
|
94
|
+
export interface IMemberOf extends IAttestationResponse {
|
|
95
|
+
type: "MemberOf";
|
|
96
|
+
data: {
|
|
97
|
+
memberOf: true;
|
|
98
|
+
};
|
|
99
|
+
details?: IMemberDetails;
|
|
100
|
+
}
|
|
101
|
+
export interface IProjectDetails extends IAttestationResponse {
|
|
102
|
+
type: "ProjectDetails";
|
|
103
|
+
data: {
|
|
104
|
+
title: string;
|
|
105
|
+
description: string;
|
|
106
|
+
imageURL: string;
|
|
107
|
+
links?: ExternalLink[];
|
|
108
|
+
tags?: ITag[];
|
|
109
|
+
slug?: string;
|
|
110
|
+
type: "project-details";
|
|
111
|
+
};
|
|
112
|
+
}
|
|
113
|
+
export interface IProjectImpact extends IAttestationResponse {
|
|
114
|
+
type: "ProjectImpact";
|
|
115
|
+
data: {
|
|
116
|
+
work: string;
|
|
117
|
+
impact: string;
|
|
118
|
+
proof: string;
|
|
119
|
+
completedAt: number;
|
|
120
|
+
type: "project-impact";
|
|
121
|
+
};
|
|
122
|
+
}
|
|
123
|
+
export interface IProjectEndorsement extends IAttestationResponse {
|
|
124
|
+
type: "ProjectEndorsement";
|
|
125
|
+
data: {
|
|
126
|
+
comment?: string;
|
|
127
|
+
type?: 'project-endorsement';
|
|
128
|
+
};
|
|
129
|
+
}
|
|
130
|
+
export interface IProjectResponse extends IAttestationResponse {
|
|
131
|
+
type: "Project";
|
|
132
|
+
data: {
|
|
133
|
+
project: true;
|
|
134
|
+
};
|
|
135
|
+
details?: IProjectDetails;
|
|
136
|
+
members: IMemberOf[];
|
|
137
|
+
grants: any[];
|
|
138
|
+
grantee: any;
|
|
139
|
+
impacts: IProjectImpact[];
|
|
140
|
+
endorsements: IProjectEndorsement[];
|
|
141
|
+
}
|
|
142
|
+
export interface ICommunityDetails extends IAttestationResponse {
|
|
143
|
+
type: "CommunityDetails";
|
|
144
|
+
data: {
|
|
145
|
+
name: string;
|
|
146
|
+
description: string;
|
|
147
|
+
imageURL: string;
|
|
148
|
+
links: ExternalLink[];
|
|
149
|
+
slug?: string;
|
|
150
|
+
};
|
|
151
|
+
}
|
|
152
|
+
export interface ICommunityResponse extends IAttestationResponse {
|
|
153
|
+
type: "Community";
|
|
154
|
+
data: {
|
|
155
|
+
community: true;
|
|
156
|
+
};
|
|
157
|
+
details?: ICommunityDetails;
|
|
158
|
+
grants: IGrantResponse[];
|
|
159
|
+
}
|