Skip to content

Commit

Permalink
fix(walletFactory): move upgrading check before baggage is populated (#…
Browse files Browse the repository at this point in the history
…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
  • Loading branch information
dckc authored Sep 14, 2023
1 parent 386dc7c commit 97cb715
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
2 changes: 1 addition & 1 deletion packages/smart-wallet/src/walletFactory.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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 {
Expand Down
2 changes: 2 additions & 0 deletions packages/smart-wallet/test/supports.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
},
});
Expand Down

0 comments on commit 97cb715

Please sign in to comment.