Skip to content

Commit

Permalink
feat: charter for the PSM, enabling governance (#6090)
Browse files Browse the repository at this point in the history
* feat: charter for the PSM, enabling governance

No tests are included.

* refactor: turn it into a continuing invitation

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
  • Loading branch information
Chris-Hibbert and mergify[bot] authored Sep 1, 2022
1 parent 14b20e6 commit e80b763
Show file tree
Hide file tree
Showing 3 changed files with 81 additions and 1 deletion.
1 change: 1 addition & 0 deletions packages/governance/src/types.js
Original file line number Diff line number Diff line change
Expand Up @@ -521,6 +521,7 @@
* @typedef {object} GovernedContractFacetAccess
* @property {VoteOnParamChanges} voteOnParamChanges
* @property {VoteOnApiInvocation} voteOnApiInvocation
* @property {VoteOnOfferFilter} voteOnOfferFilter
* @property {() => Promise<LimitedCreatorFacet<CF>>} getCreatorFacet - creator
* facet of the governed contract, without the tightly held ability to change
* param values.
Expand Down
80 changes: 80 additions & 0 deletions packages/inter-protocol/src/psm/psmCharter.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
// @ts-check

import '@agoric/governance/src/exported.js';
import '@agoric/zoe/exported.js';
import '@agoric/zoe/src/contracts/exported.js';

import { E, Far } from '@endo/far';

/**
* @file
*
* This contract makes it possible for those who govern the PSM to call for
* votes on changes. A more complete implementation would validate parameters,
* constrain deadlines and possibly split the ability to call for votes into
* separate capabilities for finer grain encapsulation.
*/

/**
* @param {ZCF<{binaryVoteCounterInstallation:Installation}>} zcf
* @param {{psm:GovernedContractFacetAccess<{},{}>}} privateArgs
*/
export const start = async (zcf, privateArgs) => {
const { binaryVoteCounterInstallation: counter } = zcf.getTerms();
const { psm } = privateArgs;

const makeParamInvitaion = () => {
/**
* @param {Record<string, unknown>} params
* @param {bigint} deadline
* @param {{paramPath: { key: string }}} [path]
*/
const voteOnParamChanges = (
params,
deadline,
path = { paramPath: { key: 'governedApi' } },
) => {
return E(psm).voteOnParamChanges(counter, deadline, {
...path,
changes: params,
});
};

return zcf.makeInvitation(
() => Far('param change hook', { voteOnParamChanges }),
'vote on param changes',
);
};

const makeOfferFilterInvitation = () => {
/**
* @param {string[]} strings
* @param {bigint} deadline
*/
const voteOnOfferFilter = (strings, deadline) => {
return E(psm).voteOnOfferFilter(counter, deadline, strings);
};

return zcf.makeInvitation(
() => Far('offer filter hook', { voteOnOfferFilter }),
'vote on offer filter',
);
};

const invitationMakers = Far('PSM Invitation Makers', {
VoteOnParamChange: makeParamInvitaion,
VoteOnPauseOffers: makeOfferFilterInvitation,
});

const charterMemberHandler = seat => {
seat.exit();
return invitationMakers;
};

const creatorFacet = Far('psm charter creator', {
makeCharterMemberInvitation: () =>
zcf.makeInvitation(charterMemberHandler, 'PSM charter member invitation'),
});

return harden({ creatorFacet });
};
1 change: 0 additions & 1 deletion packages/inter-protocol/test/psm/test-governedPsm.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ test('psm block offers w/Governance', async t => {
const invitations = await E(committeeCreator).getVoterInvitations();
const { governorCreatorFacet } = governor;

// @ts-expect-error undeclared type?
const { details } = await E(governorCreatorFacet).voteOnOfferFilter(
installs.counter,
2n,
Expand Down

0 comments on commit e80b763

Please sign in to comment.