Skip to content

Commit

Permalink
feat: add noAction electorate for assurance of no governance changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Chris-Hibbert committed Oct 6, 2021
1 parent 8345ecd commit 3ca89e8
Show file tree
Hide file tree
Showing 3 changed files with 64 additions and 9 deletions.
53 changes: 53 additions & 0 deletions packages/governance/src/noActionElectorate.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
// @ts-check

import { Far } from '@agoric/marshal';
import { makeSubscriptionKit } from '@agoric/notifier';
import { makePromiseKit } from '@agoric/promise-kit';

/**
* This Electorate visibly has no members, takes no votes, and approves no
* changes.
*
* @type {ContractStartFn}
*/
const start = zcf => {
const { subscription } = makeSubscriptionKit();

/** @type {ElectoratePublic} */
const publicFacet = Far('publicFacet', {
getQuestionSubscription: () => subscription,
getOpenQuestions: () => {
/** @type {Handle<'Question'>[]} */
const noQuestions = [];
const questionsPromise = makePromiseKit();
questionsPromise.resolve(noQuestions);
return questionsPromise.promise;
},
getName: () => 'no Action electorate',
getInstance: zcf.getInstance,
getQuestion: () => {
throw Error(`noActionElectorate doesn't have questions.`);
},
});

/** @type {ElectorateCreatorFacet} */
const creatorFacet = Far('creatorFacet', {
getPoserInvitation: () => {
return zcf.makeInvitation(() => {},
`noActionElectorate doesn't allow posing questions`);
},
addQuestion() {
throw Error(`noActionElectorate doesn't add questions.`);
},
getVoterInvitations: () => {
throw Error(`No Action Electorate doesn't have invitations.`);
},
getQuestionSubscription: () => subscription,
getPublicFacet: () => publicFacet,
});

return { publicFacet, creatorFacet };
};

harden(start);
export { start };
16 changes: 7 additions & 9 deletions packages/treasury/bundles/install-on-chain.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import liquidateBundle from './bundle-liquidateMinimum.js';
import autoswapBundle from './bundle-multipoolAutoswap.js';
import stablecoinBundle from './bundle-stablecoinMachine.js';
import contractGovernorBundle from './bundle-contractGovernor.js';
import committeeBundle from './bundle-committee.js';
import noActionElectorateBundle from './bundle-noActionElectorate.js';
import binaryVoteCounterBundle from './bundle-binaryVoteCounter.js';
import { governedParameterTerms } from '../src/params';
import { Far } from '@agoric/marshal';
Expand Down Expand Up @@ -66,7 +66,7 @@ export async function installOnChain({
['autoswap', autoswapBundle],
['stablecoin', stablecoinBundle],
['contractGovernor', contractGovernorBundle],
['committee', committeeBundle],
['noActionElectorate', noActionElectorateBundle],
['binaryCounter', binaryVoteCounterBundle],

];
Expand All @@ -75,7 +75,7 @@ export async function installOnChain({
autoswapInstall,
stablecoinMachineInstall,
contractGovernorInstall,
committeeInstall,
noActionElectorateInstall,
binaryCounterInstall,
] = await Promise.all(
nameBundles.map(async ([name, bundle]) => {
Expand All @@ -88,14 +88,12 @@ export async function installOnChain({
}),
);

const electorateTerms = { committeeName: 'TreasuryBoard', committeeSize: 5 };
// The electorateCreatorFacet has `getVoterInvitations()`, which returns
// invitations for the people who can vote on changes to the treasury. We
// don't currently hand those out to anyone, but that is not visible on chain.
// The Electorate is a no-action electorate, so the testNet runs without
// anyone having the ability to change the treasury's parameters.
const {
creatorFacet: electorateCreatorFacet,
instance: electorateInstance,
} = await E(zoeWPurse).startInstance(committeeInstall, {}, electorateTerms);
} = await E(zoeWPurse).startInstance(noActionElectorateInstall);

const loanParams = {
chargingPeriod: SECONDS_PER_HOUR,
Expand Down Expand Up @@ -167,7 +165,7 @@ export async function installOnChain({
['AMM_INSTALLATION_BOARD_ID', autoswapInstall],
['LIQ_INSTALLATION_BOARD_ID', liquidationInstall],
['BINARY_COUNTER_INSTALLATION_BOARD_ID', binaryCounterInstall],
['COMMITTEE_INSTALLATION_BOARD_ID', committeeInstall],
['NO_ACTION_INSTALLATION_BOARD_ID', noActionElectorateInstall],
['CONTRACT_GOVERNOR_INSTALLATION_BOARD_ID', contractGovernorInstall],
['AMM_INSTANCE_BOARD_ID', ammInstance],
['INVITE_BRAND_BOARD_ID', E(invitationIssuer).getBrand()],
Expand Down
4 changes: 4 additions & 0 deletions packages/treasury/scripts/build-bundles.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,10 @@ async function main() {
'@agoric/governance/src/committee.js',
`${dirname}/../bundles/bundle-committee.js`,
],
[
'@agoric/governance/src/noActionElectorate.js',
`${dirname}/../bundles/bundle-noActionElectorate.js`,
],
[
'@agoric/governance/src/binaryVoteCounter.js',
`${dirname}/../bundles/bundle-binaryVoteCounter.js`,
Expand Down

0 comments on commit 3ca89e8

Please sign in to comment.