Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add blacklisted domains feature #207

Merged
merged 2 commits into from
Jul 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion src/indexer/utils/evm/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ export async function getDecodedLogs(
}

if (!decodedLog) {
throw new Error(`No decoded log for ${fromDomain.id}} and ${log.address}`)
throw new Error(`No decoded log for ${fromDomain.id} and ${log.address}`)
}

const txReceipt = await provider.getTransactionReceipt(log.transactionHash)
Expand All @@ -64,6 +64,11 @@ export async function getDecodedLogs(
}
switch (decodedLog.name) {
case EventType.DEPOSIT: {
const destinationDomainID = decodedLog.args.destinationDomainID as string
if (process.env.BLACKLISTED_DOMAINS?.split(",").includes(destinationDomainID)) {
logger.debug(`Destination domain ID ${destinationDomainID} is blacklisted`)
return
}
const toDomain = domains.filter(domain => domain.id == decodedLog?.args.destinationDomainID)
const deposit = await parseDeposit(provider, fromDomain, toDomain[0], log, decodedLog, txReceipt, blockUnixTimestamp, resourceMap)
decodedLogs.deposit.push(deposit)
Expand Down
9 changes: 9 additions & 0 deletions src/indexer/utils/substrate/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,10 @@ export async function saveEvents(
const txIdentifier = `${block}-${depositEvent.phase.asApplyExtrinsic}` //this is like the txHash but for the substrate
const { data } = depositEvent.event.toHuman()
const { destDomainId, resourceId, depositNonce, sender, transferType, depositData, handlerResponse } = data
if (process.env.BLACKLISTED_DOMAINS?.split(",").includes(destDomainId)) {
logger.debug(`Destination domain ID ${destDomainId} is blacklisted.`)
return
}
await saveDepositToDb(
domain,
block.toString(),
Expand All @@ -296,6 +300,7 @@ export async function saveEvents(
coinMakerCapService,
sharedConfig,
)
// legacy code to handle substrate deposits/fees that didn't have feeCollected event
if (feeCollectedEvents.length !== depositEvents.length) {
resourceMap.set(resourceId, { symbol: "PHA" } as SubstrateResource)
await saveFeeToDb(
Expand All @@ -319,6 +324,10 @@ export async function saveEvents(
const { data } = feeCollectedEvent.event.toHuman()

const { destDomainId, resourceId, feeAmount, feePayer, feeAssetId } = data
if (process.env.BLACKLISTED_DOMAINS?.split(",").includes(destDomainId)) {
logger.debug(`Destination domain ID ${destDomainId} is blacklisted.`)
return
}
await saveFeeToDb(
{
destDomainId,
Expand Down
Loading