v2-core
v2-core copied to clipboard
Use `try...catch` in `cancelMultiple` and `withdrawMultiple` to handle invalid stream IDs
As discussed here, batch functions such as cancelMultiple
and withdrawMultiple
should be allowed to continue execution if one of the stream IDs revert.
A sample implementation would look like the following:
event InvalidStreamIDInBatch(uint256 id, string memory reason);
function cancelMultiple(uint256[] calldata streamIds) external override {
for (uint256 i = 0; i < streamIds.length; ++i) {
try cancel(streamIds[i]) {
} catch Error(string memory reason){
emit InvalidStreamIDInBatch(streamIds[i], reason);
}
}
}