@show-karma/karma-gap-sdk 0.3.41 → 0.3.42

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.
@@ -5,6 +5,8 @@ import { Grant } from "./Grant";
5
5
  import { MemberOf } from "./MemberOf";
6
6
  import { IProjectResponse } from "../karma-indexer/api/types";
7
7
  import { ProjectImpact } from "./ProjectImpact";
8
+ import { ProjectUpdate } from "./ProjectUpdate";
9
+ import { ProjectPointer } from "./ProjectPointer";
8
10
  export interface IProject {
9
11
  project: true;
10
12
  }
@@ -15,6 +17,8 @@ export declare class Project extends Attestation<IProject> {
15
17
  grantee: Grantee;
16
18
  impacts: ProjectImpact[];
17
19
  endorsements: ProjectEndorsement[];
20
+ updates: ProjectUpdate[];
21
+ pointers: ProjectPointer[];
18
22
  /**
19
23
  * Creates the payload for a multi-attestation.
20
24
  *
@@ -73,6 +77,8 @@ export declare class Project extends Attestation<IProject> {
73
77
  */
74
78
  removeAllMembers(signer: SignerOrProvider): Promise<void>;
75
79
  static from(attestations: IProjectResponse[], network: TNetwork): Project[];
80
+ attestUpdate(signer: SignerOrProvider, data: ProjectUpdate, callback?: Function): Promise<void>;
81
+ attestPointer(signer: SignerOrProvider, data: ProjectPointer, callback?: Function): Promise<void>;
76
82
  attestImpact(signer: SignerOrProvider, data: ProjectImpact): Promise<void>;
77
83
  attestEndorsement(signer: SignerOrProvider, data?: ProjectEndorsement): Promise<void>;
78
84
  }
@@ -11,6 +11,8 @@ const MemberOf_1 = require("./MemberOf");
11
11
  const GapContract_1 = require("../contract/GapContract");
12
12
  const AllGapSchemas_1 = require("../AllGapSchemas");
13
13
  const ProjectImpact_1 = require("./ProjectImpact");
14
+ const ProjectUpdate_1 = require("./ProjectUpdate");
15
+ const ProjectPointer_1 = require("./ProjectPointer");
14
16
  class Project extends Attestation_1.Attestation {
15
17
  constructor() {
16
18
  super(...arguments);
@@ -18,6 +20,8 @@ class Project extends Attestation_1.Attestation {
18
20
  this.grants = [];
19
21
  this.impacts = [];
20
22
  this.endorsements = [];
23
+ this.updates = [];
24
+ this.pointers = [];
21
25
  }
22
26
  /**
23
27
  * Creates the payload for a multi-attestation.
@@ -250,6 +254,12 @@ class Project extends Attestation_1.Attestation {
250
254
  if (attestation.impacts) {
251
255
  project.impacts = ProjectImpact_1.ProjectImpact.from(attestation.impacts, network);
252
256
  }
257
+ if (attestation.pointers) {
258
+ project.pointers = ProjectPointer_1.ProjectPointer.from(attestation.pointers, network);
259
+ }
260
+ if (attestation.updates) {
261
+ project.updates = ProjectUpdate_1.ProjectUpdate.from(attestation.updates, network);
262
+ }
253
263
  if (attestation.endorsements) {
254
264
  project.endorsements = attestation.endorsements.map((pi) => {
255
265
  const endorsement = new attestations_1.ProjectEndorsement({
@@ -266,6 +276,32 @@ class Project extends Attestation_1.Attestation {
266
276
  return project;
267
277
  });
268
278
  }
279
+ async attestUpdate(signer, data, callback) {
280
+ const projectUpdate = new ProjectUpdate_1.ProjectUpdate({
281
+ data: {
282
+ ...data,
283
+ type: "project-update",
284
+ },
285
+ recipient: this.recipient,
286
+ refUID: this.uid,
287
+ schema: this.schema.gap.findSchema("ProjectUpdate"),
288
+ });
289
+ await projectUpdate.attest(signer, callback);
290
+ this.updates.push(projectUpdate);
291
+ }
292
+ async attestPointer(signer, data, callback) {
293
+ const projectPointer = new ProjectPointer_1.ProjectPointer({
294
+ data: {
295
+ ...data,
296
+ type: "project-pointer",
297
+ },
298
+ recipient: this.recipient,
299
+ refUID: this.uid,
300
+ schema: this.schema.gap.findSchema("ProjectPointer"),
301
+ });
302
+ await projectPointer.attest(signer, callback);
303
+ this.pointers.push(projectPointer);
304
+ }
269
305
  async attestImpact(signer, data) {
270
306
  const projectImpact = new ProjectImpact_1.ProjectImpact({
271
307
  data: {
@@ -0,0 +1,12 @@
1
+ import { TNetwork } from "../../../core/types";
2
+ import { Attestation } from "../Attestation";
3
+ export interface _IProjectPointer extends ProjectPointer {
4
+ }
5
+ export interface IProjectPointer {
6
+ ogProjectUID: string;
7
+ type?: string;
8
+ }
9
+ export declare class ProjectPointer extends Attestation<IProjectPointer> implements IProjectPointer {
10
+ ogProjectUID: string;
11
+ static from(attestations: _IProjectPointer[], network: TNetwork): ProjectPointer[];
12
+ }
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ProjectPointer = void 0;
4
+ const Attestation_1 = require("../Attestation");
5
+ const AllGapSchemas_1 = require("../AllGapSchemas");
6
+ const consts_1 = require("../../../core/consts");
7
+ class ProjectPointer extends Attestation_1.Attestation {
8
+ static from(attestations, network) {
9
+ return attestations.map((attestation) => {
10
+ const projectUpdate = new ProjectPointer({
11
+ ...attestation,
12
+ data: {
13
+ ...attestation.data,
14
+ },
15
+ schema: new AllGapSchemas_1.AllGapSchemas().findSchema("ProjectUpdate", consts_1.chainIdToNetwork[attestation.chainID]),
16
+ chainID: attestation.chainID,
17
+ });
18
+ return projectUpdate;
19
+ });
20
+ }
21
+ }
22
+ exports.ProjectPointer = ProjectPointer;
@@ -0,0 +1,36 @@
1
+ import { SignerOrProvider, TNetwork } from "../../../core/types";
2
+ import { Attestation } from "../Attestation";
3
+ export interface _IProjectUpdate extends ProjectUpdate {
4
+ }
5
+ export interface IProjectUpdate {
6
+ title: string;
7
+ text: string;
8
+ type?: string;
9
+ }
10
+ type IStatus = "verified";
11
+ export interface IProjectUpdateStatus {
12
+ type: `project-update-${IStatus}`;
13
+ reason?: string;
14
+ }
15
+ export declare class ProjectUpdateStatus extends Attestation<IProjectUpdateStatus> implements IProjectUpdateStatus {
16
+ type: `project-update-${IStatus}`;
17
+ reason?: string;
18
+ }
19
+ export declare class ProjectUpdate extends Attestation<IProjectUpdate> implements IProjectUpdate {
20
+ title: string;
21
+ text: string;
22
+ verified: ProjectUpdateStatus[];
23
+ /**
24
+ * Attest the status of the update as approved, rejected or completed.
25
+ */
26
+ private attestStatus;
27
+ /**
28
+ * Verify this ProjectUpdate. If the ProjectUpdate is not already verified,
29
+ * it will throw an error.
30
+ * @param signer
31
+ * @param reason
32
+ */
33
+ verify(signer: SignerOrProvider, reason?: string, callback?: Function): Promise<void>;
34
+ static from(attestations: _IProjectUpdate[], network: TNetwork): ProjectUpdate[];
35
+ }
36
+ export {};
@@ -0,0 +1,94 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ProjectUpdate = exports.ProjectUpdateStatus = void 0;
4
+ const Attestation_1 = require("../Attestation");
5
+ const SchemaError_1 = require("../SchemaError");
6
+ const AllGapSchemas_1 = require("../AllGapSchemas");
7
+ const consts_1 = require("../../../core/consts");
8
+ class ProjectUpdateStatus extends Attestation_1.Attestation {
9
+ }
10
+ exports.ProjectUpdateStatus = ProjectUpdateStatus;
11
+ class ProjectUpdate extends Attestation_1.Attestation {
12
+ constructor() {
13
+ super(...arguments);
14
+ this.verified = [];
15
+ }
16
+ /**
17
+ * Attest the status of the update as approved, rejected or completed.
18
+ */
19
+ async attestStatus(signer, schema, callback) {
20
+ const eas = this.schema.gap.eas.connect(signer);
21
+ try {
22
+ if (callback)
23
+ callback("preparing");
24
+ const tx = await eas.attest({
25
+ schema: schema.uid,
26
+ data: {
27
+ recipient: this.recipient,
28
+ data: schema.encode(),
29
+ refUID: this.uid,
30
+ expirationTime: 0n,
31
+ revocable: schema.revocable,
32
+ },
33
+ });
34
+ if (callback)
35
+ callback("pending");
36
+ const uid = await tx.wait();
37
+ if (callback)
38
+ callback("confirmed");
39
+ console.log(uid);
40
+ }
41
+ catch (error) {
42
+ console.error(error);
43
+ throw new SchemaError_1.AttestationError("ATTEST_ERROR", error.message);
44
+ }
45
+ }
46
+ /**
47
+ * Verify this ProjectUpdate. If the ProjectUpdate is not already verified,
48
+ * it will throw an error.
49
+ * @param signer
50
+ * @param reason
51
+ */
52
+ async verify(signer, reason = "", callback) {
53
+ console.log("Verifying");
54
+ const schema = this.schema.gap.findSchema("ProjectUpdateStatus");
55
+ schema.setValue("type", "project-update-verified");
56
+ schema.setValue("reason", reason);
57
+ console.log("Before attest project update verified");
58
+ await this.attestStatus(signer, schema, callback);
59
+ console.log("After attest project update verified");
60
+ this.verified.push(new ProjectUpdateStatus({
61
+ data: {
62
+ type: "project-update-verified",
63
+ reason,
64
+ },
65
+ refUID: this.uid,
66
+ schema: schema,
67
+ recipient: this.recipient,
68
+ }));
69
+ }
70
+ static from(attestations, network) {
71
+ return attestations.map((attestation) => {
72
+ const projectUpdate = new ProjectUpdate({
73
+ ...attestation,
74
+ data: {
75
+ ...attestation.data,
76
+ },
77
+ schema: new AllGapSchemas_1.AllGapSchemas().findSchema("ProjectUpdate", consts_1.chainIdToNetwork[attestation.chainID]),
78
+ chainID: attestation.chainID,
79
+ });
80
+ if (attestation.verified?.length > 0) {
81
+ projectUpdate.verified = attestation.verified.map((m) => new ProjectUpdateStatus({
82
+ ...m,
83
+ data: {
84
+ ...m.data,
85
+ },
86
+ schema: new AllGapSchemas_1.AllGapSchemas().findSchema("ProjectUpdateStatus", consts_1.chainIdToNetwork[attestation.chainID]),
87
+ chainID: attestation.chainID,
88
+ }));
89
+ }
90
+ return projectUpdate;
91
+ });
92
+ }
93
+ }
94
+ exports.ProjectUpdate = ProjectUpdate;
@@ -4,3 +4,5 @@ export * from "./Project";
4
4
  export * from "./Community";
5
5
  export * from "./MemberOf";
6
6
  export * from "./GrantUpdate";
7
+ export * from "./ProjectUpdate";
8
+ export * from "./ProjectPointer";
@@ -20,3 +20,5 @@ __exportStar(require("./Project"), exports);
20
20
  __exportStar(require("./Community"), exports);
21
21
  __exportStar(require("./MemberOf"), exports);
22
22
  __exportStar(require("./GrantUpdate"), exports);
23
+ __exportStar(require("./ProjectUpdate"), exports);
24
+ __exportStar(require("./ProjectPointer"), exports);
@@ -68,6 +68,28 @@ export interface IGrantUpdate extends IAttestationResponse {
68
68
  };
69
69
  verified?: IGrantUpdateStatus[];
70
70
  }
71
+ export interface IProjectUpdateStatus extends IAttestationResponse {
72
+ type: `project-update-${IStatus}`;
73
+ reason?: string;
74
+ data: {
75
+ type: "approved" | "rejected" | "completed";
76
+ reason?: string;
77
+ };
78
+ }
79
+ export interface IProjectUpdate extends IAttestationResponse {
80
+ data: {
81
+ text: string;
82
+ title: string;
83
+ type: "project-update";
84
+ };
85
+ verified?: IProjectUpdateStatus[];
86
+ }
87
+ export interface IProjectPointer extends IAttestationResponse {
88
+ data: {
89
+ ogProjectUID: string;
90
+ type: "project-pointer";
91
+ };
92
+ }
71
93
  export interface IGrantDetails extends IAttestationResponse {
72
94
  type: "GrantDetails";
73
95
  data: {
@@ -165,6 +187,9 @@ export interface IProjectResponse extends IAttestationResponse {
165
187
  grants: IGrantResponse[];
166
188
  grantee: any;
167
189
  impacts: IProjectImpact[];
190
+ updates: IProjectUpdate[];
191
+ pointers: IProjectPointer[];
192
+ symlinks: Hex[];
168
193
  endorsements: IProjectEndorsement[];
169
194
  }
170
195
  export interface ICommunityDetails extends IAttestationResponse {
package/core/consts.js CHANGED
@@ -11,6 +11,7 @@ exports.useDefaultAttestation = [
11
11
  "GrantVerified",
12
12
  "Community",
13
13
  "GrantUpdateStatus",
14
+ "ProjectUpdateStatus",
14
15
  ];
15
16
  exports.chainIdToNetwork = {
16
17
  11155420: "optimism-sepolia",
@@ -53,6 +54,7 @@ exports.Networks = {
53
54
  MilestoneCompleted: "0x13adc8df8a7324b1651e8bcec948b3e2d4fcfa2a88a52136206cb9ea44836e93",
54
55
  GrantUpdateStatus: "0x13adc8df8a7324b1651e8bcec948b3e2d4fcfa2a88a52136206cb9ea44836e93",
55
56
  Project: "0x5b873b6e7a16207b526dde366e8164e95bcda2f009272306519667c5e94d2191",
57
+ ProjectUpdateStatus: "0x13adc8df8a7324b1651e8bcec948b3e2d4fcfa2a88a52136206cb9ea44836e93",
56
58
  },
57
59
  },
58
60
  "optimism-sepolia": {
@@ -77,6 +79,7 @@ exports.Networks = {
77
79
  MilestoneCompleted: "0xf9ec600d61d88614c863365a79715a7ba29781ec67643ffeb9222dd8873ee3fa",
78
80
  GrantUpdateStatus: "0xf9ec600d61d88614c863365a79715a7ba29781ec67643ffeb9222dd8873ee3fa",
79
81
  Project: "0xf9bbd118dd100459a7d093403af21c6e7f847fd7f331b7a4e6bfb94a1366bd76",
82
+ ProjectUpdateStatus: "0xf9ec600d61d88614c863365a79715a7ba29781ec67643ffeb9222dd8873ee3fa",
80
83
  },
81
84
  },
82
85
  arbitrum: {
@@ -101,6 +104,7 @@ exports.Networks = {
101
104
  MilestoneCompleted: "0xd25ccdfbf87659a9081681eb90598d8b944ed28544da7d57c3ccbe6e6422cc15",
102
105
  GrantUpdateStatus: "0xd25ccdfbf87659a9081681eb90598d8b944ed28544da7d57c3ccbe6e6422cc15",
103
106
  Project: "0xac2a06e955a7e25e6729efe1a6532237e3435b21ccd3dc827ae3c94e624d25b3",
107
+ ProjectUpdateStatus: "0xd25ccdfbf87659a9081681eb90598d8b944ed28544da7d57c3ccbe6e6422cc15",
104
108
  },
105
109
  },
106
110
  sepolia: {
@@ -126,6 +130,7 @@ exports.Networks = {
126
130
  MilestoneCompleted: "0xcdef0e492d2e7ad25d0b0fdb868f6dcd1f5e5c30e42fd5fa0debdc12f7618322",
127
131
  GrantUpdateStatus: "0xcdef0e492d2e7ad25d0b0fdb868f6dcd1f5e5c30e42fd5fa0debdc12f7618322",
128
132
  Project: "0xec77990a252b54b17673955c774b9712766de5eecb22ca5aa2c440e0e93257fb",
133
+ ProjectUpdateStatus: "0xcdef0e492d2e7ad25d0b0fdb868f6dcd1f5e5c30e42fd5fa0debdc12f7618322",
129
134
  },
130
135
  },
131
136
  "base-sepolia": {
@@ -150,6 +155,7 @@ exports.Networks = {
150
155
  MilestoneCompleted: "0xe9cce07bd9295aafc78faa7afdd88a6fad6fd61834a048fb8c3dbc86cb471f81",
151
156
  GrantUpdateStatus: "0xe9cce07bd9295aafc78faa7afdd88a6fad6fd61834a048fb8c3dbc86cb471f81",
152
157
  Project: "0x5ddd6b7a11406771308431ca9bd146cc717848b74b52993a532dc1aad0ccc83f",
158
+ ProjectUpdateStatus: "0xe9cce07bd9295aafc78faa7afdd88a6fad6fd61834a048fb8c3dbc86cb471f81",
153
159
  },
154
160
  },
155
161
  celo: {
@@ -174,9 +180,10 @@ exports.Networks = {
174
180
  MilestoneCompleted: "0xf45fdf2c064073f0623416571c2746085d785cde5a57fd0696ff88bdf78bcbdc",
175
181
  GrantUpdateStatus: "0xf45fdf2c064073f0623416571c2746085d785cde5a57fd0696ff88bdf78bcbdc",
176
182
  Project: "0xf3f753b41e04d1052b5a5ec7624d1dfdb6c2da288a985120e477ddbcac071022",
183
+ ProjectUpdateStatus: "0xf45fdf2c064073f0623416571c2746085d785cde5a57fd0696ff88bdf78bcbdc",
177
184
  },
178
185
  },
179
- "sei": {
186
+ sei: {
180
187
  chainId: 1329,
181
188
  url: "https://sei.easscan.org/graphql",
182
189
  rpcUrl: "https://evm-rpc.sei-apis.com",
@@ -198,6 +205,7 @@ exports.Networks = {
198
205
  MilestoneCompleted: "0x6edc90af92553109cfed1292a67a75b34e41880bd8a61e9d05db0473b69a2f9e",
199
206
  GrantUpdateStatus: "0x6edc90af92553109cfed1292a67a75b34e41880bd8a61e9d05db0473b69a2f9e",
200
207
  Project: "0xf6b89107f8096220051240b89a48abb66e0a23e529c914953b80f5a2bc5ea44c",
208
+ ProjectUpdateStatus: "0x6edc90af92553109cfed1292a67a75b34e41880bd8a61e9d05db0473b69a2f9e",
201
209
  },
202
210
  },
203
211
  "sei-testnet": {
@@ -221,7 +229,8 @@ exports.Networks = {
221
229
  MilestoneApproved: "0xb25551d21dc886be83a07c241c46de318704cb6f485191fdedcf80f4b8b28188",
222
230
  MilestoneCompleted: "0xb25551d21dc886be83a07c241c46de318704cb6f485191fdedcf80f4b8b28188",
223
231
  GrantUpdateStatus: "0xb25551d21dc886be83a07c241c46de318704cb6f485191fdedcf80f4b8b28188",
224
- Project: "0x9de9294fbb62391b39332a33bfc28b4e0e728dd094aee4bda3955df62f8401a5",
232
+ Project: "0x9de9294fbb62391b393332a33bfc28b4e0e728dd094aee4bda3955df62f8401a5",
233
+ ProjectUpdateStatus: "0xb25551d21dc886be83a07c241c46de318704cb6f485191fdedcf80f4b8b28188",
225
234
  },
226
235
  },
227
236
  };
@@ -344,6 +353,27 @@ const MountEntities = (network) => ({
344
353
  uid: network.schemas.Details,
345
354
  references: "Project",
346
355
  },
356
+ ProjectUpdate: {
357
+ name: "ProjectUpdate",
358
+ schema: DetailsSchema,
359
+ uid: network.schemas.Details,
360
+ references: "Project",
361
+ },
362
+ ProjectUpdateStatus: {
363
+ name: "ProjectUpdateStatus",
364
+ schema: [
365
+ { type: "string", name: "type", value: null },
366
+ { type: "string", name: "reason", value: "" },
367
+ ],
368
+ uid: network.schemas.ProjectUpdateStatus,
369
+ references: "ProjectUpdate",
370
+ },
371
+ ProjectPointer: {
372
+ name: "ProjectPointer",
373
+ schema: DetailsSchema,
374
+ uid: network.schemas.Details,
375
+ references: "Project",
376
+ },
347
377
  });
348
378
  exports.MountEntities = MountEntities;
349
379
  exports.alloSupportedNetworks = {
package/core/types.d.ts CHANGED
@@ -23,8 +23,8 @@ export interface AttestArgs<T = unknown> {
23
23
  signer: SignerOrProvider;
24
24
  callback?: (status: CallbackStatus) => void;
25
25
  }
26
- export type TSchemaName = "Community" | "CommunityDetails" | "Grant" | "GrantDetails" | "GrantVerified" | "MemberOf" | "MemberDetails" | "Milestone" | "MilestoneCompleted" | "MilestoneApproved" | "Project" | "ProjectDetails" | "Details" | "ProjectImpact" | "GrantUpdate" | "GrantUpdateStatus" | "ProjectEndorsement";
27
- export type TResolvedSchemaNames = "Community" | "Grant" | "GrantVerified" | "MemberOf" | "MilestoneCompleted" | "MilestoneApproved" | "Project" | "Details" | "GrantUpdateStatus";
26
+ export type TSchemaName = "Community" | "CommunityDetails" | "Grant" | "GrantDetails" | "GrantVerified" | "MemberOf" | "MemberDetails" | "Milestone" | "MilestoneCompleted" | "MilestoneApproved" | "Project" | "ProjectDetails" | "Details" | "ProjectImpact" | "ProjectUpdate" | "ProjectUpdateStatus" | "ProjectPointer" | "GrantUpdate" | "GrantUpdateStatus" | "ProjectEndorsement";
27
+ export type TResolvedSchemaNames = "Community" | "Grant" | "GrantVerified" | "MemberOf" | "MilestoneCompleted" | "MilestoneApproved" | "Project" | "Details" | "ProjectUpdateStatus" | "GrantUpdateStatus" | "ProjectUpdateStatus";
28
28
  export type TExternalLink = "twitter" | "github" | "website" | "linkedin" | "discord";
29
29
  export type TNetwork = "optimism" | "celo" | "optimism-sepolia" | "arbitrum" | "sepolia" | "sei" | "sei-testnet" | "base-sepolia";
30
30
  /**
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "publishConfig": {
4
4
  "access": "public"
5
5
  },
6
- "version": "0.3.41",
6
+ "version": "0.3.42",
7
7
  "description": "Simple and easy interface between EAS and Karma GAP.",
8
8
  "main": "./index.js",
9
9
  "author": "KarmaHQ",