Skip to content

Commit

Permalink
additional logs for bulk scan (#137) (#138)
Browse files Browse the repository at this point in the history
* additional logs for bulk scan

* log issue with adding malicious score

* rm console.log
  • Loading branch information
piyalbasu authored Aug 15, 2024
1 parent 02050db commit 29e65ea
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
1 change: 0 additions & 1 deletion src/route/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,6 @@ export async function initApiServer(
const useMercury = await getUseMercury(mode, useMercuryConf, redis);
const pubKey = request.params["pubKey"];
const { network } = request.query;
console.log(request.query);
const { data, error } = await mercuryClient.getAccountHistory(
pubKey,
network,
Expand Down
17 changes: 12 additions & 5 deletions src/service/blockaid/helpers/addScanResults.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ export const addScannedStatus = async (
keyList.push(blockaidKey);
} catch (e) {
logger.error(e);
logger.error(`Failed to split key: ${key}`);
}
}

Expand All @@ -38,15 +39,21 @@ export const addScannedStatus = async (
const bulkRes = await blockaidService.scanAssetBulk(keyList);

Object.entries(bulkRes?.data?.results || {}).forEach(([key, val]) => {
const splitKey = key.split("-");
const balKey = `${splitKey[0]}:${splitKey[1]}`;
try {
const splitKey = key.split("-");
const balKey = `${splitKey[0]}:${splitKey[1]}`;

// overwrite the isMalicious default with the Blockaid scan result
scannedBalances[balKey].isMalicious =
Boolean(Number(val?.malicious_score)) || false;
// overwrite the isMalicious default with the Blockaid scan result
scannedBalances[balKey].isMalicious =
Boolean(Number(val?.malicious_score)) || false;
} catch (e) {
logger.error(e);
logger.error(`Failed to process Blockaid scan result: ${key}:${val}`);
}
});
} catch (e) {
logger.error(e);
logger.error(`Failed to bulk scan assets: ${JSON.stringify(keyList)}`);
}
}

Expand Down

0 comments on commit 29e65ea

Please sign in to comment.