From 3764eeea9a391b5dc6c9c7a21e430f358b8f7476 Mon Sep 17 00:00:00 2001 From: Turadg Aleahmad Date: Fri, 15 Dec 2023 11:17:15 -0800 Subject: [PATCH] feat(types): coreEvalEnv --- .../test/psm/gov-replace-committee.js | 7 ++-- packages/vats/src/core/core-eval-env.d.ts | 37 +++++++++++++++++++ 2 files changed, 41 insertions(+), 3 deletions(-) create mode 100644 packages/vats/src/core/core-eval-env.d.ts diff --git a/packages/inter-protocol/test/psm/gov-replace-committee.js b/packages/inter-protocol/test/psm/gov-replace-committee.js index 36be6a6023b..b222a09ee37 100644 --- a/packages/inter-protocol/test/psm/gov-replace-committee.js +++ b/packages/inter-protocol/test/psm/gov-replace-committee.js @@ -1,5 +1,6 @@ /* global E */ -// @ts-nocheck +// @ts-check +/// /** * @file Script to replace the econ governance committee in a SwingSet Core Eval * (aka big hammer) @@ -26,12 +27,12 @@ const { values } = Object; const zip = (xs, ys) => xs.map((x, i) => [x, ys[i]]); /** - * @param {ERef} nameAdmin + * @param {ERef} nameAdmin * @param {string[][]} paths */ const reserveThenGetNamePaths = async (nameAdmin, paths) => { /** - * @param {ERef} nextAdmin + * @param {ERef} nextAdmin * @param {string[]} path */ const nextPath = async (nextAdmin, path) => { diff --git a/packages/vats/src/core/core-eval-env.d.ts b/packages/vats/src/core/core-eval-env.d.ts new file mode 100644 index 00000000000..2fb497f6084 --- /dev/null +++ b/packages/vats/src/core/core-eval-env.d.ts @@ -0,0 +1,37 @@ +/* eslint-disable */ +/** + * @file typesdef for the CoreEval environment + * + * To use add this to the top of the proposal: /// + * + * That directive has to be before imports, but this one's only useful in + * modules that have no imports or named exports. + */ + +import type { VatData } from '@agoric/swingset-liveslots/src/vatDataTypes.js'; +import type { E, Far, getInterfaceOf, passStyleOf } from '@endo/far'; +import type { Assert, VirtualConsole } from 'ses'; +import type { BootstrapModules } from './boot-chain.js'; + +// Provided by 'CORE_EVAL' handler in chain-behaviors.js +declare global { + // bootstrap modules + var behaviors: BootstrapModules['behaviors']; + var utils: BootstrapModules['utils']; + + // @endo/far exports + var E: E; + var Far: Far; + var getInterfaceOfFar: getInterfaceOfFar; + var passStyleOfFar: passStyleOfFar; + + // endowments + var VatData: VatData; + var assert: Assert; + + // console is a VirtualConsole but this directive fails to override the extant global `console` + // var console: VirtualConsole; + + // Base64 and URL are not available in all environments +}