@show-karma/karma-gap-sdk 0.2.2 → 0.2.4

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.
@@ -0,0 +1,471 @@
1
+ [
2
+ {
3
+ "inputs": [
4
+ {
5
+ "internalType": "contract IEAS",
6
+ "name": "eas",
7
+ "type": "address"
8
+ }
9
+ ],
10
+ "stateMutability": "nonpayable",
11
+ "type": "constructor"
12
+ },
13
+ {
14
+ "inputs": [],
15
+ "name": "AccessDenied",
16
+ "type": "error"
17
+ },
18
+ {
19
+ "inputs": [],
20
+ "name": "InsufficientValue",
21
+ "type": "error"
22
+ },
23
+ {
24
+ "inputs": [],
25
+ "name": "InvalidEAS",
26
+ "type": "error"
27
+ },
28
+ {
29
+ "inputs": [],
30
+ "name": "NotPayable",
31
+ "type": "error"
32
+ },
33
+ {
34
+ "anonymous": false,
35
+ "inputs": [
36
+ {
37
+ "indexed": false,
38
+ "internalType": "uint8",
39
+ "name": "version",
40
+ "type": "uint8"
41
+ }
42
+ ],
43
+ "name": "Initialized",
44
+ "type": "event"
45
+ },
46
+ {
47
+ "anonymous": false,
48
+ "inputs": [
49
+ {
50
+ "indexed": true,
51
+ "internalType": "address",
52
+ "name": "previousOwner",
53
+ "type": "address"
54
+ },
55
+ {
56
+ "indexed": true,
57
+ "internalType": "address",
58
+ "name": "newOwner",
59
+ "type": "address"
60
+ }
61
+ ],
62
+ "name": "OwnershipTransferred",
63
+ "type": "event"
64
+ },
65
+ {
66
+ "inputs": [
67
+ {
68
+ "components": [
69
+ {
70
+ "internalType": "bytes32",
71
+ "name": "uid",
72
+ "type": "bytes32"
73
+ },
74
+ {
75
+ "internalType": "bytes32",
76
+ "name": "schema",
77
+ "type": "bytes32"
78
+ },
79
+ {
80
+ "internalType": "uint64",
81
+ "name": "time",
82
+ "type": "uint64"
83
+ },
84
+ {
85
+ "internalType": "uint64",
86
+ "name": "expirationTime",
87
+ "type": "uint64"
88
+ },
89
+ {
90
+ "internalType": "uint64",
91
+ "name": "revocationTime",
92
+ "type": "uint64"
93
+ },
94
+ {
95
+ "internalType": "bytes32",
96
+ "name": "refUID",
97
+ "type": "bytes32"
98
+ },
99
+ {
100
+ "internalType": "address",
101
+ "name": "recipient",
102
+ "type": "address"
103
+ },
104
+ {
105
+ "internalType": "address",
106
+ "name": "attester",
107
+ "type": "address"
108
+ },
109
+ {
110
+ "internalType": "bool",
111
+ "name": "revocable",
112
+ "type": "bool"
113
+ },
114
+ {
115
+ "internalType": "bytes",
116
+ "name": "data",
117
+ "type": "bytes"
118
+ }
119
+ ],
120
+ "internalType": "struct Attestation",
121
+ "name": "attestation",
122
+ "type": "tuple"
123
+ }
124
+ ],
125
+ "name": "attest",
126
+ "outputs": [
127
+ {
128
+ "internalType": "bool",
129
+ "name": "",
130
+ "type": "bool"
131
+ }
132
+ ],
133
+ "stateMutability": "payable",
134
+ "type": "function"
135
+ },
136
+ {
137
+ "inputs": [],
138
+ "name": "initialize",
139
+ "outputs": [],
140
+ "stateMutability": "nonpayable",
141
+ "type": "function"
142
+ },
143
+ {
144
+ "inputs": [
145
+ {
146
+ "internalType": "bytes32",
147
+ "name": "projectId",
148
+ "type": "bytes32"
149
+ },
150
+ {
151
+ "internalType": "address",
152
+ "name": "addr",
153
+ "type": "address"
154
+ }
155
+ ],
156
+ "name": "isAdmin",
157
+ "outputs": [
158
+ {
159
+ "internalType": "bool",
160
+ "name": "",
161
+ "type": "bool"
162
+ }
163
+ ],
164
+ "stateMutability": "view",
165
+ "type": "function"
166
+ },
167
+ {
168
+ "inputs": [],
169
+ "name": "isPayable",
170
+ "outputs": [
171
+ {
172
+ "internalType": "bool",
173
+ "name": "",
174
+ "type": "bool"
175
+ }
176
+ ],
177
+ "stateMutability": "pure",
178
+ "type": "function"
179
+ },
180
+ {
181
+ "inputs": [
182
+ {
183
+ "components": [
184
+ {
185
+ "internalType": "bytes32",
186
+ "name": "uid",
187
+ "type": "bytes32"
188
+ },
189
+ {
190
+ "internalType": "bytes32",
191
+ "name": "schema",
192
+ "type": "bytes32"
193
+ },
194
+ {
195
+ "internalType": "uint64",
196
+ "name": "time",
197
+ "type": "uint64"
198
+ },
199
+ {
200
+ "internalType": "uint64",
201
+ "name": "expirationTime",
202
+ "type": "uint64"
203
+ },
204
+ {
205
+ "internalType": "uint64",
206
+ "name": "revocationTime",
207
+ "type": "uint64"
208
+ },
209
+ {
210
+ "internalType": "bytes32",
211
+ "name": "refUID",
212
+ "type": "bytes32"
213
+ },
214
+ {
215
+ "internalType": "address",
216
+ "name": "recipient",
217
+ "type": "address"
218
+ },
219
+ {
220
+ "internalType": "address",
221
+ "name": "attester",
222
+ "type": "address"
223
+ },
224
+ {
225
+ "internalType": "bool",
226
+ "name": "revocable",
227
+ "type": "bool"
228
+ },
229
+ {
230
+ "internalType": "bytes",
231
+ "name": "data",
232
+ "type": "bytes"
233
+ }
234
+ ],
235
+ "internalType": "struct Attestation[]",
236
+ "name": "attestations",
237
+ "type": "tuple[]"
238
+ },
239
+ {
240
+ "internalType": "uint256[]",
241
+ "name": "values",
242
+ "type": "uint256[]"
243
+ }
244
+ ],
245
+ "name": "multiAttest",
246
+ "outputs": [
247
+ {
248
+ "internalType": "bool",
249
+ "name": "",
250
+ "type": "bool"
251
+ }
252
+ ],
253
+ "stateMutability": "payable",
254
+ "type": "function"
255
+ },
256
+ {
257
+ "inputs": [
258
+ {
259
+ "components": [
260
+ {
261
+ "internalType": "bytes32",
262
+ "name": "uid",
263
+ "type": "bytes32"
264
+ },
265
+ {
266
+ "internalType": "bytes32",
267
+ "name": "schema",
268
+ "type": "bytes32"
269
+ },
270
+ {
271
+ "internalType": "uint64",
272
+ "name": "time",
273
+ "type": "uint64"
274
+ },
275
+ {
276
+ "internalType": "uint64",
277
+ "name": "expirationTime",
278
+ "type": "uint64"
279
+ },
280
+ {
281
+ "internalType": "uint64",
282
+ "name": "revocationTime",
283
+ "type": "uint64"
284
+ },
285
+ {
286
+ "internalType": "bytes32",
287
+ "name": "refUID",
288
+ "type": "bytes32"
289
+ },
290
+ {
291
+ "internalType": "address",
292
+ "name": "recipient",
293
+ "type": "address"
294
+ },
295
+ {
296
+ "internalType": "address",
297
+ "name": "attester",
298
+ "type": "address"
299
+ },
300
+ {
301
+ "internalType": "bool",
302
+ "name": "revocable",
303
+ "type": "bool"
304
+ },
305
+ {
306
+ "internalType": "bytes",
307
+ "name": "data",
308
+ "type": "bytes"
309
+ }
310
+ ],
311
+ "internalType": "struct Attestation[]",
312
+ "name": "attestations",
313
+ "type": "tuple[]"
314
+ },
315
+ {
316
+ "internalType": "uint256[]",
317
+ "name": "values",
318
+ "type": "uint256[]"
319
+ }
320
+ ],
321
+ "name": "multiRevoke",
322
+ "outputs": [
323
+ {
324
+ "internalType": "bool",
325
+ "name": "",
326
+ "type": "bool"
327
+ }
328
+ ],
329
+ "stateMutability": "payable",
330
+ "type": "function"
331
+ },
332
+ {
333
+ "inputs": [],
334
+ "name": "owner",
335
+ "outputs": [
336
+ {
337
+ "internalType": "address",
338
+ "name": "",
339
+ "type": "address"
340
+ }
341
+ ],
342
+ "stateMutability": "view",
343
+ "type": "function"
344
+ },
345
+ {
346
+ "inputs": [],
347
+ "name": "renounceOwnership",
348
+ "outputs": [],
349
+ "stateMutability": "nonpayable",
350
+ "type": "function"
351
+ },
352
+ {
353
+ "inputs": [
354
+ {
355
+ "components": [
356
+ {
357
+ "internalType": "bytes32",
358
+ "name": "uid",
359
+ "type": "bytes32"
360
+ },
361
+ {
362
+ "internalType": "bytes32",
363
+ "name": "schema",
364
+ "type": "bytes32"
365
+ },
366
+ {
367
+ "internalType": "uint64",
368
+ "name": "time",
369
+ "type": "uint64"
370
+ },
371
+ {
372
+ "internalType": "uint64",
373
+ "name": "expirationTime",
374
+ "type": "uint64"
375
+ },
376
+ {
377
+ "internalType": "uint64",
378
+ "name": "revocationTime",
379
+ "type": "uint64"
380
+ },
381
+ {
382
+ "internalType": "bytes32",
383
+ "name": "refUID",
384
+ "type": "bytes32"
385
+ },
386
+ {
387
+ "internalType": "address",
388
+ "name": "recipient",
389
+ "type": "address"
390
+ },
391
+ {
392
+ "internalType": "address",
393
+ "name": "attester",
394
+ "type": "address"
395
+ },
396
+ {
397
+ "internalType": "bool",
398
+ "name": "revocable",
399
+ "type": "bool"
400
+ },
401
+ {
402
+ "internalType": "bytes",
403
+ "name": "data",
404
+ "type": "bytes"
405
+ }
406
+ ],
407
+ "internalType": "struct Attestation",
408
+ "name": "attestation",
409
+ "type": "tuple"
410
+ }
411
+ ],
412
+ "name": "revoke",
413
+ "outputs": [
414
+ {
415
+ "internalType": "bool",
416
+ "name": "",
417
+ "type": "bool"
418
+ }
419
+ ],
420
+ "stateMutability": "payable",
421
+ "type": "function"
422
+ },
423
+ {
424
+ "inputs": [
425
+ {
426
+ "internalType": "address",
427
+ "name": "newOwner",
428
+ "type": "address"
429
+ }
430
+ ],
431
+ "name": "transferOwnership",
432
+ "outputs": [],
433
+ "stateMutability": "nonpayable",
434
+ "type": "function"
435
+ },
436
+ {
437
+ "inputs": [
438
+ {
439
+ "internalType": "bytes32",
440
+ "name": "uid",
441
+ "type": "bytes32"
442
+ },
443
+ {
444
+ "internalType": "address",
445
+ "name": "newOwner",
446
+ "type": "address"
447
+ }
448
+ ],
449
+ "name": "transferProjectOwnership",
450
+ "outputs": [],
451
+ "stateMutability": "nonpayable",
452
+ "type": "function"
453
+ },
454
+ {
455
+ "inputs": [],
456
+ "name": "version",
457
+ "outputs": [
458
+ {
459
+ "internalType": "string",
460
+ "name": "",
461
+ "type": "string"
462
+ }
463
+ ],
464
+ "stateMutability": "view",
465
+ "type": "function"
466
+ },
467
+ {
468
+ "stateMutability": "payable",
469
+ "type": "receive"
470
+ }
471
+ ]
@@ -200,6 +200,11 @@ export declare class GAP extends Facade {
200
200
  * @param signer
201
201
  */
202
202
  static getMulticall(signer: SignerOrProvider): ethers.Contract;
203
+ /**
204
+ * Get the multicall contract
205
+ * @param signer
206
+ */
207
+ static getProjectResolver(signer: SignerOrProvider): ethers.Contract;
203
208
  get schemas(): GapSchema[];
204
209
  /**
205
210
  * Defined if the transactions will be gasless or not.
package/core/class/GAP.js CHANGED
@@ -4,6 +4,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.GAP = void 0;
7
+ const MultiAttester_json_1 = __importDefault(require("../abi/MultiAttester.json"));
8
+ const ProjectResolver_json_1 = __importDefault(require("../abi/ProjectResolver.json"));
7
9
  const types_1 = require("../types");
8
10
  const Schema_1 = require("./Schema");
9
11
  const GapSchema_1 = require("./GapSchema");
@@ -11,7 +13,6 @@ const GapEasClient_1 = require("./GraphQL/GapEasClient");
11
13
  const eas_sdk_1 = require("@ethereum-attestation-service/eas-sdk");
12
14
  const consts_1 = require("../consts");
13
15
  const ethers_1 = require("ethers");
14
- const MultiAttester_json_1 = __importDefault(require("../abi/MultiAttester.json"));
15
16
  const package_json_1 = require("../../package.json");
16
17
  /**
17
18
  * GAP SDK Facade.
@@ -167,6 +168,14 @@ class GAP extends types_1.Facade {
167
168
  const address = consts_1.Networks[this.client.network].contracts.multicall;
168
169
  return new ethers_1.ethers.Contract(address, MultiAttester_json_1.default, signer);
169
170
  }
171
+ /**
172
+ * Get the multicall contract
173
+ * @param signer
174
+ */
175
+ static getProjectResolver(signer) {
176
+ const address = consts_1.Networks[this.client.network].contracts.projectResolver;
177
+ return new ethers_1.ethers.Contract(address, ProjectResolver_json_1.default, signer);
178
+ }
170
179
  get schemas() {
171
180
  return this._schemas;
172
181
  }
@@ -17,7 +17,7 @@ export declare class GapContract {
17
17
  * @returns
18
18
  */
19
19
  private static getRSV;
20
- private static getSignerAddress;
20
+ static getSignerAddress(signer: SignerOrProvider): Promise<string>;
21
21
  /**
22
22
  * Get nonce for the transaction
23
23
  * @param address
@@ -51,5 +51,20 @@ export declare class GapContract {
51
51
  * @returns an array with the attestation UIDs.
52
52
  */
53
53
  static multiRevokeBySig(signer: SignerOrProvider, payload: MultiRevocationRequest[]): Promise<void>;
54
+ /**
55
+ * Transfer the ownership of an attestation
56
+ * @param signer
57
+ * @param projectUID
58
+ * @param newOwner
59
+ * @returns
60
+ */
61
+ static transferProjectOwnership(signer: SignerOrProvider, projectUID: Hex, newOwner: Hex): Promise<any>;
62
+ /**
63
+ * Check if the signer is the owner of the project
64
+ * @param signer
65
+ * @param projectUID
66
+ * @returns
67
+ */
68
+ static isProjectOwner(signer: SignerOrProvider, projectUID: Hex): Promise<boolean>;
54
69
  private static getTransactionLogs;
55
70
  }
@@ -163,6 +163,30 @@ class GapContract {
163
163
  throw new Error('Transaction data is empty');
164
164
  await (0, send_gelato_txn_1.sendGelatoTxn)(...send_gelato_txn_1.Gelato.buildArgs(populatedTxn, chainId, contract.address));
165
165
  }
166
+ /**
167
+ * Transfer the ownership of an attestation
168
+ * @param signer
169
+ * @param projectUID
170
+ * @param newOwner
171
+ * @returns
172
+ */
173
+ static async transferProjectOwnership(signer, projectUID, newOwner) {
174
+ const contract = GAP_1.GAP.getProjectResolver(signer);
175
+ const tx = await contract.functions.transferProjectOwnership(projectUID, newOwner);
176
+ return tx.wait?.();
177
+ }
178
+ /**
179
+ * Check if the signer is the owner of the project
180
+ * @param signer
181
+ * @param projectUID
182
+ * @returns
183
+ */
184
+ static async isProjectOwner(signer, projectUID) {
185
+ const contract = GAP_1.GAP.getProjectResolver(signer);
186
+ const address = await this.getSignerAddress(signer);
187
+ const isOwner = await contract.functions.isAdmin(projectUID, address);
188
+ return !!isOwner?.[0];
189
+ }
166
190
  static async getTransactionLogs(signer, txnHash) {
167
191
  const txn = await signer.provider.getTransactionReceipt(txnHash);
168
192
  if (!txn || !txn.logs.length)
@@ -25,6 +25,7 @@ export declare class Grant extends Attestation<IGrant> {
25
25
  members: string[];
26
26
  completed?: GrantCompleted;
27
27
  project?: ISummaryProject;
28
+ categories?: string[];
28
29
  verify(signer: SignerOrProvider): Promise<void>;
29
30
  /**
30
31
  * Add milestones to the grant.
@@ -17,6 +17,7 @@ class Grant extends Attestation_1.Attestation {
17
17
  this.milestones = [];
18
18
  this.updates = [];
19
19
  this.members = [];
20
+ this.categories = [];
20
21
  }
21
22
  async verify(signer) {
22
23
  const eas = GAP_1.GAP.eas.connect(signer);
@@ -186,6 +187,9 @@ class Grant extends Attestation_1.Attestation {
186
187
  if (attestation.members) {
187
188
  grant.members = attestation.members;
188
189
  }
190
+ if (attestation.categories) {
191
+ grant.categories = attestation.categories;
192
+ }
189
193
  return grant;
190
194
  });
191
195
  }
@@ -1,8 +1,8 @@
1
- import { Attestation } from "../Attestation";
2
- import { Grantee, MemberDetails, ProjectDetails } from "../types/attestations";
3
- import { Hex, MultiAttestPayload, SignerOrProvider } from "core/types";
4
- import { Grant } from "./Grant";
5
- import { MemberOf } from "./MemberOf";
1
+ import { Attestation } from '../Attestation';
2
+ import { Grantee, MemberDetails, ProjectDetails } from '../types/attestations';
3
+ import { Hex, MultiAttestPayload, SignerOrProvider } from 'core/types';
4
+ import { Grant } from './Grant';
5
+ import { MemberOf } from './MemberOf';
6
6
  interface _Project extends Project {
7
7
  }
8
8
  export interface IProject {
@@ -25,6 +25,8 @@ export declare class Project extends Attestation<IProject> {
25
25
  */
26
26
  multiAttestPayload(currentPayload?: MultiAttestPayload, communityIdx?: number): Promise<MultiAttestPayload>;
27
27
  attest(signer: SignerOrProvider): Promise<void>;
28
+ transferOwnership(signer: SignerOrProvider, newOwner: Hex): Promise<void>;
29
+ isOwner(signer: SignerOrProvider): Promise<boolean>;
28
30
  /**
29
31
  * Add new members to the project.
30
32
  * If any member in the array already exists in the project