diff --git a/packages/run-protocol/src/vaultFactory/vault.js b/packages/run-protocol/src/vaultFactory/vault.js index 4e985ac995b..d711762ba54 100644 --- a/packages/run-protocol/src/vaultFactory/vault.js +++ b/packages/run-protocol/src/vaultFactory/vault.js @@ -144,6 +144,7 @@ export const makeInnerVault = ( assertPhase(VaultPhase.ACTIVE); }; + /** @type {IterationObserver | null} */ let outerUpdater; // vaultSeat will hold the collateral until the loan is retired. The @@ -303,6 +304,7 @@ export const makeInnerVault = ( break; case VaultPhase.CLOSED: case VaultPhase.LIQUIDATED: + case VaultPhase.TRANSFER: outerUpdater.finish(uiState); outerUpdater = null; break; @@ -684,7 +686,7 @@ export const makeInnerVault = ( }; const makeTransferInvitationHook = seat => { - assertVaultIsOpen(); + assertPhase(VaultPhase.TRANSFER); seat.exit(); // eslint-disable-next-line no-use-before-define return setupOuter(innerVault); @@ -701,10 +703,8 @@ export const makeInnerVault = ( makeAdjustBalancesInvitation, makeCloseInvitation, makeTransferInvitation: () => { - if (outerUpdater) { - outerUpdater.finish(snapshotState(VaultPhase.TRANSFER)); - outerUpdater = null; - } + assignPhase(VaultPhase.TRANSFER); + updateUiState(); return zcf.makeInvitation(makeTransferInvitationHook, 'TransferVault'); }, diff --git a/packages/run-protocol/test/vaultFactory/test-vaultFactory.js b/packages/run-protocol/test/vaultFactory/test-vaultFactory.js index fc75b55e001..7b0d7d891ed 100644 --- a/packages/run-protocol/test/vaultFactory/test-vaultFactory.js +++ b/packages/run-protocol/test/vaultFactory/test-vaultFactory.js @@ -1277,8 +1277,8 @@ test('transfer vault', async t => { const transferStatus = await E(transferNotifier).getUpdateSince(); t.deepEqual( transferStatus.value.vaultState, - VaultPhase.ACTIVE, - 'new notifier is active', + VaultPhase.TRANSFER, + 'vault now transferrable', ); // Interleave with `adjustVault`