Maybe we have a function like this in libpromises, but please check