Some checks failed
CI/CD Pipeline / Solidity Contracts (push) Failing after 1m3s
CI/CD Pipeline / Security Scanning (push) Successful in 2m18s
CI/CD Pipeline / Lint and Format (push) Failing after 34s
CI/CD Pipeline / Terraform Validation (push) Failing after 20s
CI/CD Pipeline / Kubernetes Validation (push) Successful in 22s
Deploy ChainID 138 / Deploy ChainID 138 (push) Failing after 40s
HYBX OMNL TypeScript & anchor / token-aggregation build + reconcile artifact (push) Failing after 49s
OMNL reconcile anchor / Run omnl:reconcile and upload artifacts (push) Failing after 21s
Validation / validate-genesis (push) Successful in 25s
Validation / validate-terraform (push) Failing after 21s
Validation / validate-kubernetes (push) Failing after 8s
Validation / validate-smart-contracts (push) Failing after 8s
Validation / validate-security (push) Failing after 1m11s
Validation / validate-documentation (push) Failing after 14s
Verify Deployment / Verify Deployment (push) Failing after 45s
Ship AddressActivityRegistry V1/V2, ISO20022IntakeGateway, Chain138ParticipantSurface, checkpoint hub contracts, checkpoint-core package, aggregator/indexer/sdk services, relay profile guards, M00 diamond bridge facet, and OMNL compliance contracts. Co-authored-by: Cursor <cursoragent@cursor.com>
43 lines
1.5 KiB
JavaScript
43 lines
1.5 KiB
JavaScript
"use strict";
|
|
/**
|
|
* Blockscout token-transfer enrichment — Chain 138 txs are mostly ERC-20; native `value` is often 0.
|
|
*/
|
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
exports.pickPrimaryTokenTransfer = pickPrimaryTokenTransfer;
|
|
exports.fetchTokenTransfersForTx = fetchTokenTransfersForTx;
|
|
/** Pick the largest ERC-20 transfer in a tx (typical payment). */
|
|
function pickPrimaryTokenTransfer(items) {
|
|
let best = null;
|
|
for (const item of items) {
|
|
const token = item.token?.address;
|
|
const raw = item.total?.value;
|
|
if (!token || !raw)
|
|
continue;
|
|
const value = BigInt(raw);
|
|
if (value === 0n)
|
|
continue;
|
|
const decimals = parseInt(item.token?.decimals || '18', 10);
|
|
const summary = {
|
|
token,
|
|
tokenSymbol: item.token?.symbol || '',
|
|
tokenDecimals: Number.isFinite(decimals) ? decimals : 18,
|
|
from: item.from?.hash || '',
|
|
to: item.to?.hash || '',
|
|
value,
|
|
logIndex: item.log_index ?? 0,
|
|
};
|
|
if (!best || summary.value > best.value)
|
|
best = summary;
|
|
}
|
|
return best;
|
|
}
|
|
async function fetchTokenTransfersForTx(apiBase, txHash) {
|
|
const base = apiBase.replace(/\/$/, '');
|
|
const url = `${base}/transactions/${txHash}/token-transfers`;
|
|
const res = await fetch(url);
|
|
if (!res.ok)
|
|
return null;
|
|
const body = (await res.json());
|
|
return pickPrimaryTokenTransfer(body.items ?? []);
|
|
}
|