From 50305ff91289ffeeda140aff65da4b2a5717ee6a Mon Sep 17 00:00:00 2001 From: Eduardo Melo Date: Thu, 19 Sep 2024 14:10:26 -0300 Subject: [PATCH] feat: withdraw with tokenAddresses as parameter --- contracts/ERC20Splitter.sol | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) 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);