v2-core icon indicating copy to clipboard operation
v2-core copied to clipboard

Use `try...catch` in `cancelMultiple` and `withdrawMultiple` to handle invalid stream IDs

Open smol-ninja opened this issue 9 months ago • 7 comments

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);
        }
    }
}

smol-ninja avatar May 08 '24 16:05 smol-ninja