From 330b7a26da9a8eefb95e3e0fd082714fdfad7873 Mon Sep 17 00:00:00 2001 From: Dan Connolly Date: Thu, 14 Sep 2023 13:59:06 -0500 Subject: [PATCH] fix(walletFactory): move upgrading check before baggage is populated (#8322) * fix(walletFactory): move upgrading check before baggage is populated The `baggage.has('walletsByAddress')` check has to come before the `provideDurableMapStore(baggage, 'walletsByAddress')` call. * test(smart-wallet): fake bridge manager detects handler not set ... and handler already set * fixup! test(smart-wallet): fake bridge manager detects handler not set --- packages/smart-wallet/src/walletFactory.js | 2 +- packages/smart-wallet/test/supports.js | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/smart-wallet/src/walletFactory.js b/packages/smart-wallet/src/walletFactory.js index b7ad6709bd6..bc9cb0c8c48 100644 --- a/packages/smart-wallet/src/walletFactory.js +++ b/packages/smart-wallet/src/walletFactory.js @@ -142,6 +142,7 @@ export const makeAssetRegistry = assetPublisher => { * @param {import('@agoric/vat-data').Baggage} baggage */ export const prepare = async (zcf, privateArgs, baggage) => { + const upgrading = baggage.has('walletsByAddress'); const { agoricNames, board, assetPublisher } = zcf.getTerms(); const zoe = zcf.getZoeService(); @@ -292,7 +293,6 @@ export const prepare = async (zcf, privateArgs, baggage) => { if (walletBridgeManager) { // NB: may not be in service when creatorFacet is used, or ever // It can't be awaited because that fails vat restart - const upgrading = baggage.has('walletsByAddress'); if (upgrading) { void E(walletBridgeManager).setHandler(handleWalletAction); } else { diff --git a/packages/smart-wallet/test/supports.js b/packages/smart-wallet/test/supports.js index dd51dc9c75e..6c8e7a8d03c 100644 --- a/packages/smart-wallet/test/supports.js +++ b/packages/smart-wallet/test/supports.js @@ -76,9 +76,11 @@ const makeFakeBridgeManager = () => return E(handler).fromBridge(obj); }, initHandler(newHandler) { + !handler || Fail`Handler already set`; handler = newHandler; }, setHandler(newHandler) { + !!handler || Fail`Handler not set`; handler = newHandler; }, });