@show-karma/karma-gap-sdk 0.4.16 → 0.4.18

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 (188) hide show
  1. package/core/abi/AirdropNFT.json +1 -1
  2. package/core/abi/Allo.json +860 -860
  3. package/core/abi/AlloRegistry.json +578 -578
  4. package/core/abi/CommunityResolverABI.json +506 -506
  5. package/core/abi/Donations.json +251 -251
  6. package/core/abi/EAS.json +1 -1
  7. package/core/abi/MultiAttester.json +746 -746
  8. package/core/abi/ProjectResolver.json +574 -574
  9. package/core/abi/SchemaRegistry.json +1 -1
  10. package/core/abi/index.d.ts +1114 -0
  11. package/core/abi/index.js +26 -0
  12. package/core/class/AllGapSchemas.d.ts +9 -0
  13. package/core/class/AllGapSchemas.js +19 -0
  14. package/core/class/Attestation.d.ts +173 -0
  15. package/core/class/Attestation.js +333 -0
  16. package/core/class/Fetcher.d.ts +175 -0
  17. package/core/class/Fetcher.js +13 -0
  18. package/core/class/GAP.d.ts +254 -0
  19. package/core/class/GAP.js +289 -0
  20. package/core/class/GapSchema.d.ts +34 -0
  21. package/core/class/GapSchema.js +62 -0
  22. package/core/class/Gelato/{Gelato.ts → Gelato.js} +0 -23
  23. package/core/class/GrantProgramRegistry/Allo.d.ts +17 -0
  24. package/core/class/GrantProgramRegistry/Allo.js +137 -0
  25. package/core/class/GrantProgramRegistry/AlloRegistry.d.ts +15 -0
  26. package/core/class/GrantProgramRegistry/AlloRegistry.js +70 -0
  27. package/core/class/GraphQL/AxiosGQL.d.ts +6 -0
  28. package/core/class/GraphQL/AxiosGQL.js +25 -0
  29. package/core/class/GraphQL/EASClient.d.ts +16 -0
  30. package/core/class/GraphQL/EASClient.js +26 -0
  31. package/core/class/GraphQL/GapEasClient.d.ts +71 -0
  32. package/core/class/GraphQL/GapEasClient.js +451 -0
  33. package/core/class/GraphQL/index.js +19 -0
  34. package/core/class/Schema.d.ts +233 -0
  35. package/core/class/Schema.js +490 -0
  36. package/core/class/SchemaError.d.ts +30 -0
  37. package/core/class/SchemaError.js +39 -0
  38. package/core/class/contract/GapContract.d.ts +102 -0
  39. package/core/class/contract/GapContract.js +285 -0
  40. package/core/class/entities/Community.d.ts +34 -0
  41. package/core/class/entities/Community.js +109 -0
  42. package/core/class/entities/ContributorProfile.d.ts +41 -0
  43. package/core/class/entities/ContributorProfile.js +69 -0
  44. package/core/class/entities/Grant.d.ts +54 -0
  45. package/core/class/entities/Grant.js +223 -0
  46. package/core/class/entities/GrantUpdate.d.ts +62 -0
  47. package/core/class/entities/GrantUpdate.js +114 -0
  48. package/core/class/entities/MemberOf.d.ts +11 -0
  49. package/core/class/entities/MemberOf.js +33 -0
  50. package/core/class/entities/Milestone.d.ts +168 -0
  51. package/core/class/entities/Milestone.js +657 -0
  52. package/core/class/entities/Project.d.ts +92 -0
  53. package/core/class/entities/Project.js +418 -0
  54. package/core/class/entities/ProjectImpact.d.ts +50 -0
  55. package/core/class/entities/ProjectImpact.js +112 -0
  56. package/core/class/entities/ProjectMilestone.d.ts +60 -0
  57. package/core/class/entities/ProjectMilestone.js +174 -0
  58. package/core/class/entities/ProjectPointer.d.ts +12 -0
  59. package/core/class/entities/ProjectPointer.js +22 -0
  60. package/core/class/entities/ProjectUpdate.d.ts +50 -0
  61. package/core/class/entities/ProjectUpdate.js +110 -0
  62. package/core/class/entities/Track.d.ts +16 -0
  63. package/core/class/entities/Track.js +21 -0
  64. package/core/class/entities/index.js +26 -0
  65. package/core/class/index.js +26 -0
  66. package/core/class/karma-indexer/GapIndexerClient.d.ts +66 -0
  67. package/core/class/karma-indexer/GapIndexerClient.js +207 -0
  68. package/core/class/karma-indexer/api/GapIndexerApi.d.ts +73 -0
  69. package/core/class/karma-indexer/api/GapIndexerApi.js +256 -0
  70. package/core/class/karma-indexer/api/types.d.ts +309 -0
  71. package/core/class/karma-indexer/api/types.js +2 -0
  72. package/core/class/remote-storage/IpfsStorage.d.ts +23 -0
  73. package/core/class/remote-storage/IpfsStorage.js +56 -0
  74. package/core/class/remote-storage/RemoteStorage.d.ts +41 -0
  75. package/core/class/remote-storage/RemoteStorage.js +38 -0
  76. package/core/class/types/allo.d.ts +78 -0
  77. package/core/class/types/allo.js +2 -0
  78. package/core/class/types/attestations.d.ts +173 -0
  79. package/core/class/types/attestations.js +66 -0
  80. package/core/consts.d.ts +50 -0
  81. package/core/consts.js +699 -0
  82. package/core/index.js +24 -0
  83. package/core/shared/types.d.ts +13 -0
  84. package/core/shared/types.js +2 -0
  85. package/core/types.d.ts +131 -0
  86. package/core/types.js +13 -0
  87. package/core/utils/gelato/index.js +19 -0
  88. package/core/utils/gelato/send-gelato-txn.d.ts +55 -0
  89. package/core/utils/gelato/send-gelato-txn.js +100 -0
  90. package/core/utils/gelato/sponsor-handler.d.ts +9 -0
  91. package/core/utils/gelato/sponsor-handler.js +60 -0
  92. package/core/utils/gelato/watch-gelato-txn.d.ts +7 -0
  93. package/core/utils/gelato/watch-gelato-txn.js +63 -0
  94. package/core/utils/get-date.d.ts +1 -0
  95. package/core/utils/get-date.js +7 -0
  96. package/core/utils/get-ipfs-data.d.ts +1 -0
  97. package/core/utils/get-ipfs-data.js +20 -0
  98. package/core/utils/get-web3-provider.d.ts +2 -0
  99. package/core/utils/get-web3-provider.js +18 -0
  100. package/core/utils/gql-queries.d.ts +12 -0
  101. package/core/utils/gql-queries.js +90 -0
  102. package/core/utils/index.js +23 -0
  103. package/core/utils/map-filter.d.ts +8 -0
  104. package/core/utils/map-filter.js +20 -0
  105. package/core/utils/serialize-bigint.d.ts +1 -0
  106. package/core/utils/serialize-bigint.js +8 -0
  107. package/core/utils/to-unix.d.ts +1 -0
  108. package/core/utils/to-unix.js +25 -0
  109. package/index.js +17 -0
  110. package/package.json +45 -45
  111. package/.cursorrules +0 -43
  112. package/core/abi/index.ts +0 -21
  113. package/core/class/AllGapSchemas.ts +0 -21
  114. package/core/class/Attestation.ts +0 -429
  115. package/core/class/Fetcher.ts +0 -224
  116. package/core/class/GAP.ts +0 -481
  117. package/core/class/GapSchema.ts +0 -93
  118. package/core/class/GrantProgramRegistry/Allo.ts +0 -188
  119. package/core/class/GrantProgramRegistry/AlloRegistry.ts +0 -101
  120. package/core/class/GraphQL/AxiosGQL.ts +0 -29
  121. package/core/class/GraphQL/EASClient.ts +0 -34
  122. package/core/class/GraphQL/GapEasClient.ts +0 -869
  123. package/core/class/Schema.ts +0 -659
  124. package/core/class/SchemaError.ts +0 -42
  125. package/core/class/contract/GapContract.ts +0 -457
  126. package/core/class/entities/Community.ts +0 -148
  127. package/core/class/entities/ContributorProfile.ts +0 -108
  128. package/core/class/entities/Grant.ts +0 -321
  129. package/core/class/entities/GrantUpdate.ts +0 -187
  130. package/core/class/entities/MemberOf.ts +0 -52
  131. package/core/class/entities/Milestone.ts +0 -898
  132. package/core/class/entities/Project.ts +0 -672
  133. package/core/class/entities/ProjectImpact.ts +0 -170
  134. package/core/class/entities/ProjectMilestone.ts +0 -254
  135. package/core/class/entities/ProjectPointer.ts +0 -39
  136. package/core/class/entities/ProjectUpdate.ts +0 -176
  137. package/core/class/entities/Track.ts +0 -32
  138. package/core/class/karma-indexer/GapIndexerClient.ts +0 -383
  139. package/core/class/karma-indexer/api/GapIndexerApi.ts +0 -446
  140. package/core/class/karma-indexer/api/types.ts +0 -313
  141. package/core/class/remote-storage/IpfsStorage.ts +0 -76
  142. package/core/class/remote-storage/RemoteStorage.ts +0 -65
  143. package/core/class/types/allo.ts +0 -93
  144. package/core/class/types/attestations.ts +0 -223
  145. package/core/consts.ts +0 -775
  146. package/core/scripts/create-grant.ts +0 -102
  147. package/core/scripts/create-program.ts +0 -43
  148. package/core/scripts/create-schemas.ts +0 -65
  149. package/core/scripts/deploy.ts +0 -65
  150. package/core/scripts/index.ts +0 -1
  151. package/core/scripts/milestone-multi-grants.ts +0 -125
  152. package/core/shared/types.ts +0 -13
  153. package/core/types.ts +0 -224
  154. package/core/utils/gelato/send-gelato-txn.ts +0 -114
  155. package/core/utils/gelato/sponsor-handler.ts +0 -77
  156. package/core/utils/gelato/watch-gelato-txn.ts +0 -67
  157. package/core/utils/get-date.ts +0 -3
  158. package/core/utils/get-ipfs-data.ts +0 -13
  159. package/core/utils/get-web3-provider.ts +0 -18
  160. package/core/utils/gql-queries.ts +0 -133
  161. package/core/utils/map-filter.ts +0 -21
  162. package/core/utils/serialize-bigint.ts +0 -7
  163. package/core/utils/to-unix.ts +0 -18
  164. package/create-community-example.ts +0 -119
  165. package/csv-upload/README.md +0 -74
  166. package/csv-upload/config.ts +0 -41
  167. package/csv-upload/example.csv +0 -2
  168. package/csv-upload/keys.example.json +0 -8
  169. package/csv-upload/scripts/run.ts +0 -417
  170. package/csv-upload/types.ts +0 -39
  171. package/docs/.gitkeep +0 -0
  172. package/docs/images/attestation-architecture.png +0 -0
  173. package/docs/images/dfd-get-projects.png +0 -0
  174. package/gap-schema.yaml +0 -155
  175. package/milestone-workflow-example.ts +0 -353
  176. package/readme.md +0 -872
  177. package/schemas/.gitkeep +0 -0
  178. package/schemas/GAP-schemas-1692135812877.json +0 -33
  179. package/test-file-indexer-api.ts +0 -25
  180. package/tsconfig.json +0 -26
  181. /package/{csv-upload/.gitkeep → core/class/Gelato/Gelato.d.ts} +0 -0
  182. /package/core/class/GraphQL/{index.ts → index.d.ts} +0 -0
  183. /package/core/class/entities/{index.ts → index.d.ts} +0 -0
  184. /package/core/class/{index.ts → index.d.ts} +0 -0
  185. /package/core/{index.ts → index.d.ts} +0 -0
  186. /package/core/utils/gelato/{index.ts → index.d.ts} +0 -0
  187. /package/core/utils/{index.ts → index.d.ts} +0 -0
  188. /package/{index.ts → index.d.ts} +0 -0
@@ -1,170 +0,0 @@
1
- import { Hex, SignerOrProvider, TNetwork } from "../../types";
2
- import { Attestation, AttestationArgs } from "../Attestation";
3
- import { GapSchema } from "../GapSchema";
4
- import { AttestationError } from "../SchemaError";
5
- import { AllGapSchemas } from "../AllGapSchemas";
6
- import { chainIdToNetwork } from "../../consts";
7
- import { Transaction } from "ethers";
8
-
9
- export interface _IProjectImpact extends ProjectImpact {}
10
-
11
- type IStatus = "verified";
12
-
13
- export interface IProjectImpactStatus {
14
- type?: `project-impact-${IStatus}`;
15
- reason?: string;
16
- }
17
-
18
- export class ProjectImpactStatus
19
- extends Attestation<IProjectImpactStatus>
20
- implements IProjectImpactStatus
21
- {
22
- type: `project-impact-${IStatus}`;
23
- reason?: string;
24
- }
25
-
26
- export interface IProjectImpact {
27
- work: string;
28
- impact: string;
29
- proof: string;
30
- startedAt?: number;
31
- completedAt: number;
32
- type?: string;
33
- verified?: ProjectImpactStatus[];
34
- }
35
-
36
- export class ProjectImpact
37
- extends Attestation<IProjectImpact>
38
- implements IProjectImpact
39
- {
40
- work: string;
41
- impact: string;
42
- proof: string;
43
- startedAt?: number;
44
- completedAt: number;
45
- type?: string;
46
- verified: ProjectImpactStatus[] = [];
47
-
48
- constructor(data: AttestationArgs<IProjectImpact, GapSchema>) {
49
- (data.data as any).type = "project-impact";
50
- super(data);
51
- }
52
-
53
- /**
54
- * Attest Project Impact.
55
- */
56
- private async attestStatus(
57
- signer: SignerOrProvider,
58
- schema: GapSchema,
59
- callback?: Function
60
- ) {
61
- const eas = this.schema.gap.eas.connect(signer);
62
- try {
63
- if (callback) callback("preparing");
64
- const tx = await eas.attest({
65
- schema: schema.uid,
66
- data: {
67
- recipient: this.recipient,
68
- data: schema.encode(),
69
- refUID: this.uid,
70
- expirationTime: 0n,
71
- revocable: schema.revocable,
72
- },
73
- });
74
-
75
- if (callback) callback("pending");
76
- const uid = await tx.wait();
77
- if (callback) callback("confirmed");
78
-
79
- console.log(uid);
80
- return {
81
- tx: [
82
- {
83
- hash: tx.tx.hash as Hex,
84
- } as Transaction,
85
- ],
86
- uids: [uid as `0x${string}`],
87
- };
88
- } catch (error: any) {
89
- console.error(error);
90
- throw new AttestationError("ATTEST_ERROR", error.message, error);
91
- }
92
- }
93
-
94
- /**
95
- * Verify this ProjectImpact. If the ProjectImpact is not already verified,
96
- * it will throw an error.
97
- * @param signer
98
- * @param reason
99
- */
100
- async verify(signer: SignerOrProvider, data?: IProjectImpactStatus, callback?: Function) {
101
- console.log("Verifying ProjectImpact");
102
-
103
- const schema = this.schema.gap.findSchema("GrantUpdateStatus");
104
- if (this.schema.isJsonSchema()) {
105
- schema.setValue("json", JSON.stringify({
106
- type: "project-impact-verified",
107
- reason: data?.reason || '',
108
- }))
109
- } else {
110
- schema.setValue("type", "project-impact-verified");
111
- schema.setValue("reason", data?.reason || '');
112
- }
113
-
114
- console.log("Before attest project impact verified");
115
- const { tx, uids } = await this.attestStatus(signer, schema, callback);
116
- console.log("After attest project impact verified");
117
-
118
- this.verified.push(
119
- new ProjectImpactStatus({
120
- data: {
121
- type: "project-impact-verified",
122
- reason: data?.reason || '',
123
- },
124
- refUID: this.uid,
125
- schema: schema,
126
- recipient: this.recipient,
127
- })
128
- );
129
-
130
- return { tx, uids };
131
- }
132
-
133
- static from(
134
- attestations: ProjectImpact[],
135
- network: TNetwork
136
- ): ProjectImpact[] {
137
- return attestations.map((attestation) => {
138
- const projectImpact = new ProjectImpact({
139
- ...attestation,
140
- data: {
141
- ...attestation.data,
142
- },
143
- schema: new AllGapSchemas().findSchema(
144
- "ProjectImpact",
145
- chainIdToNetwork[attestation.chainID] as TNetwork
146
- ),
147
- chainID: attestation.chainID,
148
- });
149
-
150
- if (attestation.verified?.length > 0) {
151
- projectImpact.verified = attestation.verified.map(
152
- (m) =>
153
- new ProjectImpactStatus({
154
- ...m,
155
- data: {
156
- ...m.data,
157
- },
158
- schema: new AllGapSchemas().findSchema(
159
- "GrantUpdateStatus",
160
- chainIdToNetwork[attestation.chainID] as TNetwork
161
- ),
162
- chainID: attestation.chainID,
163
- })
164
- );
165
- }
166
-
167
- return projectImpact;
168
- });
169
- }
170
- }
@@ -1,254 +0,0 @@
1
- import { SignerOrProvider, TNetwork } from "../../../core/types";
2
- import { Attestation, AttestationArgs } from "../Attestation";
3
- import { GapSchema } from "../GapSchema";
4
- import { AttestationError } from "../SchemaError";
5
- import { AllGapSchemas } from "../AllGapSchemas";
6
- import { chainIdToNetwork } from "../../../core/consts";
7
- import { Transaction } from "ethers";
8
- import { Hex, IProjectMilestoneResponse } from "../karma-indexer/api/types";
9
- import {
10
- AttestationWithTx,
11
- IMilestoneCompleted as IProjectMilestoneCompleted,
12
- MilestoneCompleted as ProjectMilestoneCompleted,
13
- } from "../types/attestations";
14
-
15
- export interface IProjectMilestone {
16
- title: string;
17
- text: string;
18
- type?: string;
19
- }
20
-
21
- type IStatus = "verified" | "completed";
22
-
23
- export interface IProjectMilestoneStatus {
24
- type?: `project-milestone-${IStatus}`;
25
- proofOfWork?: string;
26
- reason?: string;
27
- }
28
-
29
- export class ProjectMilestoneStatus
30
- extends Attestation<IProjectMilestoneStatus>
31
- implements IProjectMilestoneStatus
32
- {
33
- type: `project-milestone-${IStatus}`;
34
- reason?: string;
35
- }
36
-
37
- export class ProjectMilestone
38
- extends Attestation<IProjectMilestone>
39
- implements IProjectMilestone
40
- {
41
- title: string;
42
- text: string;
43
- verified: ProjectMilestoneStatus[] = [];
44
- completed: ProjectMilestoneCompleted;
45
-
46
- constructor(data: AttestationArgs<IProjectMilestone, GapSchema>) {
47
- (data.data as any).type = "project-milestone";
48
- super(data);
49
- }
50
-
51
- /**
52
- * Attest the status of the update as approved, rejected or completed.
53
- */
54
- private async attestStatus(
55
- signer: SignerOrProvider,
56
- schema: GapSchema,
57
- callback?: Function
58
- ): Promise<AttestationWithTx> {
59
- const eas = this.schema.gap.eas.connect(signer);
60
- try {
61
- if (callback) callback("preparing");
62
- const tx = await eas.attest({
63
- schema: schema.uid,
64
- data: {
65
- recipient: this.recipient,
66
- data: schema.encode(),
67
- refUID: this.uid,
68
- expirationTime: 0n,
69
- revocable: schema.revocable,
70
- },
71
- });
72
-
73
- if (callback) callback("pending");
74
- const uid = await tx.wait();
75
- if (callback) callback("confirmed");
76
-
77
- console.log(uid);
78
- return {
79
- tx: [
80
- {
81
- hash: tx.tx.hash as Hex,
82
- } as Transaction,
83
- ],
84
- uids: [uid as `0x${string}`],
85
- };
86
- } catch (error: any) {
87
- console.error(error);
88
- throw new AttestationError("ATTEST_ERROR", error.message, error);
89
- }
90
- }
91
-
92
- /**
93
- * Verify this ProjectUpdate. If the ProjectUpdate is not already verified,
94
- * it will throw an error.
95
- * @param signer
96
- * @param reason
97
- */
98
- async verify(
99
- signer: SignerOrProvider,
100
- data?: IProjectMilestoneStatus,
101
- callback?: Function
102
- ) {
103
- console.log("Verifying");
104
-
105
- const schema = this.schema.gap.findSchema("ProjectMilestoneStatus");
106
- if (this.schema.isJsonSchema()) {
107
- schema.setValue(
108
- "json",
109
- JSON.stringify({
110
- type: "verified",
111
- reason: data?.reason || "",
112
- })
113
- );
114
- } else {
115
- schema.setValue("type", "project-milestone-verified");
116
- schema.setValue("reason", data?.reason || "");
117
- }
118
- console.log("Before attest project milestone verified");
119
- await this.attestStatus(signer, schema, callback);
120
- console.log("After attest project milestone verified");
121
-
122
- this.verified.push(
123
- new ProjectMilestoneStatus({
124
- data: {
125
- type: "project-milestone-verified",
126
- reason: data?.reason || "",
127
- },
128
- refUID: this.uid,
129
- schema: schema,
130
- recipient: this.recipient,
131
- })
132
- );
133
- }
134
-
135
- /**
136
- * Marks a milestone as completed. If the milestone is already completed,
137
- * it will throw an error.
138
- * @param signer
139
- * @param reason
140
- */
141
- async complete(
142
- signer: SignerOrProvider,
143
- data?: IProjectMilestoneStatus,
144
- callback?: Function
145
- ) {
146
- console.log("Completing");
147
-
148
- const schema = this.schema.gap.findSchema("ProjectMilestoneStatus");
149
- if (this.schema.isJsonSchema()) {
150
- schema.setValue(
151
- "json",
152
- JSON.stringify({
153
- type: "project-milestone-completed",
154
- ...data,
155
- })
156
- );
157
- } else {
158
- schema.setValue("type", "project-milestone-completed");
159
- schema.setValue("proofOfWork", data?.proofOfWork || "");
160
- schema.setValue("reason", data?.reason || "");
161
- }
162
- console.log("Before attest project milestone completed");
163
- const { tx, uids } = await this.attestStatus(signer, schema, callback);
164
- console.log("After attest project milestone completed");
165
-
166
- this.completed = new ProjectMilestoneCompleted({
167
- data: {
168
- reason: data?.reason || "",
169
- },
170
- refUID: this.uid,
171
- schema: schema,
172
- recipient: this.recipient,
173
- });
174
- return { tx, uids };
175
- }
176
-
177
- /**
178
- * Revokes the completed status of the milestone. If the milestone is not completed,
179
- * it will throw an error.
180
- * @param signer
181
- */
182
- async revokeCompletion(signer: SignerOrProvider, callback?: Function) {
183
- if (!this.completed)
184
- throw new AttestationError("ATTEST_ERROR", "Milestone is not completed");
185
-
186
- const { tx, uids } = await this.completed.schema.multiRevoke(
187
- signer,
188
- [
189
- {
190
- schemaId: this.completed.schema.uid,
191
- uid: this.completed.uid,
192
- },
193
- ],
194
- callback
195
- );
196
- return { tx, uids };
197
- }
198
-
199
- static from(
200
- attestations: IProjectMilestoneResponse[],
201
- network: TNetwork
202
- ): ProjectMilestone[] {
203
- return attestations.map((attestation) => {
204
- const projectMilestone = new ProjectMilestone({
205
- ...attestation,
206
- data: {
207
- ...attestation.data,
208
- },
209
- schema: new AllGapSchemas().findSchema(
210
- "ProjectMilestone",
211
- chainIdToNetwork[attestation.chainID] as TNetwork
212
- ),
213
- chainID: attestation.chainID,
214
- });
215
-
216
- if (attestation.verified?.length > 0) {
217
- projectMilestone.verified = attestation.verified.map(
218
- (m) =>
219
- new ProjectMilestoneStatus({
220
- ...m,
221
- data: {
222
- ...m.data,
223
- type:
224
- m.data.type === "completed"
225
- ? "project-milestone-completed"
226
- : "project-milestone-verified",
227
- },
228
- schema: new AllGapSchemas().findSchema(
229
- "ProjectMilestoneStatus",
230
- chainIdToNetwork[attestation.chainID] as TNetwork
231
- ),
232
- chainID: attestation.chainID,
233
- })
234
- );
235
- }
236
-
237
- if (attestation.completed) {
238
- projectMilestone.completed = new ProjectMilestoneCompleted({
239
- ...attestation.completed,
240
- data: {
241
- ...attestation.completed.data,
242
- },
243
- schema: new AllGapSchemas().findSchema(
244
- "MilestoneCompleted",
245
- chainIdToNetwork[attestation.chainID] as TNetwork
246
- ),
247
- chainID: attestation.chainID,
248
- });
249
- }
250
-
251
- return projectMilestone;
252
- });
253
- }
254
- }
@@ -1,39 +0,0 @@
1
- import { TNetwork } from "../../../core/types";
2
- import { Attestation } from "../Attestation";
3
- import { AllGapSchemas } from "../AllGapSchemas";
4
- import { chainIdToNetwork } from "../../../core/consts";
5
-
6
- export interface _IProjectPointer extends ProjectPointer {}
7
-
8
- export interface IProjectPointer {
9
- ogProjectUID: string;
10
- type?: string;
11
- }
12
-
13
- export class ProjectPointer
14
- extends Attestation<IProjectPointer>
15
- implements IProjectPointer
16
- {
17
- ogProjectUID: string;
18
-
19
- static from(
20
- attestations: _IProjectPointer[],
21
- network: TNetwork
22
- ): ProjectPointer[] {
23
- return attestations.map((attestation) => {
24
- const projectUpdate = new ProjectPointer({
25
- ...attestation,
26
- data: {
27
- ...attestation.data,
28
- },
29
- schema: new AllGapSchemas().findSchema(
30
- "ProjectUpdate",
31
- chainIdToNetwork[attestation.chainID] as TNetwork
32
- ),
33
- chainID: attestation.chainID,
34
- });
35
-
36
- return projectUpdate;
37
- });
38
- }
39
- }
@@ -1,176 +0,0 @@
1
- import { SignerOrProvider, TNetwork } from "../../../core/types";
2
- import { Attestation } from "../Attestation";
3
- import { GapSchema } from "../GapSchema";
4
- import { AttestationError } from "../SchemaError";
5
- import { AllGapSchemas } from "../AllGapSchemas";
6
- import { chainIdToNetwork } from "../../../core/consts";
7
- import { Transaction } from "ethers";
8
- import { Hex } from "../karma-indexer/api/types";
9
- import { AttestationWithTx } from "../types/attestations";
10
-
11
- export interface _IProjectUpdate extends ProjectUpdate {}
12
- export interface IProjectUpdate {
13
- title: string;
14
- text: string;
15
- startDate?: Date;
16
- endDate?: Date;
17
- type?: string;
18
- grants?: string[];
19
- indicators?: {
20
- name: string;
21
- indicatorId: string;
22
- }[];
23
- deliverables?: {
24
- name: string;
25
- proof: string;
26
- description: string;
27
- }[];
28
- }
29
-
30
- type IStatus = "verified";
31
-
32
- export interface IProjectUpdateStatus {
33
- type?: `project-update-${IStatus}`;
34
- reason?: string;
35
- proofOfWork?: string;
36
- }
37
-
38
- export class ProjectUpdateStatus
39
- extends Attestation<IProjectUpdateStatus>
40
- implements IProjectUpdateStatus
41
- {
42
- type: `project-update-${IStatus}`;
43
- reason?: string;
44
- proofOfWork?: string;
45
- }
46
-
47
- export class ProjectUpdate
48
- extends Attestation<IProjectUpdate>
49
- implements IProjectUpdate
50
- {
51
- title: string;
52
- text: string;
53
- verified: ProjectUpdateStatus[] = [];
54
-
55
- /**
56
- * Attest the status of the update as approved, rejected or completed.
57
- */
58
- private async attestStatus(
59
- signer: SignerOrProvider,
60
- schema: GapSchema,
61
- callback?: Function
62
- ): Promise<AttestationWithTx> {
63
- const eas = this.schema.gap.eas.connect(signer);
64
- try {
65
- if (callback) callback("preparing");
66
- const tx = await eas.attest({
67
- schema: schema.uid,
68
- data: {
69
- recipient: this.recipient,
70
- data: schema.encode(),
71
- refUID: this.uid,
72
- expirationTime: 0n,
73
- revocable: schema.revocable,
74
- },
75
- });
76
-
77
- if (callback) callback("pending");
78
- const uid = await tx.wait();
79
- if (callback) callback("confirmed");
80
-
81
- console.log(uid);
82
- return {
83
- tx: [
84
- {
85
- hash: tx.tx.hash as Hex,
86
- } as Transaction,
87
- ],
88
- uids: [uid as `0x${string}`],
89
- };
90
- } catch (error: any) {
91
- console.error(error);
92
- throw new AttestationError("ATTEST_ERROR", error.message, error);
93
- }
94
- }
95
-
96
- /**
97
- * Verify this ProjectUpdate. If the ProjectUpdate is not already verified,
98
- * it will throw an error.
99
- * @param signer
100
- * @param reason
101
- */
102
- async verify(
103
- signer: SignerOrProvider,
104
- data?: IProjectUpdateStatus,
105
- callback?: Function
106
- ) {
107
- console.log("Verifying");
108
-
109
- const schema = this.schema.gap.findSchema("ProjectUpdateStatus");
110
- if (this.schema.isJsonSchema()) {
111
- schema.setValue(
112
- "json",
113
- JSON.stringify({
114
- type: "verified",
115
- reason: data?.reason || "",
116
- })
117
- );
118
- } else {
119
- schema.setValue("type", "project-update-verified");
120
- schema.setValue("reason", data?.reason || "");
121
- }
122
- console.log("Before attest project update verified");
123
- await this.attestStatus(signer, schema, callback);
124
- console.log("After attest project update verified");
125
-
126
- this.verified.push(
127
- new ProjectUpdateStatus({
128
- data: {
129
- type: "project-update-verified",
130
- reason: data?.reason || "",
131
- },
132
- refUID: this.uid,
133
- schema: schema,
134
- recipient: this.recipient,
135
- })
136
- );
137
- }
138
-
139
- static from(
140
- attestations: _IProjectUpdate[],
141
- network: TNetwork
142
- ): ProjectUpdate[] {
143
- return attestations.map((attestation) => {
144
- const projectUpdate = new ProjectUpdate({
145
- ...attestation,
146
- data: {
147
- ...attestation.data,
148
- },
149
- schema: new AllGapSchemas().findSchema(
150
- "ProjectUpdate",
151
- chainIdToNetwork[attestation.chainID] as TNetwork
152
- ),
153
- chainID: attestation.chainID,
154
- });
155
-
156
- if (attestation.verified?.length > 0) {
157
- projectUpdate.verified = attestation.verified.map(
158
- (m) =>
159
- new ProjectUpdateStatus({
160
- ...m,
161
- data: {
162
- ...m.data,
163
- },
164
- schema: new AllGapSchemas().findSchema(
165
- "ProjectUpdateStatus",
166
- chainIdToNetwork[attestation.chainID] as TNetwork
167
- ),
168
- chainID: attestation.chainID,
169
- })
170
- );
171
- }
172
-
173
- return projectUpdate;
174
- });
175
- }
176
- }
@@ -1,32 +0,0 @@
1
- import { TNetwork } from "core/types";
2
- import { ITrackResponse } from "../karma-indexer/api/types";
3
-
4
- export class Track {
5
- id: string;
6
- name: string;
7
- description?: string;
8
- communityUID: string;
9
- isArchived: boolean;
10
- createdAt: Date;
11
- updatedAt: Date;
12
- programId?: string;
13
- isActive?: boolean;
14
- network: TNetwork;
15
-
16
- constructor(data: any, network: TNetwork) {
17
- this.id = data.id;
18
- this.name = data.name;
19
- this.description = data.description;
20
- this.communityUID = data.communityUID;
21
- this.isArchived = data.isArchived ?? false;
22
- this.createdAt = new Date(data.createdAt);
23
- this.updatedAt = new Date(data.updatedAt);
24
- this.programId = data.programId;
25
- this.isActive = data.isActive;
26
- this.network = network;
27
- }
28
-
29
- static from(data: ITrackResponse[], network: TNetwork): Track[] {
30
- return data.map((item) => new Track(item, network));
31
- }
32
- }