@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.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
|
|
567
|
-
const
|
|
613
|
+
const txHash = getEasTransactionHash(tx) ?? ZERO_UID;
|
|
614
|
+
const receipt = getEasTransactionReceipt(tx);
|
|
568
615
|
return {
|
|
569
616
|
uid,
|
|
570
617
|
txHash,
|
|
571
|
-
receipt
|
|
618
|
+
receipt
|
|
572
619
|
};
|
|
573
620
|
} catch (err) {
|
|
574
621
|
throw new OmaTrustError("NETWORK_ERROR", "Failed to submit attestation", { err });
|
|
@@ -1444,6 +1491,9 @@ async function getSchemaDetails(schemaRegistry, schemaUid) {
|
|
|
1444
1491
|
revocable: Boolean(details.revocable)
|
|
1445
1492
|
};
|
|
1446
1493
|
} catch (err) {
|
|
1494
|
+
if (isEasSchemaNotFoundError(err)) {
|
|
1495
|
+
throw new OmaTrustError("SCHEMA_NOT_FOUND", "Schema was not found", { schemaUid });
|
|
1496
|
+
}
|
|
1447
1497
|
if (err instanceof OmaTrustError) {
|
|
1448
1498
|
throw err;
|
|
1449
1499
|
}
|