"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.enrichLeafUsdRecord = enrichLeafUsdRecord;
const checkpoint_core_1 = require("@dbis/checkpoint-core");
async function enrichLeafUsdRecord(leaf, cfg) {
    if (cfg.enabled === false)
        return leaf;
    if (leaf.usdEnrichedAt && leaf.transfers != null && leaf.valueUsd != null) {
        return leaf;
    }
    const allErc20 = cfg.preloadedErc20 ??
        (await (0, checkpoint_core_1.fetchAllTokenTransfersForTx)(cfg.blockscoutApi, String(leaf.txHash)));
    return (await (0, checkpoint_core_1.enrichLeafUsdFields)(cfg, leaf, allErc20));
}
