Skip to content

Commit

Permalink
refactor: review suggestions
Browse files Browse the repository at this point in the history
  • Loading branch information
erights committed Aug 29, 2023
1 parent 2fbb6d0 commit 8ec2f74
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 15 deletions.
6 changes: 5 additions & 1 deletion packages/swingset-liveslots/src/vatDataTypes.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ import type {
WeakSetStore,
} from '@agoric/store';

// TODO should be moved into @endo/patterns and eventually imported here
// instead of this local definition.
export type InterfaceGuardKit = Record<string, InterfaceGuard>;

export type { MapStore, Pattern };

// This needs `any` values. If they were `unknown`, code that uses Baggage
Expand Down Expand Up @@ -125,7 +129,7 @@ export type DefineKindOptions<C> = {
* In absence, an exo is protected anyway, while a bare kind is
* not (detected by `!thisfulMethods`),
*/
interfaceGuardKit?: Record<string, InterfaceGuard>;
interfaceGuardKit?: InterfaceGuardKit;
};

export type VatData = {
Expand Down
27 changes: 13 additions & 14 deletions packages/vat-data/src/exo-utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,19 @@ import { initEmpty } from '@agoric/store';

import { provide, VatData as globalVatData } from './vat-data-bindings.js';

/** @typedef {import('@endo/patterns').MethodGuard} MethodGuard */
/**
* @template {Record<string | symbol, MethodGuard>} [T=Record<string | symbol, MethodGuard>]
* @typedef {import('@endo/patterns').InterfaceGuard<T>} InterfaceGuard
*/
/** @template L,R @typedef {import('@endo/eventual-send').RemotableBrand<L, R>} RemotableBrand */
/** @template T @typedef {import('@endo/far').ERef<T>} ERef */
/** @typedef {import('@agoric/swingset-liveslots').Baggage} Baggage */
/** @template T @typedef {import('@agoric/swingset-liveslots').DefineKindOptions<T>} DefineKindOptions */
/** @template T @typedef {import('@agoric/swingset-liveslots').KindFacet<T>} KindFacet */
/** @template T @typedef {import('@agoric/swingset-liveslots').KindFacets<T>} KindFacets */
/** @typedef {import('@agoric/swingset-liveslots').DurableKindHandle} DurableKindHandle */
/** @typedef {import('@agoric/swingset-liveslots').InterfaceGuardKit} InterfaceGuardKit */

/**
* Make a version of the argument function that takes a kind context but
Expand Down Expand Up @@ -81,12 +87,11 @@ export const makeExoUtils = VatData => {
);
harden(prepareKindMulti);

// TODO interfaceGuard type https://github.com/Agoric/agoric-sdk/issues/6206
/**
* @template {(...args: any) => any} I init state function
* @template T behavior
* @param {string} tag
* @param {any} interfaceGuard
* @param {InterfaceGuard | undefined} interfaceGuard
* @param {I} init
* @param {T & ThisType<{
* self: T,
Expand All @@ -106,12 +111,11 @@ export const makeExoUtils = VatData => {
});
harden(defineVirtualExoClass);

// TODO interfaceGuardKit type https://github.com/Agoric/agoric-sdk/issues/6206
/**
* @template {(...args: any) => any} I init state function
* @template {Record<string, Record<string | symbol, CallableFunction>>} T facets
* @param {string} tag
* @param {any} interfaceGuardKit
* @param {InterfaceGuardKit | undefined} interfaceGuardKit
* @param {I} init
* @param {T & ThisType<{
* facets: T,
Expand All @@ -137,12 +141,11 @@ export const makeExoUtils = VatData => {
});
harden(defineVirtualExoClassKit);

// TODO interfaceGuard type https://github.com/Agoric/agoric-sdk/issues/6206
/**
* @template {(...args: any) => any} I init state function
* @template {Record<string | symbol, CallableFunction>} T methods
* @param {DurableKindHandle} kindHandle
* @param {any} interfaceGuard
* @param {InterfaceGuard | undefined} interfaceGuard
* @param {I} init
* @param {T & ThisType<{
* self: T,
Expand All @@ -168,12 +171,11 @@ export const makeExoUtils = VatData => {
});
harden(defineDurableExoClass);

// TODO interfaceGuardKit type https://github.com/Agoric/agoric-sdk/issues/6206
/**
* @template {(...args: any) => any} I init state function
* @template {Record<string, Record<string | symbol, CallableFunction>>} T facets
* @param {DurableKindHandle} kindHandle
* @param {any} interfaceGuardKit
* @param {InterfaceGuardKit | undefined} interfaceGuardKit
* @param {I} init
* @param {T & ThisType<{
* facets: T,
Expand All @@ -199,13 +201,12 @@ export const makeExoUtils = VatData => {
});
harden(defineDurableExoClassKit);

// TODO interfaceGuard type https://github.com/Agoric/agoric-sdk/issues/6206
/**
* @template {(...args: any) => any} I init state function
* @template {Record<string | symbol, CallableFunction>} T methods
* @param {Baggage} baggage
* @param {string} kindName
* @param {any} interfaceGuard
* @param {InterfaceGuard | undefined} interfaceGuard
* @param {I} init
* @param {T & ThisType<{
* self: T,
Expand Down Expand Up @@ -234,13 +235,12 @@ export const makeExoUtils = VatData => {
);
harden(prepareExoClass);

// TODO interfaceGuardKit type https://github.com/Agoric/agoric-sdk/issues/6206
/**
* @template {(...args: any) => any} I init state function
* @template {Record<string, Record<string | symbol, CallableFunction>>} T facets
* @param {Baggage} baggage
* @param {string} kindName
* @param {any} interfaceGuardKit
* @param {InterfaceGuardKit | undefined} interfaceGuardKit
* @param {I} init
* @param {T & ThisType<{
* facets: T,
Expand Down Expand Up @@ -269,12 +269,11 @@ export const makeExoUtils = VatData => {
);
harden(prepareExoClassKit);

// TODO interfaceGuard type https://github.com/Agoric/agoric-sdk/issues/6206
/**
* @template {Record<string | symbol, CallableFunction>} M methods
* @param {Baggage} baggage
* @param {string} kindName
* @param {any} interfaceGuard
* @param {InterfaceGuard | undefined} interfaceGuard
* @param {M} methods
* @param {DefineKindOptions<{ self: M }>} [options]
* @returns {M & RemotableBrand<{}, M>}
Expand Down

0 comments on commit 8ec2f74

Please sign in to comment.