AccountNFT.mint always revert with Errors.AccountNotFound.
AccountNFT overrides _update to sync tradingAccount.owner with the NFT owner.
https://github.com/Cyfrin/2024-07-zaros/blob/7439d79e627286ade431d4ea02805715e46ccf42/src/account-nft/AccountNFT.sol#L23-L25
However, notifyAccountTransfer calls loadExisting to load the previous trading account.
https://github.com/Cyfrin/2024-07-zaros/blob/7439d79e627286ade431d4ea02805715e46ccf42/src/perpetuals/branches/TradingAccountBranch.sol#L408
The problem is that a previous owner is address(0) when minting a new NFT. Therefore, AccountNFT.mint always reverts with Errors.AccountNotFound.
https://github.com/Cyfrin/2024-07-zaros/blob/7439d79e627286ade431d4ea02805715e46ccf42/src/perpetuals/leaves/TradingAccount.sol#L69-L74
Add the following test function test_AccountNFT_Mint in [NotifyAccountTransfer_Integration_Test]
(https://github.com/Cyfrin/2024-07-zaros/blob/7439d79e627286ade431d4ea02805715e46ccf42/test/integration/perpetuals/trading-account-branch/notifyAccountTransfer/notifyAccountTransfer.t.sol#L13).
Run forge test --mt test_AccountNFT_Mint.
AccountNFT contract cannot mint any NFTs.
Manual, Foundry
Replace loadExisting with load in notifyAccountTransfer.
https://github.com/Cyfrin/2024-07-zaros/blob/7439d79e627286ade431d4ea02805715e46ccf42/src/perpetuals/branches/TradingAccountBranch.sol#L408
notifyAccountTransfer is only allowed to AccountNFT, and AccountNFT only calls notifyAccountTransfer in _update function.
Therefore, loadExisting in notifyAccountTransfer reverts only when tradingAccount.owner is address(0), or
equivalently when AccountNFT is newly minted. In conclusion, load is more suitable than loadExisting in
notifyAccountTransfer.
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.