@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,92 +0,0 @@
1
- import { Hex, MultiAttestPayload, SignerOrProvider, TNetwork } from "core/types";
2
- import { Attestation } from "../Attestation";
3
- import { IProjectResponse } from "../karma-indexer/api/types";
4
- import { AttestationWithTx, Grantee, MemberDetails, ProjectDetails, ProjectEndorsement } from "../types/attestations";
5
- import { Grant } from "./Grant";
6
- import { MemberOf } from "./MemberOf";
7
- import { IProjectImpact, ProjectImpact } from "./ProjectImpact";
8
- import { ProjectMilestone } from "./ProjectMilestone";
9
- import { ProjectPointer } from "./ProjectPointer";
10
- import { ProjectUpdate } from "./ProjectUpdate";
11
- export interface IProject {
12
- project: true;
13
- }
14
- export declare class Project extends Attestation<IProject> {
15
- details?: ProjectDetails;
16
- members: MemberOf[];
17
- grants: Grant[];
18
- grantee: Grantee;
19
- impacts: ProjectImpact[];
20
- endorsements: ProjectEndorsement[];
21
- updates: ProjectUpdate[];
22
- pointers: ProjectPointer[];
23
- milestones: ProjectMilestone[];
24
- /**
25
- * Creates the payload for a multi-attestation.
26
- *
27
- * > if Current payload is set, it'll be used as the base payload
28
- * and the project should refer to an index of the current payload,
29
- * usually the community position.
30
- *
31
- * @param payload
32
- * @param communityIdx
33
- */
34
- multiAttestPayload(currentPayload?: MultiAttestPayload, communityIdx?: number): Promise<MultiAttestPayload>;
35
- attest(signer: SignerOrProvider, callback?: Function): Promise<AttestationWithTx>;
36
- transferOwnership(signer: SignerOrProvider, newOwner: Hex, callback?: Function): Promise<AttestationWithTx>;
37
- isOwner(signer: SignerOrProvider, publicAddress?: string): Promise<boolean>;
38
- isAdmin(signer: SignerOrProvider, publicAddress?: string): Promise<boolean>;
39
- /**
40
- * Add new members to the project.
41
- * If any member in the array already exists in the project
42
- * it'll be ignored.
43
- * @param members
44
- */
45
- pushMembers(...members: Hex[]): void;
46
- /**
47
- * Add new members to the project.
48
- * If any member in the array already exists in the project
49
- * it'll be ignored.
50
- *
51
- * __To modify member details, use `addMemberDetails(signer, MemberDetails[])` instead.__
52
- * @param signer
53
- * @param members
54
- */
55
- attestMembers(signer: SignerOrProvider, members: MemberDetails[], callback?: Function): Promise<void>;
56
- /**
57
- * Add new details to the members of a project. Note that it will overwrite
58
- * any existing details.
59
- *
60
- * @param signer
61
- * @param entities
62
- */
63
- private addMemberDetails;
64
- /**
65
- * Clean member details.
66
- * @param signer
67
- * @param uids
68
- */
69
- cleanDetails(signer: SignerOrProvider, uids: Hex[]): Promise<void>;
70
- /**
71
- * Remove members from the project.
72
- * @param signer
73
- * @param uids
74
- * @returns
75
- */
76
- removeMembers(signer: SignerOrProvider, uids: Hex[]): Promise<void>;
77
- /**
78
- * Remove all members from the project.
79
- * @param signer
80
- */
81
- removeAllMembers(signer: SignerOrProvider): Promise<void>;
82
- static from(attestations: IProjectResponse[], network: TNetwork): Project[];
83
- attestUpdate(signer: SignerOrProvider, data: ProjectUpdate, callback?: Function): Promise<void>;
84
- attestMilestone(signer: SignerOrProvider, data: ProjectUpdate, callback?: Function): Promise<void>;
85
- attestPointer(signer: SignerOrProvider, data: ProjectPointer, callback?: Function): Promise<void>;
86
- attestImpact(signer: SignerOrProvider, data: IProjectImpact, targetChainId?: number, callback?: Function): Promise<AttestationWithTx>;
87
- private attestGhostProjectImpact;
88
- attestEndorsement(signer: SignerOrProvider, data?: ProjectEndorsement): Promise<void>;
89
- attestGhostProject(signer: SignerOrProvider, targetChainId: number): Promise<AttestationWithTx>;
90
- addAdmin(signer: SignerOrProvider, newAdmin: Hex, callback?: Function): Promise<AttestationWithTx>;
91
- removeAdmin(signer: SignerOrProvider, oldAdmin: Hex, callback?: Function): Promise<AttestationWithTx>;
92
- }
@@ -1,418 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Project = void 0;
4
- const consts_1 = require("../../consts");
5
- const utils_1 = require("../../utils");
6
- const AllGapSchemas_1 = require("../AllGapSchemas");
7
- const Attestation_1 = require("../Attestation");
8
- const GapContract_1 = require("../contract/GapContract");
9
- const SchemaError_1 = require("../SchemaError");
10
- const attestations_1 = require("../types/attestations");
11
- const Grant_1 = require("./Grant");
12
- const MemberOf_1 = require("./MemberOf");
13
- const ProjectImpact_1 = require("./ProjectImpact");
14
- const ProjectMilestone_1 = require("./ProjectMilestone");
15
- const ProjectPointer_1 = require("./ProjectPointer");
16
- const ProjectUpdate_1 = require("./ProjectUpdate");
17
- class Project extends Attestation_1.Attestation {
18
- constructor() {
19
- super(...arguments);
20
- this.members = [];
21
- this.grants = [];
22
- this.impacts = [];
23
- this.endorsements = [];
24
- this.updates = [];
25
- this.pointers = [];
26
- this.milestones = [];
27
- }
28
- /**
29
- * Creates the payload for a multi-attestation.
30
- *
31
- * > if Current payload is set, it'll be used as the base payload
32
- * and the project should refer to an index of the current payload,
33
- * usually the community position.
34
- *
35
- * @param payload
36
- * @param communityIdx
37
- */
38
- async multiAttestPayload(currentPayload = [], communityIdx = 0) {
39
- const payload = [...currentPayload];
40
- const projectIdx = payload.push([this, await this.payloadFor(communityIdx)]) - 1;
41
- if (this.details) {
42
- payload.push([this.details, await this.details.payloadFor(projectIdx)]);
43
- }
44
- if (this.members?.length) {
45
- await Promise.all(this.members.map(async (m) => payload.push(...(await m.multiAttestPayload(payload, projectIdx)))));
46
- }
47
- if (this.grants?.length) {
48
- await Promise.all(this.grants.map(async (g) => payload.push(...(await g.multiAttestPayload(payload, projectIdx)))));
49
- }
50
- return payload.slice(currentPayload.length, payload.length);
51
- }
52
- async attest(signer, callback) {
53
- const payload = await this.multiAttestPayload();
54
- const { tx, uids } = await GapContract_1.GapContract.multiAttest(signer, payload.map((p) => p[1]), callback);
55
- if (Array.isArray(uids)) {
56
- uids.forEach((uid, index) => {
57
- payload[index][0].uid = uid;
58
- });
59
- }
60
- return { tx, uids };
61
- }
62
- async transferOwnership(signer, newOwner, callback) {
63
- callback?.("preparing");
64
- const tx = await GapContract_1.GapContract.transferProjectOwnership(signer, this.uid, newOwner);
65
- callback?.("confirmed");
66
- const txArray = [tx].flat();
67
- return { tx: txArray, uids: [this.uid] };
68
- }
69
- isOwner(signer, publicAddress) {
70
- return GapContract_1.GapContract.isProjectOwner(signer, this.uid, this.chainID, publicAddress);
71
- }
72
- isAdmin(signer, publicAddress) {
73
- return GapContract_1.GapContract.isProjectAdmin(signer, this.uid, this.chainID, publicAddress);
74
- }
75
- /**
76
- * Add new members to the project.
77
- * If any member in the array already exists in the project
78
- * it'll be ignored.
79
- * @param members
80
- */
81
- pushMembers(...members) {
82
- this.members.push(...(0, utils_1.mapFilter)(members, (member) => !!this.members.find((m) => m.recipient === member), (member) => new MemberOf_1.MemberOf({
83
- data: { memberOf: true },
84
- refUID: this.uid,
85
- schema: this.schema.gap.findSchema("MemberOf"),
86
- recipient: member,
87
- uid: consts_1.nullRef,
88
- })));
89
- }
90
- /**
91
- * Add new members to the project.
92
- * If any member in the array already exists in the project
93
- * it'll be ignored.
94
- *
95
- * __To modify member details, use `addMemberDetails(signer, MemberDetails[])` instead.__
96
- * @param signer
97
- * @param members
98
- */
99
- async attestMembers(signer, members, callback) {
100
- const newMembers = (0, utils_1.mapFilter)(members, (member) => !this.members.find((m) => m.recipient === member.recipient),
101
- // (member) => !!member,
102
- (details) => {
103
- const member = new MemberOf_1.MemberOf({
104
- data: { memberOf: true },
105
- refUID: this.uid,
106
- schema: this.schema.gap.findSchema("MemberOf"),
107
- createdAt: Date.now(),
108
- recipient: details.recipient,
109
- uid: consts_1.nullRef,
110
- });
111
- return { member, details };
112
- });
113
- if (!newMembers.length) {
114
- throw new SchemaError_1.AttestationError("ATTEST_ERROR", "No new members to add.");
115
- }
116
- console.log(`Creating ${newMembers.length} new members`);
117
- const { uids: attestedMembers } = await this.schema.multiAttest(signer, newMembers.map((m) => m.member), callback);
118
- console.log("attested-members", attestedMembers);
119
- newMembers.forEach(({ member, details }, idx) => {
120
- Object.assign(member, { uid: attestedMembers[idx] });
121
- if (!details)
122
- return;
123
- Object.assign(details, { refUID: attestedMembers[idx] });
124
- });
125
- this.members.push(...newMembers.map((m) => m.member));
126
- await this.addMemberDetails(signer, newMembers.map((m) => m.details));
127
- }
128
- /**
129
- * Add new details to the members of a project. Note that it will overwrite
130
- * any existing details.
131
- *
132
- * @param signer
133
- * @param entities
134
- */
135
- async addMemberDetails(signer, entities, callback) {
136
- // Check if any of members should be revoked (details modified)
137
- const toRevoke = (0, utils_1.mapFilter)(this.members, (member) => !!entities.find((entity) => member.uid === entity.refUID &&
138
- member.details &&
139
- member.details?.refUID !== entity.refUID), (member) => member.uid);
140
- if (toRevoke.length) {
141
- console.log("Revoking details");
142
- await this.cleanDetails(signer, toRevoke);
143
- }
144
- console.log(`Creating ${entities.length} new member details`);
145
- const { uids: attestedEntities } = await this.schema.multiAttest(signer, entities, callback);
146
- console.log("attested-entities", attestedEntities);
147
- entities.forEach((entity, idx) => {
148
- const member = this.members.find((member) => member.uid === entity.refUID);
149
- if (!member)
150
- return;
151
- Object.assign(entity, { uid: attestedEntities[idx] });
152
- member.details = entity;
153
- });
154
- }
155
- /**
156
- * Clean member details.
157
- * @param signer
158
- * @param uids
159
- */
160
- async cleanDetails(signer, uids) {
161
- if (!uids.length) {
162
- throw new SchemaError_1.AttestationError("ATTEST_ERROR", "No details to clean.");
163
- }
164
- const memberDetails = this.schema.gap.findSchema("MemberDetails");
165
- await this.schema.multiRevoke(signer, uids.map((uid) => ({ schemaId: memberDetails.uid, uid })));
166
- this.members.forEach((member) => {
167
- if (!member.details)
168
- return;
169
- if (uids.includes(member.details.uid)) {
170
- member.details = undefined;
171
- }
172
- });
173
- }
174
- /**
175
- * Remove members from the project.
176
- * @param signer
177
- * @param uids
178
- * @returns
179
- */
180
- async removeMembers(signer, uids) {
181
- if (!uids.length) {
182
- throw new SchemaError_1.AttestationError("ATTEST_ERROR", "No members to remove.");
183
- }
184
- const memberOf = this.schema.gap.findSchema("MemberOf");
185
- const details = (0, utils_1.mapFilter)(this.members, (m) => uids.includes(m.uid) && !!m.details, (m) => m.details?.uid);
186
- if (details.length) {
187
- await this.cleanDetails(signer, details);
188
- }
189
- await this.schema.multiRevoke(signer, uids.map((uid) => ({ schemaId: memberOf.uid, uid })));
190
- this.members = this.members.filter((m) => !uids.includes(m.uid));
191
- }
192
- /**
193
- * Remove all members from the project.
194
- * @param signer
195
- */
196
- async removeAllMembers(signer) {
197
- const members = (0, utils_1.mapFilter)(this.members, (m) => !!m.uid, (m) => m.uid);
198
- if (!members.length) {
199
- throw new SchemaError_1.AttestationError("REVOKATION_ERROR", "No members to revoke.");
200
- }
201
- const details = (0, utils_1.mapFilter)(this.members, (m) => !!m.details, (m) => m.details?.uid);
202
- if (details.length) {
203
- await this.cleanDetails(signer, details);
204
- }
205
- await this.removeMembers(signer, members);
206
- this.members.splice(0, this.members.length);
207
- }
208
- static from(attestations, network) {
209
- const allSchemas = new AllGapSchemas_1.AllGapSchemas();
210
- return attestations.map((attestation) => {
211
- const project = new Project({
212
- ...attestation,
213
- data: {
214
- project: true,
215
- },
216
- schema: allSchemas.findSchema("Project", consts_1.chainIdToNetwork[attestation.chainID]),
217
- chainID: attestation.chainID,
218
- });
219
- if (attestation.details) {
220
- const { details } = attestation;
221
- project.details = new attestations_1.ProjectDetails({
222
- ...details,
223
- data: {
224
- ...details.data,
225
- },
226
- schema: allSchemas.findSchema("ProjectDetails", consts_1.chainIdToNetwork[attestation.chainID]),
227
- chainID: attestation.chainID,
228
- });
229
- project.details.links = details.data.links || [];
230
- project.details.tags = details.data.tags || [];
231
- if (attestation.data.links) {
232
- project.details.links = attestation.data.links;
233
- }
234
- if (attestation.data.tags) {
235
- project.details.tags = attestation.tags;
236
- }
237
- }
238
- if (attestation.members) {
239
- project.members = attestation.members.map((m) => {
240
- const member = new MemberOf_1.MemberOf({
241
- ...m,
242
- data: {
243
- memberOf: true,
244
- },
245
- schema: allSchemas.findSchema("MemberOf", consts_1.chainIdToNetwork[attestation.chainID]),
246
- chainID: attestation.chainID,
247
- });
248
- if (m.details) {
249
- const { details } = m;
250
- member.details = new attestations_1.MemberDetails({
251
- ...details,
252
- data: {
253
- ...details.data,
254
- },
255
- schema: allSchemas.findSchema("MemberDetails", consts_1.chainIdToNetwork[attestation.chainID]),
256
- chainID: attestation.chainID,
257
- });
258
- }
259
- return member;
260
- });
261
- }
262
- if (attestation.grants) {
263
- project.grants = Grant_1.Grant.from(attestation.grants, network);
264
- }
265
- if (attestation.impacts) {
266
- project.impacts = ProjectImpact_1.ProjectImpact.from(attestation.impacts, network);
267
- }
268
- if (attestation.pointers) {
269
- project.pointers = ProjectPointer_1.ProjectPointer.from(attestation.pointers, network);
270
- }
271
- if (attestation.updates) {
272
- project.updates = ProjectUpdate_1.ProjectUpdate.from(attestation.updates, network);
273
- }
274
- if (attestation.milestones) {
275
- project.milestones = ProjectMilestone_1.ProjectMilestone.from(attestation.milestones, network);
276
- }
277
- if (attestation.endorsements) {
278
- project.endorsements = attestation.endorsements.map((pi) => {
279
- const endorsement = new attestations_1.ProjectEndorsement({
280
- ...pi,
281
- data: {
282
- ...pi.data,
283
- },
284
- schema: allSchemas.findSchema("ProjectDetails", consts_1.chainIdToNetwork[attestation.chainID]),
285
- chainID: attestation.chainID,
286
- });
287
- return endorsement;
288
- });
289
- }
290
- return project;
291
- });
292
- }
293
- async attestUpdate(signer, data, callback) {
294
- const projectUpdate = new ProjectUpdate_1.ProjectUpdate({
295
- data: {
296
- ...data,
297
- type: "project-update",
298
- },
299
- recipient: this.recipient,
300
- refUID: this.uid,
301
- schema: this.schema.gap.findSchema("ProjectUpdate"),
302
- });
303
- await projectUpdate.attest(signer, callback);
304
- this.updates.push(projectUpdate);
305
- }
306
- async attestMilestone(signer, data, callback) {
307
- const projectMilestone = new ProjectMilestone_1.ProjectMilestone({
308
- data: {
309
- ...data,
310
- type: "project-milestone",
311
- },
312
- recipient: this.recipient,
313
- refUID: this.uid,
314
- schema: this.schema.gap.findSchema("ProjectMilestone"),
315
- });
316
- await projectMilestone.attest(signer, callback);
317
- this.milestones.push(projectMilestone);
318
- }
319
- async attestPointer(signer, data, callback) {
320
- const projectPointer = new ProjectPointer_1.ProjectPointer({
321
- data: {
322
- ...data,
323
- type: "project-pointer",
324
- },
325
- recipient: this.recipient,
326
- refUID: this.uid,
327
- schema: this.schema.gap.findSchema("ProjectPointer"),
328
- });
329
- await projectPointer.attest(signer, callback);
330
- this.pointers.push(projectPointer);
331
- }
332
- async attestImpact(signer, data, targetChainId, callback) {
333
- if (targetChainId && targetChainId !== this.chainID) {
334
- return this.attestGhostProjectImpact(signer, data, targetChainId, callback);
335
- }
336
- const projectImpact = new ProjectImpact_1.ProjectImpact({
337
- data: {
338
- ...data,
339
- type: "project-impact",
340
- },
341
- recipient: this.recipient,
342
- refUID: this.uid,
343
- schema: this.schema.gap.findSchema("ProjectDetails"),
344
- });
345
- const { tx, uids } = await projectImpact.attest(signer, callback);
346
- this.impacts.push(projectImpact);
347
- return { tx, uids };
348
- }
349
- async attestGhostProjectImpact(signer, data, targetChainId, callback) {
350
- const { tx, uids } = await this.attestGhostProject(signer, targetChainId);
351
- const ghostProjectUid = uids[0];
352
- const allGapSchemas = new AllGapSchemas_1.AllGapSchemas();
353
- const projectImpact = new ProjectImpact_1.ProjectImpact({
354
- data: {
355
- ...data,
356
- type: "project-impact",
357
- },
358
- recipient: this.recipient,
359
- refUID: ghostProjectUid,
360
- schema: allGapSchemas.findSchema("ProjectDetails", consts_1.chainIdToNetwork[targetChainId]),
361
- chainID: targetChainId,
362
- });
363
- const impactAttestation = await projectImpact.attest(signer, callback);
364
- this.impacts.push(projectImpact);
365
- return {
366
- tx: impactAttestation.tx,
367
- uids: [...uids, impactAttestation.uids[0]],
368
- };
369
- }
370
- async attestEndorsement(signer, data) {
371
- const projectEndorsement = new attestations_1.ProjectEndorsement({
372
- data: {
373
- ...data,
374
- type: "project-endorsement",
375
- },
376
- recipient: this.recipient,
377
- refUID: this.uid,
378
- schema: this.schema.gap.findSchema("ProjectDetails"),
379
- });
380
- await projectEndorsement.attest(signer);
381
- this.endorsements.push(projectEndorsement);
382
- }
383
- async attestGhostProject(signer, targetChainId) {
384
- const allGapSchemas = new AllGapSchemas_1.AllGapSchemas();
385
- const project = new Project({
386
- data: { project: true },
387
- schema: allGapSchemas.findSchema("Project", consts_1.chainIdToNetwork[targetChainId]),
388
- recipient: this.recipient,
389
- chainID: targetChainId,
390
- });
391
- project.details = new Attestation_1.Attestation({
392
- data: {
393
- originalProjectChainId: this.chainID,
394
- uid: this.uid,
395
- },
396
- chainID: targetChainId,
397
- recipient: this.recipient,
398
- schema: allGapSchemas.findSchema("ProjectDetails", consts_1.chainIdToNetwork[targetChainId]),
399
- });
400
- const attestation = await project.attest(signer);
401
- return attestation;
402
- }
403
- async addAdmin(signer, newAdmin, callback) {
404
- callback?.("preparing");
405
- const tx = await GapContract_1.GapContract.addProjectAdmin(signer, this.uid, newAdmin);
406
- callback?.("confirmed");
407
- const txArray = [tx].flat();
408
- return { tx: txArray, uids: [this.uid] };
409
- }
410
- async removeAdmin(signer, oldAdmin, callback) {
411
- callback?.("preparing");
412
- const tx = await GapContract_1.GapContract.removeProjectAdmin(signer, this.uid, oldAdmin);
413
- callback?.("confirmed");
414
- const txArray = [tx].flat();
415
- return { tx: txArray, uids: [this.uid] };
416
- }
417
- }
418
- exports.Project = Project;
@@ -1,50 +0,0 @@
1
- import { SignerOrProvider, TNetwork } from "../../types";
2
- import { Attestation, AttestationArgs } from "../Attestation";
3
- import { GapSchema } from "../GapSchema";
4
- import { Transaction } from "ethers";
5
- export interface _IProjectImpact extends ProjectImpact {
6
- }
7
- type IStatus = "verified";
8
- export interface IProjectImpactStatus {
9
- type?: `project-impact-${IStatus}`;
10
- reason?: string;
11
- }
12
- export declare class ProjectImpactStatus extends Attestation<IProjectImpactStatus> implements IProjectImpactStatus {
13
- type: `project-impact-${IStatus}`;
14
- reason?: string;
15
- }
16
- export interface IProjectImpact {
17
- work: string;
18
- impact: string;
19
- proof: string;
20
- startedAt?: number;
21
- completedAt: number;
22
- type?: string;
23
- verified?: ProjectImpactStatus[];
24
- }
25
- export declare class ProjectImpact extends Attestation<IProjectImpact> implements IProjectImpact {
26
- work: string;
27
- impact: string;
28
- proof: string;
29
- startedAt?: number;
30
- completedAt: number;
31
- type?: string;
32
- verified: ProjectImpactStatus[];
33
- constructor(data: AttestationArgs<IProjectImpact, GapSchema>);
34
- /**
35
- * Attest Project Impact.
36
- */
37
- private attestStatus;
38
- /**
39
- * Verify this ProjectImpact. If the ProjectImpact is not already verified,
40
- * it will throw an error.
41
- * @param signer
42
- * @param reason
43
- */
44
- verify(signer: SignerOrProvider, data?: IProjectImpactStatus, callback?: Function): Promise<{
45
- tx: Transaction[];
46
- uids: `0x${string}`[];
47
- }>;
48
- static from(attestations: ProjectImpact[], network: TNetwork): ProjectImpact[];
49
- }
50
- export {};
@@ -1,112 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ProjectImpact = exports.ProjectImpactStatus = 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("../../consts");
8
- class ProjectImpactStatus extends Attestation_1.Attestation {
9
- }
10
- exports.ProjectImpactStatus = ProjectImpactStatus;
11
- class ProjectImpact extends Attestation_1.Attestation {
12
- constructor(data) {
13
- data.data.type = "project-impact";
14
- super(data);
15
- this.verified = [];
16
- }
17
- /**
18
- * Attest Project Impact.
19
- */
20
- async attestStatus(signer, schema, callback) {
21
- const eas = this.schema.gap.eas.connect(signer);
22
- try {
23
- if (callback)
24
- callback("preparing");
25
- const tx = await eas.attest({
26
- schema: schema.uid,
27
- data: {
28
- recipient: this.recipient,
29
- data: schema.encode(),
30
- refUID: this.uid,
31
- expirationTime: 0n,
32
- revocable: schema.revocable,
33
- },
34
- });
35
- if (callback)
36
- callback("pending");
37
- const uid = await tx.wait();
38
- if (callback)
39
- callback("confirmed");
40
- console.log(uid);
41
- return {
42
- tx: [
43
- {
44
- hash: tx.tx.hash,
45
- },
46
- ],
47
- uids: [uid],
48
- };
49
- }
50
- catch (error) {
51
- console.error(error);
52
- throw new SchemaError_1.AttestationError("ATTEST_ERROR", error.message, error);
53
- }
54
- }
55
- /**
56
- * Verify this ProjectImpact. If the ProjectImpact is not already verified,
57
- * it will throw an error.
58
- * @param signer
59
- * @param reason
60
- */
61
- async verify(signer, data, callback) {
62
- console.log("Verifying ProjectImpact");
63
- const schema = this.schema.gap.findSchema("GrantUpdateStatus");
64
- if (this.schema.isJsonSchema()) {
65
- schema.setValue("json", JSON.stringify({
66
- type: "project-impact-verified",
67
- reason: data?.reason || '',
68
- }));
69
- }
70
- else {
71
- schema.setValue("type", "project-impact-verified");
72
- schema.setValue("reason", data?.reason || '');
73
- }
74
- console.log("Before attest project impact verified");
75
- const { tx, uids } = await this.attestStatus(signer, schema, callback);
76
- console.log("After attest project impact verified");
77
- this.verified.push(new ProjectImpactStatus({
78
- data: {
79
- type: "project-impact-verified",
80
- reason: data?.reason || '',
81
- },
82
- refUID: this.uid,
83
- schema: schema,
84
- recipient: this.recipient,
85
- }));
86
- return { tx, uids };
87
- }
88
- static from(attestations, network) {
89
- return attestations.map((attestation) => {
90
- const projectImpact = new ProjectImpact({
91
- ...attestation,
92
- data: {
93
- ...attestation.data,
94
- },
95
- schema: new AllGapSchemas_1.AllGapSchemas().findSchema("ProjectImpact", consts_1.chainIdToNetwork[attestation.chainID]),
96
- chainID: attestation.chainID,
97
- });
98
- if (attestation.verified?.length > 0) {
99
- projectImpact.verified = attestation.verified.map((m) => new ProjectImpactStatus({
100
- ...m,
101
- data: {
102
- ...m.data,
103
- },
104
- schema: new AllGapSchemas_1.AllGapSchemas().findSchema("GrantUpdateStatus", consts_1.chainIdToNetwork[attestation.chainID]),
105
- chainID: attestation.chainID,
106
- }));
107
- }
108
- return projectImpact;
109
- });
110
- }
111
- }
112
- exports.ProjectImpact = ProjectImpact;