Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(run-protocol): extract a vaultKit module #4743

Merged
merged 2 commits into from
Mar 6, 2022

Conversation

turadg
Copy link
Member

@turadg turadg commented Mar 5, 2022

Description

Several refactorings and cleanups. I split across multiple commits to see the flow and I'll autosquash upon approval.

  • extract a vaultKit module
  • make naming more consistent
  • define more types with their constructor functions

Security Considerations

None.

Documentation Considerations

No, implementation details.

Testing Considerations

No changes.

@@ -105,6 +77,28 @@ const makeOuterKit = inner => {
* @property {(oldDebt: Amount, oldCollateral: Amount, vaultId: VaultId) => void} updateVaultPriority
*/

/**
* @typedef {Readonly<{
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I put these in here but stopped short of using them because they're available in closure scope and it doesn't make much sense to change them before factoring out makeMethods or whatever we call it. I may have time for that before Monday if it's worthwhile, though I'd prefer to land the non-state parts of this PR first.

Copy link
Member

@dtribble dtribble left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Generally looks great. I few key minor but important issues.

makeAdjustBalancesInvitation: () =>
owned(vault).makeAdjustBalancesInvitation(),
makeCloseInvitation: () => owned(vault).makeCloseInvitation(),
makeTransferInvitation: () => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adding a comment here would be good: "Starting a transfer revokes the outer vault. The associated updater will get a special notification the the vault is being transferred."

};

/**
*
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Return the kit for a vault in the structure that wallets are expecting

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let me know if you're talking about more than uiNotifier discussed in #4743 (comment) .

export const makeVaultKit = (inner, assetNotifier) => {
const { vault, vaultUpdater } = wrapVault(inner);
const vaultKit = harden({
assetNotifier,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The structure here is not what wallets are expecting. They need uiNotifier. This got renamed, but it means that the wallet doesn't know to treat it specially (in lib-wallet getUINotifier).

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The vault notifications were broken by #4527 because they can no longer rely on one notifier. We discussed multiple designs in the RUN protocol meeting and agreed this was the best option. 554d41e renamed uiNotifier to make it clear to consumers that there was no longer a single notifier for UI.

I think that's the right thing for now for clarity of how the contract works. ("UI updater" is a misnomer.) Updating the UI code is queued up in #4482 which can happen after Restival because UI is not in scope.

* runMint: ZCFMint,
* vaultSeat: ZCFSeat,
* zcf: ContractFacet,
* }>} ImmutableState
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if we should have props a la React for immutable and have separate storage for those!

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Neat idea. We'd need the virtual objects API to send them in. Could be useful for distinguishing between things the contract gets to change vs things it just needs to be provided consistently.

@turadg turadg mentioned this pull request Mar 5, 2022
@turadg turadg requested a review from dtribble March 5, 2022 19:01
@dtribble dtribble force-pushed the ta/extract-vaultKit branch from 33c03fb to 13bdd71 Compare March 5, 2022 22:48
@turadg turadg force-pushed the ta/extract-vaultKit branch from 13bdd71 to 06103d8 Compare March 6, 2022 02:24
@turadg turadg added the automerge:no-update (expert!) Automatically merge without updates label Mar 6, 2022
@mergify mergify bot merged commit 0f87afd into master Mar 6, 2022
@mergify mergify bot deleted the ta/extract-vaultKit branch March 6, 2022 02:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
automerge:no-update (expert!) Automatically merge without updates
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants