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 Oct 20, 2022
1 parent 6108ad2 commit 30f1a1f
Show file tree
Hide file tree
Showing 8 changed files with 68 additions and 14 deletions.
15 changes: 13 additions & 2 deletions packages/governance/src/committee.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,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 @@ -92,7 +93,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 @@ -103,7 +109,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,5 +1,6 @@
// @ts-check

import { EmptyProposal } from '@agoric/zoe/src/typeGuards';
import { E } from '@endo/eventual-send';
import { deeplyFulfilled, Far } from '@endo/marshal';

Expand Down Expand Up @@ -69,7 +70,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
Expand Up @@ -3,6 +3,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 @@ -39,8 +40,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
8 changes: 6 additions & 2 deletions packages/inter-protocol/src/psm/psm.js
Original file line number Diff line number Diff line change
Expand Up @@ -275,9 +275,11 @@ export const start = async (zcf, privateArgs, baggage) => {
wantmintedHook,
'wantMinted',
undefined,
M.split({
harden({
give: { In: anchorAmountShape },
want: M.or({ Out: stableAmountShape }, {}),
multiples: 1n,
exit: M.any(),
}),
);
},
Expand All @@ -286,9 +288,11 @@ export const start = async (zcf, privateArgs, baggage) => {
giveMintedHook,
'giveMinted',
undefined,
M.split({
harden({
give: { In: stableAmountShape },
want: M.or({ Out: anchorAmountShape }, {}),
multiples: 1n,
exit: M.any(),
}),
);
},
Expand Down
21 changes: 18 additions & 3 deletions packages/inter-protocol/src/psm/psmCharter.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@ import '@agoric/governance/src/exported.js';
import { makeScalarMapStore, M, makeHeapFarInstance, fit } from '@agoric/store';
import '@agoric/zoe/exported.js';
import '@agoric/zoe/src/contracts/exported.js';
import { InstanceHandleShape } from '@agoric/zoe/src/typeGuards.js';
import {
EmptyProposal,
InstanceHandleShape,
} from '@agoric/zoe/src/typeGuards.js';
import { BrandShape } from '@agoric/ertp';
import { TimestampShape } from '@agoric/swingset-vat/src/vats/timer/typeGuards.js';
import { E } from '@endo/far';
Expand Down Expand Up @@ -68,7 +71,12 @@ export const start = async zcf => {
});
};

return zcf.makeInvitation(voteOnParamChanges, 'vote on param changes');
return zcf.makeInvitation(
voteOnParamChanges,
'vote on param changes',
undefined,
EmptyProposal,
);
};

const makeOfferFilterInvitation = (instance, strings, deadline) => {
Expand All @@ -79,7 +87,12 @@ export const start = async zcf => {
return E(psmGovernor).voteOnOfferFilter(counter, deadline, strings);
};

return zcf.makeInvitation(voteOnOfferFilterHandler, 'vote on offer filter');
return zcf.makeInvitation(
voteOnOfferFilterHandler,
'vote on offer filter',
undefined,
EmptyProposal,
);
};

const MakerShape = M.interface('PSM Charter InvitationMakers', {
Expand Down Expand Up @@ -129,6 +142,8 @@ export const start = async zcf => {
zcf.makeInvitation(
charterMemberHandler,
'PSM charter member invitation',
undefined,
EmptyProposal,
),
},
);
Expand Down
6 changes: 3 additions & 3 deletions packages/inter-protocol/test/psm/test-psm.js
Original file line number Diff line number Diff line change
Expand Up @@ -624,7 +624,7 @@ test('wrong give giveMintedInvitation', async t => {
),
{
message:
'"giveMinted" proposal: required-parts: give: In: brand: "[Alleged: aUSD brand]" - Must be: "[Alleged: IST brand]"',
'"giveMinted" proposal: give: In: brand: "[Alleged: aUSD brand]" - Must be: "[Alleged: IST brand]"',
},
);
});
Expand Down Expand Up @@ -654,7 +654,7 @@ test('wrong give wantMintedInvitation', async t => {
),
{
message:
'"wantMinted" proposal: required-parts: give: In: brand: "[Alleged: IST brand]" - Must be: "[Alleged: aUSD brand]"',
'"wantMinted" proposal: give: In: brand: "[Alleged: IST brand]" - Must be: "[Alleged: aUSD brand]"',
},
);
});
Expand All @@ -676,7 +676,7 @@ test('extra give wantMintedInvitation', async t => {
),
{
message:
'"wantMinted" proposal: required-parts: give: {"Extra":{"brand":"[Alleged: aUSD brand]","value":"[200000000n]"},"In":{"brand":"[Seen]","value":"[200000000n]"}} - Must not have unexpected properties: ["Extra"]',
'"wantMinted" proposal: give: {"Extra":{"brand":"[Alleged: aUSD brand]","value":"[200000000n]"},"In":{"brand":"[Seen]","value":"[200000000n]"}} - Must not have unexpected properties: ["Extra"]',
},
);
});
9 changes: 8 additions & 1 deletion packages/zoe/src/contractSupport/zoeHelpers.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// @ts-check
import '../../exported.js';

import { fit, keyEQ } from '@agoric/store';
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 @@ -219,6 +219,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 @@ -45,6 +45,12 @@ export const FullProposalShape = harden({
});
/** @see {Proposal} type */
export const ProposalShape = M.partial(FullProposalShape);
export const EmptyProposal = harden({
give: {},
want: {},
multiples: 1n,
exit: { onDemand: null },
});

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

0 comments on commit 30f1a1f

Please sign in to comment.