From 9e3d865b3cf3997683364a7b831c0ef11375a51c Mon Sep 17 00:00:00 2001 From: Dan Connolly Date: Thu, 22 Feb 2024 02:14:29 -0600 Subject: [PATCH] chore(wallet-tools): notifier -> async iterator --- contract/test/wallet-tools.js | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/contract/test/wallet-tools.js b/contract/test/wallet-tools.js index 87d54468..57cc8353 100644 --- a/contract/test/wallet-tools.js +++ b/contract/test/wallet-tools.js @@ -1,6 +1,7 @@ // @ts-check import { E, Far } from '@endo/far'; import { makePromiseKit } from '@endo/promise-kit'; +import { makeNotifier } from '@agoric/notifier'; import { allValues, mapValues } from '../src/objectTools.js'; export { allValues, mapValues }; @@ -162,15 +163,20 @@ export const mockWalletFactory = ( }; } + async function* purseUpdates(brand) { + const n = makeNotifier( + E( + purseByBrand.get(brand) || Fail`${q(brand)}`, + ).getCurrentAmountNotifier(), + ); + for await (const amount of n) { + yield amount; + } + } return { deposit: depositFacet, offers: Far('Offers', { executeOffer, addIssuer, tryExit }), - peek: Far('Wallet Peek', { - purseNotifier: brand => - E( - purseByBrand.get(brand) || Fail`${q(brand)}`, - ).getCurrentAmountNotifier(), - }), + peek: Far('Wallet Peek', { purseUpdates }), }; }; @@ -187,6 +193,7 @@ export const seatLike = updates => { payouts: makePromiseKit(), }; (async () => { + await null; try { // XXX an error here is somehow and unhandled rejection for await (const update of updates) {