Skip to content

Commit

Permalink
chore(pp-upgrade): create and set a new bridgeHandler in the proposal
Browse files Browse the repository at this point in the history
Refs: #10395
  • Loading branch information
anilhelvaci committed Nov 5, 2024
1 parent 44132c0 commit 28cada0
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 2 deletions.
6 changes: 6 additions & 0 deletions golang/cosmos/app/upgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,12 @@ func unreleasedUpgradeHandler(app *GaiaApp, targetUpgrade string) func(sdk.Conte
// Upgrade to include a cleanup from https://github.com/Agoric/agoric-sdk/pull/10319
"@agoric/builders/scripts/smart-wallet/build-wallet-factory2-upgrade.js",
),
vm.CoreProposalStepForModules(
"@agoric/builders/scripts/vats/upgrade-provisionPool.js",
),
vm.CoreProposalStepForModules(
"@agoric/builders/scripts/vats/upgrade-bank.js",
),
)
}

Expand Down
44 changes: 42 additions & 2 deletions packages/vats/src/proposals/upgrade-provisionPool-proposal.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ export const upgradeProvisionPool = async (
economicCommitteeCreatorFacet: electorateCreatorFacet,
instancePrivateArgs: instancePrivateArgsP,
provisionPoolStartResult: provisionPoolStartResultP,
bankManager,
namesByAddressAdmin: namesByAddressAdminP,
walletFactoryStartResult: walletFactoryStartResultP,
provisionWalletBridgeManager: provisionWalletBridgeManagerP,
},
},
options,
Expand All @@ -25,11 +29,25 @@ export const upgradeProvisionPool = async (
assert(provisionPoolRef.bundleID);
console.log(`PROVISION POOL BUNDLE ID: `, provisionPoolRef.bundleID);

const [provisionPoolStartResult, instancePrivateArgs] = await Promise.all([
const [
provisionPoolStartResult,
instancePrivateArgs,
namesByAddressAdmin,
walletFactoryStartResult,
provisionWalletBridgeManager,
] = await Promise.all([
provisionPoolStartResultP,
instancePrivateArgsP,
namesByAddressAdminP,
walletFactoryStartResultP,
provisionWalletBridgeManagerP,
]);
const { adminFacet, instance } = provisionPoolStartResult;
const {
adminFacet,
instance,
creatorFacet: ppCreatorFacet,
} = provisionPoolStartResult;
const { creatorFacet: wfCreatorFacet } = walletFactoryStartResult;

const [originalPrivateArgs, poserInvitation] = await Promise.all([
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
Expand All @@ -49,6 +67,24 @@ export const upgradeProvisionPool = async (
);

console.log('ProvisionPool upgraded: ', upgradeResult);

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

console.log('Calling setReferences with: ', references);
await E(ppCreatorFacet).setReferences(references);

console.log('Creating bridgeHandler...');
const bridgeHandler = await E(ppCreatorFacet).makeHandler();

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

console.log('Done.');
};

export const getManifestForUpgradingProvisionPool = (
Expand All @@ -61,6 +97,10 @@ export const getManifestForUpgradingProvisionPool = (
economicCommitteeCreatorFacet: true,
instancePrivateArgs: true,
provisionPoolStartResult: true,
bankManager: true,
namesByAddressAdmin: true,
walletFactoryStartResult: true,
provisionWalletBridgeManager: true,
},
produce: {},
},
Expand Down

0 comments on commit 28cada0

Please sign in to comment.