Files
smom-dbis-138/services/checkpoint-indexer/src/tokenEnrich.ts
defiQUG c336809676
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
Add mainnet checkpoint stack: ISO attestation, participant Etherscan surface, and services.
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>
2026-05-25 00:30:45 -07:00

51 lines
1.5 KiB
TypeScript

import {
applyPrimaryTransferToLeaf,
fetchAllTokenTransfersForTx,
pickPrimaryFromSummaries,
} from '@dbis/checkpoint-core';
import { checkpointIndexerConfig as cfg } from './config';
import { enrichLeafUsdRecord } from './usdEnrich';
export type LeafRecord = Record<string, unknown>;
export async function enrichLeaves(
leaves: LeafRecord[],
blockscoutApi: string
): Promise<LeafRecord[]> {
const api = blockscoutApi.replace(/\/$/, '');
const out: LeafRecord[] = [];
for (const leaf of leaves) {
const copy = { ...leaf };
const txHash = String(leaf.txHash || '');
const needsToken =
cfg.enrichTokenTransfers &&
/^0x[a-fA-F0-9]{64}$/.test(txHash) &&
!copy.token &&
BigInt(String(copy.value ?? copy.nativeValueWei ?? '0')) === 0n;
let allErc20: Awaited<ReturnType<typeof fetchAllTokenTransfersForTx>> = [];
if (needsToken || (cfg.usdEnrichEnabled && /^0x[a-fA-F0-9]{64}$/.test(txHash))) {
allErc20 = await fetchAllTokenTransfersForTx(api, txHash);
if (needsToken) {
applyPrimaryTransferToLeaf(copy, pickPrimaryFromSummaries(allErc20));
}
}
const withUsd = await enrichLeafUsdRecord(copy, {
apiBaseUrl: cfg.tokenAggregationApiUrl,
chainId: 138,
enabled: cfg.usdEnrichEnabled,
requestDelayMs: cfg.usdRequestDelayMs,
blockscoutApi: api,
preloadedErc20: allErc20,
});
out.push(withUsd);
await sleep(60);
}
return out;
}
function sleep(ms: number): Promise<void> {
return new Promise((r) => setTimeout(r, ms));
}