Skip to content

Commit

Permalink
chore(acceptance): add proposal for reserve null upgrade
Browse files Browse the repository at this point in the history
  • Loading branch information
Jorge-Lopes committed Nov 21, 2024
1 parent 6112a8b commit 463557a
Show file tree
Hide file tree
Showing 4 changed files with 100 additions and 2 deletions.
15 changes: 14 additions & 1 deletion a3p-integration/proposals/z:acceptance/governance.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Check warning on line 6 in a3p-integration/proposals/z:acceptance/governance.test.js

View workflow job for this annotation

GitHub Actions / lint-rest

Replace `·evalBundles,·getDetailsMatchingVats,·GOV1ADDR,·GOV2ADDR,·waitForBlock·` with `⏎··evalBundles,⏎··getDetailsMatchingVats,⏎··GOV1ADDR,⏎··GOV2ADDR,⏎··waitForBlock,⏎`
import { makeGovernanceDriver } from './test-lib/governance.js';
import { networkConfig } from './test-lib/index.js';
import { makeTimerUtils } from './test-lib/utils.js';
Expand Down Expand Up @@ -106,3 +106,16 @@ test.serial(
t.like(latestOutcome, { outcome: 'win' });
},
);

test.only('dummy Reserve', async t => {

Check warning on line 110 in a3p-integration/proposals/z:acceptance/governance.test.js

View workflow job for this annotation

GitHub Actions / lint-rest

Delete `⏎`

console.log('Log: Before ', await getDetailsMatchingVats('reserve'));

await evalBundles('upgrade-reserve');

await waitForBlock(10);

console.log('Log: After ', await getDetailsMatchingVats('reserve'));

t.pass();
});
3 changes: 2 additions & 1 deletion a3p-integration/proposals/z:acceptance/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
24 changes: 24 additions & 0 deletions packages/builders/scripts/testing/upgrade-reserve.js
Original file line number Diff line number Diff line change
@@ -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);
};
60 changes: 60 additions & 0 deletions packages/vats/src/proposals/upgrade-reserve-proposal.js
Original file line number Diff line number Diff line change
@@ -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 },
});

0 comments on commit 463557a

Please sign in to comment.