feat: modify batcher contract to support erc20 sendMany - #192
Conversation
f4779d5 to
7a1176e
Compare
gianchandania
left a comment
There was a problem hiding this comment.
Please add tests for the method
| address[] calldata recipients, | ||
| uint256[] calldata amounts | ||
| ) external lockCall { | ||
| require(recipients.length == amounts.length, "Length mismatch"); |
There was a problem hiding this comment.
I think we should add other validations which are there in batch method here as well
require(recipients.length != 0, 'Must send to at least one person');
require(recipients.length < 256, 'Too many recipients');
should check what this number should be instead of 256
There was a problem hiding this comment.
Also length mismatch error is bit ambiguous. let's make this error message same as batch method
There was a problem hiding this comment.
kept the limit dynamic since it can be different for different chains.
added a function changeBatchTransferLimit to change the limit.
| ) external lockCall { | ||
| require(recipients.length == amounts.length, "Length mismatch"); | ||
| for (uint256 i = 0; i < recipients.length; i++) { | ||
| TransferHelper.safeTransferFrom(token, msg.sender, recipients[i], amounts[i]); |
There was a problem hiding this comment.
Ideally there should not be a case of partial success, either we send successfully to all the recipients, or none of the transfer should go through.
There was a problem hiding this comment.
as suggested, I tried to send to 5 recipients while giving the gas limit for only 2.
the tx failed on chain.
https://holesky.etherscan.io/tx/0x42d64222124a57e5ee7135be7794fcf3d81df5563be3b55cb5a4df81803f2bf9
7a1176e to
54c9321
Compare
| ) external lockCall { | ||
| require(recipients.length != 0, 'Must send to at least one person'); | ||
| require(recipients.length == amounts.length, "Unequal recipients and values"); | ||
| for (uint256 i = 0; i < recipients.length; i++) { |
There was a problem hiding this comment.
| for (uint256 i = 0; i < recipients.length; i++) { | |
| for (uint8 i = 0; i < recipients.length; i++) { |
There was a problem hiding this comment.
You can also change the contract to use custom errors instead of require statements
There was a problem hiding this comment.
used uint16.
also added custom errors.
54c9321 to
91304b5
Compare
91304b5 to
85c7b1f
Compare
85c7b1f to
2506542
Compare
2506542 to
5a2cf63
Compare
added few tests. |
5a2cf63 to
73ecc14
Compare
73ecc14 to
eca5b19
Compare
e79e1f9 to
92bc37b
Compare
92bc37b to
932dbb5
Compare
| error EmptyRecipientsList(); | ||
| error UnequalRecipientsAndValues(); | ||
| error TooManyRecipients(uint256 provided, uint256 limit); | ||
| error TokenTransferFailed(address token, address from, address to, uint256 amount); |
There was a problem hiding this comment.
Add comments following the natspec format for everything
There was a problem hiding this comment.
NIT: comments on errros
932dbb5 to
ae2cb27
Compare
ae2cb27 to
aec9d8d
Compare
aec9d8d to
83e6911
Compare
| error EmptyRecipientsList(); | ||
| error UnequalRecipientsAndValues(); | ||
| error TooManyRecipients(uint256 provided, uint256 limit); | ||
| error TokenTransferFailed(address token, address from, address to, uint256 amount); |
There was a problem hiding this comment.
NIT: comments on errros
mullapudipruthvik
left a comment
There was a problem hiding this comment.
LGTM
Have we figured out the owner and how do we interact with the contract?
|
|
||
| IERC20 safeToken = IERC20(token); | ||
| for (uint16 i = 0; i < recipients.length; i++) { | ||
| safeToken.safeTransferFrom(msg.sender, recipients[i], amounts[i]); |
There was a problem hiding this comment.
should we allow 0 value transfers ?
There was a problem hiding this comment.
will handle it here.
https://bitgoinc.atlassian.net/browse/COIN-3005
what is the expected behaviour?
- should it skip the 0 value transfers and continue with other transfers?
- fail entirely (keeping it atomic).
Not sure about the owner. |
Ticket: COIN-2782