@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
|
@@ -1,285 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.GapContract = void 0;
|
|
4
|
-
const eas_sdk_1 = require("@ethereum-attestation-service/eas-sdk");
|
|
5
|
-
const send_gelato_txn_1 = require("../../utils/gelato/send-gelato-txn");
|
|
6
|
-
const serialize_bigint_1 = require("../../utils/serialize-bigint");
|
|
7
|
-
const GAP_1 = require("../GAP");
|
|
8
|
-
const AttestationDataTypes = {
|
|
9
|
-
Attest: [
|
|
10
|
-
{ name: "payloadHash", type: "string" },
|
|
11
|
-
{ name: "nonce", type: "uint256" },
|
|
12
|
-
{ name: "expiry", type: "uint256" },
|
|
13
|
-
],
|
|
14
|
-
};
|
|
15
|
-
class GapContract {
|
|
16
|
-
/**
|
|
17
|
-
* Signs a message for the delegated attestation.
|
|
18
|
-
* @param signer
|
|
19
|
-
* @param payload
|
|
20
|
-
* @returns r,s,v signature
|
|
21
|
-
*/
|
|
22
|
-
static async signAttestation(signer, payload, expiry) {
|
|
23
|
-
let { nonce } = await this.getNonce(signer);
|
|
24
|
-
const { chainId } = await signer.provider.getNetwork();
|
|
25
|
-
const domain = {
|
|
26
|
-
chainId,
|
|
27
|
-
name: "gap-attestation",
|
|
28
|
-
version: "1",
|
|
29
|
-
verifyingContract: (await GAP_1.GAP.getMulticall(signer)).address,
|
|
30
|
-
};
|
|
31
|
-
const data = { payloadHash: payload, nonce, expiry };
|
|
32
|
-
console.log({ domain, AttestationDataTypes, data });
|
|
33
|
-
const signature = await signer._signTypedData(domain, AttestationDataTypes, data);
|
|
34
|
-
const { r, s, v } = this.getRSV(signature);
|
|
35
|
-
return { r, s, v, nonce, chainId };
|
|
36
|
-
}
|
|
37
|
-
/**
|
|
38
|
-
* Returns the r, s, v values of a signature
|
|
39
|
-
* @param signature
|
|
40
|
-
* @returns
|
|
41
|
-
*/
|
|
42
|
-
static getRSV(signature) {
|
|
43
|
-
const r = signature.slice(0, 66);
|
|
44
|
-
const s = `0x${signature.slice(66, 130)}`;
|
|
45
|
-
const v = `0x${signature.slice(130, 132)}`;
|
|
46
|
-
return { r, s, v };
|
|
47
|
-
}
|
|
48
|
-
static async getSignerAddress(signer) {
|
|
49
|
-
const address = signer.address || signer._address || (await signer.getAddress());
|
|
50
|
-
if (!address)
|
|
51
|
-
throw new Error("Signer does not provider either address or getAddress().");
|
|
52
|
-
return address;
|
|
53
|
-
}
|
|
54
|
-
/**
|
|
55
|
-
* Get nonce for the transaction
|
|
56
|
-
* @param address
|
|
57
|
-
* @returns
|
|
58
|
-
*/
|
|
59
|
-
static async getNonce(signer) {
|
|
60
|
-
const contract = await GAP_1.GAP.getMulticall(signer);
|
|
61
|
-
const address = await this.getSignerAddress(signer);
|
|
62
|
-
console.log({ address });
|
|
63
|
-
const nonce = await contract.nonces(address);
|
|
64
|
-
return {
|
|
65
|
-
nonce: Number(nonce),
|
|
66
|
-
next: Number(nonce + 1n),
|
|
67
|
-
};
|
|
68
|
-
}
|
|
69
|
-
/**
|
|
70
|
-
* Send a single attestation
|
|
71
|
-
* @param signer
|
|
72
|
-
* @param payload
|
|
73
|
-
* @returns
|
|
74
|
-
*/
|
|
75
|
-
static async attest(signer, payload, callback) {
|
|
76
|
-
const contract = await GAP_1.GAP.getMulticall(signer);
|
|
77
|
-
if (GAP_1.GAP.gelatoOpts?.useGasless) {
|
|
78
|
-
return this.attestBySig(signer, payload);
|
|
79
|
-
}
|
|
80
|
-
callback?.("preparing");
|
|
81
|
-
const tx = await contract
|
|
82
|
-
.attest({
|
|
83
|
-
schema: payload.schema,
|
|
84
|
-
data: payload.data.payload,
|
|
85
|
-
})
|
|
86
|
-
.then((res) => {
|
|
87
|
-
callback?.("pending");
|
|
88
|
-
return res;
|
|
89
|
-
});
|
|
90
|
-
const result = await tx.wait?.();
|
|
91
|
-
callback?.("confirmed");
|
|
92
|
-
const attestations = (0, eas_sdk_1.getUIDsFromAttestReceipt)(result)[0];
|
|
93
|
-
const resultArray = [result].flat();
|
|
94
|
-
return {
|
|
95
|
-
tx: resultArray,
|
|
96
|
-
uids: [attestations],
|
|
97
|
-
};
|
|
98
|
-
}
|
|
99
|
-
static async attestBySig(signer, payload) {
|
|
100
|
-
const contract = await GAP_1.GAP.getMulticall(signer);
|
|
101
|
-
const expiry = BigInt(Math.floor(Date.now() / 1000) + 60 * 60 * 24 * 30);
|
|
102
|
-
const address = await this.getSignerAddress(signer);
|
|
103
|
-
const payloadHash = (0, serialize_bigint_1.serializeWithBigint)({
|
|
104
|
-
schema: payload.schema,
|
|
105
|
-
data: payload.data.raw,
|
|
106
|
-
});
|
|
107
|
-
const { r, s, v, nonce, chainId } = await this.signAttestation(signer, payloadHash, expiry);
|
|
108
|
-
const { data: populatedTxn } = await contract.attestBySig.populateTransaction({
|
|
109
|
-
data: payload.data.payload,
|
|
110
|
-
schema: payload.schema,
|
|
111
|
-
}, payloadHash, address, nonce, expiry, v, r, s);
|
|
112
|
-
if (!populatedTxn)
|
|
113
|
-
throw new Error("Transaction data is empty");
|
|
114
|
-
let contractAddress = await contract.getAddress();
|
|
115
|
-
const txn = await (0, send_gelato_txn_1.sendGelatoTxn)(...send_gelato_txn_1.Gelato.buildArgs(populatedTxn, chainId, contractAddress));
|
|
116
|
-
const attestations = await this.getTransactionLogs(signer, txn);
|
|
117
|
-
return {
|
|
118
|
-
tx: [
|
|
119
|
-
{
|
|
120
|
-
hash: txn,
|
|
121
|
-
},
|
|
122
|
-
],
|
|
123
|
-
uids: attestations,
|
|
124
|
-
};
|
|
125
|
-
}
|
|
126
|
-
/**
|
|
127
|
-
* Performs a referenced multi attestation.
|
|
128
|
-
*
|
|
129
|
-
* @returns an array with the attestation UIDs.
|
|
130
|
-
*/
|
|
131
|
-
static async multiAttest(signer, payload, callback) {
|
|
132
|
-
const contract = await GAP_1.GAP.getMulticall(signer);
|
|
133
|
-
if (GAP_1.GAP.gelatoOpts?.useGasless) {
|
|
134
|
-
return this.multiAttestBySig(signer, payload);
|
|
135
|
-
}
|
|
136
|
-
if (callback)
|
|
137
|
-
callback("preparing");
|
|
138
|
-
const tx = await contract.multiSequentialAttest(payload.map((p) => p.payload));
|
|
139
|
-
if (callback)
|
|
140
|
-
callback("pending");
|
|
141
|
-
const result = await tx.wait?.();
|
|
142
|
-
if (callback)
|
|
143
|
-
callback("confirmed");
|
|
144
|
-
const attestations = (0, eas_sdk_1.getUIDsFromAttestReceipt)(result);
|
|
145
|
-
const resultArray = [result].flat();
|
|
146
|
-
return {
|
|
147
|
-
tx: resultArray,
|
|
148
|
-
uids: attestations,
|
|
149
|
-
};
|
|
150
|
-
}
|
|
151
|
-
/**
|
|
152
|
-
* Performs a referenced multi attestation.
|
|
153
|
-
*
|
|
154
|
-
* @returns an array with the attestation UIDs.
|
|
155
|
-
*/
|
|
156
|
-
static async multiAttestBySig(signer, payload) {
|
|
157
|
-
const contract = await GAP_1.GAP.getMulticall(signer);
|
|
158
|
-
const expiry = BigInt(Math.floor(Date.now() / 1000) + 60 * 60 * 24 * 30);
|
|
159
|
-
const address = await this.getSignerAddress(signer);
|
|
160
|
-
const payloadHash = (0, serialize_bigint_1.serializeWithBigint)(payload.map((p) => p.raw));
|
|
161
|
-
const { r, s, v, nonce, chainId } = await this.signAttestation(signer, payloadHash, expiry);
|
|
162
|
-
console.info({ r, s, v, nonce, chainId, payloadHash, address });
|
|
163
|
-
const { data: populatedTxn } = await contract.multiSequentialAttestBySig.populateTransaction(payload.map((p) => p.payload), payloadHash, address, nonce, expiry, v, r, s);
|
|
164
|
-
if (!populatedTxn)
|
|
165
|
-
throw new Error("Transaction data is empty");
|
|
166
|
-
let contractAddress = await contract.getAddress();
|
|
167
|
-
const txn = await (0, send_gelato_txn_1.sendGelatoTxn)(...send_gelato_txn_1.Gelato.buildArgs(populatedTxn, chainId, contractAddress));
|
|
168
|
-
const attestations = await this.getTransactionLogs(signer, txn);
|
|
169
|
-
return {
|
|
170
|
-
tx: [
|
|
171
|
-
{
|
|
172
|
-
hash: txn,
|
|
173
|
-
},
|
|
174
|
-
],
|
|
175
|
-
uids: attestations,
|
|
176
|
-
};
|
|
177
|
-
}
|
|
178
|
-
static async multiRevoke(signer, payload) {
|
|
179
|
-
const contract = await GAP_1.GAP.getMulticall(signer);
|
|
180
|
-
if (GAP_1.GAP.gelatoOpts?.useGasless) {
|
|
181
|
-
return this.multiRevokeBySig(signer, payload);
|
|
182
|
-
}
|
|
183
|
-
const tx = await contract.multiRevoke(payload);
|
|
184
|
-
return {
|
|
185
|
-
tx: [tx],
|
|
186
|
-
uids: [],
|
|
187
|
-
};
|
|
188
|
-
}
|
|
189
|
-
/**
|
|
190
|
-
* Performs a referenced multi attestation.
|
|
191
|
-
*
|
|
192
|
-
* @returns an array with the attestation UIDs.
|
|
193
|
-
*/
|
|
194
|
-
static async multiRevokeBySig(signer, payload) {
|
|
195
|
-
const contract = await GAP_1.GAP.getMulticall(signer);
|
|
196
|
-
const expiry = BigInt(Math.floor(Date.now() / 1000) + 60 * 60 * 24 * 30);
|
|
197
|
-
const address = await this.getSignerAddress(signer);
|
|
198
|
-
const payloadHash = (0, serialize_bigint_1.serializeWithBigint)(payload);
|
|
199
|
-
const { r, s, v, nonce, chainId } = await this.signAttestation(signer, payloadHash, expiry);
|
|
200
|
-
console.info({ r, s, v, nonce, chainId, payloadHash, address });
|
|
201
|
-
const { data: populatedTxn } = await contract.multiRevokeBySig.populateTransaction(payload, payloadHash, address, nonce, expiry, v, r, s);
|
|
202
|
-
if (!populatedTxn)
|
|
203
|
-
throw new Error("Transaction data is empty");
|
|
204
|
-
let contractAddress = await contract.getAddress();
|
|
205
|
-
const txn = await (0, send_gelato_txn_1.sendGelatoTxn)(...send_gelato_txn_1.Gelato.buildArgs(populatedTxn, chainId, contractAddress));
|
|
206
|
-
return {
|
|
207
|
-
tx: [{ hash: txn }],
|
|
208
|
-
uids: [],
|
|
209
|
-
};
|
|
210
|
-
}
|
|
211
|
-
/**
|
|
212
|
-
* Transfer the ownership of an attestation
|
|
213
|
-
* @param signer
|
|
214
|
-
* @param projectUID
|
|
215
|
-
* @param newOwner
|
|
216
|
-
* @returns
|
|
217
|
-
*/
|
|
218
|
-
static async transferProjectOwnership(signer, projectUID, newOwner) {
|
|
219
|
-
const contract = await GAP_1.GAP.getProjectResolver(signer);
|
|
220
|
-
const tx = await contract.transferProjectOwnership(projectUID, newOwner);
|
|
221
|
-
return tx.wait?.();
|
|
222
|
-
}
|
|
223
|
-
/**
|
|
224
|
-
* Check if the signer is the owner of the project
|
|
225
|
-
* @param signer
|
|
226
|
-
* @param projectUID
|
|
227
|
-
* @param projectChainId
|
|
228
|
-
* @param publicAddress
|
|
229
|
-
* @returns
|
|
230
|
-
*/
|
|
231
|
-
static async isProjectOwner(signer, projectUID, projectChainId, publicAddress) {
|
|
232
|
-
const contract = await GAP_1.GAP.getProjectResolver(signer, projectChainId);
|
|
233
|
-
const address = publicAddress || (await this.getSignerAddress(signer));
|
|
234
|
-
const isOwner = await contract.isOwner(projectUID, address);
|
|
235
|
-
return isOwner;
|
|
236
|
-
}
|
|
237
|
-
/**
|
|
238
|
-
* Check if the signer is admin of the project
|
|
239
|
-
* @param signer
|
|
240
|
-
* @param projectUID
|
|
241
|
-
* @param projectChainId
|
|
242
|
-
* @param publicAddress
|
|
243
|
-
* @returns
|
|
244
|
-
*/
|
|
245
|
-
static async isProjectAdmin(signer, projectUID, projectChainId, publicAddress) {
|
|
246
|
-
const contract = await GAP_1.GAP.getProjectResolver(signer, projectChainId);
|
|
247
|
-
const address = publicAddress || (await this.getSignerAddress(signer));
|
|
248
|
-
const isAdmin = await contract.isAdmin(projectUID, address);
|
|
249
|
-
return isAdmin;
|
|
250
|
-
}
|
|
251
|
-
static async getTransactionLogs(signer, txnHash) {
|
|
252
|
-
const txn = await signer.provider.getTransactionReceipt(txnHash);
|
|
253
|
-
if (!txn || !txn.logs.length)
|
|
254
|
-
throw new Error("Transaction not found");
|
|
255
|
-
// Returns the txn logs with the attestation results. Tha last two logs are the
|
|
256
|
-
// the ones from the GelatoRelay contract.
|
|
257
|
-
return (0, eas_sdk_1.getUIDsFromAttestReceipt)(txn);
|
|
258
|
-
}
|
|
259
|
-
/**
|
|
260
|
-
* Add Project Admin
|
|
261
|
-
* @param signer
|
|
262
|
-
* @param projectUID
|
|
263
|
-
* @param newAdmin
|
|
264
|
-
* @returns
|
|
265
|
-
*/
|
|
266
|
-
static async addProjectAdmin(signer, projectUID, newAdmin) {
|
|
267
|
-
const contract = await GAP_1.GAP.getProjectResolver(signer);
|
|
268
|
-
const tx = await contract.addAdmin(projectUID, newAdmin);
|
|
269
|
-
return tx.wait?.();
|
|
270
|
-
}
|
|
271
|
-
/**
|
|
272
|
-
* RemoveProject Admin
|
|
273
|
-
* @param signer
|
|
274
|
-
* @param projectUID
|
|
275
|
-
* @param newAdmin
|
|
276
|
-
* @returns
|
|
277
|
-
*/
|
|
278
|
-
static async removeProjectAdmin(signer, projectUID, oldAdmin) {
|
|
279
|
-
const contract = await GAP_1.GAP.getProjectResolver(signer);
|
|
280
|
-
const tx = await contract.removeAdmin(projectUID, oldAdmin);
|
|
281
|
-
return tx.wait?.();
|
|
282
|
-
}
|
|
283
|
-
}
|
|
284
|
-
exports.GapContract = GapContract;
|
|
285
|
-
GapContract.nonces = {};
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import { Attestation } from "../Attestation";
|
|
2
|
-
import { AttestationWithTx, CommunityDetails, ICommunityDetails } from "../types/attestations";
|
|
3
|
-
import { Project } from "./Project";
|
|
4
|
-
import { MultiAttestPayload, SignerOrProvider, TNetwork } from "core/types";
|
|
5
|
-
import { Grant } from "./Grant";
|
|
6
|
-
import { ICommunityResponse } from "../karma-indexer/api/types";
|
|
7
|
-
export interface ICommunity {
|
|
8
|
-
community: true;
|
|
9
|
-
}
|
|
10
|
-
export declare class Community extends Attestation<ICommunity> {
|
|
11
|
-
projects: Project[];
|
|
12
|
-
grants: Grant[];
|
|
13
|
-
details?: CommunityDetails;
|
|
14
|
-
/**
|
|
15
|
-
* Creates the payload for a multi-attestation.
|
|
16
|
-
*
|
|
17
|
-
* > if Current payload is set, it'll be used as the base payload
|
|
18
|
-
* and the project should refer to an index of the current payload,
|
|
19
|
-
* usually the community position.
|
|
20
|
-
*
|
|
21
|
-
* @param payload
|
|
22
|
-
* @param refIdx
|
|
23
|
-
*/
|
|
24
|
-
multiAttestPayload(): Promise<MultiAttestPayload>;
|
|
25
|
-
/**
|
|
26
|
-
* Attest a community with its details.
|
|
27
|
-
*
|
|
28
|
-
* If the community exists, it will not be revoked but its details will be updated.
|
|
29
|
-
* @param signer
|
|
30
|
-
* @param details
|
|
31
|
-
*/
|
|
32
|
-
attest(signer: SignerOrProvider, details?: ICommunityDetails, callback?: Function): Promise<AttestationWithTx>;
|
|
33
|
-
static from(attestations: ICommunityResponse[], network: TNetwork): Community[];
|
|
34
|
-
}
|
|
@@ -1,109 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Community = void 0;
|
|
4
|
-
const Attestation_1 = require("../Attestation");
|
|
5
|
-
const attestations_1 = require("../types/attestations");
|
|
6
|
-
const consts_1 = require("../../consts");
|
|
7
|
-
const SchemaError_1 = require("../SchemaError");
|
|
8
|
-
const GapSchema_1 = require("../GapSchema");
|
|
9
|
-
const Grant_1 = require("./Grant");
|
|
10
|
-
class Community extends Attestation_1.Attestation {
|
|
11
|
-
constructor() {
|
|
12
|
-
super(...arguments);
|
|
13
|
-
this.projects = [];
|
|
14
|
-
this.grants = [];
|
|
15
|
-
}
|
|
16
|
-
/**
|
|
17
|
-
* Creates the payload for a multi-attestation.
|
|
18
|
-
*
|
|
19
|
-
* > if Current payload is set, it'll be used as the base payload
|
|
20
|
-
* and the project should refer to an index of the current payload,
|
|
21
|
-
* usually the community position.
|
|
22
|
-
*
|
|
23
|
-
* @param payload
|
|
24
|
-
* @param refIdx
|
|
25
|
-
*/
|
|
26
|
-
async multiAttestPayload() {
|
|
27
|
-
const payload = [[this, await this.payloadFor(0)]];
|
|
28
|
-
if (this.details) {
|
|
29
|
-
payload.push([this.details, await this.details.payloadFor(0)]);
|
|
30
|
-
}
|
|
31
|
-
if (this.projects?.length) {
|
|
32
|
-
await Promise.all(this.projects.map(async (p) => payload.push(...(await p.multiAttestPayload(payload, 0)))));
|
|
33
|
-
}
|
|
34
|
-
return payload;
|
|
35
|
-
}
|
|
36
|
-
/**
|
|
37
|
-
* Attest a community with its details.
|
|
38
|
-
*
|
|
39
|
-
* If the community exists, it will not be revoked but its details will be updated.
|
|
40
|
-
* @param signer
|
|
41
|
-
* @param details
|
|
42
|
-
*/
|
|
43
|
-
async attest(signer, details, callback) {
|
|
44
|
-
console.log("Attesting community");
|
|
45
|
-
try {
|
|
46
|
-
if (callback)
|
|
47
|
-
callback("preparing");
|
|
48
|
-
const { tx: communityTx, uids: communityUID } = await this.schema.attest({
|
|
49
|
-
signer,
|
|
50
|
-
to: this.recipient,
|
|
51
|
-
refUID: consts_1.nullRef,
|
|
52
|
-
data: this.data,
|
|
53
|
-
});
|
|
54
|
-
this._uid = communityTx[0].hash;
|
|
55
|
-
console.log(this.uid);
|
|
56
|
-
if (callback)
|
|
57
|
-
callback("pending");
|
|
58
|
-
if (details) {
|
|
59
|
-
const communityDetails = new attestations_1.CommunityDetails({
|
|
60
|
-
data: details,
|
|
61
|
-
recipient: this.recipient,
|
|
62
|
-
refUID: this.uid,
|
|
63
|
-
schema: this.schema.gap.findSchema("CommunityDetails"),
|
|
64
|
-
});
|
|
65
|
-
const { tx: communityDetailsTx, uids: communityDetailsUID } = await communityDetails.attest(signer);
|
|
66
|
-
return {
|
|
67
|
-
tx: [communityTx[0], communityDetailsTx[0]],
|
|
68
|
-
uids: [communityUID[0], communityDetailsUID[0]],
|
|
69
|
-
};
|
|
70
|
-
}
|
|
71
|
-
if (callback)
|
|
72
|
-
callback("confirmed");
|
|
73
|
-
return { tx: communityTx, uids: communityUID };
|
|
74
|
-
}
|
|
75
|
-
catch (error) {
|
|
76
|
-
console.error(error);
|
|
77
|
-
throw new SchemaError_1.AttestationError("ATTEST_ERROR", "Error during attestation.", error);
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
static from(attestations, network) {
|
|
81
|
-
return attestations.map((attestation) => {
|
|
82
|
-
const community = new Community({
|
|
83
|
-
...attestation,
|
|
84
|
-
data: {
|
|
85
|
-
community: true,
|
|
86
|
-
},
|
|
87
|
-
schema: GapSchema_1.GapSchema.find("Community", network),
|
|
88
|
-
chainID: attestation.chainID,
|
|
89
|
-
});
|
|
90
|
-
if (attestation.details) {
|
|
91
|
-
const { details } = attestation;
|
|
92
|
-
community.details = new attestations_1.CommunityDetails({
|
|
93
|
-
...details,
|
|
94
|
-
data: {
|
|
95
|
-
...details.data,
|
|
96
|
-
},
|
|
97
|
-
schema: GapSchema_1.GapSchema.find("CommunityDetails", network),
|
|
98
|
-
chainID: attestation.chainID,
|
|
99
|
-
});
|
|
100
|
-
}
|
|
101
|
-
if (attestation.grants) {
|
|
102
|
-
const { grants } = attestation;
|
|
103
|
-
community.grants = Grant_1.Grant.from(grants, network);
|
|
104
|
-
}
|
|
105
|
-
return community;
|
|
106
|
-
});
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
exports.Community = Community;
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
import { Attestation, AttestationArgs } from "../Attestation";
|
|
2
|
-
import { AttestationWithTx } from "../types/attestations";
|
|
3
|
-
import { GapSchema } from "../GapSchema";
|
|
4
|
-
import { MultiAttestPayload, SignerOrProvider, TNetwork } from "core/types";
|
|
5
|
-
export interface IContributorProfile {
|
|
6
|
-
name: string;
|
|
7
|
-
aboutMe?: string;
|
|
8
|
-
github?: string;
|
|
9
|
-
twitter?: string;
|
|
10
|
-
linkedin?: string;
|
|
11
|
-
farcaster?: string;
|
|
12
|
-
}
|
|
13
|
-
export declare class ContributorProfile extends Attestation<IContributorProfile> implements IContributorProfile {
|
|
14
|
-
name: string;
|
|
15
|
-
aboutMe?: string;
|
|
16
|
-
github?: string;
|
|
17
|
-
twitter?: string;
|
|
18
|
-
linkedin?: string;
|
|
19
|
-
farcaster?: string;
|
|
20
|
-
constructor(data: AttestationArgs<IContributorProfile, GapSchema>);
|
|
21
|
-
/**
|
|
22
|
-
* Creates the payload for a multi-attestation.
|
|
23
|
-
*
|
|
24
|
-
* > if Current payload is set, it'll be used as the base payload
|
|
25
|
-
* and the project should refer to an index of the current payload,
|
|
26
|
-
* usually the community position.
|
|
27
|
-
*
|
|
28
|
-
* @param payload
|
|
29
|
-
* @param refIdx
|
|
30
|
-
*/
|
|
31
|
-
multiAttestPayload(): Promise<MultiAttestPayload>;
|
|
32
|
-
/**
|
|
33
|
-
* Attest a community with its details.
|
|
34
|
-
*
|
|
35
|
-
* If the community exists, it will not be revoked but its details will be updated.
|
|
36
|
-
* @param signer
|
|
37
|
-
* @param details
|
|
38
|
-
*/
|
|
39
|
-
attest(signer: SignerOrProvider, callback?: Function): Promise<AttestationWithTx>;
|
|
40
|
-
static from(attestation: ContributorProfile, network: TNetwork): ContributorProfile;
|
|
41
|
-
}
|
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ContributorProfile = void 0;
|
|
4
|
-
const Attestation_1 = require("../Attestation");
|
|
5
|
-
const consts_1 = require("../../consts");
|
|
6
|
-
const SchemaError_1 = require("../SchemaError");
|
|
7
|
-
const AllGapSchemas_1 = require("../AllGapSchemas");
|
|
8
|
-
class ContributorProfile extends Attestation_1.Attestation {
|
|
9
|
-
constructor(data) {
|
|
10
|
-
data.data.type = "contributor-profile";
|
|
11
|
-
super(data);
|
|
12
|
-
}
|
|
13
|
-
/**
|
|
14
|
-
* Creates the payload for a multi-attestation.
|
|
15
|
-
*
|
|
16
|
-
* > if Current payload is set, it'll be used as the base payload
|
|
17
|
-
* and the project should refer to an index of the current payload,
|
|
18
|
-
* usually the community position.
|
|
19
|
-
*
|
|
20
|
-
* @param payload
|
|
21
|
-
* @param refIdx
|
|
22
|
-
*/
|
|
23
|
-
async multiAttestPayload() {
|
|
24
|
-
const payload = [[this, await this.payloadFor(0)]];
|
|
25
|
-
return payload;
|
|
26
|
-
}
|
|
27
|
-
/**
|
|
28
|
-
* Attest a community with its details.
|
|
29
|
-
*
|
|
30
|
-
* If the community exists, it will not be revoked but its details will be updated.
|
|
31
|
-
* @param signer
|
|
32
|
-
* @param details
|
|
33
|
-
*/
|
|
34
|
-
async attest(signer, callback) {
|
|
35
|
-
console.log("Attesting ContributorProfile");
|
|
36
|
-
try {
|
|
37
|
-
if (callback)
|
|
38
|
-
callback("preparing");
|
|
39
|
-
const { tx: ContributorProfileTx, uids: ContributorProfileUID } = await this.schema.attest({
|
|
40
|
-
signer,
|
|
41
|
-
to: this.recipient,
|
|
42
|
-
refUID: consts_1.nullRef,
|
|
43
|
-
data: this.data,
|
|
44
|
-
});
|
|
45
|
-
this._uid = ContributorProfileUID[0];
|
|
46
|
-
console.log(this.uid);
|
|
47
|
-
if (callback)
|
|
48
|
-
callback("pending");
|
|
49
|
-
if (callback)
|
|
50
|
-
callback("confirmed");
|
|
51
|
-
return { tx: ContributorProfileTx, uids: ContributorProfileUID };
|
|
52
|
-
}
|
|
53
|
-
catch (error) {
|
|
54
|
-
console.error(error);
|
|
55
|
-
throw new SchemaError_1.AttestationError("ATTEST_ERROR", "Error during attestation.", error);
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
static from(attestation, network) {
|
|
59
|
-
return new ContributorProfile({
|
|
60
|
-
...attestation,
|
|
61
|
-
data: {
|
|
62
|
-
...attestation.data,
|
|
63
|
-
},
|
|
64
|
-
schema: new AllGapSchemas_1.AllGapSchemas().findSchema("ContributorProfile", consts_1.chainIdToNetwork[attestation.chainID]),
|
|
65
|
-
chainID: attestation.chainID,
|
|
66
|
-
});
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
exports.ContributorProfile = ContributorProfile;
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
import { Attestation } from "../Attestation";
|
|
2
|
-
import { GrantDetails, GrantRound, GrantCompleted, AttestationWithTx } from "../types/attestations";
|
|
3
|
-
import { IMilestone, Milestone } from "./Milestone";
|
|
4
|
-
import { GapSchema } from "../GapSchema";
|
|
5
|
-
import { Hex, MultiAttestPayload, SignerOrProvider, TNetwork } from "core/types";
|
|
6
|
-
import { Community } from "./Community";
|
|
7
|
-
import { IGrantResponse, IProjectResponse, ISummaryProject } from "../karma-indexer/api/types";
|
|
8
|
-
import { GrantUpdate, IGrantUpdate } from "./GrantUpdate";
|
|
9
|
-
export interface IGrant {
|
|
10
|
-
communityUID: Hex;
|
|
11
|
-
}
|
|
12
|
-
export declare class Grant extends Attestation<IGrant> {
|
|
13
|
-
details?: GrantDetails;
|
|
14
|
-
communityUID: Hex;
|
|
15
|
-
verified?: boolean;
|
|
16
|
-
round?: GrantRound;
|
|
17
|
-
milestones: Milestone[];
|
|
18
|
-
community: Community;
|
|
19
|
-
updates: GrantUpdate[];
|
|
20
|
-
members: string[];
|
|
21
|
-
completed?: GrantCompleted;
|
|
22
|
-
project?: IProjectResponse | ISummaryProject;
|
|
23
|
-
categories?: string[];
|
|
24
|
-
verify(signer: SignerOrProvider): Promise<void>;
|
|
25
|
-
/**
|
|
26
|
-
* Add milestones to the grant.
|
|
27
|
-
* @param signer
|
|
28
|
-
* @param milestones
|
|
29
|
-
*/
|
|
30
|
-
addMilestones(milestones: IMilestone[]): void;
|
|
31
|
-
/**
|
|
32
|
-
* Creates the payload for a multi-attestation.
|
|
33
|
-
*
|
|
34
|
-
* > if Current payload is set, it'll be used as the base payload
|
|
35
|
-
* and the project should refer to an index of the current payload,
|
|
36
|
-
* usually the community position.
|
|
37
|
-
*
|
|
38
|
-
* @param payload
|
|
39
|
-
* @param projectIdx
|
|
40
|
-
*/
|
|
41
|
-
multiAttestPayload(currentPayload?: MultiAttestPayload, projectIdx?: number): Promise<[Attestation<unknown, GapSchema>, import("core/types").RawMultiAttestPayload][]>;
|
|
42
|
-
attestProject(signer: SignerOrProvider, originalProjectChainId: number): Promise<AttestationWithTx>;
|
|
43
|
-
/**
|
|
44
|
-
* @inheritdoc
|
|
45
|
-
*/
|
|
46
|
-
attest(signer: SignerOrProvider, projectChainId: number, callback?: Function): Promise<AttestationWithTx>;
|
|
47
|
-
attestUpdate(signer: SignerOrProvider, data: IGrantUpdate, callback?: Function): Promise<void>;
|
|
48
|
-
/**
|
|
49
|
-
* Validate if the grant has a valid reference to a community.
|
|
50
|
-
*/
|
|
51
|
-
protected assertPayload(): boolean;
|
|
52
|
-
complete(signer: SignerOrProvider, data: IGrantUpdate, callback?: Function): Promise<AttestationWithTx>;
|
|
53
|
-
static from(attestations: IGrantResponse[], network: TNetwork): Grant[];
|
|
54
|
-
}
|