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

chore: change select Zoe methods to take a feePurse #3663

Merged
merged 11 commits into from
Aug 14, 2021
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import fakeVatAdmin from '@agoric/zoe/tools/fakeVatAdmin.js';
import { makeBoard } from '@agoric/vats/src/lib-board.js';
// eslint-disable-next-line import/no-extraneous-dependencies
import { makeNameHubKit } from '@agoric/vats/src/nameHub.js';
import { makeAndApplyFeePurse } from '@agoric/zoe/src/applyFeePurse.js';
import { Far } from '@agoric/marshal';
import { makeWallet } from '../src/lib-wallet.js';

Expand All @@ -24,7 +25,8 @@ function makeFakeMyAddressNameAdmin() {
}

const setup = async () => {
const { zoeService: zoe } = makeZoeKit(fakeVatAdmin);
const { zoeService } = makeZoeKit(fakeVatAdmin);
const { zoeService: zoe } = makeAndApplyFeePurse(zoeService);
const board = makeBoard();

const pursesStateChangeHandler = _data => {};
Expand Down
10 changes: 7 additions & 3 deletions packages/dapp-svelte-wallet/api/test/test-lib-wallet.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { makeIssuerKit, AmountMath, AssetKind } from '@agoric/ertp';

import { makeZoeKit } from '@agoric/zoe';
import fakeVatAdmin from '@agoric/zoe/tools/fakeVatAdmin.js';
import { makeAndApplyFeePurse } from '@agoric/zoe/src/applyFeePurse.js';

import { assert } from '@agoric/assert';
import { E } from '@agoric/eventual-send';
Expand Down Expand Up @@ -45,7 +46,8 @@ async function setupTest() {
const moolaBundle = makeIssuerKit('moola');
const simoleanBundle = makeIssuerKit('simolean');
const rpgBundle = makeIssuerKit('rpg', AssetKind.SET);
const { zoeService: zoe } = makeZoeKit(fakeVatAdmin);
const { zoeService } = makeZoeKit(fakeVatAdmin);
const { zoeService: zoe } = makeAndApplyFeePurse(zoeService);
const board = makeBoard();

// Create AutomaticRefund instance
Expand Down Expand Up @@ -1193,7 +1195,8 @@ test('addOffer offer.invitation', async t => {
});

test('addOffer makeContinuingInvitation', async t => {
const { zoeService: zoe } = makeZoeKit(fakeVatAdmin);
const { zoeService } = makeZoeKit(fakeVatAdmin);
const { zoeService: zoe } = makeAndApplyFeePurse(zoeService);
const board = makeBoard();

// Create ContinuingInvitationExample instance
Expand Down Expand Up @@ -1275,7 +1278,8 @@ test('addOffer makeContinuingInvitation', async t => {
});

test('getZoe, getBoard', async t => {
const { zoeService: zoe } = makeZoeKit(fakeVatAdmin);
const { zoeService } = makeZoeKit(fakeVatAdmin);
const { zoeService: zoe } = makeAndApplyFeePurse(zoeService);
const board = makeBoard();

const pursesStateChangeHandler = _data => {};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,15 @@ import fakeVatAdmin from '@agoric/zoe/tools/fakeVatAdmin.js';
import { makeBoard } from '@agoric/vats/src/lib-board.js';
import bundleSource from '@agoric/bundle-source';
import { resolve as importMetaResolve } from 'import-meta-resolve';
import { makeAndApplyFeePurse } from '@agoric/zoe/src/applyFeePurse.js';

import '../../exported.js';

import { makeInstall } from '../../src/install.js';

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

let addedInstallation;

Expand Down
4 changes: 3 additions & 1 deletion packages/deploy-script-support/test/unitTests/test-offer.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import fakeVatAdmin from '@agoric/zoe/tools/fakeVatAdmin.js';
import bundleSource from '@agoric/bundle-source';
import { makeIssuerKit, AmountMath } from '@agoric/ertp';
import { resolve as importMetaResolve } from 'import-meta-resolve';
import { makeAndApplyFeePurse } from '@agoric/zoe/src/applyFeePurse.js';

import '../../exported.js';

Expand Down Expand Up @@ -37,7 +38,8 @@ test('offer', async t => {
},
saveOfferResult: () => {},
};
const { zoeService: zoe } = makeZoeKit(fakeVatAdmin);
const { zoeService } = makeZoeKit(fakeVatAdmin);
const { zoeService: zoe } = makeAndApplyFeePurse(zoeService);

const bundleUrl = await importMetaResolve(
'@agoric/zoe/src/contracts/automaticRefund.js',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import fakeVatAdmin from '@agoric/zoe/tools/fakeVatAdmin.js';
import bundleSource from '@agoric/bundle-source';
import { makeIssuerKit } from '@agoric/ertp';
import { resolve as importMetaResolve } from 'import-meta-resolve';
import { makeAndApplyFeePurse } from '@agoric/zoe/src/applyFeePurse.js';

import '../../exported.js';

Expand All @@ -19,7 +20,8 @@ test('startInstance', async t => {
const moolaKit = makeIssuerKit('moola');
const usdKit = makeIssuerKit('usd');

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

const bundleUrl = new URL(
await importMetaResolve(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,14 @@
import { Far } from '@agoric/marshal';

import { makeZoeKit } from '@agoric/zoe';
import { makeAndApplyFeePurse } from '@agoric/zoe/src/applyFeePurse.js';

export function buildRootObject(vatPowers) {
return Far('root', {
buildZoe: vatAdminSvc => {
const shutdownZoeVat = vatPowers.exitVatWithFailure;
const { zoeService: zoe } = makeZoeKit(vatAdminSvc, shutdownZoeVat);
const { zoeService } = makeZoeKit(vatAdminSvc, shutdownZoeVat);
const { zoeService: zoe } = makeAndApplyFeePurse(zoeService);
return zoe;
},
});
Expand Down
4 changes: 3 additions & 1 deletion packages/governance/test/unitTests/test-committee.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { makeZoeKit } from '@agoric/zoe';
import fakeVatAdmin from '@agoric/zoe/tools/fakeVatAdmin.js';
import bundleSource from '@agoric/bundle-source';
import buildManualTimer from '@agoric/zoe/tools/manualTimer.js';
import { makeAndApplyFeePurse } from '@agoric/zoe/src/applyFeePurse.js';

import { ChoiceMethod } from '../../src/ballotBuilder.js';

Expand All @@ -20,7 +21,8 @@ const registrarRoot = `${dirname}/../../src/committeeRegistrar.js`;
const counterRoot = `${dirname}/../../src/binaryBallotCounter.js`;

async function setupContract() {
const { zoeService: zoe } = makeZoeKit(fakeVatAdmin);
const { zoeService } = makeZoeKit(fakeVatAdmin);
const { zoeService: zoe } = makeAndApplyFeePurse(zoeService);

// pack the contract
const [registrarBundle, counterBundle] = await Promise.all([
Expand Down
4 changes: 3 additions & 1 deletion packages/pegasus/test/test-peg.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {
import bundleSource from '@agoric/bundle-source';
import { AmountMath } from '@agoric/ertp';
import { makeZoeKit } from '@agoric/zoe';
import { makeAndApplyFeePurse } from '@agoric/zoe/src/applyFeePurse.js';

import fakeVatAdmin from '@agoric/zoe/tools/fakeVatAdmin.js';
import { Far } from '@agoric/marshal';
Expand Down Expand Up @@ -47,7 +48,8 @@ async function testRemotePeg(t) {
},
});

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

// Pack the contract.
const contractBundle = await bundleSource(contractPath);
Expand Down
4 changes: 3 additions & 1 deletion packages/swingset-runner/demo/exchangeBenchmark/vat-zoe.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,18 @@
import { Far } from '@agoric/marshal';

import { makeZoeKit } from '@agoric/zoe';
import { makeAndApplyFeePurse } from '@agoric/zoe/src/applyFeePurse.js';

export function buildRootObject(vatPowers, vatParameters) {
return Far('root', {
buildZoe: vatAdminSvc => {
const shutdownZoeVat = vatPowers.exitVatWithFailure;
const { zoeService: zoe } = makeZoeKit(
const { zoeService } = makeZoeKit(
vatAdminSvc,
shutdownZoeVat,
vatParameters.zcfBundleName,
);
const { zoeService: zoe } = makeAndApplyFeePurse(zoeService);
return zoe;
},
});
Expand Down
4 changes: 3 additions & 1 deletion packages/swingset-runner/demo/swapBenchmark/vat-zoe.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,18 @@
import { Far } from '@agoric/marshal';

import { makeZoeKit } from '@agoric/zoe';
import { makeAndApplyFeePurse } from '@agoric/zoe/src/applyFeePurse.js';

export function buildRootObject(vatPowers, vatParameters) {
return Far('root', {
buildZoe: vatAdminSvc => {
const shutdownZoeVat = vatPowers.exitVatWithFailure;
const { zoeService: zoe } = makeZoeKit(
const { zoeService } = makeZoeKit(
vatAdminSvc,
shutdownZoeVat,
vatParameters.zcfBundleName,
);
const { zoeService: zoe } = makeAndApplyFeePurse(zoeService);
return zoe;
},
});
Expand Down
4 changes: 3 additions & 1 deletion packages/swingset-runner/demo/zoeTests/vat-zoe.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,18 @@
import { Far } from '@agoric/marshal';

import { makeZoeKit } from '@agoric/zoe';
import { makeAndApplyFeePurse } from '@agoric/zoe/src/applyFeePurse.js';

export function buildRootObject(vatPowers, vatParameters) {
return Far('root', {
buildZoe: vatAdminSvc => {
const shutdownZoeVat = vatPowers.exitVatWithFailure;
const { zoeService: zoe } = makeZoeKit(
const { zoeService } = makeZoeKit(
vatAdminSvc,
shutdownZoeVat,
vatParameters.zcfBundleName,
);
const { zoeService: zoe } = makeAndApplyFeePurse(zoeService);
return zoe;
},
});
Expand Down
4 changes: 3 additions & 1 deletion packages/treasury/test/swingsetTests/bootstrap.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { E } from '@agoric/eventual-send';
import { Far } from '@agoric/marshal';
import { makeIssuerKit, AmountMath } from '@agoric/ertp';
import buildManualTimer from '@agoric/zoe/tools/manualTimer.js';
import { makeAndApplyFeePurse } from '../../../zoe/src/applyFeePurse';

const ONE_DAY = 24n * 60n * 60n;

Expand Down Expand Up @@ -67,9 +68,10 @@ function makeBootstrap(argv, cb, vatPowers) {
const vatAdminSvc = await E(vats.vatAdmin).createVatAdminService(
devices.vatAdmin,
);
const { zoeService: zoe, feeMintAccess } = await E(vats.zoe).buildZoe(
const { zoeService, feeMintAccess } = await E(vats.zoe).buildZoe(
vatAdminSvc,
);
const { zoeService: zoe } = makeAndApplyFeePurse(zoeService);
const [liquidateMinimum, autoswap, treasury] = await Promise.all([
E(zoe).install(cb.liquidateMinimum),
E(zoe).install(cb.autoswap),
Expand Down
1 change: 0 additions & 1 deletion packages/treasury/test/swingsetTests/vat-zoe.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// @ts-check

import { Far } from '@agoric/marshal';

import { makeZoeKit } from '@agoric/zoe';

export function buildRootObject(vatPowers) {
Expand Down
10 changes: 7 additions & 3 deletions packages/treasury/test/test-bootstrapPayment.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import { makeZoeKit } from '@agoric/zoe';
import buildManualTimer from '@agoric/zoe/tools/manualTimer.js';
import { AmountMath } from '@agoric/ertp';
import { resolve as importMetaResolve } from 'import-meta-resolve';
import { makeAndApplyFeePurse } from '@agoric/zoe/src/applyFeePurse.js';

const filename = new URL(import.meta.url).pathname;
const dirname = path.dirname(filename);
Expand All @@ -33,7 +34,8 @@ const makeInstall = async (root, zoe) => {
};

test('bootstrap payment', async t => {
const { zoeService: zoe, feeMintAccess } = makeZoeKit(fakeVatAdmin);
const { zoeService, feeMintAccess } = makeZoeKit(fakeVatAdmin);
const { zoeService: zoe } = makeAndApplyFeePurse(zoeService);
const autoswapRoot = await autoswapRootP;
const autoswapInstall = await makeInstall(autoswapRoot, zoe);
const stablecoinInstall = await makeInstall(stablecoinRoot, zoe);
Expand Down Expand Up @@ -81,7 +83,8 @@ test('bootstrap payment', async t => {
});

test('bootstrap payment - only minted once', async t => {
const { zoeService: zoe, feeMintAccess } = makeZoeKit(fakeVatAdmin);
const { zoeService, feeMintAccess } = makeZoeKit(fakeVatAdmin);
const { zoeService: zoe } = makeAndApplyFeePurse(zoeService);
const autoswapRoot = await autoswapRootP;
const autoswapInstall = await makeInstall(autoswapRoot, zoe);
const stablecoinInstall = await makeInstall(stablecoinRoot, zoe);
Expand Down Expand Up @@ -138,7 +141,8 @@ test('bootstrap payment - only minted once', async t => {
});

test('bootstrap payment - default value is 0n', async t => {
const { zoeService: zoe, feeMintAccess } = makeZoeKit(fakeVatAdmin);
const { zoeService, feeMintAccess } = makeZoeKit(fakeVatAdmin);
const { zoeService: zoe } = makeAndApplyFeePurse(zoeService);
const autoswapRoot = await autoswapRootP;
const autoswapInstall = await makeInstall(autoswapRoot, zoe);
const stablecoinInstall = await makeInstall(stablecoinRoot, zoe);
Expand Down
9 changes: 6 additions & 3 deletions packages/treasury/test/test-stablecoin.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import '../src/types.js';
import { E } from '@agoric/eventual-send';
import bundleSource from '@agoric/bundle-source';
import { resolve as importMetaResolve } from 'import-meta-resolve';
import { makeAndApplyFeePurse } from '@agoric/zoe/src/applyFeePurse.js';

import { makeFakeVatAdmin } from '@agoric/zoe/tools/fakeVatAdmin.js';
import { makeLoopback } from '@agoric/captp';
Expand Down Expand Up @@ -55,9 +56,11 @@ const setUpZoeForTest = async setJig => {
* @property {ERef<MultipoolAutoswapPublicFacet>} autoswap
*/

const { zoeService, feeMintAccess: nonFarFeeMintAccess } = makeZoeKit(
makeFakeVatAdmin(setJig, makeRemote).admin,
);
const {
zoeService: nonFarZoeService,
feeMintAccess: nonFarFeeMintAccess,
} = makeZoeKit(makeFakeVatAdmin(setJig, makeRemote).admin);
const { zoeService } = makeAndApplyFeePurse(nonFarZoeService);
/** @type {ERef<ZoeService>} */
const zoe = makeFar(zoeService);
trace('makeZoe');
Expand Down
9 changes: 6 additions & 3 deletions packages/treasury/test/test-vault-interest.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { makeLoopback } from '@agoric/captp';
import { makeZoeKit } from '@agoric/zoe';
import bundleSource from '@agoric/bundle-source';
import { resolve as importMetaResolve } from 'import-meta-resolve';
import { makeAndApplyFeePurse } from '@agoric/zoe/src/applyFeePurse.js';

import { makeRatio } from '@agoric/zoe/src/contractSupport/ratio.js';
import { AmountMath } from '@agoric/ertp';
Expand Down Expand Up @@ -39,9 +40,11 @@ const setJig = jig => {

const { makeFar, makeNear: makeRemote } = makeLoopback('zoeTest');

const { zoeService, feeMintAccess: nonFarFeeMintAccess } = makeZoeKit(
makeFakeVatAdmin(setJig, makeRemote).admin,
);
const {
zoeService: nonFarZoeService,
feeMintAccess: nonFarFeeMintAccess,
} = makeZoeKit(makeFakeVatAdmin(setJig, makeRemote).admin);
const { zoeService } = makeAndApplyFeePurse(nonFarZoeService);
/** @type {ERef<ZoeService>} */
const zoe = makeFar(zoeService);
trace('makeZoe');
Expand Down
9 changes: 6 additions & 3 deletions packages/treasury/test/test-vault.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { makeLoopback } from '@agoric/captp';
import { makeZoeKit } from '@agoric/zoe';
import bundleSource from '@agoric/bundle-source';
import { resolve as importMetaResolve } from 'import-meta-resolve';
import { makeAndApplyFeePurse } from '@agoric/zoe/src/applyFeePurse.js';

import { makeIssuerKit, AmountMath } from '@agoric/ertp';

Expand Down Expand Up @@ -37,9 +38,11 @@ const setJig = jig => {

const { makeFar, makeNear: makeRemote } = makeLoopback('zoeTest');

const { zoeService, feeMintAccess: nonFarFeeMintAccess } = makeZoeKit(
makeFakeVatAdmin(setJig, makeRemote).admin,
);
const {
zoeService: nonFarZoeService,
feeMintAccess: nonFarFeeMintAccess,
} = makeZoeKit(makeFakeVatAdmin(setJig, makeRemote).admin);
const { zoeService } = makeAndApplyFeePurse(nonFarZoeService);
/** @type {ERef<ZoeService>} */
const zoe = makeFar(zoeService);
trace('makeZoe');
Expand Down
Loading