@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,5 +1,5 @@
1
- import { D as Did } from '../eip712-C4a-JGko.cjs';
2
- export { A as AttestationQueryResult, B as BuildDelegatedTypedDataFromEncodedParams, C as CallControllerWitnessParams, a as CallControllerWitnessResult, b as ChainConstants, c as CreatePopEip712ProofParams, d as CreatePopJwsProofParams, 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';
1
+ import { D as Did } from '../eip712-CevLiOcD.cjs';
2
+ 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, 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';
3
3
 
4
4
  declare function verifyDnsTxtControllerDid(domain: string, expectedControllerDid: Did): Promise<{
5
5
  valid: boolean;
@@ -1,5 +1,5 @@
1
- import { D as Did } from '../eip712-C4a-JGko.js';
2
- export { A as AttestationQueryResult, B as BuildDelegatedTypedDataFromEncodedParams, C as CallControllerWitnessParams, a as CallControllerWitnessResult, b as ChainConstants, c as CreatePopEip712ProofParams, d as CreatePopJwsProofParams, 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';
1
+ import { D as Did } from '../eip712-CevLiOcD.js';
2
+ 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, 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';
3
3
 
4
4
  declare function verifyDnsTxtControllerDid(domain: string, expectedControllerDid: Did): Promise<{
5
5
  valid: boolean;
@@ -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
 
5
5
  // src/reputation/submit.ts
@@ -51,6 +51,13 @@ function encodeAttestationData(schema, data) {
51
51
  if (!data || typeof data !== "object") {
52
52
  throw new OmaTrustError("INVALID_INPUT", "data must be an object");
53
53
  }
54
+ const validationErrors = validateAttestationData(schema, data);
55
+ if (validationErrors.length > 0) {
56
+ const summary = validationErrors.map((error) => `Field "${error.schemaFieldName}" (${error.expectedType}) got ${error.providedType}`).join("; ");
57
+ throw new OmaTrustError("INVALID_INPUT", `Attestation data validation failed: ${summary}`, {
58
+ errors: validationErrors
59
+ });
60
+ }
54
61
  const fields = normalizeSchema(schema);
55
62
  const schemaString = schemaToString(fields);
56
63
  const encoder = new SchemaEncoder(schemaString);
@@ -63,6 +70,99 @@ function encodeAttestationData(schema, data) {
63
70
  );
64
71
  return encoded;
65
72
  }
73
+ function getActualType(value) {
74
+ if (value === null) {
75
+ return "null";
76
+ }
77
+ if (value === void 0) {
78
+ return "undefined";
79
+ }
80
+ if (Array.isArray(value)) {
81
+ return "array";
82
+ }
83
+ if (typeof value === "number") {
84
+ return Number.isFinite(value) ? "number" : "non-finite-number";
85
+ }
86
+ return typeof value;
87
+ }
88
+ function isNumericValue(value, allowNegative) {
89
+ if (typeof value === "bigint") {
90
+ return allowNegative || value >= 0n;
91
+ }
92
+ if (typeof value === "number") {
93
+ if (!Number.isFinite(value) || !Number.isInteger(value)) {
94
+ return false;
95
+ }
96
+ return allowNegative || value >= 0;
97
+ }
98
+ if (typeof value === "string") {
99
+ if (value.length === 0) {
100
+ return false;
101
+ }
102
+ const pattern = allowNegative ? /^-?\d+$/ : /^\d+$/;
103
+ return pattern.test(value);
104
+ }
105
+ return false;
106
+ }
107
+ function isHex(value) {
108
+ return typeof value === "string" && /^0x[0-9a-fA-F]*$/.test(value);
109
+ }
110
+ function validateFieldValue(type, value) {
111
+ const normalizedType = type.trim().toLowerCase();
112
+ const bytesNMatch = normalizedType.match(/^bytes([1-9]|[12]\d|3[0-2])$/);
113
+ if (/^uint\d*$/.test(normalizedType)) {
114
+ return isNumericValue(value, false);
115
+ }
116
+ if (/^int\d*$/.test(normalizedType)) {
117
+ return isNumericValue(value, true);
118
+ }
119
+ if (normalizedType === "string") {
120
+ return typeof value === "string";
121
+ }
122
+ if (normalizedType === "string[]") {
123
+ return Array.isArray(value) && value.every((entry) => typeof entry === "string");
124
+ }
125
+ if (normalizedType === "bool") {
126
+ return typeof value === "boolean";
127
+ }
128
+ if (normalizedType === "address") {
129
+ return typeof value === "string" && isAddress(value);
130
+ }
131
+ if (normalizedType === "bytes") {
132
+ return isHex(value) && (value.length - 2) % 2 === 0;
133
+ }
134
+ if (bytesNMatch) {
135
+ const expectedBytes = Number(bytesNMatch[1]);
136
+ return isHex(value) && value.length === 2 + expectedBytes * 2;
137
+ }
138
+ return true;
139
+ }
140
+ function validateAttestationData(schema, data) {
141
+ if (!data || typeof data !== "object") {
142
+ return [{
143
+ schemaFieldName: "data",
144
+ expectedType: "object",
145
+ providedType: getActualType(data),
146
+ providedValue: data
147
+ }];
148
+ }
149
+ const fields = normalizeSchema(schema);
150
+ const errors = [];
151
+ for (const field of fields) {
152
+ const value = data[field.name];
153
+ const isValid = validateFieldValue(field.type, value);
154
+ if (isValid) {
155
+ continue;
156
+ }
157
+ errors.push({
158
+ schemaFieldName: field.name,
159
+ expectedType: field.type,
160
+ providedType: getActualType(value),
161
+ providedValue: value
162
+ });
163
+ }
164
+ return errors;
165
+ }
66
166
  function decodeAttestationData(schema, encodedData) {
67
167
  if (typeof encodedData !== "string" || !encodedData.startsWith("0x")) {
68
168
  throw new OmaTrustError("INVALID_INPUT", "encodedData must be a hex string");
@@ -83,22 +183,11 @@ function decodeAttestationData(schema, encodedData) {
83
183
  return result;
84
184
  }
85
185
  function extractExpirationTime(data) {
86
- const keys = ["expirationTime", "expiration", "validUntil", "expiresAt", "expires"];
87
- for (const key of keys) {
88
- const value = data[key];
89
- if (value === void 0 || value === null) {
90
- continue;
91
- }
92
- if (typeof value === "bigint") {
93
- return value;
94
- }
95
- if (typeof value === "number") {
96
- return value;
97
- }
98
- if (typeof value === "string" && /^\d+$/.test(value)) {
99
- return BigInt(value);
100
- }
101
- }
186
+ const value = data["expiresAt"];
187
+ if (value === void 0 || value === null) return void 0;
188
+ if (typeof value === "bigint") return value;
189
+ if (typeof value === "number") return value;
190
+ if (typeof value === "string" && /^\d+$/.test(value)) return BigInt(value);
102
191
  return void 0;
103
192
  }
104
193
 
@@ -411,6 +500,34 @@ async function submitAttestation(params) {
411
500
  throw new OmaTrustError("NETWORK_ERROR", "Failed to submit attestation", { err });
412
501
  }
413
502
  }
503
+ async function revokeAttestation(params) {
504
+ if (!params || typeof params !== "object") {
505
+ throw new OmaTrustError("INVALID_INPUT", "params must be provided");
506
+ }
507
+ if (!params.signer) {
508
+ throw new OmaTrustError("INVALID_INPUT", "signer is required");
509
+ }
510
+ const eas = new EAS(params.easContractAddress);
511
+ eas.connect(params.signer);
512
+ try {
513
+ const tx = await eas.revoke({
514
+ schema: params.schemaUid,
515
+ data: {
516
+ uid: params.uid,
517
+ value: toBigIntOrDefault(params.value, 0n)
518
+ }
519
+ });
520
+ await tx.wait();
521
+ const txHash = getEasTransactionHash(tx) ?? ZERO_UID;
522
+ const receipt = getEasTransactionReceipt(tx);
523
+ return {
524
+ txHash,
525
+ receipt
526
+ };
527
+ } catch (err) {
528
+ throw new OmaTrustError("NETWORK_ERROR", "Failed to revoke attestation", { err });
529
+ }
530
+ }
414
531
  function buildDelegatedTypedData(params) {
415
532
  return {
416
533
  domain: {
@@ -558,7 +675,14 @@ async function submitDelegatedAttestation(params) {
558
675
  var EAS_EVENT_ABI = [
559
676
  "event Attested(address indexed recipient, address indexed attester, bytes32 uid, bytes32 indexed schemaUID)"
560
677
  ];
561
- function parseAttestation(attestation, schema) {
678
+ function parseEventTxHash(event) {
679
+ const txHash = event.transactionHash;
680
+ if (typeof txHash !== "string") {
681
+ return void 0;
682
+ }
683
+ return /^0x[0-9a-fA-F]{64}$/.test(txHash) ? txHash : void 0;
684
+ }
685
+ function parseAttestation(attestation, schema, txHash) {
562
686
  const rawData = attestation.data ?? "0x";
563
687
  const decoded = schema ? decodeAttestationData(schema, rawData) : {};
564
688
  const toBigIntSafe = (value) => {
@@ -578,6 +702,7 @@ function parseAttestation(attestation, schema) {
578
702
  schema: attestation.schema,
579
703
  attester: attestation.attester,
580
704
  recipient: attestation.recipient,
705
+ txHash,
581
706
  revocable: Boolean(attestation.revocable),
582
707
  revocationTime: toBigIntSafe(attestation.revocationTime),
583
708
  expirationTime: toBigIntSafe(attestation.expirationTime),
@@ -603,21 +728,18 @@ async function getAttestation(params) {
603
728
  throw new OmaTrustError("NETWORK_ERROR", "Failed to read attestation", { err });
604
729
  }
605
730
  }
606
- async function getAttestationsForDid(params) {
607
- const provider = params.provider;
608
- const contract = new Contract(params.easContractAddress, EAS_EVENT_ABI, provider);
609
- const toBlock = params.toBlock ?? await provider.getBlockNumber();
610
- const fromBlock = params.fromBlock ?? Math.max(0, toBlock - 5e4);
611
- const filter = contract.filters.Attested(didToAddress(params.did));
731
+ async function queryAttestationEvents(easContractAddress, provider, fromBlock, toBlock, options) {
732
+ const contract = new Contract(easContractAddress, EAS_EVENT_ABI, provider);
733
+ const filter = contract.filters.Attested(options?.recipient ?? null, options?.attester ?? null);
612
734
  let events;
613
735
  try {
614
736
  events = await contract.queryFilter(filter, fromBlock, toBlock);
615
737
  } catch (err) {
616
738
  throw new OmaTrustError("NETWORK_ERROR", "Failed to query attestation events", { err });
617
739
  }
618
- const eas = new EAS(params.easContractAddress);
740
+ const eas = new EAS(easContractAddress);
619
741
  eas.connect(provider);
620
- const schemaFilter = params.schemas?.map((schema) => schema.toLowerCase());
742
+ const schemaFilter = options?.schemas?.map((s) => s.toLowerCase());
621
743
  const results = [];
622
744
  for (const event of events) {
623
745
  if (!("args" in event && Array.isArray(event.args))) {
@@ -636,11 +758,39 @@ async function getAttestationsForDid(params) {
636
758
  if (!attestation || !attestation.uid) {
637
759
  continue;
638
760
  }
639
- results.push(parseAttestation(attestation));
761
+ results.push(parseAttestation(attestation, void 0, parseEventTxHash(event)));
640
762
  }
641
763
  results.sort((a, b) => Number(b.time - a.time));
642
764
  return results;
643
765
  }
766
+ async function getAttestationsForDid(params) {
767
+ const provider = params.provider;
768
+ const toBlock = params.toBlock ?? await provider.getBlockNumber();
769
+ const fromBlock = params.fromBlock ?? Math.max(0, toBlock - 5e4);
770
+ return queryAttestationEvents(
771
+ params.easContractAddress,
772
+ provider,
773
+ fromBlock,
774
+ toBlock,
775
+ { recipient: didToAddress(params.did), schemas: params.schemas }
776
+ );
777
+ }
778
+ async function getAttestationsByAttester(params) {
779
+ const provider = params.provider;
780
+ const toBlock = params.toBlock ?? await provider.getBlockNumber();
781
+ const fromBlock = params.fromBlock ?? Math.max(0, toBlock - 5e4);
782
+ if (params.limit !== void 0 && params.limit <= 0) {
783
+ return [];
784
+ }
785
+ const results = await queryAttestationEvents(
786
+ params.easContractAddress,
787
+ provider,
788
+ fromBlock,
789
+ toBlock,
790
+ { attester: params.attester, schemas: params.schemas }
791
+ );
792
+ return params.limit !== void 0 ? results.slice(0, params.limit) : results;
793
+ }
644
794
  async function listAttestations(params) {
645
795
  const limit = params.limit ?? 20;
646
796
  if (limit <= 0) {
@@ -651,34 +801,15 @@ async function listAttestations(params) {
651
801
  }
652
802
  async function getLatestAttestations(params) {
653
803
  const provider = params.provider;
654
- const contract = new Contract(params.easContractAddress, EAS_EVENT_ABI, provider);
655
- const currentBlock = await provider.getBlockNumber();
656
- const fromBlock = params.fromBlock ?? Math.max(0, currentBlock - 5e4);
657
- const events = await contract.queryFilter(contract.filters.Attested(), fromBlock, currentBlock);
658
- const eas = new EAS(params.easContractAddress);
659
- eas.connect(provider);
660
- const schemaFilter = params.schemas?.map((schema) => schema.toLowerCase());
661
- const results = [];
662
- for (const event of events) {
663
- if (!("args" in event && Array.isArray(event.args))) {
664
- continue;
665
- }
666
- const args = event.args;
667
- const uid = args?.[2];
668
- const schemaUid = args?.[3];
669
- if (!uid || !schemaUid) {
670
- continue;
671
- }
672
- if (schemaFilter && !schemaFilter.includes(schemaUid.toLowerCase())) {
673
- continue;
674
- }
675
- const attestation = await eas.getAttestation(uid);
676
- if (!attestation || !attestation.uid) {
677
- continue;
678
- }
679
- results.push(parseAttestation(attestation));
680
- }
681
- results.sort((a, b) => Number(b.time - a.time));
804
+ const toBlock = await provider.getBlockNumber();
805
+ const fromBlock = params.fromBlock ?? Math.max(0, toBlock - 5e4);
806
+ const results = await queryAttestationEvents(
807
+ params.easContractAddress,
808
+ provider,
809
+ fromBlock,
810
+ toBlock,
811
+ { schemas: params.schemas }
812
+ );
682
813
  return results.slice(0, params.limit ?? 20);
683
814
  }
684
815
  function deduplicateReviews(attestations) {
@@ -1480,6 +1611,6 @@ async function verifyDnsTxtControllerDid(domain, expectedControllerDid) {
1480
1611
  );
1481
1612
  }
1482
1613
 
1483
- 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 };
1614
+ 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 };
1484
1615
  //# sourceMappingURL=index.browser.js.map
1485
1616
  //# sourceMappingURL=index.browser.js.map