@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.
- package/dist/{eip712-C4a-JGko.d.cts → eip712-Dx9kvqtn.d.cts} +1 -0
- package/dist/{eip712-C4a-JGko.d.ts → eip712-Dx9kvqtn.d.ts} +1 -0
- package/dist/{index-BDeQNCi_.d.ts → index-BUWbuvqZ.d.ts} +1 -1
- package/dist/{index-DP6IIpIh.d.cts → index-ByNU5VpJ.d.cts} +1 -1
- package/dist/index.cjs +64 -6
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +64 -6
- package/dist/index.js.map +1 -1
- package/dist/reputation/index.browser.cjs +64 -6
- package/dist/reputation/index.browser.cjs.map +1 -1
- package/dist/reputation/index.browser.d.cts +2 -2
- package/dist/reputation/index.browser.d.ts +2 -2
- package/dist/reputation/index.browser.js +64 -6
- package/dist/reputation/index.browser.js.map +1 -1
- package/dist/reputation/index.cjs +64 -6
- package/dist/reputation/index.cjs.map +1 -1
- package/dist/reputation/index.d.cts +2 -2
- package/dist/reputation/index.d.ts +2 -2
- package/dist/reputation/index.js +64 -6
- package/dist/reputation/index.js.map +1 -1
- package/package.json +1 -1
|
@@ -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-
|
|
2
|
-
export { v as verifyDnsTxtControllerDid } from '../index-
|
|
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-Dx9kvqtn.js';
|
|
2
|
+
export { v as verifyDnsTxtControllerDid } from '../index-BUWbuvqZ.js';
|
package/dist/reputation/index.js
CHANGED
|
@@ -324,6 +324,53 @@ function resolveRecipientAddress(data) {
|
|
|
324
324
|
return ZeroAddress;
|
|
325
325
|
}
|
|
326
326
|
|
|
327
|
+
// src/reputation/eas-adapter.ts
|
|
328
|
+
function isRecord(value) {
|
|
329
|
+
return Boolean(value) && typeof value === "object";
|
|
330
|
+
}
|
|
331
|
+
function isHex32(value) {
|
|
332
|
+
return typeof value === "string" && /^0x[0-9a-fA-F]{64}$/.test(value);
|
|
333
|
+
}
|
|
334
|
+
function getEasTransactionReceipt(tx) {
|
|
335
|
+
if (!isRecord(tx)) {
|
|
336
|
+
return void 0;
|
|
337
|
+
}
|
|
338
|
+
const candidates = [tx.receipt, tx.tx, tx.transaction];
|
|
339
|
+
for (const candidate of candidates) {
|
|
340
|
+
if (isRecord(candidate)) {
|
|
341
|
+
return candidate;
|
|
342
|
+
}
|
|
343
|
+
}
|
|
344
|
+
return void 0;
|
|
345
|
+
}
|
|
346
|
+
function getEasTransactionHash(tx) {
|
|
347
|
+
const receipt = getEasTransactionReceipt(tx);
|
|
348
|
+
if (receipt) {
|
|
349
|
+
const receiptHash = receipt.hash;
|
|
350
|
+
if (isHex32(receiptHash)) {
|
|
351
|
+
return receiptHash;
|
|
352
|
+
}
|
|
353
|
+
const transactionHash = receipt.transactionHash;
|
|
354
|
+
if (isHex32(transactionHash)) {
|
|
355
|
+
return transactionHash;
|
|
356
|
+
}
|
|
357
|
+
}
|
|
358
|
+
if (isRecord(tx) && isHex32(tx.hash)) {
|
|
359
|
+
return tx.hash;
|
|
360
|
+
}
|
|
361
|
+
return void 0;
|
|
362
|
+
}
|
|
363
|
+
function isEasSchemaNotFoundError(err) {
|
|
364
|
+
if (!isRecord(err)) {
|
|
365
|
+
return false;
|
|
366
|
+
}
|
|
367
|
+
const message = err.message;
|
|
368
|
+
if (typeof message !== "string" || message.length === 0) {
|
|
369
|
+
return false;
|
|
370
|
+
}
|
|
371
|
+
return /schema not found/i.test(message);
|
|
372
|
+
}
|
|
373
|
+
|
|
327
374
|
// src/reputation/submit.ts
|
|
328
375
|
async function submitAttestation(params) {
|
|
329
376
|
if (!params || typeof params !== "object") {
|
|
@@ -354,12 +401,12 @@ async function submitAttestation(params) {
|
|
|
354
401
|
}
|
|
355
402
|
});
|
|
356
403
|
const uid = await tx.wait();
|
|
357
|
-
const
|
|
358
|
-
const
|
|
404
|
+
const txHash = getEasTransactionHash(tx) ?? ZERO_UID;
|
|
405
|
+
const receipt = getEasTransactionReceipt(tx);
|
|
359
406
|
return {
|
|
360
407
|
uid,
|
|
361
408
|
txHash,
|
|
362
|
-
receipt
|
|
409
|
+
receipt
|
|
363
410
|
};
|
|
364
411
|
} catch (err) {
|
|
365
412
|
throw new OmaTrustError("NETWORK_ERROR", "Failed to submit attestation", { err });
|
|
@@ -512,7 +559,14 @@ async function submitDelegatedAttestation(params) {
|
|
|
512
559
|
var EAS_EVENT_ABI = [
|
|
513
560
|
"event Attested(address indexed recipient, address indexed attester, bytes32 uid, bytes32 indexed schemaUID)"
|
|
514
561
|
];
|
|
515
|
-
function
|
|
562
|
+
function parseEventTxHash(event) {
|
|
563
|
+
const txHash = event.transactionHash;
|
|
564
|
+
if (typeof txHash !== "string") {
|
|
565
|
+
return void 0;
|
|
566
|
+
}
|
|
567
|
+
return /^0x[0-9a-fA-F]{64}$/.test(txHash) ? txHash : void 0;
|
|
568
|
+
}
|
|
569
|
+
function parseAttestation(attestation, schema, txHash) {
|
|
516
570
|
const rawData = attestation.data ?? "0x";
|
|
517
571
|
const decoded = schema ? decodeAttestationData(schema, rawData) : {};
|
|
518
572
|
const toBigIntSafe = (value) => {
|
|
@@ -532,6 +586,7 @@ function parseAttestation(attestation, schema) {
|
|
|
532
586
|
schema: attestation.schema,
|
|
533
587
|
attester: attestation.attester,
|
|
534
588
|
recipient: attestation.recipient,
|
|
589
|
+
txHash,
|
|
535
590
|
revocable: Boolean(attestation.revocable),
|
|
536
591
|
revocationTime: toBigIntSafe(attestation.revocationTime),
|
|
537
592
|
expirationTime: toBigIntSafe(attestation.expirationTime),
|
|
@@ -590,7 +645,7 @@ async function getAttestationsForDid(params) {
|
|
|
590
645
|
if (!attestation || !attestation.uid) {
|
|
591
646
|
continue;
|
|
592
647
|
}
|
|
593
|
-
results.push(parseAttestation(attestation));
|
|
648
|
+
results.push(parseAttestation(attestation, void 0, parseEventTxHash(event)));
|
|
594
649
|
}
|
|
595
650
|
results.sort((a, b) => Number(b.time - a.time));
|
|
596
651
|
return results;
|
|
@@ -630,7 +685,7 @@ async function getLatestAttestations(params) {
|
|
|
630
685
|
if (!attestation || !attestation.uid) {
|
|
631
686
|
continue;
|
|
632
687
|
}
|
|
633
|
-
results.push(parseAttestation(attestation));
|
|
688
|
+
results.push(parseAttestation(attestation, void 0, parseEventTxHash(event)));
|
|
634
689
|
}
|
|
635
690
|
results.sort((a, b) => Number(b.time - a.time));
|
|
636
691
|
return results.slice(0, params.limit ?? 20);
|
|
@@ -1235,6 +1290,9 @@ async function getSchemaDetails(schemaRegistry, schemaUid) {
|
|
|
1235
1290
|
revocable: Boolean(details.revocable)
|
|
1236
1291
|
};
|
|
1237
1292
|
} catch (err) {
|
|
1293
|
+
if (isEasSchemaNotFoundError(err)) {
|
|
1294
|
+
throw new OmaTrustError("SCHEMA_NOT_FOUND", "Schema was not found", { schemaUid });
|
|
1295
|
+
}
|
|
1238
1296
|
if (err instanceof OmaTrustError) {
|
|
1239
1297
|
throw err;
|
|
1240
1298
|
}
|