@oma3/omatrust 0.1.0-alpha.4 → 0.1.0-alpha.6

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.
@@ -1,2 +1,2 @@
1
- export { A as AttestationQueryResult, B as BuildDelegatedTypedDataFromEncodedParams, C as CallControllerWitnessParams, a as CallControllerWitnessResult, b as ChainConstants, c as CreatePopEip712ProofParams, d as CreatePopJwsProofParams, D as Did, E as EvidencePointerProof, G as GetAttestationParams, e as GetLatestAttestationsParams, H as Hex, L as ListAttestationsParams, P as PopEip712Proof, f as PopJwsProof, g as PrepareDelegatedAttestationParams, h as PrepareDelegatedAttestationResult, i as ProofPurpose, j as ProofType, k as ProofWrapper, S as SchemaField, l as SubmitAttestationParams, m as SubmitAttestationResult, n as SubmitDelegatedAttestationParams, o as SubmitDelegatedAttestationResult, T as TxEncodedValueProof, p as TxInteractionProof, V as VerifyAttestationParams, q as VerifyAttestationResult, r as VerifyProofParams, s as VerifyProofResult, X as X402OfferProof, t as X402ReceiptProof, u as buildDelegatedAttestationTypedData, v as buildDelegatedTypedDataFromEncoded, w as buildDnsTxtRecord, x as buildEip712Domain, y as calculateAverageUserReviewRating, z as calculateTransferAmount, F as calculateTransferAmountFromAddresses, I as callControllerWitness, J as constructSeed, K as createEvidencePointerProof, M as createPopEip712Proof, N as createPopJwsProof, O as createTxEncodedValueProof, Q as createTxInteractionProof, R as createX402OfferProof, U as createX402ReceiptProof, W as decodeAttestationData, Y as deduplicateReviews, Z as encodeAttestationData, _ as extractAddressesFromDidDocument, $ as extractExpirationTime, a0 as fetchDidDocument, a1 as formatSchemaUid, a2 as formatTransferAmount, a3 as getAttestation, a4 as getAttestationsForDid, a5 as getChainConstants, a6 as getExplorerAddressUrl, a7 as getExplorerTxUrl, a8 as getLatestAttestations, a9 as getMajorVersion, aa as getOmaTrustProofEip712Types, ab as getSchemaDetails, ac as getSupportedChainIds, ad as hashSeed, ae as isChainSupported, af as listAttestations, ag as normalizeSchema, ah as parseDnsTxtRecord, ai as prepareDelegatedAttestation, aj as schemaToString, ak as splitSignature, al as submitAttestation, am as submitDelegatedAttestation, an as verifyAttestation, ao as verifyDidDocumentControllerDid, ap as verifyEip712Signature, aq as verifyProof, ar as verifySchemaExists } from '../eip712-C4a-JGko.cjs';
2
- export { v as verifyDnsTxtControllerDid } from '../index-DP6IIpIh.cjs';
1
+ export { A as AttestationQueryResult, a as AttestationValidationError, B as BuildDelegatedTypedDataFromEncodedParams, C as CallControllerWitnessParams, b as CallControllerWitnessResult, c as ChainConstants, d as CreatePopEip712ProofParams, e as CreatePopJwsProofParams, D as Did, E as EvidencePointerProof, G as GetAttestationParams, f as GetAttestationsByAttesterParams, g as GetLatestAttestationsParams, H as Hex, L as ListAttestationsParams, P as PopEip712Proof, h as PopJwsProof, i as PrepareDelegatedAttestationParams, j as PrepareDelegatedAttestationResult, k as ProofPurpose, l as ProofType, m as ProofWrapper, R as RevokeAttestationParams, n as RevokeAttestationResult, S as SchemaField, o as SubmitAttestationParams, p as SubmitAttestationResult, q as SubmitDelegatedAttestationParams, r as SubmitDelegatedAttestationResult, T as TxEncodedValueProof, s as TxInteractionProof, V as VerifyAttestationParams, t as VerifyAttestationResult, u as VerifyProofParams, v as VerifyProofResult, X as X402OfferProof, w as X402ReceiptProof, x as buildDelegatedAttestationTypedData, y as buildDelegatedTypedDataFromEncoded, z as buildDnsTxtRecord, F as buildEip712Domain, I as calculateAverageUserReviewRating, J as calculateTransferAmount, K as calculateTransferAmountFromAddresses, M as callControllerWitness, N as constructSeed, O as createEvidencePointerProof, Q as createPopEip712Proof, U as createPopJwsProof, W as createTxEncodedValueProof, Y as createTxInteractionProof, Z as createX402OfferProof, _ as createX402ReceiptProof, $ as decodeAttestationData, a0 as deduplicateReviews, a1 as encodeAttestationData, a2 as extractAddressesFromDidDocument, a3 as extractExpirationTime, a4 as fetchDidDocument, a5 as formatSchemaUid, a6 as formatTransferAmount, a7 as getAttestation, a8 as getAttestationsByAttester, a9 as getAttestationsForDid, aa as getChainConstants, ab as getExplorerAddressUrl, ac as getExplorerTxUrl, ad as getLatestAttestations, ae as getMajorVersion, af as getOmaTrustProofEip712Types, ag as getSchemaDetails, ah as getSupportedChainIds, ai as hashSeed, aj as isChainSupported, ak as listAttestations, al as normalizeSchema, am as parseDnsTxtRecord, an as prepareDelegatedAttestation, ao as revokeAttestation, ap as schemaToString, aq as splitSignature, ar as submitAttestation, as as submitDelegatedAttestation, at as validateAttestationData, au as verifyAttestation, av as verifyDidDocumentControllerDid, aw as verifyEip712Signature, ax as verifyProof, ay as verifySchemaExists } from '../eip712-CevLiOcD.cjs';
2
+ export { v as verifyDnsTxtControllerDid } from '../index-BsUwj4r5.cjs';
@@ -1,2 +1,2 @@
1
- export { A as AttestationQueryResult, B as BuildDelegatedTypedDataFromEncodedParams, C as CallControllerWitnessParams, a as CallControllerWitnessResult, b as ChainConstants, c as CreatePopEip712ProofParams, d as CreatePopJwsProofParams, D as Did, E as EvidencePointerProof, G as GetAttestationParams, e as GetLatestAttestationsParams, H as Hex, L as ListAttestationsParams, P as PopEip712Proof, f as PopJwsProof, g as PrepareDelegatedAttestationParams, h as PrepareDelegatedAttestationResult, i as ProofPurpose, j as ProofType, k as ProofWrapper, S as SchemaField, l as SubmitAttestationParams, m as SubmitAttestationResult, n as SubmitDelegatedAttestationParams, o as SubmitDelegatedAttestationResult, T as TxEncodedValueProof, p as TxInteractionProof, V as VerifyAttestationParams, q as VerifyAttestationResult, r as VerifyProofParams, s as VerifyProofResult, X as X402OfferProof, t as X402ReceiptProof, u as buildDelegatedAttestationTypedData, v as buildDelegatedTypedDataFromEncoded, w as buildDnsTxtRecord, x as buildEip712Domain, y as calculateAverageUserReviewRating, z as calculateTransferAmount, F as calculateTransferAmountFromAddresses, I as callControllerWitness, J as constructSeed, K as createEvidencePointerProof, M as createPopEip712Proof, N as createPopJwsProof, O as createTxEncodedValueProof, Q as createTxInteractionProof, R as createX402OfferProof, U as createX402ReceiptProof, W as decodeAttestationData, Y as deduplicateReviews, Z as encodeAttestationData, _ as extractAddressesFromDidDocument, $ as extractExpirationTime, a0 as fetchDidDocument, a1 as formatSchemaUid, a2 as formatTransferAmount, a3 as getAttestation, a4 as getAttestationsForDid, a5 as getChainConstants, a6 as getExplorerAddressUrl, a7 as getExplorerTxUrl, a8 as getLatestAttestations, a9 as getMajorVersion, aa as getOmaTrustProofEip712Types, ab as getSchemaDetails, ac as getSupportedChainIds, ad as hashSeed, ae as isChainSupported, af as listAttestations, ag as normalizeSchema, ah as parseDnsTxtRecord, ai as prepareDelegatedAttestation, aj as schemaToString, ak as splitSignature, al as submitAttestation, am as submitDelegatedAttestation, an as verifyAttestation, ao as verifyDidDocumentControllerDid, ap as verifyEip712Signature, aq as verifyProof, ar as verifySchemaExists } from '../eip712-C4a-JGko.js';
2
- export { v as verifyDnsTxtControllerDid } from '../index-BDeQNCi_.js';
1
+ export { A as AttestationQueryResult, a as AttestationValidationError, B as BuildDelegatedTypedDataFromEncodedParams, C as CallControllerWitnessParams, b as CallControllerWitnessResult, c as ChainConstants, d as CreatePopEip712ProofParams, e as CreatePopJwsProofParams, D as Did, E as EvidencePointerProof, G as GetAttestationParams, f as GetAttestationsByAttesterParams, g as GetLatestAttestationsParams, H as Hex, L as ListAttestationsParams, P as PopEip712Proof, h as PopJwsProof, i as PrepareDelegatedAttestationParams, j as PrepareDelegatedAttestationResult, k as ProofPurpose, l as ProofType, m as ProofWrapper, R as RevokeAttestationParams, n as RevokeAttestationResult, S as SchemaField, o as SubmitAttestationParams, p as SubmitAttestationResult, q as SubmitDelegatedAttestationParams, r as SubmitDelegatedAttestationResult, T as TxEncodedValueProof, s as TxInteractionProof, V as VerifyAttestationParams, t as VerifyAttestationResult, u as VerifyProofParams, v as VerifyProofResult, X as X402OfferProof, w as X402ReceiptProof, x as buildDelegatedAttestationTypedData, y as buildDelegatedTypedDataFromEncoded, z as buildDnsTxtRecord, F as buildEip712Domain, I as calculateAverageUserReviewRating, J as calculateTransferAmount, K as calculateTransferAmountFromAddresses, M as callControllerWitness, N as constructSeed, O as createEvidencePointerProof, Q as createPopEip712Proof, U as createPopJwsProof, W as createTxEncodedValueProof, Y as createTxInteractionProof, Z as createX402OfferProof, _ as createX402ReceiptProof, $ as decodeAttestationData, a0 as deduplicateReviews, a1 as encodeAttestationData, a2 as extractAddressesFromDidDocument, a3 as extractExpirationTime, a4 as fetchDidDocument, a5 as formatSchemaUid, a6 as formatTransferAmount, a7 as getAttestation, a8 as getAttestationsByAttester, a9 as getAttestationsForDid, aa as getChainConstants, ab as getExplorerAddressUrl, ac as getExplorerTxUrl, ad as getLatestAttestations, ae as getMajorVersion, af as getOmaTrustProofEip712Types, ag as getSchemaDetails, ah as getSupportedChainIds, ai as hashSeed, aj as isChainSupported, ak as listAttestations, al as normalizeSchema, am as parseDnsTxtRecord, an as prepareDelegatedAttestation, ao as revokeAttestation, ap as schemaToString, aq as splitSignature, ar as submitAttestation, as as submitDelegatedAttestation, at as validateAttestationData, au as verifyAttestation, av as verifyDidDocumentControllerDid, aw as verifyEip712Signature, ax as verifyProof, ay as verifySchemaExists } from '../eip712-CevLiOcD.js';
2
+ export { v as verifyDnsTxtControllerDid } from '../index-pYFRyitI.js';
@@ -1,5 +1,5 @@
1
1
  import { SchemaEncoder, EAS } from '@ethereum-attestation-service/eas-sdk';
2
- import { ZeroAddress, Signature, Contract, toUtf8Bytes, sha256, keccak256, formatUnits, getAddress, isAddress, verifyTypedData, hexlify, randomBytes } from 'ethers';
2
+ import { ZeroAddress, Signature, toUtf8Bytes, sha256, keccak256, formatUnits, getAddress, isAddress, verifyTypedData, hexlify, randomBytes, Contract } from 'ethers';
3
3
  import canonicalize from 'canonicalize';
4
4
  import { resolveTxt } from 'dns/promises';
5
5
 
@@ -52,6 +52,13 @@ function encodeAttestationData(schema, data) {
52
52
  if (!data || typeof data !== "object") {
53
53
  throw new OmaTrustError("INVALID_INPUT", "data must be an object");
54
54
  }
55
+ const validationErrors = validateAttestationData(schema, data);
56
+ if (validationErrors.length > 0) {
57
+ const summary = validationErrors.map((error) => `Field "${error.schemaFieldName}" (${error.expectedType}) got ${error.providedType}`).join("; ");
58
+ throw new OmaTrustError("INVALID_INPUT", `Attestation data validation failed: ${summary}`, {
59
+ errors: validationErrors
60
+ });
61
+ }
55
62
  const fields = normalizeSchema(schema);
56
63
  const schemaString = schemaToString(fields);
57
64
  const encoder = new SchemaEncoder(schemaString);
@@ -64,6 +71,99 @@ function encodeAttestationData(schema, data) {
64
71
  );
65
72
  return encoded;
66
73
  }
74
+ function getActualType(value) {
75
+ if (value === null) {
76
+ return "null";
77
+ }
78
+ if (value === void 0) {
79
+ return "undefined";
80
+ }
81
+ if (Array.isArray(value)) {
82
+ return "array";
83
+ }
84
+ if (typeof value === "number") {
85
+ return Number.isFinite(value) ? "number" : "non-finite-number";
86
+ }
87
+ return typeof value;
88
+ }
89
+ function isNumericValue(value, allowNegative) {
90
+ if (typeof value === "bigint") {
91
+ return allowNegative || value >= 0n;
92
+ }
93
+ if (typeof value === "number") {
94
+ if (!Number.isFinite(value) || !Number.isInteger(value)) {
95
+ return false;
96
+ }
97
+ return allowNegative || value >= 0;
98
+ }
99
+ if (typeof value === "string") {
100
+ if (value.length === 0) {
101
+ return false;
102
+ }
103
+ const pattern = allowNegative ? /^-?\d+$/ : /^\d+$/;
104
+ return pattern.test(value);
105
+ }
106
+ return false;
107
+ }
108
+ function isHex(value) {
109
+ return typeof value === "string" && /^0x[0-9a-fA-F]*$/.test(value);
110
+ }
111
+ function validateFieldValue(type, value) {
112
+ const normalizedType = type.trim().toLowerCase();
113
+ const bytesNMatch = normalizedType.match(/^bytes([1-9]|[12]\d|3[0-2])$/);
114
+ if (/^uint\d*$/.test(normalizedType)) {
115
+ return isNumericValue(value, false);
116
+ }
117
+ if (/^int\d*$/.test(normalizedType)) {
118
+ return isNumericValue(value, true);
119
+ }
120
+ if (normalizedType === "string") {
121
+ return typeof value === "string";
122
+ }
123
+ if (normalizedType === "string[]") {
124
+ return Array.isArray(value) && value.every((entry) => typeof entry === "string");
125
+ }
126
+ if (normalizedType === "bool") {
127
+ return typeof value === "boolean";
128
+ }
129
+ if (normalizedType === "address") {
130
+ return typeof value === "string" && isAddress(value);
131
+ }
132
+ if (normalizedType === "bytes") {
133
+ return isHex(value) && (value.length - 2) % 2 === 0;
134
+ }
135
+ if (bytesNMatch) {
136
+ const expectedBytes = Number(bytesNMatch[1]);
137
+ return isHex(value) && value.length === 2 + expectedBytes * 2;
138
+ }
139
+ return true;
140
+ }
141
+ function validateAttestationData(schema, data) {
142
+ if (!data || typeof data !== "object") {
143
+ return [{
144
+ schemaFieldName: "data",
145
+ expectedType: "object",
146
+ providedType: getActualType(data),
147
+ providedValue: data
148
+ }];
149
+ }
150
+ const fields = normalizeSchema(schema);
151
+ const errors = [];
152
+ for (const field of fields) {
153
+ const value = data[field.name];
154
+ const isValid = validateFieldValue(field.type, value);
155
+ if (isValid) {
156
+ continue;
157
+ }
158
+ errors.push({
159
+ schemaFieldName: field.name,
160
+ expectedType: field.type,
161
+ providedType: getActualType(value),
162
+ providedValue: value
163
+ });
164
+ }
165
+ return errors;
166
+ }
67
167
  function decodeAttestationData(schema, encodedData) {
68
168
  if (typeof encodedData !== "string" || !encodedData.startsWith("0x")) {
69
169
  throw new OmaTrustError("INVALID_INPUT", "encodedData must be a hex string");
@@ -84,22 +184,11 @@ function decodeAttestationData(schema, encodedData) {
84
184
  return result;
85
185
  }
86
186
  function extractExpirationTime(data) {
87
- const keys = ["expirationTime", "expiration", "validUntil", "expiresAt", "expires"];
88
- for (const key of keys) {
89
- const value = data[key];
90
- if (value === void 0 || value === null) {
91
- continue;
92
- }
93
- if (typeof value === "bigint") {
94
- return value;
95
- }
96
- if (typeof value === "number") {
97
- return value;
98
- }
99
- if (typeof value === "string" && /^\d+$/.test(value)) {
100
- return BigInt(value);
101
- }
102
- }
187
+ const value = data["expiresAt"];
188
+ if (value === void 0 || value === null) return void 0;
189
+ if (typeof value === "bigint") return value;
190
+ if (typeof value === "number") return value;
191
+ if (typeof value === "string" && /^\d+$/.test(value)) return BigInt(value);
103
192
  return void 0;
104
193
  }
105
194
 
@@ -412,6 +501,34 @@ async function submitAttestation(params) {
412
501
  throw new OmaTrustError("NETWORK_ERROR", "Failed to submit attestation", { err });
413
502
  }
414
503
  }
504
+ async function revokeAttestation(params) {
505
+ if (!params || typeof params !== "object") {
506
+ throw new OmaTrustError("INVALID_INPUT", "params must be provided");
507
+ }
508
+ if (!params.signer) {
509
+ throw new OmaTrustError("INVALID_INPUT", "signer is required");
510
+ }
511
+ const eas = new EAS(params.easContractAddress);
512
+ eas.connect(params.signer);
513
+ try {
514
+ const tx = await eas.revoke({
515
+ schema: params.schemaUid,
516
+ data: {
517
+ uid: params.uid,
518
+ value: toBigIntOrDefault(params.value, 0n)
519
+ }
520
+ });
521
+ await tx.wait();
522
+ const txHash = getEasTransactionHash(tx) ?? ZERO_UID;
523
+ const receipt = getEasTransactionReceipt(tx);
524
+ return {
525
+ txHash,
526
+ receipt
527
+ };
528
+ } catch (err) {
529
+ throw new OmaTrustError("NETWORK_ERROR", "Failed to revoke attestation", { err });
530
+ }
531
+ }
415
532
  function buildDelegatedTypedData(params) {
416
533
  return {
417
534
  domain: {
@@ -559,7 +676,14 @@ async function submitDelegatedAttestation(params) {
559
676
  var EAS_EVENT_ABI = [
560
677
  "event Attested(address indexed recipient, address indexed attester, bytes32 uid, bytes32 indexed schemaUID)"
561
678
  ];
562
- function parseAttestation(attestation, schema) {
679
+ function parseEventTxHash(event) {
680
+ const txHash = event.transactionHash;
681
+ if (typeof txHash !== "string") {
682
+ return void 0;
683
+ }
684
+ return /^0x[0-9a-fA-F]{64}$/.test(txHash) ? txHash : void 0;
685
+ }
686
+ function parseAttestation(attestation, schema, txHash) {
563
687
  const rawData = attestation.data ?? "0x";
564
688
  const decoded = schema ? decodeAttestationData(schema, rawData) : {};
565
689
  const toBigIntSafe = (value) => {
@@ -579,6 +703,7 @@ function parseAttestation(attestation, schema) {
579
703
  schema: attestation.schema,
580
704
  attester: attestation.attester,
581
705
  recipient: attestation.recipient,
706
+ txHash,
582
707
  revocable: Boolean(attestation.revocable),
583
708
  revocationTime: toBigIntSafe(attestation.revocationTime),
584
709
  expirationTime: toBigIntSafe(attestation.expirationTime),
@@ -604,21 +729,18 @@ async function getAttestation(params) {
604
729
  throw new OmaTrustError("NETWORK_ERROR", "Failed to read attestation", { err });
605
730
  }
606
731
  }
607
- async function getAttestationsForDid(params) {
608
- const provider = params.provider;
609
- const contract = new Contract(params.easContractAddress, EAS_EVENT_ABI, provider);
610
- const toBlock = params.toBlock ?? await provider.getBlockNumber();
611
- const fromBlock = params.fromBlock ?? Math.max(0, toBlock - 5e4);
612
- const filter = contract.filters.Attested(didToAddress(params.did));
732
+ async function queryAttestationEvents(easContractAddress, provider, fromBlock, toBlock, options) {
733
+ const contract = new Contract(easContractAddress, EAS_EVENT_ABI, provider);
734
+ const filter = contract.filters.Attested(options?.recipient ?? null, options?.attester ?? null);
613
735
  let events;
614
736
  try {
615
737
  events = await contract.queryFilter(filter, fromBlock, toBlock);
616
738
  } catch (err) {
617
739
  throw new OmaTrustError("NETWORK_ERROR", "Failed to query attestation events", { err });
618
740
  }
619
- const eas = new EAS(params.easContractAddress);
741
+ const eas = new EAS(easContractAddress);
620
742
  eas.connect(provider);
621
- const schemaFilter = params.schemas?.map((schema) => schema.toLowerCase());
743
+ const schemaFilter = options?.schemas?.map((s) => s.toLowerCase());
622
744
  const results = [];
623
745
  for (const event of events) {
624
746
  if (!("args" in event && Array.isArray(event.args))) {
@@ -637,11 +759,39 @@ async function getAttestationsForDid(params) {
637
759
  if (!attestation || !attestation.uid) {
638
760
  continue;
639
761
  }
640
- results.push(parseAttestation(attestation));
762
+ results.push(parseAttestation(attestation, void 0, parseEventTxHash(event)));
641
763
  }
642
764
  results.sort((a, b) => Number(b.time - a.time));
643
765
  return results;
644
766
  }
767
+ async function getAttestationsForDid(params) {
768
+ const provider = params.provider;
769
+ const toBlock = params.toBlock ?? await provider.getBlockNumber();
770
+ const fromBlock = params.fromBlock ?? Math.max(0, toBlock - 5e4);
771
+ return queryAttestationEvents(
772
+ params.easContractAddress,
773
+ provider,
774
+ fromBlock,
775
+ toBlock,
776
+ { recipient: didToAddress(params.did), schemas: params.schemas }
777
+ );
778
+ }
779
+ async function getAttestationsByAttester(params) {
780
+ const provider = params.provider;
781
+ const toBlock = params.toBlock ?? await provider.getBlockNumber();
782
+ const fromBlock = params.fromBlock ?? Math.max(0, toBlock - 5e4);
783
+ if (params.limit !== void 0 && params.limit <= 0) {
784
+ return [];
785
+ }
786
+ const results = await queryAttestationEvents(
787
+ params.easContractAddress,
788
+ provider,
789
+ fromBlock,
790
+ toBlock,
791
+ { attester: params.attester, schemas: params.schemas }
792
+ );
793
+ return params.limit !== void 0 ? results.slice(0, params.limit) : results;
794
+ }
645
795
  async function listAttestations(params) {
646
796
  const limit = params.limit ?? 20;
647
797
  if (limit <= 0) {
@@ -652,34 +802,15 @@ async function listAttestations(params) {
652
802
  }
653
803
  async function getLatestAttestations(params) {
654
804
  const provider = params.provider;
655
- const contract = new Contract(params.easContractAddress, EAS_EVENT_ABI, provider);
656
- const currentBlock = await provider.getBlockNumber();
657
- const fromBlock = params.fromBlock ?? Math.max(0, currentBlock - 5e4);
658
- const events = await contract.queryFilter(contract.filters.Attested(), fromBlock, currentBlock);
659
- const eas = new EAS(params.easContractAddress);
660
- eas.connect(provider);
661
- const schemaFilter = params.schemas?.map((schema) => schema.toLowerCase());
662
- const results = [];
663
- for (const event of events) {
664
- if (!("args" in event && Array.isArray(event.args))) {
665
- continue;
666
- }
667
- const args = event.args;
668
- const uid = args?.[2];
669
- const schemaUid = args?.[3];
670
- if (!uid || !schemaUid) {
671
- continue;
672
- }
673
- if (schemaFilter && !schemaFilter.includes(schemaUid.toLowerCase())) {
674
- continue;
675
- }
676
- const attestation = await eas.getAttestation(uid);
677
- if (!attestation || !attestation.uid) {
678
- continue;
679
- }
680
- results.push(parseAttestation(attestation));
681
- }
682
- results.sort((a, b) => Number(b.time - a.time));
805
+ const toBlock = await provider.getBlockNumber();
806
+ const fromBlock = params.fromBlock ?? Math.max(0, toBlock - 5e4);
807
+ const results = await queryAttestationEvents(
808
+ params.easContractAddress,
809
+ provider,
810
+ fromBlock,
811
+ toBlock,
812
+ { schemas: params.schemas }
813
+ );
683
814
  return results.slice(0, params.limit ?? 20);
684
815
  }
685
816
  function deduplicateReviews(attestations) {
@@ -1490,6 +1621,6 @@ async function verifyDnsTxtControllerDid(domain, expectedControllerDid) {
1490
1621
  return { valid: false, reason: "No TXT record matched expected controller DID" };
1491
1622
  }
1492
1623
 
1493
- export { buildDelegatedAttestationTypedData, buildDelegatedTypedDataFromEncoded, buildDnsTxtRecord, buildEip712Domain, calculateAverageUserReviewRating, calculateTransferAmount, calculateTransferAmountFromAddresses, callControllerWitness, constructSeed, createEvidencePointerProof, createPopEip712Proof, createPopJwsProof, createTxEncodedValueProof, createTxInteractionProof, createX402OfferProof, createX402ReceiptProof, decodeAttestationData, deduplicateReviews, encodeAttestationData, extractAddressesFromDidDocument, extractExpirationTime, fetchDidDocument, formatSchemaUid, formatTransferAmount, getAttestation, getAttestationsForDid, getChainConstants, getExplorerAddressUrl, getExplorerTxUrl, getLatestAttestations, getMajorVersion, getOmaTrustProofEip712Types, getSchemaDetails, getSupportedChainIds, hashSeed, isChainSupported, listAttestations, normalizeSchema, parseDnsTxtRecord, prepareDelegatedAttestation, schemaToString, splitSignature, submitAttestation, submitDelegatedAttestation, verifyAttestation, verifyDidDocumentControllerDid, verifyDnsTxtControllerDid, verifyEip712Signature, verifyProof, verifySchemaExists };
1624
+ export { buildDelegatedAttestationTypedData, buildDelegatedTypedDataFromEncoded, buildDnsTxtRecord, buildEip712Domain, calculateAverageUserReviewRating, calculateTransferAmount, calculateTransferAmountFromAddresses, callControllerWitness, constructSeed, createEvidencePointerProof, createPopEip712Proof, createPopJwsProof, createTxEncodedValueProof, createTxInteractionProof, createX402OfferProof, createX402ReceiptProof, decodeAttestationData, deduplicateReviews, encodeAttestationData, extractAddressesFromDidDocument, extractExpirationTime, fetchDidDocument, formatSchemaUid, formatTransferAmount, getAttestation, getAttestationsByAttester, getAttestationsForDid, getChainConstants, getExplorerAddressUrl, getExplorerTxUrl, getLatestAttestations, getMajorVersion, getOmaTrustProofEip712Types, getSchemaDetails, getSupportedChainIds, hashSeed, isChainSupported, listAttestations, normalizeSchema, parseDnsTxtRecord, prepareDelegatedAttestation, revokeAttestation, schemaToString, splitSignature, submitAttestation, submitDelegatedAttestation, validateAttestationData, verifyAttestation, verifyDidDocumentControllerDid, verifyDnsTxtControllerDid, verifyEip712Signature, verifyProof, verifySchemaExists };
1494
1625
  //# sourceMappingURL=index.js.map
1495
1626
  //# sourceMappingURL=index.js.map