@show-karma/karma-gap-sdk 0.3.11 → 0.3.12

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.
@@ -17,6 +17,7 @@ export declare class Milestone extends Attestation<IMilestone> implements IMiles
17
17
  completed: MilestoneCompleted;
18
18
  approved: MilestoneCompleted;
19
19
  rejected: MilestoneCompleted;
20
+ verified: MilestoneCompleted[];
20
21
  type: string;
21
22
  /**
22
23
  * Approves this milestone. If the milestone is not completed or already approved,
@@ -77,5 +78,12 @@ export declare class Milestone extends Attestation<IMilestone> implements IMiles
77
78
  */
78
79
  private attestStatus;
79
80
  static from(attestations: _Milestone[], network: TNetwork): Milestone[];
81
+ /**
82
+ * Verify this milestone. If the milestone is not completed or already verified,
83
+ * it will throw an error.
84
+ * @param signer
85
+ * @param reason
86
+ */
87
+ verify(signer: SignerOrProvider, reason?: string): Promise<void>;
80
88
  }
81
89
  export {};
@@ -10,6 +10,7 @@ const attestations_1 = require("../types/attestations");
10
10
  class Milestone extends Attestation_1.Attestation {
11
11
  constructor() {
12
12
  super(...arguments);
13
+ this.verified = [];
13
14
  this.type = 'milestone';
14
15
  }
15
16
  /**
@@ -144,6 +145,14 @@ class Milestone extends Attestation_1.Attestation {
144
145
  await this.completed.payloadFor(milestoneIdx),
145
146
  ]);
146
147
  }
148
+ if (this.verified.length > 0) {
149
+ await Promise.all(this.verified.map(async (m) => {
150
+ const payloadForMilestone = await m.payloadFor(milestoneIdx);
151
+ if (Array.isArray(payloadForMilestone)) {
152
+ payloadForMilestone.forEach((item) => payload.push(item));
153
+ }
154
+ }));
155
+ }
147
156
  return payload.slice(currentPayload.length, payload.length);
148
157
  }
149
158
  /**
@@ -222,8 +231,44 @@ class Milestone extends Attestation_1.Attestation {
222
231
  chainID: attestation.chainID,
223
232
  });
224
233
  }
234
+ if (attestation.verified?.length > 0) {
235
+ milestone.verified = attestation.verified.map(m => new attestations_1.MilestoneCompleted({
236
+ ...m,
237
+ data: {
238
+ ...m.data,
239
+ },
240
+ schema: new AllGapSchemas_1.AllGapSchemas().findSchema('MilestoneCompleted', consts_1.chainIdToNetwork[attestation.chainID]),
241
+ chainID: attestation.chainID,
242
+ }));
243
+ }
225
244
  return milestone;
226
245
  });
227
246
  }
247
+ /**
248
+ * Verify this milestone. If the milestone is not completed or already verified,
249
+ * it will throw an error.
250
+ * @param signer
251
+ * @param reason
252
+ */
253
+ async verify(signer, reason = '') {
254
+ console.log('Verifying');
255
+ if (!this.completed)
256
+ throw new SchemaError_1.AttestationError('ATTEST_ERROR', 'Milestone is not completed');
257
+ const schema = this.schema.gap.findSchema('MilestoneCompleted');
258
+ schema.setValue('type', 'verified');
259
+ schema.setValue('reason', reason);
260
+ console.log('Before attestStatus');
261
+ await this.attestStatus(signer, schema);
262
+ console.log('After attestStatus');
263
+ this.verified.push(new attestations_1.MilestoneCompleted({
264
+ data: {
265
+ type: 'verified',
266
+ reason,
267
+ },
268
+ refUID: this.uid,
269
+ schema: schema,
270
+ recipient: this.recipient,
271
+ }));
272
+ }
228
273
  }
229
274
  exports.Milestone = Milestone;
@@ -69,11 +69,11 @@ export declare class MemberDetails extends Attestation<IMemberDetails> implement
69
69
  profilePictureURL: string;
70
70
  }
71
71
  export interface IMilestoneCompleted {
72
- type: 'approved' | 'rejected' | 'completed';
72
+ type: 'approved' | 'rejected' | 'completed' | 'verified';
73
73
  reason?: string;
74
74
  }
75
75
  export declare class MilestoneCompleted extends Attestation<IMilestoneCompleted> implements IMilestoneCompleted {
76
- type: 'approved' | 'rejected' | 'completed';
76
+ type: 'approved' | 'rejected' | 'completed' | 'verified';
77
77
  reason?: string;
78
78
  }
79
79
  export interface ITag {
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "publishConfig": {
4
4
  "access": "public"
5
5
  },
6
- "version": "0.3.11",
6
+ "version": "0.3.12",
7
7
  "description": "Simple and easy interface between EAS and Karma GAP.",
8
8
  "main": "./index.js",
9
9
  "author": "KarmaHQ",