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

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/.cursorrules +43 -0
  2. package/core/abi/AirdropNFT.json +1 -1
  3. package/core/abi/Allo.json +860 -860
  4. package/core/abi/AlloRegistry.json +578 -578
  5. package/core/abi/CommunityResolverABI.json +506 -506
  6. package/core/abi/Donations.json +251 -251
  7. package/core/abi/EAS.json +1 -1
  8. package/core/abi/MultiAttester.json +746 -746
  9. package/core/abi/ProjectResolver.json +574 -574
  10. package/core/abi/SchemaRegistry.json +1 -1
  11. package/core/abi/index.ts +21 -0
  12. package/core/class/AllGapSchemas.ts +21 -0
  13. package/core/class/Attestation.ts +429 -0
  14. package/core/class/Fetcher.ts +224 -0
  15. package/core/class/GAP.ts +481 -0
  16. package/core/class/GapSchema.ts +93 -0
  17. package/core/class/Gelato/{Gelato.js → Gelato.ts} +23 -0
  18. package/core/class/GrantProgramRegistry/Allo.ts +188 -0
  19. package/core/class/GrantProgramRegistry/AlloRegistry.ts +101 -0
  20. package/core/class/GraphQL/AxiosGQL.ts +29 -0
  21. package/core/class/GraphQL/EASClient.ts +34 -0
  22. package/core/class/GraphQL/GapEasClient.ts +869 -0
  23. package/core/class/Schema.ts +659 -0
  24. package/core/class/SchemaError.ts +42 -0
  25. package/core/class/contract/GapContract.ts +457 -0
  26. package/core/class/entities/Community.ts +148 -0
  27. package/core/class/entities/ContributorProfile.ts +108 -0
  28. package/core/class/entities/Grant.ts +321 -0
  29. package/core/class/entities/GrantUpdate.ts +187 -0
  30. package/core/class/entities/MemberOf.ts +52 -0
  31. package/core/class/entities/Milestone.ts +898 -0
  32. package/core/class/entities/Project.ts +672 -0
  33. package/core/class/entities/ProjectImpact.ts +170 -0
  34. package/core/class/entities/ProjectMilestone.ts +254 -0
  35. package/core/class/entities/ProjectPointer.ts +39 -0
  36. package/core/class/entities/ProjectUpdate.ts +176 -0
  37. package/core/class/entities/Track.ts +32 -0
  38. package/core/class/karma-indexer/GapIndexerClient.ts +383 -0
  39. package/core/class/karma-indexer/api/GapIndexerApi.ts +446 -0
  40. package/core/class/karma-indexer/api/types.ts +313 -0
  41. package/core/class/remote-storage/IpfsStorage.ts +76 -0
  42. package/core/class/remote-storage/RemoteStorage.ts +65 -0
  43. package/core/class/types/allo.ts +93 -0
  44. package/core/class/types/attestations.ts +223 -0
  45. package/core/consts.ts +775 -0
  46. package/core/scripts/create-grant.ts +102 -0
  47. package/core/scripts/create-program.ts +43 -0
  48. package/core/scripts/create-schemas.ts +65 -0
  49. package/core/scripts/deploy.ts +65 -0
  50. package/core/scripts/index.ts +1 -0
  51. package/core/scripts/milestone-multi-grants.ts +125 -0
  52. package/core/shared/types.ts +13 -0
  53. package/core/types.ts +224 -0
  54. package/core/utils/gelato/send-gelato-txn.ts +114 -0
  55. package/core/utils/gelato/sponsor-handler.ts +77 -0
  56. package/core/utils/gelato/watch-gelato-txn.ts +67 -0
  57. package/core/utils/get-date.ts +3 -0
  58. package/core/utils/get-ipfs-data.ts +13 -0
  59. package/core/utils/get-web3-provider.ts +18 -0
  60. package/core/utils/gql-queries.ts +133 -0
  61. package/core/utils/map-filter.ts +21 -0
  62. package/core/utils/serialize-bigint.ts +7 -0
  63. package/core/utils/to-unix.ts +18 -0
  64. package/create-community-example.ts +119 -0
  65. package/csv-upload/README.md +74 -0
  66. package/csv-upload/config.ts +41 -0
  67. package/csv-upload/example.csv +2 -0
  68. package/csv-upload/keys.example.json +8 -0
  69. package/csv-upload/scripts/run.ts +417 -0
  70. package/csv-upload/types.ts +39 -0
  71. package/docs/.gitkeep +0 -0
  72. package/docs/images/attestation-architecture.png +0 -0
  73. package/docs/images/dfd-get-projects.png +0 -0
  74. package/gap-schema.yaml +155 -0
  75. package/milestone-workflow-example.ts +353 -0
  76. package/package.json +45 -39
  77. package/readme.md +872 -0
  78. package/schemas/.gitkeep +0 -0
  79. package/schemas/GAP-schemas-1692135812877.json +33 -0
  80. package/test-file-indexer-api.ts +25 -0
  81. package/tsconfig.json +26 -0
  82. package/core/abi/index.d.ts +0 -1114
  83. package/core/abi/index.js +0 -26
  84. package/core/class/AllGapSchemas.d.ts +0 -9
  85. package/core/class/AllGapSchemas.js +0 -19
  86. package/core/class/Attestation.d.ts +0 -173
  87. package/core/class/Attestation.js +0 -333
  88. package/core/class/Fetcher.d.ts +0 -175
  89. package/core/class/Fetcher.js +0 -13
  90. package/core/class/GAP.d.ts +0 -254
  91. package/core/class/GAP.js +0 -289
  92. package/core/class/GapSchema.d.ts +0 -34
  93. package/core/class/GapSchema.js +0 -62
  94. package/core/class/GrantProgramRegistry/Allo.d.ts +0 -17
  95. package/core/class/GrantProgramRegistry/Allo.js +0 -137
  96. package/core/class/GrantProgramRegistry/AlloRegistry.d.ts +0 -15
  97. package/core/class/GrantProgramRegistry/AlloRegistry.js +0 -70
  98. package/core/class/GraphQL/AxiosGQL.d.ts +0 -6
  99. package/core/class/GraphQL/AxiosGQL.js +0 -25
  100. package/core/class/GraphQL/EASClient.d.ts +0 -16
  101. package/core/class/GraphQL/EASClient.js +0 -26
  102. package/core/class/GraphQL/GapEasClient.d.ts +0 -71
  103. package/core/class/GraphQL/GapEasClient.js +0 -451
  104. package/core/class/GraphQL/index.js +0 -19
  105. package/core/class/Schema.d.ts +0 -233
  106. package/core/class/Schema.js +0 -488
  107. package/core/class/SchemaError.d.ts +0 -30
  108. package/core/class/SchemaError.js +0 -39
  109. package/core/class/contract/GapContract.d.ts +0 -102
  110. package/core/class/contract/GapContract.js +0 -285
  111. package/core/class/entities/Community.d.ts +0 -34
  112. package/core/class/entities/Community.js +0 -109
  113. package/core/class/entities/ContributorProfile.d.ts +0 -41
  114. package/core/class/entities/ContributorProfile.js +0 -69
  115. package/core/class/entities/Grant.d.ts +0 -54
  116. package/core/class/entities/Grant.js +0 -223
  117. package/core/class/entities/GrantUpdate.d.ts +0 -40
  118. package/core/class/entities/GrantUpdate.js +0 -114
  119. package/core/class/entities/MemberOf.d.ts +0 -11
  120. package/core/class/entities/MemberOf.js +0 -33
  121. package/core/class/entities/Milestone.d.ts +0 -168
  122. package/core/class/entities/Milestone.js +0 -657
  123. package/core/class/entities/Project.d.ts +0 -92
  124. package/core/class/entities/Project.js +0 -418
  125. package/core/class/entities/ProjectImpact.d.ts +0 -50
  126. package/core/class/entities/ProjectImpact.js +0 -112
  127. package/core/class/entities/ProjectMilestone.d.ts +0 -60
  128. package/core/class/entities/ProjectMilestone.js +0 -174
  129. package/core/class/entities/ProjectPointer.d.ts +0 -12
  130. package/core/class/entities/ProjectPointer.js +0 -22
  131. package/core/class/entities/ProjectUpdate.d.ts +0 -50
  132. package/core/class/entities/ProjectUpdate.js +0 -110
  133. package/core/class/entities/Track.d.ts +0 -16
  134. package/core/class/entities/Track.js +0 -21
  135. package/core/class/entities/index.js +0 -26
  136. package/core/class/index.js +0 -26
  137. package/core/class/karma-indexer/GapIndexerClient.d.ts +0 -66
  138. package/core/class/karma-indexer/GapIndexerClient.js +0 -207
  139. package/core/class/karma-indexer/api/GapIndexerApi.d.ts +0 -73
  140. package/core/class/karma-indexer/api/GapIndexerApi.js +0 -256
  141. package/core/class/karma-indexer/api/types.d.ts +0 -295
  142. package/core/class/karma-indexer/api/types.js +0 -2
  143. package/core/class/remote-storage/IpfsStorage.d.ts +0 -23
  144. package/core/class/remote-storage/IpfsStorage.js +0 -56
  145. package/core/class/remote-storage/RemoteStorage.d.ts +0 -41
  146. package/core/class/remote-storage/RemoteStorage.js +0 -38
  147. package/core/class/types/allo.d.ts +0 -78
  148. package/core/class/types/allo.js +0 -2
  149. package/core/class/types/attestations.d.ts +0 -168
  150. package/core/class/types/attestations.js +0 -66
  151. package/core/consts.d.ts +0 -48
  152. package/core/consts.js +0 -641
  153. package/core/index.js +0 -24
  154. package/core/shared/types.d.ts +0 -6
  155. package/core/shared/types.js +0 -2
  156. package/core/types.d.ts +0 -131
  157. package/core/types.js +0 -13
  158. package/core/utils/gelato/index.js +0 -19
  159. package/core/utils/gelato/send-gelato-txn.d.ts +0 -55
  160. package/core/utils/gelato/send-gelato-txn.js +0 -100
  161. package/core/utils/gelato/sponsor-handler.d.ts +0 -9
  162. package/core/utils/gelato/sponsor-handler.js +0 -60
  163. package/core/utils/gelato/watch-gelato-txn.d.ts +0 -7
  164. package/core/utils/gelato/watch-gelato-txn.js +0 -63
  165. package/core/utils/get-date.d.ts +0 -1
  166. package/core/utils/get-date.js +0 -7
  167. package/core/utils/get-ipfs-data.d.ts +0 -1
  168. package/core/utils/get-ipfs-data.js +0 -20
  169. package/core/utils/get-web3-provider.d.ts +0 -2
  170. package/core/utils/get-web3-provider.js +0 -18
  171. package/core/utils/gql-queries.d.ts +0 -12
  172. package/core/utils/gql-queries.js +0 -90
  173. package/core/utils/index.js +0 -23
  174. package/core/utils/map-filter.d.ts +0 -8
  175. package/core/utils/map-filter.js +0 -20
  176. package/core/utils/serialize-bigint.d.ts +0 -1
  177. package/core/utils/serialize-bigint.js +0 -8
  178. package/core/utils/to-unix.d.ts +0 -1
  179. package/core/utils/to-unix.js +0 -25
  180. package/index.js +0 -17
  181. /package/core/class/GraphQL/{index.d.ts → index.ts} +0 -0
  182. /package/core/class/entities/{index.d.ts → index.ts} +0 -0
  183. /package/core/class/{index.d.ts → index.ts} +0 -0
  184. /package/core/{index.d.ts → index.ts} +0 -0
  185. /package/core/utils/gelato/{index.d.ts → index.ts} +0 -0
  186. /package/core/utils/{index.d.ts → index.ts} +0 -0
  187. /package/{core/class/Gelato/Gelato.d.ts → csv-upload/.gitkeep} +0 -0
  188. /package/{index.d.ts → index.ts} +0 -0
@@ -1,223 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Grant = void 0;
4
- const Attestation_1 = require("../Attestation");
5
- const attestations_1 = require("../types/attestations");
6
- const Milestone_1 = require("./Milestone");
7
- const SchemaError_1 = require("../SchemaError");
8
- const consts_1 = require("../../consts");
9
- const GapContract_1 = require("../contract/GapContract");
10
- const Community_1 = require("./Community");
11
- const Project_1 = require("./Project");
12
- const AllGapSchemas_1 = require("../AllGapSchemas");
13
- const GrantUpdate_1 = require("./GrantUpdate");
14
- class Grant extends Attestation_1.Attestation {
15
- constructor() {
16
- super(...arguments);
17
- this.verified = false;
18
- this.milestones = [];
19
- this.updates = [];
20
- this.members = [];
21
- this.categories = [];
22
- }
23
- async verify(signer) {
24
- const eas = this.schema.gap.eas.connect(signer);
25
- const schema = this.schema.gap.findSchema("MilestoneApproved");
26
- schema.setValue("approved", true);
27
- try {
28
- await eas.attest({
29
- schema: schema.raw,
30
- data: {
31
- recipient: this.recipient,
32
- data: schema.encode(),
33
- refUID: this.uid,
34
- expirationTime: 0n,
35
- revocable: schema.revocable,
36
- },
37
- });
38
- this.verified = true;
39
- }
40
- catch (error) {
41
- console.error(error);
42
- throw new SchemaError_1.AttestationError("ATTEST_ERROR", error.message, error);
43
- }
44
- }
45
- /**
46
- * Add milestones to the grant.
47
- * @param signer
48
- * @param milestones
49
- */
50
- addMilestones(milestones) {
51
- const schema = this.schema.gap.findSchema("Milestone");
52
- const newMilestones = milestones.map((milestone) => {
53
- const m = new Milestone_1.Milestone({
54
- data: milestone,
55
- refUID: this.uid,
56
- schema,
57
- createdAt: Date.now(),
58
- recipient: this.recipient,
59
- uid: consts_1.nullRef,
60
- });
61
- return m;
62
- });
63
- this.milestones.push(...newMilestones);
64
- }
65
- /**
66
- * Creates the payload for a multi-attestation.
67
- *
68
- * > if Current payload is set, it'll be used as the base payload
69
- * and the project should refer to an index of the current payload,
70
- * usually the community position.
71
- *
72
- * @param payload
73
- * @param projectIdx
74
- */
75
- async multiAttestPayload(currentPayload = [], projectIdx = 0) {
76
- this.assertPayload();
77
- const payload = [...currentPayload];
78
- const grantIdx = payload.push([this, await this.payloadFor(projectIdx)]) - 1;
79
- if (this.details) {
80
- payload.push([this.details, await this.details.payloadFor(grantIdx)]);
81
- }
82
- if (this.milestones.length) {
83
- await Promise.all(this.milestones.map(async (m) => payload.push(...(await m.multiAttestPayload(payload, grantIdx)))));
84
- }
85
- if (this.updates.length) {
86
- await Promise.all(this.updates.map(async (u) => payload.push([u, await u.payloadFor(grantIdx)])));
87
- }
88
- return payload.slice(currentPayload.length, payload.length);
89
- }
90
- async attestProject(signer, originalProjectChainId) {
91
- const project = new Project_1.Project({
92
- data: { project: true },
93
- schema: this.schema.gap.findSchema("Project"),
94
- recipient: this.recipient,
95
- chainID: this.chainID,
96
- });
97
- project.details = new Attestation_1.Attestation({
98
- data: {
99
- originalProjectChainId,
100
- uid: this.refUID,
101
- },
102
- chainID: this.chainID,
103
- recipient: this.recipient,
104
- schema: this.schema.gap.findSchema("ProjectDetails"),
105
- });
106
- // Overwrite refuid
107
- Object.assign(this, { refUID: consts_1.nullRef });
108
- project.grants = [this];
109
- const attestation = await project.attest(signer);
110
- return attestation;
111
- }
112
- /**
113
- * @inheritdoc
114
- */
115
- async attest(signer, projectChainId, callback) {
116
- if (projectChainId !== this.chainID) {
117
- return this.attestProject(signer, projectChainId);
118
- }
119
- this.assertPayload();
120
- const payload = await this.multiAttestPayload();
121
- const { tx, uids } = await GapContract_1.GapContract.multiAttest(signer, payload.map((p) => p[1]), callback);
122
- if (Array.isArray(uids)) {
123
- uids.forEach((uid, index) => {
124
- payload[index][0].uid = uid;
125
- });
126
- }
127
- return { tx, uids };
128
- }
129
- async attestUpdate(signer, data, callback) {
130
- const grantUpdate = new GrantUpdate_1.GrantUpdate({
131
- data: {
132
- ...data,
133
- type: "grant-update",
134
- },
135
- recipient: this.recipient,
136
- refUID: this.uid,
137
- schema: this.schema.gap.findSchema("GrantDetails"),
138
- });
139
- await grantUpdate.attest(signer, callback);
140
- this.updates.push(grantUpdate);
141
- }
142
- /**
143
- * Validate if the grant has a valid reference to a community.
144
- */
145
- assertPayload() {
146
- if (!this.details || !this.communityUID) {
147
- throw new SchemaError_1.AttestationError("INVALID_REFERENCE", "Grant should include a valid reference to a community on its details.");
148
- }
149
- return true;
150
- }
151
- async complete(signer, data, callback) {
152
- const completed = new attestations_1.GrantCompleted({
153
- data: {
154
- ...data,
155
- type: "grant-completed",
156
- },
157
- recipient: this.recipient,
158
- refUID: this.uid,
159
- schema: this.schema.gap.findSchema("GrantDetails"),
160
- });
161
- const { tx, uids } = await completed.attest(signer, callback);
162
- this.completed = completed;
163
- return { tx, uids };
164
- }
165
- static from(attestations, network) {
166
- return attestations.map((attestation) => {
167
- const grant = new Grant({
168
- ...attestation,
169
- data: {
170
- communityUID: attestation.data.communityUID,
171
- },
172
- schema: new AllGapSchemas_1.AllGapSchemas().findSchema("Grant", consts_1.chainIdToNetwork[attestation.chainID]),
173
- chainID: attestation.chainID,
174
- });
175
- if (attestation.details) {
176
- const { details } = attestation;
177
- grant.details = new attestations_1.GrantDetails({
178
- ...details,
179
- data: {
180
- ...details.data,
181
- },
182
- schema: new AllGapSchemas_1.AllGapSchemas().findSchema("GrantDetails", consts_1.chainIdToNetwork[attestation.chainID]),
183
- chainID: attestation.chainID,
184
- });
185
- }
186
- if (attestation.milestones) {
187
- const { milestones } = attestation;
188
- grant.milestones = Milestone_1.Milestone.from(milestones, network);
189
- }
190
- if (attestation.updates) {
191
- const { updates } = attestation;
192
- grant.updates = GrantUpdate_1.GrantUpdate.from(updates, network);
193
- }
194
- if (attestation.completed) {
195
- const { completed } = attestation;
196
- grant.completed = new attestations_1.GrantCompleted({
197
- ...completed,
198
- data: {
199
- ...completed.data,
200
- },
201
- schema: new AllGapSchemas_1.AllGapSchemas().findSchema("GrantDetails", consts_1.chainIdToNetwork[attestation.chainID]),
202
- chainID: attestation.chainID,
203
- });
204
- }
205
- if (attestation.project) {
206
- const { project } = attestation;
207
- grant.project = project;
208
- }
209
- if (attestation.community) {
210
- const { community } = attestation;
211
- grant.community = Community_1.Community.from([community], network)[0];
212
- }
213
- if (attestation.members) {
214
- grant.members = attestation.members;
215
- }
216
- if (attestation.categories) {
217
- grant.categories = attestation.categories;
218
- }
219
- return grant;
220
- });
221
- }
222
- }
223
- exports.Grant = Grant;
@@ -1,40 +0,0 @@
1
- import { IGrantUpdateBase } from "core/shared/types";
2
- import { Transaction } from "ethers";
3
- import { SignerOrProvider, TNetwork } from "../../../core/types";
4
- import { Attestation } from "../Attestation";
5
- export interface _IGrantUpdate extends GrantUpdate {
6
- }
7
- export interface IGrantUpdate extends IGrantUpdateBase {
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
- proofOfWork: string;
23
- verified: GrantUpdateStatus[];
24
- /**
25
- * Attest the status of the milestone as approved, rejected or completed.
26
- */
27
- private attestStatus;
28
- /**
29
- * Verify this GrantUpdate. If the GrantUpdate is not already verified,
30
- * it will throw an error.
31
- * @param signer
32
- * @param reason
33
- */
34
- verify(signer: SignerOrProvider, data?: IGrantUpdateStatus, callback?: Function): Promise<{
35
- tx: Transaction[];
36
- uids: `0x${string}`[];
37
- }>;
38
- static from(attestations: _IGrantUpdate[], network: TNetwork): GrantUpdate[];
39
- }
40
- export {};
@@ -1,114 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.GrantUpdate = exports.GrantUpdateStatus = void 0;
4
- const consts_1 = require("../../../core/consts");
5
- const AllGapSchemas_1 = require("../AllGapSchemas");
6
- const Attestation_1 = require("../Attestation");
7
- const SchemaError_1 = require("../SchemaError");
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, 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 GrantUpdate. If the GrantUpdate 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("GrantUpdateStatus");
63
- if (this.schema.isJsonSchema()) {
64
- schema.setValue("json", JSON.stringify({
65
- type: "grant-update-verified",
66
- ...data,
67
- }));
68
- }
69
- else {
70
- schema.setValue("type", "grant-update-verified");
71
- schema.setValue("reason", data?.reason || "");
72
- }
73
- console.log("Before attest grant update verified");
74
- const { tx, uids } = await this.attestStatus(signer, schema, callback);
75
- console.log("After attest grant update verified");
76
- this.verified.push(new GrantUpdateStatus({
77
- data: {
78
- type: "grant-update-verified",
79
- ...data,
80
- },
81
- refUID: this.uid,
82
- schema: schema,
83
- recipient: this.recipient,
84
- }));
85
- return {
86
- tx,
87
- uids,
88
- };
89
- }
90
- static from(attestations, network) {
91
- return attestations.map((attestation) => {
92
- const grantUpdate = new GrantUpdate({
93
- ...attestation,
94
- data: {
95
- ...attestation.data,
96
- },
97
- schema: new AllGapSchemas_1.AllGapSchemas().findSchema("GrantUpdate", consts_1.chainIdToNetwork[attestation.chainID]),
98
- chainID: attestation.chainID,
99
- });
100
- if (attestation.verified?.length > 0) {
101
- grantUpdate.verified = attestation.verified.map((m) => new GrantUpdateStatus({
102
- ...m,
103
- data: {
104
- ...m.data,
105
- },
106
- schema: new AllGapSchemas_1.AllGapSchemas().findSchema("GrantUpdateStatus", consts_1.chainIdToNetwork[attestation.chainID]),
107
- chainID: attestation.chainID,
108
- }));
109
- }
110
- return grantUpdate;
111
- });
112
- }
113
- }
114
- exports.GrantUpdate = GrantUpdate;
@@ -1,11 +0,0 @@
1
- import { MultiAttestPayload, SignerOrProvider } from "core/types";
2
- import { Attestation } from "../Attestation";
3
- import { AttestationWithTx, MemberDetails } from "../types/attestations";
4
- export interface IMemberOf {
5
- memberOf: true;
6
- }
7
- export declare class MemberOf extends Attestation<IMemberOf> {
8
- details?: MemberDetails;
9
- multiAttestPayload(currentPayload?: MultiAttestPayload, projectIdx?: number): Promise<[Attestation<unknown, import("..").GapSchema>, import("core/types").RawMultiAttestPayload][]>;
10
- attest(signer: SignerOrProvider, callback?: Function): Promise<AttestationWithTx>;
11
- }
@@ -1,33 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.MemberOf = void 0;
4
- const Attestation_1 = require("../Attestation");
5
- const SchemaError_1 = require("../SchemaError");
6
- const GapContract_1 = require("../contract/GapContract");
7
- class MemberOf extends Attestation_1.Attestation {
8
- async multiAttestPayload(currentPayload = [], projectIdx = 0) {
9
- const payload = [...currentPayload];
10
- const memberIdx = payload.push([this, await this.payloadFor(projectIdx)]) - 1;
11
- if (this.details) {
12
- payload.push([this.details, await this.details.payloadFor(memberIdx)]);
13
- }
14
- return payload.slice(currentPayload.length, payload.length);
15
- }
16
- async attest(signer, callback) {
17
- const payload = await this.multiAttestPayload();
18
- try {
19
- const { uids, tx } = await GapContract_1.GapContract.multiAttest(signer, payload.map((p) => p[1]), callback);
20
- const [memberUID, detailsUID] = uids;
21
- this.uid = memberUID;
22
- if (this.details && detailsUID) {
23
- this.details.uid = detailsUID;
24
- }
25
- return { tx, uids };
26
- }
27
- catch (error) {
28
- console.error(error);
29
- throw new SchemaError_1.AttestationError("ATTEST_ERROR", error.message, error);
30
- }
31
- }
32
- }
33
- exports.MemberOf = MemberOf;
@@ -1,168 +0,0 @@
1
- import { Transaction } from "ethers";
2
- import { Hex, MultiAttestPayload, MultiRevokeArgs, SignerOrProvider, TNetwork } from "../../types";
3
- import { Attestation } from "../Attestation";
4
- import { GapSchema } from "../GapSchema";
5
- import { IMilestoneResponse } from "../karma-indexer/api/types";
6
- import { AttestationWithTx, MilestoneCompleted, IMilestoneCompleted } from "../types/attestations";
7
- export interface IMilestone {
8
- title: string;
9
- startsAt?: number;
10
- endsAt: number;
11
- description: string;
12
- type?: string;
13
- priority?: number;
14
- }
15
- /**
16
- * Milestone class represents a milestone that can be attested to one or multiple grants.
17
- *
18
- * It provides methods to:
19
- * - Create, complete, approve, reject, and verify milestones
20
- * - Attest a milestone to a single grant
21
- * - Attest a milestone to multiple grants in a single transaction
22
- * - Complete, approve, and verify milestones across multiple grants
23
- * - Revoke multiple milestone attestations at once
24
- */
25
- export declare class Milestone extends Attestation<IMilestone> implements IMilestone {
26
- title: string;
27
- startsAt?: number;
28
- endsAt: number;
29
- description: string;
30
- completed: MilestoneCompleted;
31
- approved: MilestoneCompleted;
32
- rejected: MilestoneCompleted;
33
- verified: MilestoneCompleted[];
34
- type: string;
35
- priority?: number;
36
- /**
37
- * Approves this milestone. If the milestone is not completed or already approved,
38
- * it will throw an error.
39
- * @param signer
40
- * @param reason
41
- */
42
- approve(signer: SignerOrProvider, data?: IMilestoneCompleted, callback?: Function): Promise<void>;
43
- /**
44
- * Approves this milestone across multiple grants. If the milestones are not completed,
45
- * it will throw an error.
46
- * @param signer - The signer to use for attestation
47
- * @param milestoneUIDs - Array of milestone UIDs to approve
48
- * @param data - Optional approval data
49
- * @param callback - Optional callback function for status updates
50
- * @returns Promise with transaction and UIDs
51
- */
52
- approveMultipleGrants(signer: SignerOrProvider, milestoneUIDs: Hex[], data?: IMilestoneCompleted, callback?: Function): Promise<AttestationWithTx>;
53
- /**
54
- * Revokes the approved status of the milestone. If the milestone is not approved,
55
- * it will throw an error.
56
- * @param signer
57
- */
58
- revokeApproval(signer: SignerOrProvider): Promise<void>;
59
- /**
60
- * Reject a completed milestone. If the milestone is not completed or already rejected,
61
- * it will throw an error.
62
- * @param signer
63
- * @param reason
64
- */
65
- reject(signer: SignerOrProvider, reason?: string): Promise<void>;
66
- /**
67
- * Revokes the rejected status of the milestone. If the milestone is not rejected,
68
- * it will throw an error.
69
- * @param signer
70
- */
71
- revokeRejection(signer: SignerOrProvider): Promise<{
72
- tx: Transaction[];
73
- uids: `0x${string}`[];
74
- }>;
75
- /**
76
- * Revokes multiple milestone attestations at once.
77
- * This method can be used to revoke multiple milestone attestations in a single transaction.
78
- *
79
- * @param signer - The signer to use for revocation
80
- * @param attestationsToRevoke - Array of objects containing schemaId and uid of attestations to revoke
81
- * @param callback - Optional callback function for status updates
82
- * @returns Promise with transaction and UIDs of revoked attestations
83
- */
84
- revokeMultipleAttestations(signer: SignerOrProvider, attestationsToRevoke: MultiRevokeArgs[], callback?: Function): Promise<AttestationWithTx>;
85
- /**
86
- * Marks a milestone as completed. If the milestone is already completed,
87
- * it will throw an error.
88
- * @param signer
89
- * @param reason
90
- */
91
- complete(signer: SignerOrProvider, data?: IMilestoneCompleted, callback?: Function): Promise<AttestationWithTx>;
92
- /**
93
- * Marks a milestone as completed across multiple grants. If the milestone is already completed,
94
- * it will throw an error.
95
- * @param signer - The signer to use for attestation
96
- * @param grantIndices - Array of grant indices to attest this milestone to, or array of milestone UIDs
97
- * @param data - Optional completion data
98
- * @param callback - Optional callback function for status updates
99
- * @returns Promise with transaction and UIDs
100
- */
101
- completeForMultipleGrants(signer: SignerOrProvider, grantIndicesOrMilestoneUIDs?: number[] | Hex[], data?: IMilestoneCompleted, callback?: Function): Promise<AttestationWithTx>;
102
- /**
103
- * Revokes the completed status of the milestone. If the milestone is not completed,
104
- * it will throw an error.
105
- * @param signer
106
- */
107
- revokeCompletion(signer: SignerOrProvider, callback?: Function): Promise<{
108
- tx: Transaction[];
109
- uids: `0x${string}`[];
110
- }>;
111
- /**
112
- * Creates the payload for a multi-attestation.
113
- *
114
- * > if Current payload is set, it'll be used as the base payload
115
- * and the project should refer to an index of the current payload,
116
- * usually the community position.
117
- *
118
- * @param payload
119
- * @param grantIdx
120
- */
121
- multiAttestPayload(currentPayload?: MultiAttestPayload, grantIdx?: number): Promise<[Attestation<unknown, GapSchema>, import("../../types").RawMultiAttestPayload][]>;
122
- /**
123
- * Creates the payload for a multi-attestation across multiple grants.
124
- *
125
- * This method allows for the same milestone to be attested to multiple grants
126
- * in a single transaction.
127
- *
128
- * @param currentPayload - Current payload to append to
129
- * @param grantIndices - Array of grant indices to attest this milestone to
130
- * @returns The multi-attest payload with all grant attestations
131
- */
132
- multiGrantAttestPayload(currentPayload?: MultiAttestPayload, grantIndices?: number[]): Promise<[Attestation<unknown, GapSchema>, import("../../types").RawMultiAttestPayload][]>;
133
- /**
134
- * Attests this milestone to multiple grants in a single transaction.
135
- *
136
- * @param signer - The signer to use for attestation
137
- * @param grantIndices - Array of grant indices to attest this milestone to, or array of grant UIDs
138
- * @param callback - Optional callback function for status updates
139
- * @returns Promise with transaction and UIDs
140
- */
141
- attestToMultipleGrants(signer: SignerOrProvider, grantIndices?: number[] | Hex[], callback?: Function): Promise<AttestationWithTx>;
142
- /**
143
- * @inheritdoc
144
- */
145
- attest(signer: SignerOrProvider, callback?: Function): Promise<AttestationWithTx>;
146
- /**
147
- * Attest the status of the milestone as approved, rejected or completed.
148
- */
149
- private attestStatus;
150
- static from(attestations: IMilestoneResponse[], network: TNetwork): Milestone[];
151
- /**
152
- * Verify this milestone. If the milestone is not completed or already verified,
153
- * it will throw an error.
154
- * @param signer
155
- * @param reason
156
- */
157
- verify(signer: SignerOrProvider, data?: IMilestoneCompleted, callback?: Function): Promise<AttestationWithTx>;
158
- /**
159
- * Verifies this milestone across multiple grants. If the milestones are not completed,
160
- * it will throw an error.
161
- * @param signer - The signer to use for attestation
162
- * @param milestoneUIDs - Array of milestone UIDs to verify
163
- * @param data - Optional verification data
164
- * @param callback - Optional callback function for status updates
165
- * @returns Promise with transaction and UIDs
166
- */
167
- verifyMultipleGrants(signer: SignerOrProvider, milestoneUIDs: Hex[], data?: IMilestoneCompleted, callback?: Function): Promise<AttestationWithTx>;
168
- }