diff --git a/contracts/ERC20Splitter.sol b/contracts/ERC20Splitter.sol index 7531d69..609f9eb 100644 --- a/contracts/ERC20Splitter.sol +++ b/contracts/ERC20Splitter.sol @@ -57,7 +57,7 @@ contract ERC20Splitter is ReentrancyGuard { /// @notice Withdraw all tokens that the caller is entitled to. /// Tokens are automatically determined based on previous deposits. - function withdraw(address[] calldata tokenAddresses) external nonReentrant { + function withdraw(address[] calldata tokenAddresses) external nonReentrant { uint256 tokenCount = tokenAddresses.length; require(tokenCount > 0, 'ERC20Splitter: No tokens specified'); @@ -68,10 +68,10 @@ contract ERC20Splitter is ReentrancyGuard { uint256 amount = balances[tokenAddress][msg.sender]; if (amount == 0) { - continue; // Skip if no balance + continue; } - balances[tokenAddress][msg.sender] = 0; + delete balances[tokenAddress][msg.sender]; if (tokenAddress == address(0)) { payable(msg.sender).transfer(amount);