@@ -73,14 +73,12 @@ contract DonationHandler is OwnableUpgradeable, ReentrancyGuardUpgradeable {
73
73
revert InsufficientAllowance ();
74
74
}
75
75
}
76
- // ETH Donations
77
- // Donate multiple ETH donations at once
76
+
78
77
/// @notice Donate multiple ETH donations at once
79
78
/// @param totalAmount The total amount of the donation
80
79
/// @param recipientAddresses The addresses of the recipients of the donation
81
80
/// @param amounts The amounts of the donation to each recipient
82
81
/// @param data The data of the donation to each recipient
83
-
84
82
function donateManyETH (
85
83
uint256 totalAmount ,
86
84
address [] calldata recipientAddresses ,
@@ -100,7 +98,6 @@ contract DonationHandler is OwnableUpgradeable, ReentrancyGuardUpgradeable {
100
98
}
101
99
}
102
100
103
- // Donate a single ETH donation
104
101
/// @notice Donate a single ETH donation
105
102
/// @param recipientAddress The address of the recipient of the donation
106
103
/// @param amount The amount of the donation
@@ -110,7 +107,6 @@ contract DonationHandler is OwnableUpgradeable, ReentrancyGuardUpgradeable {
110
107
_handleETH (amount, recipientAddress, data);
111
108
}
112
109
113
- // Donate a single ERC20 donation
114
110
/// @notice Donate a single ERC20 donation
115
111
/// @param tokenAddress The address of the token being donated
116
112
/// @param recipientAddress The address of the recipient of the donation
@@ -126,8 +122,6 @@ contract DonationHandler is OwnableUpgradeable, ReentrancyGuardUpgradeable {
126
122
_handleERC20 (tokenAddress, amount, recipientAddress, data);
127
123
}
128
124
129
- // ERC20 Donations
130
- // Donate multiple ERC20 donations at once
131
125
/// @notice Donate multiple ERC20 donations at once
132
126
/// @param tokenAddress The address of the token being donated
133
127
/// @param totalAmount The total amount of the donation
@@ -155,13 +149,12 @@ contract DonationHandler is OwnableUpgradeable, ReentrancyGuardUpgradeable {
155
149
}
156
150
}
157
151
}
158
- // Donate multiple ERC20 & ETH donations at once
152
+
159
153
/// @notice Donate multiple ERC20 & ETH donations at once
160
154
/// @param tokenAddresses The addresses of the tokens being donated
161
155
/// @param amounts The amounts of the donation to each recipient
162
156
/// @param recipientAddresses The addresses of the recipients of the donation
163
157
/// @param data The data of the donation to each recipient
164
-
165
158
function donateManyMultipleTokens (
166
159
address [] calldata tokenAddresses ,
167
160
uint256 [] calldata amounts ,
@@ -201,18 +194,14 @@ contract DonationHandler is OwnableUpgradeable, ReentrancyGuardUpgradeable {
201
194
}
202
195
}
203
196
204
- // Internal functions
205
197
/// @notice Handle a single ETH donation
206
198
/// @param amount The amount of the donation
207
199
/// @param recipientAddress The address of the recipient of the donation
208
200
function _handleETH (uint256 amount , address recipientAddress , bytes memory data ) internal {
209
- // Interactions
210
-
211
201
if (recipientAddress == ETH_TOKEN_ADDRESS) revert InvalidInput ();
212
202
if (amount == 0 ) revert InvalidInput ();
213
203
(bool success ,) = recipientAddress.call {value: amount}('' );
214
204
require (success, 'ETH transfer failed ' );
215
- // Effects
216
205
emit DonationMade (recipientAddress, amount, ETH_TOKEN_ADDRESS, data);
217
206
}
218
207
@@ -225,13 +214,10 @@ contract DonationHandler is OwnableUpgradeable, ReentrancyGuardUpgradeable {
225
214
if (amount == 0 ) revert InvalidInput ();
226
215
bool success = IERC20 (token).transferFrom (msg .sender , recipientAddress, amount);
227
216
require (success, 'ERC20 transfer failed ' );
228
-
229
217
emit DonationMade (recipientAddress, amount, token, data);
230
218
}
231
219
232
- // Receive function to accept ETH
233
220
receive () external payable {
234
- // Only accept ETH through allocateETH function
235
221
revert ('Use allocateETH function to send ETH ' );
236
222
}
237
223
}
0 commit comments