@show-karma/karma-gap-sdk 0.3.43 → 0.3.45
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/abi/AirdropNFT.json +622 -0
- package/core/abi/Donations.json +260 -0
- package/core/abi/EAS.json +1 -0
- package/core/abi/SchemaRegistry.json +1 -0
- package/core/abi/index.d.ts +1114 -0
- package/core/abi/index.js +26 -0
- package/core/class/Attestation.d.ts +3 -2
- package/core/class/Attestation.js +11 -8
- package/core/class/GAP.d.ts +1 -1
- package/core/class/GAP.js +9 -10
- package/core/class/GapSchema.js +1 -0
- package/core/class/GraphQL/GapEasClient.d.ts +7 -7
- package/core/class/GraphQL/GapEasClient.js +60 -60
- package/core/class/Schema.d.ts +12 -3
- package/core/class/Schema.js +32 -12
- package/core/class/SchemaError.d.ts +2 -1
- package/core/class/SchemaError.js +4 -3
- package/core/class/contract/GapContract.d.ts +11 -6
- package/core/class/contract/GapContract.js +35 -6
- package/core/class/entities/Community.d.ts +2 -2
- package/core/class/entities/Community.js +9 -3
- package/core/class/entities/Grant.d.ts +11 -11
- package/core/class/entities/Grant.js +33 -29
- package/core/class/entities/GrantUpdate.d.ts +8 -2
- package/core/class/entities/GrantUpdate.js +26 -6
- package/core/class/entities/MemberOf.d.ts +2 -2
- package/core/class/entities/MemberOf.js +4 -2
- package/core/class/entities/Milestone.d.ts +14 -7
- package/core/class/entities/Milestone.js +63 -21
- package/core/class/entities/Project.d.ts +10 -5
- package/core/class/entities/Project.js +77 -9
- package/core/class/entities/ProjectImpact.d.ts +7 -3
- package/core/class/entities/ProjectImpact.js +23 -6
- package/core/class/entities/ProjectMilestone.d.ts +60 -0
- package/core/class/entities/ProjectMilestone.js +174 -0
- package/core/class/entities/ProjectUpdate.d.ts +4 -2
- package/core/class/entities/ProjectUpdate.js +21 -5
- package/core/class/karma-indexer/GapIndexerClient.d.ts +9 -7
- package/core/class/karma-indexer/GapIndexerClient.js +15 -10
- package/core/class/karma-indexer/api/GapIndexerApi.d.ts +3 -1
- package/core/class/karma-indexer/api/GapIndexerApi.js +9 -0
- package/core/class/karma-indexer/api/types.d.ts +21 -0
- package/core/class/types/attestations.d.ts +20 -1
- package/core/class/types/attestations.js +4 -1
- package/core/consts.js +219 -45
- package/core/index.d.ts +1 -0
- package/core/index.js +1 -0
- package/core/types.d.ts +12 -2
- package/package.json +1 -1
- package/core/abi/AlloCaller.json +0 -117
|
@@ -19,17 +19,26 @@ class Milestone extends Attestation_1.Attestation {
|
|
|
19
19
|
* @param signer
|
|
20
20
|
* @param reason
|
|
21
21
|
*/
|
|
22
|
-
async approve(signer,
|
|
22
|
+
async approve(signer, data, 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");
|
|
26
|
-
schema.
|
|
27
|
-
|
|
26
|
+
if (this.schema.isJsonSchema()) {
|
|
27
|
+
schema.setValue("json", JSON.stringify({
|
|
28
|
+
type: "approved",
|
|
29
|
+
...data,
|
|
30
|
+
}));
|
|
31
|
+
}
|
|
32
|
+
else {
|
|
33
|
+
schema.setValue("type", "approved");
|
|
34
|
+
schema.setValue("reason", data?.reason || "");
|
|
35
|
+
schema.setValue("proofOfWork", data?.proofOfWork || "");
|
|
36
|
+
}
|
|
28
37
|
await this.attestStatus(signer, schema, callback);
|
|
29
38
|
this.approved = new attestations_1.MilestoneCompleted({
|
|
30
39
|
data: {
|
|
31
40
|
type: "approved",
|
|
32
|
-
reason,
|
|
41
|
+
reason: data?.reason || "",
|
|
33
42
|
},
|
|
34
43
|
refUID: this.uid,
|
|
35
44
|
schema: schema,
|
|
@@ -82,12 +91,13 @@ class Milestone extends Attestation_1.Attestation {
|
|
|
82
91
|
async revokeRejection(signer) {
|
|
83
92
|
if (!this.rejected)
|
|
84
93
|
throw new SchemaError_1.AttestationError("ATTEST_ERROR", "Milestone is not rejected");
|
|
85
|
-
await this.rejected.schema.multiRevoke(signer, [
|
|
94
|
+
const { tx, uids } = await this.rejected.schema.multiRevoke(signer, [
|
|
86
95
|
{
|
|
87
96
|
schemaId: this.completed.schema.uid,
|
|
88
97
|
uid: this.completed.uid,
|
|
89
98
|
},
|
|
90
99
|
]);
|
|
100
|
+
return { tx, uids };
|
|
91
101
|
}
|
|
92
102
|
/**
|
|
93
103
|
* Marks a milestone as completed. If the milestone is already completed,
|
|
@@ -95,20 +105,30 @@ class Milestone extends Attestation_1.Attestation {
|
|
|
95
105
|
* @param signer
|
|
96
106
|
* @param reason
|
|
97
107
|
*/
|
|
98
|
-
async complete(signer,
|
|
108
|
+
async complete(signer, data, callback) {
|
|
99
109
|
const schema = this.schema.gap.findSchema("MilestoneCompleted");
|
|
100
|
-
schema.
|
|
101
|
-
|
|
102
|
-
|
|
110
|
+
if (this.schema.isJsonSchema()) {
|
|
111
|
+
schema.setValue("json", JSON.stringify({
|
|
112
|
+
type: "completed",
|
|
113
|
+
...data,
|
|
114
|
+
}));
|
|
115
|
+
}
|
|
116
|
+
else {
|
|
117
|
+
schema.setValue("type", "completed");
|
|
118
|
+
schema.setValue("reason", data?.reason || "");
|
|
119
|
+
schema.setValue("proofOfWork", data?.proofOfWork || "");
|
|
120
|
+
}
|
|
121
|
+
const { tx, uids } = await this.attestStatus(signer, schema, callback);
|
|
103
122
|
this.completed = new attestations_1.MilestoneCompleted({
|
|
104
123
|
data: {
|
|
105
124
|
type: "completed",
|
|
106
|
-
|
|
125
|
+
...data,
|
|
107
126
|
},
|
|
108
127
|
refUID: this.uid,
|
|
109
128
|
schema,
|
|
110
129
|
recipient: this.recipient,
|
|
111
130
|
});
|
|
131
|
+
return { tx, uids };
|
|
112
132
|
}
|
|
113
133
|
/**
|
|
114
134
|
* Revokes the completed status of the milestone. If the milestone is not completed,
|
|
@@ -118,12 +138,13 @@ class Milestone extends Attestation_1.Attestation {
|
|
|
118
138
|
async revokeCompletion(signer, callback) {
|
|
119
139
|
if (!this.completed)
|
|
120
140
|
throw new SchemaError_1.AttestationError("ATTEST_ERROR", "Milestone is not completed");
|
|
121
|
-
await this.completed.schema.multiRevoke(signer, [
|
|
141
|
+
const { tx, uids } = await this.completed.schema.multiRevoke(signer, [
|
|
122
142
|
{
|
|
123
143
|
schemaId: this.completed.schema.uid,
|
|
124
144
|
uid: this.completed.uid,
|
|
125
145
|
},
|
|
126
146
|
], callback);
|
|
147
|
+
return { tx, uids };
|
|
127
148
|
}
|
|
128
149
|
/**
|
|
129
150
|
* Creates the payload for a multi-attestation.
|
|
@@ -161,11 +182,14 @@ class Milestone extends Attestation_1.Attestation {
|
|
|
161
182
|
async attest(signer, callback) {
|
|
162
183
|
this.assertPayload();
|
|
163
184
|
const payload = await this.multiAttestPayload();
|
|
164
|
-
const uids = await GapContract_1.GapContract.multiAttest(signer, payload.map((p) => p[1]), callback);
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
185
|
+
const { uids, tx } = await GapContract_1.GapContract.multiAttest(signer, payload.map((p) => p[1]), callback);
|
|
186
|
+
if (Array.isArray(uids)) {
|
|
187
|
+
uids.forEach((uid, index) => {
|
|
188
|
+
payload[index][0].uid = uid;
|
|
189
|
+
});
|
|
190
|
+
}
|
|
168
191
|
console.log(uids);
|
|
192
|
+
return { tx, uids };
|
|
169
193
|
}
|
|
170
194
|
/**
|
|
171
195
|
* Attest the status of the milestone as approved, rejected or completed.
|
|
@@ -191,10 +215,18 @@ class Milestone extends Attestation_1.Attestation {
|
|
|
191
215
|
if (callback)
|
|
192
216
|
callback("confirmed");
|
|
193
217
|
console.log(uid);
|
|
218
|
+
return {
|
|
219
|
+
tx: [
|
|
220
|
+
{
|
|
221
|
+
hash: tx.tx.hash,
|
|
222
|
+
},
|
|
223
|
+
],
|
|
224
|
+
uids: [uid],
|
|
225
|
+
};
|
|
194
226
|
}
|
|
195
227
|
catch (error) {
|
|
196
228
|
console.error(error);
|
|
197
|
-
throw new SchemaError_1.AttestationError("ATTEST_ERROR", error.message);
|
|
229
|
+
throw new SchemaError_1.AttestationError("ATTEST_ERROR", error.message, error);
|
|
198
230
|
}
|
|
199
231
|
}
|
|
200
232
|
static from(attestations, network) {
|
|
@@ -256,25 +288,35 @@ class Milestone extends Attestation_1.Attestation {
|
|
|
256
288
|
* @param signer
|
|
257
289
|
* @param reason
|
|
258
290
|
*/
|
|
259
|
-
async verify(signer,
|
|
291
|
+
async verify(signer, data, callback) {
|
|
260
292
|
console.log("Verifying");
|
|
261
293
|
if (!this.completed)
|
|
262
294
|
throw new SchemaError_1.AttestationError("ATTEST_ERROR", "Milestone is not completed");
|
|
263
295
|
const schema = this.schema.gap.findSchema("MilestoneCompleted");
|
|
264
|
-
schema.
|
|
265
|
-
|
|
296
|
+
if (this.schema.isJsonSchema()) {
|
|
297
|
+
schema.setValue("json", JSON.stringify({
|
|
298
|
+
type: "verified",
|
|
299
|
+
...data,
|
|
300
|
+
}));
|
|
301
|
+
}
|
|
302
|
+
else {
|
|
303
|
+
schema.setValue("type", "verified");
|
|
304
|
+
schema.setValue("reason", data?.reason || "");
|
|
305
|
+
schema.setValue("proofOfWork", data?.proofOfWork || "");
|
|
306
|
+
}
|
|
266
307
|
console.log("Before attestStatus");
|
|
267
|
-
await this.attestStatus(signer, schema, callback);
|
|
308
|
+
const { tx, uids } = await this.attestStatus(signer, schema, callback);
|
|
268
309
|
console.log("After attestStatus");
|
|
269
310
|
this.verified.push(new attestations_1.MilestoneCompleted({
|
|
270
311
|
data: {
|
|
271
312
|
type: "verified",
|
|
272
|
-
|
|
313
|
+
...data,
|
|
273
314
|
},
|
|
274
315
|
refUID: this.uid,
|
|
275
316
|
schema: schema,
|
|
276
317
|
recipient: this.recipient,
|
|
277
318
|
}));
|
|
319
|
+
return { tx, uids };
|
|
278
320
|
}
|
|
279
321
|
}
|
|
280
322
|
exports.Milestone = Milestone;
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import { Attestation } from "../Attestation";
|
|
2
|
-
import { Grantee, MemberDetails, ProjectDetails, ProjectEndorsement } from "../types/attestations";
|
|
2
|
+
import { AttestationWithTx, Grantee, MemberDetails, ProjectDetails, ProjectEndorsement } from "../types/attestations";
|
|
3
3
|
import { Hex, MultiAttestPayload, SignerOrProvider, TNetwork } from "core/types";
|
|
4
4
|
import { Grant } from "./Grant";
|
|
5
5
|
import { MemberOf } from "./MemberOf";
|
|
6
6
|
import { IProjectResponse } from "../karma-indexer/api/types";
|
|
7
|
-
import { ProjectImpact } from "./ProjectImpact";
|
|
7
|
+
import { IProjectImpact, ProjectImpact } from "./ProjectImpact";
|
|
8
8
|
import { ProjectUpdate } from "./ProjectUpdate";
|
|
9
9
|
import { ProjectPointer } from "./ProjectPointer";
|
|
10
|
+
import { ProjectMilestone } from "./ProjectMilestone";
|
|
10
11
|
export interface IProject {
|
|
11
12
|
project: true;
|
|
12
13
|
}
|
|
@@ -19,6 +20,7 @@ export declare class Project extends Attestation<IProject> {
|
|
|
19
20
|
endorsements: ProjectEndorsement[];
|
|
20
21
|
updates: ProjectUpdate[];
|
|
21
22
|
pointers: ProjectPointer[];
|
|
23
|
+
milestones: ProjectMilestone[];
|
|
22
24
|
/**
|
|
23
25
|
* Creates the payload for a multi-attestation.
|
|
24
26
|
*
|
|
@@ -30,8 +32,8 @@ export declare class Project extends Attestation<IProject> {
|
|
|
30
32
|
* @param communityIdx
|
|
31
33
|
*/
|
|
32
34
|
multiAttestPayload(currentPayload?: MultiAttestPayload, communityIdx?: number): Promise<MultiAttestPayload>;
|
|
33
|
-
attest(signer: SignerOrProvider, callback?: Function): Promise<
|
|
34
|
-
transferOwnership(signer: SignerOrProvider, newOwner: Hex, callback?: Function): Promise<
|
|
35
|
+
attest(signer: SignerOrProvider, callback?: Function): Promise<AttestationWithTx>;
|
|
36
|
+
transferOwnership(signer: SignerOrProvider, newOwner: Hex, callback?: Function): Promise<AttestationWithTx>;
|
|
35
37
|
isOwner(signer: SignerOrProvider): Promise<boolean>;
|
|
36
38
|
/**
|
|
37
39
|
* Add new members to the project.
|
|
@@ -78,7 +80,10 @@ export declare class Project extends Attestation<IProject> {
|
|
|
78
80
|
removeAllMembers(signer: SignerOrProvider): Promise<void>;
|
|
79
81
|
static from(attestations: IProjectResponse[], network: TNetwork): Project[];
|
|
80
82
|
attestUpdate(signer: SignerOrProvider, data: ProjectUpdate, callback?: Function): Promise<void>;
|
|
83
|
+
attestMilestone(signer: SignerOrProvider, data: ProjectUpdate, callback?: Function): Promise<void>;
|
|
81
84
|
attestPointer(signer: SignerOrProvider, data: ProjectPointer, callback?: Function): Promise<void>;
|
|
82
|
-
attestImpact(signer: SignerOrProvider, data:
|
|
85
|
+
attestImpact(signer: SignerOrProvider, data: IProjectImpact, targetChainId?: number, callback?: Function): Promise<AttestationWithTx>;
|
|
86
|
+
private attestGhostProjectImpact;
|
|
83
87
|
attestEndorsement(signer: SignerOrProvider, data?: ProjectEndorsement): Promise<void>;
|
|
88
|
+
attestGhostProject(signer: SignerOrProvider, targetChainId: number): Promise<AttestationWithTx>;
|
|
84
89
|
}
|
|
@@ -13,6 +13,7 @@ const AllGapSchemas_1 = require("../AllGapSchemas");
|
|
|
13
13
|
const ProjectImpact_1 = require("./ProjectImpact");
|
|
14
14
|
const ProjectUpdate_1 = require("./ProjectUpdate");
|
|
15
15
|
const ProjectPointer_1 = require("./ProjectPointer");
|
|
16
|
+
const ProjectMilestone_1 = require("./ProjectMilestone");
|
|
16
17
|
class Project extends Attestation_1.Attestation {
|
|
17
18
|
constructor() {
|
|
18
19
|
super(...arguments);
|
|
@@ -22,6 +23,7 @@ class Project extends Attestation_1.Attestation {
|
|
|
22
23
|
this.endorsements = [];
|
|
23
24
|
this.updates = [];
|
|
24
25
|
this.pointers = [];
|
|
26
|
+
this.milestones = [];
|
|
25
27
|
}
|
|
26
28
|
/**
|
|
27
29
|
* Creates the payload for a multi-attestation.
|
|
@@ -49,15 +51,20 @@ class Project extends Attestation_1.Attestation {
|
|
|
49
51
|
}
|
|
50
52
|
async attest(signer, callback) {
|
|
51
53
|
const payload = await this.multiAttestPayload();
|
|
52
|
-
const uids = await GapContract_1.GapContract.multiAttest(signer, payload.map((p) => p[1]), callback);
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
54
|
+
const { tx, uids } = await GapContract_1.GapContract.multiAttest(signer, payload.map((p) => p[1]), callback);
|
|
55
|
+
if (Array.isArray(uids)) {
|
|
56
|
+
uids.forEach((uid, index) => {
|
|
57
|
+
payload[index][0].uid = uid;
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
return { tx, uids };
|
|
56
61
|
}
|
|
57
62
|
async transferOwnership(signer, newOwner, callback) {
|
|
58
63
|
callback?.("preparing");
|
|
59
|
-
await GapContract_1.GapContract.transferProjectOwnership(signer, this.uid, newOwner);
|
|
64
|
+
const tx = await GapContract_1.GapContract.transferProjectOwnership(signer, this.uid, newOwner);
|
|
60
65
|
callback?.("confirmed");
|
|
66
|
+
const txArray = [tx].flat();
|
|
67
|
+
return { tx: txArray, uids: [this.uid] };
|
|
61
68
|
}
|
|
62
69
|
isOwner(signer) {
|
|
63
70
|
return GapContract_1.GapContract.isProjectOwner(signer, this.uid, this.chainID);
|
|
@@ -104,7 +111,7 @@ class Project extends Attestation_1.Attestation {
|
|
|
104
111
|
throw new SchemaError_1.AttestationError("ATTEST_ERROR", "No new members to add.");
|
|
105
112
|
}
|
|
106
113
|
console.log(`Creating ${newMembers.length} new members`);
|
|
107
|
-
const attestedMembers = await this.schema.multiAttest(signer, newMembers.map((m) => m.member), callback);
|
|
114
|
+
const { uids: attestedMembers } = await this.schema.multiAttest(signer, newMembers.map((m) => m.member), callback);
|
|
108
115
|
console.log("attested-members", attestedMembers);
|
|
109
116
|
newMembers.forEach(({ member, details }, idx) => {
|
|
110
117
|
Object.assign(member, { uid: attestedMembers[idx] });
|
|
@@ -132,7 +139,7 @@ class Project extends Attestation_1.Attestation {
|
|
|
132
139
|
await this.cleanDetails(signer, toRevoke);
|
|
133
140
|
}
|
|
134
141
|
console.log(`Creating ${entities.length} new member details`);
|
|
135
|
-
const attestedEntities = await this.schema.multiAttest(signer, entities, callback);
|
|
142
|
+
const { uids: attestedEntities } = await this.schema.multiAttest(signer, entities, callback);
|
|
136
143
|
console.log("attested-entities", attestedEntities);
|
|
137
144
|
entities.forEach((entity, idx) => {
|
|
138
145
|
const member = this.members.find((member) => member.uid === entity.refUID);
|
|
@@ -260,6 +267,9 @@ class Project extends Attestation_1.Attestation {
|
|
|
260
267
|
if (attestation.updates) {
|
|
261
268
|
project.updates = ProjectUpdate_1.ProjectUpdate.from(attestation.updates, network);
|
|
262
269
|
}
|
|
270
|
+
if (attestation.milestones) {
|
|
271
|
+
project.milestones = ProjectMilestone_1.ProjectMilestone.from(attestation.milestones, network);
|
|
272
|
+
}
|
|
263
273
|
if (attestation.endorsements) {
|
|
264
274
|
project.endorsements = attestation.endorsements.map((pi) => {
|
|
265
275
|
const endorsement = new attestations_1.ProjectEndorsement({
|
|
@@ -289,6 +299,19 @@ class Project extends Attestation_1.Attestation {
|
|
|
289
299
|
await projectUpdate.attest(signer, callback);
|
|
290
300
|
this.updates.push(projectUpdate);
|
|
291
301
|
}
|
|
302
|
+
async attestMilestone(signer, data, callback) {
|
|
303
|
+
const projectMilestone = new ProjectMilestone_1.ProjectMilestone({
|
|
304
|
+
data: {
|
|
305
|
+
...data,
|
|
306
|
+
type: "project-milestone",
|
|
307
|
+
},
|
|
308
|
+
recipient: this.recipient,
|
|
309
|
+
refUID: this.uid,
|
|
310
|
+
schema: this.schema.gap.findSchema("ProjectMilestone"),
|
|
311
|
+
});
|
|
312
|
+
await projectMilestone.attest(signer, callback);
|
|
313
|
+
this.milestones.push(projectMilestone);
|
|
314
|
+
}
|
|
292
315
|
async attestPointer(signer, data, callback) {
|
|
293
316
|
const projectPointer = new ProjectPointer_1.ProjectPointer({
|
|
294
317
|
data: {
|
|
@@ -302,7 +325,10 @@ class Project extends Attestation_1.Attestation {
|
|
|
302
325
|
await projectPointer.attest(signer, callback);
|
|
303
326
|
this.pointers.push(projectPointer);
|
|
304
327
|
}
|
|
305
|
-
async attestImpact(signer, data) {
|
|
328
|
+
async attestImpact(signer, data, targetChainId, callback) {
|
|
329
|
+
if (targetChainId && targetChainId !== this.chainID) {
|
|
330
|
+
return this.attestGhostProjectImpact(signer, data, targetChainId, callback);
|
|
331
|
+
}
|
|
306
332
|
const projectImpact = new ProjectImpact_1.ProjectImpact({
|
|
307
333
|
data: {
|
|
308
334
|
...data,
|
|
@@ -312,8 +338,30 @@ class Project extends Attestation_1.Attestation {
|
|
|
312
338
|
refUID: this.uid,
|
|
313
339
|
schema: this.schema.gap.findSchema("ProjectDetails"),
|
|
314
340
|
});
|
|
315
|
-
await projectImpact.attest(signer);
|
|
341
|
+
const { tx, uids } = await projectImpact.attest(signer, callback);
|
|
342
|
+
this.impacts.push(projectImpact);
|
|
343
|
+
return { tx, uids };
|
|
344
|
+
}
|
|
345
|
+
async attestGhostProjectImpact(signer, data, targetChainId, callback) {
|
|
346
|
+
const { tx, uids } = await this.attestGhostProject(signer, targetChainId);
|
|
347
|
+
const ghostProjectUid = uids[0];
|
|
348
|
+
const allGapSchemas = new AllGapSchemas_1.AllGapSchemas();
|
|
349
|
+
const projectImpact = new ProjectImpact_1.ProjectImpact({
|
|
350
|
+
data: {
|
|
351
|
+
...data,
|
|
352
|
+
type: "project-impact",
|
|
353
|
+
},
|
|
354
|
+
recipient: this.recipient,
|
|
355
|
+
refUID: ghostProjectUid,
|
|
356
|
+
schema: allGapSchemas.findSchema("ProjectDetails", consts_1.chainIdToNetwork[targetChainId]),
|
|
357
|
+
chainID: targetChainId,
|
|
358
|
+
});
|
|
359
|
+
const impactAttestation = await projectImpact.attest(signer, callback);
|
|
316
360
|
this.impacts.push(projectImpact);
|
|
361
|
+
return {
|
|
362
|
+
tx: impactAttestation.tx,
|
|
363
|
+
uids: [...uids, impactAttestation.uids[0]],
|
|
364
|
+
};
|
|
317
365
|
}
|
|
318
366
|
async attestEndorsement(signer, data) {
|
|
319
367
|
const projectEndorsement = new attestations_1.ProjectEndorsement({
|
|
@@ -328,5 +376,25 @@ class Project extends Attestation_1.Attestation {
|
|
|
328
376
|
await projectEndorsement.attest(signer);
|
|
329
377
|
this.endorsements.push(projectEndorsement);
|
|
330
378
|
}
|
|
379
|
+
async attestGhostProject(signer, targetChainId) {
|
|
380
|
+
const allGapSchemas = new AllGapSchemas_1.AllGapSchemas();
|
|
381
|
+
const project = new Project({
|
|
382
|
+
data: { project: true },
|
|
383
|
+
schema: allGapSchemas.findSchema("Project", consts_1.chainIdToNetwork[targetChainId]),
|
|
384
|
+
recipient: this.recipient,
|
|
385
|
+
chainID: targetChainId,
|
|
386
|
+
});
|
|
387
|
+
project.details = new Attestation_1.Attestation({
|
|
388
|
+
data: {
|
|
389
|
+
originalProjectChainId: this.chainID,
|
|
390
|
+
uid: this.uid,
|
|
391
|
+
},
|
|
392
|
+
chainID: targetChainId,
|
|
393
|
+
recipient: this.recipient,
|
|
394
|
+
schema: allGapSchemas.findSchema("ProjectDetails", consts_1.chainIdToNetwork[targetChainId]),
|
|
395
|
+
});
|
|
396
|
+
const attestation = await project.attest(signer);
|
|
397
|
+
return attestation;
|
|
398
|
+
}
|
|
331
399
|
}
|
|
332
400
|
exports.Project = Project;
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { SignerOrProvider, TNetwork } from "../../types";
|
|
2
2
|
import { Attestation, AttestationArgs } from "../Attestation";
|
|
3
3
|
import { GapSchema } from "../GapSchema";
|
|
4
|
+
import { Transaction } from "ethers";
|
|
4
5
|
export interface _IProjectImpact extends ProjectImpact {
|
|
5
6
|
}
|
|
6
7
|
type IStatus = "verified";
|
|
7
8
|
export interface IProjectImpactStatus {
|
|
8
|
-
type
|
|
9
|
+
type?: `project-impact-${IStatus}`;
|
|
9
10
|
reason?: string;
|
|
10
11
|
}
|
|
11
12
|
export declare class ProjectImpactStatus extends Attestation<IProjectImpactStatus> implements IProjectImpactStatus {
|
|
@@ -19,7 +20,7 @@ export interface IProjectImpact {
|
|
|
19
20
|
startedAt?: number;
|
|
20
21
|
completedAt: number;
|
|
21
22
|
type?: string;
|
|
22
|
-
verified
|
|
23
|
+
verified?: ProjectImpactStatus[];
|
|
23
24
|
}
|
|
24
25
|
export declare class ProjectImpact extends Attestation<IProjectImpact> implements IProjectImpact {
|
|
25
26
|
work: string;
|
|
@@ -40,7 +41,10 @@ export declare class ProjectImpact extends Attestation<IProjectImpact> implement
|
|
|
40
41
|
* @param signer
|
|
41
42
|
* @param reason
|
|
42
43
|
*/
|
|
43
|
-
verify(signer: SignerOrProvider,
|
|
44
|
+
verify(signer: SignerOrProvider, data?: IProjectImpactStatus, callback?: Function): Promise<{
|
|
45
|
+
tx: Transaction[];
|
|
46
|
+
uids: `0x${string}`[];
|
|
47
|
+
}>;
|
|
44
48
|
static from(attestations: ProjectImpact[], network: TNetwork): ProjectImpact[];
|
|
45
49
|
}
|
|
46
50
|
export {};
|
|
@@ -38,10 +38,18 @@ class ProjectImpact extends Attestation_1.Attestation {
|
|
|
38
38
|
if (callback)
|
|
39
39
|
callback("confirmed");
|
|
40
40
|
console.log(uid);
|
|
41
|
+
return {
|
|
42
|
+
tx: [
|
|
43
|
+
{
|
|
44
|
+
hash: tx.tx.hash,
|
|
45
|
+
},
|
|
46
|
+
],
|
|
47
|
+
uids: [uid],
|
|
48
|
+
};
|
|
41
49
|
}
|
|
42
50
|
catch (error) {
|
|
43
51
|
console.error(error);
|
|
44
|
-
throw new SchemaError_1.AttestationError("ATTEST_ERROR", error.message);
|
|
52
|
+
throw new SchemaError_1.AttestationError("ATTEST_ERROR", error.message, error);
|
|
45
53
|
}
|
|
46
54
|
}
|
|
47
55
|
/**
|
|
@@ -50,23 +58,32 @@ class ProjectImpact extends Attestation_1.Attestation {
|
|
|
50
58
|
* @param signer
|
|
51
59
|
* @param reason
|
|
52
60
|
*/
|
|
53
|
-
async verify(signer,
|
|
61
|
+
async verify(signer, data, callback) {
|
|
54
62
|
console.log("Verifying ProjectImpact");
|
|
55
63
|
const schema = this.schema.gap.findSchema("GrantUpdateStatus");
|
|
56
|
-
schema.
|
|
57
|
-
|
|
64
|
+
if (this.schema.isJsonSchema()) {
|
|
65
|
+
schema.setValue("json", JSON.stringify({
|
|
66
|
+
type: "project-impact-verified",
|
|
67
|
+
reason: data?.reason || '',
|
|
68
|
+
}));
|
|
69
|
+
}
|
|
70
|
+
else {
|
|
71
|
+
schema.setValue("type", "project-impact-verified");
|
|
72
|
+
schema.setValue("reason", data?.reason || '');
|
|
73
|
+
}
|
|
58
74
|
console.log("Before attest project impact verified");
|
|
59
|
-
await this.attestStatus(signer, schema, callback);
|
|
75
|
+
const { tx, uids } = await this.attestStatus(signer, schema, callback);
|
|
60
76
|
console.log("After attest project impact verified");
|
|
61
77
|
this.verified.push(new ProjectImpactStatus({
|
|
62
78
|
data: {
|
|
63
79
|
type: "project-impact-verified",
|
|
64
|
-
reason,
|
|
80
|
+
reason: data?.reason || '',
|
|
65
81
|
},
|
|
66
82
|
refUID: this.uid,
|
|
67
83
|
schema: schema,
|
|
68
84
|
recipient: this.recipient,
|
|
69
85
|
}));
|
|
86
|
+
return { tx, uids };
|
|
70
87
|
}
|
|
71
88
|
static from(attestations, network) {
|
|
72
89
|
return attestations.map((attestation) => {
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { SignerOrProvider, TNetwork } from "../../../core/types";
|
|
2
|
+
import { Attestation, AttestationArgs } from "../Attestation";
|
|
3
|
+
import { GapSchema } from "../GapSchema";
|
|
4
|
+
import { Transaction } from "ethers";
|
|
5
|
+
import { IProjectMilestoneResponse } from "../karma-indexer/api/types";
|
|
6
|
+
import { MilestoneCompleted as ProjectMilestoneCompleted } from "../types/attestations";
|
|
7
|
+
export interface IProjectMilestone {
|
|
8
|
+
title: string;
|
|
9
|
+
text: string;
|
|
10
|
+
type?: string;
|
|
11
|
+
}
|
|
12
|
+
type IStatus = "verified" | "completed";
|
|
13
|
+
export interface IProjectMilestoneStatus {
|
|
14
|
+
type?: `project-milestone-${IStatus}`;
|
|
15
|
+
proofOfWork?: string;
|
|
16
|
+
reason?: string;
|
|
17
|
+
}
|
|
18
|
+
export declare class ProjectMilestoneStatus extends Attestation<IProjectMilestoneStatus> implements IProjectMilestoneStatus {
|
|
19
|
+
type: `project-milestone-${IStatus}`;
|
|
20
|
+
reason?: string;
|
|
21
|
+
}
|
|
22
|
+
export declare class ProjectMilestone extends Attestation<IProjectMilestone> implements IProjectMilestone {
|
|
23
|
+
title: string;
|
|
24
|
+
text: string;
|
|
25
|
+
verified: ProjectMilestoneStatus[];
|
|
26
|
+
completed: ProjectMilestoneCompleted;
|
|
27
|
+
constructor(data: AttestationArgs<IProjectMilestone, GapSchema>);
|
|
28
|
+
/**
|
|
29
|
+
* Attest the status of the update as approved, rejected or completed.
|
|
30
|
+
*/
|
|
31
|
+
private attestStatus;
|
|
32
|
+
/**
|
|
33
|
+
* Verify this ProjectUpdate. If the ProjectUpdate is not already verified,
|
|
34
|
+
* it will throw an error.
|
|
35
|
+
* @param signer
|
|
36
|
+
* @param reason
|
|
37
|
+
*/
|
|
38
|
+
verify(signer: SignerOrProvider, data?: IProjectMilestoneStatus, callback?: Function): Promise<void>;
|
|
39
|
+
/**
|
|
40
|
+
* Marks a milestone as completed. If the milestone is already completed,
|
|
41
|
+
* it will throw an error.
|
|
42
|
+
* @param signer
|
|
43
|
+
* @param reason
|
|
44
|
+
*/
|
|
45
|
+
complete(signer: SignerOrProvider, data?: IProjectMilestoneStatus, callback?: Function): Promise<{
|
|
46
|
+
tx: Transaction[];
|
|
47
|
+
uids: `0x${string}`[];
|
|
48
|
+
}>;
|
|
49
|
+
/**
|
|
50
|
+
* Revokes the completed status of the milestone. If the milestone is not completed,
|
|
51
|
+
* it will throw an error.
|
|
52
|
+
* @param signer
|
|
53
|
+
*/
|
|
54
|
+
revokeCompletion(signer: SignerOrProvider, callback?: Function): Promise<{
|
|
55
|
+
tx: Transaction[];
|
|
56
|
+
uids: `0x${string}`[];
|
|
57
|
+
}>;
|
|
58
|
+
static from(attestations: IProjectMilestoneResponse[], network: TNetwork): ProjectMilestone[];
|
|
59
|
+
}
|
|
60
|
+
export {};
|