@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,102 @@
1
+ import { AlloBase } from "../class/GrantProgramRegistry/Allo";
2
+ import { ethers } from "ethers";
3
+ import { Networks } from "../consts";
4
+ import { ApplicationMetadata, RoundMetadata } from "../class/types/allo";
5
+ import keys from "../../config/keys.json";
6
+ import { AlloContracts } from "../consts";
7
+ import { GrantArgs, Address } from "../class/types/allo";
8
+
9
+ const networkName = "sepolia";
10
+ const chainId = Networks[networkName].chainId;
11
+ const web3 = new ethers.JsonRpcProvider(Networks[networkName].rpcUrl);
12
+ const wallet = new ethers.Wallet(keys.privateKey, web3);
13
+ const signer = wallet.connect(web3);
14
+
15
+ export async function main() {
16
+ const allo = new AlloBase(signer, keys.ipfsToken, chainId);
17
+
18
+ const _currentTimestamp = (await signer?.provider?.getBlock(
19
+ await signer?.provider?.getBlockNumber()
20
+ ))!.timestamp;
21
+ const owner = wallet.address;
22
+
23
+ const profileId =
24
+ "0x812f0ae5dc7dd0a3a66e52f71f2da56c61a23bb06f1a149975424d6f73519ed1"; // Karma Test Program 3
25
+ const matchinFundAmount = 0;
26
+ const roundMetadata: RoundMetadata = {
27
+ name: "Sepolia Test Round #3",
28
+ support: {
29
+ info: "Email",
30
+ type: "mahesh@karmahq.xyz",
31
+ },
32
+ roundType: "public",
33
+ eligibility: {
34
+ description:
35
+ "This is a test round using Karma Test Program on allo-v2 for grant-program-registry.",
36
+ requirements: [
37
+ {
38
+ requirement: "Be awesome!",
39
+ },
40
+ ],
41
+ },
42
+ feesAddress: "",
43
+ feesPercentage: 0,
44
+ programContractAddress: "0x0613fc8c28ca79d110a104c274b2d1eacef52355", // Some Contract Address
45
+
46
+ // TODO: Additional metadata
47
+ category: "zk-rollups",
48
+ source: "grant-program-registry",
49
+ // type: 'Proactive',
50
+ // ecosystem: 'EMV',
51
+ // status: 'Active',
52
+ // size: 3000,
53
+ };
54
+ const applicationMetadata: ApplicationMetadata = {
55
+ version: "1.0.0",
56
+ lastUpdatedOn: new Date().getTime(),
57
+ applicationSchema: {
58
+ questions: [
59
+ {
60
+ id: 0,
61
+ info: "Email Address",
62
+ type: "email",
63
+ title: "Email Address",
64
+ hidden: false,
65
+ required: true,
66
+ encrypted: false,
67
+ },
68
+ ],
69
+ requirements: {
70
+ github: {
71
+ required: false,
72
+ verification: false,
73
+ },
74
+ twitter: {
75
+ required: false,
76
+ verification: false,
77
+ },
78
+ // Potentially add more requirements here if they exist in the data
79
+ },
80
+ },
81
+ };
82
+
83
+ const args: GrantArgs = {
84
+ profileId,
85
+ roundMetadata,
86
+ applicationStart: _currentTimestamp + 3600, // 1 hour later registrationStartTime
87
+ applicationEnd: _currentTimestamp + 432000, // 5 days later registrationEndTime
88
+ roundStart: _currentTimestamp + 7200, // 2 hours later allocationStartTime
89
+ roundEnd: _currentTimestamp + 864000, // 10 days later allocaitonEndTime
90
+ matchingFundAmt: matchinFundAmount,
91
+ applicationMetadata,
92
+ managers: [owner as Address], // managers
93
+ strategy: AlloContracts.strategy
94
+ .DonationVotingMerkleDistributionDirectTransferStrategy as Address, // strategy
95
+ payoutToken: "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE", // Eg. ETH
96
+ };
97
+
98
+ const response = await allo.createGrant(args);
99
+ console.log(response);
100
+ }
101
+
102
+ main();
@@ -0,0 +1,43 @@
1
+ import { AlloRegistry } from "../class/GrantProgramRegistry/AlloRegistry";
2
+ import { ethers } from "ethers";
3
+ import { Networks } from "../consts";
4
+
5
+ import keys from "../../config/keys.json";
6
+
7
+ const networkName = "sepolia";
8
+ const web3 = new ethers.JsonRpcProvider(Networks[networkName].rpcUrl);
9
+ const wallet = new ethers.Wallet(keys.privateKey, web3);
10
+ const signer = wallet.connect(web3);
11
+
12
+ export async function main() {
13
+ const alloRegistry = new AlloRegistry(signer, keys.ipfsToken);
14
+
15
+ const nonce = 12310;
16
+ const name = "Karma Gap Registry";
17
+ const metadata = {
18
+ title: name,
19
+ description: `Karma Gap Registry`,
20
+ website: "gap.karmahq.xyz",
21
+ projectTwitter: "karmahq_",
22
+ logoImg: "gap.karmahq.xyz/logo/karma-gap-logo.svg",
23
+ bannerImg: "gap.karmahq.xyz/logo/karma-gap-logo.svg",
24
+ logoImgData: {},
25
+ bannerImgData: {},
26
+ credentials: {},
27
+ createdAt: new Date().getTime(),
28
+
29
+ type: "program",
30
+ };
31
+ const owner = await signer.getAddress();
32
+
33
+ const response = await alloRegistry.createProgram(
34
+ nonce,
35
+ metadata.title,
36
+ metadata,
37
+ owner,
38
+ [owner]
39
+ );
40
+ console.log(response);
41
+ }
42
+
43
+ main();
@@ -0,0 +1,65 @@
1
+ import { EAS, SchemaEncoder, SchemaRegistry } from "@ethereum-attestation-service/eas-sdk";
2
+ import { ethers } from 'ethers';
3
+ import keys from "../../config/keys.json";
4
+ import { Networks, zeroAddress } from "../consts";
5
+ import { resolve } from "path";
6
+
7
+ const schemaRegistryContractAddress = "0x4200000000000000000000000000000000000020";
8
+
9
+ (async () => {
10
+ const schemaRegistry = new SchemaRegistry(schemaRegistryContractAddress);
11
+
12
+ const web3 = new ethers.JsonRpcProvider("https://lisk.drpc.org");
13
+ const wallet = new ethers.Wallet(keys.privateKey, web3);
14
+ schemaRegistry.connect(wallet);
15
+
16
+ const allSchemas = [
17
+ {
18
+ name: "Project",
19
+ schema: "bool project",
20
+ resolver: "0x6dC1D6b864e8BEf815806f9e4677123496e12026"
21
+ },
22
+ {
23
+ name: "Community",
24
+ schema: "bool community",
25
+ resolver: "0xfddb660F2F1C27d219372210745BB9f73431856E"
26
+ },
27
+ {
28
+ name: "Details",
29
+ schema: "string json",
30
+ resolver: "0xd2eD366393FDfd243931Fe48e9fb65A192B0018c"
31
+ },
32
+ {
33
+ name: "Grant",
34
+ schema: "bytes32 communityUID",
35
+ resolver: "0xd2eD366393FDfd243931Fe48e9fb65A192B0018c"
36
+ },
37
+ {
38
+ name: "GrantVerified",
39
+ schema: "string type, string reason",
40
+ resolver: "0x04D6BB799f5A8c76882C4372d1FC39Cd0DDA0A4c"
41
+ },
42
+ {
43
+ name: "MemberOf",
44
+ schema: "bool memberOf",
45
+ resolver: "0xd2eD366393FDfd243931Fe48e9fb65A192B0018c"
46
+ },
47
+ {
48
+ name: "ContributorProfile",
49
+ schema: "string json",
50
+ resolver: "0x0ab840273E4Ab6Dc642D02102Db719e1c1e3B299"
51
+ }
52
+ ];
53
+
54
+ for(const schema of allSchemas) {
55
+ const transaction = await schemaRegistry.register({
56
+ schema: schema.schema,
57
+ resolverAddress: schema.resolver,
58
+ revocable: true,
59
+ }
60
+ );
61
+
62
+ const response = await transaction.wait();
63
+ console.log(`Schema ${schema.name} registered with UID: ${response}`);
64
+ }
65
+ })();
@@ -0,0 +1,65 @@
1
+ import { EASNetworkConfig, TNetwork } from "../types";
2
+ import { MountEntities, Networks, zeroAddress } from "../consts";
3
+
4
+ import SchemaRegistry from "../abi/SchemaRegistry.json";
5
+
6
+ import { ethers } from "ethers";
7
+
8
+ import keys from "../../config/keys.json";
9
+ import { GapSchema } from "../class/GapSchema";
10
+ import { writeFileSync } from "fs";
11
+
12
+ const web3 = new ethers.JsonRpcProvider("https://eth-sepolia-public.unifra.io");
13
+ const wallet = new ethers.Wallet(keys.privateKey, web3);
14
+
15
+ const contract = new ethers.Contract(
16
+ Networks.sepolia.contracts.schema,
17
+ SchemaRegistry.abi,
18
+ wallet
19
+ );
20
+
21
+ async function deploy(networkName?: TNetwork) {
22
+ const [, , $3] = process.argv;
23
+ const network = Networks[networkName || $3] as EASNetworkConfig;
24
+ const key = keys[networkName || $3];
25
+
26
+ if (!(networkName || $3)) throw new Error("Network name is required");
27
+ if (!network) {
28
+ throw new Error(
29
+ `Invalid network name. Supported networks are: ${Object.keys(
30
+ Networks
31
+ ).join(", ")}`
32
+ );
33
+ }
34
+ if (!key) throw new Error("No keys found for this network");
35
+
36
+ const revocable = true;
37
+
38
+ const promises = Object.values(MountEntities(Networks.sepolia))
39
+ .slice(0, 1)
40
+ .map((entity) => {
41
+ return contract.register(
42
+ new GapSchema(entity, {} as any).raw,
43
+ zeroAddress,
44
+ revocable,
45
+ {
46
+ gasLimit: 5000000n,
47
+ }
48
+ );
49
+ });
50
+ const results: any[] = [];
51
+ for (const tx of promises) {
52
+ const txn = await tx;
53
+ const result = await txn.wait();
54
+ results.push(result);
55
+ }
56
+ console.log(results);
57
+ writeFileSync(
58
+ `schemas/GAP-schemas-${Date.now()}.json`,
59
+ JSON.stringify(results, null, 2)
60
+ );
61
+ }
62
+
63
+ if (process.argv[1].includes("core/scripts/deploy.ts")) deploy();
64
+
65
+ export { deploy };
@@ -0,0 +1 @@
1
+ export * from './deploy';
@@ -0,0 +1,125 @@
1
+ /**
2
+ * Example script demonstrating how to attest a milestone to multiple grants in a single transaction.
3
+ */
4
+ import { ethers } from "ethers";
5
+ import { GAP } from "../class/GAP";
6
+ import { Milestone } from "../class/entities/Milestone";
7
+ import { Grant } from "../class/entities/Grant";
8
+ import { Hex, SignerOrProvider } from "../types";
9
+ import { GapContract } from "../class/contract/GapContract";
10
+ import { MultiAttestPayload } from "../types";
11
+
12
+ async function main() {
13
+ // Initialize GAP with your network and signer
14
+ // Replace with your actual RPC URL and private key
15
+ const provider = new ethers.JsonRpcProvider("YOUR_RPC_URL");
16
+ const signer = new ethers.Wallet("YOUR_PRIVATE_KEY", provider);
17
+ const gap = new GAP({
18
+ network: "optimism",
19
+ // Additional GAP options can be specified here if needed
20
+ });
21
+
22
+ try {
23
+ console.log("Attesting milestone to multiple grants example");
24
+
25
+ // Example: Retrieve existing grants
26
+ // Replace these with actual grant UIDs from your application
27
+ // Using TypeScript template literals to ensure proper Hex type matching
28
+ const grantUIDs: Hex[] = ["0x123" as Hex, "0x456" as Hex, "0x789" as Hex];
29
+
30
+ // Fetch grants using individual queries instead of fetchByUID
31
+ const grants = await Promise.all(
32
+ grantUIDs.map(async (uid) => {
33
+ return await gap.fetch.attestation<Grant>(uid);
34
+ })
35
+ );
36
+
37
+ console.log(`Retrieved ${grants.length} grants`);
38
+
39
+ // Create a new milestone
40
+ const milestone = new Milestone({
41
+ schema: gap.findSchema("Milestone"),
42
+ recipient: (await signer.getAddress()) as `0x${string}`,
43
+ data: {
44
+ title: "Cross-Grant Milestone",
45
+ description: "This milestone applies to multiple grants",
46
+ endsAt: Math.floor(Date.now() / 1000) + 86400 * 30, // 30 days from now
47
+ priority: 1,
48
+ },
49
+ });
50
+
51
+ console.log("Created milestone object");
52
+
53
+ // Function to attest a milestone directly to specific grant UIDs
54
+ async function attestMilestoneToSpecificGrants(
55
+ milestoneObj: Milestone,
56
+ grantIds: Hex[],
57
+ signerObj: SignerOrProvider
58
+ ) {
59
+ // Create a payload for each grant
60
+ const allPayloads: any[] = [];
61
+
62
+ // For each grant UID, create a milestone attestation with that grant as the reference
63
+ for (const grantUID of grantIds) {
64
+ // Create a new milestone that references this specific grant
65
+ const grantMilestone = new Milestone({
66
+ schema: milestoneObj.schema,
67
+ recipient: milestoneObj.recipient,
68
+ data: milestoneObj.data,
69
+ refUID: grantUID, // Point directly to this grant's UID
70
+ });
71
+
72
+ // Generate the payload for this grant
73
+ const payload = await grantMilestone.multiAttestPayload();
74
+ // Add each item from payload to allPayloads
75
+ payload.forEach((item) => allPayloads.push(item));
76
+ }
77
+
78
+ // Execute all attestations in a single transaction
79
+ const { uids, tx } = await GapContract.multiAttest(
80
+ signerObj,
81
+ allPayloads.map((p) => p[1]),
82
+ (status) => console.log(`Attestation status: ${status}`)
83
+ );
84
+
85
+ return { uids, tx };
86
+ }
87
+
88
+ // Attest the milestone to your specific grant UIDs
89
+ const result = await attestMilestoneToSpecificGrants(
90
+ milestone,
91
+ grantUIDs,
92
+ signer
93
+ );
94
+
95
+ console.log("Milestone attested to all grants successfully");
96
+ console.log("UIDs:", result.uids);
97
+
98
+ // If you need to complete the milestone for all grants
99
+ if (result.uids.length > 0) {
100
+ // Complete all the newly created milestones at once
101
+ const completionResult = await milestone.approveMultipleGrants(
102
+ signer,
103
+ result.uids, // UIDs of the milestones we just created
104
+ {
105
+ reason: "Milestone completed for all grants",
106
+ proofOfWork: "https://example.com/proof",
107
+ },
108
+ (status) => console.log(`Completion status: ${status}`)
109
+ );
110
+
111
+ console.log("Milestones completed for all grants");
112
+ console.log("Completion UIDs:", completionResult.uids);
113
+ }
114
+ } catch (error) {
115
+ console.error("Error:", error);
116
+ }
117
+ }
118
+
119
+ // Execute the script
120
+ main()
121
+ .then(() => process.exit(0))
122
+ .catch((error) => {
123
+ console.error(error);
124
+ process.exit(1);
125
+ });
@@ -0,0 +1,13 @@
1
+ export interface IGrantUpdateBase {
2
+ title: string;
3
+ text: string;
4
+ proofOfWork?: string;
5
+ completionPercentage?: string;
6
+ pitchDeck?: string;
7
+ demoVideo?: string;
8
+ trackExplanations?: Array<{
9
+ trackId: string;
10
+ trackName: string;
11
+ explanation: string;
12
+ }>;
13
+ }
package/core/types.ts ADDED
@@ -0,0 +1,224 @@
1
+ import { BytesLike } from "ethers";
2
+ import {
3
+ AttestationRequestData,
4
+ EAS,
5
+ MultiAttestationRequest,
6
+ SchemaItem,
7
+ } from "@ethereum-attestation-service/eas-sdk";
8
+ // import { SignerOrProvider as EASSigner } from '@ethereum-attestation-service/eas-sdk/dist/transaction';
9
+ import { Attestation, GAP } from "./class";
10
+ import { Fetcher } from "./class/Fetcher";
11
+ export type Hex = `0x${string}`;
12
+
13
+ export type SignerOrProvider = any;
14
+ // EASSigner & {
15
+ // address?: Hex;
16
+ // _address?: Hex;
17
+ // getAddress?: () => Promise<Hex>;
18
+ // };
19
+
20
+ export interface SchemaInterface<T extends string = string> {
21
+ name: string;
22
+ schema: SchemaItem[];
23
+ references?: T;
24
+ uid: Hex;
25
+ revocable?: boolean;
26
+ oldSchemas?: { uid: string; raw: SchemaItem[] }[];
27
+ }
28
+
29
+ export interface MultiRevokeArgs {
30
+ uid: Hex;
31
+ schemaId: Hex;
32
+ }
33
+
34
+ export type CallbackStatus = "pending" | "confirmed" | "preparing";
35
+
36
+ export interface AttestArgs<T = unknown> {
37
+ to: Hex;
38
+ data: T;
39
+ refUID?: Hex;
40
+ signer: SignerOrProvider;
41
+ callback?: (status: CallbackStatus) => void;
42
+ }
43
+
44
+ export type TSchemaName =
45
+ | "Community"
46
+ | "CommunityDetails"
47
+ | "Grant"
48
+ | "GrantDetails"
49
+ | "GrantVerified"
50
+ | "MemberOf"
51
+ | "MemberDetails"
52
+ | "Milestone"
53
+ | "MilestoneCompleted"
54
+ | "MilestoneApproved"
55
+ | "Project"
56
+ | "ProjectDetails"
57
+ | "Details"
58
+ | "ProjectImpact"
59
+ | "ProjectUpdate"
60
+ | "ProjectUpdateStatus"
61
+ | "ProjectPointer"
62
+ | "GrantUpdate"
63
+ | "GrantUpdateStatus"
64
+ | "ProjectEndorsement"
65
+ | "ProjectMilestone"
66
+ | "ProjectMilestoneStatus"
67
+ | "ContributorProfile";
68
+
69
+ export type TResolvedSchemaNames =
70
+ | "Community"
71
+ | "Grant"
72
+ | "GrantVerified"
73
+ | "MemberOf"
74
+ | "MilestoneCompleted"
75
+ | "MilestoneApproved"
76
+ | "Project"
77
+ | "Details"
78
+ | "ProjectUpdateStatus"
79
+ | "GrantUpdateStatus"
80
+ | "ProjectUpdateStatus"
81
+ | "ProjectMilestoneStatus"
82
+ | "ContributorProfile";
83
+
84
+ export type TExternalLink =
85
+ | "twitter"
86
+ | "github"
87
+ | "website"
88
+ | "linkedin"
89
+ | "discord"
90
+ | "pitchDeck"
91
+ | "demoVideo"
92
+ | "farcaster"
93
+ | "custom";
94
+
95
+ export type TNetwork =
96
+ // | "mainnet"
97
+ // | "base-goerli"
98
+ | "optimism"
99
+ | "celo"
100
+ | "optimism-sepolia"
101
+ | "arbitrum"
102
+ | "sepolia"
103
+ | "sei"
104
+ | "sei-testnet"
105
+ | "base-sepolia"
106
+ | "lisk"
107
+ | "scroll";
108
+
109
+ /**
110
+ * Generic GAP Facade interface.
111
+ * This supplies the GAP class with the necessary properties.
112
+ */
113
+ export abstract class Facade {
114
+ abstract readonly network: TNetwork;
115
+ abstract readonly schemas: SchemaInterface[];
116
+ abstract readonly fetch: Fetcher;
117
+ protected _eas: EAS;
118
+
119
+ get eas() {
120
+ return this._eas;
121
+ }
122
+ }
123
+
124
+ export interface RawAttestationPayload {
125
+ schema: Hex;
126
+ data: {
127
+ payload: AttestationRequestData;
128
+ raw: AttestationRequestData;
129
+ };
130
+ }
131
+
132
+ export interface RawMultiAttestPayload {
133
+ payload: MultiAttestData;
134
+ raw: MultiAttestData;
135
+ }
136
+
137
+ export interface MultiAttestData {
138
+ uid?: Hex;
139
+ multiRequest: MultiAttestationRequest;
140
+ refIdx: number;
141
+ }
142
+
143
+ export type MultiAttestPayload = [Attestation, RawMultiAttestPayload][];
144
+
145
+ export interface EASNetworkConfig {
146
+ url: string;
147
+ rpcUrl: string;
148
+ chainId: number;
149
+ contracts: {
150
+ eas: Hex;
151
+ schema: Hex;
152
+ multicall: Hex;
153
+ projectResolver: Hex;
154
+ communityResolver: Hex;
155
+ donations: Hex;
156
+ airdropNFT: Hex;
157
+ };
158
+ /**
159
+ * A tuple containing the schema name and it's UID for that network
160
+ */
161
+ schemas: Record<TResolvedSchemaNames, Hex>;
162
+ oldSchemas?: {
163
+ name: string;
164
+ uid: string;
165
+ raw: SchemaItem[];
166
+ }[];
167
+ }
168
+
169
+ export type IGapSchema = SchemaInterface<TSchemaName>;
170
+
171
+ export type JSONStr = string;
172
+
173
+ export interface Schemata {
174
+ uid: Hex;
175
+ schema: string;
176
+ }
177
+
178
+ export interface SchemataRes {
179
+ schemata: Schemata[];
180
+ }
181
+
182
+ export interface IAttestation {
183
+ uid: Hex;
184
+ attester: Hex;
185
+ data: BytesLike;
186
+ decodedDataJson: JSONStr;
187
+ recipient: Hex;
188
+ revoked: boolean;
189
+ createdAt: number;
190
+ refUID?: Hex;
191
+ isOffchain: boolean;
192
+ revocable: boolean;
193
+ revocationTime?: number;
194
+ schemaId: Hex;
195
+ }
196
+
197
+ export interface AttestationRes {
198
+ attestation: IAttestation;
199
+ }
200
+
201
+ export interface AttestationsRes {
202
+ attestations: IAttestation[];
203
+ }
204
+
205
+ export interface SchemaRes {
206
+ schema: {
207
+ attestations: IAttestation[];
208
+ };
209
+ }
210
+
211
+ /**
212
+ * Valid remote storage types
213
+ */
214
+ export const enum STORAGE_TYPE {
215
+ IPFS = 0,
216
+ ARWEAVE = 1,
217
+ SWARM = 2,
218
+ UNKNOWN = 3,
219
+ }
220
+
221
+ export type TRemoteStorageOutput<T = unknown> = {
222
+ hash: T;
223
+ storageType: number;
224
+ };