From 854ed91b8c114e5337c2a8c1452774c4f3c743d0 Mon Sep 17 00:00:00 2001 From: Turadg Aleahmad Date: Thu, 18 Jan 2024 16:12:50 -0800 Subject: [PATCH] WIP --- packages/notifier/src/subscribe.js | 1 + packages/notifier/src/types-ambient.js | 4 ++-- .../store/src/stores/scalarWeakMapStore.js | 3 ++- .../store/src/stores/scalarWeakSetStore.js | 2 +- packages/store/src/stores/store-utils.js | 24 +++++++++++-------- packages/store/src/types.js | 6 ++++- .../zoe/src/contractFacet/types-ambient.d.ts | 12 ++++++++++ .../zoe/src/zoeService/zoeStorageManager.js | 3 ++- 8 files changed, 39 insertions(+), 16 deletions(-) diff --git a/packages/notifier/src/subscribe.js b/packages/notifier/src/subscribe.js index e35fa153cfa..80f7f94bcb4 100644 --- a/packages/notifier/src/subscribe.js +++ b/packages/notifier/src/subscribe.js @@ -46,6 +46,7 @@ const reconnectAsNeeded = async (getter, seed = []) => { if (isObject(err) && disconnection && disconnection !== err) { try { assert.note( + // @ts-expect-error FIXME takes more than Error err, X`Attempting to recover from disconnection: ${disconnection}`, ); diff --git a/packages/notifier/src/types-ambient.js b/packages/notifier/src/types-ambient.js index c0e7c40db34..e826245c400 100644 --- a/packages/notifier/src/types-ambient.js +++ b/packages/notifier/src/types-ambient.js @@ -236,7 +236,7 @@ /** * @template T - * @typedef {NotifierInternals & + * @typedef {import('@endo/marshal').RemotableObject & NotifierInternals & * ForkableAsyncIterable & * SharableNotifier * } Notifier an object that can be used to get the current state or updates @@ -259,7 +259,7 @@ /** * @template T * @typedef {object} NotifierRecord the produced notifier/updater pair - * @property {IterationObserver} updater the (closely-held) notifier producer + * @property {import('@endo/marshal').RemotableObject & IterationObserver} updater the (closely-held) notifier producer * @property {Notifier} notifier the (widely-held) notifier consumer */ diff --git a/packages/store/src/stores/scalarWeakMapStore.js b/packages/store/src/stores/scalarWeakMapStore.js index 9bd3db54823..413ef46068a 100644 --- a/packages/store/src/stores/scalarWeakMapStore.js +++ b/packages/store/src/stores/scalarWeakMapStore.js @@ -5,7 +5,8 @@ import { isCopyMap } from './store-utils.js'; const { quote: q, Fail } = assert; /** - * @template K,V + * @template {Key} K + * @template {Passable} V * @param {WeakMap} jsmap * @param {(k: K, v: V) => void} assertKVOkToAdd * @param {(k: K, v: V) => void} assertKVOkToSet diff --git a/packages/store/src/stores/scalarWeakSetStore.js b/packages/store/src/stores/scalarWeakSetStore.js index 4a256ba9207..9feaa6a3817 100644 --- a/packages/store/src/stores/scalarWeakSetStore.js +++ b/packages/store/src/stores/scalarWeakSetStore.js @@ -5,7 +5,7 @@ import { isCopySet } from './store-utils.js'; const { quote: q, Fail } = assert; /** - * @template K + * @template {Key} K * @param {WeakSet} jsset * @param {(k: K) => void} assertKeyOkToAdd * @param {(k: K) => void} [assertKeyOkToDelete] diff --git a/packages/store/src/stores/store-utils.js b/packages/store/src/stores/store-utils.js index b6a359bbce8..c089bc2d4ac 100644 --- a/packages/store/src/stores/store-utils.js +++ b/packages/store/src/stores/store-utils.js @@ -12,7 +12,7 @@ const { Fail, quote: q } = assert; * for now because `@endo/patterns` forgot to export this one. This one is * simple enough that I prefer a reimplementation to a deep import. * - * @param {Passable} s + * @param {unknown} s * @returns {s is CopySet} */ export const isCopySet = s => matches(s, M.set()); @@ -24,13 +24,14 @@ export const isCopySet = s => matches(s, M.set()); * for now because `@endo/patterns` forgot to export this one. This one is * simple enough that I prefer a reimplementation to a deep import. * - * @param {Passable} m + * @param {unknown} m * @returns {m is CopyMap} */ export const isCopyMap = m => matches(m, M.map()); /** - * @template K,V + * @template {Key} K + * @template {Passable} V * @typedef {object} CurrentKeysKit * @property {(k: K, v?: V) => void} assertUpdateOnAdd * @property {(k: K) => void} assertUpdateOnDelete @@ -38,7 +39,8 @@ export const isCopyMap = m => matches(m, M.map()); */ /** - * @template K,V + * @template {Key} K + * @template {Passable} V * @param {() => Iterable} getRawKeys * @param {(k: K) => boolean} checkHas * @param {RankCompare} compare @@ -113,7 +115,8 @@ harden(makeCurrentKeysKit); * already is one, return that. Otherwise, call `makeValue(key)`, remember it as * the value for that key, and return it. * - * @template K,V + * @template {Key} K + * @template {Passable} V * @param {WeakMapStore} mapStore * @param {K} key * @param {(key: K) => V} makeValue @@ -138,8 +141,8 @@ harden(provideLazy); * termination to happen after the make completes and before it reaches durable * storage. * - * @template K - * @template V + * @template {Key} K + * @template {Passable} V * @param {WeakMapStore} store */ export const makeAtomicProvider = store => { @@ -189,13 +192,14 @@ export const makeAtomicProvider = store => { }; harden(makeAtomicProvider); /** - * @template K - * @template V + * @template {Key} K + * @template {Passable} V * @typedef {ReturnType>} AtomicProvider */ /** - * @template K, V + * @template {Key} K + * @template {Passable} V * @param {MapStore} mapStore * @param {K} key * @param {V} item diff --git a/packages/store/src/types.js b/packages/store/src/types.js index c0cf489d6a0..19aa32bb746 100644 --- a/packages/store/src/types.js +++ b/packages/store/src/types.js @@ -72,7 +72,11 @@ /** * @template {Key} [K=Key] - * @typedef {object} SetStore + * @typedef {import('@endo/pass-style').RemotableObject & SetStoreMethods} SetStore + */ +/** + * @template {Key} [K=Key] + * @typedef {object} SetStoreMethods * @property {(key: K) => boolean} has Check if a key exists. The key can be any * JavaScript value, though the answer will always be false for keys that * cannot be found in this store. diff --git a/packages/zoe/src/contractFacet/types-ambient.d.ts b/packages/zoe/src/contractFacet/types-ambient.d.ts index d6610121400..b2eb14daad6 100644 --- a/packages/zoe/src/contractFacet/types-ambient.d.ts +++ b/packages/zoe/src/contractFacet/types-ambient.d.ts @@ -7,6 +7,18 @@ type IssuerOptionsRecord = import('@agoric/ertp').IssuerOptionsRecord; */ type Completion = any; type ZCFMakeEmptySeatKit = (exit?: ExitRule | undefined) => ZcfSeatKit; + +type InvitationAmount = Amount< + 'set', + { + customDetails?: any; + description: string; + handle: any; + instance: any; + installation: Installation; + } +>; + /** * Zoe Contract Facet * diff --git a/packages/zoe/src/zoeService/zoeStorageManager.js b/packages/zoe/src/zoeService/zoeStorageManager.js index 1fde6e0afca..9497f201d67 100644 --- a/packages/zoe/src/zoeService/zoeStorageManager.js +++ b/packages/zoe/src/zoeService/zoeStorageManager.js @@ -275,8 +275,9 @@ export const makeZoeStorageManager = ( ownKeys(customDetails).length >= 1 ? harden({ customDetails }) : harden({}); + /** @type {InvitationAmount} */ const invitationAmount = AmountMath.make( - invitationKit.brand, + /** @type {Brand<'set'>} */ (invitationKit.brand), harden([ { ...extraProperties,