@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.
- 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.d.ts +1114 -0
- package/core/abi/index.js +26 -0
- package/core/class/AllGapSchemas.d.ts +9 -0
- package/core/class/AllGapSchemas.js +19 -0
- package/core/class/Attestation.d.ts +173 -0
- package/core/class/Attestation.js +333 -0
- package/core/class/Fetcher.d.ts +175 -0
- package/core/class/Fetcher.js +13 -0
- package/core/class/GAP.d.ts +254 -0
- package/core/class/GAP.js +289 -0
- package/core/class/GapSchema.d.ts +34 -0
- package/core/class/GapSchema.js +62 -0
- package/core/class/Gelato/{Gelato.ts → Gelato.js} +0 -23
- package/core/class/GrantProgramRegistry/Allo.d.ts +17 -0
- package/core/class/GrantProgramRegistry/Allo.js +137 -0
- package/core/class/GrantProgramRegistry/AlloRegistry.d.ts +15 -0
- package/core/class/GrantProgramRegistry/AlloRegistry.js +70 -0
- package/core/class/GraphQL/AxiosGQL.d.ts +6 -0
- package/core/class/GraphQL/AxiosGQL.js +25 -0
- package/core/class/GraphQL/EASClient.d.ts +16 -0
- package/core/class/GraphQL/EASClient.js +26 -0
- package/core/class/GraphQL/GapEasClient.d.ts +71 -0
- package/core/class/GraphQL/GapEasClient.js +451 -0
- package/core/class/GraphQL/index.js +19 -0
- package/core/class/Schema.d.ts +233 -0
- package/core/class/Schema.js +490 -0
- package/core/class/SchemaError.d.ts +30 -0
- package/core/class/SchemaError.js +39 -0
- package/core/class/contract/GapContract.d.ts +102 -0
- package/core/class/contract/GapContract.js +285 -0
- package/core/class/entities/Community.d.ts +34 -0
- package/core/class/entities/Community.js +109 -0
- package/core/class/entities/ContributorProfile.d.ts +41 -0
- package/core/class/entities/ContributorProfile.js +69 -0
- package/core/class/entities/Grant.d.ts +54 -0
- package/core/class/entities/Grant.js +223 -0
- package/core/class/entities/GrantUpdate.d.ts +62 -0
- package/core/class/entities/GrantUpdate.js +114 -0
- package/core/class/entities/MemberOf.d.ts +11 -0
- package/core/class/entities/MemberOf.js +33 -0
- package/core/class/entities/Milestone.d.ts +168 -0
- package/core/class/entities/Milestone.js +657 -0
- package/core/class/entities/Project.d.ts +92 -0
- package/core/class/entities/Project.js +418 -0
- package/core/class/entities/ProjectImpact.d.ts +50 -0
- package/core/class/entities/ProjectImpact.js +112 -0
- package/core/class/entities/ProjectMilestone.d.ts +60 -0
- package/core/class/entities/ProjectMilestone.js +174 -0
- package/core/class/entities/ProjectPointer.d.ts +12 -0
- package/core/class/entities/ProjectPointer.js +22 -0
- package/core/class/entities/ProjectUpdate.d.ts +50 -0
- package/core/class/entities/ProjectUpdate.js +110 -0
- package/core/class/entities/Track.d.ts +16 -0
- package/core/class/entities/Track.js +21 -0
- package/core/class/entities/index.js +26 -0
- package/core/class/index.js +26 -0
- package/core/class/karma-indexer/GapIndexerClient.d.ts +66 -0
- package/core/class/karma-indexer/GapIndexerClient.js +207 -0
- package/core/class/karma-indexer/api/GapIndexerApi.d.ts +73 -0
- package/core/class/karma-indexer/api/GapIndexerApi.js +256 -0
- package/core/class/karma-indexer/api/types.d.ts +309 -0
- package/core/class/karma-indexer/api/types.js +2 -0
- package/core/class/remote-storage/IpfsStorage.d.ts +23 -0
- package/core/class/remote-storage/IpfsStorage.js +56 -0
- package/core/class/remote-storage/RemoteStorage.d.ts +41 -0
- package/core/class/remote-storage/RemoteStorage.js +38 -0
- package/core/class/types/allo.d.ts +78 -0
- package/core/class/types/allo.js +2 -0
- package/core/class/types/attestations.d.ts +173 -0
- package/core/class/types/attestations.js +66 -0
- package/core/consts.d.ts +50 -0
- package/core/consts.js +699 -0
- package/core/index.js +24 -0
- package/core/shared/types.d.ts +13 -0
- package/core/shared/types.js +2 -0
- package/core/types.d.ts +131 -0
- package/core/types.js +13 -0
- package/core/utils/gelato/index.js +19 -0
- package/core/utils/gelato/send-gelato-txn.d.ts +55 -0
- package/core/utils/gelato/send-gelato-txn.js +100 -0
- package/core/utils/gelato/sponsor-handler.d.ts +9 -0
- package/core/utils/gelato/sponsor-handler.js +60 -0
- package/core/utils/gelato/watch-gelato-txn.d.ts +7 -0
- package/core/utils/gelato/watch-gelato-txn.js +63 -0
- package/core/utils/get-date.d.ts +1 -0
- package/core/utils/get-date.js +7 -0
- package/core/utils/get-ipfs-data.d.ts +1 -0
- package/core/utils/get-ipfs-data.js +20 -0
- package/core/utils/get-web3-provider.d.ts +2 -0
- package/core/utils/get-web3-provider.js +18 -0
- package/core/utils/gql-queries.d.ts +12 -0
- package/core/utils/gql-queries.js +90 -0
- package/core/utils/index.js +23 -0
- package/core/utils/map-filter.d.ts +8 -0
- package/core/utils/map-filter.js +20 -0
- package/core/utils/serialize-bigint.d.ts +1 -0
- package/core/utils/serialize-bigint.js +8 -0
- package/core/utils/to-unix.d.ts +1 -0
- package/core/utils/to-unix.js +25 -0
- package/index.js +17 -0
- package/package.json +45 -45
- package/.cursorrules +0 -43
- package/core/abi/index.ts +0 -21
- package/core/class/AllGapSchemas.ts +0 -21
- package/core/class/Attestation.ts +0 -429
- package/core/class/Fetcher.ts +0 -224
- package/core/class/GAP.ts +0 -481
- package/core/class/GapSchema.ts +0 -93
- package/core/class/GrantProgramRegistry/Allo.ts +0 -188
- package/core/class/GrantProgramRegistry/AlloRegistry.ts +0 -101
- package/core/class/GraphQL/AxiosGQL.ts +0 -29
- package/core/class/GraphQL/EASClient.ts +0 -34
- package/core/class/GraphQL/GapEasClient.ts +0 -869
- package/core/class/Schema.ts +0 -659
- package/core/class/SchemaError.ts +0 -42
- package/core/class/contract/GapContract.ts +0 -457
- package/core/class/entities/Community.ts +0 -148
- package/core/class/entities/ContributorProfile.ts +0 -108
- package/core/class/entities/Grant.ts +0 -321
- package/core/class/entities/GrantUpdate.ts +0 -187
- package/core/class/entities/MemberOf.ts +0 -52
- package/core/class/entities/Milestone.ts +0 -898
- package/core/class/entities/Project.ts +0 -672
- package/core/class/entities/ProjectImpact.ts +0 -170
- package/core/class/entities/ProjectMilestone.ts +0 -254
- package/core/class/entities/ProjectPointer.ts +0 -39
- package/core/class/entities/ProjectUpdate.ts +0 -176
- package/core/class/entities/Track.ts +0 -32
- package/core/class/karma-indexer/GapIndexerClient.ts +0 -383
- package/core/class/karma-indexer/api/GapIndexerApi.ts +0 -446
- package/core/class/karma-indexer/api/types.ts +0 -313
- package/core/class/remote-storage/IpfsStorage.ts +0 -76
- package/core/class/remote-storage/RemoteStorage.ts +0 -65
- package/core/class/types/allo.ts +0 -93
- package/core/class/types/attestations.ts +0 -223
- package/core/consts.ts +0 -775
- package/core/scripts/create-grant.ts +0 -102
- package/core/scripts/create-program.ts +0 -43
- package/core/scripts/create-schemas.ts +0 -65
- package/core/scripts/deploy.ts +0 -65
- package/core/scripts/index.ts +0 -1
- package/core/scripts/milestone-multi-grants.ts +0 -125
- package/core/shared/types.ts +0 -13
- package/core/types.ts +0 -224
- package/core/utils/gelato/send-gelato-txn.ts +0 -114
- package/core/utils/gelato/sponsor-handler.ts +0 -77
- package/core/utils/gelato/watch-gelato-txn.ts +0 -67
- package/core/utils/get-date.ts +0 -3
- package/core/utils/get-ipfs-data.ts +0 -13
- package/core/utils/get-web3-provider.ts +0 -18
- package/core/utils/gql-queries.ts +0 -133
- package/core/utils/map-filter.ts +0 -21
- package/core/utils/serialize-bigint.ts +0 -7
- package/core/utils/to-unix.ts +0 -18
- package/create-community-example.ts +0 -119
- package/csv-upload/README.md +0 -74
- package/csv-upload/config.ts +0 -41
- package/csv-upload/example.csv +0 -2
- package/csv-upload/keys.example.json +0 -8
- package/csv-upload/scripts/run.ts +0 -417
- package/csv-upload/types.ts +0 -39
- 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 +0 -155
- package/milestone-workflow-example.ts +0 -353
- package/readme.md +0 -872
- package/schemas/.gitkeep +0 -0
- package/schemas/GAP-schemas-1692135812877.json +0 -33
- package/test-file-indexer-api.ts +0 -25
- package/tsconfig.json +0 -26
- /package/{csv-upload/.gitkeep → core/class/Gelato/Gelato.d.ts} +0 -0
- /package/core/class/GraphQL/{index.ts → index.d.ts} +0 -0
- /package/core/class/entities/{index.ts → index.d.ts} +0 -0
- /package/core/class/{index.ts → index.d.ts} +0 -0
- /package/core/{index.ts → index.d.ts} +0 -0
- /package/core/utils/gelato/{index.ts → index.d.ts} +0 -0
- /package/core/utils/{index.ts → index.d.ts} +0 -0
- /package/{index.ts → index.d.ts} +0 -0
|
@@ -1,321 +0,0 @@
|
|
|
1
|
-
import { Attestation } from "../Attestation";
|
|
2
|
-
import {
|
|
3
|
-
GrantDetails,
|
|
4
|
-
GrantRound,
|
|
5
|
-
GrantCompleted,
|
|
6
|
-
AttestationWithTx,
|
|
7
|
-
} from "../types/attestations";
|
|
8
|
-
import { IMilestone, Milestone } from "./Milestone";
|
|
9
|
-
import { GapSchema } from "../GapSchema";
|
|
10
|
-
import { GAP } from "../GAP";
|
|
11
|
-
import { AttestationError } from "../SchemaError";
|
|
12
|
-
import { chainIdToNetwork, nullRef } from "../../consts";
|
|
13
|
-
import {
|
|
14
|
-
Hex,
|
|
15
|
-
MultiAttestPayload,
|
|
16
|
-
SignerOrProvider,
|
|
17
|
-
TNetwork,
|
|
18
|
-
} from "core/types";
|
|
19
|
-
import { GapContract } from "../contract/GapContract";
|
|
20
|
-
import { Community } from "./Community";
|
|
21
|
-
import { Project } from "./Project";
|
|
22
|
-
import { AllGapSchemas } from "../AllGapSchemas";
|
|
23
|
-
import {
|
|
24
|
-
IGrantResponse,
|
|
25
|
-
IProjectResponse,
|
|
26
|
-
ISummaryProject,
|
|
27
|
-
} from "../karma-indexer/api/types";
|
|
28
|
-
import { GrantUpdate, IGrantUpdate, _IGrantUpdate } from "./GrantUpdate";
|
|
29
|
-
|
|
30
|
-
interface _Grant extends Grant {}
|
|
31
|
-
|
|
32
|
-
export interface IGrant {
|
|
33
|
-
communityUID: Hex;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
export class Grant extends Attestation<IGrant> {
|
|
37
|
-
details?: GrantDetails;
|
|
38
|
-
communityUID: Hex;
|
|
39
|
-
verified?: boolean = false;
|
|
40
|
-
round?: GrantRound;
|
|
41
|
-
milestones: Milestone[] = [];
|
|
42
|
-
community: Community;
|
|
43
|
-
updates: GrantUpdate[] = [];
|
|
44
|
-
members: string[] = [];
|
|
45
|
-
completed?: GrantCompleted;
|
|
46
|
-
project?: IProjectResponse | ISummaryProject;
|
|
47
|
-
categories?: string[] = [];
|
|
48
|
-
|
|
49
|
-
async verify(signer: SignerOrProvider) {
|
|
50
|
-
const eas = this.schema.gap.eas.connect(signer);
|
|
51
|
-
const schema = this.schema.gap.findSchema("MilestoneApproved");
|
|
52
|
-
schema.setValue("approved", true);
|
|
53
|
-
|
|
54
|
-
try {
|
|
55
|
-
await eas.attest({
|
|
56
|
-
schema: schema.raw,
|
|
57
|
-
data: {
|
|
58
|
-
recipient: this.recipient,
|
|
59
|
-
data: schema.encode(),
|
|
60
|
-
refUID: this.uid,
|
|
61
|
-
expirationTime: 0n,
|
|
62
|
-
revocable: schema.revocable,
|
|
63
|
-
},
|
|
64
|
-
});
|
|
65
|
-
this.verified = true;
|
|
66
|
-
} catch (error) {
|
|
67
|
-
console.error(error);
|
|
68
|
-
throw new AttestationError("ATTEST_ERROR", error.message, error);
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
/**
|
|
73
|
-
* Add milestones to the grant.
|
|
74
|
-
* @param signer
|
|
75
|
-
* @param milestones
|
|
76
|
-
*/
|
|
77
|
-
addMilestones(milestones: IMilestone[]) {
|
|
78
|
-
const schema = this.schema.gap.findSchema("Milestone");
|
|
79
|
-
|
|
80
|
-
const newMilestones = milestones.map((milestone) => {
|
|
81
|
-
const m = new Milestone({
|
|
82
|
-
data: milestone,
|
|
83
|
-
refUID: this.uid,
|
|
84
|
-
schema,
|
|
85
|
-
createdAt: Date.now(),
|
|
86
|
-
recipient: this.recipient,
|
|
87
|
-
uid: nullRef,
|
|
88
|
-
});
|
|
89
|
-
return m;
|
|
90
|
-
});
|
|
91
|
-
this.milestones.push(...newMilestones);
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
/**
|
|
95
|
-
* Creates the payload for a multi-attestation.
|
|
96
|
-
*
|
|
97
|
-
* > if Current payload is set, it'll be used as the base payload
|
|
98
|
-
* and the project should refer to an index of the current payload,
|
|
99
|
-
* usually the community position.
|
|
100
|
-
*
|
|
101
|
-
* @param payload
|
|
102
|
-
* @param projectIdx
|
|
103
|
-
*/
|
|
104
|
-
async multiAttestPayload(
|
|
105
|
-
currentPayload: MultiAttestPayload = [],
|
|
106
|
-
projectIdx = 0
|
|
107
|
-
) {
|
|
108
|
-
this.assertPayload();
|
|
109
|
-
const payload = [...currentPayload];
|
|
110
|
-
const grantIdx =
|
|
111
|
-
payload.push([this, await this.payloadFor(projectIdx)]) - 1;
|
|
112
|
-
if (this.details) {
|
|
113
|
-
payload.push([this.details, await this.details.payloadFor(grantIdx)]);
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
if (this.milestones.length) {
|
|
117
|
-
await Promise.all(
|
|
118
|
-
this.milestones.map(async (m) =>
|
|
119
|
-
payload.push(...(await m.multiAttestPayload(payload, grantIdx)))
|
|
120
|
-
)
|
|
121
|
-
);
|
|
122
|
-
}
|
|
123
|
-
if (this.updates.length) {
|
|
124
|
-
await Promise.all(
|
|
125
|
-
this.updates.map(async (u) =>
|
|
126
|
-
payload.push([u, await u.payloadFor(grantIdx)])
|
|
127
|
-
)
|
|
128
|
-
);
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
return payload.slice(currentPayload.length, payload.length);
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
async attestProject(
|
|
135
|
-
signer: SignerOrProvider,
|
|
136
|
-
originalProjectChainId: number
|
|
137
|
-
) {
|
|
138
|
-
const project = new Project({
|
|
139
|
-
data: { project: true },
|
|
140
|
-
schema: this.schema.gap.findSchema("Project"),
|
|
141
|
-
recipient: this.recipient,
|
|
142
|
-
chainID: this.chainID,
|
|
143
|
-
});
|
|
144
|
-
|
|
145
|
-
(project.details as Attestation) = new Attestation({
|
|
146
|
-
data: {
|
|
147
|
-
originalProjectChainId,
|
|
148
|
-
uid: this.refUID,
|
|
149
|
-
},
|
|
150
|
-
chainID: this.chainID,
|
|
151
|
-
recipient: this.recipient,
|
|
152
|
-
schema: this.schema.gap.findSchema("ProjectDetails"),
|
|
153
|
-
});
|
|
154
|
-
|
|
155
|
-
// Overwrite refuid
|
|
156
|
-
Object.assign(this, { refUID: nullRef });
|
|
157
|
-
project.grants = [this];
|
|
158
|
-
|
|
159
|
-
const attestation = await project.attest(signer);
|
|
160
|
-
return attestation;
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
/**
|
|
164
|
-
* @inheritdoc
|
|
165
|
-
*/
|
|
166
|
-
async attest(
|
|
167
|
-
signer: SignerOrProvider,
|
|
168
|
-
projectChainId: number,
|
|
169
|
-
callback?: Function
|
|
170
|
-
): Promise<AttestationWithTx> {
|
|
171
|
-
if (projectChainId !== this.chainID) {
|
|
172
|
-
return this.attestProject(signer, projectChainId);
|
|
173
|
-
}
|
|
174
|
-
this.assertPayload();
|
|
175
|
-
const payload = await this.multiAttestPayload();
|
|
176
|
-
|
|
177
|
-
const { tx, uids } = await GapContract.multiAttest(
|
|
178
|
-
signer,
|
|
179
|
-
payload.map((p) => p[1]),
|
|
180
|
-
callback
|
|
181
|
-
);
|
|
182
|
-
|
|
183
|
-
if (Array.isArray(uids)) {
|
|
184
|
-
uids.forEach((uid, index) => {
|
|
185
|
-
payload[index][0].uid = uid;
|
|
186
|
-
});
|
|
187
|
-
}
|
|
188
|
-
return { tx, uids };
|
|
189
|
-
}
|
|
190
|
-
|
|
191
|
-
async attestUpdate(
|
|
192
|
-
signer: SignerOrProvider,
|
|
193
|
-
data: IGrantUpdate,
|
|
194
|
-
callback?: Function
|
|
195
|
-
) {
|
|
196
|
-
const grantUpdate = new GrantUpdate({
|
|
197
|
-
data: {
|
|
198
|
-
...data,
|
|
199
|
-
type: "grant-update",
|
|
200
|
-
},
|
|
201
|
-
recipient: this.recipient,
|
|
202
|
-
refUID: this.uid,
|
|
203
|
-
schema: this.schema.gap.findSchema("GrantDetails"),
|
|
204
|
-
});
|
|
205
|
-
|
|
206
|
-
await grantUpdate.attest(signer, callback);
|
|
207
|
-
this.updates.push(grantUpdate);
|
|
208
|
-
}
|
|
209
|
-
|
|
210
|
-
/**
|
|
211
|
-
* Validate if the grant has a valid reference to a community.
|
|
212
|
-
*/
|
|
213
|
-
protected assertPayload() {
|
|
214
|
-
if (!this.details || !this.communityUID) {
|
|
215
|
-
throw new AttestationError(
|
|
216
|
-
"INVALID_REFERENCE",
|
|
217
|
-
"Grant should include a valid reference to a community on its details."
|
|
218
|
-
);
|
|
219
|
-
}
|
|
220
|
-
return true;
|
|
221
|
-
}
|
|
222
|
-
|
|
223
|
-
async complete(
|
|
224
|
-
signer: SignerOrProvider,
|
|
225
|
-
data: IGrantUpdate,
|
|
226
|
-
callback?: Function
|
|
227
|
-
): Promise<AttestationWithTx> {
|
|
228
|
-
const completed = new GrantCompleted({
|
|
229
|
-
data: {
|
|
230
|
-
...data,
|
|
231
|
-
type: "grant-completed",
|
|
232
|
-
},
|
|
233
|
-
recipient: this.recipient,
|
|
234
|
-
refUID: this.uid,
|
|
235
|
-
schema: this.schema.gap.findSchema("GrantDetails"),
|
|
236
|
-
});
|
|
237
|
-
|
|
238
|
-
const { tx, uids } = await completed.attest(signer, callback);
|
|
239
|
-
this.completed = completed;
|
|
240
|
-
return { tx, uids };
|
|
241
|
-
}
|
|
242
|
-
|
|
243
|
-
static from(attestations: IGrantResponse[], network: TNetwork): Grant[] {
|
|
244
|
-
return attestations.map((attestation) => {
|
|
245
|
-
const grant = new Grant({
|
|
246
|
-
...attestation,
|
|
247
|
-
data: {
|
|
248
|
-
communityUID: attestation.data.communityUID,
|
|
249
|
-
},
|
|
250
|
-
schema: new AllGapSchemas().findSchema(
|
|
251
|
-
"Grant",
|
|
252
|
-
chainIdToNetwork[attestation.chainID] as TNetwork
|
|
253
|
-
),
|
|
254
|
-
chainID: attestation.chainID,
|
|
255
|
-
});
|
|
256
|
-
|
|
257
|
-
if (attestation.details) {
|
|
258
|
-
const { details } = attestation;
|
|
259
|
-
grant.details = new GrantDetails({
|
|
260
|
-
...details,
|
|
261
|
-
data: {
|
|
262
|
-
...details.data,
|
|
263
|
-
},
|
|
264
|
-
schema: new AllGapSchemas().findSchema(
|
|
265
|
-
"GrantDetails",
|
|
266
|
-
chainIdToNetwork[attestation.chainID] as TNetwork
|
|
267
|
-
),
|
|
268
|
-
chainID: attestation.chainID,
|
|
269
|
-
});
|
|
270
|
-
}
|
|
271
|
-
|
|
272
|
-
if (attestation.milestones) {
|
|
273
|
-
const { milestones } = attestation;
|
|
274
|
-
grant.milestones = Milestone.from(milestones, network);
|
|
275
|
-
}
|
|
276
|
-
|
|
277
|
-
if (attestation.updates) {
|
|
278
|
-
const { updates } = attestation;
|
|
279
|
-
grant.updates = GrantUpdate.from(
|
|
280
|
-
updates as any as _IGrantUpdate[],
|
|
281
|
-
network
|
|
282
|
-
);
|
|
283
|
-
}
|
|
284
|
-
|
|
285
|
-
if (attestation.completed) {
|
|
286
|
-
const { completed } = attestation;
|
|
287
|
-
grant.completed = new GrantCompleted({
|
|
288
|
-
...completed,
|
|
289
|
-
data: {
|
|
290
|
-
...completed.data,
|
|
291
|
-
},
|
|
292
|
-
schema: new AllGapSchemas().findSchema(
|
|
293
|
-
"GrantDetails",
|
|
294
|
-
chainIdToNetwork[attestation.chainID] as TNetwork
|
|
295
|
-
),
|
|
296
|
-
chainID: attestation.chainID,
|
|
297
|
-
});
|
|
298
|
-
}
|
|
299
|
-
|
|
300
|
-
if (attestation.project) {
|
|
301
|
-
const { project } = attestation;
|
|
302
|
-
grant.project = project;
|
|
303
|
-
}
|
|
304
|
-
|
|
305
|
-
if (attestation.community) {
|
|
306
|
-
const { community } = attestation;
|
|
307
|
-
grant.community = Community.from([community], network)[0];
|
|
308
|
-
}
|
|
309
|
-
|
|
310
|
-
if (attestation.members) {
|
|
311
|
-
grant.members = attestation.members;
|
|
312
|
-
}
|
|
313
|
-
|
|
314
|
-
if (attestation.categories) {
|
|
315
|
-
grant.categories = attestation.categories;
|
|
316
|
-
}
|
|
317
|
-
|
|
318
|
-
return grant;
|
|
319
|
-
});
|
|
320
|
-
}
|
|
321
|
-
}
|
|
@@ -1,187 +0,0 @@
|
|
|
1
|
-
import { IGrantUpdateBase } from "core/shared/types";
|
|
2
|
-
import { Transaction } from "ethers";
|
|
3
|
-
import { chainIdToNetwork } from "../../../core/consts";
|
|
4
|
-
import { SignerOrProvider, TNetwork } from "../../../core/types";
|
|
5
|
-
import { AllGapSchemas } from "../AllGapSchemas";
|
|
6
|
-
import { Attestation } from "../Attestation";
|
|
7
|
-
import { GapSchema } from "../GapSchema";
|
|
8
|
-
import { Hex } from "../karma-indexer/api/types";
|
|
9
|
-
import { AttestationError } from "../SchemaError";
|
|
10
|
-
|
|
11
|
-
export interface _IGrantUpdate extends GrantUpdate {}
|
|
12
|
-
export interface IGrantUpdate extends IGrantUpdateBase {
|
|
13
|
-
type?: string;
|
|
14
|
-
proofOfWork?: string;
|
|
15
|
-
pitchDeck?: string;
|
|
16
|
-
demoVideo?: string;
|
|
17
|
-
trackExplanations?: Array<{
|
|
18
|
-
trackId: string;
|
|
19
|
-
trackName: string;
|
|
20
|
-
explanation: string;
|
|
21
|
-
}>;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
type IStatus = "verified";
|
|
25
|
-
|
|
26
|
-
export interface IGrantUpdateStatus {
|
|
27
|
-
type?: `grant-update-${IStatus}`;
|
|
28
|
-
reason?: string;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
export class GrantUpdateStatus
|
|
32
|
-
extends Attestation<IGrantUpdateStatus>
|
|
33
|
-
implements IGrantUpdateStatus
|
|
34
|
-
{
|
|
35
|
-
type: `grant-update-${IStatus}`;
|
|
36
|
-
reason?: string;
|
|
37
|
-
pitchDeck?: string;
|
|
38
|
-
demoVideo?: string;
|
|
39
|
-
trackExplanations?: Array<{
|
|
40
|
-
trackId: string;
|
|
41
|
-
trackName: string;
|
|
42
|
-
explanation: string;
|
|
43
|
-
}>;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
export class GrantUpdate
|
|
47
|
-
extends Attestation<IGrantUpdate>
|
|
48
|
-
implements IGrantUpdate
|
|
49
|
-
{
|
|
50
|
-
title: string;
|
|
51
|
-
text: string;
|
|
52
|
-
proofOfWork: string;
|
|
53
|
-
pitchDeck?: string;
|
|
54
|
-
demoVideo?: string;
|
|
55
|
-
trackExplanations?: Array<{
|
|
56
|
-
trackId: string;
|
|
57
|
-
trackName: string;
|
|
58
|
-
explanation: string;
|
|
59
|
-
}>;
|
|
60
|
-
verified: GrantUpdateStatus[] = [];
|
|
61
|
-
|
|
62
|
-
/**
|
|
63
|
-
* Attest the status of the milestone as approved, rejected or completed.
|
|
64
|
-
*/
|
|
65
|
-
private async attestStatus(
|
|
66
|
-
signer: SignerOrProvider,
|
|
67
|
-
schema: GapSchema,
|
|
68
|
-
callback?: Function
|
|
69
|
-
) {
|
|
70
|
-
const eas = this.schema.gap.eas.connect(signer);
|
|
71
|
-
try {
|
|
72
|
-
if (callback) callback("preparing");
|
|
73
|
-
const tx = await eas.attest({
|
|
74
|
-
schema: schema.uid,
|
|
75
|
-
data: {
|
|
76
|
-
recipient: this.recipient,
|
|
77
|
-
data: schema.encode(),
|
|
78
|
-
refUID: this.uid,
|
|
79
|
-
expirationTime: 0n,
|
|
80
|
-
revocable: schema.revocable,
|
|
81
|
-
},
|
|
82
|
-
});
|
|
83
|
-
|
|
84
|
-
if (callback) callback("pending");
|
|
85
|
-
const uid = await tx.wait();
|
|
86
|
-
if (callback) callback("confirmed");
|
|
87
|
-
|
|
88
|
-
console.log(uid);
|
|
89
|
-
return {
|
|
90
|
-
tx: [
|
|
91
|
-
{
|
|
92
|
-
hash: tx.tx.hash as Hex,
|
|
93
|
-
} as Transaction,
|
|
94
|
-
],
|
|
95
|
-
uids: [uid as `0x${string}`],
|
|
96
|
-
};
|
|
97
|
-
} catch (error: any) {
|
|
98
|
-
console.error(error);
|
|
99
|
-
throw new AttestationError("ATTEST_ERROR", error.message, error);
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
/**
|
|
104
|
-
* Verify this GrantUpdate. If the GrantUpdate is not already verified,
|
|
105
|
-
* it will throw an error.
|
|
106
|
-
* @param signer
|
|
107
|
-
* @param reason
|
|
108
|
-
*/
|
|
109
|
-
async verify(
|
|
110
|
-
signer: SignerOrProvider,
|
|
111
|
-
data?: IGrantUpdateStatus,
|
|
112
|
-
callback?: Function
|
|
113
|
-
) {
|
|
114
|
-
console.log("Verifying");
|
|
115
|
-
|
|
116
|
-
const schema = this.schema.gap.findSchema("GrantUpdateStatus");
|
|
117
|
-
|
|
118
|
-
if (this.schema.isJsonSchema()) {
|
|
119
|
-
schema.setValue(
|
|
120
|
-
"json",
|
|
121
|
-
JSON.stringify({
|
|
122
|
-
type: "grant-update-verified",
|
|
123
|
-
...data,
|
|
124
|
-
})
|
|
125
|
-
);
|
|
126
|
-
} else {
|
|
127
|
-
schema.setValue("type", "grant-update-verified");
|
|
128
|
-
schema.setValue("reason", data?.reason || "");
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
console.log("Before attest grant update verified");
|
|
132
|
-
const { tx, uids } = await this.attestStatus(signer, schema, callback);
|
|
133
|
-
console.log("After attest grant update verified");
|
|
134
|
-
|
|
135
|
-
this.verified.push(
|
|
136
|
-
new GrantUpdateStatus({
|
|
137
|
-
data: {
|
|
138
|
-
type: "grant-update-verified",
|
|
139
|
-
...data,
|
|
140
|
-
},
|
|
141
|
-
refUID: this.uid,
|
|
142
|
-
schema: schema,
|
|
143
|
-
recipient: this.recipient,
|
|
144
|
-
})
|
|
145
|
-
);
|
|
146
|
-
|
|
147
|
-
return {
|
|
148
|
-
tx,
|
|
149
|
-
uids,
|
|
150
|
-
};
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
static from(attestations: _IGrantUpdate[], network: TNetwork): GrantUpdate[] {
|
|
154
|
-
return attestations.map((attestation) => {
|
|
155
|
-
const grantUpdate = new GrantUpdate({
|
|
156
|
-
...attestation,
|
|
157
|
-
data: {
|
|
158
|
-
...attestation.data,
|
|
159
|
-
},
|
|
160
|
-
schema: new AllGapSchemas().findSchema(
|
|
161
|
-
"GrantUpdate",
|
|
162
|
-
chainIdToNetwork[attestation.chainID] as TNetwork
|
|
163
|
-
),
|
|
164
|
-
chainID: attestation.chainID,
|
|
165
|
-
});
|
|
166
|
-
|
|
167
|
-
if (attestation.verified?.length > 0) {
|
|
168
|
-
grantUpdate.verified = attestation.verified.map(
|
|
169
|
-
(m) =>
|
|
170
|
-
new GrantUpdateStatus({
|
|
171
|
-
...m,
|
|
172
|
-
data: {
|
|
173
|
-
...m.data,
|
|
174
|
-
},
|
|
175
|
-
schema: new AllGapSchemas().findSchema(
|
|
176
|
-
"GrantUpdateStatus",
|
|
177
|
-
chainIdToNetwork[attestation.chainID] as TNetwork
|
|
178
|
-
),
|
|
179
|
-
chainID: attestation.chainID,
|
|
180
|
-
})
|
|
181
|
-
);
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
return grantUpdate;
|
|
185
|
-
});
|
|
186
|
-
}
|
|
187
|
-
}
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
import { Hex, MultiAttestPayload, SignerOrProvider } from "core/types";
|
|
2
|
-
import { Attestation } from "../Attestation";
|
|
3
|
-
import { AttestationWithTx, MemberDetails } from "../types/attestations";
|
|
4
|
-
import { AttestationError } from "../SchemaError";
|
|
5
|
-
import { GapContract } from "../contract/GapContract";
|
|
6
|
-
|
|
7
|
-
export interface IMemberOf {
|
|
8
|
-
memberOf: true;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
export class MemberOf extends Attestation<IMemberOf> {
|
|
12
|
-
details?: MemberDetails;
|
|
13
|
-
|
|
14
|
-
async multiAttestPayload(
|
|
15
|
-
currentPayload: MultiAttestPayload = [],
|
|
16
|
-
projectIdx = 0
|
|
17
|
-
) {
|
|
18
|
-
const payload = [...currentPayload];
|
|
19
|
-
const memberIdx =
|
|
20
|
-
payload.push([this, await this.payloadFor(projectIdx)]) - 1;
|
|
21
|
-
|
|
22
|
-
if (this.details) {
|
|
23
|
-
payload.push([this.details, await this.details.payloadFor(memberIdx)]);
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
return payload.slice(currentPayload.length, payload.length);
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
async attest(
|
|
30
|
-
signer: SignerOrProvider,
|
|
31
|
-
callback?: Function
|
|
32
|
-
): Promise<AttestationWithTx> {
|
|
33
|
-
const payload = await this.multiAttestPayload();
|
|
34
|
-
try {
|
|
35
|
-
const { uids, tx } = await GapContract.multiAttest(
|
|
36
|
-
signer,
|
|
37
|
-
payload.map((p) => p[1]),
|
|
38
|
-
callback
|
|
39
|
-
);
|
|
40
|
-
const [memberUID, detailsUID] = uids;
|
|
41
|
-
|
|
42
|
-
this.uid = memberUID as Hex;
|
|
43
|
-
if (this.details && detailsUID) {
|
|
44
|
-
this.details.uid = detailsUID as Hex;
|
|
45
|
-
}
|
|
46
|
-
return { tx, uids };
|
|
47
|
-
} catch (error) {
|
|
48
|
-
console.error(error);
|
|
49
|
-
throw new AttestationError("ATTEST_ERROR", error.message, error);
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
}
|