The function "buyPresent" in "SantasList" contract does not need approval for the contract as stated in the doc.
Adding the following test in SantasListTest.t.sol and running it is passing:
The "buyPresent" function is not working as expected from the doc.
Manual inspection & Foundry testing
If you want the "buyPresent" function to work only if approve was called make the following changes to the function:
function buyPresent(address presentReceiver) external {
//transfer the tokens to the contract first
//transferFrom will transfer only if the current contract was approved from the msg.sender
i_santaToken.transferFrom(msg.sender, address(this));
i_santaToken.burn(address(this));
_mintAndIncrement();
}
OR
You can change the "burn" function in "SantaToken.sol" contract to make checks if the allowances of the given user are sufficient
and subtract as many allowances as burnt
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.