@agoric/vat-data 0.5.3-dev-2b7c650.0 → 0.5.3-mainnet1B-dev-2d6b13f.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/CHANGELOG.md CHANGED
@@ -3,6 +3,22 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ### [0.5.3-u11wf.0](https://github.com/Agoric/agoric-sdk/compare/@agoric/vat-data@0.5.3-u11.0...@agoric/vat-data@0.5.3-u11wf.0) (2023-09-23)
7
+
8
+ **Note:** Version bump only for package @agoric/vat-data
9
+
10
+
11
+
12
+
13
+
14
+ ### [0.5.3-u11.0](https://github.com/Agoric/agoric-sdk/compare/@agoric/vat-data@0.5.2...@agoric/vat-data@0.5.3-u11.0) (2023-08-24)
15
+
16
+ **Note:** Version bump only for package @agoric/vat-data
17
+
18
+
19
+
20
+
21
+
6
22
  ### [0.5.2](https://github.com/Agoric/agoric-sdk/compare/@agoric/vat-data@0.5.1...@agoric/vat-data@0.5.2) (2023-06-02)
7
23
 
8
24
  **Note:** Version bump only for package @agoric/vat-data
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agoric/vat-data",
3
- "version": "0.5.3-dev-2b7c650.0+2b7c650",
3
+ "version": "0.5.3-mainnet1B-dev-2d6b13f.0+2d6b13f",
4
4
  "description": "Safe access to VatData global",
5
5
  "type": "module",
6
6
  "repository": "https://github.com/Agoric/agoric-sdk",
@@ -19,26 +19,20 @@
19
19
  "author": "Agoric",
20
20
  "license": "Apache-2.0",
21
21
  "dependencies": {
22
- "@agoric/assert": "0.6.1-dev-2b7c650.0+2b7c650",
23
- "@agoric/internal": "0.3.3-dev-2b7c650.0+2b7c650",
24
- "@agoric/store": "0.9.3-dev-2b7c650.0+2b7c650",
25
- "@agoric/swingset-liveslots": "0.10.3-dev-2b7c650.0+2b7c650"
22
+ "@agoric/assert": "0.6.1-mainnet1B-dev-2d6b13f.0+2d6b13f",
23
+ "@agoric/internal": "0.3.3-mainnet1B-dev-2d6b13f.0+2d6b13f",
24
+ "@agoric/store": "0.9.3-mainnet1B-dev-2d6b13f.0+2d6b13f"
26
25
  },
27
26
  "devDependencies": {
28
- "@endo/init": "^0.5.59",
29
- "ava": "^5.3.0",
27
+ "@agoric/swingset-vat": "0.32.3-mainnet1B-dev-2d6b13f.0+2d6b13f",
28
+ "ava": "^5.2.0",
30
29
  "tsd": "^0.28.1"
31
30
  },
32
- "ava": {
33
- "require": [
34
- "@endo/init/debug.js"
35
- ]
36
- },
37
31
  "publishConfig": {
38
32
  "access": "public"
39
33
  },
40
34
  "engines": {
41
35
  "node": ">=14.15.0"
42
36
  },
43
- "gitHead": "2b7c650eaf3b6616cc37afb3ff9ba4d67779835d"
37
+ "gitHead": "2d6b13f85e7f81644f12be02c2ca9344bd056d2f"
44
38
  }
package/src/exo-utils.js CHANGED
@@ -4,25 +4,19 @@ import { initEmpty } from '@agoric/store';
4
4
 
5
5
  import { provide, VatData as globalVatData } from './vat-data-bindings.js';
6
6
 
7
- /** @typedef {import('@endo/patterns').MethodGuard} MethodGuard */
8
- /**
9
- * @template {Record<PropertyKey, MethodGuard>} [T=Record<PropertyKey, MethodGuard>]
10
- * @typedef {import('@endo/patterns').InterfaceGuard<T>} InterfaceGuard
11
- */
12
7
  /** @template L,R @typedef {import('@endo/eventual-send').RemotableBrand<L, R>} RemotableBrand */
13
8
  /** @template T @typedef {import('@endo/far').ERef<T>} ERef */
14
- /** @typedef {import('@agoric/swingset-liveslots').Baggage} Baggage */
15
- /** @template T @typedef {import('@agoric/swingset-liveslots').DefineKindOptions<T>} DefineKindOptions */
16
- /** @template T @typedef {import('@agoric/swingset-liveslots').KindFacet<T>} KindFacet */
17
- /** @template T @typedef {import('@agoric/swingset-liveslots').KindFacets<T>} KindFacets */
18
- /** @typedef {import('@agoric/swingset-liveslots').DurableKindHandle} DurableKindHandle */
19
- /** @typedef {import('@agoric/swingset-liveslots').InterfaceGuardKit} InterfaceGuardKit */
9
+ /** @typedef {import('./types.js').Baggage} Baggage */
10
+ /** @template T @typedef {import('./types.js').DefineKindOptions<T>} DefineKindOptions */
11
+ /** @template T @typedef {import('./types.js').KindFacet<T>} KindFacet */
12
+ /** @template T @typedef {import('./types.js').KindFacets<T>} KindFacets */
13
+ /** @typedef {import('./types.js').DurableKindHandle} DurableKindHandle */
20
14
 
21
15
  /**
22
16
  * Make a version of the argument function that takes a kind context but
23
17
  * ignores it.
24
18
  *
25
- * @type {<T extends Function>(fn: T) => import('@agoric/swingset-liveslots').PlusContext<never, T>}
19
+ * @type {<T extends Function>(fn: T) => import('./types.js').PlusContext<never, T>}
26
20
  */
27
21
  export const ignoreContext =
28
22
  fn =>
@@ -51,7 +45,7 @@ export const makeExoUtils = VatData => {
51
45
 
52
46
  /**
53
47
  * @deprecated Use prepareExoClass instead
54
- * @type {import('@agoric/swingset-liveslots').PrepareKind}
48
+ * @type {import('./types.js').PrepareKind}
55
49
  */
56
50
  const prepareKind = (
57
51
  baggage,
@@ -70,7 +64,7 @@ export const makeExoUtils = VatData => {
70
64
 
71
65
  /**
72
66
  * @deprecated Use prepareExoClassKit instead
73
- * @type {import('@agoric/swingset-liveslots').PrepareKindMulti}
67
+ * @type {import('./types.js').PrepareKindMulti}
74
68
  */
75
69
  const prepareKindMulti = (
76
70
  baggage,
@@ -87,20 +81,15 @@ export const makeExoUtils = VatData => {
87
81
  );
88
82
  harden(prepareKindMulti);
89
83
 
84
+ // TODO interfaceGuard type https://github.com/Agoric/agoric-sdk/issues/6206
90
85
  /**
91
86
  * @template {(...args: any) => any} I init state function
92
87
  * @template T behavior
93
88
  * @param {string} tag
94
- * @param {InterfaceGuard | undefined} interfaceGuard
89
+ * @param {any} interfaceGuard
95
90
  * @param {I} init
96
- * @param {T & ThisType<{
97
- * self: T,
98
- * state: ReturnType<I>
99
- * }>} methods
100
- * @param {DefineKindOptions<{
101
- * self: T,
102
- * state: ReturnType<I>
103
- * }>} [options]
91
+ * @param {T & ThisType<{ self: T, state: ReturnType<I> }>} methods
92
+ * @param {DefineKindOptions<{ self: T, state: ReturnType<I> }>} [options]
104
93
  * @returns {(...args: Parameters<I>) => (T & RemotableBrand<{}, T>)}
105
94
  */
106
95
  const defineVirtualExoClass = (tag, interfaceGuard, init, methods, options) =>
@@ -111,20 +100,15 @@ export const makeExoUtils = VatData => {
111
100
  });
112
101
  harden(defineVirtualExoClass);
113
102
 
103
+ // TODO interfaceGuard type https://github.com/Agoric/agoric-sdk/issues/6206
114
104
  /**
115
105
  * @template {(...args: any) => any} I init state function
116
- * @template {Record<string, Record<PropertyKey, CallableFunction>>} T facets
106
+ * @template {Record<string, Record<string | symbol, CallableFunction>>} T facets
117
107
  * @param {string} tag
118
- * @param {InterfaceGuardKit | undefined} interfaceGuardKit
108
+ * @param {any} interfaceGuardKit
119
109
  * @param {I} init
120
- * @param {T & ThisType<{
121
- * facets: T,
122
- * state: ReturnType<I>
123
- * }> } facets
124
- * @param {DefineKindOptions<{
125
- * facets: T,
126
- * state: ReturnType<I>
127
- * }>} [options]
110
+ * @param {T & ThisType<{ facets: T, state: ReturnType<I> }> } facets
111
+ * @param {DefineKindOptions<{ facets: T, state: ReturnType<I> }>} [options]
128
112
  * @returns {(...args: Parameters<I>) => (T & RemotableBrand<{}, T>)}
129
113
  */
130
114
  const defineVirtualExoClassKit = (
@@ -137,24 +121,19 @@ export const makeExoUtils = VatData => {
137
121
  defineKindMulti(tag, init, facets, {
138
122
  ...options,
139
123
  thisfulMethods: true,
140
- interfaceGuardKit,
124
+ interfaceGuard: interfaceGuardKit,
141
125
  });
142
126
  harden(defineVirtualExoClassKit);
143
127
 
128
+ // TODO interfaceGuard type https://github.com/Agoric/agoric-sdk/issues/6206
144
129
  /**
145
130
  * @template {(...args: any) => any} I init state function
146
- * @template {Record<PropertyKey, CallableFunction>} T methods
131
+ * @template {Record<string | symbol, CallableFunction>} T methods
147
132
  * @param {DurableKindHandle} kindHandle
148
- * @param {InterfaceGuard | undefined} interfaceGuard
133
+ * @param {any} interfaceGuard
149
134
  * @param {I} init
150
- * @param {T & ThisType<{
151
- * self: T,
152
- * state: ReturnType<I>
153
- * }>} methods
154
- * @param {DefineKindOptions<{
155
- * self: T,
156
- * state: ReturnType<I>
157
- * }>} [options]
135
+ * @param {T & ThisType<{ self: T, state: ReturnType<I> }>} methods
136
+ * @param {DefineKindOptions<{ self: T, state: ReturnType<I> }>} [options]
158
137
  * @returns {(...args: Parameters<I>) => (T & RemotableBrand<{}, T>)}
159
138
  */
160
139
  const defineDurableExoClass = (
@@ -171,20 +150,15 @@ export const makeExoUtils = VatData => {
171
150
  });
172
151
  harden(defineDurableExoClass);
173
152
 
153
+ // TODO interfaceGuard type https://github.com/Agoric/agoric-sdk/issues/6206
174
154
  /**
175
155
  * @template {(...args: any) => any} I init state function
176
- * @template {Record<string, Record<PropertyKey, CallableFunction>>} T facets
156
+ * @template {Record<string, Record<string | symbol, CallableFunction>>} T facets
177
157
  * @param {DurableKindHandle} kindHandle
178
- * @param {InterfaceGuardKit | undefined} interfaceGuardKit
158
+ * @param {any} interfaceGuardKit
179
159
  * @param {I} init
180
- * @param {T & ThisType<{
181
- * facets: T,
182
- * state: ReturnType<I>
183
- * }> } facets
184
- * @param {DefineKindOptions<{
185
- * facets: T,
186
- * state: ReturnType<I>
187
- * }>} [options]
160
+ * @param {T & ThisType<{ facets: T, state: ReturnType<I>}> } facets
161
+ * @param {DefineKindOptions<{ facets: T, state: ReturnType<I>}>} [options]
188
162
  * @returns {(...args: Parameters<I>) => (T & RemotableBrand<{}, T>)}
189
163
  */
190
164
  const defineDurableExoClassKit = (
@@ -197,25 +171,20 @@ export const makeExoUtils = VatData => {
197
171
  defineDurableKindMulti(kindHandle, init, facets, {
198
172
  ...options,
199
173
  thisfulMethods: true,
200
- interfaceGuardKit,
174
+ interfaceGuard: interfaceGuardKit,
201
175
  });
202
176
  harden(defineDurableExoClassKit);
203
177
 
178
+ // TODO interfaceGuard type https://github.com/Agoric/agoric-sdk/issues/6206
204
179
  /**
205
180
  * @template {(...args: any) => any} I init state function
206
- * @template {Record<PropertyKey, CallableFunction>} T methods
181
+ * @template {Record<string | symbol, CallableFunction>} T methods
207
182
  * @param {Baggage} baggage
208
183
  * @param {string} kindName
209
- * @param {InterfaceGuard | undefined} interfaceGuard
184
+ * @param {any} interfaceGuard
210
185
  * @param {I} init
211
- * @param {T & ThisType<{
212
- * self: T,
213
- * state: ReturnType<I>
214
- * }>} methods
215
- * @param {DefineKindOptions<{
216
- * self: T,
217
- * state: ReturnType<I>
218
- * }>} [options]
186
+ * @param {T & ThisType<{ self: T, state: ReturnType<I> }>} methods
187
+ * @param {DefineKindOptions<{ self: T, state: ReturnType<I> }>} [options]
219
188
  * @returns {(...args: Parameters<I>) => (T & RemotableBrand<{}, T>)}
220
189
  */
221
190
  const prepareExoClass = (
@@ -235,21 +204,16 @@ export const makeExoUtils = VatData => {
235
204
  );
236
205
  harden(prepareExoClass);
237
206
 
207
+ // TODO interfaceGuard type https://github.com/Agoric/agoric-sdk/issues/6206
238
208
  /**
239
209
  * @template {(...args: any) => any} I init state function
240
- * @template {Record<string, Record<PropertyKey, CallableFunction>>} T facets
210
+ * @template {Record<string, Record<string | symbol, CallableFunction>>} T facets
241
211
  * @param {Baggage} baggage
242
212
  * @param {string} kindName
243
- * @param {InterfaceGuardKit | undefined} interfaceGuardKit
213
+ * @param {any} interfaceGuardKit
244
214
  * @param {I} init
245
- * @param {T & ThisType<{
246
- * facets: T,
247
- * state: ReturnType<I>
248
- * }> } facets
249
- * @param {DefineKindOptions<{
250
- * facets: T,
251
- * state: ReturnType<I>
252
- * }>} [options]
215
+ * @param {T & ThisType<{ facets: T, state: ReturnType<I> }> } facets
216
+ * @param {DefineKindOptions<{ facets: T, state: ReturnType<I> }>} [options]
253
217
  * @returns {(...args: Parameters<I>) => (T & RemotableBrand<{}, T>)}
254
218
  */
255
219
  const prepareExoClassKit = (
@@ -269,11 +233,12 @@ export const makeExoUtils = VatData => {
269
233
  );
270
234
  harden(prepareExoClassKit);
271
235
 
236
+ // TODO interfaceGuard type https://github.com/Agoric/agoric-sdk/issues/6206
272
237
  /**
273
- * @template {Record<PropertyKey, CallableFunction>} M methods
238
+ * @template {Record<string | symbol, CallableFunction>} M methods
274
239
  * @param {Baggage} baggage
275
240
  * @param {string} kindName
276
- * @param {InterfaceGuard | undefined} interfaceGuard
241
+ * @param {any} interfaceGuard
277
242
  * @param {M} methods
278
243
  * @param {DefineKindOptions<{ self: M }>} [options]
279
244
  * @returns {M & RemotableBrand<{}, M>}
@@ -299,7 +264,7 @@ export const makeExoUtils = VatData => {
299
264
  harden(prepareExo);
300
265
 
301
266
  /**
302
- * @template {Record<PropertyKey, CallableFunction>} M methods
267
+ * @template {Record<string | symbol, CallableFunction>} M methods
303
268
  * @deprecated Use prepareExo instead.
304
269
  * @param {Baggage} baggage
305
270
  * @param {string} kindName
package/src/index.js CHANGED
@@ -42,9 +42,9 @@ export {
42
42
  prepareSingleton,
43
43
  } from './exo-utils.js';
44
44
 
45
- /** @typedef {import('@agoric/swingset-liveslots').Baggage} Baggage */
46
- /** @typedef {import('@agoric/swingset-liveslots').DurableKindHandle} DurableKindHandle */
47
- /** @template T @typedef {import('@agoric/swingset-liveslots').DefineKindOptions<T>} DefineKindOptions */
45
+ /** @typedef {import('./types.js').Baggage} Baggage */
46
+ /** @typedef {import('./types.js').DurableKindHandle} DurableKindHandle */
47
+ /** @template T @typedef {import('./types.js').DefineKindOptions<T>} DefineKindOptions */
48
48
 
49
49
  // //////////////////////////// deprecated /////////////////////////////////////
50
50
 
@@ -1,11 +1,5 @@
1
- /* eslint-disable no-use-before-define */
1
+ /* eslint-disable no-use-before-define, import/no-extraneous-dependencies */
2
2
  import { expectType } from 'tsd';
3
- import type {
4
- KindFacets,
5
- DurableKindHandle,
6
- KindFacet,
7
- FunctionsPlusContext,
8
- } from '@agoric/swingset-liveslots';
9
3
  import {
10
4
  defineKind,
11
5
  defineKindMulti,
@@ -13,6 +7,12 @@ import {
13
7
  defineDurableKind,
14
8
  partialAssign,
15
9
  } from '.';
10
+ import {
11
+ KindFacets,
12
+ DurableKindHandle,
13
+ KindFacet,
14
+ FunctionsPlusContext,
15
+ } from './types.js';
16
16
 
17
17
  /*
18
18
  export const makePaymentMaker = (allegedName: string, brand: unknown) => {
package/src/types.d.ts ADDED
@@ -0,0 +1,203 @@
1
+ /**
2
+ * @file Types for vat-data
3
+ *
4
+ * Facet is a single object with methods.
5
+ * Behavior is a description when defining a kind of what facets it will have.
6
+ * For the non-multi defineKind, there is just one facet so it doesn't have a key.
7
+ */
8
+ import type {
9
+ InterfaceGuard,
10
+ MapStore,
11
+ Pattern,
12
+ SetStore,
13
+ StoreOptions,
14
+ WeakMapStore,
15
+ WeakSetStore,
16
+ } from '@agoric/store';
17
+
18
+ export type { Pattern };
19
+
20
+ export type Baggage = MapStore<string, unknown>;
21
+
22
+ type Tail<T extends any[]> = T extends [head: any, ...rest: infer Rest]
23
+ ? Rest
24
+ : [];
25
+
26
+ type MinusContext<
27
+ F extends (context, ...rest: any[]) => any,
28
+ P extends any[] = Parameters<F>, // P: are the parameters of F
29
+ R = ReturnType<F>, // R: the return type of F
30
+ > = (...args: Tail<P>) => R;
31
+
32
+ export type KindFacet<O> = { [K in keyof O]: MinusContext<O[K]> };
33
+
34
+ export type KindFacets<B> = {
35
+ [FacetKey in keyof B]: KindFacet<B[FacetKey]>;
36
+ };
37
+
38
+ export type KindContext<S, F> = { state: S; self: KindFacet<F> };
39
+ export type MultiKindContext<S, B> = { state: S; facets: KindFacets<B> };
40
+
41
+ export type PlusContext<C, M> = (c: C, ...args: Parameters<M>) => ReturnType<M>;
42
+ export type FunctionsPlusContext<C, O> = {
43
+ [K in keyof O]: PlusContext<C, O[K]>;
44
+ };
45
+
46
+ declare class DurableKindHandleClass {
47
+ private descriptionTag: string;
48
+ }
49
+ export type DurableKindHandle = DurableKindHandleClass;
50
+
51
+ /**
52
+ * Grab bag of options that can be provided to `defineDurableKind` and its
53
+ * siblings. Not all options are meaningful in all contexts. See the
54
+ * doc-comments on each option.
55
+ */
56
+ export type DefineKindOptions<C> = {
57
+ /**
58
+ * If provided, the `finish` function will be called after the instance is
59
+ * made and internally registered, but before it is returned. The finish
60
+ * function is to do any post-intantiation initialization that should be
61
+ * done before exposing the object to its clients.
62
+ */
63
+ finish?: (context: C) => void;
64
+
65
+ /**
66
+ * Meaningful to `makeScalarBigMapStore` and its siblings. These maker
67
+ * fuctions will make either virtual or durable stores, depending on
68
+ * this flag. Defaults to off, making virtual but not durable collections.
69
+ *
70
+ * Generally, durable collections are provided with `provideDurableMapStore`
71
+ * and its sibling, which use this flag internally. If you do not make
72
+ * durable collections by other means, you can consider this as
73
+ * intended for internal use only.
74
+ */
75
+ durable?: boolean;
76
+
77
+ /**
78
+ * If provided, it describes the shape of all state records of instances
79
+ * of this kind.
80
+ */
81
+ stateShape?: { [name: string]: Pattern };
82
+
83
+ /**
84
+ * Intended for internal use only.
85
+ * Should the raw methods receive their `context` argument as their first
86
+ * argument or as their `this` binding? For `defineDurableKind` and its
87
+ * siblings (including `prepareSingleton`), this defaults to off, meaning that
88
+ * their behavior methods receive `context` as their first argument.
89
+ * `prepareExoClass` and its siblings (including `prepareExo`) use
90
+ * this flag internally to indicate that their methods receive `context`
91
+ * as their `this` binding.
92
+ */
93
+ thisfulMethods?: boolean;
94
+
95
+ /**
96
+ * Intended for internal use only.
97
+ * If an `interfaceGuard` is provided, then the raw methods passed alongside
98
+ * it are wrapped by a function that first checks that this method's guard
99
+ * pattern is satisfied before calling the raw method.
100
+ *
101
+ * In `defineDurableKind` and its siblings, this defaults to off.
102
+ * `prepareExoClass` use this internally to protect their raw class methods
103
+ * using the provided interface.
104
+ */
105
+ interfaceGuard?: InterfaceGuard<unknown>;
106
+ };
107
+
108
+ export type VatData = {
109
+ // virtual kinds
110
+ /** @deprecated Use defineVirtualExoClass instead */
111
+ defineKind: <P, S, F>(
112
+ tag: string,
113
+ init: (...args: P) => S,
114
+ facet: F,
115
+ options?: DefineKindOptions<KindContext<S, F>>,
116
+ ) => (...args: P) => KindFacet<F>;
117
+
118
+ /** @deprecated Use defineVirtualExoClassKit instead */
119
+ defineKindMulti: <P, S, B>(
120
+ tag: string,
121
+ init: (...args: P) => S,
122
+ behavior: B,
123
+ options?: DefineKindOptions<MultiKindContext<S, B>>,
124
+ ) => (...args: P) => KindFacets<B>;
125
+
126
+ // durable kinds
127
+ makeKindHandle: (descriptionTag: string) => DurableKindHandle;
128
+
129
+ /** @deprecated Use defineDurableExoClass instead */
130
+ defineDurableKind: <P, S, F>(
131
+ kindHandle: DurableKindHandle,
132
+ init: (...args: P) => S,
133
+ facet: F,
134
+ options?: DefineKindOptions<KindContext<S, F>>,
135
+ ) => (...args: P) => KindFacet<F>;
136
+
137
+ /** @deprecated Use defineDurableExoClassKit instead */
138
+ defineDurableKindMulti: <P, S, B>(
139
+ kindHandle: DurableKindHandle,
140
+ init: (...args: P) => S,
141
+ behavior: B,
142
+ options?: DefineKindOptions<MultiKindContext<S, B>>,
143
+ ) => (...args: P) => KindFacets<B>;
144
+
145
+ providePromiseWatcher: unknown;
146
+ watchPromise: unknown;
147
+
148
+ makeScalarBigMapStore: <K, V>(
149
+ label: string,
150
+ options?: StoreOptions,
151
+ ) => MapStore<K, V>;
152
+ makeScalarBigWeakMapStore: <K, V>(
153
+ label: string,
154
+ options?: StoreOptions,
155
+ ) => WeakMapStore<K, V>;
156
+
157
+ makeScalarBigSetStore: <K>(
158
+ label: string,
159
+ options?: StoreOptions,
160
+ ) => SetStore<K>;
161
+ makeScalarBigWeakSetStore: <K>(
162
+ label: string,
163
+ options?: StoreOptions,
164
+ ) => WeakSetStore<K>;
165
+ canBeDurable: (specimen: unknown) => boolean;
166
+ };
167
+
168
+ // The JSDoc is repeated here and at the function definition so it appears
169
+ // in IDEs where it's used, regardless of type resolution.
170
+ export interface PickFacet {
171
+ /**
172
+ * When making a multi-facet kind, it's common to pick one facet to
173
+ * expose. E.g.,
174
+ *
175
+ * const makeFoo = (a, b, c, d) => makeFooBase(a, b, c, d).self;
176
+ *
177
+ * This helper reduces the duplication:
178
+ *
179
+ * const makeFoo = pickFacet(makeFooBase, 'self');
180
+ */
181
+ <M extends (...args: any[]) => any, F extends keyof ReturnType<M>>(
182
+ maker: M,
183
+ facetName: F,
184
+ ): (...args: Parameters<M>) => ReturnType<M>[F];
185
+ }
186
+
187
+ /** @deprecated Use prepareExoClass instead */
188
+ export type PrepareKind = <P, S, F>(
189
+ baggage: Baggage,
190
+ tag: string,
191
+ init: (...args: P) => S,
192
+ facet: F,
193
+ options?: DefineKindOptions<KindContext<S, F>>,
194
+ ) => (...args: P) => KindFacet<F>;
195
+
196
+ /** @deprecated Use prepareExoClassKit instead */
197
+ export type PrepareKindMulti = <P, S, B>(
198
+ baggage: Baggage,
199
+ tag: string,
200
+ init: (...args: P) => S,
201
+ behavior: B,
202
+ options?: DefineKindOptions<MultiKindContext<S, B>>,
203
+ ) => (...args: P) => KindFacets<B>;
@@ -3,7 +3,7 @@
3
3
  import { Fail } from '@agoric/assert';
4
4
  import { provideLazy } from '@agoric/store';
5
5
 
6
- /** @type {import('@agoric/swingset-liveslots').VatData} */
6
+ /** @type {import('./types').VatData} */
7
7
  let VatDataGlobal;
8
8
  if ('VatData' in globalThis) {
9
9
  globalThis.VatData || Fail`VatData defined in global as null or undefined`;
@@ -62,7 +62,7 @@ export const {
62
62
  *
63
63
  * const makeFoo = pickFacet(makeFooBase, 'self');
64
64
  *
65
- * @type {import('@agoric/swingset-liveslots').PickFacet}
65
+ * @type {import('./types').PickFacet}
66
66
  */
67
67
  export const pickFacet =
68
68
  (maker, facetName) =>
@@ -107,8 +107,8 @@ harden(partialAssign);
107
107
  * intended to eventually be durable has not yet been made durable. A store
108
108
  * marked as fakeDurable will appear to operate normally but any attempt to
109
109
  * upgrade its containing vat will fail with an error.
110
- * @property {import('@agoric/swingset-liveslots').Pattern} [keyShape]
111
- * @property {import('@agoric/swingset-liveslots').Pattern} [valueShape]
110
+ * @property {import('./types').Pattern} [keyShape]
111
+ * @property {import('./types').Pattern} [valueShape]
112
112
  */
113
113
  /**
114
114
  * Unlike `provideLazy`, `provide` should be called at most once
@@ -138,12 +138,12 @@ harden(partialAssign);
138
138
 
139
139
  export const provide =
140
140
  // XXX cast because provideLazy is `any` due to broken type import
141
- /** @type {<K, V>(baggage: import('@agoric/swingset-liveslots').Baggage, key: K, makeValue: (key: K) => V) => V} */ (
141
+ /** @type {<K, V>(baggage: import('./types.js').Baggage, key: K, makeValue: (key: K) => V) => V} */ (
142
142
  provideLazy
143
143
  );
144
144
 
145
145
  // TODO: Find a good home for this function used by @agoric/vat-data and testing code
146
- /** @param {import('@agoric/swingset-liveslots').VatData} VatData */
146
+ /** @param {import('@agoric/vat-data/src/types').VatData} VatData */
147
147
  export const makeStoreUtils = VatData => {
148
148
  const {
149
149
  // eslint-disable-next-line no-shadow -- these literally do shadow the globals
@@ -157,7 +157,7 @@ export const makeStoreUtils = VatData => {
157
157
  } = VatData;
158
158
 
159
159
  /**
160
- * @param {import('@agoric/swingset-liveslots').Baggage} baggage
160
+ * @param {import('./types').Baggage} baggage
161
161
  * @param {string} name
162
162
  * @param {Omit<StoreOptions, 'durable'>} options
163
163
  */
@@ -168,7 +168,7 @@ export const makeStoreUtils = VatData => {
168
168
  harden(provideDurableMapStore);
169
169
 
170
170
  /**
171
- * @param {import('@agoric/swingset-liveslots').Baggage} baggage
171
+ * @param {import('./types').Baggage} baggage
172
172
  * @param {string} name
173
173
  * @param {Omit<StoreOptions, 'durable'>} options
174
174
  */
@@ -179,7 +179,7 @@ export const makeStoreUtils = VatData => {
179
179
  harden(provideDurableWeakMapStore);
180
180
 
181
181
  /**
182
- * @param {import('@agoric/swingset-liveslots').Baggage} baggage
182
+ * @param {import('./types').Baggage} baggage
183
183
  * @param {string} name
184
184
  * @param {Omit<StoreOptions, 'durable'>} options
185
185
  */
@@ -190,7 +190,7 @@ export const makeStoreUtils = VatData => {
190
190
  harden(provideDurableSetStore);
191
191
 
192
192
  /**
193
- * @param {import('@agoric/swingset-liveslots').Baggage} baggage
193
+ * @param {import('./types').Baggage} baggage
194
194
  * @param {string} name
195
195
  * @param {Omit<StoreOptions, 'durable'>} options
196
196
  */
@@ -1,13 +1,9 @@
1
- import test from 'ava';
2
-
1
+ import { test } from '@agoric/swingset-vat/tools/prepare-test-env-ava.js';
3
2
  /* global globalThis */
4
- // @ts-expect-error VatData not optional
5
3
  delete globalThis.VatData;
6
4
 
7
5
  /** @see present.test.js */
8
6
  test('methods available that throw', async t => {
9
7
  const { defineKind } = await import('../src/index.js');
10
- t.throws(() => defineKind('someTag', () => {}, {}), {
11
- message: /VatData unavailable/,
12
- });
8
+ t.throws(defineKind, { message: /VatData unavailable/ });
13
9
  });
@@ -1,12 +1,7 @@
1
- import test from 'ava';
2
-
3
- const mockDefineKind = /** @type {any} */ (harden({}));
4
-
5
- /* global globalThis */
6
- // @ts-expect-error missing fields
7
- globalThis.VatData ||= { defineKind: mockDefineKind };
1
+ import { test } from '@agoric/swingset-vat/tools/prepare-test-env-ava.js';
8
2
 
9
3
  test('methods available', async t => {
10
4
  const { defineKind } = await import('../src/index.js');
11
- t.is(defineKind, mockDefineKind);
5
+ defineKind('test', () => {}, {});
6
+ t.pass();
12
7
  });
@@ -1,8 +1,6 @@
1
1
  // Modeled on test-heap-classes.js
2
2
 
3
- import '@agoric/swingset-liveslots/tools/prepare-test-env.js';
4
-
5
- import test from 'ava';
3
+ import { test } from '@agoric/swingset-vat/tools/prepare-test-env-ava.js';
6
4
  import { M } from '@agoric/store';
7
5
  import {
8
6
  makeKindHandle,
@@ -1,8 +1,6 @@
1
1
  // Modeled on test-heap-classes.js
2
2
 
3
- import '@agoric/swingset-liveslots/tools/prepare-test-env.js';
4
-
5
- import test from 'ava';
3
+ import { test } from '@agoric/swingset-vat/tools/prepare-test-env-ava.js';
6
4
  import { M } from '@agoric/store';
7
5
  import {
8
6
  prepareExoClass,
@@ -1,14 +1,14 @@
1
1
  // From https://github.com/Agoric/agoric-sdk/pull/6903#discussion_r1098067133
2
2
 
3
- import '@agoric/swingset-liveslots/tools/prepare-test-env.js';
3
+ import { test } from '@agoric/swingset-vat/tools/prepare-test-env-ava.js';
4
4
 
5
- import test from 'ava';
6
5
  import { M, makeScalarMapStore } from '@agoric/store';
6
+
7
7
  import { makeScalarBigMapStore } from '../src/vat-data-bindings.js';
8
8
 
9
9
  test('scalar maps should reject non-scalar keys', t => {
10
10
  const bigMap = makeScalarMapStore('dummy', { keyShape: M.key() });
11
- t.throws(() => bigMap.init(harden({ label: 'not a scalar' }), 'val'), {
11
+ t.throws(() => bigMap.init(harden({ label: 'not a scalar' })), {
12
12
  message:
13
13
  /A "copyRecord" cannot be a scalar key: \{"label":"not a scalar"\}/,
14
14
  });
@@ -1,8 +1,6 @@
1
1
  // Modeled on test-heap-classes.js
2
2
 
3
- import '@agoric/swingset-liveslots/tools/prepare-test-env.js';
4
-
5
- import test from 'ava';
3
+ import { test } from '@agoric/swingset-vat/tools/prepare-test-env-ava.js';
6
4
  import { M } from '@agoric/store';
7
5
  import {
8
6
  defineVirtualExoClass,
package/tsconfig.json CHANGED
@@ -1,10 +1,8 @@
1
1
  {
2
2
  "extends": "../../tsconfig.json",
3
3
  "compilerOptions": {
4
- // XXX to resolve the swingset-liveslots types
5
- "maxNodeModuleJsDepth": 1,
6
- // "strict": true, // disabled for compat with >0 module depth
7
- // "noImplicitAny": false, // for compat with peer packages using ambient types
4
+ "strict": true,
5
+ "noImplicitAny": false, // for compat with peer packages using ambient types
8
6
  },
9
7
  "include": [
10
8
  "src/**/*.js",