diff --git a/packages/vats/src/vat-zoe.js b/packages/vats/src/vat-zoe.js index cb9973e628c..7591b2837b5 100644 --- a/packages/vats/src/vat-zoe.js +++ b/packages/vats/src/vat-zoe.js @@ -6,15 +6,17 @@ const BUILD_PARAMS_KEY = 'buildZoeParams'; export function buildRootObject(vatPowers, _vatParams, zoeBaggage) { const shutdownZoeVat = vatPowers.exitVatWithFailure; + let zoeConfigFacet; + if (zoeBaggage.has(BUILD_PARAMS_KEY)) { const { feeIssuerConfig, zcfSpec } = zoeBaggage.get(BUILD_PARAMS_KEY); - makeDurableZoeKit({ + ({ zoeConfigFacet } = makeDurableZoeKit({ // For now Zoe will rewire vatAdminSvc on its own shutdownZoeVat, feeIssuerConfig, zcfSpec, zoeBaggage, - }); + })); } return Far('root', { @@ -44,5 +46,6 @@ export function buildRootObject(vatPowers, _vatParams, zoeBaggage) { feeMintAccess, }); }, + getZoeConfigFacet: () => zoeConfigFacet, }); } diff --git a/packages/zoe/src/zoeService/zoe.js b/packages/zoe/src/zoeService/zoe.js index 3be3b3df349..8364cc6b5ae 100644 --- a/packages/zoe/src/zoeService/zoe.js +++ b/packages/zoe/src/zoeService/zoe.js @@ -18,6 +18,7 @@ import '../internal-types.js'; import { E } from '@endo/eventual-send'; import { Far } from '@endo/marshal'; import { makeScalarBigMapStore, prepareExo } from '@agoric/vat-data'; +import { M } from '@agoric/store'; import { makeZoeStorageManager } from './zoeStorageManager.js'; import { makeStartInstance } from './startInstance.js'; @@ -32,7 +33,7 @@ import { ZoeServiceI } from '../typeGuards.js'; const { Fail } = assert; /** - * Create an durable instance of Zoe. + * Create a durable instance of Zoe. * * @param {object} options * @param {Baggage} options.zoeBaggage - the baggage for Zoe durability. Must be provided by caller @@ -52,6 +53,7 @@ const makeDurableZoeKit = ({ feeIssuerConfig = defaultFeeIssuerConfig, zcfSpec = { name: 'zcf' }, }) => { + /** @type {BundleCap} */ let zcfBundleCap; const saveBundleCap = () => { @@ -168,6 +170,24 @@ const makeDurableZoeKit = ({ }); }; + const ZoeConfigI = M.interface('ZoeConfigFacet', { + updateZcfBundleId: M.call(M.string()).returns(), + }); + + const zoeConfigFacet = prepareExo(zoeBaggage, 'ZoeConfigFacet', ZoeConfigI, { + updateZcfBundleId(bundleId) { + E.when( + getZcfBundleCap({ id: bundleId }, vatAdminSvc), + bundleCap => { + zcfBundleCap = bundleCap; + }, + e => { + console.warn(`unable to update ZCF Bundle: `, e); + }, + ); + }, + }); + /** @type {ZoeService} */ const zoeService = prepareExo(zoeBaggage, 'ZoeService', ZoeServiceI, { install(bundleId, bundleLabel) { @@ -223,6 +243,7 @@ const makeDurableZoeKit = ({ return harden({ zoeService, + zoeConfigFacet, /** @type {FeeMintAccess} */ // @ts-expect-error cast feeMintAccess: feeMintKit.feeMintAccess,