Skip to content

Commit

Permalink
chore: changes to incorporate governedContractKits
Browse files Browse the repository at this point in the history
  • Loading branch information
rabi-siddique committed Oct 1, 2024
1 parent cd7809e commit 9b9c945
Showing 1 changed file with 18 additions and 54 deletions.
72 changes: 18 additions & 54 deletions packages/inter-protocol/src/proposals/replaceElectorate.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {
makeStorageNodeChild,
} from '@agoric/internal/src/lib-chainStorage.js';
import { reserveThenDeposit } from './utils.js';
import { deeplyFulfilledObject } from '@agoric/internal';

const trace = (...args) => console.log('GovReplaceCommiteeAndCharter', ...args);

Expand Down Expand Up @@ -198,18 +199,7 @@ const startNewEconCharter = async ({
};

const addGovernorsToEconCharter = async (
{
consume: {
reserveKit,
vaultFactoryKit,
auctioneerKit,
psmKit,
provisionPoolStartResult,
},
instance: {
consume: { reserve, VaultFactory, auctioneer, provisionPool },
},
},
{ consume: { psmKit, governedContractKits } },
{ options: { econCharterKit } },
) => {
const { creatorFacet } = E.get(econCharterKit);
Expand All @@ -220,34 +210,15 @@ const addGovernorsToEconCharter = async (
E(creatorFacet).addInstance(psm, psmGovernorCreatorFacet, label);
}

await Promise.all(
[
{
label: 'reserve',
instanceP: reserve,
facetP: E.get(reserveKit).governorCreatorFacet,
},
{
label: 'VaultFactory',
instanceP: VaultFactory,
facetP: E.get(vaultFactoryKit).governorCreatorFacet,
},
{
label: 'auctioneer',
instanceP: auctioneer,
facetP: E.get(auctioneerKit).governorCreatorFacet,
},
{
label: 'provisionPool',
instanceP: provisionPool,
facetP: E.get(provisionPoolStartResult).governorCreatorFacet,
},
].map(async ({ label, instanceP, facetP }) => {
const [instance, govFacet] = await Promise.all([instanceP, facetP]);
const governedContractKitMap = await governedContractKits;

return E(creatorFacet).addInstance(instance, govFacet, label);
}),
);
for (const {
instance,
governorCreatorFacet,
label,
} of governedContractKitMap.values()) {
E(creatorFacet).addInstance(instance, governorCreatorFacet, label);
}
};

export const replaceElectorate = async (permittedPowers, config) => {
Expand All @@ -264,14 +235,16 @@ export const replaceElectorate = async (permittedPowers, config) => {
},
);

const governedContractKitsMap =
await permittedPowers.consume.governedContractKits;
const psmKitMap = await permittedPowers.consume.psmKit;

console.log('RABI', [...governedContractKitsMap.values()]);

const creatorFacets = [
E.get(permittedPowers.consume.reserveKit).governorCreatorFacet,
E.get(permittedPowers.consume.auctioneerKit).governorCreatorFacet,
E.get(permittedPowers.consume.vaultFactoryKit).governorCreatorFacet,
E.get(permittedPowers.consume.provisionPoolStartResult)
.governorCreatorFacet,
...[...governedContractKitsMap.values()].map(
governedContractKit => governedContractKit.governorCreatorFacet,
),
...[...psmKitMap.values()].map(psmKit => psmKit.psmGovernorCreatorFacet),
];

Expand Down Expand Up @@ -317,11 +290,8 @@ export const getManifestForReplaceElectorate = async (_, options) => ({
manifest: {
[replaceElectorate.name]: {
consume: {
reserveKit: true,
auctioneerKit: true,
vaultFactoryKit: true,
psmKit: true,
provisionPoolStartResult: true,
governedContractKits: true,

board: true,
chainStorage: true,
Expand All @@ -347,12 +317,6 @@ export const getManifestForReplaceElectorate = async (_, options) => ({
economicCommittee: true,
econCommitteeCharter: true,
},
consume: {
reserve: true,
VaultFactory: true,
auctioneer: true,
provisionPool: true,
},
},
},
},
Expand Down

0 comments on commit 9b9c945

Please sign in to comment.