Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
turadg committed Jan 19, 2024
1 parent e892930 commit 854ed91
Show file tree
Hide file tree
Showing 8 changed files with 39 additions and 16 deletions.
1 change: 1 addition & 0 deletions packages/notifier/src/subscribe.js
Original file line number Diff line number Diff line change
Expand Up @@ -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}`,
);
Expand Down
4 changes: 2 additions & 2 deletions packages/notifier/src/types-ambient.js
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@

/**
* @template T
* @typedef {NotifierInternals<T> &
* @typedef {import('@endo/marshal').RemotableObject & NotifierInternals<T> &
* ForkableAsyncIterable<T, T> &
* SharableNotifier<T>
* } Notifier<T> an object that can be used to get the current state or updates
Expand All @@ -259,7 +259,7 @@
/**
* @template T
* @typedef {object} NotifierRecord<T> the produced notifier/updater pair
* @property {IterationObserver<T>} updater the (closely-held) notifier producer
* @property {import('@endo/marshal').RemotableObject & IterationObserver<T>} updater the (closely-held) notifier producer
* @property {Notifier<T>} notifier the (widely-held) notifier consumer
*/

Expand Down
3 changes: 2 additions & 1 deletion packages/store/src/stores/scalarWeakMapStore.js
Original file line number Diff line number Diff line change
Expand Up @@ -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<K & object, V>} jsmap
* @param {(k: K, v: V) => void} assertKVOkToAdd
* @param {(k: K, v: V) => void} assertKVOkToSet
Expand Down
2 changes: 1 addition & 1 deletion packages/store/src/stores/scalarWeakSetStore.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { isCopySet } from './store-utils.js';
const { quote: q, Fail } = assert;

/**
* @template K
* @template {Key} K
* @param {WeakSet<K & object>} jsset
* @param {(k: K) => void} assertKeyOkToAdd
* @param {(k: K) => void} [assertKeyOkToDelete]
Expand Down
24 changes: 14 additions & 10 deletions packages/store/src/stores/store-utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand All @@ -24,21 +24,23 @@ 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
* @property {Iterable<K>} iterableKeys
*/

/**
* @template K,V
* @template {Key} K
* @template {Passable} V
* @param {() => Iterable<K>} getRawKeys
* @param {(k: K) => boolean} checkHas
* @param {RankCompare} compare
Expand Down Expand Up @@ -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<K, V>} mapStore
* @param {K} key
* @param {(key: K) => V} makeValue
Expand All @@ -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<K, V>} store
*/
export const makeAtomicProvider = store => {
Expand Down Expand Up @@ -189,13 +192,14 @@ export const makeAtomicProvider = store => {
};
harden(makeAtomicProvider);
/**
* @template K
* @template V
* @template {Key} K
* @template {Passable} V
* @typedef {ReturnType<typeof makeAtomicProvider<K, V>>} AtomicProvider<K, V>
*/

/**
* @template K, V
* @template {Key} K
* @template {Passable} V
* @param {MapStore<K, V[]>} mapStore
* @param {K} key
* @param {V} item
Expand Down
6 changes: 5 additions & 1 deletion packages/store/src/types.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,11 @@

/**
* @template {Key} [K=Key]
* @typedef {object} SetStore
* @typedef {import('@endo/pass-style').RemotableObject & SetStoreMethods<K>} 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.
Expand Down
12 changes: 12 additions & 0 deletions packages/zoe/src/contractFacet/types-ambient.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
*
Expand Down
3 changes: 2 additions & 1 deletion packages/zoe/src/zoeService/zoeStorageManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 854ed91

Please sign in to comment.