@oma3/omatrust 0.1.0-alpha.3 → 0.1.0-alpha.5

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.
@@ -12,6 +12,7 @@ type AttestationQueryResult = {
12
12
  schema: Hex;
13
13
  attester: Hex;
14
14
  recipient: Hex;
15
+ txHash?: Hex;
15
16
  revocable: boolean;
16
17
  revocationTime: bigint;
17
18
  expirationTime: bigint;
@@ -12,6 +12,7 @@ type AttestationQueryResult = {
12
12
  schema: Hex;
13
13
  attester: Hex;
14
14
  recipient: Hex;
15
+ txHash?: Hex;
15
16
  revocable: boolean;
16
17
  revocationTime: bigint;
17
18
  expirationTime: bigint;
@@ -1,4 +1,4 @@
1
- import { D as Did, 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, 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-Dx9kvqtn.js';
2
2
 
3
3
  declare function verifyDnsTxtControllerDid(domain: string, expectedControllerDid: Did): Promise<{
4
4
  valid: boolean;
@@ -1,4 +1,4 @@
1
- import { D as Did, 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, 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-Dx9kvqtn.cjs';
2
2
 
3
3
  declare function verifyDnsTxtControllerDid(domain: string, expectedControllerDid: Did): Promise<{
4
4
  valid: boolean;
package/dist/index.cjs CHANGED
@@ -533,6 +533,53 @@ function resolveRecipientAddress(data) {
533
533
  return ethers.ZeroAddress;
534
534
  }
535
535
 
536
+ // src/reputation/eas-adapter.ts
537
+ function isRecord(value) {
538
+ return Boolean(value) && typeof value === "object";
539
+ }
540
+ function isHex32(value) {
541
+ return typeof value === "string" && /^0x[0-9a-fA-F]{64}$/.test(value);
542
+ }
543
+ function getEasTransactionReceipt(tx) {
544
+ if (!isRecord(tx)) {
545
+ return void 0;
546
+ }
547
+ const candidates = [tx.receipt, tx.tx, tx.transaction];
548
+ for (const candidate of candidates) {
549
+ if (isRecord(candidate)) {
550
+ return candidate;
551
+ }
552
+ }
553
+ return void 0;
554
+ }
555
+ function getEasTransactionHash(tx) {
556
+ const receipt = getEasTransactionReceipt(tx);
557
+ if (receipt) {
558
+ const receiptHash = receipt.hash;
559
+ if (isHex32(receiptHash)) {
560
+ return receiptHash;
561
+ }
562
+ const transactionHash = receipt.transactionHash;
563
+ if (isHex32(transactionHash)) {
564
+ return transactionHash;
565
+ }
566
+ }
567
+ if (isRecord(tx) && isHex32(tx.hash)) {
568
+ return tx.hash;
569
+ }
570
+ return void 0;
571
+ }
572
+ function isEasSchemaNotFoundError(err) {
573
+ if (!isRecord(err)) {
574
+ return false;
575
+ }
576
+ const message = err.message;
577
+ if (typeof message !== "string" || message.length === 0) {
578
+ return false;
579
+ }
580
+ return /schema not found/i.test(message);
581
+ }
582
+
536
583
  // src/reputation/submit.ts
537
584
  async function submitAttestation(params) {
538
585
  if (!params || typeof params !== "object") {
@@ -563,12 +610,12 @@ async function submitAttestation(params) {
563
610
  }
564
611
  });
565
612
  const uid = await tx.wait();
566
- const txAny = tx;
567
- const txHash = txAny.tx?.hash ?? txAny.hash ?? txAny.transaction?.hash ?? ZERO_UID;
613
+ const txHash = getEasTransactionHash(tx) ?? ZERO_UID;
614
+ const receipt = getEasTransactionReceipt(tx);
568
615
  return {
569
616
  uid,
570
617
  txHash,
571
- receipt: txAny.tx
618
+ receipt
572
619
  };
573
620
  } catch (err) {
574
621
  throw new OmaTrustError("NETWORK_ERROR", "Failed to submit attestation", { err });
@@ -721,7 +768,14 @@ async function submitDelegatedAttestation(params) {
721
768
  var EAS_EVENT_ABI = [
722
769
  "event Attested(address indexed recipient, address indexed attester, bytes32 uid, bytes32 indexed schemaUID)"
723
770
  ];
724
- function parseAttestation(attestation, schema) {
771
+ function parseEventTxHash(event) {
772
+ const txHash = event.transactionHash;
773
+ if (typeof txHash !== "string") {
774
+ return void 0;
775
+ }
776
+ return /^0x[0-9a-fA-F]{64}$/.test(txHash) ? txHash : void 0;
777
+ }
778
+ function parseAttestation(attestation, schema, txHash) {
725
779
  const rawData = attestation.data ?? "0x";
726
780
  const decoded = schema ? decodeAttestationData(schema, rawData) : {};
727
781
  const toBigIntSafe = (value) => {
@@ -741,6 +795,7 @@ function parseAttestation(attestation, schema) {
741
795
  schema: attestation.schema,
742
796
  attester: attestation.attester,
743
797
  recipient: attestation.recipient,
798
+ txHash,
744
799
  revocable: Boolean(attestation.revocable),
745
800
  revocationTime: toBigIntSafe(attestation.revocationTime),
746
801
  expirationTime: toBigIntSafe(attestation.expirationTime),
@@ -799,7 +854,7 @@ async function getAttestationsForDid(params) {
799
854
  if (!attestation || !attestation.uid) {
800
855
  continue;
801
856
  }
802
- results.push(parseAttestation(attestation));
857
+ results.push(parseAttestation(attestation, void 0, parseEventTxHash(event)));
803
858
  }
804
859
  results.sort((a, b) => Number(b.time - a.time));
805
860
  return results;
@@ -839,7 +894,7 @@ async function getLatestAttestations(params) {
839
894
  if (!attestation || !attestation.uid) {
840
895
  continue;
841
896
  }
842
- results.push(parseAttestation(attestation));
897
+ results.push(parseAttestation(attestation, void 0, parseEventTxHash(event)));
843
898
  }
844
899
  results.sort((a, b) => Number(b.time - a.time));
845
900
  return results.slice(0, params.limit ?? 20);
@@ -1444,6 +1499,9 @@ async function getSchemaDetails(schemaRegistry, schemaUid) {
1444
1499
  revocable: Boolean(details.revocable)
1445
1500
  };
1446
1501
  } catch (err) {
1502
+ if (isEasSchemaNotFoundError(err)) {
1503
+ throw new OmaTrustError("SCHEMA_NOT_FOUND", "Schema was not found", { schemaUid });
1504
+ }
1447
1505
  if (err instanceof OmaTrustError) {
1448
1506
  throw err;
1449
1507
  }