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
2 changes: 1 addition & 1 deletion packages/dapp-svelte-wallet/api/src/lib-wallet.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ const cmp = (a, b) => {

/**
* @typedef {Object} MakeWalletParams
* @property {ZoeService} zoe
* @property {ERef<ZoeService>} zoe
* @property {Board} board
* @property {NameHub} [agoricNames]
* @property {NameHub} [namesByAddress]
Expand Down
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 { E } from '@agoric/eventual-send';
import { Far } from '@agoric/marshal';
import { makeWallet } from '../src/lib-wallet.js';

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

const setup = async () => {
const { zoeService: zoe } = makeZoeKit(fakeVatAdmin);
const { zoeService } = makeZoeKit(fakeVatAdmin);
const feePurse = E(zoeService).makeFeePurse();
const zoe = E(zoeService).bindDefaultFeePurse(feePurse);
const board = makeBoard();

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

import { makeZoeKit } from '@agoric/zoe';
import fakeVatAdmin from '@agoric/zoe/tools/fakeVatAdmin.js';
import { E } from '@agoric/eventual-send';

import { assert } from '@agoric/assert';
import { E } from '@agoric/eventual-send';
// eslint-disable-next-line import/no-extraneous-dependencies
import { makeBoard } from '@agoric/vats/src/lib-board.js';
// eslint-disable-next-line import/no-extraneous-dependencies
Expand Down Expand Up @@ -45,7 +45,9 @@ 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 feePurse = E(zoeService).makeFeePurse();
const zoe = E(zoeService).bindDefaultFeePurse(feePurse);
const board = makeBoard();

// Create AutomaticRefund instance
Expand All @@ -56,9 +58,9 @@ async function setupTest() {
const automaticRefundContractRoot = new URL(automaticRefundContractUrl)
.pathname;
const automaticRefundBundle = await bundleSource(automaticRefundContractRoot);
const installation = await zoe.install(automaticRefundBundle);
const installation = await E(zoe).install(automaticRefundBundle);
const issuerKeywordRecord = harden({ Contribution: moolaBundle.issuer });
const { creatorInvitation: invite, instance } = await zoe.startInstance(
const { creatorInvitation: invite, instance } = await E(zoe).startInstance(
installation,
issuerKeywordRecord,
);
Expand All @@ -71,15 +73,15 @@ async function setupTest() {
);
const autoswapContractRoot = new URL(autoswapContractUrl).pathname;
const autoswapBundle = await bundleSource(autoswapContractRoot);
const autoswapInstallationHandle = await zoe.install(autoswapBundle);
const autoswapInstallationHandle = await E(zoe).install(autoswapBundle);
const autoswapIssuerKeywordRecord = harden({
Central: moolaBundle.issuer,
Secondary: simoleanBundle.issuer,
});
const {
publicFacet: autoswapPublicFacet,
instance: autoswapInstanceHandle,
} = await zoe.startInstance(
} = await E(zoe).startInstance(
autoswapInstallationHandle,
autoswapIssuerKeywordRecord,
);
Expand Down Expand Up @@ -1193,7 +1195,9 @@ test('addOffer offer.invitation', async t => {
});

test('addOffer makeContinuingInvitation', async t => {
const { zoeService: zoe } = makeZoeKit(fakeVatAdmin);
const { zoeService } = makeZoeKit(fakeVatAdmin);
const feePurse = E(zoeService).makeFeePurse();
const zoe = E(zoeService).bindDefaultFeePurse(feePurse);
const board = makeBoard();

// Create ContinuingInvitationExample instance
Expand All @@ -1203,8 +1207,10 @@ test('addOffer makeContinuingInvitation', async t => {
);
const path = new URL(url).pathname;
const bundle = await bundleSource(path);
const installation = await zoe.install(bundle);
const { creatorInvitation, instance } = await zoe.startInstance(installation);
katelynsills marked this conversation as resolved.
Show resolved Hide resolved
const installation = await E(zoe).install(bundle);
const { creatorInvitation, instance } = await E(zoe).startInstance(
installation,
);
assert(creatorInvitation);

const pursesStateChangeLog = [];
Expand Down Expand Up @@ -1275,7 +1281,9 @@ test('addOffer makeContinuingInvitation', async t => {
});

test('getZoe, getBoard', async t => {
const { zoeService: zoe } = makeZoeKit(fakeVatAdmin);
const { zoeService } = makeZoeKit(fakeVatAdmin);
const feePurse = E(zoeService).makeFeePurse();
const zoe = E(zoeService).bindDefaultFeePurse(feePurse);
const board = makeBoard();

const pursesStateChangeHandler = _data => {};
Expand All @@ -1290,6 +1298,6 @@ test('getZoe, getBoard', async t => {
});
await initialized;

t.is(await E(wallet).getZoe(), zoe);
t.is(await E(wallet).getZoe(), await zoe);
t.is(await E(wallet).getBoard(), board);
});
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,16 @@ 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 { E } from '@agoric/eventual-send';

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

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

test('install', async t => {
const { zoeService: zoe } = makeZoeKit(fakeVatAdmin);
const { zoeService } = makeZoeKit(fakeVatAdmin);
const feePurse = E(zoeService).makeFeePurse();
const zoe = E(zoeService).bindDefaultFeePurse(feePurse);

let addedInstallation;

Expand Down
6 changes: 4 additions & 2 deletions packages/deploy-script-support/test/unitTests/test-offer.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ 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 { E } from '@agoric/eventual-send';

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

import { E } from '@agoric/eventual-send';
import { makeOfferAndFindInvitationAmount } from '../../src/offer.js';

test('offer', async t => {
Expand Down Expand Up @@ -37,7 +37,9 @@ test('offer', async t => {
},
saveOfferResult: () => {},
};
const { zoeService: zoe } = makeZoeKit(fakeVatAdmin);
const { zoeService } = makeZoeKit(fakeVatAdmin);
const feePurse = E(zoeService).makeFeePurse();
const zoe = E(zoeService).bindDefaultFeePurse(feePurse);

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,10 +6,10 @@ 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 { E } from '@agoric/eventual-send';

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

import { E } from '@agoric/eventual-send';
import { makeStartInstance } from '../../src/startInstance.js';

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

const { zoeService: zoe } = makeZoeKit(fakeVatAdmin);
const { zoeService } = makeZoeKit(fakeVatAdmin);
const feePurse = E(zoeService).makeFeePurse();
const zoe = E(zoeService).bindDefaultFeePurse(feePurse);

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

import { makeZoeKit } from '@agoric/zoe';
import { E } from '@agoric/eventual-send';

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 feePurse = E(zoeService).makeFeePurse();
const zoe = E(zoeService).bindDefaultFeePurse(feePurse);
return zoe;
},
});
Expand Down
8 changes: 5 additions & 3 deletions packages/governance/test/unitTests/test-committee.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@ 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 feePurse = E(zoeService).makeFeePurse();
const zoe = E(zoeService).bindDefaultFeePurse(feePurse);

// pack the contract
const [registrarBundle, counterBundle] = await Promise.all([
Expand All @@ -29,8 +31,8 @@ async function setupContract() {
]);
// install the contract
const [registrarInstallation, counterInstallation] = await Promise.all([
zoe.install(registrarBundle),
zoe.install(counterBundle),
E(zoe).install(registrarBundle),
E(zoe).install(counterBundle),
]);
const terms = { committeeName: 'illuminati', committeeSize: 13 };
const registrarStartResult = await E(zoe).startInstance(
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 @@ -47,7 +47,9 @@ async function testRemotePeg(t) {
},
});

const { zoeService: zoe } = makeZoeKit(fakeVatAdmin);
const { zoeService } = makeZoeKit(fakeVatAdmin);
const feePurse = E(zoeService).makeFeePurse();
const zoe = E(zoeService).bindDefaultFeePurse(feePurse);

// Pack the contract.
const contractBundle = await bundleSource(contractPath);
Expand Down
5 changes: 4 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,19 @@
import { Far } from '@agoric/marshal';

import { makeZoeKit } from '@agoric/zoe';
import { E } from '@agoric/eventual-send';

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 feePurse = E(zoeService).makeFeePurse();
const zoe = E(zoeService).bindDefaultFeePurse(feePurse);
return zoe;
},
});
Expand Down
5 changes: 4 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,19 @@
import { Far } from '@agoric/marshal';

import { makeZoeKit } from '@agoric/zoe';
import { E } from '@agoric/eventual-send';

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 feePurse = E(zoeService).makeFeePurse();
const zoe = E(zoeService).bindDefaultFeePurse(feePurse);
return zoe;
},
});
Expand Down
5 changes: 4 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,19 @@
import { Far } from '@agoric/marshal';

import { makeZoeKit } from '@agoric/zoe';
import { E } from '@agoric/eventual-send';

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 feePurse = E(zoeService).makeFeePurse();
const zoe = E(zoeService).bindDefaultFeePurse(feePurse);
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 @@ -67,9 +67,11 @@ 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 feePurse = E(zoeService).makeFeePurse();
const zoe = E(zoeService).bindDefaultFeePurse(feePurse);
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
12 changes: 9 additions & 3 deletions packages/treasury/test/test-bootstrapPayment.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,9 @@ const makeInstall = async (root, zoe) => {
};

test('bootstrap payment', async t => {
const { zoeService: zoe, feeMintAccess } = makeZoeKit(fakeVatAdmin);
const { zoeService, feeMintAccess } = makeZoeKit(fakeVatAdmin);
const feePurse = E(zoeService).makeFeePurse();
const zoe = E(zoeService).bindDefaultFeePurse(feePurse);
const autoswapRoot = await autoswapRootP;
const autoswapInstall = await makeInstall(autoswapRoot, zoe);
const stablecoinInstall = await makeInstall(stablecoinRoot, zoe);
Expand Down Expand Up @@ -81,7 +83,9 @@ 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 feePurse = E(zoeService).makeFeePurse();
const zoe = E(zoeService).bindDefaultFeePurse(feePurse);
const autoswapRoot = await autoswapRootP;
const autoswapInstall = await makeInstall(autoswapRoot, zoe);
const stablecoinInstall = await makeInstall(stablecoinRoot, zoe);
Expand Down Expand Up @@ -138,7 +142,9 @@ 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 feePurse = E(zoeService).makeFeePurse();
const zoe = E(zoeService).bindDefaultFeePurse(feePurse);
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 @@ -55,9 +55,12 @@ 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 feePurse = E(nonFarZoeService).makeFeePurse();
const zoeService = await E(nonFarZoeService).bindDefaultFeePurse(feePurse);
/** @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 @@ -39,9 +39,12 @@ 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 feePurse = E(nonFarZoeService).makeFeePurse();
const zoeService = await E(nonFarZoeService).bindDefaultFeePurse(feePurse);
/** @type {ERef<ZoeService>} */
const zoe = makeFar(zoeService);
trace('makeZoe');
Expand Down
Loading