@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
|
@@ -329,6 +329,53 @@ function resolveRecipientAddress(data) {
|
|
|
329
329
|
return ethers.ZeroAddress;
|
|
330
330
|
}
|
|
331
331
|
|
|
332
|
+
// src/reputation/eas-adapter.ts
|
|
333
|
+
function isRecord(value) {
|
|
334
|
+
return Boolean(value) && typeof value === "object";
|
|
335
|
+
}
|
|
336
|
+
function isHex32(value) {
|
|
337
|
+
return typeof value === "string" && /^0x[0-9a-fA-F]{64}$/.test(value);
|
|
338
|
+
}
|
|
339
|
+
function getEasTransactionReceipt(tx) {
|
|
340
|
+
if (!isRecord(tx)) {
|
|
341
|
+
return void 0;
|
|
342
|
+
}
|
|
343
|
+
const candidates = [tx.receipt, tx.tx, tx.transaction];
|
|
344
|
+
for (const candidate of candidates) {
|
|
345
|
+
if (isRecord(candidate)) {
|
|
346
|
+
return candidate;
|
|
347
|
+
}
|
|
348
|
+
}
|
|
349
|
+
return void 0;
|
|
350
|
+
}
|
|
351
|
+
function getEasTransactionHash(tx) {
|
|
352
|
+
const receipt = getEasTransactionReceipt(tx);
|
|
353
|
+
if (receipt) {
|
|
354
|
+
const receiptHash = receipt.hash;
|
|
355
|
+
if (isHex32(receiptHash)) {
|
|
356
|
+
return receiptHash;
|
|
357
|
+
}
|
|
358
|
+
const transactionHash = receipt.transactionHash;
|
|
359
|
+
if (isHex32(transactionHash)) {
|
|
360
|
+
return transactionHash;
|
|
361
|
+
}
|
|
362
|
+
}
|
|
363
|
+
if (isRecord(tx) && isHex32(tx.hash)) {
|
|
364
|
+
return tx.hash;
|
|
365
|
+
}
|
|
366
|
+
return void 0;
|
|
367
|
+
}
|
|
368
|
+
function isEasSchemaNotFoundError(err) {
|
|
369
|
+
if (!isRecord(err)) {
|
|
370
|
+
return false;
|
|
371
|
+
}
|
|
372
|
+
const message = err.message;
|
|
373
|
+
if (typeof message !== "string" || message.length === 0) {
|
|
374
|
+
return false;
|
|
375
|
+
}
|
|
376
|
+
return /schema not found/i.test(message);
|
|
377
|
+
}
|
|
378
|
+
|
|
332
379
|
// src/reputation/submit.ts
|
|
333
380
|
async function submitAttestation(params) {
|
|
334
381
|
if (!params || typeof params !== "object") {
|
|
@@ -359,12 +406,12 @@ async function submitAttestation(params) {
|
|
|
359
406
|
}
|
|
360
407
|
});
|
|
361
408
|
const uid = await tx.wait();
|
|
362
|
-
const
|
|
363
|
-
const
|
|
409
|
+
const txHash = getEasTransactionHash(tx) ?? ZERO_UID;
|
|
410
|
+
const receipt = getEasTransactionReceipt(tx);
|
|
364
411
|
return {
|
|
365
412
|
uid,
|
|
366
413
|
txHash,
|
|
367
|
-
receipt
|
|
414
|
+
receipt
|
|
368
415
|
};
|
|
369
416
|
} catch (err) {
|
|
370
417
|
throw new OmaTrustError("NETWORK_ERROR", "Failed to submit attestation", { err });
|
|
@@ -517,7 +564,14 @@ async function submitDelegatedAttestation(params) {
|
|
|
517
564
|
var EAS_EVENT_ABI = [
|
|
518
565
|
"event Attested(address indexed recipient, address indexed attester, bytes32 uid, bytes32 indexed schemaUID)"
|
|
519
566
|
];
|
|
520
|
-
function
|
|
567
|
+
function parseEventTxHash(event) {
|
|
568
|
+
const txHash = event.transactionHash;
|
|
569
|
+
if (typeof txHash !== "string") {
|
|
570
|
+
return void 0;
|
|
571
|
+
}
|
|
572
|
+
return /^0x[0-9a-fA-F]{64}$/.test(txHash) ? txHash : void 0;
|
|
573
|
+
}
|
|
574
|
+
function parseAttestation(attestation, schema, txHash) {
|
|
521
575
|
const rawData = attestation.data ?? "0x";
|
|
522
576
|
const decoded = schema ? decodeAttestationData(schema, rawData) : {};
|
|
523
577
|
const toBigIntSafe = (value) => {
|
|
@@ -537,6 +591,7 @@ function parseAttestation(attestation, schema) {
|
|
|
537
591
|
schema: attestation.schema,
|
|
538
592
|
attester: attestation.attester,
|
|
539
593
|
recipient: attestation.recipient,
|
|
594
|
+
txHash,
|
|
540
595
|
revocable: Boolean(attestation.revocable),
|
|
541
596
|
revocationTime: toBigIntSafe(attestation.revocationTime),
|
|
542
597
|
expirationTime: toBigIntSafe(attestation.expirationTime),
|
|
@@ -595,7 +650,7 @@ async function getAttestationsForDid(params) {
|
|
|
595
650
|
if (!attestation || !attestation.uid) {
|
|
596
651
|
continue;
|
|
597
652
|
}
|
|
598
|
-
results.push(parseAttestation(attestation));
|
|
653
|
+
results.push(parseAttestation(attestation, void 0, parseEventTxHash(event)));
|
|
599
654
|
}
|
|
600
655
|
results.sort((a, b) => Number(b.time - a.time));
|
|
601
656
|
return results;
|
|
@@ -635,7 +690,7 @@ async function getLatestAttestations(params) {
|
|
|
635
690
|
if (!attestation || !attestation.uid) {
|
|
636
691
|
continue;
|
|
637
692
|
}
|
|
638
|
-
results.push(parseAttestation(attestation));
|
|
693
|
+
results.push(parseAttestation(attestation, void 0, parseEventTxHash(event)));
|
|
639
694
|
}
|
|
640
695
|
results.sort((a, b) => Number(b.time - a.time));
|
|
641
696
|
return results.slice(0, params.limit ?? 20);
|
|
@@ -1240,6 +1295,9 @@ async function getSchemaDetails(schemaRegistry, schemaUid) {
|
|
|
1240
1295
|
revocable: Boolean(details.revocable)
|
|
1241
1296
|
};
|
|
1242
1297
|
} catch (err) {
|
|
1298
|
+
if (isEasSchemaNotFoundError(err)) {
|
|
1299
|
+
throw new OmaTrustError("SCHEMA_NOT_FOUND", "Schema was not found", { schemaUid });
|
|
1300
|
+
}
|
|
1243
1301
|
if (err instanceof OmaTrustError) {
|
|
1244
1302
|
throw err;
|
|
1245
1303
|
}
|