Skip to content

Commit

Permalink
chore: rename to checkZCF which produces checkedZCF
Browse files Browse the repository at this point in the history
  • Loading branch information
katelynsills committed May 13, 2021
1 parent 8875ba8 commit 09899fa
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 13 deletions.
2 changes: 1 addition & 1 deletion packages/zoe/src/contractSupport/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export {
withdrawFromSeat,
saveAllIssuers,
offerTo,
wrapZCF,
checkZCF,
} from './zoeHelpers';

export {
Expand Down
6 changes: 3 additions & 3 deletions packages/zoe/src/contractSupport/zoeHelpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -486,14 +486,14 @@ export const offerTo = async (
* that must be true for the reallocate to occur
* @returns {ContractFacet}
*/
export const wrapZCF = (zcf, assertFn) => {
const wrappedZCF = harden({
export const checkZCF = (zcf, assertFn) => {
const checkedZCF = harden({
...zcf,
reallocate: (...stagings) => {
assertFn(stagings);
// @ts-ignore The types aren't right for spreading
zcf.reallocate(...stagings);
},
});
return wrappedZCF;
return checkedZCF;
};
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { makeWeakStore } from '@agoric/store';
import { Far } from '@agoric/marshal';

import { AssetKind, makeIssuerKit, AmountMath } from '@agoric/ertp';
import { assertIssuerKeywords, wrapZCF } from '../../contractSupport';
import { assertIssuerKeywords, checkZCF } from '../../contractSupport';
import { makeAddPool } from './pool';
import { makeGetCurrentPrice } from './getCurrentPrice';
import { makeMakeSwapInvitation } from './swap';
Expand Down Expand Up @@ -127,7 +127,7 @@ const start = zcf => {
makeSwapInInvitation,
makeSwapOutInvitation,
} = makeMakeSwapInvitation(
wrapZCF(zcf, assertConstantProduct),
checkZCF(zcf, assertConstantProduct),
isSecondary,
isCentral,
getPool,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,22 @@ import { test } from '@agoric/zoe/tools/prepare-test-env-ava';

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

import { wrapZCF } from '../../../../src/contractSupport';
import { checkZCF } from '../../../../src/contractSupport';
import { assertConstantProduct } from '../../../../src/contracts/multipoolAutoswap/constantProduct';
import { setupZCFTest } from '../../zcf/setupZcfTest';

test('constantProduct invariant', async t => {
const { zcf } = await setupZCFTest();

const wrappedZCF = wrapZCF(zcf, assertConstantProduct);
const checkedZCF = checkZCF(zcf, assertConstantProduct);

const { zcfSeat: poolSeat } = wrappedZCF.makeEmptySeatKit();
const { zcfSeat: swapSeat } = wrappedZCF.makeEmptySeatKit();
const { zcfSeat: poolSeat } = checkedZCF.makeEmptySeatKit();
const { zcfSeat: swapSeat } = checkedZCF.makeEmptySeatKit();

// allocate some secondary and central to the poolSeat
const centralMint = await wrappedZCF.makeZCFMint('Central');
const centralMint = await checkedZCF.makeZCFMint('Central');
const { brand: centralBrand } = centralMint.getIssuerRecord();
const secondaryMint = await wrappedZCF.makeZCFMint('Secondary');
const secondaryMint = await checkedZCF.makeZCFMint('Secondary');
const { brand: secondaryBrand } = secondaryMint.getIssuerRecord();
centralMint.mintGains(
{ Central: AmountMath.make(centralBrand, 10n ** 6n) },
Expand All @@ -46,7 +46,7 @@ test('constantProduct invariant', async t => {
// nothing, a clear violation of the constant product
t.throws(
() =>
wrappedZCF.reallocate(
checkedZCF.reallocate(
poolSeat.stage({
Central: AmountMath.make(centralBrand, 0n),
Secondary: AmountMath.make(secondaryBrand, 0n),
Expand Down

0 comments on commit 09899fa

Please sign in to comment.