All uninitialized address in the mapping(address person => Status naughtyOrNice) private s_theListCheckedOnce;
have a Status value of Status.NICE
Solidity always provides a default value for uninitialized typed variables. uint256 (default) = 0;
, bool (default) = false;
, e.t.c. For enums, the first named CONSTANT acts as the initial value.
For the SantasList smart contract, calling the getNaughtyOrNiceOnce
function by passing any address that has not being set in the mapping(address person => Status naughtyOrNice) private s_theListCheckedOnce;
returns Status.NICE
. This overrides the use of the checkList
function by santa to determine if a person (address) is NICE
Santa cannot determine if an unknown address is NICE or NAUGHTY in the s_theListCheckedOnce
mapping.
TEST
RESULT
FOUNDRY
Manual Review
Refactoring of enum Status
definition so as to make a trivial constant the default value.
In Solidity the first element of an enum is the default value. In Santa's List, the means each person is mapped by default to 'NICE'.
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.