@oma3/omatrust 0.1.0-alpha.3 → 0.1.0-alpha.4
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/index.cjs +53 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +53 -3
- package/dist/index.js.map +1 -1
- package/dist/reputation/index.browser.cjs +53 -3
- package/dist/reputation/index.browser.cjs.map +1 -1
- package/dist/reputation/index.browser.js +53 -3
- package/dist/reputation/index.browser.js.map +1 -1
- package/dist/reputation/index.cjs +53 -3
- package/dist/reputation/index.cjs.map +1 -1
- package/dist/reputation/index.js +53 -3
- package/dist/reputation/index.js.map +1 -1
- package/package.json +1 -1
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 });
|
|
@@ -1438,6 +1485,9 @@ async function getSchemaDetails(schemaRegistry, schemaUid) {
|
|
|
1438
1485
|
revocable: Boolean(details.revocable)
|
|
1439
1486
|
};
|
|
1440
1487
|
} catch (err) {
|
|
1488
|
+
if (isEasSchemaNotFoundError(err)) {
|
|
1489
|
+
throw new OmaTrustError("SCHEMA_NOT_FOUND", "Schema was not found", { schemaUid });
|
|
1490
|
+
}
|
|
1441
1491
|
if (err instanceof OmaTrustError) {
|
|
1442
1492
|
throw err;
|
|
1443
1493
|
}
|