@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
@@ -0,0 +1,313 @@
1
+ import { IGrantUpdateBase } from "core/shared/types";
2
+
3
+ export type Hex = `0x${string}`;
4
+ export type JSONStr = string;
5
+ export type ExternalLink = { type: string; url: string };
6
+ export type ExternalCustomLink = {
7
+ type: 'custom';
8
+ url: string;
9
+ name: string
10
+ };
11
+ export interface ITag {
12
+ name: string;
13
+ }
14
+
15
+ export interface IAttestationResponse {
16
+ id: string;
17
+ uid: Hex;
18
+ schemaUID: Hex;
19
+ refUID: Hex;
20
+ attester: Hex;
21
+ recipient: Hex;
22
+ revoked: boolean;
23
+ revocationTime?: number;
24
+ createdAt: any;
25
+ updatedAt: any;
26
+ chainID: number;
27
+ type: string;
28
+ data: any;
29
+ decodedDataJson: JSONStr;
30
+ isOffchain: any;
31
+ revocable: any;
32
+ schemaId: Hex;
33
+ }
34
+
35
+ export interface ISummaryProject {
36
+ title: string;
37
+ slug?: string;
38
+ uid: Hex;
39
+ }
40
+
41
+ export interface IMilestoneCompleted extends IAttestationResponse {
42
+ type: "MilestoneStatus";
43
+ data: {
44
+ type: "approved" | "rejected" | "completed";
45
+ reason?: string;
46
+ proofOfWork?: string;
47
+ };
48
+ }
49
+
50
+ export interface IMilestoneResponse extends IAttestationResponse {
51
+ type: "Milestone";
52
+ completed?: IMilestoneCompleted;
53
+ approved?: IMilestoneCompleted;
54
+ rejected?: IMilestoneCompleted;
55
+ verified?: IMilestoneCompleted[];
56
+ data: {
57
+ title: string;
58
+ description: string;
59
+ endsAt: number;
60
+ startsAt?: number;
61
+ type: "milestone";
62
+ priority?: number;
63
+ };
64
+ }
65
+
66
+ export interface IGrantUpdateStatus extends IAttestationResponse {
67
+ type: `grant-update-${IStatus}`;
68
+ reason?: string;
69
+ data: {
70
+ type: "approved" | "rejected" | "completed";
71
+ reason?: string;
72
+ pitchDeck?: string;
73
+ demoVideo?: string;
74
+ trackExplanations?: Array<{
75
+ trackId: string;
76
+ trackName: string;
77
+ explanation: string;
78
+ }>;
79
+ };
80
+ }
81
+ export interface IGrantUpdate extends IAttestationResponse {
82
+ data: IGrantUpdateBase & {
83
+ type: "grant-update";
84
+ };
85
+ verified?: IGrantUpdateStatus[];
86
+ }
87
+
88
+ export interface IProjectUpdateStatus extends IAttestationResponse {
89
+ type: `project-update-${IStatus}`;
90
+ reason?: string;
91
+ data: {
92
+ type: "approved" | "rejected" | "completed";
93
+ reason?: string;
94
+ };
95
+ }
96
+ export interface IProjectUpdate extends IAttestationResponse {
97
+ data: {
98
+ title: string;
99
+ text: string;
100
+ startDate?: Date;
101
+ endDate?: Date;
102
+ grants?: string[];
103
+ indicators?: {
104
+ name: string;
105
+ indicatorId: string;
106
+ }[];
107
+ deliverables?: {
108
+ name: string;
109
+ proof: string;
110
+ description: string;
111
+ }[];
112
+ type: "project-update";
113
+ };
114
+ verified?: IProjectUpdateStatus[];
115
+ }
116
+
117
+ export interface IProjectMilestoneStatus extends IAttestationResponse {
118
+ type: `project-milestone-verified`;
119
+ reason?: string;
120
+ data: {
121
+ type: "approved" | "rejected" | "completed";
122
+ reason?: string;
123
+ };
124
+ }
125
+
126
+ export interface IProjectMilestoneResponse extends IAttestationResponse {
127
+ data: {
128
+ text: string;
129
+ title: string;
130
+ type: "project-milestone";
131
+ };
132
+ verified?: IProjectMilestoneStatus[];
133
+ completed?: IMilestoneCompleted;
134
+ }
135
+
136
+ export interface IProjectPointer extends IAttestationResponse {
137
+ data: {
138
+ ogProjectUID: string;
139
+ type: "project-pointer";
140
+ };
141
+ }
142
+
143
+ export interface IGrantDetails extends IAttestationResponse {
144
+ type: "GrantDetails";
145
+ data: {
146
+ title: string;
147
+ amount: string;
148
+ description: string;
149
+ proposalURL: string;
150
+ assetAndChainId?: [Hex, number];
151
+ payoutAddress: Hex;
152
+ questions: { type: string; query: string; explanation: string }[];
153
+ startDate: number;
154
+ programId?: string;
155
+ type: "grant-details";
156
+ fundUsage?: string;
157
+ selectedTrackIds?: string[];
158
+ };
159
+ }
160
+
161
+ export interface IGrantResponse extends IAttestationResponse {
162
+ type: "Grant";
163
+ data: { communityUID: Hex };
164
+ details?: IGrantDetails;
165
+ milestones: IMilestoneResponse[];
166
+ completed?: IGrantUpdate;
167
+ project: IProjectResponse;
168
+ updates: IGrantUpdate[];
169
+ community: ICommunityResponse;
170
+ members: Hex[];
171
+ categories?: string[];
172
+ externalAddresses?: {
173
+ [key: string]: string;
174
+ };
175
+ external?: {
176
+ [key: string]: string[];
177
+ };
178
+ amount?: Hex;
179
+ }
180
+
181
+ export interface IMemberDetails extends IAttestationResponse {
182
+ name: string;
183
+ profilePictureURL: string;
184
+ }
185
+
186
+ export interface IMemberOf extends IAttestationResponse {
187
+ type: "MemberOf";
188
+ data: { memberOf: true };
189
+ details?: IMemberDetails;
190
+ }
191
+
192
+ export interface IProjectDetails extends IAttestationResponse {
193
+ type: "ProjectDetails";
194
+ data: {
195
+ title: string;
196
+ description: string;
197
+ problem?: string;
198
+ solution?: string;
199
+ missionSummary?: string;
200
+ locationOfImpact?: string;
201
+ imageURL: string;
202
+ links?: Array<ExternalLink | ExternalCustomLink>;
203
+ tags?: ITag[];
204
+ slug?: string;
205
+ type: "project-details";
206
+ businessModel?: string;
207
+ stageIn?: string;
208
+ raisedMoney?: string;
209
+ pathToTake?: string;
210
+ };
211
+ }
212
+
213
+ type IStatus = "verified";
214
+ export interface IProjectImpactStatus extends IAttestationResponse {
215
+ type: `project-impact-${IStatus}`;
216
+ reason?: string;
217
+ }
218
+ export interface IProjectImpact extends IAttestationResponse {
219
+ type: "ProjectImpact";
220
+ data: {
221
+ work: string;
222
+ impact: string;
223
+ proof: string;
224
+ startedAt?: number;
225
+ completedAt: number;
226
+ type: "project-impact";
227
+ };
228
+ verified: IProjectImpactStatus[];
229
+ }
230
+ export interface IProjectEndorsement extends IAttestationResponse {
231
+ type: "ProjectEndorsement";
232
+ data: {
233
+ comment?: string;
234
+ type?: "project-endorsement";
235
+ };
236
+ }
237
+
238
+ export interface IProjectResponse extends IAttestationResponse {
239
+ type: "Project";
240
+ data: { project: true };
241
+ details?: IProjectDetails;
242
+ members: IMemberOf[];
243
+ grants: IGrantResponse[];
244
+ grantee: any;
245
+ impacts: IProjectImpact[];
246
+ updates: IProjectUpdate[];
247
+ pointers: IProjectPointer[];
248
+ symlinks: Hex[];
249
+ endorsements: IProjectEndorsement[];
250
+ milestones: IProjectMilestoneResponse[];
251
+ payoutAddress?: Hex;
252
+ }
253
+
254
+ export interface ICommunityDetails extends IAttestationResponse {
255
+ type: "CommunityDetails";
256
+ data: {
257
+ name: string;
258
+ description: string;
259
+ imageURL: string;
260
+ links: ExternalLink[];
261
+ slug?: string;
262
+ };
263
+ }
264
+
265
+ export interface ICommunityResponse extends IAttestationResponse {
266
+ type: "Community";
267
+ data: { community: true };
268
+ details?: ICommunityDetails;
269
+ grants: IGrantResponse[];
270
+ }
271
+
272
+ export interface ICommunityAdminsResponse {
273
+ id: string;
274
+ admins: { user: { id: string } }[];
275
+ }
276
+
277
+ export interface ISearchResponse {
278
+ projects: IProjectResponse[];
279
+ communities: ICommunityResponse[];
280
+ }
281
+
282
+ export interface ITrackResponse {
283
+ id: string;
284
+ name: string;
285
+ description?: string;
286
+ communityUID: string;
287
+ isArchived: boolean;
288
+ createdAt: string;
289
+ updatedAt: string;
290
+ programId?: string;
291
+ isActive?: boolean;
292
+ chainID?: number;
293
+ }
294
+
295
+ export interface ITrackAssignmentResponse {
296
+ id: string;
297
+ programId: string;
298
+ chainID: number;
299
+ trackId: string;
300
+ track: ITrackResponse;
301
+ }
302
+
303
+ export interface IProjectTrackResponse {
304
+ projectUID: string;
305
+ chainID: number;
306
+ programId: string;
307
+ track: ITrackResponse;
308
+ project: {
309
+ uid: string;
310
+ chainID: number;
311
+ details: any;
312
+ };
313
+ }
@@ -0,0 +1,76 @@
1
+ import { RemoteStorage } from "./RemoteStorage";
2
+ import { RemoteStorageError } from "../SchemaError";
3
+ import { getIPFSData } from "../../utils";
4
+ import { STORAGE_TYPE, TRemoteStorageOutput } from "core/types";
5
+ import axios from "axios";
6
+
7
+ export interface IpfsStorageOptions {
8
+ token: string;
9
+ }
10
+
11
+ export class IpfsStorage extends RemoteStorage {
12
+ private pinataJWTToken: string;
13
+
14
+ constructor(
15
+ opts: IpfsStorageOptions,
16
+ /**
17
+ * If set, will send request to another server instead of
18
+ * using the local instance
19
+ */
20
+ sponsor?: RemoteStorage["sponsor"]
21
+ ) {
22
+ super(STORAGE_TYPE.IPFS, sponsor);
23
+
24
+ this.assert(opts);
25
+ this.pinataJWTToken = opts.token;
26
+ }
27
+
28
+ private assert(opts: IpfsStorageOptions) {}
29
+
30
+ async save<T = unknown>(data: T): Promise<string> {
31
+ try {
32
+ const cid = await this.saveAndGetCID(data);
33
+ return cid;
34
+ } catch (error) {
35
+ throw new RemoteStorageError(
36
+ "REMOTE_STORAGE_UPLOAD",
37
+ `Error adding data to IPFS`
38
+ );
39
+ }
40
+ }
41
+
42
+ encode(data: string): TRemoteStorageOutput<string> {
43
+ return { hash: data, storageType: this.storageType };
44
+ }
45
+
46
+ async get<T = unknown>(args: { cid: string }): Promise<T> {
47
+ return getIPFSData<T>(args.cid);
48
+ }
49
+
50
+ async saveAndGetCID(
51
+ data: any,
52
+ pinataMetadata = { name: "via karma-gap-sdk" }
53
+ ) {
54
+ try {
55
+ const res = await axios.post(
56
+ "https://api.pinata.cloud/pinning/pinJSONToIPFS",
57
+ {
58
+ pinataContent: data,
59
+ pinataMetadata: pinataMetadata,
60
+ },
61
+ {
62
+ headers: {
63
+ "Content-Type": "application/json",
64
+ Authorization: `Bearer ${this.pinataJWTToken}`,
65
+ },
66
+ }
67
+ );
68
+ return res.data.IpfsHash;
69
+ } catch (error) {
70
+ throw new RemoteStorageError(
71
+ "REMOTE_STORAGE_UPLOAD",
72
+ `Error adding data to IPFS`
73
+ );
74
+ }
75
+ }
76
+ }
@@ -0,0 +1,65 @@
1
+ import axios from 'axios';
2
+ import { STORAGE_TYPE, TRemoteStorageOutput, TSchemaName } from 'core/types';
3
+
4
+ interface SponsoredRemote {
5
+ url: string;
6
+ responseParser: (response: any) => string;
7
+ }
8
+
9
+ export abstract class RemoteStorage<C = unknown> {
10
+ protected client: C;
11
+ readonly storageType: number;
12
+
13
+ readonly sponsor?: SponsoredRemote;
14
+
15
+ constructor(
16
+ storageType: STORAGE_TYPE,
17
+ /**
18
+ * If set, will try to POST request to another server instead of
19
+ * using the local instance.
20
+ *
21
+ * > If a response parser is not set, it will try to get { cid: string }.
22
+ */
23
+ sponsor: SponsoredRemote
24
+ ) {
25
+ this.storageType = storageType;
26
+ this.sponsor = sponsor;
27
+ this.interceptRemoteStorage();
28
+ }
29
+
30
+ /**
31
+ * Try to save data to remote storage and return the CID.
32
+ * IF sponsorUrl is set, this method will be automatically
33
+ * intercepted and will send a POST request to the sponsorUrl
34
+ * with the contents: `{ data: T, type: "<AttestationType>" }`
35
+ */
36
+ abstract save<T = unknown>(data: T, schemaName: string): Promise<string>;
37
+
38
+ /**
39
+ * Encodes the data according to the remote storage type parameters
40
+ * OR returns the data as is if no encoding is required
41
+ */
42
+ abstract encode(data: unknown): TRemoteStorageOutput;
43
+
44
+ /**
45
+ * Get data from Remote Storage
46
+ */
47
+ abstract get<T = unknown>(args: unknown): Promise<T>;
48
+
49
+ /**
50
+ * If sponsorUrl is set, intercept the save method and send a POST request
51
+ * to the sponsorUrl instead of using the local instance.
52
+ * @returns
53
+ */
54
+ private interceptRemoteStorage() {
55
+ if (!this.sponsor?.url) return;
56
+ this.save = async (data: unknown, schemaName: TSchemaName) => {
57
+ const { data: response } = await axios.post(this.sponsor.url, {
58
+ data: data,
59
+ type: schemaName,
60
+ });
61
+
62
+ return this.sponsor.responseParser?.(response) || response.cid;
63
+ };
64
+ }
65
+ }
@@ -0,0 +1,93 @@
1
+ export type RoundMetadata = {
2
+ name: string;
3
+ support: {
4
+ info: string;
5
+ type: string;
6
+ };
7
+ roundType: "public" | string; // Could be extended to include other round types
8
+ eligibility: {
9
+ description: string;
10
+ requirements: Array<{
11
+ requirement: string;
12
+ }>;
13
+ };
14
+ feesAddress: string;
15
+ feesPercentage: number;
16
+ programContractAddress: string;
17
+ quadraticFundingConfig?: {
18
+ matchingCap: boolean;
19
+ sybilDefense: boolean;
20
+ matchingCapAmount: number;
21
+ minDonationThreshold: boolean;
22
+ matchingFundsAvailable: number;
23
+ minDonationThresholdAmount: number;
24
+ };
25
+ category: string;
26
+ source: string;
27
+ };
28
+
29
+ export type Address = `0x${string}`;
30
+
31
+ export type GrantArgs = {
32
+ profileId: Address;
33
+ roundMetadata: RoundMetadata;
34
+ applicationStart: number;
35
+ applicationEnd: number;
36
+ roundStart: number;
37
+ roundEnd: number;
38
+ // Use available payout tokens from this file:
39
+ // https://github.dev/gitcoinco/grants-stack-indexer/blob/main/src/database/schema.ts
40
+ matchingFundAmt: number;
41
+ applicationMetadata: ApplicationMetadata;
42
+ managers: Address[];
43
+ strategy: Address;
44
+ payoutToken: Address;
45
+ };
46
+
47
+ export type ApplicationMetadata = {
48
+ version: string;
49
+ lastUpdatedOn: number;
50
+ applicationSchema: {
51
+ questions: Array<{
52
+ id: number;
53
+ info: string;
54
+ type:
55
+ | "email"
56
+ | "short-answer"
57
+ | "link"
58
+ | "number"
59
+ | "paragraph"
60
+ | "address"
61
+ | "checkbox"
62
+ | "multiple-choice";
63
+ title: string;
64
+ hidden: boolean;
65
+ choices?: string[];
66
+ required: boolean;
67
+ encrypted: boolean;
68
+ }>;
69
+ requirements: {
70
+ github: {
71
+ required: boolean;
72
+ verification: boolean;
73
+ };
74
+ twitter: {
75
+ required: boolean;
76
+ verification: boolean;
77
+ };
78
+ // Potentially add more requirements here if they exist in the data
79
+ };
80
+ };
81
+ };
82
+
83
+ export type ProfileMetadata = {
84
+ title: string;
85
+ description: string;
86
+ website: string;
87
+ projectTwitter: string;
88
+ logoImg: string; // Assuming it's a URL to the logo image
89
+ bannerImg: string; // Assuming it's a URL to the banner image
90
+ logoImgData: any; // Could be object with image data or left as type 'any' if not used
91
+ bannerImgData: any; // Could be object with image data or left as type 'any' if not used
92
+ createdAt: number; // Timestamp in milliseconds
93
+ };