We need to make a smart contract call in B3trUserChallengesService. This should be avoided. In fact this indexer and the sister indexer B3trChallengeIndexer need to be reviewed and refactored. The implementation was rushed and went through a lot of increments. We need to take a free look at that thing.
`private suspend fun fetchParticipantActionsForCompletion(
completionEvent: IndexedEvent,
challengeId: Long,
wallets: Set,
): Map<String, BigInteger> {
if (!shouldFanoutCompletion(completionEvent, wallets.size, challengeId)) {
return emptyMap()
}
val abi = loadChallengesAbiFunction("getParticipantActions")
val revision = BlockRevision.Id(completionEvent.blockId)
val candidateWallets = wallets.sorted()
val actionsByWallet = linkedMapOf<String, BigInteger>()
candidateWallets.chunked(PARTICIPANT_ACTIONS_BATCH_SIZE).forEach { batch ->
val clauses =
batch.map { wallet ->
ContractUtils.createClause(
challengesContractAddress,
abi,
BigInteger.valueOf(challengeId),
AddressUtils.toBigInt(wallet),
)
}
val responses = thorClient.inspectClauses(clauses, revision)
batch.forEachIndexed { index, wallet ->
val response =
responses.getOrNull(index)
?: error(
"Missing getParticipantActions response for challengeId=$challengeId wallet=$wallet"
)
actionsByWallet[wallet] =
parseParticipantActions(response, abi, challengeId, wallet)
}
}
return actionsByWallet
}`
We need to make a smart contract call in B3trUserChallengesService. This should be avoided. In fact this indexer and the sister indexer B3trChallengeIndexer need to be reviewed and refactored. The implementation was rushed and went through a lot of increments. We need to take a free look at that thing.
`private suspend fun fetchParticipantActionsForCompletion(
completionEvent: IndexedEvent,
challengeId: Long,
wallets: Set,
): Map<String, BigInteger> {
if (!shouldFanoutCompletion(completionEvent, wallets.size, challengeId)) {
return emptyMap()
}