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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (188) hide show
  1. package/core/abi/AirdropNFT.json +1 -1
  2. package/core/abi/Allo.json +860 -860
  3. package/core/abi/AlloRegistry.json +578 -578
  4. package/core/abi/CommunityResolverABI.json +506 -506
  5. package/core/abi/Donations.json +251 -251
  6. package/core/abi/EAS.json +1 -1
  7. package/core/abi/MultiAttester.json +746 -746
  8. package/core/abi/ProjectResolver.json +574 -574
  9. package/core/abi/SchemaRegistry.json +1 -1
  10. package/core/abi/index.d.ts +1114 -0
  11. package/core/abi/index.js +26 -0
  12. package/core/class/AllGapSchemas.d.ts +9 -0
  13. package/core/class/AllGapSchemas.js +19 -0
  14. package/core/class/Attestation.d.ts +173 -0
  15. package/core/class/Attestation.js +333 -0
  16. package/core/class/Fetcher.d.ts +175 -0
  17. package/core/class/Fetcher.js +13 -0
  18. package/core/class/GAP.d.ts +254 -0
  19. package/core/class/GAP.js +289 -0
  20. package/core/class/GapSchema.d.ts +34 -0
  21. package/core/class/GapSchema.js +62 -0
  22. package/core/class/Gelato/{Gelato.ts → Gelato.js} +0 -23
  23. package/core/class/GrantProgramRegistry/Allo.d.ts +17 -0
  24. package/core/class/GrantProgramRegistry/Allo.js +137 -0
  25. package/core/class/GrantProgramRegistry/AlloRegistry.d.ts +15 -0
  26. package/core/class/GrantProgramRegistry/AlloRegistry.js +70 -0
  27. package/core/class/GraphQL/AxiosGQL.d.ts +6 -0
  28. package/core/class/GraphQL/AxiosGQL.js +25 -0
  29. package/core/class/GraphQL/EASClient.d.ts +16 -0
  30. package/core/class/GraphQL/EASClient.js +26 -0
  31. package/core/class/GraphQL/GapEasClient.d.ts +71 -0
  32. package/core/class/GraphQL/GapEasClient.js +451 -0
  33. package/core/class/GraphQL/index.js +19 -0
  34. package/core/class/Schema.d.ts +233 -0
  35. package/core/class/Schema.js +490 -0
  36. package/core/class/SchemaError.d.ts +30 -0
  37. package/core/class/SchemaError.js +39 -0
  38. package/core/class/contract/GapContract.d.ts +102 -0
  39. package/core/class/contract/GapContract.js +285 -0
  40. package/core/class/entities/Community.d.ts +34 -0
  41. package/core/class/entities/Community.js +109 -0
  42. package/core/class/entities/ContributorProfile.d.ts +41 -0
  43. package/core/class/entities/ContributorProfile.js +69 -0
  44. package/core/class/entities/Grant.d.ts +54 -0
  45. package/core/class/entities/Grant.js +223 -0
  46. package/core/class/entities/GrantUpdate.d.ts +62 -0
  47. package/core/class/entities/GrantUpdate.js +114 -0
  48. package/core/class/entities/MemberOf.d.ts +11 -0
  49. package/core/class/entities/MemberOf.js +33 -0
  50. package/core/class/entities/Milestone.d.ts +168 -0
  51. package/core/class/entities/Milestone.js +657 -0
  52. package/core/class/entities/Project.d.ts +92 -0
  53. package/core/class/entities/Project.js +418 -0
  54. package/core/class/entities/ProjectImpact.d.ts +50 -0
  55. package/core/class/entities/ProjectImpact.js +112 -0
  56. package/core/class/entities/ProjectMilestone.d.ts +60 -0
  57. package/core/class/entities/ProjectMilestone.js +174 -0
  58. package/core/class/entities/ProjectPointer.d.ts +12 -0
  59. package/core/class/entities/ProjectPointer.js +22 -0
  60. package/core/class/entities/ProjectUpdate.d.ts +50 -0
  61. package/core/class/entities/ProjectUpdate.js +110 -0
  62. package/core/class/entities/Track.d.ts +16 -0
  63. package/core/class/entities/Track.js +21 -0
  64. package/core/class/entities/index.js +26 -0
  65. package/core/class/index.js +26 -0
  66. package/core/class/karma-indexer/GapIndexerClient.d.ts +66 -0
  67. package/core/class/karma-indexer/GapIndexerClient.js +207 -0
  68. package/core/class/karma-indexer/api/GapIndexerApi.d.ts +73 -0
  69. package/core/class/karma-indexer/api/GapIndexerApi.js +256 -0
  70. package/core/class/karma-indexer/api/types.d.ts +309 -0
  71. package/core/class/karma-indexer/api/types.js +2 -0
  72. package/core/class/remote-storage/IpfsStorage.d.ts +23 -0
  73. package/core/class/remote-storage/IpfsStorage.js +56 -0
  74. package/core/class/remote-storage/RemoteStorage.d.ts +41 -0
  75. package/core/class/remote-storage/RemoteStorage.js +38 -0
  76. package/core/class/types/allo.d.ts +78 -0
  77. package/core/class/types/allo.js +2 -0
  78. package/core/class/types/attestations.d.ts +173 -0
  79. package/core/class/types/attestations.js +66 -0
  80. package/core/consts.d.ts +50 -0
  81. package/core/consts.js +699 -0
  82. package/core/index.js +24 -0
  83. package/core/shared/types.d.ts +13 -0
  84. package/core/shared/types.js +2 -0
  85. package/core/types.d.ts +131 -0
  86. package/core/types.js +13 -0
  87. package/core/utils/gelato/index.js +19 -0
  88. package/core/utils/gelato/send-gelato-txn.d.ts +55 -0
  89. package/core/utils/gelato/send-gelato-txn.js +100 -0
  90. package/core/utils/gelato/sponsor-handler.d.ts +9 -0
  91. package/core/utils/gelato/sponsor-handler.js +60 -0
  92. package/core/utils/gelato/watch-gelato-txn.d.ts +7 -0
  93. package/core/utils/gelato/watch-gelato-txn.js +63 -0
  94. package/core/utils/get-date.d.ts +1 -0
  95. package/core/utils/get-date.js +7 -0
  96. package/core/utils/get-ipfs-data.d.ts +1 -0
  97. package/core/utils/get-ipfs-data.js +20 -0
  98. package/core/utils/get-web3-provider.d.ts +2 -0
  99. package/core/utils/get-web3-provider.js +18 -0
  100. package/core/utils/gql-queries.d.ts +12 -0
  101. package/core/utils/gql-queries.js +90 -0
  102. package/core/utils/index.js +23 -0
  103. package/core/utils/map-filter.d.ts +8 -0
  104. package/core/utils/map-filter.js +20 -0
  105. package/core/utils/serialize-bigint.d.ts +1 -0
  106. package/core/utils/serialize-bigint.js +8 -0
  107. package/core/utils/to-unix.d.ts +1 -0
  108. package/core/utils/to-unix.js +25 -0
  109. package/index.js +17 -0
  110. package/package.json +45 -45
  111. package/.cursorrules +0 -43
  112. package/core/abi/index.ts +0 -21
  113. package/core/class/AllGapSchemas.ts +0 -21
  114. package/core/class/Attestation.ts +0 -429
  115. package/core/class/Fetcher.ts +0 -224
  116. package/core/class/GAP.ts +0 -481
  117. package/core/class/GapSchema.ts +0 -93
  118. package/core/class/GrantProgramRegistry/Allo.ts +0 -188
  119. package/core/class/GrantProgramRegistry/AlloRegistry.ts +0 -101
  120. package/core/class/GraphQL/AxiosGQL.ts +0 -29
  121. package/core/class/GraphQL/EASClient.ts +0 -34
  122. package/core/class/GraphQL/GapEasClient.ts +0 -869
  123. package/core/class/Schema.ts +0 -659
  124. package/core/class/SchemaError.ts +0 -42
  125. package/core/class/contract/GapContract.ts +0 -457
  126. package/core/class/entities/Community.ts +0 -148
  127. package/core/class/entities/ContributorProfile.ts +0 -108
  128. package/core/class/entities/Grant.ts +0 -321
  129. package/core/class/entities/GrantUpdate.ts +0 -187
  130. package/core/class/entities/MemberOf.ts +0 -52
  131. package/core/class/entities/Milestone.ts +0 -898
  132. package/core/class/entities/Project.ts +0 -672
  133. package/core/class/entities/ProjectImpact.ts +0 -170
  134. package/core/class/entities/ProjectMilestone.ts +0 -254
  135. package/core/class/entities/ProjectPointer.ts +0 -39
  136. package/core/class/entities/ProjectUpdate.ts +0 -176
  137. package/core/class/entities/Track.ts +0 -32
  138. package/core/class/karma-indexer/GapIndexerClient.ts +0 -383
  139. package/core/class/karma-indexer/api/GapIndexerApi.ts +0 -446
  140. package/core/class/karma-indexer/api/types.ts +0 -313
  141. package/core/class/remote-storage/IpfsStorage.ts +0 -76
  142. package/core/class/remote-storage/RemoteStorage.ts +0 -65
  143. package/core/class/types/allo.ts +0 -93
  144. package/core/class/types/attestations.ts +0 -223
  145. package/core/consts.ts +0 -775
  146. package/core/scripts/create-grant.ts +0 -102
  147. package/core/scripts/create-program.ts +0 -43
  148. package/core/scripts/create-schemas.ts +0 -65
  149. package/core/scripts/deploy.ts +0 -65
  150. package/core/scripts/index.ts +0 -1
  151. package/core/scripts/milestone-multi-grants.ts +0 -125
  152. package/core/shared/types.ts +0 -13
  153. package/core/types.ts +0 -224
  154. package/core/utils/gelato/send-gelato-txn.ts +0 -114
  155. package/core/utils/gelato/sponsor-handler.ts +0 -77
  156. package/core/utils/gelato/watch-gelato-txn.ts +0 -67
  157. package/core/utils/get-date.ts +0 -3
  158. package/core/utils/get-ipfs-data.ts +0 -13
  159. package/core/utils/get-web3-provider.ts +0 -18
  160. package/core/utils/gql-queries.ts +0 -133
  161. package/core/utils/map-filter.ts +0 -21
  162. package/core/utils/serialize-bigint.ts +0 -7
  163. package/core/utils/to-unix.ts +0 -18
  164. package/create-community-example.ts +0 -119
  165. package/csv-upload/README.md +0 -74
  166. package/csv-upload/config.ts +0 -41
  167. package/csv-upload/example.csv +0 -2
  168. package/csv-upload/keys.example.json +0 -8
  169. package/csv-upload/scripts/run.ts +0 -417
  170. package/csv-upload/types.ts +0 -39
  171. package/docs/.gitkeep +0 -0
  172. package/docs/images/attestation-architecture.png +0 -0
  173. package/docs/images/dfd-get-projects.png +0 -0
  174. package/gap-schema.yaml +0 -155
  175. package/milestone-workflow-example.ts +0 -353
  176. package/readme.md +0 -872
  177. package/schemas/.gitkeep +0 -0
  178. package/schemas/GAP-schemas-1692135812877.json +0 -33
  179. package/test-file-indexer-api.ts +0 -25
  180. package/tsconfig.json +0 -26
  181. /package/{csv-upload/.gitkeep → core/class/Gelato/Gelato.d.ts} +0 -0
  182. /package/core/class/GraphQL/{index.ts → index.d.ts} +0 -0
  183. /package/core/class/entities/{index.ts → index.d.ts} +0 -0
  184. /package/core/class/{index.ts → index.d.ts} +0 -0
  185. /package/core/{index.ts → index.d.ts} +0 -0
  186. /package/core/utils/gelato/{index.ts → index.d.ts} +0 -0
  187. /package/core/utils/{index.ts → index.d.ts} +0 -0
  188. /package/{index.ts → index.d.ts} +0 -0
@@ -0,0 +1,309 @@
1
+ import { IGrantUpdateBase } from "core/shared/types";
2
+ export type Hex = `0x${string}`;
3
+ export type JSONStr = string;
4
+ export type ExternalLink = {
5
+ type: string;
6
+ url: string;
7
+ };
8
+ export type ExternalCustomLink = {
9
+ type: 'custom';
10
+ url: string;
11
+ name: string;
12
+ };
13
+ export interface ITag {
14
+ name: string;
15
+ }
16
+ export interface IAttestationResponse {
17
+ id: string;
18
+ uid: Hex;
19
+ schemaUID: Hex;
20
+ refUID: Hex;
21
+ attester: Hex;
22
+ recipient: Hex;
23
+ revoked: boolean;
24
+ revocationTime?: number;
25
+ createdAt: any;
26
+ updatedAt: any;
27
+ chainID: number;
28
+ type: string;
29
+ data: any;
30
+ decodedDataJson: JSONStr;
31
+ isOffchain: any;
32
+ revocable: any;
33
+ schemaId: Hex;
34
+ }
35
+ export interface ISummaryProject {
36
+ title: string;
37
+ slug?: string;
38
+ uid: Hex;
39
+ }
40
+ export interface IMilestoneCompleted extends IAttestationResponse {
41
+ type: "MilestoneStatus";
42
+ data: {
43
+ type: "approved" | "rejected" | "completed";
44
+ reason?: string;
45
+ proofOfWork?: string;
46
+ };
47
+ }
48
+ export interface IMilestoneResponse extends IAttestationResponse {
49
+ type: "Milestone";
50
+ completed?: IMilestoneCompleted;
51
+ approved?: IMilestoneCompleted;
52
+ rejected?: IMilestoneCompleted;
53
+ verified?: IMilestoneCompleted[];
54
+ data: {
55
+ title: string;
56
+ description: string;
57
+ endsAt: number;
58
+ startsAt?: number;
59
+ type: "milestone";
60
+ priority?: number;
61
+ };
62
+ }
63
+ export interface IGrantUpdateStatus extends IAttestationResponse {
64
+ type: `grant-update-${IStatus}`;
65
+ reason?: string;
66
+ data: {
67
+ type: "approved" | "rejected" | "completed";
68
+ reason?: string;
69
+ pitchDeck?: string;
70
+ demoVideo?: string;
71
+ trackExplanations?: Array<{
72
+ trackId: string;
73
+ trackName: string;
74
+ explanation: string;
75
+ }>;
76
+ };
77
+ }
78
+ export interface IGrantUpdate extends IAttestationResponse {
79
+ data: IGrantUpdateBase & {
80
+ type: "grant-update";
81
+ };
82
+ verified?: IGrantUpdateStatus[];
83
+ }
84
+ export interface IProjectUpdateStatus extends IAttestationResponse {
85
+ type: `project-update-${IStatus}`;
86
+ reason?: string;
87
+ data: {
88
+ type: "approved" | "rejected" | "completed";
89
+ reason?: string;
90
+ };
91
+ }
92
+ export interface IProjectUpdate extends IAttestationResponse {
93
+ data: {
94
+ title: string;
95
+ text: string;
96
+ startDate?: Date;
97
+ endDate?: Date;
98
+ grants?: string[];
99
+ indicators?: {
100
+ name: string;
101
+ indicatorId: string;
102
+ }[];
103
+ deliverables?: {
104
+ name: string;
105
+ proof: string;
106
+ description: string;
107
+ }[];
108
+ type: "project-update";
109
+ };
110
+ verified?: IProjectUpdateStatus[];
111
+ }
112
+ export interface IProjectMilestoneStatus extends IAttestationResponse {
113
+ type: `project-milestone-verified`;
114
+ reason?: string;
115
+ data: {
116
+ type: "approved" | "rejected" | "completed";
117
+ reason?: string;
118
+ };
119
+ }
120
+ export interface IProjectMilestoneResponse extends IAttestationResponse {
121
+ data: {
122
+ text: string;
123
+ title: string;
124
+ type: "project-milestone";
125
+ };
126
+ verified?: IProjectMilestoneStatus[];
127
+ completed?: IMilestoneCompleted;
128
+ }
129
+ export interface IProjectPointer extends IAttestationResponse {
130
+ data: {
131
+ ogProjectUID: string;
132
+ type: "project-pointer";
133
+ };
134
+ }
135
+ export interface IGrantDetails extends IAttestationResponse {
136
+ type: "GrantDetails";
137
+ data: {
138
+ title: string;
139
+ amount: string;
140
+ description: string;
141
+ proposalURL: string;
142
+ assetAndChainId?: [Hex, number];
143
+ payoutAddress: Hex;
144
+ questions: {
145
+ type: string;
146
+ query: string;
147
+ explanation: string;
148
+ }[];
149
+ startDate: number;
150
+ programId?: string;
151
+ type: "grant-details";
152
+ fundUsage?: string;
153
+ selectedTrackIds?: string[];
154
+ };
155
+ }
156
+ export interface IGrantResponse extends IAttestationResponse {
157
+ type: "Grant";
158
+ data: {
159
+ communityUID: Hex;
160
+ };
161
+ details?: IGrantDetails;
162
+ milestones: IMilestoneResponse[];
163
+ completed?: IGrantUpdate;
164
+ project: IProjectResponse;
165
+ updates: IGrantUpdate[];
166
+ community: ICommunityResponse;
167
+ members: Hex[];
168
+ categories?: string[];
169
+ externalAddresses?: {
170
+ [key: string]: string;
171
+ };
172
+ external?: {
173
+ [key: string]: string[];
174
+ };
175
+ amount?: Hex;
176
+ }
177
+ export interface IMemberDetails extends IAttestationResponse {
178
+ name: string;
179
+ profilePictureURL: string;
180
+ }
181
+ export interface IMemberOf extends IAttestationResponse {
182
+ type: "MemberOf";
183
+ data: {
184
+ memberOf: true;
185
+ };
186
+ details?: IMemberDetails;
187
+ }
188
+ export interface IProjectDetails extends IAttestationResponse {
189
+ type: "ProjectDetails";
190
+ data: {
191
+ title: string;
192
+ description: string;
193
+ problem?: string;
194
+ solution?: string;
195
+ missionSummary?: string;
196
+ locationOfImpact?: string;
197
+ imageURL: string;
198
+ links?: Array<ExternalLink | ExternalCustomLink>;
199
+ tags?: ITag[];
200
+ slug?: string;
201
+ type: "project-details";
202
+ businessModel?: string;
203
+ stageIn?: string;
204
+ raisedMoney?: string;
205
+ pathToTake?: string;
206
+ };
207
+ }
208
+ type IStatus = "verified";
209
+ export interface IProjectImpactStatus extends IAttestationResponse {
210
+ type: `project-impact-${IStatus}`;
211
+ reason?: string;
212
+ }
213
+ export interface IProjectImpact extends IAttestationResponse {
214
+ type: "ProjectImpact";
215
+ data: {
216
+ work: string;
217
+ impact: string;
218
+ proof: string;
219
+ startedAt?: number;
220
+ completedAt: number;
221
+ type: "project-impact";
222
+ };
223
+ verified: IProjectImpactStatus[];
224
+ }
225
+ export interface IProjectEndorsement extends IAttestationResponse {
226
+ type: "ProjectEndorsement";
227
+ data: {
228
+ comment?: string;
229
+ type?: "project-endorsement";
230
+ };
231
+ }
232
+ export interface IProjectResponse extends IAttestationResponse {
233
+ type: "Project";
234
+ data: {
235
+ project: true;
236
+ };
237
+ details?: IProjectDetails;
238
+ members: IMemberOf[];
239
+ grants: IGrantResponse[];
240
+ grantee: any;
241
+ impacts: IProjectImpact[];
242
+ updates: IProjectUpdate[];
243
+ pointers: IProjectPointer[];
244
+ symlinks: Hex[];
245
+ endorsements: IProjectEndorsement[];
246
+ milestones: IProjectMilestoneResponse[];
247
+ payoutAddress?: Hex;
248
+ }
249
+ export interface ICommunityDetails extends IAttestationResponse {
250
+ type: "CommunityDetails";
251
+ data: {
252
+ name: string;
253
+ description: string;
254
+ imageURL: string;
255
+ links: ExternalLink[];
256
+ slug?: string;
257
+ };
258
+ }
259
+ export interface ICommunityResponse extends IAttestationResponse {
260
+ type: "Community";
261
+ data: {
262
+ community: true;
263
+ };
264
+ details?: ICommunityDetails;
265
+ grants: IGrantResponse[];
266
+ }
267
+ export interface ICommunityAdminsResponse {
268
+ id: string;
269
+ admins: {
270
+ user: {
271
+ id: string;
272
+ };
273
+ }[];
274
+ }
275
+ export interface ISearchResponse {
276
+ projects: IProjectResponse[];
277
+ communities: ICommunityResponse[];
278
+ }
279
+ export interface ITrackResponse {
280
+ id: string;
281
+ name: string;
282
+ description?: string;
283
+ communityUID: string;
284
+ isArchived: boolean;
285
+ createdAt: string;
286
+ updatedAt: string;
287
+ programId?: string;
288
+ isActive?: boolean;
289
+ chainID?: number;
290
+ }
291
+ export interface ITrackAssignmentResponse {
292
+ id: string;
293
+ programId: string;
294
+ chainID: number;
295
+ trackId: string;
296
+ track: ITrackResponse;
297
+ }
298
+ export interface IProjectTrackResponse {
299
+ projectUID: string;
300
+ chainID: number;
301
+ programId: string;
302
+ track: ITrackResponse;
303
+ project: {
304
+ uid: string;
305
+ chainID: number;
306
+ details: any;
307
+ };
308
+ }
309
+ export {};
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,23 @@
1
+ import { RemoteStorage } from "./RemoteStorage";
2
+ import { TRemoteStorageOutput } from "core/types";
3
+ export interface IpfsStorageOptions {
4
+ token: string;
5
+ }
6
+ export declare class IpfsStorage extends RemoteStorage {
7
+ private pinataJWTToken;
8
+ constructor(opts: IpfsStorageOptions,
9
+ /**
10
+ * If set, will send request to another server instead of
11
+ * using the local instance
12
+ */
13
+ sponsor?: RemoteStorage["sponsor"]);
14
+ private assert;
15
+ save<T = unknown>(data: T): Promise<string>;
16
+ encode(data: string): TRemoteStorageOutput<string>;
17
+ get<T = unknown>(args: {
18
+ cid: string;
19
+ }): Promise<T>;
20
+ saveAndGetCID(data: any, pinataMetadata?: {
21
+ name: string;
22
+ }): Promise<any>;
23
+ }
@@ -0,0 +1,56 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.IpfsStorage = void 0;
7
+ const RemoteStorage_1 = require("./RemoteStorage");
8
+ const SchemaError_1 = require("../SchemaError");
9
+ const utils_1 = require("../../utils");
10
+ const axios_1 = __importDefault(require("axios"));
11
+ class IpfsStorage extends RemoteStorage_1.RemoteStorage {
12
+ constructor(opts,
13
+ /**
14
+ * If set, will send request to another server instead of
15
+ * using the local instance
16
+ */
17
+ sponsor) {
18
+ super(0 /* STORAGE_TYPE.IPFS */, sponsor);
19
+ this.assert(opts);
20
+ this.pinataJWTToken = opts.token;
21
+ }
22
+ assert(opts) { }
23
+ async save(data) {
24
+ try {
25
+ const cid = await this.saveAndGetCID(data);
26
+ return cid;
27
+ }
28
+ catch (error) {
29
+ throw new SchemaError_1.RemoteStorageError("REMOTE_STORAGE_UPLOAD", `Error adding data to IPFS`);
30
+ }
31
+ }
32
+ encode(data) {
33
+ return { hash: data, storageType: this.storageType };
34
+ }
35
+ async get(args) {
36
+ return (0, utils_1.getIPFSData)(args.cid);
37
+ }
38
+ async saveAndGetCID(data, pinataMetadata = { name: "via karma-gap-sdk" }) {
39
+ try {
40
+ const res = await axios_1.default.post("https://api.pinata.cloud/pinning/pinJSONToIPFS", {
41
+ pinataContent: data,
42
+ pinataMetadata: pinataMetadata,
43
+ }, {
44
+ headers: {
45
+ "Content-Type": "application/json",
46
+ Authorization: `Bearer ${this.pinataJWTToken}`,
47
+ },
48
+ });
49
+ return res.data.IpfsHash;
50
+ }
51
+ catch (error) {
52
+ throw new SchemaError_1.RemoteStorageError("REMOTE_STORAGE_UPLOAD", `Error adding data to IPFS`);
53
+ }
54
+ }
55
+ }
56
+ exports.IpfsStorage = IpfsStorage;
@@ -0,0 +1,41 @@
1
+ import { STORAGE_TYPE, TRemoteStorageOutput } from 'core/types';
2
+ interface SponsoredRemote {
3
+ url: string;
4
+ responseParser: (response: any) => string;
5
+ }
6
+ export declare abstract class RemoteStorage<C = unknown> {
7
+ protected client: C;
8
+ readonly storageType: number;
9
+ readonly sponsor?: SponsoredRemote;
10
+ constructor(storageType: STORAGE_TYPE,
11
+ /**
12
+ * If set, will try to POST request to another server instead of
13
+ * using the local instance.
14
+ *
15
+ * > If a response parser is not set, it will try to get { cid: string }.
16
+ */
17
+ sponsor: SponsoredRemote);
18
+ /**
19
+ * Try to save data to remote storage and return the CID.
20
+ * IF sponsorUrl is set, this method will be automatically
21
+ * intercepted and will send a POST request to the sponsorUrl
22
+ * with the contents: `{ data: T, type: "<AttestationType>" }`
23
+ */
24
+ abstract save<T = unknown>(data: T, schemaName: string): Promise<string>;
25
+ /**
26
+ * Encodes the data according to the remote storage type parameters
27
+ * OR returns the data as is if no encoding is required
28
+ */
29
+ abstract encode(data: unknown): TRemoteStorageOutput;
30
+ /**
31
+ * Get data from Remote Storage
32
+ */
33
+ abstract get<T = unknown>(args: unknown): Promise<T>;
34
+ /**
35
+ * If sponsorUrl is set, intercept the save method and send a POST request
36
+ * to the sponsorUrl instead of using the local instance.
37
+ * @returns
38
+ */
39
+ private interceptRemoteStorage;
40
+ }
41
+ export {};
@@ -0,0 +1,38 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.RemoteStorage = void 0;
7
+ const axios_1 = __importDefault(require("axios"));
8
+ class RemoteStorage {
9
+ constructor(storageType,
10
+ /**
11
+ * If set, will try to POST request to another server instead of
12
+ * using the local instance.
13
+ *
14
+ * > If a response parser is not set, it will try to get { cid: string }.
15
+ */
16
+ sponsor) {
17
+ this.storageType = storageType;
18
+ this.sponsor = sponsor;
19
+ this.interceptRemoteStorage();
20
+ }
21
+ /**
22
+ * If sponsorUrl is set, intercept the save method and send a POST request
23
+ * to the sponsorUrl instead of using the local instance.
24
+ * @returns
25
+ */
26
+ interceptRemoteStorage() {
27
+ if (!this.sponsor?.url)
28
+ return;
29
+ this.save = async (data, schemaName) => {
30
+ const { data: response } = await axios_1.default.post(this.sponsor.url, {
31
+ data: data,
32
+ type: schemaName,
33
+ });
34
+ return this.sponsor.responseParser?.(response) || response.cid;
35
+ };
36
+ }
37
+ }
38
+ exports.RemoteStorage = RemoteStorage;
@@ -0,0 +1,78 @@
1
+ export type RoundMetadata = {
2
+ name: string;
3
+ support: {
4
+ info: string;
5
+ type: string;
6
+ };
7
+ roundType: "public" | string;
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
+ export type Address = `0x${string}`;
29
+ export type GrantArgs = {
30
+ profileId: Address;
31
+ roundMetadata: RoundMetadata;
32
+ applicationStart: number;
33
+ applicationEnd: number;
34
+ roundStart: number;
35
+ roundEnd: number;
36
+ matchingFundAmt: number;
37
+ applicationMetadata: ApplicationMetadata;
38
+ managers: Address[];
39
+ strategy: Address;
40
+ payoutToken: Address;
41
+ };
42
+ export type ApplicationMetadata = {
43
+ version: string;
44
+ lastUpdatedOn: number;
45
+ applicationSchema: {
46
+ questions: Array<{
47
+ id: number;
48
+ info: string;
49
+ type: "email" | "short-answer" | "link" | "number" | "paragraph" | "address" | "checkbox" | "multiple-choice";
50
+ title: string;
51
+ hidden: boolean;
52
+ choices?: string[];
53
+ required: boolean;
54
+ encrypted: boolean;
55
+ }>;
56
+ requirements: {
57
+ github: {
58
+ required: boolean;
59
+ verification: boolean;
60
+ };
61
+ twitter: {
62
+ required: boolean;
63
+ verification: boolean;
64
+ };
65
+ };
66
+ };
67
+ };
68
+ export type ProfileMetadata = {
69
+ title: string;
70
+ description: string;
71
+ website: string;
72
+ projectTwitter: string;
73
+ logoImg: string;
74
+ bannerImg: string;
75
+ logoImgData: any;
76
+ bannerImgData: any;
77
+ createdAt: number;
78
+ };
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });