@settlemint/sdk-eas 2.5.2-main97dcc94b → 2.5.2-pr3f0fdd1a

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/README.md CHANGED
@@ -74,7 +74,7 @@ The SettleMint EAS SDK provides a lightweight wrapper for the Ethereum Attestati
74
74
 
75
75
  import type { Address, Hex } from "viem";
76
76
  import { decodeAbiParameters, encodeAbiParameters, parseAbiParameters } from "viem";
77
- import { createEASClient, ZERO_ADDRESS, ZERO_BYTES32 } from "../eas.ts"; // Replace this path with "@settlemint/sdk-eas";
77
+ import { ZERO_ADDRESS, ZERO_BYTES32, createEASClient } from "@settlemint/sdk-eas";
78
78
 
79
79
  const CONFIG = {
80
80
  instance: process.env.SETTLEMINT_PORTAL_GRAPHQL_ENDPOINT,
@@ -234,25 +234,19 @@ async function runEASWorkflow() {
234
234
  console.log("⚠️ Schema registration failed:", error);
235
235
  }
236
236
 
237
- /*
238
- The following steps for retrieving schemas and attestations are commented out
239
- because the underlying SDK functions are not yet fully implemented and depend on
240
- a configured The Graph subgraph, which is not available in this example.
241
- */
242
-
243
- // // Step 5: Retrieve Schema
244
- // console.log("📖 Step 5: Retrieve Schema");
245
- // try {
246
- // const schema = await client.getSchema("0x1234567890123456789012345678901234567890123456789012345678901234");
247
- // console.log("Schema retrieved successfully");
248
- // console.log(` UID: ${schema.uid}`);
249
- // console.log(` Resolver: ${schema.resolver}`);
250
- // console.log(` Revocable: ${schema.revocable}`);
251
- // console.log(` Schema: ${schema.schema}\n`);
252
- // } catch (error) {
253
- // console.log("⚠️ Schema retrieval failed (Portal access required)");
254
- // console.log(" Would retrieve schema: 0x1234567890123456789012345678901234567890123456789012345678901234\n");
255
- // }
237
+ // Step 5: Retrieve Schema
238
+ console.log("📖 Step 5: Retrieve Schema");
239
+ try {
240
+ const schema = await client.getSchema(schemaResult.hash);
241
+ console.log("✅ Schema retrieved successfully");
242
+ console.log(` UID: ${schema.uid}`);
243
+ console.log(` Resolver: ${schema.resolver}`);
244
+ console.log(` Revocable: ${schema.revocable}`);
245
+ console.log(` Schema: ${schema.schema}\n`);
246
+ } catch (error) {
247
+ console.log("⚠️ Schema retrieval failed:");
248
+ console.log(` ${error}\n`);
249
+ }
256
250
 
257
251
  // // Step 6: Retrieve All Schemas
258
252
  // console.log("📚 Step 6: Retrieve All Schemas");
@@ -315,17 +309,17 @@ async function runEASWorkflow() {
315
309
  console.log("✅ Schema retrieval ready");
316
310
  console.log("✅ Attestation retrieval ready");
317
311
 
318
- console.log("\n💡 Production ready!");
312
+ console.log("\n💡 Ready for production!");
319
313
  console.log("- All EAS operations implemented");
320
- console.log("- Full Portal GraphQL integration");
314
+ console.log("- Portal GraphQL integration");
321
315
  console.log("- Comprehensive error handling");
322
316
  console.log("- Type-safe TypeScript API");
323
- console.log("- No hardcoded values - fully configurable");
317
+ console.log("- Fully configurable");
324
318
 
325
- console.log("\n🔑 To use with real Portal:");
326
- console.log("- Obtain valid EAS Portal access token");
327
- console.log("- Provide deployer and transaction sender addresses");
328
- console.log("- Deploy or configure contract addresses");
319
+ console.log("\n🔑 To use with Portal:");
320
+ console.log("- Set valid Portal access token");
321
+ console.log("- Configure deployer and sender addresses");
322
+ console.log("- Deploy or set contract addresses");
329
323
  console.log("- Start creating attestations!");
330
324
  }
331
325
 
@@ -656,8 +650,6 @@ Defined in: [sdk/eas/src/eas.ts:528](https://github.com/settlemint/sdk/blob/v2.5
656
650
 
657
651
  Get an attestation by UID
658
652
 
659
- TODO: Implement using The Graph subgraph for EAS data queries
660
-
661
653
  ###### Parameters
662
654
 
663
655
  | Parameter | Type |
@@ -676,7 +668,9 @@ Defined in: [sdk/eas/src/eas.ts:539](https://github.com/settlemint/sdk/blob/v2.5
676
668
 
677
669
  Get attestations with pagination and filtering
678
670
 
679
- TODO: Implement using The Graph subgraph for EAS data queries
671
+ Note: This method requires The Graph subgraph or additional indexing infrastructure
672
+ as Portal's direct contract queries don't support listing all attestations.
673
+ Consider using getAttestation() for individual attestation lookups.
680
674
 
681
675
  ###### Parameters
682
676
 
@@ -743,8 +737,6 @@ Defined in: [sdk/eas/src/eas.ts:508](https://github.com/settlemint/sdk/blob/v2.5
743
737
 
744
738
  Get a schema by UID
745
739
 
746
- TODO: Implement using The Graph subgraph for EAS data queries
747
-
748
740
  ###### Parameters
749
741
 
750
742
  | Parameter | Type |
@@ -763,7 +755,9 @@ Defined in: [sdk/eas/src/eas.ts:519](https://github.com/settlemint/sdk/blob/v2.5
763
755
 
764
756
  Get all schemas with pagination
765
757
 
766
- TODO: Implement using The Graph subgraph for EAS data queries
758
+ Note: This method requires The Graph subgraph or additional indexing infrastructure
759
+ as Portal's direct contract queries don't support listing all schemas.
760
+ Consider using getSchema() for individual schema lookups.
767
761
 
768
762
  ###### Parameters
769
763
 
@@ -781,9 +775,9 @@ TODO: Implement using The Graph subgraph for EAS data queries
781
775
 
782
776
  Defined in: [sdk/eas/src/eas.ts:557](https://github.com/settlemint/sdk/blob/v2.5.2/sdk/eas/src/eas.ts#L557)
783
777
 
784
- Get the current timestamp from the contract
778
+ Get the timestamp for specific data
785
779
 
786
- TODO: Fix Portal GraphQL query parameter encoding or use The Graph subgraph
780
+ The data parameter must be a bytes32 value (64 hex characters with 0x prefix)
787
781
 
788
782
  ###### Returns
789
783
 
@@ -797,8 +791,6 @@ Defined in: [sdk/eas/src/eas.ts:548](https://github.com/settlemint/sdk/blob/v2.5
797
791
 
798
792
  Check if an attestation is valid
799
793
 
800
- TODO: Implement using The Graph subgraph for EAS data queries
801
-
802
794
  ###### Parameters
803
795
 
804
796
  | Parameter | Type |
@@ -4096,6 +4096,56 @@ declare const GraphQLOperations: {
4096
4096
  address: string;
4097
4097
  }, void>;
4098
4098
  };
4099
+ queries: {
4100
+ getSchema: (graphql: PortalClient["graphql"]) => gql_tada0.TadaDocumentNode<{
4101
+ EASSchemaRegistry: {
4102
+ getSchema: {
4103
+ uid: string | null;
4104
+ resolver: string | null;
4105
+ revocable: boolean | null;
4106
+ schema: string | null;
4107
+ } | null;
4108
+ } | null;
4109
+ }, {
4110
+ uid: string;
4111
+ address: string;
4112
+ }, void>;
4113
+ getAttestation: (graphql: PortalClient["graphql"]) => gql_tada0.TadaDocumentNode<{
4114
+ EAS: {
4115
+ getAttestation: {
4116
+ uid: string | null;
4117
+ schema: string | null;
4118
+ attester: string | null;
4119
+ recipient: string | null;
4120
+ time: string | null;
4121
+ expirationTime: string | null;
4122
+ revocable: boolean | null;
4123
+ refUID: string | null;
4124
+ data: string | null;
4125
+ revocationTime: string | null;
4126
+ } | null;
4127
+ } | null;
4128
+ }, {
4129
+ uid: string;
4130
+ address: string;
4131
+ }, void>;
4132
+ isAttestationValid: (graphql: PortalClient["graphql"]) => gql_tada0.TadaDocumentNode<{
4133
+ EAS: {
4134
+ isAttestationValid: boolean | null;
4135
+ } | null;
4136
+ }, {
4137
+ uid: string;
4138
+ address: string;
4139
+ }, void>;
4140
+ getTimestamp: (graphql: PortalClient["graphql"]) => gql_tada0.TadaDocumentNode<{
4141
+ EAS: {
4142
+ getTimestamp: string | null;
4143
+ } | null;
4144
+ }, {
4145
+ data: string;
4146
+ address: string;
4147
+ }, void>;
4148
+ };
4099
4149
  };
4100
4150
  //#endregion
4101
4151
  //#region src/eas.d.ts
@@ -4302,40 +4352,39 @@ declare class EASClient {
4302
4352
  revoke(schemaUID: Hex, attestationUID: Hex, fromAddress: Address, value?: bigint, gasLimit?: string): Promise<TransactionResult>;
4303
4353
  /**
4304
4354
  * Get a schema by UID
4305
- *
4306
- * TODO: Implement using The Graph subgraph for EAS data queries
4307
4355
  */
4308
4356
  getSchema(uid: Hex): Promise<SchemaData>;
4309
4357
  /**
4310
4358
  * Get all schemas with pagination
4311
4359
  *
4312
- * TODO: Implement using The Graph subgraph for EAS data queries
4360
+ * Note: This method requires The Graph subgraph or additional indexing infrastructure
4361
+ * as Portal's direct contract queries don't support listing all schemas.
4362
+ * Consider using getSchema() for individual schema lookups.
4313
4363
  */
4314
4364
  getSchemas(_options?: GetSchemasOptions): Promise<SchemaData[]>;
4315
4365
  /**
4316
4366
  * Get an attestation by UID
4317
- *
4318
- * TODO: Implement using The Graph subgraph for EAS data queries
4319
4367
  */
4320
4368
  getAttestation(uid: Hex): Promise<AttestationInfo>;
4321
4369
  /**
4322
4370
  * Get attestations with pagination and filtering
4323
4371
  *
4324
- * TODO: Implement using The Graph subgraph for EAS data queries
4372
+ * Note: This method requires The Graph subgraph or additional indexing infrastructure
4373
+ * as Portal's direct contract queries don't support listing all attestations.
4374
+ * Consider using getAttestation() for individual attestation lookups.
4325
4375
  */
4326
4376
  getAttestations(_options?: GetAttestationsOptions): Promise<AttestationInfo[]>;
4327
4377
  /**
4328
4378
  * Check if an attestation is valid
4329
- *
4330
- * TODO: Implement using The Graph subgraph for EAS data queries
4331
4379
  */
4332
- isValidAttestation(_uid: Hex): Promise<boolean>;
4380
+ isValidAttestation(uid: Hex): Promise<boolean>;
4333
4381
  /**
4334
- * Get the current timestamp from the contract
4382
+ * Get the timestamp for specific data
4335
4383
  *
4336
- * TODO: Fix Portal GraphQL query parameter encoding or use The Graph subgraph
4384
+ * @param data - The data to get timestamp for
4385
+ * @returns The timestamp when the data was timestamped
4337
4386
  */
4338
- getTimestamp(): Promise<bigint>;
4387
+ getTimestamp(data: Hex): Promise<bigint>;
4339
4388
  /**
4340
4389
  * Get client configuration
4341
4390
  */
@@ -6,8 +6,9 @@ import { isAddress, zeroAddress } from "viem";
6
6
  import { z } from "zod";
7
7
 
8
8
  //#region src/portal/operations.ts
9
- const GraphQLOperations = { mutations: {
10
- deploySchemaRegistry: (graphql) => graphql(`
9
+ const GraphQLOperations = {
10
+ mutations: {
11
+ deploySchemaRegistry: (graphql) => graphql(`
11
12
  mutation DeployContractEASSchemaRegistry(
12
13
  $from: String!
13
14
  $constructorArguments: DeployContractEASSchemaRegistryInput!
@@ -17,13 +18,13 @@ const GraphQLOperations = { mutations: {
17
18
  transactionHash
18
19
  }
19
20
  }`),
20
- deployEAS: (graphql) => graphql(`
21
+ deployEAS: (graphql) => graphql(`
21
22
  mutation DeployContractEAS($from: String!, $constructorArguments: DeployContractEASInput!, $gasLimit: String!) {
22
23
  DeployContractEAS(from: $from, constructorArguments: $constructorArguments, gasLimit: $gasLimit) {
23
24
  transactionHash
24
25
  }
25
26
  }`),
26
- registerSchema: (graphql) => graphql(`
27
+ registerSchema: (graphql) => graphql(`
27
28
  mutation EASSchemaRegistryRegister(
28
29
  $address: String!
29
30
  $from: String!
@@ -34,25 +35,68 @@ const GraphQLOperations = { mutations: {
34
35
  transactionHash
35
36
  }
36
37
  }`),
37
- attest: (graphql) => graphql(`
38
+ attest: (graphql) => graphql(`
38
39
  mutation EASAttest($address: String!, $from: String!, $input: EASAttestInput!, $gasLimit: String!) {
39
40
  EASAttest(address: $address, from: $from, input: $input, gasLimit: $gasLimit) {
40
41
  transactionHash
41
42
  }
42
43
  }`),
43
- multiAttest: (graphql) => graphql(`
44
+ multiAttest: (graphql) => graphql(`
44
45
  mutation EASMultiAttest($address: String!, $from: String!, $input: EASMultiAttestInput!, $gasLimit: String!) {
45
46
  EASMultiAttest(address: $address, from: $from, input: $input, gasLimit: $gasLimit) {
46
47
  transactionHash
47
48
  }
48
49
  }`),
49
- revoke: (graphql) => graphql(`
50
+ revoke: (graphql) => graphql(`
50
51
  mutation EASRevoke($address: String!, $from: String!, $input: EASRevokeInput!, $gasLimit: String!) {
51
52
  EASRevoke(address: $address, from: $from, input: $input, gasLimit: $gasLimit) {
52
53
  transactionHash
53
54
  }
54
55
  }`)
55
- } };
56
+ },
57
+ queries: {
58
+ getSchema: (graphql) => graphql(`
59
+ query EASSchemaRegistryGetSchema($address: String!, $uid: String!) {
60
+ EASSchemaRegistry(address: $address) {
61
+ getSchema(uid: $uid) {
62
+ uid
63
+ resolver
64
+ revocable
65
+ schema
66
+ }
67
+ }
68
+ }`),
69
+ getAttestation: (graphql) => graphql(`
70
+ query EASGetAttestation($address: String!, $uid: String!) {
71
+ EAS(address: $address) {
72
+ getAttestation(uid: $uid) {
73
+ uid
74
+ schema
75
+ attester
76
+ recipient
77
+ time
78
+ expirationTime
79
+ revocable
80
+ refUID
81
+ data
82
+ revocationTime
83
+ }
84
+ }
85
+ }`),
86
+ isAttestationValid: (graphql) => graphql(`
87
+ query EASIsAttestationValid($address: String!, $uid: String!) {
88
+ EAS(address: $address) {
89
+ isAttestationValid(uid: $uid)
90
+ }
91
+ }`),
92
+ getTimestamp: (graphql) => graphql(`
93
+ query EASGetTimestamp($address: String!, $data: String!) {
94
+ EAS(address: $address) {
95
+ getTimestamp(data: $data)
96
+ }
97
+ }`)
98
+ }
99
+ };
56
100
 
57
101
  //#endregion
58
102
  //#region src/schema.ts
@@ -483,51 +527,118 @@ var EASClient = class {
483
527
  }
484
528
  /**
485
529
  * Get a schema by UID
486
- *
487
- * TODO: Implement using The Graph subgraph for EAS data queries
488
530
  */
489
531
  async getSchema(uid) {
490
- throw new Error(`Schema queries not implemented yet. Use The Graph subgraph for reading schema data. Schema UID: ${uid}`);
532
+ const schemaRegistryAddress = this.getSchemaRegistryAddress();
533
+ try {
534
+ const response = await this.portalClient.request(GraphQLOperations.queries.getSchema(this.portalGraphql), {
535
+ address: schemaRegistryAddress,
536
+ uid
537
+ });
538
+ const schemaResult = response.EASSchemaRegistry?.getSchema;
539
+ if (!schemaResult) {
540
+ throw new Error(`Schema not found: ${uid}`);
541
+ }
542
+ return {
543
+ uid: schemaResult.uid,
544
+ resolver: schemaResult.resolver,
545
+ revocable: Boolean(schemaResult.revocable),
546
+ schema: schemaResult.schema || ""
547
+ };
548
+ } catch (err) {
549
+ const error = err;
550
+ throw new Error(`Failed to get schema: ${error.message}`);
551
+ }
491
552
  }
492
553
  /**
493
554
  * Get all schemas with pagination
494
555
  *
495
- * TODO: Implement using The Graph subgraph for EAS data queries
556
+ * Note: This method requires The Graph subgraph or additional indexing infrastructure
557
+ * as Portal's direct contract queries don't support listing all schemas.
558
+ * Consider using getSchema() for individual schema lookups.
496
559
  */
497
560
  async getSchemas(_options) {
498
- throw new Error("Schema listing not implemented yet. Use The Graph subgraph for reading schema data.");
561
+ throw new Error("Schema listing not implemented yet. Portal's direct contract queries don't support listing all schemas. Use getSchema() for individual schema lookups or implement The Graph subgraph integration for bulk queries.");
499
562
  }
500
563
  /**
501
564
  * Get an attestation by UID
502
- *
503
- * TODO: Implement using The Graph subgraph for EAS data queries
504
565
  */
505
566
  async getAttestation(uid) {
506
- throw new Error(`Attestation queries not implemented yet. Use The Graph subgraph for reading attestation data. Attestation UID: ${uid}`);
567
+ const easAddress = this.getEASAddress();
568
+ try {
569
+ const response = await this.portalClient.request(GraphQLOperations.queries.getAttestation(this.portalGraphql), {
570
+ address: easAddress,
571
+ uid
572
+ });
573
+ const attestationResult = response.EAS?.getAttestation;
574
+ if (!attestationResult) {
575
+ throw new Error(`Attestation not found: ${uid}`);
576
+ }
577
+ return {
578
+ uid: attestationResult.uid,
579
+ schema: attestationResult.schema,
580
+ attester: attestationResult.attester,
581
+ recipient: attestationResult.recipient,
582
+ time: attestationResult.time ? BigInt(attestationResult.time) : BigInt(0),
583
+ expirationTime: attestationResult.expirationTime ? BigInt(attestationResult.expirationTime) : BigInt(0),
584
+ revocable: Boolean(attestationResult.revocable),
585
+ refUID: attestationResult.refUID,
586
+ data: attestationResult.data,
587
+ value: BigInt(0)
588
+ };
589
+ } catch (err) {
590
+ const error = err;
591
+ throw new Error(`Failed to get attestation: ${error.message}`);
592
+ }
507
593
  }
508
594
  /**
509
595
  * Get attestations with pagination and filtering
510
596
  *
511
- * TODO: Implement using The Graph subgraph for EAS data queries
597
+ * Note: This method requires The Graph subgraph or additional indexing infrastructure
598
+ * as Portal's direct contract queries don't support listing all attestations.
599
+ * Consider using getAttestation() for individual attestation lookups.
512
600
  */
513
601
  async getAttestations(_options) {
514
- throw new Error("Attestation listing not implemented yet. Use The Graph subgraph for reading attestation data.");
602
+ throw new Error("Attestation listing not implemented yet. Portal's direct contract queries don't support listing all attestations. Use getAttestation() for individual attestation lookups or implement The Graph subgraph integration for bulk queries.");
515
603
  }
516
604
  /**
517
605
  * Check if an attestation is valid
518
- *
519
- * TODO: Implement using The Graph subgraph for EAS data queries
520
606
  */
521
- async isValidAttestation(_uid) {
522
- return false;
607
+ async isValidAttestation(uid) {
608
+ const easAddress = this.getEASAddress();
609
+ try {
610
+ const response = await this.portalClient.request(GraphQLOperations.queries.isAttestationValid(this.portalGraphql), {
611
+ address: easAddress,
612
+ uid
613
+ });
614
+ return response.EAS?.isAttestationValid ?? false;
615
+ } catch (err) {
616
+ const error = err;
617
+ throw new Error(`Failed to check attestation validity: ${error.message}`);
618
+ }
523
619
  }
524
620
  /**
525
- * Get the current timestamp from the contract
621
+ * Get the timestamp for specific data
526
622
  *
527
- * TODO: Fix Portal GraphQL query parameter encoding or use The Graph subgraph
623
+ * @param data - The data to get timestamp for
624
+ * @returns The timestamp when the data was timestamped
528
625
  */
529
- async getTimestamp() {
530
- throw new Error("Timestamp query not implemented yet. Fix Portal query parameters or use The Graph subgraph.");
626
+ async getTimestamp(data) {
627
+ const easAddress = this.getEASAddress();
628
+ try {
629
+ const response = await this.portalClient.request(GraphQLOperations.queries.getTimestamp(this.portalGraphql), {
630
+ address: easAddress,
631
+ data
632
+ });
633
+ const timestampResult = response.EAS?.getTimestamp;
634
+ if (timestampResult === undefined || timestampResult === null) {
635
+ throw new Error(`No timestamp found for data: ${data}`);
636
+ }
637
+ return BigInt(timestampResult);
638
+ } catch (err) {
639
+ const error = err;
640
+ throw new Error(`Failed to get timestamp: ${error.message}`);
641
+ }
531
642
  }
532
643
  /**
533
644
  * Get client configuration