Skip to content

Commit

Permalink
fix(governance): governor adminFacet handling
Browse files Browse the repository at this point in the history
  • Loading branch information
turadg committed May 11, 2023
1 parent f580497 commit e2b3e34
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 9 deletions.
3 changes: 2 additions & 1 deletion packages/governance/src/types-ambient.js
Original file line number Diff line number Diff line change
Expand Up @@ -721,9 +721,10 @@
* @template {GovernableStartFn} SF
* @typedef GovernanceFacetKit
* Akin to StartedInstanceKit but designed for the results of starting governed contracts. Used in bootstrap space.
* @property {AdminFacet} adminFacet of the governing contract
* @property {AdminFacet} adminFacet of the governed contract
* @property {LimitedCF<SF>} creatorFacet creator-like facet within the governed contract (without the powers the governor needs)
* @property {GovernorCreatorFacet<SF>} governorCreatorFacet of the governing contract
* @property {AdminFacet} governorAdminFacet of the governing contract
* @property {Awaited<ReturnType<SF>>['publicFacet']} publicFacet
* @property {Instance} instance
* @property {Instance} governor
Expand Down
27 changes: 19 additions & 8 deletions packages/inter-protocol/src/proposals/econ-behaviors.js
Original file line number Diff line number Diff line change
Expand Up @@ -144,12 +144,15 @@ export const setupReserve = async ({

reserveKit.resolve(
harden({
label: 'AssetReserve',
instance,
governor: g.instance,
publicFacet,
creatorFacet,
governorCreatorFacet: g.creatorFacet,
adminFacet: g.adminFacet,

governor: g.instance,
governorCreatorFacet: g.creatorFacet,
governorAdminFacet: g.adminFacet,
}),
);

Expand Down Expand Up @@ -295,7 +298,7 @@ export const startVaultFactory = async (
const {
creatorFacet: governorCreatorFacet,
instance: governorInstance,
adminFacet,
adminFacet: governorAdminFacet,
} = await E(consume.zoe).startInstance(
contractGovernorInstallation,
undefined,
Expand All @@ -307,11 +310,12 @@ export const startVaultFactory = async (
'vaultFactory.governor',
);

const [vaultFactoryInstance, vaultFactoryCreator, publicFacet] =
const [vaultFactoryInstance, vaultFactoryCreator, publicFacet, adminFacet] =
await Promise.all([
E(governorCreatorFacet).getInstance(),
E(governorCreatorFacet).getCreatorFacet(),
E(governorCreatorFacet).getPublicFacet(),
E(governorCreatorFacet).getAdminFacet(),
]);

const { instancePrivateArgs } = await consume.diagnostics;
Expand All @@ -320,12 +324,16 @@ export const startVaultFactory = async (

vaultFactoryKit.resolve(
harden({
label: 'VaultFactory',

creatorFacet: vaultFactoryCreator,
governorCreatorFacet,
adminFacet,
publicFacet,
governor: governorInstance,
instance: vaultFactoryInstance,
governor: governorInstance,
governorAdminFacet,
governorCreatorFacet,

// XXX try refactoring to use instancePrivateArgs
privateArgs: vaultFactoryPrivateArgs,
}),
Expand Down Expand Up @@ -590,12 +598,15 @@ export const startAuctioneer = async (

auctioneerKit.resolve(
harden({
label: 'auctioneer',
creatorFacet: governedCreatorFacet,
governorCreatorFacet: governorStartResult.creatorFacet,
adminFacet: governorStartResult.adminFacet,
publicFacet: governedPublicFacet,
governor: governorStartResult.instance,
instance: governedInstance,

governor: governorStartResult.instance,
governorCreatorFacet: governorStartResult.creatorFacet,
governorAdminFacet: governorStartResult.adminFacet,
}),
);

Expand Down
1 change: 1 addition & 0 deletions packages/vats/src/core/basic-behaviors.js
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,7 @@ const startGovernedInstance = async (
creatorFacet,
adminFacet,
governorCreatorFacet: governorFacets.creatorFacet,
governorAdminFacet: governorFacets.adminFacet,
};
return facets;
};
Expand Down

0 comments on commit e2b3e34

Please sign in to comment.