Skip to content

Commit

Permalink
refactor: remove makeEmptyOffer from zoeHelpers, use zcf.makeEmptySea…
Browse files Browse the repository at this point in the history
…tKit instead (#1451)
  • Loading branch information
katelynsills authored Aug 13, 2020
1 parent 986af3d commit 013ae80
Show file tree
Hide file tree
Showing 4 changed files with 1 addition and 62 deletions.
1 change: 0 additions & 1 deletion packages/zoe/src/contractSupport/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,4 @@ export {
satisfies,
escrowAndAllocateTo,
assertNatMathHelpers,
makeEmptyOffer,
} from './zoeHelpers';
24 changes: 0 additions & 24 deletions packages/zoe/src/contractSupport/zoeHelpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import { assert, details } from '@agoric/assert';
import { sameStructure } from '@agoric/same-structure';
import { E } from '@agoric/eventual-send';
import { makePromiseKit } from '@agoric/promise-kit';

import { satisfiesWant } from '../contractFacet/offerSafety';

Expand Down Expand Up @@ -293,29 +292,6 @@ export const assertProposalKeywords = (offerHandler, expected) =>
assertKeys(actual.exit, expected.exit);
return offerHandler(seat);
};
/**
* Return a record with a promise for the userSeat and a promise for
* the zcfSeat
*
* This offer will have an empty 'give' and 'want', making it useful
* for contracts to use for unrestricted internal asset reallocation.
* One example is the Autoswap contract, which uses an empty offer
* to manage internal escrowed assets.
* @param {ContractFacet} zcf
* @returns {{userSeat: Promise<UserSeat>, zcfSeat: Promise<ZCFSeat>}}
*/
export const makeEmptyOffer = zcf => {
const ZCFSeatPromiseKit = makePromiseKit();
const invite = zcf.makeInvitation(
seat => ZCFSeatPromiseKit.resolve(seat),
'empty offer',
);
const zoeService = zcf.getZoeService();
return {
userSeat: E(zoeService).offer(invite),
zcfSeat: ZCFSeatPromiseKit.promise,
};
};

/**
* Escrow payments with Zoe and reallocate the amount of each
Expand Down
3 changes: 1 addition & 2 deletions packages/zoe/src/contracts/multipoolAutoswap/pool.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import {
calcLiqValueToMint,
calcValueToRemove,
assertNatMathHelpers,
makeEmptyOffer,
trade,
} from '../../contractSupport';

Expand Down Expand Up @@ -165,7 +164,7 @@ export const makeAddPool = (zcf, isSecondary, initPool, centralBrand) => {
await zcf.saveIssuer(secondaryIssuer, keyword);
assertNatMathHelpers(zcf, secondaryBrand);
const liquidityZCFMint = await zcf.makeZCFMint(liquidityKeyword);
const { zcfSeat: poolSeatP } = await makeEmptyOffer(zcf);
const { zcfSeat: poolSeatP } = zcf.makeEmptySeatKit(zcf);
const poolSeat = await poolSeatP;
const pool = makePool(liquidityZCFMint, poolSeat, secondaryBrand);
initPool(secondaryBrand, pool);
Expand Down
35 changes: 0 additions & 35 deletions packages/zoe/test/unitTests/contractSupport/test-zoeHelpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -560,41 +560,6 @@ test.skip(`ZoeHelpers swap - can't trade with`, t => {
}
});

test.skip('ZoeHelpers makeEmptyOffer', async t => {
t.plan(2);
const { moolaR, simoleanR } = setup();
const redeemedInvites = [];
try {
const offerHandle = harden({});
const mockZCF = harden({
getInstanceRecord: () =>
harden({
issuerKeywordRecord: {
Asset: moolaR.issuer,
Price: simoleanR.issuer,
},
}),
getZoeService: () =>
harden({
offer: invite => {
redeemedInvites.push(invite);
return Promise.resolve();
},
}),
makeInvitation: offerHook => {
offerHook(offerHandle);
return 'anInvite';
},
});
const { makeEmptyOffer } = makeZoeHelpers(mockZCF);
const result = await makeEmptyOffer();
t.deepEquals(result, offerHandle, `offerHandle was returned`);
t.deepEquals(redeemedInvites, harden(['anInvite']), `invite was redeemed`);
} catch (e) {
t.assert(false, e);
}
});

test.skip('ZoeHelpers isOfferSafe', t => {
t.plan(5);
const { moolaR, simoleanR, moola, simoleans } = setup();
Expand Down

0 comments on commit 013ae80

Please sign in to comment.