Skip to content

Commit

Permalink
Merge pull request #8649 from Agoric/ta/guard-governorKit
Browse files Browse the repository at this point in the history
feat: guard ContractGovernorKit
  • Loading branch information
mergify[bot] authored Dec 13, 2023
2 parents bc4a41c + f0654e0 commit 55d228c
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 4 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,8 @@ jobs:
path: ./agoric-sdk
- uses: ./agoric-sdk/.github/actions/restore-node
with:
node-version: 18.x
# XXX loadgen not compatible with 18.19 https://github.com/Agoric/agoric-sdk/pull/8365#issuecomment-1848003597
node-version: 18.18
path: ./agoric-sdk
# Forces xsnap to initialize all memory to random data, which increases
# the chances the content of snapshots may deviate between validators
Expand Down
47 changes: 44 additions & 3 deletions packages/governance/src/contractGovernorKit.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,57 @@
import { Fail } from '@agoric/assert';
import { makeTracer } from '@agoric/internal';
import { prepareExoClassKit } from '@agoric/vat-data';
import { UnguardedHelperI, makeTracer } from '@agoric/internal';
import { M, prepareExoClassKit } from '@agoric/vat-data';
import { E } from '@endo/eventual-send';
import {
InvitationShape,
InstanceHandleShape,
InstallationShape,
} from '@agoric/zoe/src/typeGuards.js';
import { TimestampShape } from '@agoric/time';
import { setupApiGovernance } from './contractGovernance/governApi.js';
import { setupFilterGovernance } from './contractGovernance/governFilter.js';
import {
CONTRACT_ELECTORATE,
setupParamGovernance,
} from './contractGovernance/governParam.js';
import { ClosingRuleShape, ParamChangesSpecShape } from './typeGuards.js';

const trace = makeTracer('CGK', false);

const ContractGovernorKitI = {
helper: UnguardedHelperI,
creator: M.interface('Contract Governor Kit creator', {
replaceElectorate: M.call(InvitationShape).returns(M.promise()),
voteOnParamChanges: M.call(
InstallationShape,
TimestampShape,
ParamChangesSpecShape,
).returns(M.promise()),
voteOnApiInvocation: M.call(
M.string(),
M.arrayOf(M.any()),
InstallationShape,
TimestampShape,
).returns(M.promise()),
voteOnOfferFilter: M.call(
InstallationShape,
TimestampShape,
M.arrayOf(M.string()),
).returns(M.promise()),
getCreatorFacet: M.call().returns(M.remotable('ElectorateCreator')),
getAdminFacet: M.call().returns(M.remotable('ElectorateAdmin')),
getInstance: M.call().returns(InstanceHandleShape),
getPublicFacet: M.call().returns(M.remotable('ElectoratePublic')),
}),
public: M.interface('Contract Governor Kit public', {
getElectorate: M.call().returns(M.promise(/* Instance */)),
getGovernedContract: M.call().returns(InstanceHandleShape),
validateVoteCounter: M.call(InstanceHandleShape).returns(M.promise()),
validateElectorate: M.call(InstanceHandleShape).returns(M.promise()),
validateTimer: M.call(ClosingRuleShape).returns(),
}),
};

/**
*
* @param {import('@agoric/vat-data').Baggage} baggage
Expand All @@ -36,7 +77,7 @@ export const prepareContractGovernorKit = (baggage, powers) => {
const makeContractGovernorKit = prepareExoClassKit(
baggage,
'ContractGovernorKit',
undefined,
ContractGovernorKitI,
/**
* @param {import('@agoric/zoe/src/zoeService/utils.js').StartedInstanceKit<GovernableStartFn>} startedInstanceKit
* @param {LimitedCF<unknown>} limitedCreatorFacet
Expand Down

0 comments on commit 55d228c

Please sign in to comment.