In the TokenDivider
contract, several events are emitted before the respective state changes or actions they represent have been finalized. This could lead to inconsistencies and confusion, especially when relying on these events for off-chain automation or analysis in the case that these functions are delayed or fail before completion.
divideNft
Function:
The NftDivided
event is emitted before the ERC20 token transfer is performed. This could result in the event being misleading if the transfer subsequently fails.
claimNft
Function:
The NftClaimed
event is emitted before the NFT is transferred from the contract to the caller's address. In the case that this fails, this event would be misleading.
transferErcTokens
Function:
The TokensTransfered
event is emitted before the actual ERC20 token transfer occurs. If the token transfer fails, the event will have already been emitted, leading to incorrect assumptions about the transfer's success.
sellErc20
Function:
The OrderPublished
event is emitted before the order creation process is fully completed, which might not reflect the accurate state of the contract at the time the event is captured.
buyOrder
Function:
The OrderSelled
event is emitted here before the transfer of ether in this function is completed. If the transfer goes wrong somewhere, the emitted event would be misleading.
Emitting events prematurely can cause discrepancies between the actual contract state and the state gotten from the events. This is particularly problematic for:
Off-chain services and monitoring tools that rely on emitted events to trigger actions.
Users or developers debugging issues, as the event logs do not accurately represent the state changes.
Manual code review
To address this issue, move the code that handles the emitting of the events in all the mentioned functions to the end of those function after the states and/or transfer logic has been completed.
The contest is live. Earn rewards by submitting a finding.
This is your time to appeal against judgements on your submissions.
Appeals are being carefully reviewed by our judges.