Skip to content

Commit

Permalink
Merge pull request #7296 from Agoric/ta/durable-invitationMakers
Browse files Browse the repository at this point in the history
fix(vaults): durable invitationMakers
  • Loading branch information
mergify[bot] authored Mar 31, 2023
2 parents 90e1601 + aec82e8 commit 397b0d0
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 8 deletions.
16 changes: 16 additions & 0 deletions packages/inter-protocol/src/vaultFactory/vaultHolder.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,11 @@ export const prepareVaultHolder = (baggage, marshaller) => {
{
helper: UnguardedHelperI,
holder: HolderI,
invitationMakers: M.interface('invitationMakers', {
AdjustBalances: M.call().returns(M.promise()),
CloseVault: M.call().returns(M.promise()),
TransferVault: M.call().returns(M.promise()),
}),
},
/**
*
Expand Down Expand Up @@ -83,6 +88,17 @@ export const prepareVaultHolder = (baggage, marshaller) => {
return this.state.publisher;
},
},
invitationMakers: {
AdjustBalances() {
return this.facets.holder.makeAdjustBalancesInvitation();
},
CloseVault() {
return this.facets.holder.makeCloseInvitation();
},
TransferVault() {
return this.facets.holder.makeTransferInvitation();
},
},
holder: {
/** @deprecated use getPublicTopics */
getSubscriber() {
Expand Down
16 changes: 8 additions & 8 deletions packages/inter-protocol/src/vaultFactory/vaultKit.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import { makeTracer } from '@agoric/internal';
import '@agoric/zoe/exported.js';
import { Far } from '@endo/marshal';

import { makeTracer } from '@agoric/internal';
import { prepareVaultHolder } from './vaultHolder.js';

const trace = makeTracer('VK', false);

/**
* Wrap the VaultHolder duration object in a record suitable for the result of an invitation.
*
* @param {import('@agoric/ertp').Baggage} baggage
* @param {ERef<Marshaller>} marshaller
Expand All @@ -22,17 +23,16 @@ export const prepareVaultKit = (baggage, marshaller) => {
*/
const makeVaultKit = (vault, storageNode) => {
trace('prepareVaultKit makeVaultKit');
const { holder, helper } = makeVaultHolder(vault, storageNode);
const { holder, helper, invitationMakers } = makeVaultHolder(
vault,
storageNode,
);
const holderTopics = holder.getPublicTopics();
const vaultKit = harden({
publicSubscribers: {
vault: holderTopics.vault,
},
invitationMakers: Far('invitation makers', {
AdjustBalances: () => holder.makeAdjustBalancesInvitation(),
CloseVault: () => holder.makeCloseInvitation(),
TransferVault: () => holder.makeTransferInvitation(),
}),
invitationMakers,
vault: holder,
vaultUpdater: helper.getUpdater(),
});
Expand Down

0 comments on commit 397b0d0

Please sign in to comment.