@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.
- package/.cursorrules +43 -0
- package/core/abi/AirdropNFT.json +1 -1
- package/core/abi/Allo.json +860 -860
- package/core/abi/AlloRegistry.json +578 -578
- package/core/abi/CommunityResolverABI.json +506 -506
- package/core/abi/Donations.json +251 -251
- package/core/abi/EAS.json +1 -1
- package/core/abi/MultiAttester.json +746 -746
- package/core/abi/ProjectResolver.json +574 -574
- package/core/abi/SchemaRegistry.json +1 -1
- package/core/abi/index.ts +21 -0
- package/core/class/AllGapSchemas.ts +21 -0
- package/core/class/Attestation.ts +429 -0
- package/core/class/Fetcher.ts +224 -0
- package/core/class/GAP.ts +481 -0
- package/core/class/GapSchema.ts +93 -0
- package/core/class/Gelato/{Gelato.js → Gelato.ts} +23 -0
- package/core/class/GrantProgramRegistry/Allo.ts +188 -0
- package/core/class/GrantProgramRegistry/AlloRegistry.ts +101 -0
- package/core/class/GraphQL/AxiosGQL.ts +29 -0
- package/core/class/GraphQL/EASClient.ts +34 -0
- package/core/class/GraphQL/GapEasClient.ts +869 -0
- package/core/class/Schema.ts +659 -0
- package/core/class/SchemaError.ts +42 -0
- package/core/class/contract/GapContract.ts +457 -0
- package/core/class/entities/Community.ts +148 -0
- package/core/class/entities/ContributorProfile.ts +108 -0
- package/core/class/entities/Grant.ts +321 -0
- package/core/class/entities/GrantUpdate.ts +187 -0
- package/core/class/entities/MemberOf.ts +52 -0
- package/core/class/entities/Milestone.ts +898 -0
- package/core/class/entities/Project.ts +672 -0
- package/core/class/entities/ProjectImpact.ts +170 -0
- package/core/class/entities/ProjectMilestone.ts +254 -0
- package/core/class/entities/ProjectPointer.ts +39 -0
- package/core/class/entities/ProjectUpdate.ts +176 -0
- package/core/class/entities/Track.ts +32 -0
- package/core/class/karma-indexer/GapIndexerClient.ts +383 -0
- package/core/class/karma-indexer/api/GapIndexerApi.ts +446 -0
- package/core/class/karma-indexer/api/types.ts +313 -0
- package/core/class/remote-storage/IpfsStorage.ts +76 -0
- package/core/class/remote-storage/RemoteStorage.ts +65 -0
- package/core/class/types/allo.ts +93 -0
- package/core/class/types/attestations.ts +223 -0
- package/core/consts.ts +775 -0
- package/core/scripts/create-grant.ts +102 -0
- package/core/scripts/create-program.ts +43 -0
- package/core/scripts/create-schemas.ts +65 -0
- package/core/scripts/deploy.ts +65 -0
- package/core/scripts/index.ts +1 -0
- package/core/scripts/milestone-multi-grants.ts +125 -0
- package/core/shared/types.ts +13 -0
- package/core/types.ts +224 -0
- package/core/utils/gelato/send-gelato-txn.ts +114 -0
- package/core/utils/gelato/sponsor-handler.ts +77 -0
- package/core/utils/gelato/watch-gelato-txn.ts +67 -0
- package/core/utils/get-date.ts +3 -0
- package/core/utils/get-ipfs-data.ts +13 -0
- package/core/utils/get-web3-provider.ts +18 -0
- package/core/utils/gql-queries.ts +133 -0
- package/core/utils/map-filter.ts +21 -0
- package/core/utils/serialize-bigint.ts +7 -0
- package/core/utils/to-unix.ts +18 -0
- package/create-community-example.ts +119 -0
- package/csv-upload/README.md +74 -0
- package/csv-upload/config.ts +41 -0
- package/csv-upload/example.csv +2 -0
- package/csv-upload/keys.example.json +8 -0
- package/csv-upload/scripts/run.ts +417 -0
- package/csv-upload/types.ts +39 -0
- package/docs/.gitkeep +0 -0
- package/docs/images/attestation-architecture.png +0 -0
- package/docs/images/dfd-get-projects.png +0 -0
- package/gap-schema.yaml +155 -0
- package/milestone-workflow-example.ts +353 -0
- package/package.json +45 -39
- package/readme.md +872 -0
- package/schemas/.gitkeep +0 -0
- package/schemas/GAP-schemas-1692135812877.json +33 -0
- package/test-file-indexer-api.ts +25 -0
- package/tsconfig.json +26 -0
- package/core/abi/index.d.ts +0 -1114
- package/core/abi/index.js +0 -26
- package/core/class/AllGapSchemas.d.ts +0 -9
- package/core/class/AllGapSchemas.js +0 -19
- package/core/class/Attestation.d.ts +0 -173
- package/core/class/Attestation.js +0 -333
- package/core/class/Fetcher.d.ts +0 -175
- package/core/class/Fetcher.js +0 -13
- package/core/class/GAP.d.ts +0 -254
- package/core/class/GAP.js +0 -289
- package/core/class/GapSchema.d.ts +0 -34
- package/core/class/GapSchema.js +0 -62
- package/core/class/GrantProgramRegistry/Allo.d.ts +0 -17
- package/core/class/GrantProgramRegistry/Allo.js +0 -137
- package/core/class/GrantProgramRegistry/AlloRegistry.d.ts +0 -15
- package/core/class/GrantProgramRegistry/AlloRegistry.js +0 -70
- package/core/class/GraphQL/AxiosGQL.d.ts +0 -6
- package/core/class/GraphQL/AxiosGQL.js +0 -25
- package/core/class/GraphQL/EASClient.d.ts +0 -16
- package/core/class/GraphQL/EASClient.js +0 -26
- package/core/class/GraphQL/GapEasClient.d.ts +0 -71
- package/core/class/GraphQL/GapEasClient.js +0 -451
- package/core/class/GraphQL/index.js +0 -19
- package/core/class/Schema.d.ts +0 -233
- package/core/class/Schema.js +0 -488
- package/core/class/SchemaError.d.ts +0 -30
- package/core/class/SchemaError.js +0 -39
- package/core/class/contract/GapContract.d.ts +0 -102
- package/core/class/contract/GapContract.js +0 -285
- package/core/class/entities/Community.d.ts +0 -34
- package/core/class/entities/Community.js +0 -109
- package/core/class/entities/ContributorProfile.d.ts +0 -41
- package/core/class/entities/ContributorProfile.js +0 -69
- package/core/class/entities/Grant.d.ts +0 -54
- package/core/class/entities/Grant.js +0 -223
- package/core/class/entities/GrantUpdate.d.ts +0 -40
- package/core/class/entities/GrantUpdate.js +0 -114
- package/core/class/entities/MemberOf.d.ts +0 -11
- package/core/class/entities/MemberOf.js +0 -33
- package/core/class/entities/Milestone.d.ts +0 -168
- package/core/class/entities/Milestone.js +0 -657
- package/core/class/entities/Project.d.ts +0 -92
- package/core/class/entities/Project.js +0 -418
- package/core/class/entities/ProjectImpact.d.ts +0 -50
- package/core/class/entities/ProjectImpact.js +0 -112
- package/core/class/entities/ProjectMilestone.d.ts +0 -60
- package/core/class/entities/ProjectMilestone.js +0 -174
- package/core/class/entities/ProjectPointer.d.ts +0 -12
- package/core/class/entities/ProjectPointer.js +0 -22
- package/core/class/entities/ProjectUpdate.d.ts +0 -50
- package/core/class/entities/ProjectUpdate.js +0 -110
- package/core/class/entities/Track.d.ts +0 -16
- package/core/class/entities/Track.js +0 -21
- package/core/class/entities/index.js +0 -26
- package/core/class/index.js +0 -26
- package/core/class/karma-indexer/GapIndexerClient.d.ts +0 -66
- package/core/class/karma-indexer/GapIndexerClient.js +0 -207
- package/core/class/karma-indexer/api/GapIndexerApi.d.ts +0 -73
- package/core/class/karma-indexer/api/GapIndexerApi.js +0 -256
- package/core/class/karma-indexer/api/types.d.ts +0 -295
- package/core/class/karma-indexer/api/types.js +0 -2
- package/core/class/remote-storage/IpfsStorage.d.ts +0 -23
- package/core/class/remote-storage/IpfsStorage.js +0 -56
- package/core/class/remote-storage/RemoteStorage.d.ts +0 -41
- package/core/class/remote-storage/RemoteStorage.js +0 -38
- package/core/class/types/allo.d.ts +0 -78
- package/core/class/types/allo.js +0 -2
- package/core/class/types/attestations.d.ts +0 -168
- package/core/class/types/attestations.js +0 -66
- package/core/consts.d.ts +0 -48
- package/core/consts.js +0 -641
- package/core/index.js +0 -24
- package/core/shared/types.d.ts +0 -6
- package/core/shared/types.js +0 -2
- package/core/types.d.ts +0 -131
- package/core/types.js +0 -13
- package/core/utils/gelato/index.js +0 -19
- package/core/utils/gelato/send-gelato-txn.d.ts +0 -55
- package/core/utils/gelato/send-gelato-txn.js +0 -100
- package/core/utils/gelato/sponsor-handler.d.ts +0 -9
- package/core/utils/gelato/sponsor-handler.js +0 -60
- package/core/utils/gelato/watch-gelato-txn.d.ts +0 -7
- package/core/utils/gelato/watch-gelato-txn.js +0 -63
- package/core/utils/get-date.d.ts +0 -1
- package/core/utils/get-date.js +0 -7
- package/core/utils/get-ipfs-data.d.ts +0 -1
- package/core/utils/get-ipfs-data.js +0 -20
- package/core/utils/get-web3-provider.d.ts +0 -2
- package/core/utils/get-web3-provider.js +0 -18
- package/core/utils/gql-queries.d.ts +0 -12
- package/core/utils/gql-queries.js +0 -90
- package/core/utils/index.js +0 -23
- package/core/utils/map-filter.d.ts +0 -8
- package/core/utils/map-filter.js +0 -20
- package/core/utils/serialize-bigint.d.ts +0 -1
- package/core/utils/serialize-bigint.js +0 -8
- package/core/utils/to-unix.d.ts +0 -1
- package/core/utils/to-unix.js +0 -25
- package/index.js +0 -17
- /package/core/class/GraphQL/{index.d.ts → index.ts} +0 -0
- /package/core/class/entities/{index.d.ts → index.ts} +0 -0
- /package/core/class/{index.d.ts → index.ts} +0 -0
- /package/core/{index.d.ts → index.ts} +0 -0
- /package/core/utils/gelato/{index.d.ts → index.ts} +0 -0
- /package/core/utils/{index.d.ts → index.ts} +0 -0
- /package/{core/class/Gelato/Gelato.d.ts → csv-upload/.gitkeep} +0 -0
- /package/{index.d.ts → index.ts} +0 -0
|
@@ -0,0 +1,353 @@
|
|
|
1
|
+
import { ethers } from "ethers";
|
|
2
|
+
import { GAP } from "./core/class/GAP";
|
|
3
|
+
import { GapIndexerClient } from "./core/class/karma-indexer/GapIndexerClient";
|
|
4
|
+
import {
|
|
5
|
+
Hex,
|
|
6
|
+
MultiAttestPayload,
|
|
7
|
+
MultiRevokeArgs,
|
|
8
|
+
SignerOrProvider,
|
|
9
|
+
} from "./core/types";
|
|
10
|
+
import { Milestone } from "./core/class/entities/Milestone";
|
|
11
|
+
import { Grant } from "./core/class/entities/Grant";
|
|
12
|
+
import {
|
|
13
|
+
IMilestoneCompleted,
|
|
14
|
+
MilestoneCompleted,
|
|
15
|
+
} from "./core/class/types/attestations";
|
|
16
|
+
import { GapContract } from "./core/class/contract/GapContract";
|
|
17
|
+
|
|
18
|
+
// Configuration
|
|
19
|
+
const API_URL = "https://gapstagapi.karmahq.xyz";
|
|
20
|
+
const PROJECT_ID = "your-project-id-here"; // Replace with your actual project ID or slug
|
|
21
|
+
const RPC_URL = "your-rpc-url-here"; // Replace with your RPC URL
|
|
22
|
+
const PRIVATE_KEY = "your-private-key-here"; // Replace with your private key
|
|
23
|
+
|
|
24
|
+
async function main() {
|
|
25
|
+
try {
|
|
26
|
+
// Initialize provider and signer
|
|
27
|
+
const provider = new ethers.JsonRpcProvider(RPC_URL);
|
|
28
|
+
const signer = new ethers.Wallet(PRIVATE_KEY, provider);
|
|
29
|
+
const signerAddress = (await signer.getAddress()) as `0x${string}`;
|
|
30
|
+
|
|
31
|
+
console.log(`Using signer address: ${signerAddress}`);
|
|
32
|
+
|
|
33
|
+
// Initialize GAP SDK
|
|
34
|
+
const gap = new GAP({
|
|
35
|
+
globalSchemas: false,
|
|
36
|
+
network: "optimism-sepolia", // Change to your target network
|
|
37
|
+
apiClient: new GapIndexerClient(API_URL),
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
// 1. Fetch a project by ID or slug
|
|
41
|
+
console.log(`Fetching project: ${PROJECT_ID}`);
|
|
42
|
+
const project = await (PROJECT_ID.startsWith("0x")
|
|
43
|
+
? gap.fetch.projectById(PROJECT_ID as Hex)
|
|
44
|
+
: gap.fetch.projectBySlug(PROJECT_ID));
|
|
45
|
+
|
|
46
|
+
if (!project) {
|
|
47
|
+
throw new Error(`Project not found: ${PROJECT_ID}`);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
// Project may have details with title, or we can use UID
|
|
51
|
+
const projectName = project.details?.title || project.uid;
|
|
52
|
+
console.log(`Project found: ${projectName}`);
|
|
53
|
+
|
|
54
|
+
// 2. Fetch grants associated with the project
|
|
55
|
+
console.log("Fetching grants for the project...");
|
|
56
|
+
const grants = await gap.fetch.grantsFor([project], true);
|
|
57
|
+
|
|
58
|
+
if (!grants || grants.length === 0) {
|
|
59
|
+
throw new Error("No grants found for this project");
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
console.log(`Found ${grants.length} grants`);
|
|
63
|
+
|
|
64
|
+
// Get grant UIDs for milestone creation
|
|
65
|
+
const grantUIDs = grants.map((grant) => grant.uid);
|
|
66
|
+
|
|
67
|
+
// 3. Create milestones for all grants in batches - using approach that works in frontend
|
|
68
|
+
const milestones = [
|
|
69
|
+
{
|
|
70
|
+
title: "123 123 123",
|
|
71
|
+
description: "Complete initial research and planning",
|
|
72
|
+
endsAt: Math.floor(Date.now() / 1000) + 86400 * 14, // 14 days from now
|
|
73
|
+
priority: 1,
|
|
74
|
+
},
|
|
75
|
+
{
|
|
76
|
+
title: "Development Phase",
|
|
77
|
+
description: "Implement core functionality",
|
|
78
|
+
endsAt: Math.floor(Date.now() / 1000) + 86400 * 30, // 30 days from now
|
|
79
|
+
priority: 2,
|
|
80
|
+
},
|
|
81
|
+
{
|
|
82
|
+
title: "Testing Phase",
|
|
83
|
+
description: "Comprehensive testing and bug fixes",
|
|
84
|
+
endsAt: Math.floor(Date.now() / 1000) + 86400 * 45, // 45 days from now
|
|
85
|
+
priority: 3,
|
|
86
|
+
},
|
|
87
|
+
{
|
|
88
|
+
title: "Fasd Phase",
|
|
89
|
+
description: "Implement core functionality",
|
|
90
|
+
endsAt: Math.floor(Date.now() / 1000) + 86400 * 30, // 30 days from now
|
|
91
|
+
priority: 2,
|
|
92
|
+
},
|
|
93
|
+
{
|
|
94
|
+
title: "FEFSAD Phase",
|
|
95
|
+
description: "Comprehensive testing and bug fixes",
|
|
96
|
+
endsAt: Math.floor(Date.now() / 1000) + 86400 * 45, // 45 days from now
|
|
97
|
+
priority: 3,
|
|
98
|
+
},
|
|
99
|
+
{
|
|
100
|
+
title: "XCZCZXlopment Phase",
|
|
101
|
+
description: "Implement core functionality",
|
|
102
|
+
endsAt: Math.floor(Date.now() / 1000) + 86400 * 30, // 30 days from now
|
|
103
|
+
priority: 2,
|
|
104
|
+
},
|
|
105
|
+
{
|
|
106
|
+
title: "ADAqewq123 Phase",
|
|
107
|
+
description: "Comprehensive testing and bug fixes",
|
|
108
|
+
endsAt: Math.floor(Date.now() / 1000) + 86400 * 45, // 45 days from now
|
|
109
|
+
priority: 3,
|
|
110
|
+
},
|
|
111
|
+
];
|
|
112
|
+
|
|
113
|
+
console.log("Creating milestones for all grants in batches...");
|
|
114
|
+
|
|
115
|
+
// Array to store created milestones for completion
|
|
116
|
+
const createdMilestones: { milestone: Milestone; uids: Hex[] }[] = [];
|
|
117
|
+
|
|
118
|
+
// Process each milestone type and create it for all grants at once
|
|
119
|
+
for (const milestoneData of milestones) {
|
|
120
|
+
try {
|
|
121
|
+
console.log(
|
|
122
|
+
`Creating milestone: ${milestoneData.title} for all grants`
|
|
123
|
+
);
|
|
124
|
+
|
|
125
|
+
// Create a milestone template
|
|
126
|
+
const milestone = new Milestone({
|
|
127
|
+
schema: gap.findSchema("Milestone"),
|
|
128
|
+
recipient: signerAddress,
|
|
129
|
+
data: milestoneData,
|
|
130
|
+
// No refUID here - we'll attest to multiple grants
|
|
131
|
+
});
|
|
132
|
+
|
|
133
|
+
console.log(`Milestone schema UID: ${milestone.schema.uid}`);
|
|
134
|
+
console.log(`Grant UIDs: ${JSON.stringify(grantUIDs)}`);
|
|
135
|
+
|
|
136
|
+
console.log(`Attesting to ${grantUIDs.length} grants...`);
|
|
137
|
+
|
|
138
|
+
// Use the enhanced attestToMultipleGrants that now accepts grant UIDs directly
|
|
139
|
+
const attestResult = await milestone.attestToMultipleGrants(
|
|
140
|
+
signer,
|
|
141
|
+
grantUIDs, // Pass grant UIDs directly
|
|
142
|
+
(status) => console.log(`Attestation status: ${status}`)
|
|
143
|
+
);
|
|
144
|
+
|
|
145
|
+
console.log(
|
|
146
|
+
`Successfully attested milestone to ${attestResult.uids.length} grants. UIDs:`,
|
|
147
|
+
attestResult.uids
|
|
148
|
+
);
|
|
149
|
+
|
|
150
|
+
// Store the milestone and UIDs for later completion
|
|
151
|
+
createdMilestones.push({
|
|
152
|
+
milestone,
|
|
153
|
+
uids: attestResult.uids,
|
|
154
|
+
});
|
|
155
|
+
} catch (error) {
|
|
156
|
+
console.error(
|
|
157
|
+
`Error creating milestone "${milestoneData.title}" for all grants:`,
|
|
158
|
+
error
|
|
159
|
+
);
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
// 4. Complete all milestones in batches
|
|
164
|
+
console.log("Completing milestones in batches...");
|
|
165
|
+
|
|
166
|
+
for (const { milestone, uids } of createdMilestones) {
|
|
167
|
+
try {
|
|
168
|
+
console.log(
|
|
169
|
+
`Completing milestone: ${milestone.title} across all grants...`
|
|
170
|
+
);
|
|
171
|
+
|
|
172
|
+
const completionData: IMilestoneCompleted = {
|
|
173
|
+
type: "completed",
|
|
174
|
+
reason: "Work completed successfully",
|
|
175
|
+
proofOfWork: "https://github.com/your-org/your-repo/pull/123", // Replace with actual proof of work
|
|
176
|
+
};
|
|
177
|
+
|
|
178
|
+
// Now we can use the enhanced completeForMultipleGrants method directly with UIDs
|
|
179
|
+
console.log(
|
|
180
|
+
`Completing ${uids.length} milestones with completeForMultipleGrants...`
|
|
181
|
+
);
|
|
182
|
+
|
|
183
|
+
// Complete all milestones with a single method call
|
|
184
|
+
const completeResult = await milestone.completeForMultipleGrants(
|
|
185
|
+
signer,
|
|
186
|
+
uids, // Pass milestone UIDs directly - will be detected automatically
|
|
187
|
+
completionData,
|
|
188
|
+
(status) => console.log(`Completion status: ${status}`)
|
|
189
|
+
);
|
|
190
|
+
|
|
191
|
+
console.log(
|
|
192
|
+
`Successfully completed milestones. UIDs:`,
|
|
193
|
+
completeResult.uids
|
|
194
|
+
);
|
|
195
|
+
|
|
196
|
+
// 5. (Optional) Demonstrate milestone revocation
|
|
197
|
+
console.log(
|
|
198
|
+
"Demonstrating milestone revocation using improved method..."
|
|
199
|
+
);
|
|
200
|
+
|
|
201
|
+
console.log(`Milestone UIDs to revoke: ${JSON.stringify(uids)}`);
|
|
202
|
+
|
|
203
|
+
// Get the milestone schema
|
|
204
|
+
const milestoneSchema = gap.findSchema("Milestone");
|
|
205
|
+
console.log(`Milestone schema UID: ${milestoneSchema.uid}`);
|
|
206
|
+
|
|
207
|
+
// Prepare the revocation arguments
|
|
208
|
+
const revocationArgs: MultiRevokeArgs[] = uids.map((uid) => ({
|
|
209
|
+
schemaId: milestoneSchema.uid,
|
|
210
|
+
uid,
|
|
211
|
+
}));
|
|
212
|
+
|
|
213
|
+
console.log(revocationArgs);
|
|
214
|
+
// Use the improved revokeMultipleAttestations method
|
|
215
|
+
const revokeResult = await milestone.revokeMultipleAttestations(
|
|
216
|
+
signer,
|
|
217
|
+
revocationArgs,
|
|
218
|
+
(status) => console.log(`Revocation status: ${status}`)
|
|
219
|
+
);
|
|
220
|
+
|
|
221
|
+
console.log(
|
|
222
|
+
`Successfully revoked ${
|
|
223
|
+
uids.length
|
|
224
|
+
} milestone attestations. Transaction hash: ${
|
|
225
|
+
revokeResult.tx[0].hash || "unknown"
|
|
226
|
+
}`
|
|
227
|
+
);
|
|
228
|
+
} catch (error) {
|
|
229
|
+
console.error(
|
|
230
|
+
`Error processing milestone "${milestone.title}":`,
|
|
231
|
+
error
|
|
232
|
+
);
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
console.log("All milestone operations completed!");
|
|
237
|
+
} catch (error) {
|
|
238
|
+
console.error("Error in workflow:", error);
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
async function deleteMilestones(milestoneUIDs: Hex[]) {
|
|
242
|
+
try {
|
|
243
|
+
// Initialize provider and signer
|
|
244
|
+
const provider = new ethers.JsonRpcProvider(RPC_URL);
|
|
245
|
+
const signer = new ethers.Wallet(PRIVATE_KEY, provider);
|
|
246
|
+
const signerAddress = (await signer.getAddress()) as `0x${string}`;
|
|
247
|
+
|
|
248
|
+
console.log(`Using signer address: ${signerAddress}`);
|
|
249
|
+
|
|
250
|
+
// Initialize GAP SDK
|
|
251
|
+
const gap = new GAP({
|
|
252
|
+
globalSchemas: false,
|
|
253
|
+
network: "optimism-sepolia", // Change to your target network
|
|
254
|
+
apiClient: new GapIndexerClient(API_URL),
|
|
255
|
+
});
|
|
256
|
+
|
|
257
|
+
// 1. Fetch a project by ID or slug
|
|
258
|
+
console.log(`Fetching project: ${PROJECT_ID}`);
|
|
259
|
+
const project = await (PROJECT_ID.startsWith("0x")
|
|
260
|
+
? gap.fetch.projectById(PROJECT_ID as Hex)
|
|
261
|
+
: gap.fetch.projectBySlug(PROJECT_ID));
|
|
262
|
+
|
|
263
|
+
if (!project) {
|
|
264
|
+
throw new Error(`Project not found: ${PROJECT_ID}`);
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
// Project may have details with title, or we can use UID
|
|
268
|
+
const projectName = project.details?.title || project.uid;
|
|
269
|
+
console.log(`Project found: ${projectName}`);
|
|
270
|
+
|
|
271
|
+
// 2. Fetch grants associated with the project
|
|
272
|
+
console.log("Fetching grants for the project...");
|
|
273
|
+
const grants = await gap.fetch.grantsFor([project], true);
|
|
274
|
+
|
|
275
|
+
if (!grants || grants.length === 0) {
|
|
276
|
+
throw new Error("No grants found for this project");
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
const milestoneInstances = grants
|
|
280
|
+
.filter((grant) => grant.milestones.length > 0)
|
|
281
|
+
.flatMap((grant) => grant.milestones)
|
|
282
|
+
.filter((milestone) => milestoneUIDs.includes(milestone.uid));
|
|
283
|
+
|
|
284
|
+
const groupedByChain = milestoneInstances.reduce(
|
|
285
|
+
(acc, instance) => {
|
|
286
|
+
const chainId = instance.chainID;
|
|
287
|
+
if (!acc[chainId]) {
|
|
288
|
+
acc[chainId] = [];
|
|
289
|
+
}
|
|
290
|
+
acc[chainId].push(instance);
|
|
291
|
+
return acc;
|
|
292
|
+
},
|
|
293
|
+
{} as Record<number, Milestone[]>
|
|
294
|
+
);
|
|
295
|
+
const arrayOfChains = Object.keys(groupedByChain).map(Number);
|
|
296
|
+
|
|
297
|
+
for (const chainId of arrayOfChains) {
|
|
298
|
+
const firstInstance = groupedByChain[chainId][0];
|
|
299
|
+
try {
|
|
300
|
+
console.log(
|
|
301
|
+
"Demonstrating milestone revocation using improved method..."
|
|
302
|
+
);
|
|
303
|
+
|
|
304
|
+
// Get the milestone schema
|
|
305
|
+
const milestoneSchema = gap.findSchema("Milestone");
|
|
306
|
+
console.log(`Milestone schema UID: ${milestoneSchema.uid}`);
|
|
307
|
+
|
|
308
|
+
// Prepare the revocation arguments
|
|
309
|
+
const revocationArgs: MultiRevokeArgs[] = milestoneUIDs.map((uid) => ({
|
|
310
|
+
schemaId: milestoneSchema.uid,
|
|
311
|
+
uid,
|
|
312
|
+
}));
|
|
313
|
+
|
|
314
|
+
console.log(revocationArgs);
|
|
315
|
+
// Use the improved revokeMultipleAttestations method
|
|
316
|
+
const revokeResult = await firstInstance.revokeMultipleAttestations(
|
|
317
|
+
signer,
|
|
318
|
+
revocationArgs,
|
|
319
|
+
(status) => console.log(`Revocation status: ${status}`)
|
|
320
|
+
);
|
|
321
|
+
|
|
322
|
+
console.log(
|
|
323
|
+
`Successfully revoked ${
|
|
324
|
+
revokeResult.tx.length
|
|
325
|
+
} milestone attestations. Transaction hash: ${
|
|
326
|
+
revokeResult.tx[0].hash || "unknown"
|
|
327
|
+
}`
|
|
328
|
+
);
|
|
329
|
+
} catch (error) {
|
|
330
|
+
console.error(
|
|
331
|
+
`Error processing milestone "${firstInstance.title}":`,
|
|
332
|
+
error
|
|
333
|
+
);
|
|
334
|
+
}
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
console.log("All milestone operations completed!");
|
|
338
|
+
} catch (error) {
|
|
339
|
+
console.error("Error in workflow:", error);
|
|
340
|
+
}
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
// Run the script
|
|
344
|
+
main()
|
|
345
|
+
.then(() => process.exit(0))
|
|
346
|
+
.catch((error) => {
|
|
347
|
+
console.error(error);
|
|
348
|
+
process.exit(1);
|
|
349
|
+
});
|
|
350
|
+
// deleteMilestones([
|
|
351
|
+
// "0x1b78c2e7babceddd4c23cd7c6e50e513a0bc265a4d2c6f6b278189ca6ab17cbd",
|
|
352
|
+
// "0x7e0b1712fcee46f36a32ba826233beba9cb79c163500e93855ee440a141512f8",
|
|
353
|
+
// ]);
|
package/package.json
CHANGED
|
@@ -1,41 +1,47 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
"
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
2
|
+
"name": "@show-karma/karma-gap-sdk",
|
|
3
|
+
"publishConfig": {
|
|
4
|
+
"access": "public"
|
|
5
|
+
},
|
|
6
|
+
"version": "0.4.16",
|
|
7
|
+
"description": "Simple and easy interface between EAS and Karma GAP.",
|
|
8
|
+
"main": "./index.js",
|
|
9
|
+
"author": "KarmaHQ",
|
|
10
|
+
"license": "MIT",
|
|
11
|
+
"private": false,
|
|
12
|
+
"repository": {
|
|
13
|
+
"url": "git+https://github.com/show-karma/karma-gap-sdk.git",
|
|
14
|
+
"type": "git"
|
|
15
|
+
},
|
|
16
|
+
"scripts": {
|
|
17
|
+
"deploy": "npx ts-node ./core/scripts/deploy.ts",
|
|
18
|
+
"csv-upload": "npx ts-node ./csv-upload/scripts/run.ts",
|
|
19
|
+
"test-file": "npx ts-node ./test-file-indexer-api.ts",
|
|
20
|
+
"test-milestone": "npx ts-node ./milestone-workflow-example.ts",
|
|
21
|
+
"create-community": "npx ts-node ./create-community-example.ts",
|
|
22
|
+
"publish-npm": "npm version patch && tsc && cd .dist && npm publish --scope=@show-karma/karma-gap-sdk --access public"
|
|
23
|
+
},
|
|
24
|
+
"dependencies": {
|
|
25
|
+
"@allo-team/allo-v2-sdk": "^1.0.63",
|
|
26
|
+
"@ethereum-attestation-service/eas-sdk": "1.4.2",
|
|
27
|
+
"@gelatonetwork/relay-sdk": "^5.6.0",
|
|
28
|
+
"@types/sha256": "^0.2.0",
|
|
29
|
+
"axios": "^1.7.9",
|
|
30
|
+
"dotenv": "^17.2.3",
|
|
31
|
+
"ethers": "6.11.0",
|
|
32
|
+
"sha256": "^0.2.0",
|
|
33
|
+
"simple-ts-job-runner": "^1.0.12"
|
|
34
|
+
},
|
|
35
|
+
"overrides": {
|
|
36
|
+
"ws": ">=8.17.1",
|
|
37
|
+
"cookie": ">=0.7.0"
|
|
38
|
+
},
|
|
39
|
+
"devDependencies": {
|
|
40
|
+
"@types/node": "^20.5.0",
|
|
41
|
+
"eslint": "^8.47.0",
|
|
42
|
+
"fast-csv": "^4.3.6",
|
|
43
|
+
"husky": "^8.0.3",
|
|
44
|
+
"prettier": "^3.0.1",
|
|
45
|
+
"typescript": "^5.1.6"
|
|
46
|
+
}
|
|
41
47
|
}
|