@show-karma/karma-gap-sdk 0.3.30 → 0.3.32
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/class/Attestation.d.ts +5 -5
- package/core/class/Attestation.js +24 -19
- package/core/class/GrantProgramRegistry/Allo.d.ts +2 -2
- package/core/class/GrantProgramRegistry/Allo.js +15 -0
- package/core/class/Schema.d.ts +3 -5
- package/core/class/Schema.js +20 -14
- package/core/class/contract/GapContract.d.ts +2 -2
- package/core/class/contract/GapContract.js +13 -4
- package/core/class/entities/Community.d.ts +6 -6
- package/core/class/entities/Community.js +9 -7
- package/core/class/entities/GrantUpdate.d.ts +3 -3
- package/core/class/entities/GrantUpdate.js +16 -14
- package/core/class/entities/Milestone.d.ts +12 -12
- package/core/class/entities/Milestone.js +50 -48
- package/core/class/entities/Project.d.ts +8 -8
- package/core/class/entities/Project.js +24 -22
- package/core/class/entities/ProjectImpact.js +3 -1
- package/core/class/types/attestations.d.ts +5 -5
- package/core/consts.js +14 -8
- package/core/types.d.ts +4 -2
- package/package.json +1 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { Hex, IAttestation, JSONStr, MultiAttestData, SignerOrProvider, TNetwork } from
|
|
2
|
-
import { Schema } from
|
|
3
|
-
import { SchemaItem, SchemaValue } from
|
|
4
|
-
import { GapSchema } from
|
|
1
|
+
import { Hex, IAttestation, JSONStr, MultiAttestData, SignerOrProvider, TNetwork } from "../types";
|
|
2
|
+
import { Schema } from "./Schema";
|
|
3
|
+
import { SchemaItem, SchemaValue } from "@ethereum-attestation-service/eas-sdk";
|
|
4
|
+
import { GapSchema } from "./GapSchema";
|
|
5
5
|
export interface AttestationArgs<T = unknown, S extends Schema = Schema> {
|
|
6
6
|
data: T | string;
|
|
7
7
|
schema: S;
|
|
@@ -88,7 +88,7 @@ export declare class Attestation<T = unknown, S extends Schema = GapSchema> impl
|
|
|
88
88
|
* @param signer
|
|
89
89
|
* @returns
|
|
90
90
|
*/
|
|
91
|
-
revoke(signer: SignerOrProvider): Promise<
|
|
91
|
+
revoke(signer: SignerOrProvider, callback?: Function): Promise<void>;
|
|
92
92
|
/**
|
|
93
93
|
* Attests the data using the specified signer and schema.
|
|
94
94
|
* @param signer - The signer or provider to use for attestation.
|
|
@@ -72,7 +72,7 @@ class Attestation {
|
|
|
72
72
|
setValues(values) {
|
|
73
73
|
const isJsonSchema = this.schema.isJsonSchema();
|
|
74
74
|
if (isJsonSchema)
|
|
75
|
-
this.schema.setValue(
|
|
75
|
+
this.schema.setValue("json", JSON.stringify(values));
|
|
76
76
|
this._data = values;
|
|
77
77
|
Object.entries(values).forEach(([key, value]) => {
|
|
78
78
|
this[key] = value;
|
|
@@ -92,7 +92,7 @@ class Attestation {
|
|
|
92
92
|
* @returns
|
|
93
93
|
*/
|
|
94
94
|
fromDecodedSchema(data) {
|
|
95
|
-
return typeof data ===
|
|
95
|
+
return typeof data === "string"
|
|
96
96
|
? Attestation.fromDecodedSchema(data)
|
|
97
97
|
: data;
|
|
98
98
|
}
|
|
@@ -102,8 +102,9 @@ class Attestation {
|
|
|
102
102
|
* @param signer
|
|
103
103
|
* @returns
|
|
104
104
|
*/
|
|
105
|
-
revoke(signer) {
|
|
105
|
+
async revoke(signer, callback) {
|
|
106
106
|
try {
|
|
107
|
+
callback?.("preparing");
|
|
107
108
|
return GapContract_1.GapContract.multiRevoke(signer, [
|
|
108
109
|
{
|
|
109
110
|
data: [
|
|
@@ -114,11 +115,13 @@ class Attestation {
|
|
|
114
115
|
],
|
|
115
116
|
schema: this.schema.uid,
|
|
116
117
|
},
|
|
117
|
-
])
|
|
118
|
+
]).then(() => {
|
|
119
|
+
callback?.("confirmed");
|
|
120
|
+
});
|
|
118
121
|
}
|
|
119
122
|
catch (error) {
|
|
120
123
|
console.error(error);
|
|
121
|
-
throw new SchemaError_1.SchemaError(
|
|
124
|
+
throw new SchemaError_1.SchemaError("REVOKE_ERROR", "Error revoking attestation.");
|
|
122
125
|
}
|
|
123
126
|
}
|
|
124
127
|
/**
|
|
@@ -129,7 +132,9 @@ class Attestation {
|
|
|
129
132
|
* @throws An `AttestationError` if an error occurs during attestation.
|
|
130
133
|
*/
|
|
131
134
|
async attest(signer, ...args) {
|
|
132
|
-
const callback = typeof args[args.length - 1] ===
|
|
135
|
+
const callback = typeof args[args.length - 1] === "function"
|
|
136
|
+
? args.pop()
|
|
137
|
+
: null;
|
|
133
138
|
console.log(`Attesting ${this.schema.name}`);
|
|
134
139
|
try {
|
|
135
140
|
const uid = await this.schema.attest({
|
|
@@ -137,14 +142,14 @@ class Attestation {
|
|
|
137
142
|
to: this.recipient,
|
|
138
143
|
refUID: this.refUID,
|
|
139
144
|
signer,
|
|
140
|
-
callback: callback
|
|
145
|
+
callback: callback,
|
|
141
146
|
});
|
|
142
147
|
this._uid = uid;
|
|
143
148
|
console.log(`Attested ${this.schema.name} with UID ${uid}`);
|
|
144
149
|
}
|
|
145
150
|
catch (error) {
|
|
146
151
|
console.error(error);
|
|
147
|
-
throw new SchemaError_1.AttestationError(
|
|
152
|
+
throw new SchemaError_1.AttestationError("ATTEST_ERROR", "Error during attestation.");
|
|
148
153
|
}
|
|
149
154
|
}
|
|
150
155
|
/**
|
|
@@ -194,12 +199,12 @@ class Attestation {
|
|
|
194
199
|
const { remoteClient } = GAP_1.GAP;
|
|
195
200
|
if (this.type) {
|
|
196
201
|
this._data.type = this.type;
|
|
197
|
-
this.schema.setValue(
|
|
202
|
+
this.schema.setValue("json", JSON.stringify(this._data));
|
|
198
203
|
}
|
|
199
204
|
if (remoteClient && JSON.stringify(this._data)?.length > 1500) {
|
|
200
205
|
const cid = await remoteClient.save(this._data, this.schema.name);
|
|
201
206
|
const encodedData = remoteClient.encode(cid);
|
|
202
|
-
this.schema.setValue(
|
|
207
|
+
this.schema.setValue("json", JSON.stringify(encodedData));
|
|
203
208
|
}
|
|
204
209
|
}
|
|
205
210
|
const payload = (encode = true) => ({
|
|
@@ -234,17 +239,17 @@ class Attestation {
|
|
|
234
239
|
const parsed = JSON.parse(data);
|
|
235
240
|
if (data.length < 2 && !/\{.*\}/gim.test(data))
|
|
236
241
|
return {};
|
|
237
|
-
if (parsed.length === 1 && parsed[0].name ===
|
|
242
|
+
if (parsed.length === 1 && parsed[0].name === "json") {
|
|
238
243
|
const { value } = parsed[0];
|
|
239
|
-
return (typeof value.value ===
|
|
244
|
+
return (typeof value.value === "string"
|
|
240
245
|
? JSON.parse(value.value)
|
|
241
246
|
: value.value);
|
|
242
247
|
}
|
|
243
248
|
if (parsed && Array.isArray(parsed)) {
|
|
244
249
|
return parsed.reduce((acc, curr) => {
|
|
245
250
|
const { value } = curr.value;
|
|
246
|
-
if (curr.type.includes(
|
|
247
|
-
acc[curr.name] = [
|
|
251
|
+
if (curr.type.includes("uint")) {
|
|
252
|
+
acc[curr.name] = ["string", "bigint"].includes(typeof value)
|
|
248
253
|
? BigInt(value)
|
|
249
254
|
: Number(value);
|
|
250
255
|
}
|
|
@@ -253,11 +258,11 @@ class Attestation {
|
|
|
253
258
|
return acc;
|
|
254
259
|
}, {});
|
|
255
260
|
}
|
|
256
|
-
throw new SchemaError_1.SchemaError(
|
|
261
|
+
throw new SchemaError_1.SchemaError("INVALID_DATA", "Data must be a valid JSON array string.");
|
|
257
262
|
}
|
|
258
263
|
catch (error) {
|
|
259
264
|
console.error(error);
|
|
260
|
-
throw new SchemaError_1.SchemaError(
|
|
265
|
+
throw new SchemaError_1.SchemaError("INVALID_DATA", "Data must be a valid JSON string.");
|
|
261
266
|
}
|
|
262
267
|
}
|
|
263
268
|
/**
|
|
@@ -289,10 +294,10 @@ class Attestation {
|
|
|
289
294
|
assert(args, strict = false) {
|
|
290
295
|
const { schema, uid } = args;
|
|
291
296
|
if (!schema || !(schema instanceof Schema_1.Schema)) {
|
|
292
|
-
throw new SchemaError_1.SchemaError(
|
|
297
|
+
throw new SchemaError_1.SchemaError("MISSING_FIELD", "Schema must be an array.");
|
|
293
298
|
}
|
|
294
299
|
if (!uid) {
|
|
295
|
-
throw new SchemaError_1.SchemaError(
|
|
300
|
+
throw new SchemaError_1.SchemaError("MISSING_FIELD", "Schema uid is required");
|
|
296
301
|
}
|
|
297
302
|
if (strict)
|
|
298
303
|
Schema_1.Schema.validate(this.schema.gap.network);
|
|
@@ -323,7 +328,7 @@ class Attestation {
|
|
|
323
328
|
recipient: to,
|
|
324
329
|
attester: from,
|
|
325
330
|
schema,
|
|
326
|
-
uid:
|
|
331
|
+
uid: "0x0",
|
|
327
332
|
createdAt: new Date(),
|
|
328
333
|
chainID: consts_1.Networks[schema.gap.network].chainId,
|
|
329
334
|
});
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { ethers } from "ethers";
|
|
2
|
-
import { GrantArgs } from "../types/allo";
|
|
3
2
|
import { NFTStorage } from "nft.storage";
|
|
4
3
|
export declare class AlloBase {
|
|
5
4
|
private signer;
|
|
@@ -9,8 +8,9 @@ export declare class AlloBase {
|
|
|
9
8
|
constructor(signer: ethers.Signer, ipfsStorage: NFTStorage, chainId: number);
|
|
10
9
|
saveAndGetCID(data: any): Promise<import("nft.storage").CIDString>;
|
|
11
10
|
encodeStrategyInitData(applicationStart: number, applicationEnd: number, roundStart: number, roundEnd: number, payoutToken: string): Promise<string>;
|
|
12
|
-
createGrant(args:
|
|
11
|
+
createGrant(args: any): Promise<{
|
|
13
12
|
poolId: string;
|
|
14
13
|
txHash: string;
|
|
15
14
|
}>;
|
|
15
|
+
updatePoolMetadata(poolId: string, poolMetadata: any): Promise<any>;
|
|
16
16
|
}
|
|
@@ -82,5 +82,20 @@ class AlloBase {
|
|
|
82
82
|
console.error(`Failed to create pool: ${error}`);
|
|
83
83
|
}
|
|
84
84
|
}
|
|
85
|
+
async updatePoolMetadata(poolId, poolMetadata) {
|
|
86
|
+
try {
|
|
87
|
+
const metadata_cid = await this.saveAndGetCID(poolMetadata);
|
|
88
|
+
const metadata = {
|
|
89
|
+
protocol: 1,
|
|
90
|
+
pointer: metadata_cid,
|
|
91
|
+
};
|
|
92
|
+
const tx = await this.contract.updatePoolMetadata(poolId, metadata);
|
|
93
|
+
const receipt = await tx.wait();
|
|
94
|
+
return receipt;
|
|
95
|
+
}
|
|
96
|
+
catch (error) {
|
|
97
|
+
console.error(`Failed to update pool metadata: ${error}`);
|
|
98
|
+
}
|
|
99
|
+
}
|
|
85
100
|
}
|
|
86
101
|
exports.AlloBase = AlloBase;
|
package/core/class/Schema.d.ts
CHANGED
|
@@ -140,23 +140,21 @@ export declare abstract class Schema<T extends string = string> implements Schem
|
|
|
140
140
|
* @param {Object} param0 - An object containing the schema and other optional settings.
|
|
141
141
|
* @returns {Object} An object containing the attestation results, including the CID if 'ipfsKey' is enabled.
|
|
142
142
|
*/
|
|
143
|
-
attest<T>({ data, to, signer, refUID, callback }: AttestArgs<T>
|
|
144
|
-
callback?: (status: string) => void;
|
|
145
|
-
}): Promise<Hex>;
|
|
143
|
+
attest<T>({ data, to, signer, refUID, callback, }: AttestArgs<T>): Promise<Hex>;
|
|
146
144
|
/**
|
|
147
145
|
* Bulk attest a set of attestations.
|
|
148
146
|
* @param signer
|
|
149
147
|
* @param entities
|
|
150
148
|
* @returns
|
|
151
149
|
*/
|
|
152
|
-
multiAttest(signer: SignerOrProvider, entities?: Attestation[], callback?: Function): Promise<
|
|
150
|
+
multiAttest(signer: SignerOrProvider, entities?: Attestation[], callback?: Function): Promise<void>;
|
|
153
151
|
/**
|
|
154
152
|
* Revokes a set of attestations by their UIDs.
|
|
155
153
|
* @param signer
|
|
156
154
|
* @param uids
|
|
157
155
|
* @returns
|
|
158
156
|
*/
|
|
159
|
-
multiRevoke(signer: SignerOrProvider, toRevoke: MultiRevokeArgs[]): Promise<void>;
|
|
157
|
+
multiRevoke(signer: SignerOrProvider, toRevoke: MultiRevokeArgs[], callback?: Function): Promise<void>;
|
|
160
158
|
static exists(name: string, network: TNetwork): Schema<string>;
|
|
161
159
|
/**
|
|
162
160
|
* Adds the schema signature to a shares list. Use Schema.get("SchemaName") to get the schema.
|
package/core/class/Schema.js
CHANGED
|
@@ -219,7 +219,7 @@ class Schema {
|
|
|
219
219
|
* @param {Object} param0 - An object containing the schema and other optional settings.
|
|
220
220
|
* @returns {Object} An object containing the attestation results, including the CID if 'ipfsKey' is enabled.
|
|
221
221
|
*/
|
|
222
|
-
async attest({ data, to, signer, refUID, callback }) {
|
|
222
|
+
async attest({ data, to, signer, refUID, callback, }) {
|
|
223
223
|
const eas = this.gap.eas.connect(signer);
|
|
224
224
|
if (this.references && !refUID)
|
|
225
225
|
throw new SchemaError_1.AttestationError("INVALID_REFERENCE", "Attestation schema references another schema but no reference UID was provided.");
|
|
@@ -258,19 +258,18 @@ class Schema {
|
|
|
258
258
|
},
|
|
259
259
|
},
|
|
260
260
|
};
|
|
261
|
+
callback?.("preparing");
|
|
261
262
|
if (consts_1.useDefaultAttestation.includes(this.name)) {
|
|
262
263
|
const tx = await eas.attest({
|
|
263
264
|
schema: this.uid,
|
|
264
265
|
data: payload.data.payload,
|
|
265
266
|
});
|
|
266
|
-
|
|
267
|
-
callback('pending');
|
|
267
|
+
callback?.("pending");
|
|
268
268
|
const txResult = await tx.wait();
|
|
269
|
-
|
|
270
|
-
callback('completed');
|
|
269
|
+
callback?.("confirmed");
|
|
271
270
|
return txResult;
|
|
272
271
|
}
|
|
273
|
-
const uid = await GapContract_1.GapContract.attest(signer, payload);
|
|
272
|
+
const uid = await GapContract_1.GapContract.attest(signer, payload, callback);
|
|
274
273
|
return uid;
|
|
275
274
|
}
|
|
276
275
|
/**
|
|
@@ -301,14 +300,17 @@ class Schema {
|
|
|
301
300
|
expirationTime: 0n,
|
|
302
301
|
})),
|
|
303
302
|
}));
|
|
303
|
+
if (callback)
|
|
304
|
+
callback("preparing");
|
|
304
305
|
const tx = await eas.multiAttest(payload, {
|
|
305
306
|
gasLimit: 5000000n,
|
|
306
307
|
});
|
|
307
308
|
if (callback)
|
|
308
|
-
callback(
|
|
309
|
-
return tx.wait()
|
|
310
|
-
|
|
311
|
-
|
|
309
|
+
callback("pending");
|
|
310
|
+
return tx.wait().then(() => {
|
|
311
|
+
if (callback)
|
|
312
|
+
callback("confirmed");
|
|
313
|
+
});
|
|
312
314
|
}
|
|
313
315
|
/**
|
|
314
316
|
* Revokes a set of attestations by their UIDs.
|
|
@@ -316,7 +318,8 @@ class Schema {
|
|
|
316
318
|
* @param uids
|
|
317
319
|
* @returns
|
|
318
320
|
*/
|
|
319
|
-
async multiRevoke(signer, toRevoke) {
|
|
321
|
+
async multiRevoke(signer, toRevoke, callback) {
|
|
322
|
+
callback?.("preparing");
|
|
320
323
|
const groupBySchema = toRevoke.reduce((acc, { uid, schemaId }) => {
|
|
321
324
|
if (!acc[schemaId])
|
|
322
325
|
acc[schemaId] = [];
|
|
@@ -331,7 +334,10 @@ class Schema {
|
|
|
331
334
|
const tx = await eas.multiRevoke(payload, {
|
|
332
335
|
gasLimit: 5000000n,
|
|
333
336
|
});
|
|
334
|
-
|
|
337
|
+
callback?.("pending");
|
|
338
|
+
return tx.wait().then(() => {
|
|
339
|
+
callback?.("confirmed");
|
|
340
|
+
});
|
|
335
341
|
}
|
|
336
342
|
static exists(name, network) {
|
|
337
343
|
return this.schemas[network].find((schema) => schema.name === name);
|
|
@@ -455,11 +461,11 @@ class Schema {
|
|
|
455
461
|
}
|
|
456
462
|
exports.Schema = Schema;
|
|
457
463
|
Schema.schemas = {
|
|
458
|
-
|
|
464
|
+
"optimism-sepolia": [],
|
|
459
465
|
// "optimism-goerli": [],
|
|
460
466
|
optimism: [],
|
|
461
467
|
sepolia: [],
|
|
462
468
|
arbitrum: [],
|
|
463
469
|
celo: [],
|
|
464
|
-
|
|
470
|
+
"base-sepolia": [],
|
|
465
471
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Hex, RawAttestationPayload, RawMultiAttestPayload, SignerOrProvider } from "core/types";
|
|
1
|
+
import { CallbackStatus, Hex, RawAttestationPayload, RawMultiAttestPayload, SignerOrProvider } from "core/types";
|
|
2
2
|
import { MultiRevocationRequest } from "@ethereum-attestation-service/eas-sdk";
|
|
3
3
|
export declare class GapContract {
|
|
4
4
|
static nonces: {
|
|
@@ -30,7 +30,7 @@ export declare class GapContract {
|
|
|
30
30
|
* @param payload
|
|
31
31
|
* @returns
|
|
32
32
|
*/
|
|
33
|
-
static attest(signer: SignerOrProvider, payload: RawAttestationPayload): Promise<`0x${string}`>;
|
|
33
|
+
static attest(signer: SignerOrProvider, payload: RawAttestationPayload, callback?: ((status: CallbackStatus) => void) & ((status: string) => void)): Promise<`0x${string}`>;
|
|
34
34
|
static attestBySig(signer: SignerOrProvider, payload: RawAttestationPayload): Promise<`0x${string}`>;
|
|
35
35
|
/**
|
|
36
36
|
* Performs a referenced multi attestation.
|
|
@@ -72,16 +72,23 @@ class GapContract {
|
|
|
72
72
|
* @param payload
|
|
73
73
|
* @returns
|
|
74
74
|
*/
|
|
75
|
-
static async attest(signer, payload) {
|
|
75
|
+
static async attest(signer, payload, callback) {
|
|
76
76
|
const contract = await GAP_1.GAP.getMulticall(signer);
|
|
77
77
|
if (GAP_1.GAP.gelatoOpts?.useGasless) {
|
|
78
78
|
return this.attestBySig(signer, payload);
|
|
79
79
|
}
|
|
80
|
-
|
|
80
|
+
callback?.("preparing");
|
|
81
|
+
const tx = await contract
|
|
82
|
+
.attest({
|
|
81
83
|
schema: payload.schema,
|
|
82
84
|
data: payload.data.payload,
|
|
85
|
+
})
|
|
86
|
+
.then((res) => {
|
|
87
|
+
callback?.("pending");
|
|
88
|
+
return res;
|
|
83
89
|
});
|
|
84
90
|
const result = await tx.wait?.();
|
|
91
|
+
callback?.("confirmed");
|
|
85
92
|
const attestations = (0, eas_sdk_1.getUIDsFromAttestReceipt)(result)[0];
|
|
86
93
|
return attestations;
|
|
87
94
|
}
|
|
@@ -115,12 +122,14 @@ class GapContract {
|
|
|
115
122
|
if (GAP_1.GAP.gelatoOpts?.useGasless) {
|
|
116
123
|
return this.multiAttestBySig(signer, payload);
|
|
117
124
|
}
|
|
125
|
+
if (callback)
|
|
126
|
+
callback("preparing");
|
|
118
127
|
const tx = await contract.multiSequentialAttest(payload.map((p) => p.payload));
|
|
119
128
|
if (callback)
|
|
120
|
-
callback(
|
|
129
|
+
callback("pending");
|
|
121
130
|
const result = await tx.wait?.();
|
|
122
131
|
if (callback)
|
|
123
|
-
callback(
|
|
132
|
+
callback("confirmed");
|
|
124
133
|
const attestations = (0, eas_sdk_1.getUIDsFromAttestReceipt)(result);
|
|
125
134
|
return attestations;
|
|
126
135
|
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { Attestation } from
|
|
2
|
-
import { CommunityDetails, ICommunityDetails } from
|
|
3
|
-
import { Project } from
|
|
4
|
-
import { MultiAttestPayload, SignerOrProvider, TNetwork } from
|
|
5
|
-
import { Grant } from
|
|
6
|
-
import { ICommunityResponse } from
|
|
1
|
+
import { Attestation } from "../Attestation";
|
|
2
|
+
import { 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
7
|
export interface ICommunity {
|
|
8
8
|
community: true;
|
|
9
9
|
}
|
|
@@ -41,8 +41,10 @@ class Community extends Attestation_1.Attestation {
|
|
|
41
41
|
* @param details
|
|
42
42
|
*/
|
|
43
43
|
async attest(signer, details, callback) {
|
|
44
|
-
console.log(
|
|
44
|
+
console.log("Attesting community");
|
|
45
45
|
try {
|
|
46
|
+
if (callback)
|
|
47
|
+
callback("preparing");
|
|
46
48
|
this._uid = await this.schema.attest({
|
|
47
49
|
signer,
|
|
48
50
|
to: this.recipient,
|
|
@@ -51,22 +53,22 @@ class Community extends Attestation_1.Attestation {
|
|
|
51
53
|
});
|
|
52
54
|
console.log(this.uid);
|
|
53
55
|
if (callback)
|
|
54
|
-
callback(
|
|
56
|
+
callback("pending");
|
|
55
57
|
if (details) {
|
|
56
58
|
const communityDetails = new attestations_1.CommunityDetails({
|
|
57
59
|
data: details,
|
|
58
60
|
recipient: this.recipient,
|
|
59
61
|
refUID: this.uid,
|
|
60
|
-
schema: this.schema.gap.findSchema(
|
|
62
|
+
schema: this.schema.gap.findSchema("CommunityDetails"),
|
|
61
63
|
});
|
|
62
64
|
await communityDetails.attest(signer);
|
|
63
65
|
}
|
|
64
66
|
if (callback)
|
|
65
|
-
callback(
|
|
67
|
+
callback("confirmed");
|
|
66
68
|
}
|
|
67
69
|
catch (error) {
|
|
68
70
|
console.error(error);
|
|
69
|
-
throw new SchemaError_1.AttestationError(
|
|
71
|
+
throw new SchemaError_1.AttestationError("ATTEST_ERROR", "Error during attestation.");
|
|
70
72
|
}
|
|
71
73
|
}
|
|
72
74
|
static from(attestations, network) {
|
|
@@ -76,7 +78,7 @@ class Community extends Attestation_1.Attestation {
|
|
|
76
78
|
data: {
|
|
77
79
|
community: true,
|
|
78
80
|
},
|
|
79
|
-
schema: GapSchema_1.GapSchema.find(
|
|
81
|
+
schema: GapSchema_1.GapSchema.find("Community", network),
|
|
80
82
|
chainID: attestation.chainID,
|
|
81
83
|
});
|
|
82
84
|
if (attestation.details) {
|
|
@@ -86,7 +88,7 @@ class Community extends Attestation_1.Attestation {
|
|
|
86
88
|
data: {
|
|
87
89
|
...details.data,
|
|
88
90
|
},
|
|
89
|
-
schema: GapSchema_1.GapSchema.find(
|
|
91
|
+
schema: GapSchema_1.GapSchema.find("CommunityDetails", network),
|
|
90
92
|
chainID: attestation.chainID,
|
|
91
93
|
});
|
|
92
94
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { SignerOrProvider, TNetwork } from
|
|
2
|
-
import { Attestation } from
|
|
1
|
+
import { SignerOrProvider, TNetwork } from "../../../core/types";
|
|
2
|
+
import { Attestation } from "../Attestation";
|
|
3
3
|
export interface _IGrantUpdate extends GrantUpdate {
|
|
4
4
|
}
|
|
5
5
|
export interface IGrantUpdate {
|
|
@@ -7,7 +7,7 @@ export interface IGrantUpdate {
|
|
|
7
7
|
text: string;
|
|
8
8
|
type?: string;
|
|
9
9
|
}
|
|
10
|
-
type IStatus =
|
|
10
|
+
type IStatus = "verified";
|
|
11
11
|
export interface IGrantUpdateStatus {
|
|
12
12
|
type: `grant-update-${IStatus}`;
|
|
13
13
|
reason?: string;
|
|
@@ -19,6 +19,8 @@ class GrantUpdate extends Attestation_1.Attestation {
|
|
|
19
19
|
async attestStatus(signer, schema, callback) {
|
|
20
20
|
const eas = this.schema.gap.eas.connect(signer);
|
|
21
21
|
try {
|
|
22
|
+
if (callback)
|
|
23
|
+
callback("preparing");
|
|
22
24
|
const tx = await eas.attest({
|
|
23
25
|
schema: schema.uid,
|
|
24
26
|
data: {
|
|
@@ -30,15 +32,15 @@ class GrantUpdate extends Attestation_1.Attestation {
|
|
|
30
32
|
},
|
|
31
33
|
});
|
|
32
34
|
if (callback)
|
|
33
|
-
callback(
|
|
35
|
+
callback("pending");
|
|
34
36
|
const uid = await tx.wait();
|
|
35
37
|
if (callback)
|
|
36
|
-
callback(
|
|
38
|
+
callback("confirmed");
|
|
37
39
|
console.log(uid);
|
|
38
40
|
}
|
|
39
41
|
catch (error) {
|
|
40
42
|
console.error(error);
|
|
41
|
-
throw new SchemaError_1.AttestationError(
|
|
43
|
+
throw new SchemaError_1.AttestationError("ATTEST_ERROR", error.message);
|
|
42
44
|
}
|
|
43
45
|
}
|
|
44
46
|
/**
|
|
@@ -47,17 +49,17 @@ class GrantUpdate extends Attestation_1.Attestation {
|
|
|
47
49
|
* @param signer
|
|
48
50
|
* @param reason
|
|
49
51
|
*/
|
|
50
|
-
async verify(signer, reason =
|
|
51
|
-
console.log(
|
|
52
|
-
const schema = this.schema.gap.findSchema(
|
|
53
|
-
schema.setValue(
|
|
54
|
-
schema.setValue(
|
|
55
|
-
console.log(
|
|
52
|
+
async verify(signer, reason = "", callback) {
|
|
53
|
+
console.log("Verifying");
|
|
54
|
+
const schema = this.schema.gap.findSchema("GrantUpdateStatus");
|
|
55
|
+
schema.setValue("type", "grant-update-verified");
|
|
56
|
+
schema.setValue("reason", reason);
|
|
57
|
+
console.log("Before attest grant update verified");
|
|
56
58
|
await this.attestStatus(signer, schema, callback);
|
|
57
|
-
console.log(
|
|
59
|
+
console.log("After attest grant update verified");
|
|
58
60
|
this.verified.push(new GrantUpdateStatus({
|
|
59
61
|
data: {
|
|
60
|
-
type:
|
|
62
|
+
type: "grant-update-verified",
|
|
61
63
|
reason,
|
|
62
64
|
},
|
|
63
65
|
refUID: this.uid,
|
|
@@ -72,16 +74,16 @@ class GrantUpdate extends Attestation_1.Attestation {
|
|
|
72
74
|
data: {
|
|
73
75
|
...attestation.data,
|
|
74
76
|
},
|
|
75
|
-
schema: new AllGapSchemas_1.AllGapSchemas().findSchema(
|
|
77
|
+
schema: new AllGapSchemas_1.AllGapSchemas().findSchema("GrantUpdate", consts_1.chainIdToNetwork[attestation.chainID]),
|
|
76
78
|
chainID: attestation.chainID,
|
|
77
79
|
});
|
|
78
80
|
if (attestation.verified?.length > 0) {
|
|
79
|
-
grantUpdate.verified = attestation.verified.map(m => new GrantUpdateStatus({
|
|
81
|
+
grantUpdate.verified = attestation.verified.map((m) => new GrantUpdateStatus({
|
|
80
82
|
...m,
|
|
81
83
|
data: {
|
|
82
84
|
...m.data,
|
|
83
85
|
},
|
|
84
|
-
schema: new AllGapSchemas_1.AllGapSchemas().findSchema(
|
|
86
|
+
schema: new AllGapSchemas_1.AllGapSchemas().findSchema("GrantUpdateStatus", consts_1.chainIdToNetwork[attestation.chainID]),
|
|
85
87
|
chainID: attestation.chainID,
|
|
86
88
|
}));
|
|
87
89
|
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { MultiAttestPayload, SignerOrProvider, TNetwork } from
|
|
2
|
-
import { Attestation } from
|
|
3
|
-
import { GapSchema } from
|
|
4
|
-
import { IMilestoneResponse } from
|
|
5
|
-
import { MilestoneCompleted } from
|
|
1
|
+
import { MultiAttestPayload, SignerOrProvider, TNetwork } from "../../types";
|
|
2
|
+
import { Attestation } from "../Attestation";
|
|
3
|
+
import { GapSchema } from "../GapSchema";
|
|
4
|
+
import { IMilestoneResponse } from "../karma-indexer/api/types";
|
|
5
|
+
import { MilestoneCompleted } from "../types/attestations";
|
|
6
6
|
export interface IMilestone {
|
|
7
7
|
title: string;
|
|
8
8
|
startsAt?: number;
|
|
@@ -52,13 +52,13 @@ export declare class Milestone extends Attestation<IMilestone> implements IMiles
|
|
|
52
52
|
* @param signer
|
|
53
53
|
* @param reason
|
|
54
54
|
*/
|
|
55
|
-
complete(signer: SignerOrProvider, reason?: string): Promise<void>;
|
|
55
|
+
complete(signer: SignerOrProvider, reason?: string, callback?: Function): Promise<void>;
|
|
56
56
|
/**
|
|
57
57
|
* Revokes the completed status of the milestone. If the milestone is not completed,
|
|
58
58
|
* it will throw an error.
|
|
59
59
|
* @param signer
|
|
60
60
|
*/
|
|
61
|
-
revokeCompletion(signer: SignerOrProvider): Promise<void>;
|
|
61
|
+
revokeCompletion(signer: SignerOrProvider, callback?: Function): Promise<void>;
|
|
62
62
|
/**
|
|
63
63
|
* Creates the payload for a multi-attestation.
|
|
64
64
|
*
|
|
@@ -80,10 +80,10 @@ export declare class Milestone extends Attestation<IMilestone> implements IMiles
|
|
|
80
80
|
private attestStatus;
|
|
81
81
|
static from(attestations: IMilestoneResponse[], network: TNetwork): Milestone[];
|
|
82
82
|
/**
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
83
|
+
* Verify this milestone. If the milestone is not completed or already verified,
|
|
84
|
+
* it will throw an error.
|
|
85
|
+
* @param signer
|
|
86
|
+
* @param reason
|
|
87
|
+
*/
|
|
88
88
|
verify(signer: SignerOrProvider, reason?: string, callback?: Function): Promise<void>;
|
|
89
89
|
}
|
|
@@ -11,7 +11,7 @@ class Milestone extends Attestation_1.Attestation {
|
|
|
11
11
|
constructor() {
|
|
12
12
|
super(...arguments);
|
|
13
13
|
this.verified = [];
|
|
14
|
-
this.type =
|
|
14
|
+
this.type = "milestone";
|
|
15
15
|
}
|
|
16
16
|
/**
|
|
17
17
|
* Approves this milestone. If the milestone is not completed or already approved,
|
|
@@ -19,16 +19,16 @@ class Milestone extends Attestation_1.Attestation {
|
|
|
19
19
|
* @param signer
|
|
20
20
|
* @param reason
|
|
21
21
|
*/
|
|
22
|
-
async approve(signer, reason =
|
|
22
|
+
async approve(signer, reason = "", callback) {
|
|
23
23
|
if (!this.completed)
|
|
24
|
-
throw new SchemaError_1.AttestationError(
|
|
25
|
-
const schema = this.schema.gap.findSchema(
|
|
26
|
-
schema.setValue(
|
|
27
|
-
schema.setValue(
|
|
28
|
-
await this.attestStatus(signer, schema);
|
|
24
|
+
throw new SchemaError_1.AttestationError("ATTEST_ERROR", "Milestone is not completed");
|
|
25
|
+
const schema = this.schema.gap.findSchema("MilestoneCompleted");
|
|
26
|
+
schema.setValue("type", "approved");
|
|
27
|
+
schema.setValue("reason", reason);
|
|
28
|
+
await this.attestStatus(signer, schema, callback);
|
|
29
29
|
this.approved = new attestations_1.MilestoneCompleted({
|
|
30
30
|
data: {
|
|
31
|
-
type:
|
|
31
|
+
type: "approved",
|
|
32
32
|
reason,
|
|
33
33
|
},
|
|
34
34
|
refUID: this.uid,
|
|
@@ -43,7 +43,7 @@ class Milestone extends Attestation_1.Attestation {
|
|
|
43
43
|
*/
|
|
44
44
|
async revokeApproval(signer) {
|
|
45
45
|
if (!this.approved)
|
|
46
|
-
throw new SchemaError_1.AttestationError(
|
|
46
|
+
throw new SchemaError_1.AttestationError("ATTEST_ERROR", "Milestone is not approved");
|
|
47
47
|
await this.approved.schema.multiRevoke(signer, [
|
|
48
48
|
{
|
|
49
49
|
schemaId: this.completed.schema.uid,
|
|
@@ -57,16 +57,16 @@ class Milestone extends Attestation_1.Attestation {
|
|
|
57
57
|
* @param signer
|
|
58
58
|
* @param reason
|
|
59
59
|
*/
|
|
60
|
-
async reject(signer, reason =
|
|
60
|
+
async reject(signer, reason = "") {
|
|
61
61
|
if (!this.completed)
|
|
62
|
-
throw new SchemaError_1.AttestationError(
|
|
63
|
-
const schema = this.schema.gap.findSchema(
|
|
64
|
-
schema.setValue(
|
|
65
|
-
schema.setValue(
|
|
62
|
+
throw new SchemaError_1.AttestationError("ATTEST_ERROR", "Milestone is not completed");
|
|
63
|
+
const schema = this.schema.gap.findSchema("MilestoneCompleted");
|
|
64
|
+
schema.setValue("type", "rejected");
|
|
65
|
+
schema.setValue("reason", reason);
|
|
66
66
|
await this.attestStatus(signer, schema);
|
|
67
67
|
this.rejected = new attestations_1.MilestoneCompleted({
|
|
68
68
|
data: {
|
|
69
|
-
type:
|
|
69
|
+
type: "rejected",
|
|
70
70
|
reason,
|
|
71
71
|
},
|
|
72
72
|
refUID: this.uid,
|
|
@@ -81,7 +81,7 @@ class Milestone extends Attestation_1.Attestation {
|
|
|
81
81
|
*/
|
|
82
82
|
async revokeRejection(signer) {
|
|
83
83
|
if (!this.rejected)
|
|
84
|
-
throw new SchemaError_1.AttestationError(
|
|
84
|
+
throw new SchemaError_1.AttestationError("ATTEST_ERROR", "Milestone is not rejected");
|
|
85
85
|
await this.rejected.schema.multiRevoke(signer, [
|
|
86
86
|
{
|
|
87
87
|
schemaId: this.completed.schema.uid,
|
|
@@ -95,14 +95,14 @@ class Milestone extends Attestation_1.Attestation {
|
|
|
95
95
|
* @param signer
|
|
96
96
|
* @param reason
|
|
97
97
|
*/
|
|
98
|
-
async complete(signer, reason =
|
|
99
|
-
const schema = this.schema.gap.findSchema(
|
|
100
|
-
schema.setValue(
|
|
101
|
-
schema.setValue(
|
|
102
|
-
await this.attestStatus(signer, schema);
|
|
98
|
+
async complete(signer, reason = "", callback) {
|
|
99
|
+
const schema = this.schema.gap.findSchema("MilestoneCompleted");
|
|
100
|
+
schema.setValue("type", "completed");
|
|
101
|
+
schema.setValue("reason", reason);
|
|
102
|
+
await this.attestStatus(signer, schema, callback);
|
|
103
103
|
this.completed = new attestations_1.MilestoneCompleted({
|
|
104
104
|
data: {
|
|
105
|
-
type:
|
|
105
|
+
type: "completed",
|
|
106
106
|
reason,
|
|
107
107
|
},
|
|
108
108
|
refUID: this.uid,
|
|
@@ -115,15 +115,15 @@ class Milestone extends Attestation_1.Attestation {
|
|
|
115
115
|
* it will throw an error.
|
|
116
116
|
* @param signer
|
|
117
117
|
*/
|
|
118
|
-
async revokeCompletion(signer) {
|
|
118
|
+
async revokeCompletion(signer, callback) {
|
|
119
119
|
if (!this.completed)
|
|
120
|
-
throw new SchemaError_1.AttestationError(
|
|
120
|
+
throw new SchemaError_1.AttestationError("ATTEST_ERROR", "Milestone is not completed");
|
|
121
121
|
await this.completed.schema.multiRevoke(signer, [
|
|
122
122
|
{
|
|
123
123
|
schemaId: this.completed.schema.uid,
|
|
124
124
|
uid: this.completed.uid,
|
|
125
125
|
},
|
|
126
|
-
]);
|
|
126
|
+
], callback);
|
|
127
127
|
}
|
|
128
128
|
/**
|
|
129
129
|
* Creates the payload for a multi-attestation.
|
|
@@ -173,6 +173,8 @@ class Milestone extends Attestation_1.Attestation {
|
|
|
173
173
|
async attestStatus(signer, schema, callback) {
|
|
174
174
|
const eas = this.schema.gap.eas.connect(signer);
|
|
175
175
|
try {
|
|
176
|
+
if (callback)
|
|
177
|
+
callback("preparing");
|
|
176
178
|
const tx = await eas.attest({
|
|
177
179
|
schema: schema.uid,
|
|
178
180
|
data: {
|
|
@@ -184,15 +186,15 @@ class Milestone extends Attestation_1.Attestation {
|
|
|
184
186
|
},
|
|
185
187
|
});
|
|
186
188
|
if (callback)
|
|
187
|
-
callback(
|
|
189
|
+
callback("pending");
|
|
188
190
|
const uid = await tx.wait();
|
|
189
191
|
if (callback)
|
|
190
|
-
callback(
|
|
192
|
+
callback("confirmed");
|
|
191
193
|
console.log(uid);
|
|
192
194
|
}
|
|
193
195
|
catch (error) {
|
|
194
196
|
console.error(error);
|
|
195
|
-
throw new SchemaError_1.AttestationError(
|
|
197
|
+
throw new SchemaError_1.AttestationError("ATTEST_ERROR", error.message);
|
|
196
198
|
}
|
|
197
199
|
}
|
|
198
200
|
static from(attestations, network) {
|
|
@@ -202,7 +204,7 @@ class Milestone extends Attestation_1.Attestation {
|
|
|
202
204
|
data: {
|
|
203
205
|
...attestation.data,
|
|
204
206
|
},
|
|
205
|
-
schema: new AllGapSchemas_1.AllGapSchemas().findSchema(
|
|
207
|
+
schema: new AllGapSchemas_1.AllGapSchemas().findSchema("Milestone", consts_1.chainIdToNetwork[attestation.chainID]),
|
|
206
208
|
chainID: attestation.chainID,
|
|
207
209
|
});
|
|
208
210
|
if (attestation.completed) {
|
|
@@ -211,7 +213,7 @@ class Milestone extends Attestation_1.Attestation {
|
|
|
211
213
|
data: {
|
|
212
214
|
...attestation.completed.data,
|
|
213
215
|
},
|
|
214
|
-
schema: new AllGapSchemas_1.AllGapSchemas().findSchema(
|
|
216
|
+
schema: new AllGapSchemas_1.AllGapSchemas().findSchema("MilestoneCompleted", consts_1.chainIdToNetwork[attestation.chainID]),
|
|
215
217
|
chainID: attestation.chainID,
|
|
216
218
|
});
|
|
217
219
|
}
|
|
@@ -221,7 +223,7 @@ class Milestone extends Attestation_1.Attestation {
|
|
|
221
223
|
data: {
|
|
222
224
|
...attestation.completed.data,
|
|
223
225
|
},
|
|
224
|
-
schema: new AllGapSchemas_1.AllGapSchemas().findSchema(
|
|
226
|
+
schema: new AllGapSchemas_1.AllGapSchemas().findSchema("MilestoneCompleted", consts_1.chainIdToNetwork[attestation.chainID]),
|
|
225
227
|
chainID: attestation.chainID,
|
|
226
228
|
});
|
|
227
229
|
}
|
|
@@ -231,17 +233,17 @@ class Milestone extends Attestation_1.Attestation {
|
|
|
231
233
|
data: {
|
|
232
234
|
...attestation.completed.data,
|
|
233
235
|
},
|
|
234
|
-
schema: new AllGapSchemas_1.AllGapSchemas().findSchema(
|
|
236
|
+
schema: new AllGapSchemas_1.AllGapSchemas().findSchema("MilestoneCompleted", consts_1.chainIdToNetwork[attestation.chainID]),
|
|
235
237
|
chainID: attestation.chainID,
|
|
236
238
|
});
|
|
237
239
|
}
|
|
238
240
|
if (attestation.verified?.length > 0) {
|
|
239
|
-
milestone.verified = attestation.verified.map(m => new attestations_1.MilestoneCompleted({
|
|
241
|
+
milestone.verified = attestation.verified.map((m) => new attestations_1.MilestoneCompleted({
|
|
240
242
|
...m,
|
|
241
243
|
data: {
|
|
242
244
|
...m.data,
|
|
243
245
|
},
|
|
244
|
-
schema: new AllGapSchemas_1.AllGapSchemas().findSchema(
|
|
246
|
+
schema: new AllGapSchemas_1.AllGapSchemas().findSchema("MilestoneCompleted", consts_1.chainIdToNetwork[attestation.chainID]),
|
|
245
247
|
chainID: attestation.chainID,
|
|
246
248
|
}));
|
|
247
249
|
}
|
|
@@ -249,24 +251,24 @@ class Milestone extends Attestation_1.Attestation {
|
|
|
249
251
|
});
|
|
250
252
|
}
|
|
251
253
|
/**
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
async verify(signer, reason =
|
|
258
|
-
console.log(
|
|
254
|
+
* Verify this milestone. If the milestone is not completed or already verified,
|
|
255
|
+
* it will throw an error.
|
|
256
|
+
* @param signer
|
|
257
|
+
* @param reason
|
|
258
|
+
*/
|
|
259
|
+
async verify(signer, reason = "", callback) {
|
|
260
|
+
console.log("Verifying");
|
|
259
261
|
if (!this.completed)
|
|
260
|
-
throw new SchemaError_1.AttestationError(
|
|
261
|
-
const schema = this.schema.gap.findSchema(
|
|
262
|
-
schema.setValue(
|
|
263
|
-
schema.setValue(
|
|
264
|
-
console.log(
|
|
262
|
+
throw new SchemaError_1.AttestationError("ATTEST_ERROR", "Milestone is not completed");
|
|
263
|
+
const schema = this.schema.gap.findSchema("MilestoneCompleted");
|
|
264
|
+
schema.setValue("type", "verified");
|
|
265
|
+
schema.setValue("reason", reason);
|
|
266
|
+
console.log("Before attestStatus");
|
|
265
267
|
await this.attestStatus(signer, schema, callback);
|
|
266
|
-
console.log(
|
|
268
|
+
console.log("After attestStatus");
|
|
267
269
|
this.verified.push(new attestations_1.MilestoneCompleted({
|
|
268
270
|
data: {
|
|
269
|
-
type:
|
|
271
|
+
type: "verified",
|
|
270
272
|
reason,
|
|
271
273
|
},
|
|
272
274
|
refUID: this.uid,
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { Attestation } from
|
|
2
|
-
import { Grantee, MemberDetails, ProjectDetails, ProjectEndorsement } from
|
|
3
|
-
import { Hex, MultiAttestPayload, SignerOrProvider, TNetwork } from
|
|
4
|
-
import { Grant } from
|
|
5
|
-
import { MemberOf } from
|
|
6
|
-
import { IProjectResponse } from
|
|
7
|
-
import { ProjectImpact } from
|
|
1
|
+
import { Attestation } from "../Attestation";
|
|
2
|
+
import { Grantee, MemberDetails, ProjectDetails, ProjectEndorsement } from "../types/attestations";
|
|
3
|
+
import { Hex, MultiAttestPayload, SignerOrProvider, TNetwork } from "core/types";
|
|
4
|
+
import { Grant } from "./Grant";
|
|
5
|
+
import { MemberOf } from "./MemberOf";
|
|
6
|
+
import { IProjectResponse } from "../karma-indexer/api/types";
|
|
7
|
+
import { ProjectImpact } from "./ProjectImpact";
|
|
8
8
|
export interface IProject {
|
|
9
9
|
project: true;
|
|
10
10
|
}
|
|
@@ -27,7 +27,7 @@ export declare class Project extends Attestation<IProject> {
|
|
|
27
27
|
*/
|
|
28
28
|
multiAttestPayload(currentPayload?: MultiAttestPayload, communityIdx?: number): Promise<MultiAttestPayload>;
|
|
29
29
|
attest(signer: SignerOrProvider, callback?: Function): Promise<void>;
|
|
30
|
-
transferOwnership(signer: SignerOrProvider, newOwner: Hex): Promise<void>;
|
|
30
|
+
transferOwnership(signer: SignerOrProvider, newOwner: Hex, callback?: Function): Promise<void>;
|
|
31
31
|
isOwner(signer: SignerOrProvider): Promise<boolean>;
|
|
32
32
|
/**
|
|
33
33
|
* Add new members to the project.
|
|
@@ -50,8 +50,10 @@ class Project extends Attestation_1.Attestation {
|
|
|
50
50
|
payload[index][0].uid = uid;
|
|
51
51
|
});
|
|
52
52
|
}
|
|
53
|
-
async transferOwnership(signer, newOwner) {
|
|
53
|
+
async transferOwnership(signer, newOwner, callback) {
|
|
54
|
+
callback?.("preparing");
|
|
54
55
|
await GapContract_1.GapContract.transferProjectOwnership(signer, this.uid, newOwner);
|
|
56
|
+
callback?.("confirmed");
|
|
55
57
|
}
|
|
56
58
|
isOwner(signer) {
|
|
57
59
|
return GapContract_1.GapContract.isProjectOwner(signer, this.uid, this.chainID);
|
|
@@ -66,7 +68,7 @@ class Project extends Attestation_1.Attestation {
|
|
|
66
68
|
this.members.push(...(0, utils_1.mapFilter)(members, (member) => !!this.members.find((m) => m.recipient === member), (member) => new MemberOf_1.MemberOf({
|
|
67
69
|
data: { memberOf: true },
|
|
68
70
|
refUID: this.uid,
|
|
69
|
-
schema: this.schema.gap.findSchema(
|
|
71
|
+
schema: this.schema.gap.findSchema("MemberOf"),
|
|
70
72
|
recipient: member,
|
|
71
73
|
uid: consts_1.nullRef,
|
|
72
74
|
})));
|
|
@@ -87,7 +89,7 @@ class Project extends Attestation_1.Attestation {
|
|
|
87
89
|
const member = new MemberOf_1.MemberOf({
|
|
88
90
|
data: { memberOf: true },
|
|
89
91
|
refUID: this.uid,
|
|
90
|
-
schema: this.schema.gap.findSchema(
|
|
92
|
+
schema: this.schema.gap.findSchema("MemberOf"),
|
|
91
93
|
createdAt: Date.now(),
|
|
92
94
|
recipient: details.recipient,
|
|
93
95
|
uid: consts_1.nullRef,
|
|
@@ -95,11 +97,11 @@ class Project extends Attestation_1.Attestation {
|
|
|
95
97
|
return { member, details };
|
|
96
98
|
});
|
|
97
99
|
if (!newMembers.length) {
|
|
98
|
-
throw new SchemaError_1.AttestationError(
|
|
100
|
+
throw new SchemaError_1.AttestationError("ATTEST_ERROR", "No new members to add.");
|
|
99
101
|
}
|
|
100
102
|
console.log(`Creating ${newMembers.length} new members`);
|
|
101
103
|
const attestedMembers = await this.schema.multiAttest(signer, newMembers.map((m) => m.member), callback);
|
|
102
|
-
console.log(
|
|
104
|
+
console.log("attested-members", attestedMembers);
|
|
103
105
|
newMembers.forEach(({ member, details }, idx) => {
|
|
104
106
|
Object.assign(member, { uid: attestedMembers[idx] });
|
|
105
107
|
if (!details)
|
|
@@ -122,12 +124,12 @@ class Project extends Attestation_1.Attestation {
|
|
|
122
124
|
member.details &&
|
|
123
125
|
member.details?.refUID !== entity.refUID), (member) => member.uid);
|
|
124
126
|
if (toRevoke.length) {
|
|
125
|
-
console.log(
|
|
127
|
+
console.log("Revoking details");
|
|
126
128
|
await this.cleanDetails(signer, toRevoke);
|
|
127
129
|
}
|
|
128
130
|
console.log(`Creating ${entities.length} new member details`);
|
|
129
|
-
const attestedEntities =
|
|
130
|
-
console.log(
|
|
131
|
+
const attestedEntities = await this.schema.multiAttest(signer, entities, callback);
|
|
132
|
+
console.log("attested-entities", attestedEntities);
|
|
131
133
|
entities.forEach((entity, idx) => {
|
|
132
134
|
const member = this.members.find((member) => member.uid === entity.refUID);
|
|
133
135
|
if (!member)
|
|
@@ -143,9 +145,9 @@ class Project extends Attestation_1.Attestation {
|
|
|
143
145
|
*/
|
|
144
146
|
async cleanDetails(signer, uids) {
|
|
145
147
|
if (!uids.length) {
|
|
146
|
-
throw new SchemaError_1.AttestationError(
|
|
148
|
+
throw new SchemaError_1.AttestationError("ATTEST_ERROR", "No details to clean.");
|
|
147
149
|
}
|
|
148
|
-
const memberDetails = this.schema.gap.findSchema(
|
|
150
|
+
const memberDetails = this.schema.gap.findSchema("MemberDetails");
|
|
149
151
|
await this.schema.multiRevoke(signer, uids.map((uid) => ({ schemaId: memberDetails.uid, uid })));
|
|
150
152
|
this.members.forEach((member) => {
|
|
151
153
|
if (!member.details)
|
|
@@ -163,9 +165,9 @@ class Project extends Attestation_1.Attestation {
|
|
|
163
165
|
*/
|
|
164
166
|
async removeMembers(signer, uids) {
|
|
165
167
|
if (!uids.length) {
|
|
166
|
-
throw new SchemaError_1.AttestationError(
|
|
168
|
+
throw new SchemaError_1.AttestationError("ATTEST_ERROR", "No members to remove.");
|
|
167
169
|
}
|
|
168
|
-
const memberOf = this.schema.gap.findSchema(
|
|
170
|
+
const memberOf = this.schema.gap.findSchema("MemberOf");
|
|
169
171
|
const details = (0, utils_1.mapFilter)(this.members, (m) => uids.includes(m.uid) && !!m.details, (m) => m.details?.uid);
|
|
170
172
|
if (details.length) {
|
|
171
173
|
await this.cleanDetails(signer, details);
|
|
@@ -180,7 +182,7 @@ class Project extends Attestation_1.Attestation {
|
|
|
180
182
|
async removeAllMembers(signer) {
|
|
181
183
|
const members = (0, utils_1.mapFilter)(this.members, (m) => !!m.uid, (m) => m.uid);
|
|
182
184
|
if (!members.length) {
|
|
183
|
-
throw new SchemaError_1.AttestationError(
|
|
185
|
+
throw new SchemaError_1.AttestationError("REVOKATION_ERROR", "No members to revoke.");
|
|
184
186
|
}
|
|
185
187
|
const details = (0, utils_1.mapFilter)(this.members, (m) => !!m.details, (m) => m.details?.uid);
|
|
186
188
|
if (details.length) {
|
|
@@ -196,7 +198,7 @@ class Project extends Attestation_1.Attestation {
|
|
|
196
198
|
data: {
|
|
197
199
|
project: true,
|
|
198
200
|
},
|
|
199
|
-
schema: new AllGapSchemas_1.AllGapSchemas().findSchema(
|
|
201
|
+
schema: new AllGapSchemas_1.AllGapSchemas().findSchema("Project", consts_1.chainIdToNetwork[attestation.chainID]),
|
|
200
202
|
chainID: attestation.chainID,
|
|
201
203
|
});
|
|
202
204
|
if (attestation.details) {
|
|
@@ -206,7 +208,7 @@ class Project extends Attestation_1.Attestation {
|
|
|
206
208
|
data: {
|
|
207
209
|
...details.data,
|
|
208
210
|
},
|
|
209
|
-
schema: new AllGapSchemas_1.AllGapSchemas().findSchema(
|
|
211
|
+
schema: new AllGapSchemas_1.AllGapSchemas().findSchema("ProjectDetails", consts_1.chainIdToNetwork[attestation.chainID]),
|
|
210
212
|
chainID: attestation.chainID,
|
|
211
213
|
});
|
|
212
214
|
project.details.links = details.data.links || [];
|
|
@@ -225,7 +227,7 @@ class Project extends Attestation_1.Attestation {
|
|
|
225
227
|
data: {
|
|
226
228
|
memberOf: true,
|
|
227
229
|
},
|
|
228
|
-
schema: new AllGapSchemas_1.AllGapSchemas().findSchema(
|
|
230
|
+
schema: new AllGapSchemas_1.AllGapSchemas().findSchema("MemberOf", consts_1.chainIdToNetwork[attestation.chainID]),
|
|
229
231
|
chainID: attestation.chainID,
|
|
230
232
|
});
|
|
231
233
|
if (m.details) {
|
|
@@ -235,7 +237,7 @@ class Project extends Attestation_1.Attestation {
|
|
|
235
237
|
data: {
|
|
236
238
|
...details.data,
|
|
237
239
|
},
|
|
238
|
-
schema: new AllGapSchemas_1.AllGapSchemas().findSchema(
|
|
240
|
+
schema: new AllGapSchemas_1.AllGapSchemas().findSchema("MemberDetails", consts_1.chainIdToNetwork[attestation.chainID]),
|
|
239
241
|
chainID: attestation.chainID,
|
|
240
242
|
});
|
|
241
243
|
}
|
|
@@ -255,7 +257,7 @@ class Project extends Attestation_1.Attestation {
|
|
|
255
257
|
data: {
|
|
256
258
|
...pi.data,
|
|
257
259
|
},
|
|
258
|
-
schema: new AllGapSchemas_1.AllGapSchemas().findSchema(
|
|
260
|
+
schema: new AllGapSchemas_1.AllGapSchemas().findSchema("ProjectDetails", consts_1.chainIdToNetwork[attestation.chainID]),
|
|
259
261
|
chainID: attestation.chainID,
|
|
260
262
|
});
|
|
261
263
|
return endorsement;
|
|
@@ -268,11 +270,11 @@ class Project extends Attestation_1.Attestation {
|
|
|
268
270
|
const projectImpact = new ProjectImpact_1.ProjectImpact({
|
|
269
271
|
data: {
|
|
270
272
|
...data,
|
|
271
|
-
type:
|
|
273
|
+
type: "project-impact",
|
|
272
274
|
},
|
|
273
275
|
recipient: this.recipient,
|
|
274
276
|
refUID: this.uid,
|
|
275
|
-
schema: this.schema.gap.findSchema(
|
|
277
|
+
schema: this.schema.gap.findSchema("ProjectDetails"),
|
|
276
278
|
});
|
|
277
279
|
await projectImpact.attest(signer);
|
|
278
280
|
this.impacts.push(projectImpact);
|
|
@@ -281,11 +283,11 @@ class Project extends Attestation_1.Attestation {
|
|
|
281
283
|
const projectEndorsement = new attestations_1.ProjectEndorsement({
|
|
282
284
|
data: {
|
|
283
285
|
...data,
|
|
284
|
-
type:
|
|
286
|
+
type: "project-endorsement",
|
|
285
287
|
},
|
|
286
288
|
recipient: this.recipient,
|
|
287
289
|
refUID: this.uid,
|
|
288
|
-
schema: this.schema.gap.findSchema(
|
|
290
|
+
schema: this.schema.gap.findSchema("ProjectDetails"),
|
|
289
291
|
});
|
|
290
292
|
await projectEndorsement.attest(signer);
|
|
291
293
|
this.endorsements.push(projectEndorsement);
|
|
@@ -20,6 +20,8 @@ class ProjectImpact extends Attestation_1.Attestation {
|
|
|
20
20
|
async attestStatus(signer, schema, callback) {
|
|
21
21
|
const eas = this.schema.gap.eas.connect(signer);
|
|
22
22
|
try {
|
|
23
|
+
if (callback)
|
|
24
|
+
callback("preparing");
|
|
23
25
|
const tx = await eas.attest({
|
|
24
26
|
schema: schema.uid,
|
|
25
27
|
data: {
|
|
@@ -34,7 +36,7 @@ class ProjectImpact extends Attestation_1.Attestation {
|
|
|
34
36
|
callback("pending");
|
|
35
37
|
const uid = await tx.wait();
|
|
36
38
|
if (callback)
|
|
37
|
-
callback("
|
|
39
|
+
callback("confirmed");
|
|
38
40
|
console.log(uid);
|
|
39
41
|
}
|
|
40
42
|
catch (error) {
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { Attestation, AttestationArgs } from
|
|
2
|
-
import { Hex } from
|
|
3
|
-
import { Project } from
|
|
4
|
-
import { GapSchema } from
|
|
5
|
-
import { GrantUpdate } from
|
|
1
|
+
import { Attestation, AttestationArgs } from "../Attestation";
|
|
2
|
+
import { Hex } from "core/types";
|
|
3
|
+
import { Project } from "../entities/Project";
|
|
4
|
+
import { GapSchema } from "../GapSchema";
|
|
5
|
+
import { GrantUpdate } from "../entities/GrantUpdate";
|
|
6
6
|
/** Attestation interfaces */
|
|
7
7
|
export type ExternalLink = {
|
|
8
8
|
type: string;
|
package/core/consts.js
CHANGED
|
@@ -13,12 +13,12 @@ exports.useDefaultAttestation = [
|
|
|
13
13
|
"GrantUpdateStatus",
|
|
14
14
|
];
|
|
15
15
|
exports.chainIdToNetwork = {
|
|
16
|
-
11155420:
|
|
17
|
-
42161:
|
|
18
|
-
10:
|
|
19
|
-
11155111:
|
|
20
|
-
84532:
|
|
21
|
-
42220:
|
|
16
|
+
11155420: "optimism-sepolia",
|
|
17
|
+
42161: "arbitrum",
|
|
18
|
+
10: "optimism",
|
|
19
|
+
11155111: "sepolia",
|
|
20
|
+
84532: "base-sepolia",
|
|
21
|
+
42220: "celo",
|
|
22
22
|
};
|
|
23
23
|
exports.nullRef = "0x0000000000000000000000000000000000000000000000000000000000000000";
|
|
24
24
|
// TODO: Remove null resolver and change usage to zero address
|
|
@@ -39,6 +39,7 @@ exports.Networks = {
|
|
|
39
39
|
multicall: "0xd2eD366393FDfd243931Fe48e9fb65A192B0018c", //proxy,
|
|
40
40
|
projectResolver: "0x7177AdC0f924b695C0294A40C4C5FEFf5EE1E141",
|
|
41
41
|
communityResolver: "0x6dC1D6b864e8BEf815806f9e4677123496e12026",
|
|
42
|
+
donations: "0x021896771412C1D3f31BC7B01fFA3a6A17c5dA30",
|
|
42
43
|
},
|
|
43
44
|
schemas: {
|
|
44
45
|
Community: "0x721c17b065dccc5c916e0c2708d0ef50f1810591b76d0402ff6fe5accbd8488f",
|
|
@@ -62,6 +63,7 @@ exports.Networks = {
|
|
|
62
63
|
multicall: "0xC891F8eBA218f5034bf3a472528408BE19E1130E",
|
|
63
64
|
projectResolver: "0x832931F23ea4e3c70957DA71a7eB50F5B7efA93D",
|
|
64
65
|
schema: "0x4200000000000000000000000000000000000020",
|
|
66
|
+
donations: "0x3caF83Ed040501f1f439fb22E198bB5a67Bc2884",
|
|
65
67
|
},
|
|
66
68
|
schemas: {
|
|
67
69
|
Community: "0x314bb1c3c9b5311c1b813a3ad123b6ac5a03902b987795056dd2e4ff38e833ea",
|
|
@@ -85,6 +87,7 @@ exports.Networks = {
|
|
|
85
87
|
multicall: "0x6dC1D6b864e8BEf815806f9e4677123496e12026", //proxy,
|
|
86
88
|
projectResolver: "0x28BE0b0515be8BB8822aF1467A6613795E74717b",
|
|
87
89
|
communityResolver: "0xD534C4704F82494aBbc901560046fB62Ac63E9C4",
|
|
90
|
+
donations: "0x475F3E915601d975c792E6116791FBe9ACdBE902",
|
|
88
91
|
},
|
|
89
92
|
schemas: {
|
|
90
93
|
Community: "0xc604f0661cfd522583835ed2b2c644b80e068139d287f93c7f1680888894bacc",
|
|
@@ -108,6 +111,7 @@ exports.Networks = {
|
|
|
108
111
|
multicall: "0xec8d7BFe344790FD860920C41B46B259c005727A",
|
|
109
112
|
projectResolver: "0x099787D5a5aC92779A519CfD925ACB0Dc7E8bd23",
|
|
110
113
|
communityResolver: "0xa9E55D9F52d7B47792d2Db15F6A9674c56ccc5C9",
|
|
114
|
+
donations: "0xb2021F7550b8B07cA71696159B592C1F713593e4",
|
|
111
115
|
},
|
|
112
116
|
schemas: {
|
|
113
117
|
Community: "0xf3d790c7fdab6c1b1f25ffcc9289e5be2792eb596d2851a4d059c8aae1bc8b2e", //test with resolver
|
|
@@ -132,6 +136,7 @@ exports.Networks = {
|
|
|
132
136
|
multicall: "0x4Ca7230fB6b78875bdd1B1e4F665B7B7f1891239",
|
|
133
137
|
projectResolver: "0xC891F8eBA218f5034bf3a472528408BE19E1130E",
|
|
134
138
|
communityResolver: "0x009dC7dF3Ea3b23CE80Fd3Ba811d5bA5675934A1",
|
|
139
|
+
donations: "0x61eD6D070EE996698fB35B909e45111402336645",
|
|
135
140
|
},
|
|
136
141
|
schemas: {
|
|
137
142
|
Community: "0xe130107659909d20cbd75a2c82e1988b09b1c08fd39ad6f4397ce27c089e0e95",
|
|
@@ -145,7 +150,7 @@ exports.Networks = {
|
|
|
145
150
|
Project: "0x5ddd6b7a11406771308431ca9bd146cc717848b74b52993a532dc1aad0ccc83f",
|
|
146
151
|
},
|
|
147
152
|
},
|
|
148
|
-
|
|
153
|
+
celo: {
|
|
149
154
|
chainId: 42220,
|
|
150
155
|
url: "https://celo.easscan.org/graphql",
|
|
151
156
|
rpcUrl: "https://forno.celo.org",
|
|
@@ -155,6 +160,7 @@ exports.Networks = {
|
|
|
155
160
|
multicall: "0x8791Ac8c099314bB1D1514D76de13a1E80275950",
|
|
156
161
|
projectResolver: "0x6dC1D6b864e8BEf815806f9e4677123496e12026",
|
|
157
162
|
communityResolver: "0xfddb660F2F1C27d219372210745BB9f73431856E",
|
|
163
|
+
donations: "0xf373467c21841DF20529FAA8bE49381106DBc258",
|
|
158
164
|
},
|
|
159
165
|
schemas: {
|
|
160
166
|
Community: "0x3c2231024f4f17f3718b5bd9ed9ff29cc323dea5449f9ceba11a9888bfbdd0e1",
|
|
@@ -167,7 +173,7 @@ exports.Networks = {
|
|
|
167
173
|
GrantUpdateStatus: "0xf45fdf2c064073f0623416571c2746085d785cde5a57fd0696ff88bdf78bcbdc",
|
|
168
174
|
Project: "0xf3f753b41e04d1052b5a5ec7624d1dfdb6c2da288a985120e477ddbcac071022",
|
|
169
175
|
},
|
|
170
|
-
}
|
|
176
|
+
},
|
|
171
177
|
};
|
|
172
178
|
const DetailsSchema = [{ type: "string", name: "json", value: null }];
|
|
173
179
|
/**
|
package/core/types.d.ts
CHANGED
|
@@ -15,17 +15,18 @@ export interface MultiRevokeArgs {
|
|
|
15
15
|
uid: Hex;
|
|
16
16
|
schemaId: Hex;
|
|
17
17
|
}
|
|
18
|
+
export type CallbackStatus = "pending" | "confirmed" | "preparing";
|
|
18
19
|
export interface AttestArgs<T = unknown> {
|
|
19
20
|
to: Hex;
|
|
20
21
|
data: T;
|
|
21
22
|
refUID?: Hex;
|
|
22
23
|
signer: SignerOrProvider;
|
|
23
|
-
callback?:
|
|
24
|
+
callback?: (status: CallbackStatus) => void;
|
|
24
25
|
}
|
|
25
26
|
export type TSchemaName = "Community" | "CommunityDetails" | "Grant" | "GrantDetails" | "GrantVerified" | "MemberOf" | "MemberDetails" | "Milestone" | "MilestoneCompleted" | "MilestoneApproved" | "Project" | "ProjectDetails" | "Details" | "ProjectImpact" | "GrantUpdate" | "GrantUpdateStatus" | "ProjectEndorsement";
|
|
26
27
|
export type TResolvedSchemaNames = "Community" | "Grant" | "GrantVerified" | "MemberOf" | "MilestoneCompleted" | "MilestoneApproved" | "Project" | "Details" | "GrantUpdateStatus";
|
|
27
28
|
export type TExternalLink = "twitter" | "github" | "website" | "linkedin" | "discord";
|
|
28
|
-
export type TNetwork = "optimism" |
|
|
29
|
+
export type TNetwork = "optimism" | "celo" | "optimism-sepolia" | "arbitrum" | "sepolia" | "base-sepolia";
|
|
29
30
|
/**
|
|
30
31
|
* Generic GAP Facade interface.
|
|
31
32
|
* This supplies the GAP class with the necessary properties.
|
|
@@ -64,6 +65,7 @@ export interface EASNetworkConfig {
|
|
|
64
65
|
multicall: Hex;
|
|
65
66
|
projectResolver: Hex;
|
|
66
67
|
communityResolver: Hex;
|
|
68
|
+
donations: Hex;
|
|
67
69
|
};
|
|
68
70
|
/**
|
|
69
71
|
* A tuple containing the schema name and it's UID for that network
|