@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/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 });
|
|
@@ -1235,6 +1282,9 @@ async function getSchemaDetails(schemaRegistry, schemaUid) {
|
|
|
1235
1282
|
revocable: Boolean(details.revocable)
|
|
1236
1283
|
};
|
|
1237
1284
|
} catch (err) {
|
|
1285
|
+
if (isEasSchemaNotFoundError(err)) {
|
|
1286
|
+
throw new OmaTrustError("SCHEMA_NOT_FOUND", "Schema was not found", { schemaUid });
|
|
1287
|
+
}
|
|
1238
1288
|
if (err instanceof OmaTrustError) {
|
|
1239
1289
|
throw err;
|
|
1240
1290
|
}
|