From 013ae80deaa242f17d58506343883a442f8a8580 Mon Sep 17 00:00:00 2001 From: Kate Sills Date: Thu, 13 Aug 2020 09:43:22 -0700 Subject: [PATCH] refactor: remove makeEmptyOffer from zoeHelpers, use zcf.makeEmptySeatKit instead (#1451) --- packages/zoe/src/contractSupport/index.js | 1 - .../zoe/src/contractSupport/zoeHelpers.js | 24 ------------- .../src/contracts/multipoolAutoswap/pool.js | 3 +- .../contractSupport/test-zoeHelpers.js | 35 ------------------- 4 files changed, 1 insertion(+), 62 deletions(-) diff --git a/packages/zoe/src/contractSupport/index.js b/packages/zoe/src/contractSupport/index.js index 6873832d11c..8a1f6b7be3d 100644 --- a/packages/zoe/src/contractSupport/index.js +++ b/packages/zoe/src/contractSupport/index.js @@ -20,5 +20,4 @@ export { satisfies, escrowAndAllocateTo, assertNatMathHelpers, - makeEmptyOffer, } from './zoeHelpers'; diff --git a/packages/zoe/src/contractSupport/zoeHelpers.js b/packages/zoe/src/contractSupport/zoeHelpers.js index 374bd859e92..1e539998d4f 100644 --- a/packages/zoe/src/contractSupport/zoeHelpers.js +++ b/packages/zoe/src/contractSupport/zoeHelpers.js @@ -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'; @@ -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, zcfSeat: Promise}} - */ -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 diff --git a/packages/zoe/src/contracts/multipoolAutoswap/pool.js b/packages/zoe/src/contracts/multipoolAutoswap/pool.js index 848213ac66d..00a5d2b1365 100644 --- a/packages/zoe/src/contracts/multipoolAutoswap/pool.js +++ b/packages/zoe/src/contracts/multipoolAutoswap/pool.js @@ -6,7 +6,6 @@ import { calcLiqValueToMint, calcValueToRemove, assertNatMathHelpers, - makeEmptyOffer, trade, } from '../../contractSupport'; @@ -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); diff --git a/packages/zoe/test/unitTests/contractSupport/test-zoeHelpers.js b/packages/zoe/test/unitTests/contractSupport/test-zoeHelpers.js index c71e50b4fa3..ac2c553a3cf 100644 --- a/packages/zoe/test/unitTests/contractSupport/test-zoeHelpers.js +++ b/packages/zoe/test/unitTests/contractSupport/test-zoeHelpers.js @@ -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();