Skip to content

Commit

Permalink
fix: tighten invitation proposal patterns
Browse files Browse the repository at this point in the history
  • Loading branch information
erights committed Dec 23, 2022
1 parent 6011664 commit 6b620ad
Show file tree
Hide file tree
Showing 6 changed files with 47 additions and 6 deletions.
15 changes: 13 additions & 2 deletions packages/governance/src/committee.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { makeStore, makeHeapFarInstance, M } from '@agoric/store';
import { natSafeMath } from '@agoric/zoe/src/contractSupport/index.js';
import { E } from '@endo/eventual-send';

import { EmptyProposal } from '@agoric/zoe/src/typeGuards.js';
import { makeHandle } from '@agoric/zoe/src/makeHandle.js';
import {
getOpenQuestions,
Expand Down Expand Up @@ -96,7 +97,12 @@ const start = (zcf, privateArgs) => {
return E(voteCap).submitVote(voterHandle, positions, 1n);
};

return zcf.makeInvitation(continuingVoteHandler, 'vote');
return zcf.makeInvitation(
continuingVoteHandler,
'vote',
undefined,
EmptyProposal,
);
},
},
),
Expand All @@ -107,7 +113,12 @@ const start = (zcf, privateArgs) => {
// This will produce unique descriptions because
// makeCommitteeVoterInvitation() is only called within the following loop,
// which is only called once per Electorate.
return zcf.makeInvitation(offerHandler, `Voter${index}`);
return zcf.makeInvitation(
offerHandler,
`Voter${index}`,
undefined,
EmptyProposal,
);
};

const { committeeName, committeeSize } = zcf.getTerms();
Expand Down
8 changes: 7 additions & 1 deletion packages/governance/src/electorateTools.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { EmptyProposal } from '@agoric/zoe/src/typeGuards';
import { E } from '@endo/eventual-send';
import { deeplyFulfilled, Far } from '@endo/marshal';

Expand Down Expand Up @@ -86,7 +87,12 @@ const getQuestion = (questionHandleP, questionStore) =>
*/
const getPoserInvitation = (zcf, addQuestion) => {
const questionPoserHandler = () => Far(`questionPoser`, { addQuestion });
return zcf.makeInvitation(questionPoserHandler, `questionPoser`);
return zcf.makeInvitation(
questionPoserHandler,
`questionPoser`,
undefined,
EmptyProposal,
);
};

harden(startCounter);
Expand Down
9 changes: 7 additions & 2 deletions packages/governance/src/noActionElectorate.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { makePublishKit } from '@agoric/notifier';
import { makePromiseKit } from '@endo/promise-kit';
import { makeHeapFarInstance } from '@agoric/store';
import { EmptyProposal } from '@agoric/zoe/src/typeGuards.js';

import { ElectoratePublicI, ElectorateCreatorI } from './typeGuards.js';

Expand Down Expand Up @@ -37,8 +38,12 @@ const start = zcf => {

const creatorFacet = makeHeapFarInstance('creatorFacet', ElectorateCreatorI, {
getPoserInvitation() {
return zcf.makeInvitation(() => {},
`noActionElectorate doesn't allow posing questions`);
return zcf.makeInvitation(
() => {},
`noActionElectorate doesn't allow posing questions`,
undefined,
EmptyProposal,
);
},
addQuestion(_instance, _question) {
throw Error(`noActionElectorate doesn't add questions.`);
Expand Down
4 changes: 4 additions & 0 deletions packages/inter-protocol/src/psm/psm.js
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,8 @@ export const start = async (zcf, privateArgs, baggage) => {
M.splitRecord({
give: { In: anchorAmountShape },
want: M.or({ Out: stableAmountShape }, {}),
multiples: 1n,
exit: M.any(),
}),
);
},
Expand All @@ -271,6 +273,8 @@ export const start = async (zcf, privateArgs, baggage) => {
M.splitRecord({
give: { In: stableAmountShape },
want: M.or({ Out: anchorAmountShape }, {}),
multiples: 1n,
exit: M.any(),
}),
);
},
Expand Down
11 changes: 10 additions & 1 deletion packages/zoe/src/contractSupport/zoeHelpers.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import { fit, keyEQ } from '@agoric/store';
import '../../exported.js';

import { fit, keyEQ, M } from '@agoric/store';
import { E } from '@endo/eventual-send';
import { makePromiseKit } from '@endo/promise-kit';
import { AssetKind } from '@agoric/ertp';
Expand Down Expand Up @@ -220,6 +222,13 @@ export const depositToSeat = async (zcf, recipientSeat, amounts, payments) => {
const invitation = zcf.makeInvitation(
reallocateAfterDeposit,
'temporary seat for deposit',
undefined,
harden({
give: M.any(),
want: {},
multiples: 1n,
exit: { onDemand: null },
}),
);
const proposal = harden({ give: amounts });
harden(payments);
Expand Down
6 changes: 6 additions & 0 deletions packages/zoe/src/typeGuards.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,12 @@ export const FullProposalShape = harden({
});
/** @see {Proposal} type */
export const ProposalShape = M.splitRecord({}, FullProposalShape, {});
export const EmptyProposal = harden({
give: {},
want: {},
multiples: 1n,
exit: { onDemand: null },
});

export const isOnDemandExitRule = exit => {
const [exitKey] = Object.keys(exit);
Expand Down

0 comments on commit 6b620ad

Please sign in to comment.