Skip to content

Commit

Permalink
feat!: generalize ec cmd to gov any committee
Browse files Browse the repository at this point in the history
  • Loading branch information
turadg committed Sep 25, 2023
1 parent ef466d3 commit d14b237
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 18 deletions.
4 changes: 2 additions & 2 deletions packages/agoric-cli/src/bin-agops.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import process from 'process';
import anylogger from 'anylogger';
import { Command, CommanderError, createCommand } from 'commander';
import { makeOracleCommand } from './commands/oracle.js';
import { makeEconomicCommiteeCommand } from './commands/ec.js';
import { makeGovCommand } from './commands/gov.js';
import { makePsmCommand } from './commands/psm.js';
import { makeReserveCommand } from './commands/reserve.js';
import { makeVaultsCommand } from './commands/vaults.js';
Expand All @@ -34,7 +34,7 @@ const program = new Command();
program.name(progname).version('unversioned');

program.addCommand(makeOracleCommand(logger));
program.addCommand(makeEconomicCommiteeCommand(logger));
program.addCommand(makeGovCommand(logger));
program.addCommand(makePerfCommand(logger));
program.addCommand(makePsmCommand(logger));
program.addCommand(makeVaultsCommand(logger));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import {
* delay?: (ms: number) => Promise<void>,
* }} [io]
*/
export const makeEconomicCommiteeCommand = (_logger, io = {}) => {
export const makeGovCommand = (_logger, io = {}) => {
const {
// Allow caller to provide access explicitly, but
// default to conventional ambient IO facilities.
Expand Down Expand Up @@ -127,7 +127,8 @@ export const makeEconomicCommiteeCommand = (_logger, io = {}) => {
};

ec.command('committee')
.description('accept invitation to join the economic committee')
.description('accept invitation to join a committee')
.requiredOption('--name string', 'Committee instance name')
.option('--voter <number>', 'Voter number', Number, 0)
.option(
'--offerId <string>',
Expand All @@ -141,14 +142,16 @@ export const makeEconomicCommiteeCommand = (_logger, io = {}) => {
normalizeAddress,
)
.action(async function (opts) {
const { instanceName } = opts.name;

/** @type {Parameters<typeof processOffer>[0]['toOffer']} */
const toOffer = (agoricNames, current) => {
const instance = agoricNames.instance.economicCommittee;
assert(instance, `missing economicCommittee`);
const instance = agoricNames.instance[instanceName];
assert(instance, `missing ${instanceName}`);

if (current) {
const found = findContinuingIds(current, agoricNames);
abortIfSeen('economicCommittee', found);
abortIfSeen(instanceName, found);
}

return {
Expand All @@ -164,28 +167,31 @@ export const makeEconomicCommiteeCommand = (_logger, io = {}) => {

await processOffer({
toOffer,
instanceName: 'economicCommittee',
instanceName,
...opts,
});
});

ec.command('charter')
.description('accept the charter invitation')
.requiredOption('--name string', 'Charter instance name')
.option('--offerId <string>', 'Offer id', String, `ecCharter-${Date.now()}`)
.option(
'--send-from <name-or-address>',
'Send from address',
normalizeAddress,
)
.action(async function (opts) {
const { instanceName } = opts.name;

/** @type {Parameters<typeof processOffer>[0]['toOffer']} */
const toOffer = (agoricNames, current) => {
const instance = agoricNames.instance.econCommitteeCharter;
assert(instance, `missing econCommitteeCharter`);
const instance = agoricNames.instance[instanceName];
assert(instance, `missing ${instanceName}`);

if (current) {
const found = findContinuingIds(current, agoricNames);
abortIfSeen('econCommitteeCharter', found);
abortIfSeen(instanceName, found);
}

return {
Expand All @@ -201,7 +207,7 @@ export const makeEconomicCommiteeCommand = (_logger, io = {}) => {

await processOffer({
toOffer,
instanceName: 'econCommitteeCharter',
instanceName,
...opts,
});
});
Expand Down Expand Up @@ -249,6 +255,7 @@ export const makeEconomicCommiteeCommand = (_logger, io = {}) => {

ec.command('vote')
.description('vote on a question (hard-coded for now))')
.requiredOption('--committeeName', 'Committee instance name', String)
.option('--offerId <number>', 'Offer id', String, `ecVote-${Date.now()}`)
.requiredOption(
'--forPosition <number>',
Expand Down Expand Up @@ -280,7 +287,7 @@ export const makeEconomicCommiteeCommand = (_logger, io = {}) => {
const toOffer = (agoricNames, current) => {
const cont = current ? findContinuingIds(current, agoricNames) : [];
const votingRight = cont.find(
it => it.instance === agoricNames.instance.economicCommittee,
it => it.instance === agoricNames.instance[opts.committeeName],
);
if (!votingRight) {
console.debug('continuing ids', cont, 'for', current);
Expand Down
10 changes: 5 additions & 5 deletions packages/agoric-cli/test/agops-governance-smoketest.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ set -x
# NB: fee percentages must be at least the governed param values

# Accept invitation to economic committee
bin/agops ec committee --send-from gov1
bin/agops gov committee --name economicCommittee --send-from gov1

# Accept invitation to be a charter member
bin/agops ec charter --send-from gov1
bin/agops gov charter --name economicCommitteeCharter --send-from gov1

### Now we have the continuing invitationMakers saved in the wallet

Expand All @@ -34,7 +34,7 @@ agoric wallet print --file "$PROPOSAL_OFFER"
agoric wallet send --offer "$PROPOSAL_OFFER" --from gov1 --keyring-backend="test"

# vote on the question that was made
bin/agops ec vote --forPosition 0 --send-from gov1 --keyring-backend="test" "$COMMITTEE_OFFER_ID"
bin/agops gov vote --committeeName economicCommittee --forPosition 0 --send-from gov1 --keyring-backend="test" "$COMMITTEE_OFFER_ID"
## wait for the election to be resolved (1m in commands/psm.js)

# FIXME this one failing with: Error: cannot grab 10002ibc/toyellie coins: 0ibc/toyellie is smaller than 10002ibc/toyellie: insufficient funds
Expand Down Expand Up @@ -64,7 +64,7 @@ agoric wallet send --offer "$PROPOSAL_OFFER" --from gov1 --keyring-backend="test
# agoric -B $networkConfig follow published.committees.Economic_Committee.latestQuestion

# vote on the question that was made
bin/agops ec vote --forPosition 0 --send-from gov1 --keyring-backend="test" "$COMMITTEE_OFFER_ID"
bin/agops gov vote --committeeName economicCommittee --forPosition 0 --send-from gov1 --keyring-backend="test" "$COMMITTEE_OFFER_ID"
## wait for the election to be resolved (1m default in commands/psm.js)

# to see the new MintLimit
Expand All @@ -77,4 +77,4 @@ agoric wallet print --file "$PROPOSAL_OFFER"
agoric wallet send --offer "$PROPOSAL_OFFER" --from gov1 --keyring-backend="test"

# Vote for the API call
bin/agops ec vote --forPosition 0 --send-from gov1 --keyring-backend="test" "$COMMITTEE_OFFER_ID"
bin/agops gov vote --committeeName economicCommittee --forPosition 0 --send-from gov1 --keyring-backend="test" "$COMMITTEE_OFFER_ID"

0 comments on commit d14b237

Please sign in to comment.