diff --git a/a3p-integration/proposals/z:acceptance/governance.test.js b/a3p-integration/proposals/z:acceptance/governance.test.js index 353590370eb..f55e2a492c6 100644 --- a/a3p-integration/proposals/z:acceptance/governance.test.js +++ b/a3p-integration/proposals/z:acceptance/governance.test.js @@ -3,7 +3,7 @@ import test from 'ava'; import { makeWalletUtils } from '@agoric/client-utils'; -import { GOV1ADDR, GOV2ADDR } from '@agoric/synthetic-chain'; +import { evalBundles, getDetailsMatchingVats, GOV1ADDR, GOV2ADDR, waitForBlock } from '@agoric/synthetic-chain'; import { makeGovernanceDriver } from './test-lib/governance.js'; import { networkConfig } from './test-lib/index.js'; import { makeTimerUtils } from './test-lib/utils.js'; @@ -106,3 +106,16 @@ test.serial( t.like(latestOutcome, { outcome: 'win' }); }, ); + +test.only('dummy Reserve', async t => { + + console.log('Log: Before ', await getDetailsMatchingVats('reserve')); + + await evalBundles('upgrade-reserve'); + + await waitForBlock(10); + + console.log('Log: After ', await getDetailsMatchingVats('reserve')); + + t.pass(); +}); diff --git a/a3p-integration/proposals/z:acceptance/package.json b/a3p-integration/proposals/z:acceptance/package.json index c1f8a54ce1d..daa0374ef33 100644 --- a/a3p-integration/proposals/z:acceptance/package.json +++ b/a3p-integration/proposals/z:acceptance/package.json @@ -4,7 +4,8 @@ "sdk-generate": [ "testing/start-valueVow.js start-valueVow", "vats/test-localchain.js localchaintest-submission", - "testing/restart-valueVow.js restart-valueVow" + "testing/restart-valueVow.js restart-valueVow", + "testing/upgrade-reserve.js upgrade-reserve" ] }, "type": "module", diff --git a/packages/builders/scripts/testing/upgrade-reserve.js b/packages/builders/scripts/testing/upgrade-reserve.js new file mode 100644 index 00000000000..e54b5fc17bc --- /dev/null +++ b/packages/builders/scripts/testing/upgrade-reserve.js @@ -0,0 +1,24 @@ +import { makeHelpers } from '@agoric/deploy-script-support'; + +/** @type {import('@agoric/deploy-script-support/src/externalTypes.js').CoreEvalBuilder} */ +export const defaultProposalBuilder = async ({ publishRef, install }) => + harden({ + sourceSpec: '@agoric/vats/src/proposals/upgrade-reserve-proposal.js', + getManifestCall: [ + 'getManifestForReserveUpgrade', + { + contractRef: publishRef( + install( + '@agoric/inter-protocol/src/reserve/assetReserve.js', + '../../inter-protocol/bundles/bundle-reserve.js', + ), + ), + }, + ], + }); + +/** @type {import('@agoric/deploy-script-support/src/externalTypes.js').DeployScriptFunction} */ +export default async (homeP, endowments) => { + const { writeCoreEval } = await makeHelpers(homeP, endowments); + await writeCoreEval('upgrade-reserve', defaultProposalBuilder); +}; diff --git a/packages/vats/src/proposals/upgrade-reserve-proposal.js b/packages/vats/src/proposals/upgrade-reserve-proposal.js new file mode 100644 index 00000000000..792bbb56e57 --- /dev/null +++ b/packages/vats/src/proposals/upgrade-reserve-proposal.js @@ -0,0 +1,60 @@ +import { E } from '@endo/far'; +import { makeTracer } from '@agoric/internal/src/index.js'; + +const trace = makeTracer('upgrade Vaults proposal'); + +export const upgradeReserve = async (powers, options) => { + trace('Initiate Reserve contract upgrade'); + + const { + consume: { + reserveKit, + economicCommitteeCreatorFacet, + feeMintAccess: feeMintAccessP, + instancePrivateArgs: instancePrivateArgsP, + }, + } = powers; + + const { + options: { contractRef }, + } = options; + + const { adminFacet, instance } = await reserveKit; + + const instancePrivateArgs = await instancePrivateArgsP; + const privateArgs = instancePrivateArgs.get(instance); + + const feeMintAccess = await feeMintAccessP; + + const initialPoserInvitation = await E( + economicCommitteeCreatorFacet, + ).getPoserInvitation(); + + const newPrivateArgs = harden({ + ...privateArgs, + feeMintAccess, + initialPoserInvitation, + }); + + await E(adminFacet).upgradeContract(contractRef.bundleID, newPrivateArgs); + + trace('Reserve contract upgraded!'); +}; + +export const getManifestForReserveUpgrade = ( + { restoreRef }, + { contractRef }, +) => ({ + manifest: { + [upgradeReserve.name]: { + consume: { + reserveKit: true, + instancePrivateArgs: true, + feeMintAccess: true, + economicCommitteeCreatorFacet: true, + }, + }, + }, + installations: { reserve: restoreRef(contractRef) }, + options: { contractRef }, +});