@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
@@ -0,0 +1,60 @@
1
+ import { SignerOrProvider, TNetwork } from "../../../core/types";
2
+ import { Attestation, AttestationArgs } from "../Attestation";
3
+ import { GapSchema } from "../GapSchema";
4
+ import { Transaction } from "ethers";
5
+ import { IProjectMilestoneResponse } from "../karma-indexer/api/types";
6
+ import { MilestoneCompleted as ProjectMilestoneCompleted } from "../types/attestations";
7
+ export interface IProjectMilestone {
8
+ title: string;
9
+ text: string;
10
+ type?: string;
11
+ }
12
+ type IStatus = "verified" | "completed";
13
+ export interface IProjectMilestoneStatus {
14
+ type?: `project-milestone-${IStatus}`;
15
+ proofOfWork?: string;
16
+ reason?: string;
17
+ }
18
+ export declare class ProjectMilestoneStatus extends Attestation<IProjectMilestoneStatus> implements IProjectMilestoneStatus {
19
+ type: `project-milestone-${IStatus}`;
20
+ reason?: string;
21
+ }
22
+ export declare class ProjectMilestone extends Attestation<IProjectMilestone> implements IProjectMilestone {
23
+ title: string;
24
+ text: string;
25
+ verified: ProjectMilestoneStatus[];
26
+ completed: ProjectMilestoneCompleted;
27
+ constructor(data: AttestationArgs<IProjectMilestone, GapSchema>);
28
+ /**
29
+ * Attest the status of the update as approved, rejected or completed.
30
+ */
31
+ private attestStatus;
32
+ /**
33
+ * Verify this ProjectUpdate. If the ProjectUpdate is not already verified,
34
+ * it will throw an error.
35
+ * @param signer
36
+ * @param reason
37
+ */
38
+ verify(signer: SignerOrProvider, data?: IProjectMilestoneStatus, callback?: Function): Promise<void>;
39
+ /**
40
+ * Marks a milestone as completed. If the milestone is already completed,
41
+ * it will throw an error.
42
+ * @param signer
43
+ * @param reason
44
+ */
45
+ complete(signer: SignerOrProvider, data?: IProjectMilestoneStatus, callback?: Function): Promise<{
46
+ tx: Transaction[];
47
+ uids: `0x${string}`[];
48
+ }>;
49
+ /**
50
+ * Revokes the completed status of the milestone. If the milestone is not completed,
51
+ * it will throw an error.
52
+ * @param signer
53
+ */
54
+ revokeCompletion(signer: SignerOrProvider, callback?: Function): Promise<{
55
+ tx: Transaction[];
56
+ uids: `0x${string}`[];
57
+ }>;
58
+ static from(attestations: IProjectMilestoneResponse[], network: TNetwork): ProjectMilestone[];
59
+ }
60
+ export {};
@@ -0,0 +1,174 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ProjectMilestone = exports.ProjectMilestoneStatus = 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
+ const attestations_1 = require("../types/attestations");
9
+ class ProjectMilestoneStatus extends Attestation_1.Attestation {
10
+ }
11
+ exports.ProjectMilestoneStatus = ProjectMilestoneStatus;
12
+ class ProjectMilestone extends Attestation_1.Attestation {
13
+ constructor(data) {
14
+ data.data.type = "project-milestone";
15
+ super(data);
16
+ this.verified = [];
17
+ }
18
+ /**
19
+ * Attest the status of the update as approved, rejected or completed.
20
+ */
21
+ async attestStatus(signer, schema, callback) {
22
+ const eas = this.schema.gap.eas.connect(signer);
23
+ try {
24
+ if (callback)
25
+ callback("preparing");
26
+ const tx = await eas.attest({
27
+ schema: schema.uid,
28
+ data: {
29
+ recipient: this.recipient,
30
+ data: schema.encode(),
31
+ refUID: this.uid,
32
+ expirationTime: 0n,
33
+ revocable: schema.revocable,
34
+ },
35
+ });
36
+ if (callback)
37
+ callback("pending");
38
+ const uid = await tx.wait();
39
+ if (callback)
40
+ callback("confirmed");
41
+ console.log(uid);
42
+ return {
43
+ tx: [
44
+ {
45
+ hash: tx.tx.hash,
46
+ },
47
+ ],
48
+ uids: [uid],
49
+ };
50
+ }
51
+ catch (error) {
52
+ console.error(error);
53
+ throw new SchemaError_1.AttestationError("ATTEST_ERROR", error.message, error);
54
+ }
55
+ }
56
+ /**
57
+ * Verify this ProjectUpdate. If the ProjectUpdate is not already verified,
58
+ * it will throw an error.
59
+ * @param signer
60
+ * @param reason
61
+ */
62
+ async verify(signer, data, callback) {
63
+ console.log("Verifying");
64
+ const schema = this.schema.gap.findSchema("ProjectMilestoneStatus");
65
+ if (this.schema.isJsonSchema()) {
66
+ schema.setValue("json", JSON.stringify({
67
+ type: "verified",
68
+ reason: data?.reason || "",
69
+ }));
70
+ }
71
+ else {
72
+ schema.setValue("type", "project-milestone-verified");
73
+ schema.setValue("reason", data?.reason || "");
74
+ }
75
+ console.log("Before attest project milestone verified");
76
+ await this.attestStatus(signer, schema, callback);
77
+ console.log("After attest project milestone verified");
78
+ this.verified.push(new ProjectMilestoneStatus({
79
+ data: {
80
+ type: "project-milestone-verified",
81
+ reason: data?.reason || "",
82
+ },
83
+ refUID: this.uid,
84
+ schema: schema,
85
+ recipient: this.recipient,
86
+ }));
87
+ }
88
+ /**
89
+ * Marks a milestone as completed. If the milestone is already completed,
90
+ * it will throw an error.
91
+ * @param signer
92
+ * @param reason
93
+ */
94
+ async complete(signer, data, callback) {
95
+ console.log("Completing");
96
+ const schema = this.schema.gap.findSchema("ProjectMilestoneStatus");
97
+ if (this.schema.isJsonSchema()) {
98
+ schema.setValue("json", JSON.stringify({
99
+ type: "project-milestone-completed",
100
+ ...data,
101
+ }));
102
+ }
103
+ else {
104
+ schema.setValue("type", "project-milestone-completed");
105
+ schema.setValue("proofOfWork", data?.proofOfWork || "");
106
+ schema.setValue("reason", data?.reason || "");
107
+ }
108
+ console.log("Before attest project milestone completed");
109
+ const { tx, uids } = await this.attestStatus(signer, schema, callback);
110
+ console.log("After attest project milestone completed");
111
+ this.completed = new attestations_1.MilestoneCompleted({
112
+ data: {
113
+ reason: data?.reason || "",
114
+ },
115
+ refUID: this.uid,
116
+ schema: schema,
117
+ recipient: this.recipient,
118
+ });
119
+ return { tx, uids };
120
+ }
121
+ /**
122
+ * Revokes the completed status of the milestone. If the milestone is not completed,
123
+ * it will throw an error.
124
+ * @param signer
125
+ */
126
+ async revokeCompletion(signer, callback) {
127
+ if (!this.completed)
128
+ throw new SchemaError_1.AttestationError("ATTEST_ERROR", "Milestone is not completed");
129
+ const { tx, uids } = await this.completed.schema.multiRevoke(signer, [
130
+ {
131
+ schemaId: this.completed.schema.uid,
132
+ uid: this.completed.uid,
133
+ },
134
+ ], callback);
135
+ return { tx, uids };
136
+ }
137
+ static from(attestations, network) {
138
+ return attestations.map((attestation) => {
139
+ const projectMilestone = new ProjectMilestone({
140
+ ...attestation,
141
+ data: {
142
+ ...attestation.data,
143
+ },
144
+ schema: new AllGapSchemas_1.AllGapSchemas().findSchema("ProjectMilestone", consts_1.chainIdToNetwork[attestation.chainID]),
145
+ chainID: attestation.chainID,
146
+ });
147
+ if (attestation.verified?.length > 0) {
148
+ projectMilestone.verified = attestation.verified.map((m) => new ProjectMilestoneStatus({
149
+ ...m,
150
+ data: {
151
+ ...m.data,
152
+ type: m.data.type === "completed"
153
+ ? "project-milestone-completed"
154
+ : "project-milestone-verified",
155
+ },
156
+ schema: new AllGapSchemas_1.AllGapSchemas().findSchema("ProjectMilestoneStatus", consts_1.chainIdToNetwork[attestation.chainID]),
157
+ chainID: attestation.chainID,
158
+ }));
159
+ }
160
+ if (attestation.completed) {
161
+ projectMilestone.completed = new attestations_1.MilestoneCompleted({
162
+ ...attestation.completed,
163
+ data: {
164
+ ...attestation.completed.data,
165
+ },
166
+ schema: new AllGapSchemas_1.AllGapSchemas().findSchema("MilestoneCompleted", consts_1.chainIdToNetwork[attestation.chainID]),
167
+ chainID: attestation.chainID,
168
+ });
169
+ }
170
+ return projectMilestone;
171
+ });
172
+ }
173
+ }
174
+ exports.ProjectMilestone = ProjectMilestone;
@@ -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,50 @@
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
+ startDate?: Date;
9
+ endDate?: Date;
10
+ type?: string;
11
+ grants?: string[];
12
+ indicators?: {
13
+ name: string;
14
+ indicatorId: string;
15
+ }[];
16
+ deliverables?: {
17
+ name: string;
18
+ proof: string;
19
+ description: string;
20
+ }[];
21
+ }
22
+ type IStatus = "verified";
23
+ export interface IProjectUpdateStatus {
24
+ type?: `project-update-${IStatus}`;
25
+ reason?: string;
26
+ proofOfWork?: string;
27
+ }
28
+ export declare class ProjectUpdateStatus extends Attestation<IProjectUpdateStatus> implements IProjectUpdateStatus {
29
+ type: `project-update-${IStatus}`;
30
+ reason?: string;
31
+ proofOfWork?: string;
32
+ }
33
+ export declare class ProjectUpdate extends Attestation<IProjectUpdate> implements IProjectUpdate {
34
+ title: string;
35
+ text: string;
36
+ verified: ProjectUpdateStatus[];
37
+ /**
38
+ * Attest the status of the update as approved, rejected or completed.
39
+ */
40
+ private attestStatus;
41
+ /**
42
+ * Verify this ProjectUpdate. If the ProjectUpdate is not already verified,
43
+ * it will throw an error.
44
+ * @param signer
45
+ * @param reason
46
+ */
47
+ verify(signer: SignerOrProvider, data?: IProjectUpdateStatus, callback?: Function): Promise<void>;
48
+ static from(attestations: _IProjectUpdate[], network: TNetwork): ProjectUpdate[];
49
+ }
50
+ export {};
@@ -0,0 +1,110 @@
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
+ return {
41
+ tx: [
42
+ {
43
+ hash: tx.tx.hash,
44
+ },
45
+ ],
46
+ uids: [uid],
47
+ };
48
+ }
49
+ catch (error) {
50
+ console.error(error);
51
+ throw new SchemaError_1.AttestationError("ATTEST_ERROR", error.message, error);
52
+ }
53
+ }
54
+ /**
55
+ * Verify this ProjectUpdate. If the ProjectUpdate is not already verified,
56
+ * it will throw an error.
57
+ * @param signer
58
+ * @param reason
59
+ */
60
+ async verify(signer, data, callback) {
61
+ console.log("Verifying");
62
+ const schema = this.schema.gap.findSchema("ProjectUpdateStatus");
63
+ if (this.schema.isJsonSchema()) {
64
+ schema.setValue("json", JSON.stringify({
65
+ type: "verified",
66
+ reason: data?.reason || "",
67
+ }));
68
+ }
69
+ else {
70
+ schema.setValue("type", "project-update-verified");
71
+ schema.setValue("reason", data?.reason || "");
72
+ }
73
+ console.log("Before attest project update verified");
74
+ await this.attestStatus(signer, schema, callback);
75
+ console.log("After attest project update verified");
76
+ this.verified.push(new ProjectUpdateStatus({
77
+ data: {
78
+ type: "project-update-verified",
79
+ reason: data?.reason || "",
80
+ },
81
+ refUID: this.uid,
82
+ schema: schema,
83
+ recipient: this.recipient,
84
+ }));
85
+ }
86
+ static from(attestations, network) {
87
+ return attestations.map((attestation) => {
88
+ const projectUpdate = new ProjectUpdate({
89
+ ...attestation,
90
+ data: {
91
+ ...attestation.data,
92
+ },
93
+ schema: new AllGapSchemas_1.AllGapSchemas().findSchema("ProjectUpdate", consts_1.chainIdToNetwork[attestation.chainID]),
94
+ chainID: attestation.chainID,
95
+ });
96
+ if (attestation.verified?.length > 0) {
97
+ projectUpdate.verified = attestation.verified.map((m) => new ProjectUpdateStatus({
98
+ ...m,
99
+ data: {
100
+ ...m.data,
101
+ },
102
+ schema: new AllGapSchemas_1.AllGapSchemas().findSchema("ProjectUpdateStatus", consts_1.chainIdToNetwork[attestation.chainID]),
103
+ chainID: attestation.chainID,
104
+ }));
105
+ }
106
+ return projectUpdate;
107
+ });
108
+ }
109
+ }
110
+ exports.ProjectUpdate = ProjectUpdate;
@@ -0,0 +1,16 @@
1
+ import { TNetwork } from "core/types";
2
+ import { ITrackResponse } from "../karma-indexer/api/types";
3
+ export declare class Track {
4
+ id: string;
5
+ name: string;
6
+ description?: string;
7
+ communityUID: string;
8
+ isArchived: boolean;
9
+ createdAt: Date;
10
+ updatedAt: Date;
11
+ programId?: string;
12
+ isActive?: boolean;
13
+ network: TNetwork;
14
+ constructor(data: any, network: TNetwork);
15
+ static from(data: ITrackResponse[], network: TNetwork): Track[];
16
+ }
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Track = void 0;
4
+ class Track {
5
+ constructor(data, network) {
6
+ this.id = data.id;
7
+ this.name = data.name;
8
+ this.description = data.description;
9
+ this.communityUID = data.communityUID;
10
+ this.isArchived = data.isArchived ?? false;
11
+ this.createdAt = new Date(data.createdAt);
12
+ this.updatedAt = new Date(data.updatedAt);
13
+ this.programId = data.programId;
14
+ this.isActive = data.isActive;
15
+ this.network = network;
16
+ }
17
+ static from(data, network) {
18
+ return data.map((item) => new Track(item, network));
19
+ }
20
+ }
21
+ exports.Track = Track;
@@ -0,0 +1,26 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./Grant"), exports);
18
+ __exportStar(require("./Milestone"), exports);
19
+ __exportStar(require("./Project"), exports);
20
+ __exportStar(require("./Community"), exports);
21
+ __exportStar(require("./MemberOf"), exports);
22
+ __exportStar(require("./GrantUpdate"), exports);
23
+ __exportStar(require("./ProjectUpdate"), exports);
24
+ __exportStar(require("./ProjectPointer"), exports);
25
+ __exportStar(require("./ContributorProfile"), exports);
26
+ __exportStar(require("./Track"), exports);
@@ -0,0 +1,26 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./Attestation"), exports);
18
+ __exportStar(require("./GAP"), exports);
19
+ __exportStar(require("./GapSchema"), exports);
20
+ __exportStar(require("./Schema"), exports);
21
+ __exportStar(require("./SchemaError"), exports);
22
+ __exportStar(require("./entities"), exports);
23
+ __exportStar(require("./Fetcher"), exports);
24
+ __exportStar(require("./karma-indexer/GapIndexerClient"), exports);
25
+ __exportStar(require("./remote-storage/IpfsStorage"), exports);
26
+ __exportStar(require("./remote-storage/RemoteStorage"), exports);
@@ -0,0 +1,66 @@
1
+ import { TSchemaName, IAttestation, Hex } from "core/types";
2
+ import { Attestation } from "../Attestation";
3
+ import { GapSchema } from "../GapSchema";
4
+ import { Fetcher } from "../Fetcher";
5
+ import { Community, Project, Grant, Milestone, MemberOf, Track } from "../entities";
6
+ import { Grantee } from "../types/attestations";
7
+ import { ICommunityAdminsResponse } from "./api/types";
8
+ import { ProjectMilestone } from "../entities/ProjectMilestone";
9
+ export declare class GapIndexerClient extends Fetcher {
10
+ private apiClient;
11
+ constructor(params: any);
12
+ attestation<T = unknown>(uid: `0x${string}`): Promise<Attestation<T, GapSchema>>;
13
+ attestations(schemaName: TSchemaName, search?: string): Promise<IAttestation[]>;
14
+ attestationsOf(schemaName: TSchemaName, attester: `0x${string}`): Promise<IAttestation[]>;
15
+ attestationsTo(schemaName: TSchemaName, recipient: `0x${string}`): Promise<IAttestation[]>;
16
+ communities(search?: string): Promise<Community[]>;
17
+ communitiesOf(address: Hex, withGrants: boolean): Promise<Community[]>;
18
+ adminOf(address: Hex): Promise<Community[]>;
19
+ communitiesAdminOf(address: Hex, withGrants: boolean): Promise<Community[]>;
20
+ communitiesByIds(uids: `0x${string}`[]): Promise<Community[]>;
21
+ communityBySlug(slug: string): Promise<Community>;
22
+ communityById(uid: `0x${string}`): Promise<Community>;
23
+ communityAdmins(uid: `0x${string}`): Promise<ICommunityAdminsResponse>;
24
+ projectBySlug(slug: string): Promise<Project>;
25
+ projectById(uid: `0x${string}`): Promise<Project>;
26
+ search(query: string): Promise<{
27
+ projects: Project[];
28
+ communities: Community[];
29
+ }>;
30
+ searchProjects(query: string): Promise<Project[]>;
31
+ projects(name?: string): Promise<Project[]>;
32
+ projectsOf(grantee: `0x${string}`): Promise<Project[]>;
33
+ projectMilestones(uidOrSlug: string): Promise<ProjectMilestone[]>;
34
+ grantee(address: `0x${string}`): Promise<Grantee>;
35
+ grantees(): Promise<Grantee[]>;
36
+ grantsOf(grantee: `0x${string}`, withCommunity?: boolean): Promise<Grant[]>;
37
+ grantsFor(projects: Project[], withCommunity?: boolean): Promise<Grant[]>;
38
+ grantsForExtProject(projectExtId: string): Promise<Grant[]>;
39
+ grantsByCommunity(uid: `0x${string}`, page?: number, pageLimit?: number): Promise<Grant[]>;
40
+ milestonesOf(grants: Grant[]): Promise<Milestone[]>;
41
+ membersOf(projects: Project[]): Promise<MemberOf[]>;
42
+ slugExists(slug: string): Promise<boolean>;
43
+ /**
44
+ * Track related methods
45
+ */
46
+ getTracks(communityUID: string, includeArchived?: boolean): Promise<Track[]>;
47
+ getTrackById(id: string): Promise<Track>;
48
+ createTrack(trackData: {
49
+ name: string;
50
+ description?: string;
51
+ communityUID: string;
52
+ }): Promise<Track>;
53
+ updateTrack(id: string, trackData: {
54
+ name?: string;
55
+ description?: string;
56
+ communityUID?: string;
57
+ }): Promise<Track>;
58
+ archiveTrack(id: string): Promise<Track>;
59
+ assignTracksToProgram(programId: string, trackIds: string[]): Promise<any[]>;
60
+ unassignTrackFromProgram(programId: string, trackId: string): Promise<any>;
61
+ getTracksForProgram(programId: string): Promise<Track[]>;
62
+ getTracksForProject(projectId: string, programId: string, activeOnly?: boolean): Promise<Track[]>;
63
+ assignTracksToProject(projectId: string, programId: string, trackIds: string[]): Promise<any[]>;
64
+ unassignTracksFromProject(projectId: string, programId: string, trackIds: string[]): Promise<any[]>;
65
+ getProjectsByTrack(communityId: string, programId: string, trackId?: string): Promise<any[]>;
66
+ }