@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
package/core/class/GAP.js DELETED
@@ -1,289 +0,0 @@
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.GAP = void 0;
7
- const CommunityResolverABI_json_1 = __importDefault(require("../abi/CommunityResolverABI.json"));
8
- const MultiAttester_json_1 = __importDefault(require("../abi/MultiAttester.json"));
9
- const ProjectResolver_json_1 = __importDefault(require("../abi/ProjectResolver.json"));
10
- const eas_sdk_1 = require("@ethereum-attestation-service/eas-sdk");
11
- const ethers_1 = require("ethers");
12
- const package_json_1 = require("../../package.json");
13
- const consts_1 = require("../consts");
14
- const types_1 = require("../types");
15
- const get_web3_provider_1 = require("../utils/get-web3-provider");
16
- const GapSchema_1 = require("./GapSchema");
17
- const GraphQL_1 = require("./GraphQL");
18
- const Schema_1 = require("./Schema");
19
- /**
20
- * GAP SDK Facade.
21
- *
22
- * This is the main class that is used to interact with the GAP SDK.
23
- *
24
- * This class implements the singleton pattern to ensure only one instance exists
25
- * throughout the application lifecycle.
26
- *
27
- * Using this class, the user will be able to:
28
- *
29
- * - Create and manage attestations
30
- * - Create and manage schemas
31
- * - Fetch data from the EAS
32
- *
33
- * #### Features
34
- * - EAS Client: used to interact with EAS contracts
35
- * - EAS Fetcher: used to fetch data from the EAS GraphQL API, providing methods for:
36
- * - Get projects
37
- * - Get grants with its details
38
- * - Get grantees
39
- * - Get members
40
- * - Get tags
41
- * - Get external links
42
- * - Get schemas
43
- * - Get attestations by pair, attester, recipient, schema, or UID
44
- * - Get dependent attestations
45
- * - Schema: used to create and manage schemas
46
- * - Attestation: used to create and manage attestations
47
- * - Replace schemas: used to replace the schema list with a new list
48
- * - Replace single schema: used to replace a single schema from the schema list
49
- *
50
- * ---
51
- * @example
52
- * ```ts
53
- * import { GAP } from "./core/class/GAP";
54
- * import { GapSchema } from "./core/class/GapSchema";
55
- * import { Schema } from "./core/class/Schema";
56
- * import { MountEntities, Networks } from "./core/consts";
57
- *
58
- * const schemas = MountEntities(Networks.sepolia);
59
- *
60
- * // Initialize the singleton instance
61
- * const gap = GAP.getInstance({
62
- * network: "sepolia",
63
- * owner: "0xd7d1DB401EA825b0325141Cd5e6cd7C2d01825f2",
64
- * schemas: Object.values(schemas),
65
- * });
66
- *
67
- * // Later in the code, get the same instance
68
- * const sameGap = GAP.getInstance();
69
- *
70
- * gap.fetcher
71
- * .fetchProjects()
72
- * .then((res) => {
73
- * console.log(JSON.stringify(res, null, 2));
74
- * })
75
- *
76
- * ```
77
- */
78
- class GAP extends types_1.Facade {
79
- /**
80
- * Get the singleton instance of GAP for a specific network.
81
- * If no instance exists for the network, creates one with the provided args.
82
- * @param args Optional initialization arguments
83
- * @returns The singleton instance of GAP for the specified network
84
- */
85
- static getInstance(args) {
86
- if (!args) {
87
- throw new Error("Network must be specified when getting GAP instance");
88
- }
89
- const existingInstance = GAP.instances.get(args.network);
90
- if (existingInstance) {
91
- return existingInstance;
92
- }
93
- if (!args) {
94
- throw new Error("Initialization arguments required for first instance");
95
- }
96
- const newInstance = new GAP(args);
97
- GAP.instances.set(args.network, newInstance);
98
- return newInstance;
99
- }
100
- /**
101
- * Creates a new instance of GAP.
102
- * You can either use this constructor directly or use the singleton pattern via getInstance().
103
- * @param args Initialization arguments
104
- */
105
- constructor(args) {
106
- super();
107
- /**
108
- * Generates a slug from a text.
109
- * @param text
110
- * @returns
111
- */
112
- this.generateSlug = async (text) => {
113
- let slug = text
114
- .toLowerCase()
115
- // Remove emojis
116
- .replace(/([\uE000-\uF8FF]|\uD83C[\uDF00-\uDFFF]|\uD83D[\uDC00-\uDDFF])/g, "")
117
- // Remove basic text emoticons
118
- .replace(/[:;=][()DP]/g, "")
119
- .replace(/ /g, "-")
120
- .replace(/[^\w-]+/g, "")
121
- .trim()
122
- .replace(/^-+|-+$/g, ""); // Remove leading and trailing hyphens
123
- const checkSlug = async (currentSlug, counter = 0) => {
124
- const slugToCheck = counter === 0 ? currentSlug : `${currentSlug}-${counter}`;
125
- const slugExists = await this.fetch.slugExists(slugToCheck);
126
- if (slugExists) {
127
- return checkSlug(currentSlug, counter + 1);
128
- }
129
- return slugToCheck.toLowerCase();
130
- };
131
- return checkSlug(slug);
132
- };
133
- const schemas = args.schemas || Object.values((0, consts_1.MountEntities)(consts_1.Networks[args.network]));
134
- this.network = args.network;
135
- this._eas = new eas_sdk_1.EAS(consts_1.Networks[args.network].contracts.eas);
136
- this.fetch =
137
- args.apiClient ||
138
- new GraphQL_1.GapEasClient({
139
- network: args.network,
140
- });
141
- this.fetch.gapInstance = this;
142
- this.assertGelatoOpts(args);
143
- GAP._gelatoOpts = args.gelatoOpts;
144
- GAP.remoteStorage = args.remoteStorage;
145
- this._schemas = schemas.map((schema) => new GapSchema_1.GapSchema(schema, this, false, args.globalSchemas ? !args.globalSchemas : false));
146
- Schema_1.Schema.validate(this.network);
147
- console.info(`Loaded GAP SDK v${package_json_1.version} for network ${this.network}`);
148
- GAP.instances.set(this.network, this);
149
- }
150
- assertGelatoOpts(args) {
151
- if (args.gelatoOpts &&
152
- !(args.gelatoOpts.sponsorUrl || args.gelatoOpts.apiKey)) {
153
- throw new Error("You must provide a `sponsorUrl` or an `apiKey`.");
154
- }
155
- if (args.gelatoOpts?.sponsorUrl &&
156
- args.gelatoOpts?.contained &&
157
- !args.gelatoOpts.env_gelatoApiKey) {
158
- throw new Error("You must provide `env_gelatoApiKey` to be able to use it in a backend handler.");
159
- }
160
- if ((args.gelatoOpts?.env_gelatoApiKey ||
161
- args.gelatoOpts?.apiKey ||
162
- args.gelatoOpts?.sponsorUrl) &&
163
- !args.gelatoOpts?.useGasless) {
164
- console.warn("GAP::You are using gelatoOpts but not setting useGasless to true. This will send transactions through the normal provider.");
165
- }
166
- }
167
- /**
168
- * Creates the attestation payload using a specific schema.
169
- * @param from
170
- * @param to
171
- * @param data
172
- * @param schema
173
- */
174
- async attest(attestation) {
175
- const schema = GapSchema_1.GapSchema.find(attestation.schemaName, this.network);
176
- return schema.attest(attestation);
177
- }
178
- /**
179
- * Replaces the schema list with a new list.
180
- * @param schemas
181
- */
182
- replaceSchemas(schemas) {
183
- Schema_1.Schema.replaceAll(schemas, this.network);
184
- }
185
- /**
186
- * Replaces a schema from the schema list.
187
- * @throws {SchemaError} if desired schema name does not exist.
188
- */
189
- replaceSingleSchema(schema) {
190
- Schema_1.Schema.replaceOne(schema, this.network);
191
- }
192
- /**
193
- * Returns a copy of the original schema with no pointers.
194
- * @param name
195
- * @returns
196
- */
197
- findSchema(name) {
198
- const found = Schema_1.Schema.get(name, this.network);
199
- return GapSchema_1.GapSchema.clone(found);
200
- }
201
- /**
202
- * Find many schemas by name and return their copies as an array in the same order.
203
- * @param names
204
- * @returns
205
- */
206
- findManySchemas(names) {
207
- const schemas = Schema_1.Schema.getMany(names, this.network);
208
- return schemas.map((s) => GapSchema_1.GapSchema.clone(s));
209
- }
210
- /**
211
- * Get the multicall contract
212
- * @param signer
213
- */
214
- static async getMulticall(signer) {
215
- const chain = (await signer.provider.getNetwork()) || signer.provider.network;
216
- const network = Object.values(consts_1.Networks).find((n) => +n.chainId === Number(chain.chainId));
217
- if (!network)
218
- throw new Error(`Network ${chain.name || chain.chainId} not supported.`);
219
- const address = network.contracts.multicall;
220
- return new ethers_1.ethers.Contract(address, MultiAttester_json_1.default, signer);
221
- }
222
- /**
223
- * Get the multicall contract
224
- * @param signer
225
- */
226
- static async getProjectResolver(signer, chainId) {
227
- const currentChainId = chainId ||
228
- Number((await signer.provider.getNetwork())?.chainId ||
229
- (await signer.getChainId()));
230
- const provider = chainId ? (0, get_web3_provider_1.getWeb3Provider)(chainId) : signer;
231
- const network = Object.values(consts_1.Networks).find((n) => +n.chainId === Number(currentChainId));
232
- const address = network.contracts.projectResolver;
233
- return new ethers_1.ethers.Contract(address, ProjectResolver_json_1.default, provider);
234
- }
235
- /**
236
- * Get the multicall contract
237
- * @param signer
238
- */
239
- static async getCommunityResolver(signer, chainId) {
240
- const currentChainId = chainId ||
241
- Number((await signer.provider.getNetwork())?.chainId ||
242
- (await signer.getChainId()));
243
- const provider = chainId ? (0, get_web3_provider_1.getWeb3Provider)(chainId) : signer;
244
- const network = Object.values(consts_1.Networks).find((n) => +n.chainId === Number(currentChainId));
245
- const address = network.contracts.communityResolver;
246
- return new ethers_1.ethers.Contract(address, CommunityResolverABI_json_1.default, provider);
247
- }
248
- get schemas() {
249
- return this._schemas;
250
- }
251
- /**
252
- * Defined if the transactions will be gasless or not.
253
- *
254
- * In case of true, the transactions will be sent through [Gelato](https://gelato.network)
255
- * and an API key is needed.
256
- */
257
- static set gelatoOpts(gelatoOpts) {
258
- if (typeof this._gelatoOpts === "undefined") {
259
- this._gelatoOpts = gelatoOpts;
260
- }
261
- else {
262
- throw new Error("Cannot change a readonly value gelatoOpts.");
263
- }
264
- }
265
- /**
266
- * Defined if the transactions will be gasless or not.
267
- *
268
- * In case of true, the transactions will be sent through [Gelato](https://gelato.network)
269
- * and an API key is needed.
270
- */
271
- static get gelatoOpts() {
272
- return this._gelatoOpts;
273
- }
274
- static set useGasLess(useGasLess) {
275
- if (useGasLess &&
276
- !this._gelatoOpts?.apiKey &&
277
- !this._gelatoOpts?.sponsorUrl &&
278
- !this._gelatoOpts?.env_gelatoApiKey) {
279
- throw new Error("You must provide a `sponsorUrl` or an `apiKey` before using gasless transactions.");
280
- }
281
- this._gelatoOpts.useGasless = useGasLess;
282
- }
283
- static get remoteClient() {
284
- return this.remoteStorage;
285
- }
286
- }
287
- exports.GAP = GAP;
288
- GAP.instances = new Map();
289
- GAP._gelatoOpts = null;
@@ -1,34 +0,0 @@
1
- import { IGapSchema, SchemaInterface, TNetwork, TSchemaName } from '../types';
2
- import { Schema } from './Schema';
3
- import { GAP } from './GAP';
4
- /**
5
- * Represents the GapSchema
6
- * @extends Schema
7
- */
8
- export declare class GapSchema extends Schema implements IGapSchema {
9
- readonly name: TSchemaName;
10
- readonly references: TSchemaName;
11
- constructor(args: SchemaInterface<TSchemaName>, gap: GAP, strict?: boolean, ignoreSchema?: boolean);
12
- /**
13
- * Clones a schema without references to the original.
14
- * @param schema
15
- * @returns
16
- */
17
- static clone(schema: GapSchema): GapSchema;
18
- /**
19
- * Returns a copy of the original schema with no pointers.
20
- * @param name
21
- * @returns
22
- */
23
- static find(name: TSchemaName, network: TNetwork): GapSchema;
24
- /**
25
- * Find many schemas by name and return their copies as an array in the same order.
26
- * @param names
27
- * @returns
28
- */
29
- static findMany(names: TSchemaName[], network: TNetwork): GapSchema[];
30
- /**
31
- * Get all schemas that references this schema.
32
- */
33
- get children(): GapSchema[];
34
- }
@@ -1,62 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.GapSchema = void 0;
4
- const utils_1 = require("../utils");
5
- const Schema_1 = require("./Schema");
6
- /**
7
- * Represents the GapSchema
8
- * @extends Schema
9
- */
10
- class GapSchema extends Schema_1.Schema {
11
- constructor(args, gap, strict = false, ignoreSchema = false) {
12
- super(args, gap, strict, ignoreSchema);
13
- if (!ignoreSchema)
14
- Schema_1.Schema.add(gap.network, new GapSchema({
15
- name: args.name,
16
- schema: args.schema.map((s) => ({ ...s })),
17
- uid: args.uid,
18
- references: args.references,
19
- revocable: args.revocable,
20
- oldSchemas: args.oldSchemas,
21
- }, gap, strict, true));
22
- }
23
- /**
24
- * Clones a schema without references to the original.
25
- * @param schema
26
- * @returns
27
- */
28
- static clone(schema) {
29
- return new GapSchema({
30
- name: schema.name,
31
- schema: schema.schema.map((s) => ({ ...s })),
32
- uid: schema.uid,
33
- references: schema.references,
34
- revocable: schema.revocable,
35
- }, schema.gap, false, true);
36
- }
37
- /**
38
- * Returns a copy of the original schema with no pointers.
39
- * @param name
40
- * @returns
41
- */
42
- static find(name, network) {
43
- const found = Schema_1.Schema.get(name, network);
44
- return this.clone(found);
45
- }
46
- /**
47
- * Find many schemas by name and return their copies as an array in the same order.
48
- * @param names
49
- * @returns
50
- */
51
- static findMany(names, network) {
52
- const schemas = Schema_1.Schema.getMany(names, network);
53
- return schemas.map((s) => this.clone(s));
54
- }
55
- /**
56
- * Get all schemas that references this schema.
57
- */
58
- get children() {
59
- return (0, utils_1.mapFilter)(GapSchema.schemas[this.gap.network], (s) => s.references === this.name || s.references === this.uid, (s) => new GapSchema(s, s.gap, false, true));
60
- }
61
- }
62
- exports.GapSchema = GapSchema;
@@ -1,17 +0,0 @@
1
- import { ethers } from "ethers";
2
- export declare class AlloBase {
3
- private signer;
4
- private contract;
5
- private allo;
6
- private pinataJWTToken;
7
- constructor(signer: ethers.Signer, pinataJWTToken: string, chainId: number);
8
- saveAndGetCID(data: any, pinataMetadata?: {
9
- name: string;
10
- }): Promise<any>;
11
- encodeStrategyInitData(applicationStart: number, applicationEnd: number, roundStart: number, roundEnd: number, payoutToken: string): Promise<string>;
12
- createGrant(args: any, callback?: Function): Promise<{
13
- poolId: string;
14
- txHash: string;
15
- }>;
16
- updatePoolMetadata(poolId: string, poolMetadata: any, callback?: Function): Promise<any>;
17
- }
@@ -1,137 +0,0 @@
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.AlloBase = void 0;
7
- const ethers_1 = require("ethers");
8
- const Allo_json_1 = __importDefault(require("../../abi/Allo.json"));
9
- const consts_1 = require("../../consts");
10
- const ethers_2 = require("ethers");
11
- const allo_v2_sdk_1 = require("@allo-team/allo-v2-sdk/");
12
- const axios_1 = __importDefault(require("axios"));
13
- // ABI fragment for the Initialized event
14
- const INITIALIZED_EVENT = ["event Initialized(uint256 poolId, bytes data)"];
15
- class AlloBase {
16
- constructor(signer, pinataJWTToken, chainId) {
17
- this.signer = signer;
18
- this.contract = new ethers_1.ethers.Contract(consts_1.AlloContracts.alloProxy, Allo_json_1.default, signer);
19
- this.allo = new allo_v2_sdk_1.Allo({ chain: chainId });
20
- this.pinataJWTToken = pinataJWTToken;
21
- }
22
- async saveAndGetCID(data, pinataMetadata = { name: "via karma-gap-sdk" }) {
23
- try {
24
- const res = await axios_1.default.post("https://api.pinata.cloud/pinning/pinJSONToIPFS", {
25
- pinataContent: data,
26
- pinataMetadata: pinataMetadata,
27
- }, {
28
- headers: {
29
- "Content-Type": "application/json",
30
- Authorization: `Bearer ${this.pinataJWTToken}`,
31
- },
32
- });
33
- return res.data.IpfsHash;
34
- }
35
- catch (error) {
36
- console.log(error);
37
- }
38
- }
39
- async encodeStrategyInitData(applicationStart, applicationEnd, roundStart, roundEnd, payoutToken) {
40
- const encoder = new ethers_2.AbiCoder();
41
- const initStrategyData = encoder.encode(["bool", "bool", "uint256", "uint256", "uint256", "uint256", "address[]"], [
42
- false,
43
- true,
44
- applicationStart,
45
- applicationEnd,
46
- roundStart,
47
- roundEnd,
48
- [payoutToken],
49
- ]);
50
- return initStrategyData;
51
- }
52
- async createGrant(args, callback) {
53
- console.log("Creating grant...");
54
- const walletBalance = await this.signer.provider.getBalance(await this.signer.getAddress());
55
- console.log("Wallet balance:", (0, ethers_1.formatEther)(walletBalance.toString()), " ETH");
56
- try {
57
- const metadata_cid = await this.saveAndGetCID({
58
- round: args.roundMetadata,
59
- application: args.applicationMetadata,
60
- });
61
- const metadata = {
62
- protocol: BigInt(1),
63
- pointer: metadata_cid,
64
- };
65
- const initStrategyData = (await this.encodeStrategyInitData(args.applicationStart, args.applicationEnd, args.roundStart, args.roundEnd, args.payoutToken));
66
- const createPoolArgs = {
67
- profileId: args.profileId,
68
- strategy: args.strategy,
69
- initStrategyData: initStrategyData,
70
- token: args.payoutToken,
71
- amount: BigInt(args.matchingFundAmt),
72
- metadata: metadata,
73
- managers: args.managers,
74
- };
75
- callback?.("preparing");
76
- const txData = this.allo.createPool(createPoolArgs);
77
- const tx = await this.signer.sendTransaction({
78
- data: txData.data,
79
- to: txData.to,
80
- value: BigInt(txData.value),
81
- });
82
- callback?.("pending");
83
- const receipt = await tx.wait();
84
- callback?.("confirmed");
85
- // Create interface to parse the logs
86
- const iface = new ethers_1.ethers.Interface(INITIALIZED_EVENT);
87
- let poolId;
88
- // Find the Initialized event in the logs
89
- const initializedLog = receipt.logs.find((log) => {
90
- try {
91
- const parsed = iface.parseLog(log);
92
- return parsed.name === "Initialized";
93
- }
94
- catch {
95
- return false;
96
- }
97
- });
98
- if (initializedLog) {
99
- const parsedLog = iface.parseLog(initializedLog);
100
- poolId = parsedLog.args.poolId.toString();
101
- console.log(`Transaction ${tx.hash} - Found poolId: ${poolId}`);
102
- }
103
- else {
104
- poolId = receipt.logs[receipt.logs.length - 1].topics[1]; // Fallback to Initialized order logic
105
- console.log(`No Initialized event found in tx ${tx.hash}`);
106
- }
107
- return {
108
- poolId: BigInt(poolId).toString(),
109
- txHash: tx.hash,
110
- };
111
- }
112
- catch (error) {
113
- console.error(`Failed to create pool: ${error}`);
114
- throw new Error(`Failed to create pool metadata: ${error}`);
115
- }
116
- }
117
- async updatePoolMetadata(poolId, poolMetadata, callback) {
118
- try {
119
- callback?.("preparing");
120
- const metadata_cid = await this.saveAndGetCID(poolMetadata);
121
- const metadata = {
122
- protocol: 1,
123
- pointer: metadata_cid,
124
- };
125
- const tx = await this.contract.updatePoolMetadata(poolId, metadata);
126
- callback?.("pending");
127
- const receipt = await tx.wait();
128
- callback?.("confirmed");
129
- return receipt;
130
- }
131
- catch (error) {
132
- console.error(`Failed to update pool metadata: ${error}`);
133
- throw new Error(`Failed to update pool metadata: ${error}`);
134
- }
135
- }
136
- }
137
- exports.AlloBase = AlloBase;
@@ -1,15 +0,0 @@
1
- import { ethers } from "ethers";
2
- import { ProfileMetadata } from "../types/allo";
3
- export declare class AlloRegistry {
4
- private contract;
5
- private pinataJWTToken;
6
- constructor(signer: ethers.Signer, pinataJWTToken: string);
7
- saveAndGetCID(data: any, pinataMetadata?: {
8
- name: string;
9
- }): Promise<any>;
10
- createProgram(nonce: number, name: string, profileMetadata: ProfileMetadata, owner: string, members: string[]): Promise<{
11
- profileId: any;
12
- txHash: any;
13
- }>;
14
- updateProgramMetadata(profileId: string, profileMetadata: ProfileMetadata): Promise<any>;
15
- }
@@ -1,70 +0,0 @@
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.AlloRegistry = void 0;
7
- const ethers_1 = require("ethers");
8
- const AlloRegistry_json_1 = __importDefault(require("../../abi/AlloRegistry.json"));
9
- const consts_1 = require("../../consts");
10
- const axios_1 = __importDefault(require("axios"));
11
- class AlloRegistry {
12
- constructor(signer, pinataJWTToken) {
13
- this.contract = new ethers_1.ethers.Contract(consts_1.AlloContracts.registry, AlloRegistry_json_1.default, signer);
14
- this.pinataJWTToken = pinataJWTToken;
15
- }
16
- async saveAndGetCID(data, pinataMetadata = { name: "via karma-gap-sdk" }) {
17
- try {
18
- const res = await axios_1.default.post("https://api.pinata.cloud/pinning/pinJSONToIPFS", {
19
- pinataContent: data,
20
- pinataMetadata: pinataMetadata,
21
- }, {
22
- headers: {
23
- "Content-Type": "application/json",
24
- Authorization: `Bearer ${this.pinataJWTToken}`,
25
- },
26
- });
27
- return res.data.IpfsHash;
28
- }
29
- catch (error) {
30
- console.log(error);
31
- }
32
- }
33
- async createProgram(nonce, name, profileMetadata, owner, members) {
34
- console.log("Creating program...");
35
- try {
36
- const metadata_cid = await this.saveAndGetCID(profileMetadata);
37
- const metadata = {
38
- protocol: 1,
39
- pointer: metadata_cid,
40
- };
41
- const tx = await this.contract.createProfile(nonce, name, metadata, owner, members);
42
- const receipt = await tx.wait();
43
- // Get ProfileCreated event
44
- const profileCreatedEvent = receipt.logs.find((event) => event.eventName === "ProfileCreated");
45
- return {
46
- profileId: profileCreatedEvent.args[0],
47
- txHash: receipt.hash,
48
- };
49
- }
50
- catch (error) {
51
- console.error(`Failed to register program: ${error}`);
52
- }
53
- }
54
- async updateProgramMetadata(profileId, profileMetadata) {
55
- try {
56
- const metadata_cid = await this.saveAndGetCID(profileMetadata);
57
- const metadata = {
58
- protocol: 1,
59
- pointer: metadata_cid,
60
- };
61
- const tx = await this.contract.updateProfileMetadata(profileId, metadata);
62
- const receipt = await tx.wait();
63
- return receipt;
64
- }
65
- catch (error) {
66
- console.error(`Failed to update profile metadata: ${error}`);
67
- }
68
- }
69
- }
70
- exports.AlloRegistry = AlloRegistry;
@@ -1,6 +0,0 @@
1
- import type { AxiosInstance } from "axios";
2
- export declare abstract class AxiosGQL {
3
- protected client: AxiosInstance;
4
- constructor(url: string);
5
- protected query<R = unknown, T = unknown>(query: string, variables?: T): Promise<R>;
6
- }
@@ -1,25 +0,0 @@
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.AxiosGQL = void 0;
7
- const axios_1 = __importDefault(require("axios"));
8
- class AxiosGQL {
9
- constructor(url) {
10
- this.client = axios_1.default.create({
11
- baseURL: url,
12
- headers: {
13
- "Content-Type": "application/json",
14
- },
15
- });
16
- }
17
- async query(query, variables) {
18
- const { data: { data }, } = await this.client.post("", {
19
- query,
20
- variables,
21
- });
22
- return data;
23
- }
24
- }
25
- exports.AxiosGQL = AxiosGQL;
@@ -1,16 +0,0 @@
1
- import { TNetwork } from "../../types";
2
- import { AxiosGQL } from "./AxiosGQL";
3
- interface EASClientProps {
4
- network: TNetwork;
5
- }
6
- export declare class EASClient extends AxiosGQL implements EASClientProps {
7
- private readonly _network;
8
- constructor(args: EASClientProps);
9
- /**
10
- * Validate the constructor arguments
11
- * @param args
12
- */
13
- private assert;
14
- get network(): TNetwork;
15
- }
16
- export {};