@show-karma/karma-gap-sdk 0.3.17 → 0.3.19

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.
@@ -50,6 +50,15 @@ class Community extends Attestation_1.Attestation {
50
50
  data: this.data,
51
51
  });
52
52
  console.log(this.uid);
53
+ if (details) {
54
+ const communityDetails = new attestations_1.CommunityDetails({
55
+ data: details,
56
+ recipient: this.recipient,
57
+ refUID: this.uid,
58
+ schema: this.schema.gap.findSchema('CommunityDetails'),
59
+ });
60
+ await communityDetails.attest(signer);
61
+ }
53
62
  }
54
63
  catch (error) {
55
64
  console.error(error);
@@ -1,9 +1,10 @@
1
1
  import { Attestation } from '../Attestation';
2
- import { GrantDetails, GrantRound, GrantUpdate, IGrantUpdate, GrantCompleted } from '../types/attestations';
2
+ import { GrantDetails, GrantRound, GrantCompleted } from '../types/attestations';
3
3
  import { IMilestone, Milestone } from './Milestone';
4
4
  import { GapSchema } from '../GapSchema';
5
5
  import { Hex, MultiAttestPayload, SignerOrProvider, TNetwork } from 'core/types';
6
6
  import { Community } from './Community';
7
+ import { GrantUpdate, IGrantUpdate } from './GrantUpdate';
7
8
  interface _Grant extends Grant {
8
9
  }
9
10
  export interface IGrant {
@@ -10,6 +10,7 @@ const GapContract_1 = require("../contract/GapContract");
10
10
  const Community_1 = require("./Community");
11
11
  const Project_1 = require("./Project");
12
12
  const AllGapSchemas_1 = require("../AllGapSchemas");
13
+ const GrantUpdate_1 = require("./GrantUpdate");
13
14
  class Grant extends Attestation_1.Attestation {
14
15
  constructor() {
15
16
  super(...arguments);
@@ -123,7 +124,7 @@ class Grant extends Attestation_1.Attestation {
123
124
  console.log(uids);
124
125
  }
125
126
  async attestUpdate(signer, data) {
126
- const grantUpdate = new attestations_1.GrantUpdate({
127
+ const grantUpdate = new GrantUpdate_1.GrantUpdate({
127
128
  data: {
128
129
  ...data,
129
130
  type: 'grant-update',
@@ -184,14 +185,7 @@ class Grant extends Attestation_1.Attestation {
184
185
  }
185
186
  if (attestation.updates) {
186
187
  const { updates } = attestation;
187
- grant.updates = updates.map((u) => new attestations_1.GrantUpdate({
188
- ...u,
189
- data: {
190
- ...u.data,
191
- },
192
- schema: new AllGapSchemas_1.AllGapSchemas().findSchema('GrantDetails', consts_1.chainIdToNetwork[attestation.chainID]),
193
- chainID: attestation.chainID,
194
- }));
188
+ grant.updates = GrantUpdate_1.GrantUpdate.from(updates, network);
195
189
  }
196
190
  if (attestation.completed) {
197
191
  const { completed } = attestation;
@@ -0,0 +1,36 @@
1
+ import { SignerOrProvider, TNetwork } from '../../../core/types';
2
+ import { Attestation } from '../Attestation';
3
+ interface _IGrantUpdate extends GrantUpdate {
4
+ }
5
+ export interface IGrantUpdate {
6
+ title: string;
7
+ text: string;
8
+ type?: string;
9
+ }
10
+ type IStatus = 'verified';
11
+ export interface IGrantUpdateStatus {
12
+ type: `grant-update-${IStatus}`;
13
+ reason?: string;
14
+ }
15
+ export declare class GrantUpdateStatus extends Attestation<IGrantUpdateStatus> implements IGrantUpdateStatus {
16
+ type: `grant-update-${IStatus}`;
17
+ reason?: string;
18
+ }
19
+ export declare class GrantUpdate extends Attestation<IGrantUpdate> implements IGrantUpdate {
20
+ title: string;
21
+ text: string;
22
+ verified: GrantUpdateStatus[];
23
+ /**
24
+ * Attest the status of the milestone as approved, rejected or completed.
25
+ */
26
+ private attestStatus;
27
+ /**
28
+ * Verify this GrantUpdate. If the GrantUpdate is not already verified,
29
+ * it will throw an error.
30
+ * @param signer
31
+ * @param reason
32
+ */
33
+ verify(signer: SignerOrProvider, reason?: string): Promise<void>;
34
+ static from(attestations: _IGrantUpdate[], network: TNetwork): GrantUpdate[];
35
+ }
36
+ export {};
@@ -0,0 +1,88 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.GrantUpdate = exports.GrantUpdateStatus = 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 GrantUpdateStatus extends Attestation_1.Attestation {
9
+ }
10
+ exports.GrantUpdateStatus = GrantUpdateStatus;
11
+ class GrantUpdate extends Attestation_1.Attestation {
12
+ constructor() {
13
+ super(...arguments);
14
+ this.verified = [];
15
+ }
16
+ /**
17
+ * Attest the status of the milestone as approved, rejected or completed.
18
+ */
19
+ async attestStatus(signer, schema) {
20
+ const eas = this.schema.gap.eas.connect(signer);
21
+ try {
22
+ const tx = await eas.attest({
23
+ schema: schema.uid,
24
+ data: {
25
+ recipient: this.recipient,
26
+ data: schema.encode(),
27
+ refUID: this.uid,
28
+ expirationTime: 0n,
29
+ revocable: schema.revocable,
30
+ },
31
+ });
32
+ const uid = await tx.wait();
33
+ console.log(uid);
34
+ }
35
+ catch (error) {
36
+ console.error(error);
37
+ throw new SchemaError_1.AttestationError('ATTEST_ERROR', error.message);
38
+ }
39
+ }
40
+ /**
41
+ * Verify this GrantUpdate. If the GrantUpdate is not already verified,
42
+ * it will throw an error.
43
+ * @param signer
44
+ * @param reason
45
+ */
46
+ async verify(signer, reason = '') {
47
+ console.log('Verifying');
48
+ const schema = this.schema.gap.findSchema('GrantUpdateStatus');
49
+ schema.setValue('type', 'grant-update-verified');
50
+ schema.setValue('reason', reason);
51
+ console.log('Before attest grant update verified');
52
+ await this.attestStatus(signer, schema);
53
+ console.log('After attest grant update verified');
54
+ this.verified.push(new GrantUpdateStatus({
55
+ data: {
56
+ type: 'grant-update-verified',
57
+ reason,
58
+ },
59
+ refUID: this.uid,
60
+ schema: schema,
61
+ recipient: this.recipient,
62
+ }));
63
+ }
64
+ static from(attestations, network) {
65
+ return attestations.map((attestation) => {
66
+ const grantUpdate = new GrantUpdate({
67
+ ...attestation,
68
+ data: {
69
+ ...attestation.data,
70
+ },
71
+ schema: new AllGapSchemas_1.AllGapSchemas().findSchema('GrantUpdate', consts_1.chainIdToNetwork[attestation.chainID]),
72
+ chainID: attestation.chainID,
73
+ });
74
+ if (attestation.verified?.length > 0) {
75
+ grantUpdate.verified = attestation.verified.map(m => new GrantUpdateStatus({
76
+ ...m,
77
+ data: {
78
+ ...m.data,
79
+ },
80
+ schema: new AllGapSchemas_1.AllGapSchemas().findSchema('GrantUpdateStatus', consts_1.chainIdToNetwork[attestation.chainID]),
81
+ chainID: attestation.chainID,
82
+ }));
83
+ }
84
+ return grantUpdate;
85
+ });
86
+ }
87
+ }
88
+ exports.GrantUpdate = GrantUpdate;
@@ -3,3 +3,4 @@ export * from "./Milestone";
3
3
  export * from "./Project";
4
4
  export * from "./Community";
5
5
  export * from "./MemberOf";
6
+ export * from "./GrantUpdate";
@@ -19,3 +19,4 @@ __exportStar(require("./Milestone"), exports);
19
19
  __exportStar(require("./Project"), exports);
20
20
  __exportStar(require("./Community"), exports);
21
21
  __exportStar(require("./MemberOf"), exports);
22
+ __exportStar(require("./GrantUpdate"), exports);
@@ -2,6 +2,7 @@ import { Attestation, AttestationArgs } from '../Attestation';
2
2
  import { Hex } from 'core/types';
3
3
  import { Project } from '../entities/Project';
4
4
  import { GapSchema } from '../GapSchema';
5
+ import { GrantUpdate } from '../entities/GrantUpdate';
5
6
  /** Attestation interfaces */
6
7
  export type ExternalLink = {
7
8
  type: string;
@@ -14,6 +15,7 @@ export interface ICommunityDetails {
14
15
  slug?: string;
15
16
  links?: ExternalLink;
16
17
  type?: string;
18
+ externalId?: string;
17
19
  }
18
20
  export declare class CommunityDetails extends Attestation<ICommunityDetails> implements ICommunityDetails {
19
21
  name: string;
@@ -22,6 +24,7 @@ export declare class CommunityDetails extends Attestation<ICommunityDetails> imp
22
24
  links: ExternalLink;
23
25
  slug?: string;
24
26
  type: string;
27
+ externalId?: string;
25
28
  }
26
29
  export interface IGrantDetails {
27
30
  title: string;
@@ -70,11 +73,11 @@ export declare class MemberDetails extends Attestation<IMemberDetails> implement
70
73
  profilePictureURL: string;
71
74
  }
72
75
  export interface IMilestoneCompleted {
73
- type: 'approved' | 'rejected' | 'completed' | 'verified';
76
+ type: "approved" | "rejected" | "completed" | "verified";
74
77
  reason?: string;
75
78
  }
76
79
  export declare class MilestoneCompleted extends Attestation<IMilestoneCompleted> implements IMilestoneCompleted {
77
- type: 'approved' | 'rejected' | 'completed' | 'verified';
80
+ type: "approved" | "rejected" | "completed" | "verified";
78
81
  reason?: string;
79
82
  }
80
83
  export interface ITag {
@@ -89,6 +92,7 @@ export interface IProjectDetails {
89
92
  imageURL: string;
90
93
  links?: ExternalLink;
91
94
  tags?: ITag[];
95
+ externalIds?: string[];
92
96
  slug?: string;
93
97
  type?: string;
94
98
  }
@@ -100,21 +104,13 @@ export declare class ProjectDetails extends Attestation<IProjectDetails> impleme
100
104
  tags: ITag[];
101
105
  slug: string;
102
106
  type: string;
107
+ externalIds: string[];
103
108
  }
104
109
  export declare class Grantee {
105
110
  address: string;
106
111
  projects: Project[];
107
112
  constructor(address: Hex, projects?: Project[]);
108
113
  }
109
- export interface IGrantUpdate {
110
- title: string;
111
- text: string;
112
- type?: string;
113
- }
114
- export declare class GrantUpdate extends Attestation<IGrantUpdate> implements IGrantUpdate {
115
- title: string;
116
- text: string;
117
- }
118
114
  export declare class GrantCompleted extends GrantUpdate {
119
115
  }
120
116
  export interface IGrantDetailsQuestion {
@@ -1,19 +1,20 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ProjectImpact = exports.GrantCompleted = exports.GrantUpdate = exports.Grantee = exports.ProjectDetails = exports.Tag = exports.MilestoneCompleted = exports.MemberDetails = exports.GrantVerified = exports.GrantRound = exports.GrantDetails = exports.CommunityDetails = void 0;
3
+ exports.ProjectImpact = exports.GrantCompleted = exports.Grantee = exports.ProjectDetails = exports.Tag = exports.MilestoneCompleted = exports.MemberDetails = exports.GrantVerified = exports.GrantRound = exports.GrantDetails = exports.CommunityDetails = void 0;
4
4
  const Attestation_1 = require("../Attestation");
5
+ const GrantUpdate_1 = require("../entities/GrantUpdate");
5
6
  class CommunityDetails extends Attestation_1.Attestation {
6
7
  constructor() {
7
8
  super(...arguments);
8
9
  this.links = [];
9
- this.type = 'community-details';
10
+ this.type = "community-details";
10
11
  }
11
12
  }
12
13
  exports.CommunityDetails = CommunityDetails;
13
14
  class GrantDetails extends Attestation_1.Attestation {
14
15
  constructor() {
15
16
  super(...arguments);
16
- this.type = 'grant-details';
17
+ this.type = "grant-details";
17
18
  }
18
19
  }
19
20
  exports.GrantDetails = GrantDetails;
@@ -37,7 +38,8 @@ class ProjectDetails extends Attestation_1.Attestation {
37
38
  super(...arguments);
38
39
  this.links = [];
39
40
  this.tags = [];
40
- this.type = 'project-details';
41
+ this.type = "project-details";
42
+ this.externalIds = [];
41
43
  }
42
44
  }
43
45
  exports.ProjectDetails = ProjectDetails;
@@ -49,15 +51,12 @@ class Grantee {
49
51
  }
50
52
  }
51
53
  exports.Grantee = Grantee;
52
- class GrantUpdate extends Attestation_1.Attestation {
53
- }
54
- exports.GrantUpdate = GrantUpdate;
55
- class GrantCompleted extends GrantUpdate {
54
+ class GrantCompleted extends GrantUpdate_1.GrantUpdate {
56
55
  }
57
56
  exports.GrantCompleted = GrantCompleted;
58
57
  class ProjectImpact extends Attestation_1.Attestation {
59
58
  constructor(data) {
60
- data.data.type = 'project-impact';
59
+ data.data.type = "project-impact";
61
60
  super(data);
62
61
  }
63
62
  }
package/core/consts.js CHANGED
@@ -10,6 +10,7 @@ exports.useDefaultAttestation = [
10
10
  "MilestoneCompleted",
11
11
  "GrantVerified",
12
12
  "Community",
13
+ "GrantUpdateStatus"
13
14
  ];
14
15
  exports.chainIdToNetwork = {
15
16
  11155420: 'optimism-sepolia',
@@ -45,6 +46,7 @@ exports.Networks = {
45
46
  MemberOf: "0x7fbb8a65924d8ad2ae12356e04b1418043e8361ba3b1b6c917de2e23df3ec81c",
46
47
  MilestoneApproved: "0x13adc8df8a7324b1651e8bcec948b3e2d4fcfa2a88a52136206cb9ea44836e93",
47
48
  MilestoneCompleted: "0x13adc8df8a7324b1651e8bcec948b3e2d4fcfa2a88a52136206cb9ea44836e93",
49
+ GrantUpdateStatus: "0x13adc8df8a7324b1651e8bcec948b3e2d4fcfa2a88a52136206cb9ea44836e93",
48
50
  Project: "0x5b873b6e7a16207b526dde366e8164e95bcda2f009272306519667c5e94d2191",
49
51
  },
50
52
  },
@@ -67,6 +69,7 @@ exports.Networks = {
67
69
  MemberOf: "0x611f9655188f372e27dce116a803fa9081ca3e2907986368d54fcad538ca3853",
68
70
  MilestoneApproved: "0xf9ec600d61d88614c863365a79715a7ba29781ec67643ffeb9222dd8873ee3fa",
69
71
  MilestoneCompleted: "0xf9ec600d61d88614c863365a79715a7ba29781ec67643ffeb9222dd8873ee3fa",
72
+ GrantUpdateStatus: "0xf9ec600d61d88614c863365a79715a7ba29781ec67643ffeb9222dd8873ee3fa",
70
73
  Project: "0xf9bbd118dd100459a7d093403af21c6e7f847fd7f331b7a4e6bfb94a1366bd76",
71
74
  },
72
75
  },
@@ -89,6 +92,7 @@ exports.Networks = {
89
92
  MemberOf: "0x5f430aec9d04f0dcb3729775c5dfe10752e436469a7607f8c64ae44ef996e477",
90
93
  MilestoneApproved: "0xd25ccdfbf87659a9081681eb90598d8b944ed28544da7d57c3ccbe6e6422cc15",
91
94
  MilestoneCompleted: "0xd25ccdfbf87659a9081681eb90598d8b944ed28544da7d57c3ccbe6e6422cc15",
95
+ GrantUpdateStatus: "0xd25ccdfbf87659a9081681eb90598d8b944ed28544da7d57c3ccbe6e6422cc15",
92
96
  Project: "0xac2a06e955a7e25e6729efe1a6532237e3435b21ccd3dc827ae3c94e624d25b3",
93
97
  },
94
98
  },
@@ -112,6 +116,7 @@ exports.Networks = {
112
116
  MemberOf: "0xdd87b3500457931252424f4439365534ba72a367503a8805ff3482353fb90301",
113
117
  MilestoneApproved: "0xcdef0e492d2e7ad25d0b0fdb868f6dcd1f5e5c30e42fd5fa0debdc12f7618322",
114
118
  MilestoneCompleted: "0xcdef0e492d2e7ad25d0b0fdb868f6dcd1f5e5c30e42fd5fa0debdc12f7618322",
119
+ GrantUpdateStatus: "0xcdef0e492d2e7ad25d0b0fdb868f6dcd1f5e5c30e42fd5fa0debdc12f7618322",
115
120
  Project: "0xec77990a252b54b17673955c774b9712766de5eecb22ca5aa2c440e0e93257fb",
116
121
  },
117
122
  },
@@ -214,5 +219,20 @@ const MountEntities = (network) => ({
214
219
  uid: network.schemas.Details,
215
220
  references: "Project",
216
221
  },
222
+ GrantUpdate: {
223
+ name: "GrantUpdate",
224
+ schema: DetailsSchema,
225
+ uid: network.schemas.Details,
226
+ references: "Grant",
227
+ },
228
+ GrantUpdateStatus: {
229
+ name: "GrantUpdateStatus",
230
+ schema: [
231
+ { type: "string", name: "type", value: null },
232
+ { type: "string", name: "reason", value: "" },
233
+ ],
234
+ uid: network.schemas.GrantUpdateStatus,
235
+ references: "GrantUpdate",
236
+ },
217
237
  });
218
238
  exports.MountEntities = MountEntities;
package/core/types.d.ts CHANGED
@@ -21,8 +21,8 @@ export interface AttestArgs<T = unknown> {
21
21
  refUID?: Hex;
22
22
  signer: SignerOrProvider;
23
23
  }
24
- export type TSchemaName = 'Community' | 'CommunityDetails' | 'Grant' | 'GrantDetails' | 'GrantVerified' | 'MemberOf' | 'MemberDetails' | 'Milestone' | 'MilestoneCompleted' | 'MilestoneApproved' | 'Project' | 'ProjectDetails' | 'Details' | 'ProjectImpact';
25
- export type TResolvedSchemaNames = 'Community' | 'Grant' | 'GrantVerified' | 'MemberOf' | 'MilestoneCompleted' | 'MilestoneApproved' | 'Project' | 'Details';
24
+ export type TSchemaName = 'Community' | 'CommunityDetails' | 'Grant' | 'GrantDetails' | 'GrantVerified' | 'MemberOf' | 'MemberDetails' | 'Milestone' | 'MilestoneCompleted' | 'MilestoneApproved' | 'Project' | 'ProjectDetails' | 'Details' | 'ProjectImpact' | 'GrantUpdate' | 'GrantUpdateStatus';
25
+ export type TResolvedSchemaNames = 'Community' | 'Grant' | 'GrantVerified' | 'MemberOf' | 'MilestoneCompleted' | 'MilestoneApproved' | 'Project' | 'Details' | 'GrantUpdateStatus';
26
26
  export type TExternalLink = 'twitter' | 'github' | 'website' | 'linkedin' | 'discord';
27
27
  export type TNetwork = 'optimism' | 'optimism-sepolia' | "arbitrum" | 'sepolia';
28
28
  /**
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "publishConfig": {
4
4
  "access": "public"
5
5
  },
6
- "version": "0.3.17",
6
+ "version": "0.3.19",
7
7
  "description": "Simple and easy interface between EAS and Karma GAP.",
8
8
  "main": "./index.js",
9
9
  "author": "KarmaHQ",