From d1ebf5968791e0898b43a2a6977338dfba859fb3 Mon Sep 17 00:00:00 2001 From: Turadg Aleahmad Date: Tue, 12 Dec 2023 08:29:28 -0800 Subject: [PATCH] feat: guard ContractGovernorKit --- .../governance/src/contractGovernorKit.js | 47 +++++++++++++++++-- 1 file changed, 44 insertions(+), 3 deletions(-) diff --git a/packages/governance/src/contractGovernorKit.js b/packages/governance/src/contractGovernorKit.js index 1f5f5d900d35..14cc3d799110 100644 --- a/packages/governance/src/contractGovernorKit.js +++ b/packages/governance/src/contractGovernorKit.js @@ -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 @@ -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} startedInstanceKit * @param {LimitedCF} limitedCreatorFacet