Skip to content

Commit

Permalink
chore: minor formatting changes to match master version (#8790)
Browse files Browse the repository at this point in the history
  • Loading branch information
Chris-Hibbert authored Jan 23, 2024
1 parent 81d2080 commit 57d0b3e
Showing 1 changed file with 13 additions and 11 deletions.
24 changes: 13 additions & 11 deletions packages/smart-wallet/src/smartWallet.js
Original file line number Diff line number Diff line change
Expand Up @@ -273,11 +273,12 @@ export const prepareSmartWallet = (baggage, shared) => {

const makeOfferWatcher = prepareOfferWatcher(baggage);

const NotifierShape = M.remotable();
const updateShape = {
value: AmountShape,
updateCount: M.bigint(),
};

const NotifierShape = M.remotable();
const amountWatcherGuard = M.interface('paymentWatcher', {
onFulfilled: M.call(updateShape, NotifierShape).returns(),
onRejected: M.call(M.any(), NotifierShape).returns(M.promise()),
Expand Down Expand Up @@ -534,16 +535,17 @@ export const prepareSmartWallet = (baggage, shared) => {

/** @type {(purse: ERef<Purse>) => Promise<void>} */
async watchPurse(purseRef) {
const purse = await purseRef; // promises don't fit in durable storage

const { helper } = this.facets;
// publish purse's balance and changes

// This would seem to fit the observeNotifier() pattern,
// but purse notifiers are not necessarily durable.
// If there is an error due to upgrade, retry watchPurse().
const notifier = await E(purse).getCurrentAmountNotifier();

const purse = await purseRef; // promises don't fit in durable storage
const handler = makeAmountWatcher(purse, helper);

// publish purse's balance and changes
const notifier = await E(purse).getCurrentAmountNotifier();
const startP = E(notifier).getUpdateSince(undefined);
// @ts-expect-error import watchPromise's type is unknown
watchPromise(startP, handler, notifier);
Expand Down Expand Up @@ -624,10 +626,10 @@ export const prepareSmartWallet = (baggage, shared) => {
*/
async repairUnwatchedSeats() {
const { state, facets } = this;
const { address, invitationPurse } = state;
const { liveOffers, liveOfferSeats } = state;
const { zoe, agoricNames } = shared;
const { invitationBrand, invitationIssuer } = shared;
const { address, invitationPurse, liveOffers, liveOfferSeats } =
state;
const { zoe, agoricNames, invitationBrand, invitationIssuer } =
shared;

const invitationFromSpec = makeInvitationsHelper(
zoe,
Expand Down Expand Up @@ -674,7 +676,7 @@ export const prepareSmartWallet = (baggage, shared) => {
trace(`Found ${brandToPurses.values()} purse(s) for ${address}`);
for (const purses of brandToPurses.values()) {
for (const record of purses) {
helper.watchPurse(record.purse);
void helper.watchPurse(record.purse);
trace(`Repaired purse ${record.petname} of ${address}`);
}
}
Expand Down Expand Up @@ -968,8 +970,8 @@ export const prepareSmartWallet = (baggage, shared) => {
await watchOfferOutcomes(watcher, seatRef);
} catch (err) {
facets.helper.logWalletError('OFFER ERROR:', err);
// Notify the user

// Notify the user
if (err.upgradeMessage === 'vat upgraded') {
// The offer watchers will reconnect. Don't reclaim or exit
return;
Expand Down

0 comments on commit 57d0b3e

Please sign in to comment.