@show-karma/karma-gap-sdk 0.3.28 → 0.3.30
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 +2 -0
- package/core/class/Fetcher.d.ts +9 -0
- package/core/class/GraphQL/GapEasClient.d.ts +4 -0
- package/core/class/GraphQL/GapEasClient.js +3 -0
- package/core/class/Schema.d.ts +4 -2
- package/core/class/Schema.js +12 -3
- package/core/class/contract/GapContract.d.ts +1 -1
- package/core/class/contract/GapContract.js +5 -1
- package/core/class/entities/Community.d.ts +1 -1
- package/core/class/entities/Community.js +5 -1
- package/core/class/entities/Grant.d.ts +3 -3
- package/core/class/entities/Grant.js +6 -6
- package/core/class/entities/GrantUpdate.d.ts +1 -1
- package/core/class/entities/GrantUpdate.js +7 -3
- package/core/class/entities/MemberOf.d.ts +1 -1
- package/core/class/entities/MemberOf.js +2 -2
- package/core/class/entities/Milestone.d.ts +3 -3
- package/core/class/entities/Milestone.js +10 -6
- package/core/class/entities/Project.d.ts +2 -2
- package/core/class/entities/Project.js +6 -6
- package/core/class/entities/ProjectImpact.d.ts +7 -5
- package/core/class/entities/ProjectImpact.js +18 -14
- package/core/class/karma-indexer/GapIndexerClient.d.ts +6 -0
- package/core/class/karma-indexer/GapIndexerClient.js +8 -0
- package/core/class/karma-indexer/api/GapIndexerApi.d.ts +3 -1
- package/core/class/karma-indexer/api/GapIndexerApi.js +16 -0
- package/core/class/karma-indexer/api/types.d.ts +14 -1
- package/core/types.d.ts +1 -0
- package/package.json +1 -1
|
@@ -129,6 +129,7 @@ class Attestation {
|
|
|
129
129
|
* @throws An `AttestationError` if an error occurs during attestation.
|
|
130
130
|
*/
|
|
131
131
|
async attest(signer, ...args) {
|
|
132
|
+
const callback = typeof args[args.length - 1] === 'function' ? args.pop() : null;
|
|
132
133
|
console.log(`Attesting ${this.schema.name}`);
|
|
133
134
|
try {
|
|
134
135
|
const uid = await this.schema.attest({
|
|
@@ -136,6 +137,7 @@ class Attestation {
|
|
|
136
137
|
to: this.recipient,
|
|
137
138
|
refUID: this.refUID,
|
|
138
139
|
signer,
|
|
140
|
+
callback: callback
|
|
139
141
|
});
|
|
140
142
|
this._uid = uid;
|
|
141
143
|
console.log(`Attested ${this.schema.name} with UID ${uid}`);
|
package/core/class/Fetcher.d.ts
CHANGED
|
@@ -91,6 +91,15 @@ export declare abstract class Fetcher extends AxiosGQL {
|
|
|
91
91
|
* @returns
|
|
92
92
|
*/
|
|
93
93
|
abstract projectBySlug(slug: string): Promise<Project>;
|
|
94
|
+
/**
|
|
95
|
+
* Search projects and communities by name. This method will return a list of projects and a list of communities
|
|
96
|
+
* __Must be implemented by the indexer__
|
|
97
|
+
* @param query
|
|
98
|
+
*/
|
|
99
|
+
abstract search(query: string): Promise<{
|
|
100
|
+
projects: Project[];
|
|
101
|
+
communities: Community[];
|
|
102
|
+
}>;
|
|
94
103
|
/**
|
|
95
104
|
* Search projects by name. This method will return a list of projects
|
|
96
105
|
* __Must be implemented by the indexer__
|
|
@@ -45,6 +45,10 @@ export declare class GapEasClient extends Fetcher {
|
|
|
45
45
|
projectById(uid: Hex): Promise<Project>;
|
|
46
46
|
projectBySlug(slug: string): Promise<Project>;
|
|
47
47
|
slugExists(slug: string): Promise<boolean>;
|
|
48
|
+
search(query: string): Promise<{
|
|
49
|
+
projects: Project[];
|
|
50
|
+
communities: Community[];
|
|
51
|
+
}>;
|
|
48
52
|
searchProjects(query: string): Promise<Project[]>;
|
|
49
53
|
projects(name?: string): Promise<Project[]>;
|
|
50
54
|
projectsOf(grantee: Hex): Promise<Project[]>;
|
|
@@ -236,6 +236,9 @@ class GapEasClient extends Fetcher_1.Fetcher {
|
|
|
236
236
|
const { schema: { attestations }, } = await this.query(query);
|
|
237
237
|
return attestations.some((a) => a.decodedDataJson.includes(slug));
|
|
238
238
|
}
|
|
239
|
+
search(query) {
|
|
240
|
+
throw new Error('Method not implemented.');
|
|
241
|
+
}
|
|
239
242
|
searchProjects(query) {
|
|
240
243
|
throw new Error('Method not implemented.');
|
|
241
244
|
}
|
package/core/class/Schema.d.ts
CHANGED
|
@@ -140,14 +140,16 @@ export declare abstract class Schema<T extends string = string> implements Schem
|
|
|
140
140
|
* @param {Object} param0 - An object containing the schema and other optional settings.
|
|
141
141
|
* @returns {Object} An object containing the attestation results, including the CID if 'ipfsKey' is enabled.
|
|
142
142
|
*/
|
|
143
|
-
attest<T>({ data, to, signer, refUID }: AttestArgs<T>
|
|
143
|
+
attest<T>({ data, to, signer, refUID, callback }: AttestArgs<T> & {
|
|
144
|
+
callback?: (status: string) => void;
|
|
145
|
+
}): Promise<Hex>;
|
|
144
146
|
/**
|
|
145
147
|
* Bulk attest a set of attestations.
|
|
146
148
|
* @param signer
|
|
147
149
|
* @param entities
|
|
148
150
|
* @returns
|
|
149
151
|
*/
|
|
150
|
-
multiAttest(signer: SignerOrProvider, entities?: Attestation[]): Promise<string[]>;
|
|
152
|
+
multiAttest(signer: SignerOrProvider, entities?: Attestation[], callback?: Function): Promise<string[]>;
|
|
151
153
|
/**
|
|
152
154
|
* Revokes a set of attestations by their UIDs.
|
|
153
155
|
* @param signer
|
package/core/class/Schema.js
CHANGED
|
@@ -219,7 +219,7 @@ class Schema {
|
|
|
219
219
|
* @param {Object} param0 - An object containing the schema and other optional settings.
|
|
220
220
|
* @returns {Object} An object containing the attestation results, including the CID if 'ipfsKey' is enabled.
|
|
221
221
|
*/
|
|
222
|
-
async attest({ data, to, signer, refUID }) {
|
|
222
|
+
async attest({ data, to, signer, refUID, callback }) {
|
|
223
223
|
const eas = this.gap.eas.connect(signer);
|
|
224
224
|
if (this.references && !refUID)
|
|
225
225
|
throw new SchemaError_1.AttestationError("INVALID_REFERENCE", "Attestation schema references another schema but no reference UID was provided.");
|
|
@@ -263,7 +263,12 @@ class Schema {
|
|
|
263
263
|
schema: this.uid,
|
|
264
264
|
data: payload.data.payload,
|
|
265
265
|
});
|
|
266
|
-
|
|
266
|
+
if (callback)
|
|
267
|
+
callback('pending');
|
|
268
|
+
const txResult = await tx.wait();
|
|
269
|
+
if (callback)
|
|
270
|
+
callback('completed');
|
|
271
|
+
return txResult;
|
|
267
272
|
}
|
|
268
273
|
const uid = await GapContract_1.GapContract.attest(signer, payload);
|
|
269
274
|
return uid;
|
|
@@ -274,7 +279,7 @@ class Schema {
|
|
|
274
279
|
* @param entities
|
|
275
280
|
* @returns
|
|
276
281
|
*/
|
|
277
|
-
async multiAttest(signer, entities = []) {
|
|
282
|
+
async multiAttest(signer, entities = [], callback) {
|
|
278
283
|
entities.forEach((entity) => {
|
|
279
284
|
if (this.references && !entity.refUID)
|
|
280
285
|
throw new SchemaError_1.SchemaError("INVALID_REF_UID", `Entity ${entity.schema.name} references another schema but no reference UID was provided.`);
|
|
@@ -299,7 +304,11 @@ class Schema {
|
|
|
299
304
|
const tx = await eas.multiAttest(payload, {
|
|
300
305
|
gasLimit: 5000000n,
|
|
301
306
|
});
|
|
307
|
+
if (callback)
|
|
308
|
+
callback('pending');
|
|
302
309
|
return tx.wait();
|
|
310
|
+
if (callback)
|
|
311
|
+
callback('completed');
|
|
303
312
|
}
|
|
304
313
|
/**
|
|
305
314
|
* Revokes a set of attestations by their UIDs.
|
|
@@ -37,7 +37,7 @@ export declare class GapContract {
|
|
|
37
37
|
*
|
|
38
38
|
* @returns an array with the attestation UIDs.
|
|
39
39
|
*/
|
|
40
|
-
static multiAttest(signer: SignerOrProvider, payload: RawMultiAttestPayload[]): Promise<Hex[]>;
|
|
40
|
+
static multiAttest(signer: SignerOrProvider, payload: RawMultiAttestPayload[], callback?: Function): Promise<Hex[]>;
|
|
41
41
|
/**
|
|
42
42
|
* Performs a referenced multi attestation.
|
|
43
43
|
*
|
|
@@ -110,13 +110,17 @@ class GapContract {
|
|
|
110
110
|
*
|
|
111
111
|
* @returns an array with the attestation UIDs.
|
|
112
112
|
*/
|
|
113
|
-
static async multiAttest(signer, payload) {
|
|
113
|
+
static async multiAttest(signer, payload, callback) {
|
|
114
114
|
const contract = await GAP_1.GAP.getMulticall(signer);
|
|
115
115
|
if (GAP_1.GAP.gelatoOpts?.useGasless) {
|
|
116
116
|
return this.multiAttestBySig(signer, payload);
|
|
117
117
|
}
|
|
118
118
|
const tx = await contract.multiSequentialAttest(payload.map((p) => p.payload));
|
|
119
|
+
if (callback)
|
|
120
|
+
callback('pending');
|
|
119
121
|
const result = await tx.wait?.();
|
|
122
|
+
if (callback)
|
|
123
|
+
callback('completed');
|
|
120
124
|
const attestations = (0, eas_sdk_1.getUIDsFromAttestReceipt)(result);
|
|
121
125
|
return attestations;
|
|
122
126
|
}
|
|
@@ -29,6 +29,6 @@ export declare class Community extends Attestation<ICommunity> {
|
|
|
29
29
|
* @param signer
|
|
30
30
|
* @param details
|
|
31
31
|
*/
|
|
32
|
-
attest(signer: SignerOrProvider, details?: ICommunityDetails): Promise<void>;
|
|
32
|
+
attest(signer: SignerOrProvider, details?: ICommunityDetails, callback?: Function): Promise<void>;
|
|
33
33
|
static from(attestations: ICommunityResponse[], network: TNetwork): Community[];
|
|
34
34
|
}
|
|
@@ -40,7 +40,7 @@ class Community extends Attestation_1.Attestation {
|
|
|
40
40
|
* @param signer
|
|
41
41
|
* @param details
|
|
42
42
|
*/
|
|
43
|
-
async attest(signer, details) {
|
|
43
|
+
async attest(signer, details, callback) {
|
|
44
44
|
console.log('Attesting community');
|
|
45
45
|
try {
|
|
46
46
|
this._uid = await this.schema.attest({
|
|
@@ -50,6 +50,8 @@ class Community extends Attestation_1.Attestation {
|
|
|
50
50
|
data: this.data,
|
|
51
51
|
});
|
|
52
52
|
console.log(this.uid);
|
|
53
|
+
if (callback)
|
|
54
|
+
callback('pending');
|
|
53
55
|
if (details) {
|
|
54
56
|
const communityDetails = new attestations_1.CommunityDetails({
|
|
55
57
|
data: details,
|
|
@@ -59,6 +61,8 @@ class Community extends Attestation_1.Attestation {
|
|
|
59
61
|
});
|
|
60
62
|
await communityDetails.attest(signer);
|
|
61
63
|
}
|
|
64
|
+
if (callback)
|
|
65
|
+
callback('completed');
|
|
62
66
|
}
|
|
63
67
|
catch (error) {
|
|
64
68
|
console.error(error);
|
|
@@ -48,9 +48,9 @@ export declare class Grant extends Attestation<IGrant> {
|
|
|
48
48
|
/**
|
|
49
49
|
* @inheritdoc
|
|
50
50
|
*/
|
|
51
|
-
attest(signer: SignerOrProvider, projectChainId: number): Promise<void>;
|
|
52
|
-
attestUpdate(signer: SignerOrProvider, data: IGrantUpdate): Promise<void>;
|
|
53
|
-
complete(signer: SignerOrProvider, data: IGrantUpdate): Promise<void>;
|
|
51
|
+
attest(signer: SignerOrProvider, projectChainId: number, callback?: Function): Promise<void>;
|
|
52
|
+
attestUpdate(signer: SignerOrProvider, data: IGrantUpdate, callback?: Function): Promise<void>;
|
|
53
|
+
complete(signer: SignerOrProvider, data: IGrantUpdate, callback?: Function): Promise<void>;
|
|
54
54
|
/**
|
|
55
55
|
* Validate if the grant has a valid reference to a community.
|
|
56
56
|
*/
|
|
@@ -111,19 +111,19 @@ class Grant extends Attestation_1.Attestation {
|
|
|
111
111
|
/**
|
|
112
112
|
* @inheritdoc
|
|
113
113
|
*/
|
|
114
|
-
async attest(signer, projectChainId) {
|
|
114
|
+
async attest(signer, projectChainId, callback) {
|
|
115
115
|
if (projectChainId !== this.chainID) {
|
|
116
116
|
return this.attestProject(signer, projectChainId);
|
|
117
117
|
}
|
|
118
118
|
this.assertPayload();
|
|
119
119
|
const payload = await this.multiAttestPayload();
|
|
120
|
-
const uids = await GapContract_1.GapContract.multiAttest(signer, payload.map((p) => p[1]));
|
|
120
|
+
const uids = await GapContract_1.GapContract.multiAttest(signer, payload.map((p) => p[1]), callback);
|
|
121
121
|
uids.forEach((uid, index) => {
|
|
122
122
|
payload[index][0].uid = uid;
|
|
123
123
|
});
|
|
124
124
|
console.log(uids);
|
|
125
125
|
}
|
|
126
|
-
async attestUpdate(signer, data) {
|
|
126
|
+
async attestUpdate(signer, data, callback) {
|
|
127
127
|
const grantUpdate = new GrantUpdate_1.GrantUpdate({
|
|
128
128
|
data: {
|
|
129
129
|
...data,
|
|
@@ -133,10 +133,10 @@ class Grant extends Attestation_1.Attestation {
|
|
|
133
133
|
refUID: this.uid,
|
|
134
134
|
schema: this.schema.gap.findSchema('GrantDetails'),
|
|
135
135
|
});
|
|
136
|
-
await grantUpdate.attest(signer);
|
|
136
|
+
await grantUpdate.attest(signer, callback);
|
|
137
137
|
this.updates.push(grantUpdate);
|
|
138
138
|
}
|
|
139
|
-
async complete(signer, data) {
|
|
139
|
+
async complete(signer, data, callback) {
|
|
140
140
|
const completed = new attestations_1.GrantCompleted({
|
|
141
141
|
data: {
|
|
142
142
|
...data,
|
|
@@ -146,7 +146,7 @@ class Grant extends Attestation_1.Attestation {
|
|
|
146
146
|
refUID: this.uid,
|
|
147
147
|
schema: this.schema.gap.findSchema('GrantDetails'),
|
|
148
148
|
});
|
|
149
|
-
await completed.attest(signer);
|
|
149
|
+
await completed.attest(signer, callback);
|
|
150
150
|
this.completed = completed;
|
|
151
151
|
}
|
|
152
152
|
/**
|
|
@@ -30,7 +30,7 @@ export declare class GrantUpdate extends Attestation<IGrantUpdate> implements IG
|
|
|
30
30
|
* @param signer
|
|
31
31
|
* @param reason
|
|
32
32
|
*/
|
|
33
|
-
verify(signer: SignerOrProvider, reason?: string): Promise<void>;
|
|
33
|
+
verify(signer: SignerOrProvider, reason?: string, callback?: Function): Promise<void>;
|
|
34
34
|
static from(attestations: _IGrantUpdate[], network: TNetwork): GrantUpdate[];
|
|
35
35
|
}
|
|
36
36
|
export {};
|
|
@@ -16,7 +16,7 @@ class GrantUpdate extends Attestation_1.Attestation {
|
|
|
16
16
|
/**
|
|
17
17
|
* Attest the status of the milestone as approved, rejected or completed.
|
|
18
18
|
*/
|
|
19
|
-
async attestStatus(signer, schema) {
|
|
19
|
+
async attestStatus(signer, schema, callback) {
|
|
20
20
|
const eas = this.schema.gap.eas.connect(signer);
|
|
21
21
|
try {
|
|
22
22
|
const tx = await eas.attest({
|
|
@@ -29,7 +29,11 @@ class GrantUpdate extends Attestation_1.Attestation {
|
|
|
29
29
|
revocable: schema.revocable,
|
|
30
30
|
},
|
|
31
31
|
});
|
|
32
|
+
if (callback)
|
|
33
|
+
callback('pending');
|
|
32
34
|
const uid = await tx.wait();
|
|
35
|
+
if (callback)
|
|
36
|
+
callback('completed');
|
|
33
37
|
console.log(uid);
|
|
34
38
|
}
|
|
35
39
|
catch (error) {
|
|
@@ -43,13 +47,13 @@ class GrantUpdate extends Attestation_1.Attestation {
|
|
|
43
47
|
* @param signer
|
|
44
48
|
* @param reason
|
|
45
49
|
*/
|
|
46
|
-
async verify(signer, reason = '') {
|
|
50
|
+
async verify(signer, reason = '', callback) {
|
|
47
51
|
console.log('Verifying');
|
|
48
52
|
const schema = this.schema.gap.findSchema('GrantUpdateStatus');
|
|
49
53
|
schema.setValue('type', 'grant-update-verified');
|
|
50
54
|
schema.setValue('reason', reason);
|
|
51
55
|
console.log('Before attest grant update verified');
|
|
52
|
-
await this.attestStatus(signer, schema);
|
|
56
|
+
await this.attestStatus(signer, schema, callback);
|
|
53
57
|
console.log('After attest grant update verified');
|
|
54
58
|
this.verified.push(new GrantUpdateStatus({
|
|
55
59
|
data: {
|
|
@@ -7,5 +7,5 @@ export interface IMemberOf {
|
|
|
7
7
|
export declare class MemberOf extends Attestation<IMemberOf> {
|
|
8
8
|
details?: MemberDetails;
|
|
9
9
|
multiAttestPayload(currentPayload?: MultiAttestPayload, projectIdx?: number): Promise<[Attestation<unknown, import("core").GapSchema>, import("core/types").RawMultiAttestPayload][]>;
|
|
10
|
-
attest(signer: SignerOrProvider): Promise<void>;
|
|
10
|
+
attest(signer: SignerOrProvider, callback?: Function): Promise<void>;
|
|
11
11
|
}
|
|
@@ -13,10 +13,10 @@ class MemberOf extends Attestation_1.Attestation {
|
|
|
13
13
|
}
|
|
14
14
|
return payload.slice(currentPayload.length, payload.length);
|
|
15
15
|
}
|
|
16
|
-
async attest(signer) {
|
|
16
|
+
async attest(signer, callback) {
|
|
17
17
|
const payload = await this.multiAttestPayload();
|
|
18
18
|
try {
|
|
19
|
-
const [memberUID, detailsUID] = await GapContract_1.GapContract.multiAttest(signer, payload.map((p) => p[1]));
|
|
19
|
+
const [memberUID, detailsUID] = await GapContract_1.GapContract.multiAttest(signer, payload.map((p) => p[1]), callback);
|
|
20
20
|
this.uid = memberUID;
|
|
21
21
|
if (this.details && detailsUID) {
|
|
22
22
|
this.details.uid = detailsUID;
|
|
@@ -26,7 +26,7 @@ export declare class Milestone extends Attestation<IMilestone> implements IMiles
|
|
|
26
26
|
* @param signer
|
|
27
27
|
* @param reason
|
|
28
28
|
*/
|
|
29
|
-
approve(signer: SignerOrProvider, reason?: string): Promise<void>;
|
|
29
|
+
approve(signer: SignerOrProvider, reason?: string, callback?: Function): Promise<void>;
|
|
30
30
|
/**
|
|
31
31
|
* Revokes the approved status of the milestone. If the milestone is not approved,
|
|
32
32
|
* it will throw an error.
|
|
@@ -73,7 +73,7 @@ export declare class Milestone extends Attestation<IMilestone> implements IMiles
|
|
|
73
73
|
/**
|
|
74
74
|
* @inheritdoc
|
|
75
75
|
*/
|
|
76
|
-
attest(signer: SignerOrProvider): Promise<void>;
|
|
76
|
+
attest(signer: SignerOrProvider, callback?: Function): Promise<void>;
|
|
77
77
|
/**
|
|
78
78
|
* Attest the status of the milestone as approved, rejected or completed.
|
|
79
79
|
*/
|
|
@@ -85,5 +85,5 @@ export declare class Milestone extends Attestation<IMilestone> implements IMiles
|
|
|
85
85
|
* @param signer
|
|
86
86
|
* @param reason
|
|
87
87
|
*/
|
|
88
|
-
verify(signer: SignerOrProvider, reason?: string): Promise<void>;
|
|
88
|
+
verify(signer: SignerOrProvider, reason?: string, callback?: Function): Promise<void>;
|
|
89
89
|
}
|
|
@@ -19,7 +19,7 @@ class Milestone extends Attestation_1.Attestation {
|
|
|
19
19
|
* @param signer
|
|
20
20
|
* @param reason
|
|
21
21
|
*/
|
|
22
|
-
async approve(signer, reason = '') {
|
|
22
|
+
async approve(signer, reason = '', callback) {
|
|
23
23
|
if (!this.completed)
|
|
24
24
|
throw new SchemaError_1.AttestationError('ATTEST_ERROR', 'Milestone is not completed');
|
|
25
25
|
const schema = this.schema.gap.findSchema('MilestoneCompleted');
|
|
@@ -158,10 +158,10 @@ class Milestone extends Attestation_1.Attestation {
|
|
|
158
158
|
/**
|
|
159
159
|
* @inheritdoc
|
|
160
160
|
*/
|
|
161
|
-
async attest(signer) {
|
|
161
|
+
async attest(signer, callback) {
|
|
162
162
|
this.assertPayload();
|
|
163
163
|
const payload = await this.multiAttestPayload();
|
|
164
|
-
const uids = await GapContract_1.GapContract.multiAttest(signer, payload.map((p) => p[1]));
|
|
164
|
+
const uids = await GapContract_1.GapContract.multiAttest(signer, payload.map((p) => p[1]), callback);
|
|
165
165
|
uids.forEach((uid, index) => {
|
|
166
166
|
payload[index][0].uid = uid;
|
|
167
167
|
});
|
|
@@ -170,7 +170,7 @@ class Milestone extends Attestation_1.Attestation {
|
|
|
170
170
|
/**
|
|
171
171
|
* Attest the status of the milestone as approved, rejected or completed.
|
|
172
172
|
*/
|
|
173
|
-
async attestStatus(signer, schema) {
|
|
173
|
+
async attestStatus(signer, schema, callback) {
|
|
174
174
|
const eas = this.schema.gap.eas.connect(signer);
|
|
175
175
|
try {
|
|
176
176
|
const tx = await eas.attest({
|
|
@@ -183,7 +183,11 @@ class Milestone extends Attestation_1.Attestation {
|
|
|
183
183
|
revocable: schema.revocable,
|
|
184
184
|
},
|
|
185
185
|
});
|
|
186
|
+
if (callback)
|
|
187
|
+
callback('pending');
|
|
186
188
|
const uid = await tx.wait();
|
|
189
|
+
if (callback)
|
|
190
|
+
callback('completed');
|
|
187
191
|
console.log(uid);
|
|
188
192
|
}
|
|
189
193
|
catch (error) {
|
|
@@ -250,7 +254,7 @@ class Milestone extends Attestation_1.Attestation {
|
|
|
250
254
|
* @param signer
|
|
251
255
|
* @param reason
|
|
252
256
|
*/
|
|
253
|
-
async verify(signer, reason = '') {
|
|
257
|
+
async verify(signer, reason = '', callback) {
|
|
254
258
|
console.log('Verifying');
|
|
255
259
|
if (!this.completed)
|
|
256
260
|
throw new SchemaError_1.AttestationError('ATTEST_ERROR', 'Milestone is not completed');
|
|
@@ -258,7 +262,7 @@ class Milestone extends Attestation_1.Attestation {
|
|
|
258
262
|
schema.setValue('type', 'verified');
|
|
259
263
|
schema.setValue('reason', reason);
|
|
260
264
|
console.log('Before attestStatus');
|
|
261
|
-
await this.attestStatus(signer, schema);
|
|
265
|
+
await this.attestStatus(signer, schema, callback);
|
|
262
266
|
console.log('After attestStatus');
|
|
263
267
|
this.verified.push(new attestations_1.MilestoneCompleted({
|
|
264
268
|
data: {
|
|
@@ -26,7 +26,7 @@ export declare class Project extends Attestation<IProject> {
|
|
|
26
26
|
* @param communityIdx
|
|
27
27
|
*/
|
|
28
28
|
multiAttestPayload(currentPayload?: MultiAttestPayload, communityIdx?: number): Promise<MultiAttestPayload>;
|
|
29
|
-
attest(signer: SignerOrProvider): Promise<void>;
|
|
29
|
+
attest(signer: SignerOrProvider, callback?: Function): Promise<void>;
|
|
30
30
|
transferOwnership(signer: SignerOrProvider, newOwner: Hex): Promise<void>;
|
|
31
31
|
isOwner(signer: SignerOrProvider): Promise<boolean>;
|
|
32
32
|
/**
|
|
@@ -45,7 +45,7 @@ export declare class Project extends Attestation<IProject> {
|
|
|
45
45
|
* @param signer
|
|
46
46
|
* @param members
|
|
47
47
|
*/
|
|
48
|
-
attestMembers(signer: SignerOrProvider, members: MemberDetails[]): Promise<void>;
|
|
48
|
+
attestMembers(signer: SignerOrProvider, members: MemberDetails[], callback?: Function): Promise<void>;
|
|
49
49
|
/**
|
|
50
50
|
* Add new details to the members of a project. Note that it will overwrite
|
|
51
51
|
* any existing details.
|
|
@@ -43,9 +43,9 @@ class Project extends Attestation_1.Attestation {
|
|
|
43
43
|
}
|
|
44
44
|
return payload.slice(currentPayload.length, payload.length);
|
|
45
45
|
}
|
|
46
|
-
async attest(signer) {
|
|
46
|
+
async attest(signer, callback) {
|
|
47
47
|
const payload = await this.multiAttestPayload();
|
|
48
|
-
const uids = await GapContract_1.GapContract.multiAttest(signer, payload.map((p) => p[1]));
|
|
48
|
+
const uids = await GapContract_1.GapContract.multiAttest(signer, payload.map((p) => p[1]), callback);
|
|
49
49
|
uids.forEach((uid, index) => {
|
|
50
50
|
payload[index][0].uid = uid;
|
|
51
51
|
});
|
|
@@ -80,7 +80,7 @@ class Project extends Attestation_1.Attestation {
|
|
|
80
80
|
* @param signer
|
|
81
81
|
* @param members
|
|
82
82
|
*/
|
|
83
|
-
async attestMembers(signer, members) {
|
|
83
|
+
async attestMembers(signer, members, callback) {
|
|
84
84
|
const newMembers = (0, utils_1.mapFilter)(members, (member) => !this.members.find((m) => m.recipient === member.recipient),
|
|
85
85
|
// (member) => !!member,
|
|
86
86
|
(details) => {
|
|
@@ -98,7 +98,7 @@ class Project extends Attestation_1.Attestation {
|
|
|
98
98
|
throw new SchemaError_1.AttestationError('ATTEST_ERROR', 'No new members to add.');
|
|
99
99
|
}
|
|
100
100
|
console.log(`Creating ${newMembers.length} new members`);
|
|
101
|
-
const attestedMembers = await this.schema.multiAttest(signer, newMembers.map((m) => m.member));
|
|
101
|
+
const attestedMembers = await this.schema.multiAttest(signer, newMembers.map((m) => m.member), callback);
|
|
102
102
|
console.log('attested-members', attestedMembers);
|
|
103
103
|
newMembers.forEach(({ member, details }, idx) => {
|
|
104
104
|
Object.assign(member, { uid: attestedMembers[idx] });
|
|
@@ -116,7 +116,7 @@ class Project extends Attestation_1.Attestation {
|
|
|
116
116
|
* @param signer
|
|
117
117
|
* @param entities
|
|
118
118
|
*/
|
|
119
|
-
async addMemberDetails(signer, entities) {
|
|
119
|
+
async addMemberDetails(signer, entities, callback) {
|
|
120
120
|
// Check if any of members should be revoked (details modified)
|
|
121
121
|
const toRevoke = (0, utils_1.mapFilter)(this.members, (member) => !!entities.find((entity) => member.uid === entity.refUID &&
|
|
122
122
|
member.details &&
|
|
@@ -126,7 +126,7 @@ class Project extends Attestation_1.Attestation {
|
|
|
126
126
|
await this.cleanDetails(signer, toRevoke);
|
|
127
127
|
}
|
|
128
128
|
console.log(`Creating ${entities.length} new member details`);
|
|
129
|
-
const attestedEntities = (await this.schema.multiAttest(signer, entities));
|
|
129
|
+
const attestedEntities = (await this.schema.multiAttest(signer, entities, callback));
|
|
130
130
|
console.log('attested-entities', attestedEntities);
|
|
131
131
|
entities.forEach((entity, idx) => {
|
|
132
132
|
const member = this.members.find((member) => member.uid === entity.refUID);
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { SignerOrProvider, TNetwork } from
|
|
2
|
-
import { Attestation, AttestationArgs } from
|
|
3
|
-
import { GapSchema } from
|
|
1
|
+
import { SignerOrProvider, TNetwork } from "../../types";
|
|
2
|
+
import { Attestation, AttestationArgs } from "../Attestation";
|
|
3
|
+
import { GapSchema } from "../GapSchema";
|
|
4
4
|
export interface _IProjectImpact extends ProjectImpact {
|
|
5
5
|
}
|
|
6
|
-
type IStatus =
|
|
6
|
+
type IStatus = "verified";
|
|
7
7
|
export interface IProjectImpactStatus {
|
|
8
8
|
type: `project-impact-${IStatus}`;
|
|
9
9
|
reason?: string;
|
|
@@ -16,6 +16,7 @@ export interface IProjectImpact {
|
|
|
16
16
|
work: string;
|
|
17
17
|
impact: string;
|
|
18
18
|
proof: string;
|
|
19
|
+
startedAt?: number;
|
|
19
20
|
completedAt: number;
|
|
20
21
|
type?: string;
|
|
21
22
|
}
|
|
@@ -23,6 +24,7 @@ export declare class ProjectImpact extends Attestation<IProjectImpact> implement
|
|
|
23
24
|
work: string;
|
|
24
25
|
impact: string;
|
|
25
26
|
proof: string;
|
|
27
|
+
startedAt?: number;
|
|
26
28
|
completedAt: number;
|
|
27
29
|
type?: string;
|
|
28
30
|
verified: ProjectImpactStatus[];
|
|
@@ -37,7 +39,7 @@ export declare class ProjectImpact extends Attestation<IProjectImpact> implement
|
|
|
37
39
|
* @param signer
|
|
38
40
|
* @param reason
|
|
39
41
|
*/
|
|
40
|
-
verify(signer: SignerOrProvider, reason?: string): Promise<void>;
|
|
42
|
+
verify(signer: SignerOrProvider, reason?: string, callback?: Function): Promise<void>;
|
|
41
43
|
static from(attestations: ProjectImpact[], network: TNetwork): ProjectImpact[];
|
|
42
44
|
}
|
|
43
45
|
export {};
|
|
@@ -17,7 +17,7 @@ class ProjectImpact extends Attestation_1.Attestation {
|
|
|
17
17
|
/**
|
|
18
18
|
* Attest Project Impact.
|
|
19
19
|
*/
|
|
20
|
-
async attestStatus(signer, schema) {
|
|
20
|
+
async attestStatus(signer, schema, callback) {
|
|
21
21
|
const eas = this.schema.gap.eas.connect(signer);
|
|
22
22
|
try {
|
|
23
23
|
const tx = await eas.attest({
|
|
@@ -30,12 +30,16 @@ class ProjectImpact extends Attestation_1.Attestation {
|
|
|
30
30
|
revocable: schema.revocable,
|
|
31
31
|
},
|
|
32
32
|
});
|
|
33
|
+
if (callback)
|
|
34
|
+
callback("pending");
|
|
33
35
|
const uid = await tx.wait();
|
|
36
|
+
if (callback)
|
|
37
|
+
callback("completed");
|
|
34
38
|
console.log(uid);
|
|
35
39
|
}
|
|
36
40
|
catch (error) {
|
|
37
41
|
console.error(error);
|
|
38
|
-
throw new SchemaError_1.AttestationError(
|
|
42
|
+
throw new SchemaError_1.AttestationError("ATTEST_ERROR", error.message);
|
|
39
43
|
}
|
|
40
44
|
}
|
|
41
45
|
/**
|
|
@@ -44,17 +48,17 @@ class ProjectImpact extends Attestation_1.Attestation {
|
|
|
44
48
|
* @param signer
|
|
45
49
|
* @param reason
|
|
46
50
|
*/
|
|
47
|
-
async verify(signer, reason =
|
|
48
|
-
console.log(
|
|
49
|
-
const schema = this.schema.gap.findSchema(
|
|
50
|
-
schema.setValue(
|
|
51
|
-
schema.setValue(
|
|
52
|
-
console.log(
|
|
53
|
-
await this.attestStatus(signer, schema);
|
|
54
|
-
console.log(
|
|
51
|
+
async verify(signer, reason = "", callback) {
|
|
52
|
+
console.log("Verifying ProjectImpact");
|
|
53
|
+
const schema = this.schema.gap.findSchema("GrantUpdateStatus");
|
|
54
|
+
schema.setValue("type", "project-impact-verified");
|
|
55
|
+
schema.setValue("reason", reason);
|
|
56
|
+
console.log("Before attest project impact verified");
|
|
57
|
+
await this.attestStatus(signer, schema, callback);
|
|
58
|
+
console.log("After attest project impact verified");
|
|
55
59
|
this.verified.push(new ProjectImpactStatus({
|
|
56
60
|
data: {
|
|
57
|
-
type:
|
|
61
|
+
type: "project-impact-verified",
|
|
58
62
|
reason,
|
|
59
63
|
},
|
|
60
64
|
refUID: this.uid,
|
|
@@ -69,16 +73,16 @@ class ProjectImpact extends Attestation_1.Attestation {
|
|
|
69
73
|
data: {
|
|
70
74
|
...attestation.data,
|
|
71
75
|
},
|
|
72
|
-
schema: new AllGapSchemas_1.AllGapSchemas().findSchema(
|
|
76
|
+
schema: new AllGapSchemas_1.AllGapSchemas().findSchema("ProjectImpact", consts_1.chainIdToNetwork[attestation.chainID]),
|
|
73
77
|
chainID: attestation.chainID,
|
|
74
78
|
});
|
|
75
79
|
if (attestation.verified?.length > 0) {
|
|
76
|
-
projectImpact.verified = attestation.verified.map(m => new ProjectImpactStatus({
|
|
80
|
+
projectImpact.verified = attestation.verified.map((m) => new ProjectImpactStatus({
|
|
77
81
|
...m,
|
|
78
82
|
data: {
|
|
79
83
|
...m.data,
|
|
80
84
|
},
|
|
81
|
-
schema: new AllGapSchemas_1.AllGapSchemas().findSchema(
|
|
85
|
+
schema: new AllGapSchemas_1.AllGapSchemas().findSchema("GrantUpdateStatus", consts_1.chainIdToNetwork[attestation.chainID]),
|
|
82
86
|
chainID: attestation.chainID,
|
|
83
87
|
}));
|
|
84
88
|
}
|
|
@@ -4,6 +4,7 @@ import { GapSchema } from '../GapSchema';
|
|
|
4
4
|
import { Fetcher } from '../Fetcher';
|
|
5
5
|
import { Community, Project, Grant, Milestone, MemberOf } from '../entities';
|
|
6
6
|
import { Grantee } from '../types/attestations';
|
|
7
|
+
import { ICommunityAdminsResponse } from './api/types';
|
|
7
8
|
export declare class GapIndexerClient extends Fetcher {
|
|
8
9
|
private apiClient;
|
|
9
10
|
constructor(params: any);
|
|
@@ -18,8 +19,13 @@ export declare class GapIndexerClient extends Fetcher {
|
|
|
18
19
|
communitiesByIds(uids: `0x${string}`[]): Promise<Community[]>;
|
|
19
20
|
communityBySlug(slug: string): Promise<Community>;
|
|
20
21
|
communityById(uid: `0x${string}`): Promise<Community>;
|
|
22
|
+
communityAdmins(uid: `0x${string}`): Promise<ICommunityAdminsResponse>;
|
|
21
23
|
projectBySlug(slug: string): Promise<Project>;
|
|
22
24
|
projectById(uid: `0x${string}`): Promise<Project>;
|
|
25
|
+
search(query: string): Promise<{
|
|
26
|
+
projects: Project[];
|
|
27
|
+
communities: Community[];
|
|
28
|
+
}>;
|
|
23
29
|
searchProjects(query: string): Promise<Project[]>;
|
|
24
30
|
projects(name?: string): Promise<Project[]>;
|
|
25
31
|
projectsOf(grantee: `0x${string}`): Promise<Project[]>;
|
|
@@ -85,6 +85,10 @@ class GapIndexerClient extends Fetcher_1.Fetcher {
|
|
|
85
85
|
communityById(uid) {
|
|
86
86
|
return this.communityBySlug(uid);
|
|
87
87
|
}
|
|
88
|
+
async communityAdmins(uid) {
|
|
89
|
+
const { data } = await this.apiClient.communityAdmins(uid);
|
|
90
|
+
return data;
|
|
91
|
+
}
|
|
88
92
|
async projectBySlug(slug) {
|
|
89
93
|
const { data } = await this.apiClient.projectBySlug(slug);
|
|
90
94
|
return entities_1.Project.from([data], this.gap.network)[0];
|
|
@@ -92,6 +96,10 @@ class GapIndexerClient extends Fetcher_1.Fetcher {
|
|
|
92
96
|
projectById(uid) {
|
|
93
97
|
return this.projectBySlug(uid);
|
|
94
98
|
}
|
|
99
|
+
async search(query) {
|
|
100
|
+
const { data } = await this.apiClient.search(query);
|
|
101
|
+
return { data };
|
|
102
|
+
}
|
|
95
103
|
async searchProjects(query) {
|
|
96
104
|
const { data } = await this.apiClient.searchProjects(query);
|
|
97
105
|
return entities_1.Project.from(data, this.gap.network);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { AxiosGQL } from "../../GraphQL/AxiosGQL";
|
|
2
|
-
import { Hex, IAttestationResponse, ICommunityResponse, IGrantResponse, IProjectResponse } from "./types";
|
|
2
|
+
import { Hex, IAttestationResponse, ICommunityResponse, ICommunityAdminsResponse, IGrantResponse, IProjectResponse, ISearchResponse } from "./types";
|
|
3
3
|
export declare class GapIndexerApi extends AxiosGQL {
|
|
4
4
|
constructor(url: string);
|
|
5
5
|
attestation(uid: Hex): Promise<import("axios").AxiosResponse<IAttestationResponse, any>>;
|
|
@@ -12,10 +12,12 @@ export declare class GapIndexerApi extends AxiosGQL {
|
|
|
12
12
|
communitiesOf(address: Hex, withGrants: boolean): Promise<import("axios").AxiosResponse<ICommunityResponse[], any>>;
|
|
13
13
|
adminOf(address: Hex): Promise<import("axios").AxiosResponse<ICommunityResponse[], any>>;
|
|
14
14
|
communityBySlug(slug: string): Promise<import("axios").AxiosResponse<ICommunityResponse, any>>;
|
|
15
|
+
communityAdmins(uid: Hex): Promise<import("axios").AxiosResponse<ICommunityAdminsResponse, any>>;
|
|
15
16
|
/**
|
|
16
17
|
* Project
|
|
17
18
|
*/
|
|
18
19
|
projectBySlug(slug: string): Promise<import("axios").AxiosResponse<IProjectResponse, any>>;
|
|
20
|
+
search(query: string): Promise<import("axios").AxiosResponse<ISearchResponse, any>>;
|
|
19
21
|
searchProjects(query: string): Promise<import("axios").AxiosResponse<IProjectResponse[], any>>;
|
|
20
22
|
projects(name?: string): Promise<import("axios").AxiosResponse<IProjectResponse[], any>>;
|
|
21
23
|
projectsOf(grantee: Hex): Promise<import("axios").AxiosResponse<IProjectResponse[], any>>;
|
|
@@ -9,6 +9,7 @@ const Endpoints = {
|
|
|
9
9
|
},
|
|
10
10
|
communities: {
|
|
11
11
|
all: () => "/communities",
|
|
12
|
+
admins: (uid) => `/communities/${uid}/admins`,
|
|
12
13
|
byUidOrSlug: (uidOrSlug) => `/communities/${uidOrSlug}`,
|
|
13
14
|
grants: (uidOrSlug) => `/communities/${uidOrSlug}/grants`,
|
|
14
15
|
},
|
|
@@ -31,6 +32,9 @@ const Endpoints = {
|
|
|
31
32
|
grants: (uidOrSlug) => `/projects/${uidOrSlug}/grants`,
|
|
32
33
|
milestones: (uidOrSlug) => `/projects/${uidOrSlug}/milestones`,
|
|
33
34
|
},
|
|
35
|
+
search: {
|
|
36
|
+
all: () => "/search",
|
|
37
|
+
},
|
|
34
38
|
};
|
|
35
39
|
class GapIndexerApi extends AxiosGQL_1.AxiosGQL {
|
|
36
40
|
constructor(url) {
|
|
@@ -81,6 +85,10 @@ class GapIndexerApi extends AxiosGQL_1.AxiosGQL {
|
|
|
81
85
|
const response = await this.client.get(Endpoints.communities.byUidOrSlug(slug));
|
|
82
86
|
return response;
|
|
83
87
|
}
|
|
88
|
+
async communityAdmins(uid) {
|
|
89
|
+
const response = await this.client.get(Endpoints.communities.admins(uid));
|
|
90
|
+
return response;
|
|
91
|
+
}
|
|
84
92
|
/**
|
|
85
93
|
* Project
|
|
86
94
|
*/
|
|
@@ -88,6 +96,14 @@ class GapIndexerApi extends AxiosGQL_1.AxiosGQL {
|
|
|
88
96
|
const response = await this.client.get(Endpoints.project.byUidOrSlug(slug));
|
|
89
97
|
return response;
|
|
90
98
|
}
|
|
99
|
+
async search(query) {
|
|
100
|
+
const response = await this.client.get(Endpoints.search.all(), {
|
|
101
|
+
params: {
|
|
102
|
+
q: query,
|
|
103
|
+
},
|
|
104
|
+
});
|
|
105
|
+
return response;
|
|
106
|
+
}
|
|
91
107
|
async searchProjects(query) {
|
|
92
108
|
const response = await this.client.get(Endpoints.project.all(), {
|
|
93
109
|
params: {
|
|
@@ -116,6 +116,7 @@ export interface IProjectImpact extends IAttestationResponse {
|
|
|
116
116
|
work: string;
|
|
117
117
|
impact: string;
|
|
118
118
|
proof: string;
|
|
119
|
+
startedAt?: number;
|
|
119
120
|
completedAt: number;
|
|
120
121
|
type: "project-impact";
|
|
121
122
|
};
|
|
@@ -124,7 +125,7 @@ export interface IProjectEndorsement extends IAttestationResponse {
|
|
|
124
125
|
type: "ProjectEndorsement";
|
|
125
126
|
data: {
|
|
126
127
|
comment?: string;
|
|
127
|
-
type?:
|
|
128
|
+
type?: "project-endorsement";
|
|
128
129
|
};
|
|
129
130
|
}
|
|
130
131
|
export interface IProjectResponse extends IAttestationResponse {
|
|
@@ -157,3 +158,15 @@ export interface ICommunityResponse extends IAttestationResponse {
|
|
|
157
158
|
details?: ICommunityDetails;
|
|
158
159
|
grants: IGrantResponse[];
|
|
159
160
|
}
|
|
161
|
+
export interface ICommunityAdminsResponse {
|
|
162
|
+
id: string;
|
|
163
|
+
admins: {
|
|
164
|
+
user: {
|
|
165
|
+
id: string;
|
|
166
|
+
};
|
|
167
|
+
}[];
|
|
168
|
+
}
|
|
169
|
+
export interface ISearchResponse {
|
|
170
|
+
projects: IProjectResponse[];
|
|
171
|
+
communities: ICommunityResponse[];
|
|
172
|
+
}
|
package/core/types.d.ts
CHANGED
|
@@ -20,6 +20,7 @@ export interface AttestArgs<T = unknown> {
|
|
|
20
20
|
data: T;
|
|
21
21
|
refUID?: Hex;
|
|
22
22
|
signer: SignerOrProvider;
|
|
23
|
+
callback?: SignerOrProvider;
|
|
23
24
|
}
|
|
24
25
|
export type TSchemaName = "Community" | "CommunityDetails" | "Grant" | "GrantDetails" | "GrantVerified" | "MemberOf" | "MemberDetails" | "Milestone" | "MilestoneCompleted" | "MilestoneApproved" | "Project" | "ProjectDetails" | "Details" | "ProjectImpact" | "GrantUpdate" | "GrantUpdateStatus" | "ProjectEndorsement";
|
|
25
26
|
export type TResolvedSchemaNames = "Community" | "Grant" | "GrantVerified" | "MemberOf" | "MilestoneCompleted" | "MilestoneApproved" | "Project" | "Details" | "GrantUpdateStatus";
|