diff --git a/packages/SwingSet/src/vats/network/types.js b/packages/SwingSet/src/vats/network/types.js index 63cc13ef28a..1b9f2138fb8 100644 --- a/packages/SwingSet/src/vats/network/types.js +++ b/packages/SwingSet/src/vats/network/types.js @@ -31,7 +31,7 @@ * @typedef {Object} ListenHandler A handler for incoming connections * @property {(port: Port, l: ListenHandler) => Promise} [onListen] The listener has been registered * @property {(port: Port, localAddr: Endpoint, remoteAddr: Endpoint, l: ListenHandler) => Promise} onAccept A new connection is incoming - * @property {(port: Port, localAddr: Endpoint, remoteAddr: Endpoint, l: ListenHandler) => Promise} onReject The connection was rejected + * @property {(port: Port, localAddr: Endpoint, remoteAddr: Endpoint, l: ListenHandler) => Promise} [onReject] The connection was rejected * @property {(port: Port, rej: any, l: ListenHandler) => Promise} [onError] There was an error while listening * @property {(port: Port, l: ListenHandler) => Promise} [onRemove] The listener has been removed */ diff --git a/packages/dapp-svelte-wallet/api/src/internal-types.js b/packages/dapp-svelte-wallet/api/src/internal-types.js index 6a3cdf34b00..dd6828aafb5 100644 --- a/packages/dapp-svelte-wallet/api/src/internal-types.js +++ b/packages/dapp-svelte-wallet/api/src/internal-types.js @@ -12,8 +12,8 @@ /** * @typedef {Object} PurseActions * @property {(receiverP: ERef<{ receive: (payment: Payment) => void }>, valueToSend: Value) => Promise} send - * @property {(payment: Payment) => Promise} receive - * @property {(payment: Payment, amount: Amount=) => Promise} deposit + * @property {(payment: Payment) => Promise} receive + * @property {(payment: Payment, amount: Amount=) => Promise} deposit */ /** diff --git a/packages/notifier/src/notifier.js b/packages/notifier/src/notifier.js index f19e7b4a893..735f6eb6c86 100644 --- a/packages/notifier/src/notifier.js +++ b/packages/notifier/src/notifier.js @@ -12,6 +12,11 @@ import { import './types'; +/** + * @template T + * @param {BaseNotifier} baseNotifierP + * @returns {AsyncIterable & SharableNotifier} + */ export const makeNotifier = baseNotifierP => { const asyncIterable = makeAsyncIterableFromNotifier(baseNotifierP); diff --git a/packages/notifier/src/types.js b/packages/notifier/src/types.js index 226051ba96a..735b9ae1bb3 100644 --- a/packages/notifier/src/types.js +++ b/packages/notifier/src/types.js @@ -66,9 +66,12 @@ /** * @template T - * @typedef {BaseNotifier & AsyncIterable} Notifier an object that can + * @typedef {BaseNotifier & AsyncIterable & SharableNotifier} Notifier an object that can * be used to get the current state or updates - * + */ + +/** + * @typedef {Object} SharableNotifier * @property {() => NotifierInternals} getSharableNotifierInternals * Used to replicate the multicast values at other sites. To manually create a * local representative of a Notification, do @@ -103,9 +106,12 @@ /** * @template T - * @typedef {BaseSubscription & AsyncIterable} Subscription + * @typedef {BaseSubscription & AsyncIterable & SharableSubscription} Subscription * A form of AsyncIterable supporting distributed and multicast usage. - * + */ + +/** + * @typedef {Object} SharableSubscription * @property {() => SubscriptionInternals} getSharableSubscriptionInternals * Used to replicate the multicast values at other sites. To manually create a * local representative of a Subscription, do diff --git a/packages/vats/src/bootstrap.js b/packages/vats/src/bootstrap.js index 870624225a1..ef84d08bb39 100644 --- a/packages/vats/src/bootstrap.js +++ b/packages/vats/src/bootstrap.js @@ -538,7 +538,7 @@ export function buildRootObject(vatPowers, vatParameters) { return harden(makeEchoConnectionHandler()); }, async onListen(port, _listenHandler) { - console.debug(`listening on port: ${port}`); + console.debug(`listening on echo port: ${port}`); }, }), ); diff --git a/packages/zoe/src/contractSupport/priceAuthority.js b/packages/zoe/src/contractSupport/priceAuthority.js index 2091331cc53..6b581f24650 100644 --- a/packages/zoe/src/contractSupport/priceAuthority.js +++ b/packages/zoe/src/contractSupport/priceAuthority.js @@ -5,6 +5,7 @@ import { Far } from '@agoric/marshal'; import { assert, details as X } from '@agoric/assert'; import { makePromiseKit } from '@agoric/promise-kit'; import { amountMath } from '@agoric/ertp'; +import { makeNotifier } from '@agoric/notifier'; import '../../exported'; @@ -236,26 +237,57 @@ export function makeOnewayPriceAuthorityKit(opts) { assertBrands(brandIn, brandOut); return timer; }, - getPriceNotifier(brandIn, brandOut) { - assertBrands(brandIn, brandOut); - return notifier; + makeQuoteNotifier(amountIn, brandOut) { + amountMath.coerce(amountIn, actualBrandIn); + assertBrands(amountIn.brand, brandOut); + + // Wrap our underlying notifier with specific quotes. + const specificBaseNotifier = harden({ + async getUpdateSince(updateCount = NaN) { + // We use the same updateCount as our underlying notifier. + const record = await E(notifier).getUpdateSince(updateCount); + + // We create a quote inline. + const quote = createQuote(calcAmountOut => ({ + amountIn, + amountOut: calcAmountOut(amountIn), + })); + assert(quote); + + const value = await quote; + return harden({ + value, + updateCount: record.updateCount, + }); + }, + }); + + /** @type {Notifier} */ + const specificNotifier = Far('QuoteNotifier', { + ...makeNotifier(specificBaseNotifier), + // TODO stop exposing baseNotifier methods directly. + ...specificBaseNotifier, + }); + return specificNotifier; }, async quoteGiven(amountIn, brandOut) { amountMath.coerce(amountIn, actualBrandIn); assertBrands(amountIn.brand, brandOut); await E(notifier).getUpdateSince(); - return createQuote(calcAmountOut => ({ + const quote = createQuote(calcAmountOut => ({ amountIn, amountOut: calcAmountOut(amountIn), })); + assert(quote); + return quote; }, async quoteWanted(brandIn, amountOut) { amountMath.coerce(amountOut, actualBrandOut); assertBrands(brandIn, amountOut.brand); await E(notifier).getUpdateSince(); - return createQuote((calcAmountOut, calcAmountIn) => { + const quote = createQuote((calcAmountOut, calcAmountIn) => { // We need to determine an amountIn that guarantees at least the amountOut. const amountIn = calcAmountIn(amountOut); const actualAmountOut = calcAmountOut(amountIn); @@ -266,6 +298,8 @@ export function makeOnewayPriceAuthorityKit(opts) { ); return { amountIn, amountOut }; }); + assert(quote); + return quote; }, async quoteAtTime(deadline, amountIn, brandOut) { assert.typeof(deadline, 'bigint'); diff --git a/packages/zoe/src/contracts/multipoolAutoswap/types.js b/packages/zoe/src/contracts/multipoolAutoswap/types.js index 051f76ec0f6..2fe4d38e7e9 100644 --- a/packages/zoe/src/contracts/multipoolAutoswap/types.js +++ b/packages/zoe/src/contracts/multipoolAutoswap/types.js @@ -23,8 +23,6 @@ * using makeSwapOutInvitation at the current price * @property {() => Record} getPoolAllocation get an * AmountKeywordRecord showing the current balances in the pool. - * @property {() => Array} getAllPoolBrands get a list of all the brands - * that have associated pools. */ /** @@ -88,7 +86,7 @@ * AmountKeywordRecord showing the current balances in the pool for brand. * @property {() => Issuer} getQuoteIssuer - get the Issuer that attests to * the prices in the priceQuotes issued by the PriceAuthorities - * @property {(brand: Brand) => {toCentral: PriceAuthority, fromCentral: PriceAuthority}}} getPriceAuthorities + * @property {(brand: Brand) => {toCentral: PriceAuthority, fromCentral: PriceAuthority}} getPriceAuthorities * get a pair of PriceAuthorities { toCentral, fromCentral } for requesting * Prices and notifications about changing prices. */ diff --git a/packages/zoe/src/internal-types.js b/packages/zoe/src/internal-types.js index 82b35f628f5..2d95525982b 100644 --- a/packages/zoe/src/internal-types.js +++ b/packages/zoe/src/internal-types.js @@ -96,14 +96,17 @@ * @typedef {Object} InstanceAdmin * @property {() => void} assertAcceptingOffers * @property {(invitationHandle: InvitationHandle, - initialAllocation: Allocation, - proposal: ProposalRecord) => UserSeat } makeUserSeat + * initialAllocation: Allocation, + * proposal: ProposalRecord) => Promise } makeUserSeat + * @property {(initialAllocation: Allocation, + * proposal: ProposalRecord, + * exitObj: ExitObj, + * seatHandle: SeatHandle) => foo } makeNoEscrowSeat * @property {() => Instance} getInstance * @property {() => Object} getPublicFacet * @property {() => IssuerKeywordRecord} getIssuers * @property {() => BrandKeywordRecord} getBrands * @property {() => Object} getTerms - * @property {() => boolean} acceptingOffers * @property {(completion: Completion) => void} exitAllSeats * @property {(reason: TerminationReason) => void} failAllSeats * @property {() => void} stopAcceptingOffers diff --git a/packages/zoe/src/zoeService/zoe.js b/packages/zoe/src/zoeService/zoe.js index 02c08776cd9..1f6587d6134 100644 --- a/packages/zoe/src/zoeService/zoe.js +++ b/packages/zoe/src/zoeService/zoe.js @@ -198,7 +198,7 @@ function makeZoe(vatAdminSvc, zcfBundleName = undefined) { const hasExited = zoeSeatAdmin => !zoeSeatAdmins.has(zoeSeatAdmin); /** @type {InstanceAdmin} */ - return Far('instanceAdmin', { + const instanceAdmin = Far('instanceAdmin', { getPublicFacet: () => publicFacetPromiseKit.promise, getTerms, getIssuers, @@ -278,6 +278,7 @@ function makeZoe(vatAdminSvc, zcfBundleName = undefined) { return { userSeat, notifier, zoeSeatAdmin }; }, }); + return instanceAdmin; }; const instanceAdmin = makeInstanceAdmin(); diff --git a/packages/zoe/test/unitTests/contracts/test-priceAggregator.js b/packages/zoe/test/unitTests/contracts/test-priceAggregator.js index 5a8e693e0f7..83e9b4e24d6 100644 --- a/packages/zoe/test/unitTests/contracts/test-priceAggregator.js +++ b/packages/zoe/test/unitTests/contracts/test-priceAggregator.js @@ -133,7 +133,10 @@ test('median aggregator', /** @param {ExecutionContext} t */ async t => { // TODO: Port this to makeQuoteNotifier(amountIn, brandOut) // @ts-ignore fix needed - const notifier = E(pa).getPriceNotifier(brandIn, brandOut); + const notifier = E(pa).makeQuoteNotifier( + amountMath.make(brandIn, 1n), + brandOut, + ); await E(aggregator.creatorFacet).initOracle(price1000.instance, { increment: 10n, }); diff --git a/packages/zoe/tools/types.js b/packages/zoe/tools/types.js index 733c88e9fab..2012b2219ad 100644 --- a/packages/zoe/tools/types.js +++ b/packages/zoe/tools/types.js @@ -44,8 +44,8 @@ /** * @typedef {Object} MutableQuote - * @property {() => void} cancel - * @property {() => void} updateLevel + * @property {(reason?: any) => void} cancel + * @property {(amountIn: Amount, amountOut: Amount) => void} updateLevel * @property {() => ERef} getPromise */