Skip to content

Commit

Permalink
chore: minor cleanups in governParam: types, comments, harden
Browse files Browse the repository at this point in the history
  • Loading branch information
Chris-Hibbert committed Aug 26, 2021
1 parent 342de7c commit 6b006d4
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 10 deletions.
20 changes: 10 additions & 10 deletions packages/governance/src/contractGovernor.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,18 +48,18 @@ const validateBallotFromCounter = async (zoe, registrar, ballotCounter) => {
*
* The governedContract is responsible for supplying getParamMgrAccessor() in
* its creatorFacet. getParamMgrAccessor() takes a ParamSpecification, which
* identifies the parameter to be voted on. A minimal ParamSpecification
* specifies the key which identifies a particular paramManager (even if
* there's only one) and the parameterName. The interpretation of
* ParamSpecification is up to the contract.
* identifies the parameter to be voted on. A minimal ParamSpecification
* specifies the key which identifies a particular paramManager (even if there's
* only one) and the parameterName. The interpretation of ParamSpecification is
* up to the contract.
*
* The call to startGovernedInstance() returns a facet with voteOnParamChange(),
* which is used to create ballot questions that will automatically update
* contract parameters if passed. This facet will usually be closely held.
*
* The govened contract's terms include the instance of this (governing)
* contract (as electionManager) so clients will be able to look up the state
* of the governed parameters.
* The governed contract's terms include the instance of this (governing)
* contract (as electionManager) so clients will be able to look up the state
* of the governed parameters.
*
* @type {ContractStartFn}
*/
Expand All @@ -74,7 +74,7 @@ const start = async zcf => {
/** @type {PromiseRecord<Instance>} */
const governedInstancePK = makePromiseKit();

// a predicate that identifies ballots created by this governor
// Promise for a predicate that identifies ballots created by this governor
/** @type {PromiseRecord<CreatedBallot>} */
const createdBallotPK = makePromiseKit();

Expand All @@ -92,10 +92,10 @@ const start = async zcf => {
E.get(E(zoe).getInvitationDetails(poserInvitation)).instance,
);

const augmentedTerms = {
const augmentedTerms = harden({
...customTerms,
electionManager: zcf.getInstance(),
};
});

const { creatorFacet, instance, publicFacet } = await E(zoe).startInstance(
governedContractInstallation,
Expand Down
3 changes: 3 additions & 0 deletions packages/governance/src/governParam.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,11 @@ const validateParamChangeBallot = details => {
);
};

/** @type {AssertBallotConcernsQuestion} */
const assertBallotConcernsQuestion = (paramName, ballotDetails) => {
assert(
// @ts-ignore typescript isn't sure the question is a paramChangeQuestion
// if it isn't, the assertion will fail.
ballotDetails.question.paramSpec.parameterName === paramName,
X`expected ${paramName} to be included`,
);
Expand Down
6 changes: 6 additions & 0 deletions packages/governance/src/types.js
Original file line number Diff line number Diff line change
Expand Up @@ -431,6 +431,12 @@
* contract
*/

/**
* @callback AssertBallotConcernsQuestion
* @param {string} paramName
* @param {BallotDetails} ballotDetails
*/

/**
* @callback StartGovernedContract
* @param {RegistrarCreator} registrarCreatorFacet
Expand Down

0 comments on commit 6b006d4

Please sign in to comment.