@agoric/swingset-liveslots 0.10.3-dev-7244c71.0 → 0.10.3-dev-28931a7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agoric/swingset-liveslots",
3
- "version": "0.10.3-dev-7244c71.0+7244c71",
3
+ "version": "0.10.3-dev-28931a7.0+28931a7",
4
4
  "description": "SwingSet ocap support layer",
5
5
  "type": "module",
6
6
  "main": "src/index.js",
@@ -17,9 +17,9 @@
17
17
  "lint:eslint": "eslint ."
18
18
  },
19
19
  "dependencies": {
20
- "@agoric/assert": "0.6.1-dev-7244c71.0+7244c71",
21
- "@agoric/internal": "0.3.3-dev-7244c71.0+7244c71",
22
- "@agoric/store": "0.9.3-dev-7244c71.0+7244c71",
20
+ "@agoric/assert": "0.6.1-dev-28931a7.0+28931a7",
21
+ "@agoric/internal": "0.3.3-dev-28931a7.0+28931a7",
22
+ "@agoric/store": "0.9.3-dev-28931a7.0+28931a7",
23
23
  "@endo/eventual-send": "^0.17.5",
24
24
  "@endo/exo": "^0.2.5",
25
25
  "@endo/far": "^0.2.21",
@@ -31,7 +31,7 @@
31
31
  "@endo/promise-kit": "^0.2.59"
32
32
  },
33
33
  "devDependencies": {
34
- "@agoric/kmarshal": "0.1.1-dev-7244c71.0+7244c71",
34
+ "@agoric/kmarshal": "0.1.1-dev-28931a7.0+28931a7",
35
35
  "ava": "^5.3.0"
36
36
  },
37
37
  "files": [
@@ -67,5 +67,5 @@
67
67
  "typeCoverage": {
68
68
  "atLeast": 71.48
69
69
  },
70
- "gitHead": "7244c710962174a886903cf039c0fbe18874287f"
70
+ "gitHead": "28931a75d65404433319234b5cc8507f3772d30a"
71
71
  }
@@ -13,6 +13,7 @@ import type {
13
13
  WeakMapStore,
14
14
  WeakSetStore,
15
15
  } from '@agoric/store';
16
+ import type { makeWatchedPromiseManager } from './watchedPromises.js';
16
17
 
17
18
  // TODO should be moved into @endo/patterns and eventually imported here
18
19
  // instead of this local definition.
@@ -25,17 +26,20 @@ export type { MapStore, Pattern };
25
26
  // onerous.
26
27
  export type Baggage = MapStore<string, any>;
27
28
 
29
+ type WatchedPromisesManager = ReturnType<typeof makeWatchedPromiseManager>;
30
+
28
31
  type Tail<T extends any[]> = T extends [head: any, ...rest: infer Rest]
29
32
  ? Rest
30
33
  : [];
31
34
 
32
- type MinusContext<
33
- F extends (context, ...rest: any[]) => any,
34
- P extends any[] = Parameters<F>, // P: are the parameters of F
35
- R = ReturnType<F>, // R: the return type of F
36
- > = (...args: Tail<P>) => R;
35
+ // used to omit the 'context' parameter
36
+ type OmitFirstArg<F> = F extends (x: any, ...args: infer P) => infer R
37
+ ? (...args: P) => R
38
+ : never;
37
39
 
38
- export type KindFacet<O> = { [K in keyof O]: MinusContext<O[K]> };
40
+ export type KindFacet<O> = {
41
+ [K in keyof O]: OmitFirstArg<O[K]>; // omit the 'context' parameter
42
+ };
39
43
 
40
44
  export type KindFacets<B> = {
41
45
  [FacetKey in keyof B]: KindFacet<B[FacetKey]>;
@@ -169,8 +173,8 @@ export type VatData = {
169
173
  options?: DefineKindOptions<MultiKindContext<S, B>>,
170
174
  ) => (...args: P) => KindFacets<B>;
171
175
 
172
- providePromiseWatcher: unknown;
173
- watchPromise: unknown;
176
+ providePromiseWatcher: WatchedPromisesManager['providePromiseWatcher'];
177
+ watchPromise: WatchedPromisesManager['watchPromise'];
174
178
 
175
179
  makeScalarBigMapStore: <K, V>(
176
180
  label: string,
@@ -322,7 +322,7 @@ const insistSameCapData = (oldCD, newCD) => {
322
322
  * recursion if our returned WeakMap/WeakSet wrappers are subsequently installed
323
323
  * on globalThis.
324
324
  *
325
- * @returns {object} a new virtual object manager.
325
+ * @returns a new virtual object manager.
326
326
  *
327
327
  * The virtual object manager allows the creation of persistent objects that do
328
328
  * not need to occupy memory when they are not in use. It provides five
@@ -1124,6 +1124,7 @@ export const makeVirtualObjectManager = (
1124
1124
  return id;
1125
1125
  };
1126
1126
 
1127
+ /** @type {import('./vatDataTypes').VatData['defineKind']} */
1127
1128
  const defineKind = (tag, init, behavior, options) => {
1128
1129
  const kindID = `${allocateExportID()}`;
1129
1130
  saveVirtualKindDescriptor(kindID, { kindID, tag });
@@ -1139,6 +1140,7 @@ export const makeVirtualObjectManager = (
1139
1140
  );
1140
1141
  };
1141
1142
 
1143
+ /** @type {import('./vatDataTypes').VatData['defineKindMulti']} */
1142
1144
  const defineKindMulti = (tag, init, behavior, options) => {
1143
1145
  const kindID = `${allocateExportID()}`;
1144
1146
  saveVirtualKindDescriptor(kindID, { kindID, tag });
@@ -1178,6 +1180,7 @@ export const makeVirtualObjectManager = (
1178
1180
  return kindHandle;
1179
1181
  };
1180
1182
 
1183
+ /** @type {import('./vatDataTypes').VatData['defineDurableKind']} */
1181
1184
  const defineDurableKind = (kindHandle, init, behavior, options) => {
1182
1185
  kindHandleToID.has(kindHandle) || Fail`unknown handle ${kindHandle}`;
1183
1186
  const kindID = kindHandleToID.get(kindHandle);
@@ -1200,6 +1203,7 @@ export const makeVirtualObjectManager = (
1200
1203
  return maker;
1201
1204
  };
1202
1205
 
1206
+ /** @type {import('./vatDataTypes').VatData['defineDurableKindMulti']} */
1203
1207
  const defineDurableKindMulti = (kindHandle, init, behavior, options) => {
1204
1208
  kindHandleToID.has(kindHandle) || Fail`unknown handle ${kindHandle}`;
1205
1209
  const kindID = kindHandleToID.get(kindHandle);
@@ -147,6 +147,12 @@ export function makeWatchedPromiseManager({
147
147
  }
148
148
  }
149
149
 
150
+ /**
151
+ *
152
+ * @param {Promise} p
153
+ * @param {{onFulfilled?: Function, onRejected?: Function}} watcher
154
+ * @param {...any} args
155
+ */
150
156
  function watchPromise(p, watcher, ...args) {
151
157
  // The following wrapping defers setting up the promise watcher itself to a
152
158
  // later turn so that if the promise to be watched was the return value from
@@ -15,6 +15,7 @@ async function runDurabilityCheckTest(t, relaxDurabilityRules) {
15
15
 
16
16
  const durableHolderKind = makeKindHandle('holder');
17
17
 
18
+ /** @param {any} held */
18
19
  const initHolder = (held = null) => ({ held });
19
20
  const holderBehavior = {
20
21
  hold: ({ state }, value) => {
@@ -11,16 +11,21 @@ const { WeakMap, WeakSet } = globalThis;
11
11
  let fakeVomKit;
12
12
 
13
13
  globalThis.VatData = harden({
14
+ // @ts-expect-error spread argument for non-rest parameter
14
15
  defineKind: (...args) => fakeVomKit.vom.defineKind(...args),
16
+ // @ts-expect-error spread argument for non-rest parameter
15
17
  defineKindMulti: (...args) => fakeVomKit.vom.defineKindMulti(...args),
18
+ // @ts-expect-error spread argument for non-rest parameter
16
19
  defineDurableKind: (...args) => fakeVomKit.vom.defineDurableKind(...args),
17
20
  defineDurableKindMulti: (...args) =>
21
+ // @ts-expect-error spread argument for non-rest parameter
18
22
  fakeVomKit.vom.defineDurableKindMulti(...args),
19
- makeKindHandle: (...args) => fakeVomKit.vom.makeKindHandle(...args),
23
+ makeKindHandle: tag => fakeVomKit.vom.makeKindHandle(tag),
20
24
  canBeDurable: (...args) => fakeVomKit.vom.canBeDurable(...args),
21
25
  providePromiseWatcher: (...args) =>
22
26
  fakeVomKit.wpm.providePromiseWatcher(...args),
23
- watchPromise: (...args) => fakeVomKit.wpm.watchPromise(...args),
27
+ watchPromise: (p, watcher, ...args) =>
28
+ fakeVomKit.wpm.watchPromise(p, watcher, ...args),
24
29
  makeScalarBigMapStore: (...args) =>
25
30
  fakeVomKit.cm.makeScalarBigMapStore(...args),
26
31
  makeScalarBigWeakMapStore: (...args) =>
@@ -47,7 +52,9 @@ export const reincarnate = (options = {}) => {
47
52
  WeakSet,
48
53
  });
49
54
 
55
+ // @ts-expect-error toStringTag set imperatively so it doesn't show up in the type
50
56
  globalThis.WeakMap = fakeVomKit.vom.VirtualObjectAwareWeakMap;
57
+ // @ts-expect-error ditto
51
58
  globalThis.WeakSet = fakeVomKit.vom.VirtualObjectAwareWeakSet;
52
59
 
53
60
  return { ...options, fakeStore, fakeVomKit };