games_app/backend/dist-test-faq/utils/bscExplorerTokentx.js

31 lines
1.2 KiB
JavaScript

"use strict";
/**
* Parsers for Etherscan-compatible account/tokentx explorer APIs (Blockscout, BscScan).
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.parseExplorerTokenTxResult = parseExplorerTokenTxResult;
function parseExplorerTokenTxResult(payload, usdtContract) {
if (!payload || typeof payload !== 'object')
return [];
const result = payload.result;
if (!Array.isArray(result))
return [];
const want = usdtContract.toLowerCase();
const out = [];
for (const row of result) {
if (!row || typeof row !== 'object')
continue;
const r = row;
const hash = typeof r.hash === 'string' ? r.hash : '';
const from = typeof r.from === 'string' ? r.from : '';
const to = typeof r.to === 'string' ? r.to : '';
const contractAddress = typeof r.contractAddress === 'string' ? r.contractAddress : '';
if (!/^0x[0-9a-fA-F]{64}$/.test(hash))
continue;
if (contractAddress && contractAddress.toLowerCase() !== want)
continue;
out.push({ hash, from, to, contractAddress });
}
return out;
}
//# sourceMappingURL=bscExplorerTokentx.js.map