From 98e940d70b683963b64eb828526dfacc5c80d846 Mon Sep 17 00:00:00 2001 From: Mathieu Hofman <86499+mhofman@users.noreply.github.com> Date: Mon, 18 Nov 2024 21:09:22 +0100 Subject: [PATCH] chore(smart-wallet): less noisy watch outcome (#10515) closes: #10513 ## Description Use `when` instead of `asPromise` in the smart-wallet offer outcome logic. Reduce noise on upgrades for disconnected promises which are not actually used for production logic. ### Security Considerations None ### Scaling Considerations Removes some unnecessary watch bookkepping. ### Documentation Considerations None. Added a comment for maintainers explaining the choice of `when`. ### Testing Considerations Expecting existing tests to keep passing. The only functional difference is the removal of an unnecessary warning diagnostic. ### Upgrade Considerations Requires an upgrade of the walletFactory vat. --- packages/smart-wallet/src/offerWatcher.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/packages/smart-wallet/src/offerWatcher.js b/packages/smart-wallet/src/offerWatcher.js index 4aace001224..38da65c2d77 100644 --- a/packages/smart-wallet/src/offerWatcher.js +++ b/packages/smart-wallet/src/offerWatcher.js @@ -72,13 +72,18 @@ const watchForPayout = ({ paymentWatcher }, seat) => { /** @param {VowTools} vowTools */ export const makeWatchOfferOutcomes = vowTools => { const watchForOfferResult = makeWatchForOfferResult(vowTools); - const { asPromise, allVows } = vowTools; + const { when, allVows } = vowTools; /** * @param {OutcomeWatchers} watchers * @param {UserSeat} seat */ const watchOfferOutcomes = (watchers, seat) => { - return asPromise( + // Use `when` to get a promise from the vow. + // Unlike `asPromise` this doesn't warn in case of disconnections, which is + // fine since we actually handle the outcome durably through the watchers. + // Only the `executeOffer` caller relies on the settlement of this promise, + // and only in tests. + return when( allVows([ watchForOfferResult(watchers, seat), watchForNumWants(watchers, seat),