Skip to content

Commit

Permalink
feat: upgrade zcf: install bundle and call updateZcfBundleId()
Browse files Browse the repository at this point in the history
copied from #9250.
  • Loading branch information
Chris-Hibbert committed Apr 18, 2024
1 parent 34ce82d commit 7debf1d
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 1 deletion.
3 changes: 2 additions & 1 deletion golang/cosmos/app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -857,7 +857,8 @@ func upgrade15Handler(app *GaiaApp, targetUpgrade string) func(sdk.Context, upgr
// Each CoreProposalStep runs sequentially, and can be constructed from
// one or more modules executing in parallel within the step.
CoreProposalSteps = []vm.CoreProposalStep{
// empty for now
// Upgrade ZCF only
vm.CoreProposalStepForModules("@agoric/vats/scripts/upgrade-zcf.js"),
}
}

Expand Down
18 changes: 18 additions & 0 deletions packages/vats/scripts/upgrade-zcf.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { makeHelpers } from '@agoric/deploy-script-support';

/** @type {import('packages/deploy-script-support/src/externalTypes.js').ProposalBuilder} */
export const defaultProposalBuilder = async ({ publishRef, install }) =>
harden({
sourceSpec: '@agoric/vats/src/proposals/zcf-only-proposal.js',
getManifestCall: [
'getManifestForUpgradingZcf',
{
zcfRef: publishRef(install('@agoric/zoe/src/contractFacet/vatRoot.js')),
},
],
});

export default async (homeP, endowments) => {
const { writeCoreProposal } = await makeHelpers(homeP, endowments);
await writeCoreProposal('upgrade-zcf', defaultProposalBuilder);
};
36 changes: 36 additions & 0 deletions packages/vats/src/proposals/zcf-only-proposal.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
// @ts-check
import { E } from '@endo/far';

/**
* @param {BootstrapPowers} powers
* @param {object} options
* @param {{ zcfRef: VatSourceRef }} options.options
*/
export const upgradeZcfOnly = async ({ consume: { vatStore } }, options) => {
const { zcfRef } = options.options;

const { root: zoeRoot } = await E(vatStore).get('zoe');

const zoeConfigFacet = await E(zoeRoot).getZoeConfigFacet();
await E(zoeConfigFacet).updateZcfBundleId(zcfRef.bundleID);
console.log(`ZCF BUNDLE ID: `, zcfRef.bundleID);
};
harden(upgradeZcfOnly);

// main and permit are for use with rollup-plugin-core-eval.js
export const main = upgradeZcfOnly;

export const permit = {
consume: {
vatStore: true,
},
};

export const manifest = {
[upgradeZcfOnly.name]: permit,
};

export const getManifestForUpgradingZcf = (_powers, options) => ({
manifest,
options,
});

0 comments on commit 7debf1d

Please sign in to comment.