Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(base-zone,zone): import isPassable from @endo/pass-style #9230

Merged
merged 3 commits into from
Apr 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions packages/base-zone/src/heap.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// @ts-check
// @jessie-check

import { Far } from '@endo/far';
import { Far, isPassable } from '@endo/pass-style';
import { makeExo, defineExoClass, defineExoClassKit } from '@endo/exo';
import {
makeScalarMapStore,
Expand All @@ -12,7 +12,6 @@ import {

import { makeOnceKit } from './make-once.js';
import { agoricVatDataKeys as keys } from './keys.js';
import { isPassable } from './is-passable.js';

/**
* @type {import('./types.js').Stores}
Expand Down
21 changes: 3 additions & 18 deletions packages/base-zone/src/is-passable.js
Original file line number Diff line number Diff line change
@@ -1,23 +1,8 @@
import { passStyleOf } from '@endo/pass-style';
import { isPassable as realIsPassable } from '@endo/pass-style';

/**
* Is `specimen` Passable? This returns true iff `passStyleOf(specimen)`
* returns a string. This returns `false` iff `passStyleOf(specimen)` throws.
* Under no normal circumstance should `isPassable(specimen)` throw.
*
* TODO implement an isPassable that does not rely on try/catch, and
* move it to @endo/pass-style.
* This implementation is just a standin until then
*
* @deprecated Import `isPassable` directly from `@endo/pass-style`
* @param {any} specimen
* @returns {specimen is Passable}
*/
export const isPassable = specimen => {
try {
// In fact, it never returns undefined. It either returns a
// string or throws.
return passStyleOf(specimen) !== undefined;
} catch (_) {
return false;
}
};
export const isPassable = specimen => realIsPassable(specimen);
8 changes: 2 additions & 6 deletions packages/zone/src/durable.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// @ts-check
// @jessie-check

import { Far } from '@endo/far';
import { Far, isPassable } from '@endo/pass-style';
import {
canBeDurable,
makeScalarMapStore,
Expand All @@ -14,11 +14,7 @@ import {
provideDurableWeakSetStore,
} from '@agoric/vat-data';

import {
agoricVatDataKeys as keys,
isPassable,
makeOnceKit,
} from '@agoric/base-zone';
import { agoricVatDataKeys as keys, makeOnceKit } from '@agoric/base-zone';

const { Fail } = assert;

Expand Down
8 changes: 2 additions & 6 deletions packages/zone/src/virtual.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// @ts-check
// @jessie-check

import { Far } from '@endo/far';
import { Far, isPassable } from '@endo/pass-style';
import {
defineVirtualExoClass,
defineVirtualExoClassKit,
Expand All @@ -11,11 +11,7 @@ import {
makeScalarBigWeakSetStore,
} from '@agoric/vat-data';

import {
agoricVatDataKeys as keys,
isPassable,
makeOnceKit,
} from '@agoric/base-zone';
import { agoricVatDataKeys as keys, makeOnceKit } from '@agoric/base-zone';

const emptyRecord = harden({});
const initEmpty = harden(() => emptyRecord);
Expand Down
Loading