Skip to content

Commit

Permalink
chore(provisionPool): update core-eval proposal to add governedParamO…
Browse files Browse the repository at this point in the history
…verrides
  • Loading branch information
Jorge-Lopes committed Dec 6, 2024
1 parent a1dc718 commit 197aa4b
Showing 1 changed file with 21 additions and 7 deletions.
28 changes: 21 additions & 7 deletions packages/vats/src/proposals/upgrade-provisionPool-proposal.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { E } from '@endo/far';
import { deeplyFulfilled } from '@endo/marshal';
import { makeTracer } from '@agoric/internal';

const tracer = makeTracer('UpgradeProvisionPool');
const trace = makeTracer('UpgradeProvisionPool');

/**
* @param {BootstrapPowers & {
Expand Down Expand Up @@ -30,7 +30,7 @@ export const upgradeProvisionPool = async (
const { provisionPoolRef } = options.options;

assert(provisionPoolRef.bundleID);
tracer(`PROVISION POOL BUNDLE ID: `, provisionPoolRef);
trace(`PROVISION POOL BUNDLE ID: `, provisionPoolRef);

const [
provisionPoolStartResult,
Expand All @@ -45,9 +45,11 @@ export const upgradeProvisionPool = async (
walletFactoryStartResultP,
provisionWalletBridgeManagerP,
]);

const {
adminFacet,
instance,
publicFacet: ppPublicFacet,
creatorFacet: ppCreatorFacet,
} = provisionPoolStartResult;
const { creatorFacet: wfCreatorFacet } = walletFactoryStartResult;
Expand All @@ -59,35 +61,47 @@ export const upgradeProvisionPool = async (
E(electorateCreatorFacet).getPoserInvitation(),
]);

const readCurrentGovernedParams = async () => {
await null;

const params = await E(ppPublicFacet).getGovernedParams();
return harden({
PerAccountInitialAmount: params.PerAccountInitialAmount.value,
});
};
const governedParamOverrides = await readCurrentGovernedParams();
trace('governedParamOverrides: ', { governedParamOverrides });

const newPrivateArgs = harden({
...originalPrivateArgs,
initialPoserInvitation: poserInvitation,
governedParamOverrides,
});

const upgradeResult = await E(adminFacet).upgradeContract(
provisionPoolRef.bundleID,
newPrivateArgs,
);

tracer('ProvisionPool upgraded: ', upgradeResult);
trace('ProvisionPool upgraded: ', upgradeResult);

const references = {
bankManager,
namesByAddressAdmin,
walletFactory: wfCreatorFacet,
};

tracer('Calling setReferences with: ', references);
trace('Calling setReferences with: ', references);
await E(ppCreatorFacet).setReferences(references);

tracer('Creating bridgeHandler...');
trace('Creating bridgeHandler...');
const bridgeHandler = await E(ppCreatorFacet).makeHandler();

tracer('Setting new bridgeHandler...');
trace('Setting new bridgeHandler...');
// @ts-expect-error casting
await E(provisionWalletBridgeManager).setHandler(bridgeHandler);

tracer('Done.');
trace('Done.');
};

export const getManifestForUpgradingProvisionPool = (
Expand Down

0 comments on commit 197aa4b

Please sign in to comment.