In the MembershipERC1155::burnBatch
function, the number of tokens to burn is hard-coded to 7
, however this function is supposed to burn all the tokens owned by a user. So what happens if the user has less or more than this fixed number?
The purpose of the MembershipERC1155::burnBatch
function is to burn all the tokens of a single user
, however the number of tokens this function have to burn is set to 7 as implemented in the :
So, even if the user has less than 7
to burn, the for loop will continue to run until they reach that fixed number. On the other hand, if the user has more than 7
to burn, only 7
will be burned, the rest will remain in the contract and the function will have to be called again to burn more 7
until all the user's tokens are burned. The same logic is implemented in the MembershipERC1155::burnBatchMultiple
function:
unburnt token after the 7
loop, if the user has more than 7 tokens. And unnecessary check if the user has less than 7
tokens.
Manual review.
Instead of hard-coding 7
, determine the actual number of tokens owned by the user dynamically, using mapping or other logic.
I personally recommend this approach:
The first mapping _userHasToken
tracks whether the user holds a particular tokenId when mining.
And the second mapping _userTokenCount
tracks the number of distinct tokens each user holds. This is the mapping that can be used instead of 7
when looping through the for loop.
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.