From 84dd2297eb74061b809a11bba3c2d2c5c697219f Mon Sep 17 00:00:00 2001 From: Chris Hibbert Date: Wed, 31 Jan 2024 16:50:36 -0800 Subject: [PATCH] feat: repair KREAd contract on zoe upgrade --- golang/cosmos/app/app.go | 2 ++ .../builders/scripts/vats/revive-kread.js | 13 ++++++++++ packages/vats/src/proposals/kread-proposal.js | 24 +++++++++++++++++++ 3 files changed, 39 insertions(+) create mode 100644 packages/builders/scripts/vats/revive-kread.js create mode 100644 packages/vats/src/proposals/kread-proposal.js diff --git a/golang/cosmos/app/app.go b/golang/cosmos/app/app.go index 1fa72e2d710..6ba478544c2 100644 --- a/golang/cosmos/app/app.go +++ b/golang/cosmos/app/app.go @@ -936,6 +936,8 @@ func unreleasedUpgradeHandler(app *GaiaApp, targetUpgrade string) func(sdk.Conte CoreProposalSteps = []vm.CoreProposalStep{ // Upgrade Zoe + ZCF vm.CoreProposalStepForModules("@agoric/builders/scripts/vats/replace-zoe.js"), + // Revive KREAd characters + vm.CoreProposalStepForModules("@agoric/builders/scripts/vats/revive-kread.js"), // upgrade the provisioning vat vm.CoreProposalStepForModules("@agoric/builders/scripts/vats/replace-provisioning.js"), diff --git a/packages/builders/scripts/vats/revive-kread.js b/packages/builders/scripts/vats/revive-kread.js new file mode 100644 index 00000000000..72d22da477c --- /dev/null +++ b/packages/builders/scripts/vats/revive-kread.js @@ -0,0 +1,13 @@ +import { makeHelpers } from '@agoric/deploy-script-support'; + +/** @type {import('@agoric/deploy-script-support/src/externalTypes.js').CoreEvalBuilder} */ +export const defaultProposalBuilder = async () => + harden({ + sourceSpec: '@agoric/vats/src/proposals/kread-proposal.js', + getManifestCall: ['getManifestForKread'], + }); + +export default async (homeP, endowments) => { + const { writeCoreProposal } = await makeHelpers(homeP, endowments); + await writeCoreProposal('revive-kread', defaultProposalBuilder); +}; diff --git a/packages/vats/src/proposals/kread-proposal.js b/packages/vats/src/proposals/kread-proposal.js new file mode 100644 index 00000000000..7b8affda75a --- /dev/null +++ b/packages/vats/src/proposals/kread-proposal.js @@ -0,0 +1,24 @@ +import { E } from '@endo/far'; + +/** + * @param {BootstrapPowers & { + * consume: { kreadKit: any }; + * }} powers + */ +export const repairKread = async ({ consume: { kreadKit: kreadKitP } }) => { + console.log('repairSubscribers'); + + const kreadKit = await kreadKitP; + const creatorFacet = kreadKit.creatorFacet; + console.log(`KREAd creatorFacet`, creatorFacet); + await E(creatorFacet).reviveMarketExitSubscribers(); + console.log('KREAd subscribers were revived!'); +}; + +export const getManifestForKread = _powers => ({ + manifest: { + [repairKread.name]: { + consume: { kreadKit: true }, + }, + }, +});