Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(zoe)!: makeZoeKit() now requires a zcfBundlecap #4528

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions packages/SwingSet/src/types.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
/**
* @typedef {'getExport' | 'nestedEvaluate' | 'endoZipBase64'} BundleFormat
* @typedef { string } BundleID
* @typedef { {} } BundleCap
*/

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import { test } from '@agoric/zoe/tools/prepare-test-env-ava.js';

import { makeZoeKit } from '@agoric/zoe';
import fakeVatAdmin from '@agoric/zoe/tools/fakeVatAdmin.js';
import { fakeVatAdmin, zcfBundlecap } from '@agoric/zoe/tools/fakeVatAdmin.js';
import { makeBoard } from '@agoric/vats/src/lib-board.js';
import bundleSource from '@endo/bundle-source';
import { resolve as importMetaResolve } from 'import-meta-resolve';
Expand All @@ -12,7 +12,7 @@ import '../../exported.js';
import { makeInstall } from '../../src/install.js';

test('install', async t => {
const { zoeService: zoe } = makeZoeKit(fakeVatAdmin);
const { zoeService: zoe } = makeZoeKit(fakeVatAdmin, zcfBundlecap);

let addedInstallation;

Expand Down
4 changes: 2 additions & 2 deletions packages/deploy-script-support/test/unitTests/test-offer.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import { test } from '@agoric/zoe/tools/prepare-test-env-ava.js';

import { makeZoeKit } from '@agoric/zoe';
import fakeVatAdmin from '@agoric/zoe/tools/fakeVatAdmin.js';
import { fakeVatAdmin, zcfBundlecap } from '@agoric/zoe/tools/fakeVatAdmin.js';
import bundleSource from '@endo/bundle-source';
import { makeIssuerKit, AmountMath } from '@agoric/ertp';
import { resolve as importMetaResolve } from 'import-meta-resolve';
Expand Down Expand Up @@ -37,7 +37,7 @@ test('offer', async t => {
},
saveOfferResult: () => {},
};
const { zoeService: zoe } = makeZoeKit(fakeVatAdmin);
const { zoeService: zoe } = makeZoeKit(fakeVatAdmin, zcfBundlecap);

const bundleUrl = await importMetaResolve(
'@agoric/zoe/src/contracts/automaticRefund.js',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import { test } from '@agoric/zoe/tools/prepare-test-env-ava.js';

import { makeZoeKit } from '@agoric/zoe';
import fakeVatAdmin from '@agoric/zoe/tools/fakeVatAdmin.js';
import { fakeVatAdmin, zcfBundlecap } from '@agoric/zoe/tools/fakeVatAdmin.js';
import bundleSource from '@endo/bundle-source';
import { makeIssuerKit } from '@agoric/ertp';
import { resolve as importMetaResolve } from 'import-meta-resolve';
Expand All @@ -19,7 +19,7 @@ test('startInstance', async t => {
const moolaKit = makeIssuerKit('moola');
const usdKit = makeIssuerKit('usd');

const { zoeService: zoe } = makeZoeKit(fakeVatAdmin);
const { zoeService: zoe } = makeZoeKit(fakeVatAdmin, zcfBundlecap);

const bundleUrl = new URL(
await importMetaResolve(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -212,8 +212,9 @@ const makeBootstrap = (argv, cb, vatPowers) => async (vats, devices) => {
const vatAdminSvc = await E(vats.vatAdmin).createVatAdminService(
devices.vatAdmin,
);
const zcfBundlecap = vatPowers.D(devices.bundle).getNamedBundleCap('zcf');
/** @type { ERef<ZoeService> } */
const zoe = E(vats.zoe).buildZoe(vatAdminSvc);
const zoe = E(vats.zoe).buildZoe(vatAdminSvc, zcfBundlecap);

const [committee, binaryVoteCounter] = await Promise.all([
E(zoe).install(cb.committee),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,13 @@ import { makeZoeKit } from '@agoric/zoe';

export function buildRootObject(vatPowers) {
return Far('root', {
buildZoe: vatAdminSvc => {
buildZoe: (vatAdminSvc, zcfBundlecap) => {
const shutdownZoeVat = vatPowers.exitVatWithFailure;
const { zoeService: zoe } = makeZoeKit(vatAdminSvc, shutdownZoeVat);
const { zoeService: zoe } = makeZoeKit(
vatAdminSvc,
zcfBundlecap,
shutdownZoeVat,
);
return zoe;
},
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -188,8 +188,9 @@ const makeBootstrap = (argv, cb, vatPowers) => async (vats, devices) => {
const vatAdminSvc = await E(vats.vatAdmin).createVatAdminService(
devices.vatAdmin,
);
const zcfBundlecap = vatPowers.D(devices.bundle).getNamedBundleCap('zcf');
/** @type { ERef<ZoeService> } */
const zoe = E(vats.zoe).buildZoe(vatAdminSvc);
const zoe = E(vats.zoe).buildZoe(vatAdminSvc, zcfBundlecap);
const installations = await installContracts(zoe, cb);
const timer = buildManualTimer(log);
const voterCreator = E(vats.voter).build(zoe);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,13 @@ import { makeZoeKit } from '@agoric/zoe';

export function buildRootObject(vatPowers) {
return Far('root', {
buildZoe: vatAdminSvc => {
buildZoe: (vatAdminSvc, zcfBundlecap) => {
const shutdownZoeVat = vatPowers.exitVatWithFailure;
const { zoeService: zoe } = makeZoeKit(vatAdminSvc, shutdownZoeVat);
const { zoeService: zoe } = makeZoeKit(
vatAdminSvc,
zcfBundlecap,
shutdownZoeVat,
);
return zoe;
},
});
Expand Down
4 changes: 2 additions & 2 deletions packages/governance/test/unitTests/test-committee.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import '@agoric/zoe/exported.js';
import path from 'path';
import { E } from '@agoric/eventual-send';
import { makeZoeKit } from '@agoric/zoe';
import fakeVatAdmin from '@agoric/zoe/tools/fakeVatAdmin.js';
import { fakeVatAdmin, zcfBundlecap } from '@agoric/zoe/tools/fakeVatAdmin.js';
import bundleSource from '@endo/bundle-source';
import buildManualTimer from '@agoric/zoe/tools/manualTimer.js';

Expand All @@ -25,7 +25,7 @@ const electorateRoot = `${dirname}/../../src/committee.js`;
const counterRoot = `${dirname}/../../src/binaryVoteCounter.js`;

const setupContract = async () => {
const { zoeService: zoe } = makeZoeKit(fakeVatAdmin);
const { zoeService: zoe } = makeZoeKit(fakeVatAdmin, zcfBundlecap);

// pack the contract
const [electorateBundle, counterBundle] = await Promise.all([
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@ import '@agoric/zoe/exported.js';
import { makeZoeKit } from '@agoric/zoe';
import bundleSource from '@endo/bundle-source';
import buildManualTimer from '@agoric/zoe/tools/manualTimer.js';
import { makeFakeVatAdmin } from '@agoric/zoe/tools/fakeVatAdmin.js';
import {
makeFakeVatAdmin,
zcfBundlecap,
} from '@agoric/zoe/tools/fakeVatAdmin.js';
import { E } from '@agoric/eventual-send';
import { makeLoopback } from '@endo/captp';

Expand Down Expand Up @@ -50,6 +53,7 @@ const setUpZoeForTest = async setJig => {

const { zoeService, feeMintAccess: nonFarFeeMintAccess } = makeZoeKit(
makeFakeVatAdmin(setJig, o => makeFar(o)).admin,
zcfBundlecap,
);
/** @type {ERef<ZoeService>} */
const zoe = makeFar(zoeService);
Expand Down
4 changes: 2 additions & 2 deletions packages/pegasus/test/test-peg.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import bundleSource from '@endo/bundle-source';
import { AmountMath } from '@agoric/ertp';
import { makeZoeKit } from '@agoric/zoe';

import fakeVatAdmin from '@agoric/zoe/tools/fakeVatAdmin.js';
import { fakeVatAdmin, zcfBundlecap } from '@agoric/zoe/tools/fakeVatAdmin.js';
import { Far } from '@endo/marshal';
import { makeSubscription } from '@agoric/notifier';

Expand Down Expand Up @@ -62,7 +62,7 @@ async function testRemotePeg(t) {
},
});

const { zoeService: zoe } = makeZoeKit(fakeVatAdmin);
const { zoeService: zoe } = makeZoeKit(fakeVatAdmin, zcfBundlecap);

// Pack the contract.
const contractBundle = await bundleSource(contractPath);
Expand Down
4 changes: 2 additions & 2 deletions packages/run-protocol/test/amm/vpool-xyk-amm/setup.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { E } from '@agoric/eventual-send';
import { makeLoopback } from '@endo/captp';

import { resolve as importMetaResolve } from 'import-meta-resolve';
import { makeFakeVatAdmin } from '@agoric/zoe/tools/fakeVatAdmin.js';
import { makeFakeVatAdmin, zcfBundlecap } from '@agoric/zoe/tools/fakeVatAdmin.js';

import { makeZoeKit } from '@agoric/zoe';
import buildManualTimer from '@agoric/zoe/tools/manualTimer.js';
Expand Down Expand Up @@ -44,7 +44,7 @@ export const setUpZoeForTest = async () => {
const { makeFar } = makeLoopback('zoeTest');

const { zoeService, feeMintAccess: nonFarFeeMintAccess } = makeZoeKit(
makeFakeVatAdmin(() => {}).admin,
makeFakeVatAdmin(() => {}).admin, zcfBundlecap,
);
/** @type {ERef<ZoeService>} */
const zoe = makeFar(zoeService);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,8 @@ const makeBootstrap = (argv, cb, vatPowers) => async (vats, devices) => {
const vatAdminSvc = await E(vats.vatAdmin).createVatAdminService(
devices.vatAdmin,
);
const { zoe, feeMintAccess } = await E(vats.zoe).buildZoe(vatAdminSvc);
const zcfBundlecap = vatPowers.D(devices.bundle).getNamedBundleCap('zcf');
const { zoe, feeMintAccess } = await E(vats.zoe).buildZoe(vatAdminSvc, zcfBundlecap);

const installations = await installContracts(zoe, cb);
const voterCreator = E(vats.voter).build(zoe);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,11 @@ import { makeZoeKit } from '@agoric/zoe';
/** @type {BuildRootObjectForTestVat} */
export function buildRootObject(vatPowers) {
return Far('root', {
buildZoe: vatAdminSvc => {
buildZoe: (vatAdminSvc, zcfBundlecap) => {
const shutdownZoeVat = vatPowers.exitVatWithFailure;
const { zoeService: zoe, feeMintAccess } = makeZoeKit(
vatAdminSvc,
zcfBundlecap,
shutdownZoeVat,
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ function makeBootstrap(argv, cb, vatPowers) {
const vatAdminSvc = await E(vats.vatAdmin).createVatAdminService(
devices.vatAdmin,
);
const { zoe, feeMintAccess } = await E(vats.zoe).buildZoe(vatAdminSvc);
const zcfBundlecap = vatPowers.D(devices.bundle).getNamedBundleCap('zcf');
const { zoe, feeMintAccess } = await E(vats.zoe).buildZoe(vatAdminSvc, zcfBundlecap);

const installations = await installContracts(zoe, cb);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,11 @@ import { makeZoeKit } from '@agoric/zoe';
/** @type {BuildRootObjectForTestVat} */
export function buildRootObject(vatPowers) {
return Far('root', {
buildZoe: vatAdminSvc => {
buildZoe: (vatAdminSvc, zcfBundlecap) => {
const shutdownZoeVat = vatPowers.exitVatWithFailure;
const { zoeService: zoe, feeMintAccess } = makeZoeKit(
vatAdminSvc,
zcfBundlecap,
shutdownZoeVat,
);
return { zoe, feeMintAccess };
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import '../../src/vaultFactory/types.js';
import path from 'path';
import { E } from '@agoric/eventual-send';
import bundleSource from '@endo/bundle-source';
import { makeFakeVatAdmin } from '@agoric/zoe/tools/fakeVatAdmin.js';
import { makeFakeVatAdmin, zcfBundlecap } from '@agoric/zoe/tools/fakeVatAdmin.js';
import { makeZoeKit } from '@agoric/zoe';
import buildManualTimer from '@agoric/zoe/tools/manualTimer.js';
import { AmountMath } from '@agoric/ertp';
Expand Down Expand Up @@ -59,7 +59,7 @@ const installBundle = (zoe, contractBundle) => E(zoe).install(contractBundle);
const setUpZoeForTest = async setJig => {
const { makeFar } = makeLoopback('zoeTest');
const { zoeService, feeMintAccess: nonFarFeeMintAccess } = makeZoeKit(
makeFakeVatAdmin(setJig).admin,
makeFakeVatAdmin(setJig).admin, zcfBundlecap
);
/** @type {ERef<ZoeService>} */
const zoe = makeFar(zoeService);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { test } from '@agoric/zoe/tools/prepare-test-env-ava.js';
import '@agoric/zoe/exported.js';

import { E } from '@agoric/eventual-send';
import { makeFakeVatAdmin } from '@agoric/zoe/tools/fakeVatAdmin.js';
import { makeFakeVatAdmin, zcfBundlecap } from '@agoric/zoe/tools/fakeVatAdmin.js';
import { makeLoopback } from '@endo/captp';
import { makeZoeKit } from '@agoric/zoe';
import bundleSource from '@endo/bundle-source';
Expand Down Expand Up @@ -40,7 +40,7 @@ const setJig = jig => {
const { makeFar, makeNear: makeRemote } = makeLoopback('zoeTest');

const { zoeService, feeMintAccess: nonFarFeeMintAccess } = makeZoeKit(
makeFakeVatAdmin(setJig, makeRemote).admin,
makeFakeVatAdmin(setJig, makeRemote).admin, zcfBundlecap
);
/** @type {ERef<ZoeService>} */
const zoe = makeFar(zoeService);
Expand Down
4 changes: 2 additions & 2 deletions packages/run-protocol/test/vaultFactory/test-vault.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { test } from '@agoric/zoe/tools/prepare-test-env-ava.js';
import '@agoric/zoe/exported.js';

import { E } from '@agoric/eventual-send';
import { makeFakeVatAdmin } from '@agoric/zoe/tools/fakeVatAdmin.js';
import { makeFakeVatAdmin, zcfBundlecap } from '@agoric/zoe/tools/fakeVatAdmin.js';
import { makeLoopback } from '@endo/captp';
import { makeZoeKit } from '@agoric/zoe';
import bundleSource from '@endo/bundle-source';
Expand Down Expand Up @@ -38,7 +38,7 @@ const setJig = jig => {
const { makeFar, makeNear: makeRemote } = makeLoopback('zoeTest');

const { zoeService, feeMintAccess: nonFarFeeMintAccess } = makeZoeKit(
makeFakeVatAdmin(setJig, makeRemote).admin,
makeFakeVatAdmin(setJig, makeRemote).admin, zcfBundlecap
);
/** @type {ERef<ZoeService>} */
const zoe = makeFar(zoeService);
Expand Down
5 changes: 1 addition & 4 deletions packages/vats/decentral-config.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,7 @@
"sourceSpec": "./src/vat-walletManager.js"
},
"zoe": {
"sourceSpec": "./src/vat-zoe.js",
"parameters": {
"zcfBundleName": "zcf"
}
"sourceSpec": "./src/vat-zoe.js"
},
"bootstrap": {
"sourceSpec": "./src/bootstrap.js"
Expand Down
5 changes: 1 addition & 4 deletions packages/vats/decentral-core-config.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,7 @@
"sourceSpec": "./src/vat-walletManager.js"
},
"zoe": {
"sourceSpec": "./src/vat-zoe.js",
"parameters": {
"zcfBundleName": "zcf"
}
"sourceSpec": "./src/vat-zoe.js"
}
},
"defaultManagerType": "xs-worker"
Expand Down
5 changes: 1 addition & 4 deletions packages/vats/decentral-demo-config.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,7 @@
"sourceSpec": "./src/vat-walletManager.js"
},
"zoe": {
"sourceSpec": "./src/vat-zoe.js",
"parameters": {
"zcfBundleName": "zcf"
}
"sourceSpec": "./src/vat-zoe.js"
}
},
"defaultManagerType": "xs-worker"
Expand Down
8 changes: 7 additions & 1 deletion packages/vats/src/bootstrap.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ export function buildRootObject(vatPowers, vatParameters) {
vats,
bridgeManager,
timerDevice,
bundleDevice,
vatAdminSvc,
noFakeCurrencies,
) {
Expand All @@ -80,6 +81,9 @@ export function buildRootObject(vatPowers, vatParameters) {

const chainTimerServiceP = E(vats.timer).createTimerService(timerDevice);

// vatParameters.zcfBundleName,
const zcfBundlecap = D(bundleDevice).getNamedBundleCap('zcf');

// Create singleton instances.
const [
bankManager,
Expand All @@ -96,7 +100,7 @@ export function buildRootObject(vatPowers, vatParameters) {
chainTimerServiceP,
/** @type {Promise<{ zoeService: ZoeService, feeMintAccess:
* FeeMintAccess }>} */ (
E(vats.zoe).buildZoe(vatAdminSvc, feeIssuerConfig)
E(vats.zoe).buildZoe(vatAdminSvc, zcfBundlecap, feeIssuerConfig)
),
E(vats.priceAuthority).makePriceAuthority(),
E(vats.walletManager).buildWalletManager(vatAdminSvc),
Expand Down Expand Up @@ -986,6 +990,7 @@ export function buildRootObject(vatPowers, vatParameters) {
vats,
bridgeManager,
devices.timer,
devices.bundle,
vatAdminSvc,
noFakeCurrencies,
);
Expand Down Expand Up @@ -1045,6 +1050,7 @@ export function buildRootObject(vatPowers, vatParameters) {
vats,
bridgeManager,
devices.timer,
devices.bundle,
vatAdminSvc,
noFakeCurrencies,
);
Expand Down
4 changes: 2 additions & 2 deletions packages/vats/src/vat-zoe.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@ import { makeZoeKit } from '@agoric/zoe';

export function buildRootObject(vatPowers, vatParameters) {
return Far('root', {
buildZoe: async (adminVat, feeIssuerConfig) => {
buildZoe: async (adminVat, zcfBundlecap, feeIssuerConfig) => {
const shutdownZoeVat = vatPowers.exitVatWithFailure;
const { zoeService, feeMintAccess } = makeZoeKit(
adminVat,
zcfBundlecap,
shutdownZoeVat,
feeIssuerConfig,
vatParameters.zcfBundleName,
);
return harden({
zoeService,
Expand Down
Loading