import { CheckStateEnum } from '@cashu/cashu-ts';
const ac = new AbortController();
(async () => {
for await (const u of wallet.on.proofStatesStream(proofs, { signal: ac.signal })) {
if (u.state === CheckStateEnum.SPENT) {
console.log('Spent proof', u.proof.id);
}
}
})();
// later
ac.abort();
Note: the subscription is sent to the mint on the first iteration, not when
proofStatesStreamis called. Per NUT-17 the mint replays the current state on subscribe, so the latest state is never lost — only intermediate transitions before the first iteration are collapsed into that snapshot.