@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
package/dist/index.d.cts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export { i as identity } from './index-QZDExA4I.cjs';
|
|
2
|
-
export { i as reputation } from './index-
|
|
2
|
+
export { i as reputation } from './index-ByNU5VpJ.cjs';
|
|
3
3
|
export { i as appRegistry } from './index-_Bkhoj8k.cjs';
|
|
4
|
-
import './eip712-
|
|
4
|
+
import './eip712-Dx9kvqtn.cjs';
|
|
5
5
|
|
|
6
6
|
declare class OmaTrustError extends Error {
|
|
7
7
|
code: string;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export { i as identity } from './index-QZDExA4I.js';
|
|
2
|
-
export { i as reputation } from './index-
|
|
2
|
+
export { i as reputation } from './index-BUWbuvqZ.js';
|
|
3
3
|
export { i as appRegistry } from './index-_Bkhoj8k.js';
|
|
4
|
-
import './eip712-
|
|
4
|
+
import './eip712-Dx9kvqtn.js';
|
|
5
5
|
|
|
6
6
|
declare class OmaTrustError extends Error {
|
|
7
7
|
code: string;
|
package/dist/index.js
CHANGED
|
@@ -527,6 +527,53 @@ function resolveRecipientAddress(data) {
|
|
|
527
527
|
return ZeroAddress;
|
|
528
528
|
}
|
|
529
529
|
|
|
530
|
+
// src/reputation/eas-adapter.ts
|
|
531
|
+
function isRecord(value) {
|
|
532
|
+
return Boolean(value) && typeof value === "object";
|
|
533
|
+
}
|
|
534
|
+
function isHex32(value) {
|
|
535
|
+
return typeof value === "string" && /^0x[0-9a-fA-F]{64}$/.test(value);
|
|
536
|
+
}
|
|
537
|
+
function getEasTransactionReceipt(tx) {
|
|
538
|
+
if (!isRecord(tx)) {
|
|
539
|
+
return void 0;
|
|
540
|
+
}
|
|
541
|
+
const candidates = [tx.receipt, tx.tx, tx.transaction];
|
|
542
|
+
for (const candidate of candidates) {
|
|
543
|
+
if (isRecord(candidate)) {
|
|
544
|
+
return candidate;
|
|
545
|
+
}
|
|
546
|
+
}
|
|
547
|
+
return void 0;
|
|
548
|
+
}
|
|
549
|
+
function getEasTransactionHash(tx) {
|
|
550
|
+
const receipt = getEasTransactionReceipt(tx);
|
|
551
|
+
if (receipt) {
|
|
552
|
+
const receiptHash = receipt.hash;
|
|
553
|
+
if (isHex32(receiptHash)) {
|
|
554
|
+
return receiptHash;
|
|
555
|
+
}
|
|
556
|
+
const transactionHash = receipt.transactionHash;
|
|
557
|
+
if (isHex32(transactionHash)) {
|
|
558
|
+
return transactionHash;
|
|
559
|
+
}
|
|
560
|
+
}
|
|
561
|
+
if (isRecord(tx) && isHex32(tx.hash)) {
|
|
562
|
+
return tx.hash;
|
|
563
|
+
}
|
|
564
|
+
return void 0;
|
|
565
|
+
}
|
|
566
|
+
function isEasSchemaNotFoundError(err) {
|
|
567
|
+
if (!isRecord(err)) {
|
|
568
|
+
return false;
|
|
569
|
+
}
|
|
570
|
+
const message = err.message;
|
|
571
|
+
if (typeof message !== "string" || message.length === 0) {
|
|
572
|
+
return false;
|
|
573
|
+
}
|
|
574
|
+
return /schema not found/i.test(message);
|
|
575
|
+
}
|
|
576
|
+
|
|
530
577
|
// src/reputation/submit.ts
|
|
531
578
|
async function submitAttestation(params) {
|
|
532
579
|
if (!params || typeof params !== "object") {
|
|
@@ -557,12 +604,12 @@ async function submitAttestation(params) {
|
|
|
557
604
|
}
|
|
558
605
|
});
|
|
559
606
|
const uid = await tx.wait();
|
|
560
|
-
const
|
|
561
|
-
const
|
|
607
|
+
const txHash = getEasTransactionHash(tx) ?? ZERO_UID;
|
|
608
|
+
const receipt = getEasTransactionReceipt(tx);
|
|
562
609
|
return {
|
|
563
610
|
uid,
|
|
564
611
|
txHash,
|
|
565
|
-
receipt
|
|
612
|
+
receipt
|
|
566
613
|
};
|
|
567
614
|
} catch (err) {
|
|
568
615
|
throw new OmaTrustError("NETWORK_ERROR", "Failed to submit attestation", { err });
|
|
@@ -715,7 +762,14 @@ async function submitDelegatedAttestation(params) {
|
|
|
715
762
|
var EAS_EVENT_ABI = [
|
|
716
763
|
"event Attested(address indexed recipient, address indexed attester, bytes32 uid, bytes32 indexed schemaUID)"
|
|
717
764
|
];
|
|
718
|
-
function
|
|
765
|
+
function parseEventTxHash(event) {
|
|
766
|
+
const txHash = event.transactionHash;
|
|
767
|
+
if (typeof txHash !== "string") {
|
|
768
|
+
return void 0;
|
|
769
|
+
}
|
|
770
|
+
return /^0x[0-9a-fA-F]{64}$/.test(txHash) ? txHash : void 0;
|
|
771
|
+
}
|
|
772
|
+
function parseAttestation(attestation, schema, txHash) {
|
|
719
773
|
const rawData = attestation.data ?? "0x";
|
|
720
774
|
const decoded = schema ? decodeAttestationData(schema, rawData) : {};
|
|
721
775
|
const toBigIntSafe = (value) => {
|
|
@@ -735,6 +789,7 @@ function parseAttestation(attestation, schema) {
|
|
|
735
789
|
schema: attestation.schema,
|
|
736
790
|
attester: attestation.attester,
|
|
737
791
|
recipient: attestation.recipient,
|
|
792
|
+
txHash,
|
|
738
793
|
revocable: Boolean(attestation.revocable),
|
|
739
794
|
revocationTime: toBigIntSafe(attestation.revocationTime),
|
|
740
795
|
expirationTime: toBigIntSafe(attestation.expirationTime),
|
|
@@ -793,7 +848,7 @@ async function getAttestationsForDid(params) {
|
|
|
793
848
|
if (!attestation || !attestation.uid) {
|
|
794
849
|
continue;
|
|
795
850
|
}
|
|
796
|
-
results.push(parseAttestation(attestation));
|
|
851
|
+
results.push(parseAttestation(attestation, void 0, parseEventTxHash(event)));
|
|
797
852
|
}
|
|
798
853
|
results.sort((a, b) => Number(b.time - a.time));
|
|
799
854
|
return results;
|
|
@@ -833,7 +888,7 @@ async function getLatestAttestations(params) {
|
|
|
833
888
|
if (!attestation || !attestation.uid) {
|
|
834
889
|
continue;
|
|
835
890
|
}
|
|
836
|
-
results.push(parseAttestation(attestation));
|
|
891
|
+
results.push(parseAttestation(attestation, void 0, parseEventTxHash(event)));
|
|
837
892
|
}
|
|
838
893
|
results.sort((a, b) => Number(b.time - a.time));
|
|
839
894
|
return results.slice(0, params.limit ?? 20);
|
|
@@ -1438,6 +1493,9 @@ async function getSchemaDetails(schemaRegistry, schemaUid) {
|
|
|
1438
1493
|
revocable: Boolean(details.revocable)
|
|
1439
1494
|
};
|
|
1440
1495
|
} catch (err) {
|
|
1496
|
+
if (isEasSchemaNotFoundError(err)) {
|
|
1497
|
+
throw new OmaTrustError("SCHEMA_NOT_FOUND", "Schema was not found", { schemaUid });
|
|
1498
|
+
}
|
|
1441
1499
|
if (err instanceof OmaTrustError) {
|
|
1442
1500
|
throw err;
|
|
1443
1501
|
}
|