@show-karma/karma-gap-sdk 0.3.44 → 0.3.46

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.
Files changed (37) hide show
  1. package/core/abi/AirdropNFT.json +622 -0
  2. package/core/abi/Donations.json +260 -0
  3. package/core/abi/EAS.json +1 -0
  4. package/core/abi/SchemaRegistry.json +1 -0
  5. package/core/abi/index.d.ts +1114 -0
  6. package/core/abi/index.js +26 -0
  7. package/core/class/GAP.js +16 -11
  8. package/core/class/Schema.js +2 -3
  9. package/core/class/entities/ContributorProfile.d.ts +39 -0
  10. package/core/class/entities/ContributorProfile.js +69 -0
  11. package/core/class/entities/Grant.d.ts +1 -1
  12. package/core/class/entities/Grant.js +9 -9
  13. package/core/class/entities/GrantUpdate.d.ts +2 -2
  14. package/core/class/entities/GrantUpdate.js +2 -5
  15. package/core/class/entities/Milestone.d.ts +2 -0
  16. package/core/class/entities/Milestone.js +8 -5
  17. package/core/class/entities/Project.d.ts +7 -2
  18. package/core/class/entities/Project.js +65 -2
  19. package/core/class/entities/ProjectImpact.d.ts +1 -1
  20. package/core/class/entities/ProjectMilestone.d.ts +60 -0
  21. package/core/class/entities/ProjectMilestone.js +174 -0
  22. package/core/class/entities/ProjectUpdate.d.ts +2 -0
  23. package/core/class/entities/UserSummary.d.ts +37 -0
  24. package/core/class/entities/UserSummary.js +69 -0
  25. package/core/class/karma-indexer/GapIndexerClient.d.ts +9 -7
  26. package/core/class/karma-indexer/GapIndexerClient.js +15 -10
  27. package/core/class/karma-indexer/api/GapIndexerApi.d.ts +3 -1
  28. package/core/class/karma-indexer/api/GapIndexerApi.js +9 -0
  29. package/core/class/karma-indexer/api/types.d.ts +22 -0
  30. package/core/class/types/attestations.d.ts +14 -0
  31. package/core/class/types/attestations.js +4 -1
  32. package/core/consts.js +30 -0
  33. package/core/index.d.ts +1 -0
  34. package/core/index.js +1 -0
  35. package/core/types.d.ts +3 -2
  36. package/package.json +1 -1
  37. package/core/abi/AlloCaller.json +0 -117
@@ -0,0 +1,26 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.abis = void 0;
7
+ const AirdropNFT_json_1 = __importDefault(require("./AirdropNFT.json"));
8
+ const Allo_json_1 = __importDefault(require("./Allo.json"));
9
+ const AlloRegistry_json_1 = __importDefault(require("./AlloRegistry.json"));
10
+ const CommunityResolverABI_json_1 = __importDefault(require("./CommunityResolverABI.json"));
11
+ const Donations_json_1 = __importDefault(require("./Donations.json"));
12
+ const EAS_json_1 = __importDefault(require("./EAS.json"));
13
+ const MultiAttester_json_1 = __importDefault(require("./MultiAttester.json"));
14
+ const ProjectResolver_json_1 = __importDefault(require("./ProjectResolver.json"));
15
+ const SchemaRegistry_json_1 = __importDefault(require("./SchemaRegistry.json"));
16
+ exports.abis = {
17
+ AirdropNFT: AirdropNFT_json_1.default,
18
+ Allo: Allo_json_1.default,
19
+ AlloRegistry: AlloRegistry_json_1.default,
20
+ CommunityResolverABI: CommunityResolverABI_json_1.default,
21
+ Donations: Donations_json_1.default,
22
+ EAS: EAS_json_1.default,
23
+ MultiAttester: MultiAttester_json_1.default,
24
+ ProjectResolver: ProjectResolver_json_1.default,
25
+ SchemaRegistry: SchemaRegistry_json_1.default,
26
+ };
package/core/class/GAP.js CHANGED
@@ -81,18 +81,23 @@ class GAP extends types_1.Facade {
81
81
  this.generateSlug = async (text) => {
82
82
  let slug = text
83
83
  .toLowerCase()
84
+ // Remove emojis
85
+ .replace(/([\uE000-\uF8FF]|\uD83C[\uDF00-\uDFFF]|\uD83D[\uDC00-\uDDFF])/g, '')
86
+ // Remove basic text emoticons
87
+ .replace(/[:;=][()DP]/g, '')
84
88
  .replace(/ /g, "-")
85
- .replace(/[^\w-]+/g, "");
86
- const slugExists = await this.fetch.slugExists(slug);
87
- if (slugExists) {
88
- const parts = slug.split("-");
89
- const counter = parts.pop();
90
- slug = /\d+/g.test(counter) ? parts.join("-") : slug;
91
- // eslint-disable-next-line no-param-reassign
92
- const nextSlug = `${slug}-${counter && /\d+/g.test(counter) ? +counter + 1 : 1}`;
93
- return this.generateSlug(nextSlug);
94
- }
95
- return slug.toLowerCase();
89
+ .replace(/[^\w-]+/g, "")
90
+ .trim()
91
+ .replace(/^-+|-+$/g, ''); // Remove leading and trailing hyphens
92
+ const checkSlug = async (currentSlug, counter = 0) => {
93
+ const slugToCheck = counter === 0 ? currentSlug : `${currentSlug}-${counter}`;
94
+ const slugExists = await this.fetch.slugExists(slugToCheck);
95
+ if (slugExists) {
96
+ return checkSlug(currentSlug, counter + 1);
97
+ }
98
+ return slugToCheck.toLowerCase();
99
+ };
100
+ return checkSlug(slug);
96
101
  };
97
102
  const schemas = args.schemas || Object.values((0, consts_1.MountEntities)(consts_1.Networks[args.network]));
98
103
  this.network = args.network;
@@ -345,9 +345,8 @@ class Schema {
345
345
  gasLimit: 5000000n,
346
346
  });
347
347
  callback?.("pending");
348
- tx.wait().then(() => {
349
- callback?.("confirmed");
350
- });
348
+ await tx.wait();
349
+ callback?.("confirmed");
351
350
  return {
352
351
  tx: [{ hash: tx.tx.hash }],
353
352
  uids: payload.map((p) => p.data.map((d) => d.uid)).flat(),
@@ -0,0 +1,39 @@
1
+ import { Attestation, AttestationArgs } from "../Attestation";
2
+ import { AttestationWithTx } from "../types/attestations";
3
+ import { GapSchema } from "../GapSchema";
4
+ import { MultiAttestPayload, SignerOrProvider, TNetwork } from "core/types";
5
+ export interface IContributorProfile {
6
+ name: string;
7
+ aboutMe?: string;
8
+ github?: string;
9
+ twitter?: string;
10
+ linkdin?: number;
11
+ }
12
+ export declare class ContributorProfile extends Attestation<IContributorProfile> implements IContributorProfile {
13
+ name: string;
14
+ aboutMe?: string;
15
+ github?: string;
16
+ twitter?: string;
17
+ linkdin?: number;
18
+ constructor(data: AttestationArgs<IContributorProfile, GapSchema>);
19
+ /**
20
+ * Creates the payload for a multi-attestation.
21
+ *
22
+ * > if Current payload is set, it'll be used as the base payload
23
+ * and the project should refer to an index of the current payload,
24
+ * usually the community position.
25
+ *
26
+ * @param payload
27
+ * @param refIdx
28
+ */
29
+ multiAttestPayload(): Promise<MultiAttestPayload>;
30
+ /**
31
+ * Attest a community with its details.
32
+ *
33
+ * If the community exists, it will not be revoked but its details will be updated.
34
+ * @param signer
35
+ * @param details
36
+ */
37
+ attest(signer: SignerOrProvider, callback?: Function): Promise<AttestationWithTx>;
38
+ static from(attestation: ContributorProfile, network: TNetwork): ContributorProfile;
39
+ }
@@ -0,0 +1,69 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ContributorProfile = void 0;
4
+ const Attestation_1 = require("../Attestation");
5
+ const consts_1 = require("../../consts");
6
+ const SchemaError_1 = require("../SchemaError");
7
+ const AllGapSchemas_1 = require("../AllGapSchemas");
8
+ class ContributorProfile extends Attestation_1.Attestation {
9
+ constructor(data) {
10
+ data.data.type = "contributor-profile";
11
+ super(data);
12
+ }
13
+ /**
14
+ * Creates the payload for a multi-attestation.
15
+ *
16
+ * > if Current payload is set, it'll be used as the base payload
17
+ * and the project should refer to an index of the current payload,
18
+ * usually the community position.
19
+ *
20
+ * @param payload
21
+ * @param refIdx
22
+ */
23
+ async multiAttestPayload() {
24
+ const payload = [[this, await this.payloadFor(0)]];
25
+ return payload;
26
+ }
27
+ /**
28
+ * Attest a community with its details.
29
+ *
30
+ * If the community exists, it will not be revoked but its details will be updated.
31
+ * @param signer
32
+ * @param details
33
+ */
34
+ async attest(signer, callback) {
35
+ console.log("Attesting ContributorProfile");
36
+ try {
37
+ if (callback)
38
+ callback("preparing");
39
+ const { tx: ContributorProfileTx, uids: ContributorProfileUID } = await this.schema.attest({
40
+ signer,
41
+ to: this.recipient,
42
+ refUID: consts_1.nullRef,
43
+ data: this.data,
44
+ });
45
+ this._uid = ContributorProfileUID[0];
46
+ console.log(this.uid);
47
+ if (callback)
48
+ callback("pending");
49
+ if (callback)
50
+ callback("confirmed");
51
+ return { tx: ContributorProfileTx, uids: ContributorProfileUID };
52
+ }
53
+ catch (error) {
54
+ console.error(error);
55
+ throw new SchemaError_1.AttestationError("ATTEST_ERROR", "Error during attestation.", error);
56
+ }
57
+ }
58
+ static from(attestation, network) {
59
+ return new ContributorProfile({
60
+ ...attestation,
61
+ data: {
62
+ ...attestation.data,
63
+ },
64
+ schema: new AllGapSchemas_1.AllGapSchemas().findSchema("ContributorProfile", consts_1.chainIdToNetwork[attestation.chainID]),
65
+ chainID: attestation.chainID,
66
+ });
67
+ }
68
+ }
69
+ exports.ContributorProfile = ContributorProfile;
@@ -50,10 +50,10 @@ export declare class Grant extends Attestation<IGrant> {
50
50
  */
51
51
  attest(signer: SignerOrProvider, projectChainId: number, callback?: Function): Promise<AttestationWithTx>;
52
52
  attestUpdate(signer: SignerOrProvider, data: IGrantUpdate, callback?: Function): Promise<void>;
53
- complete(signer: SignerOrProvider, data: IGrantUpdate, callback?: Function): Promise<AttestationWithTx>;
54
53
  /**
55
54
  * Validate if the grant has a valid reference to a community.
56
55
  */
57
56
  protected assertPayload(): boolean;
57
+ complete(signer: SignerOrProvider, data: IGrantUpdate, callback?: Function): Promise<AttestationWithTx>;
58
58
  static from(attestations: IGrantResponse[], network: TNetwork): Grant[];
59
59
  }
@@ -139,6 +139,15 @@ class Grant extends Attestation_1.Attestation {
139
139
  await grantUpdate.attest(signer, callback);
140
140
  this.updates.push(grantUpdate);
141
141
  }
142
+ /**
143
+ * Validate if the grant has a valid reference to a community.
144
+ */
145
+ assertPayload() {
146
+ if (!this.details || !this.communityUID) {
147
+ throw new SchemaError_1.AttestationError("INVALID_REFERENCE", "Grant should include a valid reference to a community on its details.");
148
+ }
149
+ return true;
150
+ }
142
151
  async complete(signer, data, callback) {
143
152
  const completed = new attestations_1.GrantCompleted({
144
153
  data: {
@@ -153,15 +162,6 @@ class Grant extends Attestation_1.Attestation {
153
162
  this.completed = completed;
154
163
  return { tx, uids };
155
164
  }
156
- /**
157
- * Validate if the grant has a valid reference to a community.
158
- */
159
- assertPayload() {
160
- if (!this.details || !this.communityUID) {
161
- throw new SchemaError_1.AttestationError("INVALID_REFERENCE", "Grant should include a valid reference to a community on its details.");
162
- }
163
- return true;
164
- }
165
165
  static from(attestations, network) {
166
166
  return attestations.map((attestation) => {
167
167
  const grant = new Grant({
@@ -7,21 +7,21 @@ export interface IGrantUpdate {
7
7
  title: string;
8
8
  text: string;
9
9
  type?: string;
10
+ proofOfWork?: string;
10
11
  }
11
12
  type IStatus = "verified";
12
13
  export interface IGrantUpdateStatus {
13
14
  type?: `grant-update-${IStatus}`;
14
15
  reason?: string;
15
- linkToProof?: string;
16
16
  }
17
17
  export declare class GrantUpdateStatus extends Attestation<IGrantUpdateStatus> implements IGrantUpdateStatus {
18
18
  type: `grant-update-${IStatus}`;
19
19
  reason?: string;
20
- linkToProof?: string;
21
20
  }
22
21
  export declare class GrantUpdate extends Attestation<IGrantUpdate> implements IGrantUpdate {
23
22
  title: string;
24
23
  text: string;
24
+ proofOfWork: string;
25
25
  verified: GrantUpdateStatus[];
26
26
  /**
27
27
  * Attest the status of the milestone as approved, rejected or completed.
@@ -63,14 +63,12 @@ class GrantUpdate extends Attestation_1.Attestation {
63
63
  if (this.schema.isJsonSchema()) {
64
64
  schema.setValue("json", JSON.stringify({
65
65
  type: "grant-update-verified",
66
- reason: data?.reason || "",
67
- linkToProof: data?.linkToProof || "",
66
+ ...data,
68
67
  }));
69
68
  }
70
69
  else {
71
70
  schema.setValue("type", "grant-update-verified");
72
71
  schema.setValue("reason", data?.reason || "");
73
- schema.setValue("linkToProof", data?.linkToProof || "");
74
72
  }
75
73
  console.log("Before attest grant update verified");
76
74
  const { tx, uids } = await this.attestStatus(signer, schema, callback);
@@ -78,8 +76,7 @@ class GrantUpdate extends Attestation_1.Attestation {
78
76
  this.verified.push(new GrantUpdateStatus({
79
77
  data: {
80
78
  type: "grant-update-verified",
81
- reason: data?.reason || "",
82
- linkToProof: data?.linkToProof || "",
79
+ ...data,
83
80
  },
84
81
  refUID: this.uid,
85
82
  schema: schema,
@@ -10,6 +10,7 @@ export interface IMilestone {
10
10
  endsAt: number;
11
11
  description: string;
12
12
  type?: string;
13
+ priority?: number;
13
14
  }
14
15
  export declare class Milestone extends Attestation<IMilestone> implements IMilestone {
15
16
  title: string;
@@ -21,6 +22,7 @@ export declare class Milestone extends Attestation<IMilestone> implements IMiles
21
22
  rejected: MilestoneCompleted;
22
23
  verified: MilestoneCompleted[];
23
24
  type: string;
25
+ priority?: number;
24
26
  /**
25
27
  * Approves this milestone. If the milestone is not completed or already approved,
26
28
  * it will throw an error.
@@ -26,12 +26,13 @@ class Milestone extends Attestation_1.Attestation {
26
26
  if (this.schema.isJsonSchema()) {
27
27
  schema.setValue("json", JSON.stringify({
28
28
  type: "approved",
29
- reason: data?.reason || "",
29
+ ...data,
30
30
  }));
31
31
  }
32
32
  else {
33
33
  schema.setValue("type", "approved");
34
34
  schema.setValue("reason", data?.reason || "");
35
+ schema.setValue("proofOfWork", data?.proofOfWork || "");
35
36
  }
36
37
  await this.attestStatus(signer, schema, callback);
37
38
  this.approved = new attestations_1.MilestoneCompleted({
@@ -109,18 +110,19 @@ class Milestone extends Attestation_1.Attestation {
109
110
  if (this.schema.isJsonSchema()) {
110
111
  schema.setValue("json", JSON.stringify({
111
112
  type: "completed",
112
- reason: data?.reason || "",
113
+ ...data,
113
114
  }));
114
115
  }
115
116
  else {
116
117
  schema.setValue("type", "completed");
117
118
  schema.setValue("reason", data?.reason || "");
119
+ schema.setValue("proofOfWork", data?.proofOfWork || "");
118
120
  }
119
121
  const { tx, uids } = await this.attestStatus(signer, schema, callback);
120
122
  this.completed = new attestations_1.MilestoneCompleted({
121
123
  data: {
122
124
  type: "completed",
123
- reason: data?.reason || "",
125
+ ...data,
124
126
  },
125
127
  refUID: this.uid,
126
128
  schema,
@@ -294,12 +296,13 @@ class Milestone extends Attestation_1.Attestation {
294
296
  if (this.schema.isJsonSchema()) {
295
297
  schema.setValue("json", JSON.stringify({
296
298
  type: "verified",
297
- reason: data?.reason || "",
299
+ ...data,
298
300
  }));
299
301
  }
300
302
  else {
301
303
  schema.setValue("type", "verified");
302
304
  schema.setValue("reason", data?.reason || "");
305
+ schema.setValue("proofOfWork", data?.proofOfWork || "");
303
306
  }
304
307
  console.log("Before attestStatus");
305
308
  const { tx, uids } = await this.attestStatus(signer, schema, callback);
@@ -307,7 +310,7 @@ class Milestone extends Attestation_1.Attestation {
307
310
  this.verified.push(new attestations_1.MilestoneCompleted({
308
311
  data: {
309
312
  type: "verified",
310
- reason: data?.reason || "",
313
+ ...data,
311
314
  },
312
315
  refUID: this.uid,
313
316
  schema: schema,
@@ -4,9 +4,10 @@ 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
  *
@@ -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: ProjectImpact): Promise<void>;
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.
@@ -265,6 +267,9 @@ class Project extends Attestation_1.Attestation {
265
267
  if (attestation.updates) {
266
268
  project.updates = ProjectUpdate_1.ProjectUpdate.from(attestation.updates, network);
267
269
  }
270
+ if (attestation.milestones) {
271
+ project.milestones = ProjectMilestone_1.ProjectMilestone.from(attestation.milestones, network);
272
+ }
268
273
  if (attestation.endorsements) {
269
274
  project.endorsements = attestation.endorsements.map((pi) => {
270
275
  const endorsement = new attestations_1.ProjectEndorsement({
@@ -294,6 +299,19 @@ class Project extends Attestation_1.Attestation {
294
299
  await projectUpdate.attest(signer, callback);
295
300
  this.updates.push(projectUpdate);
296
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
+ }
297
315
  async attestPointer(signer, data, callback) {
298
316
  const projectPointer = new ProjectPointer_1.ProjectPointer({
299
317
  data: {
@@ -307,7 +325,10 @@ class Project extends Attestation_1.Attestation {
307
325
  await projectPointer.attest(signer, callback);
308
326
  this.pointers.push(projectPointer);
309
327
  }
310
- 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
+ }
311
332
  const projectImpact = new ProjectImpact_1.ProjectImpact({
312
333
  data: {
313
334
  ...data,
@@ -317,8 +338,30 @@ class Project extends Attestation_1.Attestation {
317
338
  refUID: this.uid,
318
339
  schema: this.schema.gap.findSchema("ProjectDetails"),
319
340
  });
320
- 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);
321
360
  this.impacts.push(projectImpact);
361
+ return {
362
+ tx: impactAttestation.tx,
363
+ uids: [...uids, impactAttestation.uids[0]],
364
+ };
322
365
  }
323
366
  async attestEndorsement(signer, data) {
324
367
  const projectEndorsement = new attestations_1.ProjectEndorsement({
@@ -333,5 +376,25 @@ class Project extends Attestation_1.Attestation {
333
376
  await projectEndorsement.attest(signer);
334
377
  this.endorsements.push(projectEndorsement);
335
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
+ }
336
399
  }
337
400
  exports.Project = Project;
@@ -20,7 +20,7 @@ export interface IProjectImpact {
20
20
  startedAt?: number;
21
21
  completedAt: number;
22
22
  type?: string;
23
- verified: ProjectImpactStatus[];
23
+ verified?: ProjectImpactStatus[];
24
24
  }
25
25
  export declare class ProjectImpact extends Attestation<IProjectImpact> implements IProjectImpact {
26
26
  work: string;
@@ -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 {};