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

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.
@@ -79,7 +79,7 @@ class Grant extends Attestation_1.Attestation {
79
79
  payload.push([this.details, await this.details.payloadFor(grantIdx)]);
80
80
  }
81
81
  if (this.milestones.length) {
82
- await Promise.all(this.milestones.map(async (m) => payload.push(...(await m.multiAttestPayload(currentPayload, grantIdx)))));
82
+ await Promise.all(this.milestones.map(async (m) => payload.push(...(await m.multiAttestPayload(payload, grantIdx)))));
83
83
  }
84
84
  if (this.updates.length) {
85
85
  await Promise.all(this.updates.map(async (u) => payload.push([u, await u.payloadFor(grantIdx)])));
@@ -6,6 +6,6 @@ export interface IMemberOf {
6
6
  }
7
7
  export declare class MemberOf extends Attestation<IMemberOf> {
8
8
  details?: MemberDetails;
9
- multiAttestPayload(currentPayload?: MultiAttestPayload, projectIdx?: number): Promise<[Attestation<unknown, import("..").GapSchema>, import("core/types").RawMultiAttestPayload][]>;
9
+ multiAttestPayload(currentPayload?: MultiAttestPayload, projectIdx?: number): Promise<[Attestation<unknown, import("core").GapSchema>, import("core/types").RawMultiAttestPayload][]>;
10
10
  attest(signer: SignerOrProvider): Promise<void>;
11
11
  }
@@ -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/core/consts.js CHANGED
@@ -33,7 +33,7 @@ exports.Networks = {
33
33
  contracts: {
34
34
  eas: "0x4200000000000000000000000000000000000021",
35
35
  schema: "0x4200000000000000000000000000000000000020",
36
- multicall: "0xd2eD366393FDfd243931Fe48e9fb65A192B0018c",
36
+ multicall: "0xd2eD366393FDfd243931Fe48e9fb65A192B0018c", //proxy,
37
37
  projectResolver: "0x7177AdC0f924b695C0294A40C4C5FEFf5EE1E141",
38
38
  communityResolver: "0x6dC1D6b864e8BEf815806f9e4677123496e12026",
39
39
  },
@@ -77,7 +77,7 @@ exports.Networks = {
77
77
  contracts: {
78
78
  eas: "0xbD75f629A22Dc1ceD33dDA0b68c546A1c035c458",
79
79
  schema: "0xA310da9c5B885E7fb3fbA9D66E9Ba6Df512b78eB",
80
- multicall: "0x6dC1D6b864e8BEf815806f9e4677123496e12026",
80
+ multicall: "0x6dC1D6b864e8BEf815806f9e4677123496e12026", //proxy,
81
81
  projectResolver: "0x28BE0b0515be8BB8822aF1467A6613795E74717b",
82
82
  communityResolver: "0xD534C4704F82494aBbc901560046fB62Ac63E9C4",
83
83
  },
@@ -104,10 +104,10 @@ exports.Networks = {
104
104
  communityResolver: "0xa9E55D9F52d7B47792d2Db15F6A9674c56ccc5C9",
105
105
  },
106
106
  schemas: {
107
- Community: "0xf3d790c7fdab6c1b1f25ffcc9289e5be2792eb596d2851a4d059c8aae1bc8b2e",
107
+ Community: "0xf3d790c7fdab6c1b1f25ffcc9289e5be2792eb596d2851a4d059c8aae1bc8b2e", //test with resolver
108
108
  // "0x1954572e3fe21bf4334afdaf1358ed7098af1ed136e76dc93c2fdc25e83934c1", // original without resolver
109
109
  Details: "0x2c270e35bfcdc4d611f0e9d3d2ab6924ec6c673505abc22a1dd07e19b67211af",
110
- Grant: "0x09697aeeb3ae71de1cc19e388fd74264f11af5fba3016094764553ac341fdc72",
110
+ Grant: "0x09697aeeb3ae71de1cc19e388fd74264f11af5fba3016094764553ac341fdc72", // with communityUID/resolver
111
111
  GrantVerified: "0x0be8952e2dd74ffd63a02f4d55b20b603fe7a60130cb9d70de31feb9c52fdd37",
112
112
  MemberOf: "0xdd87b3500457931252424f4439365534ba72a367503a8805ff3482353fb90301",
113
113
  MilestoneApproved: "0xcdef0e492d2e7ad25d0b0fdb868f6dcd1f5e5c30e42fd5fa0debdc12f7618322",
@@ -86,7 +86,7 @@ data, chainId, target) {
86
86
  chainId,
87
87
  target,
88
88
  },
89
- '{apiKey}',
89
+ '{apiKey}', // filled in the api
90
90
  {
91
91
  retries: 3,
92
92
  },
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.13",
7
7
  "description": "Simple and easy interface between EAS and Karma GAP.",
8
8
  "main": "./index.js",
9
9
  "author": "KarmaHQ",
@@ -19,7 +19,7 @@
19
19
  "publish-npm": "npm version patch && tsc && cd .dist && npm publish --scope=@show-karma/karma-gap-sdk --access public"
20
20
  },
21
21
  "dependencies": {
22
- "@ethereum-attestation-service/eas-sdk": "^1.4.2",
22
+ "@ethereum-attestation-service/eas-sdk": "1.4.2",
23
23
  "@gelatonetwork/relay-sdk": "^5.2.0",
24
24
  "@types/sha256": "^0.2.0",
25
25
  "axios": "^1.4.0",