@show-karma/karma-gap-sdk 0.3.7 → 0.3.9
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/AllGapSchemas.d.ts +9 -0
- package/core/class/AllGapSchemas.js +19 -0
- package/core/class/Schema.d.ts +4 -4
- package/core/class/Schema.js +32 -33
- package/core/class/contract/GapContract.d.ts +2 -2
- package/core/class/contract/GapContract.js +25 -22
- package/core/class/entities/Grant.js +11 -5
- package/core/class/entities/Milestone.js +11 -5
- package/core/class/entities/Project.js +11 -5
- package/core/class/types/attestations.d.ts +2 -0
- package/core/consts.d.ts +1 -1
- package/core/consts.js +102 -103
- package/core/types.d.ts +1 -1
- package/core/utils/get-web3-provider.d.ts +2 -4
- package/core/utils/get-web3-provider.js +1 -1
- package/package.json +3 -3
- package/core/class/AttestationIPFS.d.ts +0 -7
- package/core/class/AttestationIPFS.js +0 -10
- package/core/class/GraphQL/Fetcher.d.ts +0 -132
- package/core/class/GraphQL/Fetcher.js +0 -7
- package/core/class/GraphQL/GAPFetcher.d.ts +0 -160
- package/core/class/GraphQL/GAPFetcher.js +0 -516
- package/core/class/IPFS/IPFS.d.ts +0 -13
- package/core/class/IPFS/IPFS.js +0 -24
- package/core/class/contract/MultiAttest.d.ts +0 -10
- package/core/class/contract/MultiAttest.js +0 -19
- package/readme.md +0 -841
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { SchemaInterface, TNetwork, TSchemaName } from '../types';
|
|
2
|
+
import { GapSchema } from './GapSchema';
|
|
3
|
+
export declare class AllGapSchemas {
|
|
4
|
+
allSchemas: {
|
|
5
|
+
[network: string]: SchemaInterface<TSchemaName>[];
|
|
6
|
+
};
|
|
7
|
+
constructor();
|
|
8
|
+
findSchema(name: TSchemaName, network: TNetwork): GapSchema;
|
|
9
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AllGapSchemas = void 0;
|
|
4
|
+
const consts_1 = require("../../core/consts");
|
|
5
|
+
const GapSchema_1 = require("./GapSchema");
|
|
6
|
+
const GAP_1 = require("./GAP");
|
|
7
|
+
class AllGapSchemas {
|
|
8
|
+
constructor() {
|
|
9
|
+
this.allSchemas = {};
|
|
10
|
+
Object.keys(consts_1.Networks).forEach((network) => {
|
|
11
|
+
this.allSchemas[network] = Object.values((0, consts_1.MountEntities)(consts_1.Networks[network]));
|
|
12
|
+
});
|
|
13
|
+
}
|
|
14
|
+
findSchema(name, network) {
|
|
15
|
+
const schema = this.allSchemas[network].find(s => s.name === name);
|
|
16
|
+
return new GapSchema_1.GapSchema(schema, new GAP_1.GAP({ network: network }), false, false);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
exports.AllGapSchemas = AllGapSchemas;
|
package/core/class/Schema.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { SchemaEncoder, SchemaItem, SchemaValue } from
|
|
2
|
-
import { AttestArgs, Hex, MultiRevokeArgs, SchemaInterface, SignerOrProvider, TNetwork } from
|
|
3
|
-
import { GAP } from
|
|
4
|
-
import { Attestation } from
|
|
1
|
+
import { SchemaEncoder, SchemaItem, SchemaValue } from "@ethereum-attestation-service/eas-sdk";
|
|
2
|
+
import { AttestArgs, Hex, MultiRevokeArgs, SchemaInterface, SignerOrProvider, TNetwork } from "../types";
|
|
3
|
+
import { GAP } from "./GAP";
|
|
4
|
+
import { Attestation } from "./Attestation";
|
|
5
5
|
/**
|
|
6
6
|
* Represents the EAS Schema and provides methods to encode and decode the schema,
|
|
7
7
|
* and validate the schema references.
|
package/core/class/Schema.js
CHANGED
|
@@ -3,10 +3,10 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.Schema = void 0;
|
|
4
4
|
const eas_sdk_1 = require("@ethereum-attestation-service/eas-sdk");
|
|
5
5
|
const SchemaError_1 = require("./SchemaError");
|
|
6
|
-
const ethers_1 = require("ethers");
|
|
7
6
|
const consts_1 = require("../consts");
|
|
8
7
|
const GAP_1 = require("./GAP");
|
|
9
8
|
const GapContract_1 = require("./contract/GapContract");
|
|
9
|
+
const ethers_1 = require("ethers");
|
|
10
10
|
/**
|
|
11
11
|
* Represents the EAS Schema and provides methods to encode and decode the schema,
|
|
12
12
|
* and validate the schema references.
|
|
@@ -105,7 +105,7 @@ class Schema {
|
|
|
105
105
|
setValue(key, value) {
|
|
106
106
|
const idx = this._schema.findIndex((item) => item.name === key);
|
|
107
107
|
if (!~idx)
|
|
108
|
-
throw new SchemaError_1.SchemaError(
|
|
108
|
+
throw new SchemaError_1.SchemaError("INVALID_SCHEMA_FIELD", `Field ${key} not found in schema ${this.name}`);
|
|
109
109
|
this.assertField(this._schema[idx], value);
|
|
110
110
|
this._schema[idx].value = value;
|
|
111
111
|
}
|
|
@@ -115,35 +115,35 @@ class Schema {
|
|
|
115
115
|
* @returns boolean
|
|
116
116
|
*/
|
|
117
117
|
isJsonSchema() {
|
|
118
|
-
return !!this.schema.find((s) => s.name ===
|
|
118
|
+
return !!this.schema.find((s) => s.name === "json" && s.type === "string");
|
|
119
119
|
}
|
|
120
120
|
assertField(item, value) {
|
|
121
121
|
const { type, name } = item;
|
|
122
|
-
if (type.includes(
|
|
123
|
-
throw new SchemaError_1.SchemaError(
|
|
122
|
+
if (type.includes("uint") && /\D/.test(value)) {
|
|
123
|
+
throw new SchemaError_1.SchemaError("INVALID_SCHEMA_FIELD", `Field ${name} is of type ${type} but value is not a number.`);
|
|
124
124
|
}
|
|
125
|
-
if (type.includes(
|
|
126
|
-
!ethers_1.
|
|
125
|
+
if (type.includes("address") &&
|
|
126
|
+
!(0, ethers_1.isAddress)(value) &&
|
|
127
127
|
value !== consts_1.zeroAddress) {
|
|
128
|
-
throw new SchemaError_1.SchemaError(
|
|
128
|
+
throw new SchemaError_1.SchemaError("INVALID_SCHEMA_FIELD", `Field ${name} is of type ${type} but value is not a valid address.`);
|
|
129
129
|
}
|
|
130
|
-
if (type.includes(
|
|
131
|
-
throw new SchemaError_1.SchemaError(
|
|
130
|
+
if (type.includes("bytes") && !value.startsWith("0x")) {
|
|
131
|
+
throw new SchemaError_1.SchemaError("INVALID_SCHEMA_FIELD", `Field ${name} is of type ${type} but value is not a valid hex string.`);
|
|
132
132
|
}
|
|
133
|
-
if (type.includes(
|
|
134
|
-
(![
|
|
135
|
-
typeof value !==
|
|
136
|
-
throw new SchemaError_1.SchemaError(
|
|
133
|
+
if (type.includes("bool") &&
|
|
134
|
+
(!["true", "false", true, false].includes(value) ||
|
|
135
|
+
typeof value !== "boolean")) {
|
|
136
|
+
throw new SchemaError_1.SchemaError("INVALID_SCHEMA_FIELD", `Field ${name} is of type ${type} but value is not a valid boolean.`);
|
|
137
137
|
}
|
|
138
|
-
if (type.includes(
|
|
139
|
-
throw new SchemaError_1.SchemaError(
|
|
138
|
+
if (type.includes("tuple") && !Array.isArray(value)) {
|
|
139
|
+
throw new SchemaError_1.SchemaError("INVALID_SCHEMA_FIELD", `Field ${name} is of type ${type} but value is not a valid array.`);
|
|
140
140
|
}
|
|
141
|
-
if (type ===
|
|
141
|
+
if (type === "string" && name === "json") {
|
|
142
142
|
try {
|
|
143
143
|
JSON.parse(value);
|
|
144
144
|
}
|
|
145
145
|
catch (error) {
|
|
146
|
-
throw new SchemaError_1.SchemaError(
|
|
146
|
+
throw new SchemaError_1.SchemaError("INVALID_SCHEMA_FIELD", `Field ${name} is of type ${type} but value is not a valid JSON string.`);
|
|
147
147
|
}
|
|
148
148
|
}
|
|
149
149
|
}
|
|
@@ -155,16 +155,16 @@ class Schema {
|
|
|
155
155
|
assert(args, strict = false) {
|
|
156
156
|
const { name, schema, uid, references } = args;
|
|
157
157
|
if (!name) {
|
|
158
|
-
throw new SchemaError_1.SchemaError(
|
|
158
|
+
throw new SchemaError_1.SchemaError("MISSING_FIELD", "Schema name is required");
|
|
159
159
|
}
|
|
160
160
|
if (!schema && !Array.isArray(schema)) {
|
|
161
|
-
throw new SchemaError_1.SchemaError(
|
|
161
|
+
throw new SchemaError_1.SchemaError("MISSING_FIELD", "Schema must be an array.");
|
|
162
162
|
}
|
|
163
163
|
// if (!uid) {
|
|
164
164
|
// throw new SchemaError("MISSING_FIELD", "Schema uid is required");
|
|
165
165
|
// }
|
|
166
166
|
if (strict && references && !Schema.exists(references, this.gap.network)) {
|
|
167
|
-
throw new SchemaError_1.SchemaError(
|
|
167
|
+
throw new SchemaError_1.SchemaError("INVALID_REFERENCE", `Schema ${name} references ${references} but it does not exist.`);
|
|
168
168
|
}
|
|
169
169
|
}
|
|
170
170
|
/**
|
|
@@ -222,7 +222,7 @@ class Schema {
|
|
|
222
222
|
async attest({ data, to, signer, refUID }) {
|
|
223
223
|
const eas = this.gap.eas.connect(signer);
|
|
224
224
|
if (this.references && !refUID)
|
|
225
|
-
throw new SchemaError_1.AttestationError(
|
|
225
|
+
throw new SchemaError_1.AttestationError("INVALID_REFERENCE", "Attestation schema references another schema but no reference UID was provided.");
|
|
226
226
|
if (this.isJsonSchema()) {
|
|
227
227
|
const { remoteClient } = GAP_1.GAP;
|
|
228
228
|
if (remoteClient) {
|
|
@@ -230,7 +230,7 @@ class Schema {
|
|
|
230
230
|
const encodedData = remoteClient.encode(cid);
|
|
231
231
|
data = encodedData;
|
|
232
232
|
}
|
|
233
|
-
this.setValue(
|
|
233
|
+
this.setValue("json", JSON.stringify(data));
|
|
234
234
|
}
|
|
235
235
|
else {
|
|
236
236
|
Object.entries(data).forEach(([key, value]) => {
|
|
@@ -277,7 +277,7 @@ class Schema {
|
|
|
277
277
|
async multiAttest(signer, entities = []) {
|
|
278
278
|
entities.forEach((entity) => {
|
|
279
279
|
if (this.references && !entity.refUID)
|
|
280
|
-
throw new SchemaError_1.SchemaError(
|
|
280
|
+
throw new SchemaError_1.SchemaError("INVALID_REF_UID", `Entity ${entity.schema.name} references another schema but no reference UID was provided.`);
|
|
281
281
|
});
|
|
282
282
|
const eas = this.gap.eas.connect(signer);
|
|
283
283
|
const entityBySchema = entities.reduce((acc, entity) => {
|
|
@@ -338,8 +338,6 @@ class Schema {
|
|
|
338
338
|
schemas.forEach((schema) => {
|
|
339
339
|
if (!this.exists(schema.name, network))
|
|
340
340
|
this.schemas[network].push(schema);
|
|
341
|
-
else
|
|
342
|
-
throw new SchemaError_1.SchemaError('SCHEMA_ALREADY_EXISTS', `Schema ${schema.name} already exists.`);
|
|
343
341
|
});
|
|
344
342
|
}
|
|
345
343
|
static getAll(network) {
|
|
@@ -348,7 +346,7 @@ class Schema {
|
|
|
348
346
|
static get(name, network) {
|
|
349
347
|
const schema = this.schemas[network].find((schema) => schema.name === name || schema.uid === name);
|
|
350
348
|
if (!schema)
|
|
351
|
-
throw new SchemaError_1.SchemaError(
|
|
349
|
+
throw new SchemaError_1.SchemaError("SCHEMA_NOT_FOUND", `Schema ${name} not found. Available schemas: ${Schema.getNames(network)}`);
|
|
352
350
|
return schema;
|
|
353
351
|
}
|
|
354
352
|
/**
|
|
@@ -373,7 +371,7 @@ class Schema {
|
|
|
373
371
|
if (!schema.references || Schema.exists(schema.references, network))
|
|
374
372
|
return;
|
|
375
373
|
else
|
|
376
|
-
errors.push(new SchemaError_1.SchemaError(
|
|
374
|
+
errors.push(new SchemaError_1.SchemaError("INVALID_REFERENCE", `Schema ${schema.name} references ${schema.references} but it does not exist.`));
|
|
377
375
|
});
|
|
378
376
|
if (errors.length)
|
|
379
377
|
throw errors;
|
|
@@ -393,7 +391,7 @@ class Schema {
|
|
|
393
391
|
static replaceOne(schema, network) {
|
|
394
392
|
const idx = this.schemas[network].findIndex((item) => schema.name === item.name);
|
|
395
393
|
if (!~idx)
|
|
396
|
-
throw new SchemaError_1.SchemaError(
|
|
394
|
+
throw new SchemaError_1.SchemaError("SCHEMA_NOT_FOUND", `Schema ${schema.name} not found.`);
|
|
397
395
|
this.schemas[idx] = schema;
|
|
398
396
|
}
|
|
399
397
|
/**
|
|
@@ -408,9 +406,9 @@ class Schema {
|
|
|
408
406
|
* @returns
|
|
409
407
|
*/
|
|
410
408
|
static rawToObject(abi) {
|
|
411
|
-
const items = abi.trim().replace(/,\s+/gim,
|
|
409
|
+
const items = abi.trim().replace(/,\s+/gim, ",").split(",");
|
|
412
410
|
const schema = items.map((item) => {
|
|
413
|
-
const [type, name] = item.split(
|
|
411
|
+
const [type, name] = item.split(" ");
|
|
414
412
|
return { type, name, value: null };
|
|
415
413
|
});
|
|
416
414
|
return schema;
|
|
@@ -424,7 +422,7 @@ class Schema {
|
|
|
424
422
|
* ```
|
|
425
423
|
*/
|
|
426
424
|
get raw() {
|
|
427
|
-
return this.schema.map((item) => `${item.type} ${item.name}`).join(
|
|
425
|
+
return this.schema.map((item) => `${item.type} ${item.name}`).join(",");
|
|
428
426
|
}
|
|
429
427
|
get schema() {
|
|
430
428
|
return this._schema;
|
|
@@ -448,7 +446,8 @@ class Schema {
|
|
|
448
446
|
}
|
|
449
447
|
exports.Schema = Schema;
|
|
450
448
|
Schema.schemas = {
|
|
451
|
-
'optimism-
|
|
449
|
+
'optimism-sepolia': [],
|
|
450
|
+
// "optimism-goerli": [],
|
|
452
451
|
optimism: [],
|
|
453
452
|
sepolia: [],
|
|
454
453
|
arbitrum: [],
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Hex, RawAttestationPayload, RawMultiAttestPayload, SignerOrProvider } from
|
|
2
|
-
import { MultiRevocationRequest } from
|
|
1
|
+
import { Hex, RawAttestationPayload, RawMultiAttestPayload, SignerOrProvider } from "core/types";
|
|
2
|
+
import { MultiRevocationRequest } from "@ethereum-attestation-service/eas-sdk";
|
|
3
3
|
export declare class GapContract {
|
|
4
4
|
static nonces: {
|
|
5
5
|
[key: string]: number;
|
|
@@ -7,9 +7,9 @@ const send_gelato_txn_1 = require("../../utils/gelato/send-gelato-txn");
|
|
|
7
7
|
const eas_sdk_1 = require("@ethereum-attestation-service/eas-sdk");
|
|
8
8
|
const AttestationDataTypes = {
|
|
9
9
|
Attest: [
|
|
10
|
-
{ name:
|
|
11
|
-
{ name:
|
|
12
|
-
{ name:
|
|
10
|
+
{ name: "payloadHash", type: "string" },
|
|
11
|
+
{ name: "nonce", type: "uint256" },
|
|
12
|
+
{ name: "expiry", type: "uint256" },
|
|
13
13
|
],
|
|
14
14
|
};
|
|
15
15
|
class GapContract {
|
|
@@ -24,8 +24,8 @@ class GapContract {
|
|
|
24
24
|
const { chainId } = await signer.provider.getNetwork();
|
|
25
25
|
const domain = {
|
|
26
26
|
chainId,
|
|
27
|
-
name:
|
|
28
|
-
version:
|
|
27
|
+
name: "gap-attestation",
|
|
28
|
+
version: "1",
|
|
29
29
|
verifyingContract: (await GAP_1.GAP.getMulticall(signer)).address,
|
|
30
30
|
};
|
|
31
31
|
const data = { payloadHash: payload, nonce, expiry };
|
|
@@ -48,7 +48,7 @@ class GapContract {
|
|
|
48
48
|
static async getSignerAddress(signer) {
|
|
49
49
|
const address = signer.address || signer._address || (await signer.getAddress());
|
|
50
50
|
if (!address)
|
|
51
|
-
throw new Error(
|
|
51
|
+
throw new Error("Signer does not provider either address or getAddress().");
|
|
52
52
|
return address;
|
|
53
53
|
}
|
|
54
54
|
/**
|
|
@@ -60,7 +60,7 @@ class GapContract {
|
|
|
60
60
|
const contract = await GAP_1.GAP.getMulticall(signer);
|
|
61
61
|
const address = await this.getSignerAddress(signer);
|
|
62
62
|
console.log({ address });
|
|
63
|
-
const nonce = await contract.
|
|
63
|
+
const nonce = await contract.nonces(address);
|
|
64
64
|
return {
|
|
65
65
|
nonce: Number(nonce),
|
|
66
66
|
next: Number(nonce + 1n),
|
|
@@ -77,7 +77,7 @@ class GapContract {
|
|
|
77
77
|
if (GAP_1.GAP.gelatoOpts?.useGasless) {
|
|
78
78
|
return this.attestBySig(signer, payload);
|
|
79
79
|
}
|
|
80
|
-
const tx = await contract.
|
|
80
|
+
const tx = await contract.attest({
|
|
81
81
|
schema: payload.schema,
|
|
82
82
|
data: payload.data.payload,
|
|
83
83
|
});
|
|
@@ -94,13 +94,14 @@ class GapContract {
|
|
|
94
94
|
data: payload.data.raw,
|
|
95
95
|
});
|
|
96
96
|
const { r, s, v, nonce, chainId } = await this.signAttestation(signer, payloadHash, expiry);
|
|
97
|
-
const { data: populatedTxn } = await contract.populateTransaction
|
|
97
|
+
const { data: populatedTxn } = await contract.attestBySig.populateTransaction({
|
|
98
98
|
data: payload.data.payload,
|
|
99
99
|
schema: payload.schema,
|
|
100
100
|
}, payloadHash, address, nonce, expiry, v, r, s);
|
|
101
101
|
if (!populatedTxn)
|
|
102
|
-
throw new Error(
|
|
103
|
-
|
|
102
|
+
throw new Error("Transaction data is empty");
|
|
103
|
+
let contractAddress = await contract.getAddress();
|
|
104
|
+
const txn = await (0, send_gelato_txn_1.sendGelatoTxn)(...send_gelato_txn_1.Gelato.buildArgs(populatedTxn, chainId, contractAddress));
|
|
104
105
|
const attestations = await this.getTransactionLogs(signer, txn);
|
|
105
106
|
return attestations[0];
|
|
106
107
|
}
|
|
@@ -114,7 +115,7 @@ class GapContract {
|
|
|
114
115
|
if (GAP_1.GAP.gelatoOpts?.useGasless) {
|
|
115
116
|
return this.multiAttestBySig(signer, payload);
|
|
116
117
|
}
|
|
117
|
-
const tx = await contract.
|
|
118
|
+
const tx = await contract.multiSequentialAttest(payload.map((p) => p.payload));
|
|
118
119
|
const result = await tx.wait?.();
|
|
119
120
|
const attestations = (0, eas_sdk_1.getUIDsFromAttestReceipt)(result);
|
|
120
121
|
return attestations;
|
|
@@ -131,10 +132,11 @@ class GapContract {
|
|
|
131
132
|
const payloadHash = (0, serialize_bigint_1.serializeWithBigint)(payload.map((p) => p.raw));
|
|
132
133
|
const { r, s, v, nonce, chainId } = await this.signAttestation(signer, payloadHash, expiry);
|
|
133
134
|
console.info({ r, s, v, nonce, chainId, payloadHash, address });
|
|
134
|
-
const { data: populatedTxn } = await contract.populateTransaction
|
|
135
|
+
const { data: populatedTxn } = await contract.multiSequentialAttestBySig.populateTransaction(payload.map((p) => p.payload), payloadHash, address, nonce, expiry, v, r, s);
|
|
135
136
|
if (!populatedTxn)
|
|
136
|
-
throw new Error(
|
|
137
|
-
|
|
137
|
+
throw new Error("Transaction data is empty");
|
|
138
|
+
let contractAddress = await contract.getAddress();
|
|
139
|
+
const txn = await (0, send_gelato_txn_1.sendGelatoTxn)(...send_gelato_txn_1.Gelato.buildArgs(populatedTxn, chainId, contractAddress));
|
|
138
140
|
const attestations = await this.getTransactionLogs(signer, txn);
|
|
139
141
|
return attestations;
|
|
140
142
|
}
|
|
@@ -143,7 +145,7 @@ class GapContract {
|
|
|
143
145
|
if (GAP_1.GAP.gelatoOpts?.useGasless) {
|
|
144
146
|
return this.multiRevokeBySig(signer, payload);
|
|
145
147
|
}
|
|
146
|
-
const tx = await contract.
|
|
148
|
+
const tx = await contract.multiRevoke(payload);
|
|
147
149
|
return tx.wait?.();
|
|
148
150
|
}
|
|
149
151
|
/**
|
|
@@ -158,10 +160,11 @@ class GapContract {
|
|
|
158
160
|
const payloadHash = (0, serialize_bigint_1.serializeWithBigint)(payload);
|
|
159
161
|
const { r, s, v, nonce, chainId } = await this.signAttestation(signer, payloadHash, expiry);
|
|
160
162
|
console.info({ r, s, v, nonce, chainId, payloadHash, address });
|
|
161
|
-
const { data: populatedTxn } = await contract.populateTransaction
|
|
163
|
+
const { data: populatedTxn } = await contract.multiRevokeBySig.populateTransaction(payload, payloadHash, address, nonce, expiry, v, r, s);
|
|
162
164
|
if (!populatedTxn)
|
|
163
|
-
throw new Error(
|
|
164
|
-
|
|
165
|
+
throw new Error("Transaction data is empty");
|
|
166
|
+
let contractAddress = await contract.getAddress();
|
|
167
|
+
await (0, send_gelato_txn_1.sendGelatoTxn)(...send_gelato_txn_1.Gelato.buildArgs(populatedTxn, chainId, contractAddress));
|
|
165
168
|
}
|
|
166
169
|
/**
|
|
167
170
|
* Transfer the ownership of an attestation
|
|
@@ -172,7 +175,7 @@ class GapContract {
|
|
|
172
175
|
*/
|
|
173
176
|
static async transferProjectOwnership(signer, projectUID, newOwner) {
|
|
174
177
|
const contract = await GAP_1.GAP.getProjectResolver(signer);
|
|
175
|
-
const tx = await contract.
|
|
178
|
+
const tx = await contract.transferProjectOwnership(projectUID, newOwner);
|
|
176
179
|
return tx.wait?.();
|
|
177
180
|
}
|
|
178
181
|
/**
|
|
@@ -184,13 +187,13 @@ class GapContract {
|
|
|
184
187
|
static async isProjectOwner(signer, projectUID, projectChainId) {
|
|
185
188
|
const contract = await GAP_1.GAP.getProjectResolver(signer, projectChainId);
|
|
186
189
|
const address = await this.getSignerAddress(signer);
|
|
187
|
-
const isOwner = await contract.
|
|
190
|
+
const isOwner = await contract.isAdmin(projectUID, address);
|
|
188
191
|
return !!isOwner?.[0];
|
|
189
192
|
}
|
|
190
193
|
static async getTransactionLogs(signer, txnHash) {
|
|
191
194
|
const txn = await signer.provider.getTransactionReceipt(txnHash);
|
|
192
195
|
if (!txn || !txn.logs.length)
|
|
193
|
-
throw new Error(
|
|
196
|
+
throw new Error("Transaction not found");
|
|
194
197
|
// Returns the txn logs with the attestation results. Tha last two logs are the
|
|
195
198
|
// the ones from the GelatoRelay contract.
|
|
196
199
|
return (0, eas_sdk_1.getUIDsFromAttestReceipt)(txn);
|
|
@@ -4,12 +4,18 @@ exports.Grant = void 0;
|
|
|
4
4
|
const Attestation_1 = require("../Attestation");
|
|
5
5
|
const attestations_1 = require("../types/attestations");
|
|
6
6
|
const Milestone_1 = require("./Milestone");
|
|
7
|
-
const GapSchema_1 = require("../GapSchema");
|
|
8
7
|
const SchemaError_1 = require("../SchemaError");
|
|
9
8
|
const consts_1 = require("../../consts");
|
|
10
9
|
const GapContract_1 = require("../contract/GapContract");
|
|
11
10
|
const Community_1 = require("./Community");
|
|
12
11
|
const Project_1 = require("./Project");
|
|
12
|
+
const AllGapSchemas_1 = require("../AllGapSchemas");
|
|
13
|
+
const chainIdToNetwork = {
|
|
14
|
+
11155420: 'optimism-sepolia',
|
|
15
|
+
42161: 'arbitrum',
|
|
16
|
+
10: 'optimism',
|
|
17
|
+
11155111: 'sepolia'
|
|
18
|
+
};
|
|
13
19
|
class Grant extends Attestation_1.Attestation {
|
|
14
20
|
constructor() {
|
|
15
21
|
super(...arguments);
|
|
@@ -164,7 +170,7 @@ class Grant extends Attestation_1.Attestation {
|
|
|
164
170
|
data: {
|
|
165
171
|
communityUID: attestation.data.communityUID,
|
|
166
172
|
},
|
|
167
|
-
schema:
|
|
173
|
+
schema: new AllGapSchemas_1.AllGapSchemas().findSchema('Grant', chainIdToNetwork[attestation.chainID]),
|
|
168
174
|
chainID: attestation.chainID,
|
|
169
175
|
});
|
|
170
176
|
if (attestation.details) {
|
|
@@ -174,7 +180,7 @@ class Grant extends Attestation_1.Attestation {
|
|
|
174
180
|
data: {
|
|
175
181
|
...details.data,
|
|
176
182
|
},
|
|
177
|
-
schema:
|
|
183
|
+
schema: new AllGapSchemas_1.AllGapSchemas().findSchema('GrantDetails', chainIdToNetwork[attestation.chainID]),
|
|
178
184
|
chainID: attestation.chainID,
|
|
179
185
|
});
|
|
180
186
|
}
|
|
@@ -189,7 +195,7 @@ class Grant extends Attestation_1.Attestation {
|
|
|
189
195
|
data: {
|
|
190
196
|
...u.data,
|
|
191
197
|
},
|
|
192
|
-
schema:
|
|
198
|
+
schema: new AllGapSchemas_1.AllGapSchemas().findSchema('GrantDetails', chainIdToNetwork[attestation.chainID]),
|
|
193
199
|
chainID: attestation.chainID,
|
|
194
200
|
}));
|
|
195
201
|
}
|
|
@@ -200,7 +206,7 @@ class Grant extends Attestation_1.Attestation {
|
|
|
200
206
|
data: {
|
|
201
207
|
...completed.data,
|
|
202
208
|
},
|
|
203
|
-
schema:
|
|
209
|
+
schema: new AllGapSchemas_1.AllGapSchemas().findSchema('GrantDetails', chainIdToNetwork[attestation.chainID]),
|
|
204
210
|
chainID: attestation.chainID,
|
|
205
211
|
});
|
|
206
212
|
}
|
|
@@ -1,11 +1,17 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.Milestone = void 0;
|
|
4
|
+
const AllGapSchemas_1 = require("../AllGapSchemas");
|
|
4
5
|
const Attestation_1 = require("../Attestation");
|
|
5
|
-
const GapSchema_1 = require("../GapSchema");
|
|
6
6
|
const SchemaError_1 = require("../SchemaError");
|
|
7
7
|
const GapContract_1 = require("../contract/GapContract");
|
|
8
8
|
const attestations_1 = require("../types/attestations");
|
|
9
|
+
const chainIdToNetwork = {
|
|
10
|
+
11155420: 'optimism-sepolia',
|
|
11
|
+
42161: 'arbitrum',
|
|
12
|
+
10: 'optimism',
|
|
13
|
+
11155111: 'sepolia'
|
|
14
|
+
};
|
|
9
15
|
class Milestone extends Attestation_1.Attestation {
|
|
10
16
|
constructor() {
|
|
11
17
|
super(...arguments);
|
|
@@ -188,7 +194,7 @@ class Milestone extends Attestation_1.Attestation {
|
|
|
188
194
|
data: {
|
|
189
195
|
...attestation.data,
|
|
190
196
|
},
|
|
191
|
-
schema:
|
|
197
|
+
schema: new AllGapSchemas_1.AllGapSchemas().findSchema('Milestone', chainIdToNetwork[attestation.chainID]),
|
|
192
198
|
chainID: attestation.chainID,
|
|
193
199
|
});
|
|
194
200
|
if (attestation.completed) {
|
|
@@ -197,7 +203,7 @@ class Milestone extends Attestation_1.Attestation {
|
|
|
197
203
|
data: {
|
|
198
204
|
...attestation.completed.data,
|
|
199
205
|
},
|
|
200
|
-
schema:
|
|
206
|
+
schema: new AllGapSchemas_1.AllGapSchemas().findSchema('MilestoneCompleted', chainIdToNetwork[attestation.chainID]),
|
|
201
207
|
chainID: attestation.chainID,
|
|
202
208
|
});
|
|
203
209
|
}
|
|
@@ -207,7 +213,7 @@ class Milestone extends Attestation_1.Attestation {
|
|
|
207
213
|
data: {
|
|
208
214
|
...attestation.completed.data,
|
|
209
215
|
},
|
|
210
|
-
schema:
|
|
216
|
+
schema: new AllGapSchemas_1.AllGapSchemas().findSchema('MilestoneCompleted', chainIdToNetwork[attestation.chainID]),
|
|
211
217
|
chainID: attestation.chainID,
|
|
212
218
|
});
|
|
213
219
|
}
|
|
@@ -217,7 +223,7 @@ class Milestone extends Attestation_1.Attestation {
|
|
|
217
223
|
data: {
|
|
218
224
|
...attestation.completed.data,
|
|
219
225
|
},
|
|
220
|
-
schema:
|
|
226
|
+
schema: new AllGapSchemas_1.AllGapSchemas().findSchema('MilestoneCompleted', chainIdToNetwork[attestation.chainID]),
|
|
221
227
|
chainID: attestation.chainID,
|
|
222
228
|
});
|
|
223
229
|
}
|
|
@@ -3,13 +3,19 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.Project = void 0;
|
|
4
4
|
const Attestation_1 = require("../Attestation");
|
|
5
5
|
const attestations_1 = require("../types/attestations");
|
|
6
|
-
const GapSchema_1 = require("../GapSchema");
|
|
7
6
|
const SchemaError_1 = require("../SchemaError");
|
|
8
7
|
const utils_1 = require("../../utils");
|
|
9
8
|
const Grant_1 = require("./Grant");
|
|
10
9
|
const consts_1 = require("../../consts");
|
|
11
10
|
const MemberOf_1 = require("./MemberOf");
|
|
12
11
|
const GapContract_1 = require("../contract/GapContract");
|
|
12
|
+
const AllGapSchemas_1 = require("../AllGapSchemas");
|
|
13
|
+
const chainIdToNetwork = {
|
|
14
|
+
11155420: 'optimism-sepolia',
|
|
15
|
+
42161: 'arbitrum',
|
|
16
|
+
10: 'optimism',
|
|
17
|
+
11155111: 'sepolia'
|
|
18
|
+
};
|
|
13
19
|
class Project extends Attestation_1.Attestation {
|
|
14
20
|
constructor() {
|
|
15
21
|
super(...arguments);
|
|
@@ -193,7 +199,7 @@ class Project extends Attestation_1.Attestation {
|
|
|
193
199
|
data: {
|
|
194
200
|
project: true,
|
|
195
201
|
},
|
|
196
|
-
schema:
|
|
202
|
+
schema: new AllGapSchemas_1.AllGapSchemas().findSchema('Project', chainIdToNetwork[attestation.chainID]),
|
|
197
203
|
chainID: attestation.chainID,
|
|
198
204
|
});
|
|
199
205
|
if (attestation.details) {
|
|
@@ -203,7 +209,7 @@ class Project extends Attestation_1.Attestation {
|
|
|
203
209
|
data: {
|
|
204
210
|
...details.data,
|
|
205
211
|
},
|
|
206
|
-
schema:
|
|
212
|
+
schema: new AllGapSchemas_1.AllGapSchemas().findSchema('ProjectDetails', chainIdToNetwork[attestation.chainID]),
|
|
207
213
|
chainID: attestation.chainID,
|
|
208
214
|
});
|
|
209
215
|
project.details.links = details.data.links || [];
|
|
@@ -222,7 +228,7 @@ class Project extends Attestation_1.Attestation {
|
|
|
222
228
|
data: {
|
|
223
229
|
memberOf: true,
|
|
224
230
|
},
|
|
225
|
-
schema:
|
|
231
|
+
schema: new AllGapSchemas_1.AllGapSchemas().findSchema('MemberOf', chainIdToNetwork[attestation.chainID]),
|
|
226
232
|
chainID: attestation.chainID,
|
|
227
233
|
});
|
|
228
234
|
if (m.details) {
|
|
@@ -232,7 +238,7 @@ class Project extends Attestation_1.Attestation {
|
|
|
232
238
|
data: {
|
|
233
239
|
...details.data,
|
|
234
240
|
},
|
|
235
|
-
schema:
|
|
241
|
+
schema: new AllGapSchemas_1.AllGapSchemas().findSchema('MemberDetails', chainIdToNetwork[attestation.chainID]),
|
|
236
242
|
chainID: attestation.chainID,
|
|
237
243
|
});
|
|
238
244
|
}
|
|
@@ -33,6 +33,7 @@ export interface IGrantDetails {
|
|
|
33
33
|
cycle?: string;
|
|
34
34
|
questions?: IGrantDetailsQuestion[];
|
|
35
35
|
type?: string;
|
|
36
|
+
startDate?: number;
|
|
36
37
|
}
|
|
37
38
|
export declare class GrantDetails extends Attestation<IGrantDetails> implements IGrantDetails {
|
|
38
39
|
title: string;
|
|
@@ -45,6 +46,7 @@ export declare class GrantDetails extends Attestation<IGrantDetails> implements
|
|
|
45
46
|
cycle?: string;
|
|
46
47
|
questions?: IGrantDetailsQuestion[];
|
|
47
48
|
type: string;
|
|
49
|
+
startDate?: number;
|
|
48
50
|
}
|
|
49
51
|
export interface IGrantRound {
|
|
50
52
|
name: string;
|
package/core/consts.d.ts
CHANGED