From 71d18c4221f63f1c0e7c45562b5a0a86a0b4b5c0 Mon Sep 17 00:00:00 2001 From: Turadg Aleahmad Date: Mon, 29 Apr 2024 09:41:40 -0700 Subject: [PATCH 01/14] feat(types): ambient exports from agoric/internal --- packages/cache/src/main.js | 2 ++ packages/casting/src/main.js | 2 ++ packages/internal/exported.d.ts | 27 +++++++++++++++++++++++++++ packages/internal/exported.js | 2 ++ packages/internal/package.json | 4 +++- packages/notifier/src/index.js | 2 ++ 6 files changed, 38 insertions(+), 1 deletion(-) create mode 100644 packages/internal/exported.d.ts create mode 100644 packages/internal/exported.js diff --git a/packages/cache/src/main.js b/packages/cache/src/main.js index 9ec4164ff9f..aa2a6ba5c29 100644 --- a/packages/cache/src/main.js +++ b/packages/cache/src/main.js @@ -1,5 +1,7 @@ // @jessie-check +import '@agoric/internal/exported.js'; + // eslint-disable-next-line import/export export * from './types.js'; export * from './store.js'; diff --git a/packages/casting/src/main.js b/packages/casting/src/main.js index 994755f3165..c4ea270603c 100644 --- a/packages/casting/src/main.js +++ b/packages/casting/src/main.js @@ -1,5 +1,7 @@ // @jessie-check +import '@agoric/internal/exported.js'; + // eslint-disable-next-line import/export export * from './types.js'; // no named exports export * from './defaults.js'; diff --git a/packages/internal/exported.d.ts b/packages/internal/exported.d.ts new file mode 100644 index 00000000000..2fae75c406e --- /dev/null +++ b/packages/internal/exported.d.ts @@ -0,0 +1,27 @@ +/** @file Declare common ambient types */ +/* eslint-disable import/named */ +import { ERef as _ERef } from '@endo/far'; +import { Passable as _Passable } from '@endo/pass-style'; +import { + PromiseKit as _PromiseKit, + PromiseRecord as _PromiseRecord, +} from '@endo/promise-kit'; +import { + Marshaller as _Marshaller, + StorageNode as _StorageNode, + Unserializer as _Unserializer, + VStorageKey as _VStorageKey, +} from './src/lib-chainStorage.js'; + +declare global { + export { + _ERef as ERef, + _Passable as Passable, + _Marshaller as Marshaller, + _PromiseKit as PromiseKit, + _PromiseRecord as PromiseRecord, + _StorageNode as StorageNode, + _Unserializer as Unserializer, + _VStorageKey as VStorageKey, + }; +} diff --git a/packages/internal/exported.js b/packages/internal/exported.js new file mode 100644 index 00000000000..ff54cc24a93 --- /dev/null +++ b/packages/internal/exported.js @@ -0,0 +1,2 @@ +// Dummy file for .d.ts twin to declare ambients +export {}; diff --git a/packages/internal/package.json b/packages/internal/package.json index 6d6401f8284..b07150362f0 100755 --- a/packages/internal/package.json +++ b/packages/internal/package.json @@ -26,6 +26,7 @@ "@endo/far": "^1.1.1", "@endo/init": "^1.1.1", "@endo/marshal": "^1.4.1", + "@endo/pass-style": "^1.3.1", "@endo/patterns": "^1.3.1", "@endo/promise-kit": "^1.1.1", "@endo/stream": "^1.2.1", @@ -45,7 +46,8 @@ "author": "Agoric", "license": "Apache-2.0", "files": [ - "src" + "src", + "exported.js" ], "publishConfig": { "access": "public" diff --git a/packages/notifier/src/index.js b/packages/notifier/src/index.js index 6374f5c7b18..c57da792d9d 100644 --- a/packages/notifier/src/index.js +++ b/packages/notifier/src/index.js @@ -1,5 +1,7 @@ // @jessie-check +import '@agoric/internal/exported.js'; + export { makePublishKit, prepareDurablePublishKit, From 0bc72a88c7d91ff1b2f00ee5cabeb58c6315598e Mon Sep 17 00:00:00 2001 From: Turadg Aleahmad Date: Mon, 29 Apr 2024 09:42:59 -0700 Subject: [PATCH 02/14] feat(types): explicit exports from notifier --- packages/ERTP/src/legacy-payment-helpers.js | 5 ++- packages/ERTP/src/transientNotifier.js | 5 ++- packages/ERTP/src/types.js | 5 ++- packages/casting/src/types.js | 8 ++-- packages/notifier/exported.d.ts | 43 +++++++++++++++++++ packages/notifier/exported.js | 5 +-- packages/notifier/package.json | 2 +- packages/notifier/src/asyncIterableAdaptor.js | 5 ++- packages/notifier/src/index.js | 3 ++ packages/notifier/src/notifier.js | 5 ++- packages/notifier/src/publish-kit.js | 5 ++- packages/notifier/src/stored-notifier.js | 6 +++ packages/notifier/src/storesub.js | 8 +++- packages/notifier/src/subscribe.js | 7 ++- packages/notifier/src/subscriber.js | 4 +- packages/notifier/src/topic.js | 5 ++- .../src/{types-ambient.js => types.js} | 23 +++++----- .../notifier/test/iterable-testing-tools.js | 6 ++- .../notifier/test/test-notifier-examples.js | 2 +- packages/notifier/test/test-notifier.js | 5 ++- packages/notifier/test/test-publish-kit.js | 7 ++- .../notifier/test/test-stored-subscription.js | 1 - .../notifier/test/test-subscriber-examples.js | 2 +- packages/notifier/tools/testSupports.js | 5 ++- packages/notifier/tsconfig.json | 2 +- packages/smart-wallet/test/supports.js | 4 ++ packages/zoe/src/zoeService/zoe.js | 4 ++ 27 files changed, 140 insertions(+), 42 deletions(-) create mode 100644 packages/notifier/exported.d.ts rename packages/notifier/src/{types-ambient.js => types.js} (95%) diff --git a/packages/ERTP/src/legacy-payment-helpers.js b/packages/ERTP/src/legacy-payment-helpers.js index d22bb452d64..af53e22a628 100644 --- a/packages/ERTP/src/legacy-payment-helpers.js +++ b/packages/ERTP/src/legacy-payment-helpers.js @@ -4,7 +4,10 @@ import { mustMatch } from '@agoric/store'; import { E } from '@endo/far'; import { AmountMath } from './amountMath.js'; -/** @import {Amount, AssetKind, AmountValue, AssetKindForValue, Payment, Brand, Purse} from './types.js' */ +/** + * @import {ERef} from '@endo/far'); + * @import {Amount, AssetKind, AmountValue, AssetKindForValue, Payment, Brand, Purse} from './types.js' + */ const { Fail } = assert; diff --git a/packages/ERTP/src/transientNotifier.js b/packages/ERTP/src/transientNotifier.js index 990f5b93472..a01eaeb28c1 100644 --- a/packages/ERTP/src/transientNotifier.js +++ b/packages/ERTP/src/transientNotifier.js @@ -4,7 +4,10 @@ import { makeScalarBigWeakMapStore } from '@agoric/vat-data'; import { provideLazy } from '@agoric/store'; import { makeNotifierKit } from '@agoric/notifier'; -/** @import {Purse} from './types.js' */ +/** + * @import {Purse} from './types.js'; + * @import {LatestTopic, NotifierRecord} from '@agoric/notifier'); + */ // Note: Virtual for high cardinality, but *not* durable, and so // broken across an upgrade. diff --git a/packages/ERTP/src/types.js b/packages/ERTP/src/types.js index fa107d94baa..91a97b288b1 100644 --- a/packages/ERTP/src/types.js +++ b/packages/ERTP/src/types.js @@ -5,8 +5,9 @@ export {}; /// /** - * @import {Passable} from '@endo/pass-style') - * @import {CopySet, Key} from '@endo/patterns') + * @import {ERef} from '@endo/far'); + * @import {CopySet, Key} from '@endo/patterns'); + * @import {LatestTopic, NotifierRecord} from '@agoric/notifier'); */ /** diff --git a/packages/casting/src/types.js b/packages/casting/src/types.js index 43d32c571e8..017f80ec199 100644 --- a/packages/casting/src/types.js +++ b/packages/casting/src/types.js @@ -1,11 +1,11 @@ // @jessie-check -// Make this a module. -import '@agoric/notifier'; - +// Ensure this is a module. export {}; -/** @import { ERef } from '@endo/far' */ +/** + * @import {Notifier, Subscription} from '@agoric/notifier'; + */ /** * @typedef {object} LeaderOptions diff --git a/packages/notifier/exported.d.ts b/packages/notifier/exported.d.ts new file mode 100644 index 00000000000..cc24194ec45 --- /dev/null +++ b/packages/notifier/exported.d.ts @@ -0,0 +1,43 @@ +/** @file Declare common ambient types */ +/* eslint-disable import/named */ +import { + EachTopic as _EachTopic, + IterableEachTopic as _IterableEachTopic, + IterationObserver as _IterationObserver, + LatestTopic as _LatestTopic, + Notifier as _Notifier, + NotifierRecord as _NotifierRecord, + PublicationRecord as _PublicationRecord, + Publisher as _Publisher, + PublishKit as _PublishKit, + StoredPublishKit as _StoredPublishKit, + StoredSubscriber as _StoredSubscriber, + StoredSubscription as _StoredSubscription, + Subscriber as _Subscriber, + Subscription as _Subscription, + SubscriptionRecord as _SubscriptionRecord, + UpdateRecord as _UpdateRecord, + VStorageKey as _VStorageKey, +} from './src/types.js'; + +declare global { + export { + _EachTopic as EachTopic, + _IterableEachTopic as IterableEachTopic, + _IterationObserver as IterationObserver, + _LatestTopic as LatestTopic, + _Notifier as Notifier, + _NotifierRecord as NotifierRecord, + _PublicationRecord as PublicationRecord, + _Publisher as Publisher, + _PublishKit as PublishKit, + _StoredPublishKit as StoredPublishKit, + _StoredSubscriber as StoredSubscriber, + _StoredSubscription as StoredSubscription, + _Subscriber as Subscriber, + _Subscription as Subscription, + _SubscriptionRecord as SubscriptionRecord, + _UpdateRecord as UpdateRecord, + _VStorageKey as VStorageKey, + }; +} diff --git a/packages/notifier/exported.js b/packages/notifier/exported.js index c320ce55c37..ff54cc24a93 100644 --- a/packages/notifier/exported.js +++ b/packages/notifier/exported.js @@ -1,3 +1,2 @@ -// @jessie-check - -import './src/types-ambient.js'; +// Dummy file for .d.ts twin to declare ambients +export {}; diff --git a/packages/notifier/package.json b/packages/notifier/package.json index 0953a2e5ce4..df54287d709 100644 --- a/packages/notifier/package.json +++ b/packages/notifier/package.json @@ -9,7 +9,7 @@ }, "scripts": { "build": "exit 0", - "prepack": "echo \"export {}; \" | cat - src/types-ambient.js > src/types.js && tsc --build tsconfig.build.json", + "prepack": "tsc --build tsconfig.build.json", "postpack": "git clean -f '*.d.ts*' src/types.js", "test": "ava", "test:c8": "c8 $C8_OPTIONS ava --config=ava-nesm.config.js", diff --git a/packages/notifier/src/asyncIterableAdaptor.js b/packages/notifier/src/asyncIterableAdaptor.js index b8ab685496d..65e266e2baf 100644 --- a/packages/notifier/src/asyncIterableAdaptor.js +++ b/packages/notifier/src/asyncIterableAdaptor.js @@ -3,7 +3,10 @@ import { E } from '@endo/far'; import { subscribeLatest } from './subscribe.js'; -import './types-ambient.js'; +/** + * @import {ERef} from '@endo/far'; + * @import {BaseNotifier, IterationObserver, LatestTopic} from '../src/types.js'; + */ /** * @deprecated Use `subscribeLatest` from `@agoric/notifier/subscribe.js` instead. diff --git a/packages/notifier/src/index.js b/packages/notifier/src/index.js index c57da792d9d..a45e02790a7 100644 --- a/packages/notifier/src/index.js +++ b/packages/notifier/src/index.js @@ -28,3 +28,6 @@ export { } from './asyncIterableAdaptor.js'; export * from './storesub.js'; export * from './stored-notifier.js'; + +// eslint-disable-next-line import/export -- doesn't know types +export * from './types.js'; diff --git a/packages/notifier/src/notifier.js b/packages/notifier/src/notifier.js index 7dab8342038..f2f50d4ea05 100644 --- a/packages/notifier/src/notifier.js +++ b/packages/notifier/src/notifier.js @@ -3,10 +3,13 @@ import { assert } from '@agoric/assert'; import { E, Far } from '@endo/far'; -import './types-ambient.js'; import { makePublishKit } from './publish-kit.js'; import { subscribeLatest } from './subscribe.js'; +/** + * @import {LatestTopic, Notifier, NotifierRecord, PublishKit, Subscriber, UpdateRecord} from './types.js'; + */ + /** * @template T * @param {ERef>} sharableInternalsP diff --git a/packages/notifier/src/publish-kit.js b/packages/notifier/src/publish-kit.js index e3ab7496c68..7efff5b45df 100644 --- a/packages/notifier/src/publish-kit.js +++ b/packages/notifier/src/publish-kit.js @@ -5,7 +5,10 @@ import { E, Far } from '@endo/far'; import { M, getInterfaceGuardPayload } from '@endo/patterns'; import { makePromiseKit } from '@endo/promise-kit'; -import './types-ambient.js'; +/** + * @import {ERef} from '@endo/far'; + * @import {DurablePublishKitState, DurablePublishKitValueDurability, LatestTopic, Notifier, NotifierRecord, PublicationRecord, Publisher, PublishKit, Subscriber, UpdateRecord} from '../src/types.js'; + */ const { Fail, quote: q } = assert; diff --git a/packages/notifier/src/stored-notifier.js b/packages/notifier/src/stored-notifier.js index 24b639b89b1..b432e2893b3 100644 --- a/packages/notifier/src/stored-notifier.js +++ b/packages/notifier/src/stored-notifier.js @@ -5,6 +5,12 @@ import { makeSerializeToStorage } from '@agoric/internal/src/lib-chainStorage.js import { E, Far } from '@endo/far'; import { observeNotifier } from './asyncIterableAdaptor.js'; +/** + * @import {ERef} from '@endo/far'; + * @import {BaseNotifier, Notifier, StoredFacet} from './types.js'; + * @import {Marshaller, StorageNode, Unserializer} from '@agoric/internal/src/lib-chainStorage.js'; + */ + /** * @template T * @typedef {BaseNotifier & Omit} StoredNotifier diff --git a/packages/notifier/src/storesub.js b/packages/notifier/src/storesub.js index 3389b2b6cb9..bed0f4e9185 100644 --- a/packages/notifier/src/storesub.js +++ b/packages/notifier/src/storesub.js @@ -7,6 +7,12 @@ import { makePublishKit } from './publish-kit.js'; import { makeSubscriptionKit } from './subscriber.js'; import { subscribeEach } from './subscribe.js'; +/** + * @import {ERef} from '@endo/far'; + * @import {IterationObserver, LatestTopic, Notifier, NotifierRecord, PublicationRecord, Publisher, PublishKit, StoredPublishKit, StoredSubscription, StoredSubscriber, Subscriber, Subscription, UpdateRecord} from '../src/types.js'; + * @import {Marshaller, StorageNode, Unserializer} from '@agoric/internal/src/lib-chainStorage.js'; + */ + /** * NB: does not yet survive upgrade https://github.com/Agoric/agoric-sdk/issues/6893 * @@ -97,7 +103,7 @@ export const makeStoredSubscription = ( serializeBodyFormat: 'smallcaps', }), ) => { - /** @type {Unserializer} */ + /** @type {import('@agoric/internal/src/lib-chainStorage.js').Unserializer} */ const unserializer = Far('unserializer', { fromCapData: data => E(marshaller).fromCapData(data), unserialize: data => E(marshaller).fromCapData(data), diff --git a/packages/notifier/src/subscribe.js b/packages/notifier/src/subscribe.js index e35fa153cfa..2265bb21fbb 100644 --- a/packages/notifier/src/subscribe.js +++ b/packages/notifier/src/subscribe.js @@ -2,7 +2,10 @@ import { E, Far } from '@endo/far'; import { isObject } from '@endo/marshal'; import { isUpgradeDisconnection } from '@agoric/internal/src/upgrade-api.js'; -import './types-ambient.js'; +/** + * @import {ERef} from '@endo/far'; + * @import {IterationObserver, LatestTopic, Notifier, NotifierRecord, PublicationRecord, Publisher, PublishKit, StoredPublishKit, StoredSubscription, StoredSubscriber, Subscriber, Subscription, UpdateRecord, EachTopic, ForkableAsyncIterableIterator} from '../src/types.js'; + */ const { details: X, Fail } = assert; const sink = () => {}; @@ -50,7 +53,7 @@ const reconnectAsNeeded = async (getter, seed = []) => { X`Attempting to recover from disconnection: ${disconnection}`, ); } catch (_err) { - // eslint-disable-next-line no-empty + // noop } } throw err; diff --git a/packages/notifier/src/subscriber.js b/packages/notifier/src/subscriber.js index cafdad40877..6d33758754d 100644 --- a/packages/notifier/src/subscriber.js +++ b/packages/notifier/src/subscriber.js @@ -8,7 +8,9 @@ import { makePublishKit } from './publish-kit.js'; import { makePinnedHistoryTopic } from './topic.js'; -import './types-ambient.js'; +/** + * @import {EachTopic, IterationObserver, LatestTopic, Notifier, NotifierRecord, SubscriptionRecord, Publisher, PublishKit, StoredPublishKit, StoredSubscription, StoredSubscriber, Subscriber, Subscription, UpdateRecord} from '../src/types.js'; + */ /** * @template T diff --git a/packages/notifier/src/topic.js b/packages/notifier/src/topic.js index b8a7a575d39..a3a0c35747d 100644 --- a/packages/notifier/src/topic.js +++ b/packages/notifier/src/topic.js @@ -1,7 +1,10 @@ // @jessie-check import { Far } from '@endo/far'; -import './types-ambient.js'; + +/** + * @import {EachTopic, LatestTopic} from '../src/types.js'; + */ /** * @deprecated A pinned-history topic preserves all of its published values in diff --git a/packages/notifier/src/types-ambient.js b/packages/notifier/src/types.js similarity index 95% rename from packages/notifier/src/types-ambient.js rename to packages/notifier/src/types.js index f1c070592f5..e8e94e18f17 100644 --- a/packages/notifier/src/types-ambient.js +++ b/packages/notifier/src/types.js @@ -1,10 +1,7 @@ // @jessie-check -/** @import { ERef } from '@endo/far' */ - -/** - * @import {PromiseKit, PromiseRecord} from '@endo/promise-kit' - */ +// Ensure this is a module. +export {}; /** * @template T @@ -46,7 +43,7 @@ /** * @template T - * @typedef {object} IterationObserver + * @typedef {object} IterationObserver * A valid sequence of calls to the methods of an `IterationObserver` * represents an iteration. A valid sequence consists of any number of calls * to `updateState` with the successive non-final values, followed by a @@ -155,14 +152,14 @@ /** * @template T - * @typedef {object} PublishKit + * @typedef {object} PublishKit * @property {Publisher} publisher * @property {Subscriber} subscriber */ /** * @template T - * @typedef {object} StoredPublishKit + * @typedef {object} StoredPublishKit * @property {Publisher} publisher * @property {StoredSubscriber} subscriber */ @@ -210,7 +207,7 @@ /** * @template T - * @typedef {object} UpdateRecord + * @typedef {object} UpdateRecord * @property {T} value is whatever state the service wants to publish * @property {bigint} [updateCount] is a value that identifies the update. For * the last update, it is `undefined`. @@ -228,7 +225,7 @@ * @typedef {NotifierInternals & * ForkableAsyncIterable & * SharableNotifier - * } Notifier an object that can be used to get the current state or updates + * } Notifier an object that can be used to get the current state or updates */ /** @@ -247,7 +244,7 @@ /** * @template T - * @typedef {object} NotifierRecord the produced notifier/updater pair + * @typedef {object} NotifierRecord the produced notifier/updater pair * @property {IterationObserver} updater the (closely-held) notifier producer * @property {Notifier} notifier the (widely-held) notifier consumer */ @@ -257,7 +254,7 @@ /** * @template T * @typedef {IterableEachTopic & EachTopic & - * SharableSubscription} Subscription + * SharableSubscription} Subscription * A form of AsyncIterable supporting distributed and multicast usage. */ @@ -277,7 +274,7 @@ /** * @template T - * @typedef {object} SubscriptionRecord + * @typedef {object} SubscriptionRecord * @property {IterationObserver} publication * @property {Subscription} subscription */ diff --git a/packages/notifier/test/iterable-testing-tools.js b/packages/notifier/test/iterable-testing-tools.js index 4bde033fb7c..6849cd80704 100644 --- a/packages/notifier/test/iterable-testing-tools.js +++ b/packages/notifier/test/iterable-testing-tools.js @@ -2,7 +2,11 @@ import { E } from '@endo/far'; import { makePromiseKit } from '@endo/promise-kit'; import { observeIteration, observeIterator } from '../src/index.js'; -import '../src/types-ambient.js'; +/** + * @import {ERef} from '@endo/far'; + * @import {BaseNotifier, ForkableAsyncIterator, IterationObserver, Notifier, StoredFacet, Subscription} from '../src/types.js'; + * @import {PromiseKit} from '@endo/promise-kit'; + */ export const invertPromiseSettlement = promise => promise.then( diff --git a/packages/notifier/test/test-notifier-examples.js b/packages/notifier/test/test-notifier-examples.js index c734ed81d44..296cd95819f 100644 --- a/packages/notifier/test/test-notifier-examples.js +++ b/packages/notifier/test/test-notifier-examples.js @@ -9,7 +9,7 @@ import { } from '../src/index.js'; import { paula, alice, bob } from './iterable-testing-tools.js'; -import '../src/types-ambient.js'; +import '../src/types.js'; const last = array => array[array.length - 1]; diff --git a/packages/notifier/test/test-notifier.js b/packages/notifier/test/test-notifier.js index 18fc62d567d..0d5bac94f98 100644 --- a/packages/notifier/test/test-notifier.js +++ b/packages/notifier/test/test-notifier.js @@ -1,6 +1,9 @@ import { test } from './prepare-test-env-ava.js'; import { makeNotifierKit } from '../src/index.js'; -import '../src/types-ambient.js'; + +/** + * @import {IterationObserver, LatestTopic, Notifier, NotifierRecord, PublicationRecord, Publisher, PublishKit, StoredPublishKit, StoredSubscription, StoredSubscriber, Subscriber, Subscription, UpdateRecord} from '../src/types.js'; + */ test('notifier - initial state', async t => { /** @type {NotifierRecord<1>} */ diff --git a/packages/notifier/test/test-publish-kit.js b/packages/notifier/test/test-publish-kit.js index f87d0ae9a41..8f931b934c9 100644 --- a/packages/notifier/test/test-publish-kit.js +++ b/packages/notifier/test/test-publish-kit.js @@ -17,10 +17,13 @@ import { subscribeLatest, prepareDurablePublishKit, } from '../src/index.js'; -import '../src/types-ambient.js'; +import '../src/types.js'; import { invertPromiseSettlement } from './iterable-testing-tools.js'; -/** @import {makePublishKit as MakePublishKit} from '../src/index.js' */ +/** + * @import {makePublishKit as MakePublishKit} from '../src/index.js'; + * @import {PublicationRecord} from '../src/types.js'; + */ const { ownKeys } = Reflect; const { quote: q } = assert; diff --git a/packages/notifier/test/test-stored-subscription.js b/packages/notifier/test/test-stored-subscription.js index 7b21545ae9a..a334ea6cd77 100644 --- a/packages/notifier/test/test-stored-subscription.js +++ b/packages/notifier/test/test-stored-subscription.js @@ -17,7 +17,6 @@ import { makeFakeMarshaller, } from '../tools/testSupports.js'; -import '../src/types-ambient.js'; import { jsonPairs } from './marshal-corpus.js'; test('stored subscription', async t => { diff --git a/packages/notifier/test/test-subscriber-examples.js b/packages/notifier/test/test-subscriber-examples.js index 9ee099d2426..4bac5c2bb25 100644 --- a/packages/notifier/test/test-subscriber-examples.js +++ b/packages/notifier/test/test-subscriber-examples.js @@ -9,7 +9,7 @@ import { } from '../src/index.js'; import { paula, alice, bob, carol } from './iterable-testing-tools.js'; -import '../src/types-ambient.js'; +import '../src/types.js'; test('subscription for-await-of success example', async t => { const { publication, subscription } = makeSubscriptionKit(); diff --git a/packages/notifier/tools/testSupports.js b/packages/notifier/tools/testSupports.js index d8f7ce05719..c89ccd438e8 100644 --- a/packages/notifier/tools/testSupports.js +++ b/packages/notifier/tools/testSupports.js @@ -1,6 +1,9 @@ import { Far, makeMarshal } from '@endo/marshal'; -import '../src/types-ambient.js'; +/** + * @import {IterationObserver} from '../src/types.js'; + * @import {StorageNode} from '@agoric/internal/src/lib-chainStorage.js'; + */ export { eventLoopIteration } from '@agoric/internal/src/testing-utils.js'; diff --git a/packages/notifier/tsconfig.json b/packages/notifier/tsconfig.json index fcd55e9a555..1e246e687b1 100644 --- a/packages/notifier/tsconfig.json +++ b/packages/notifier/tsconfig.json @@ -6,7 +6,7 @@ }, "include": [ "src/**/*.js", - "*.js", + // exclude exported.js so that stub doesn't overwrite exportd.d.ts "test/**/*.js", "tools/**/*.js", ], diff --git a/packages/smart-wallet/test/supports.js b/packages/smart-wallet/test/supports.js index 867dfa5860f..429be3242db 100644 --- a/packages/smart-wallet/test/supports.js +++ b/packages/smart-wallet/test/supports.js @@ -18,6 +18,10 @@ import { makeRatio } from '@agoric/zoe/src/contractSupport/ratio.js'; import { setUpZoeForTest } from '@agoric/zoe/tools/setup-zoe.js'; import { E, Far } from '@endo/far'; +/** + * @import {StoredFacet} from '@agoric/internal/src/lib-chainStorage.js'; + */ + export { ActionType }; /** diff --git a/packages/zoe/src/zoeService/zoe.js b/packages/zoe/src/zoeService/zoe.js index 6234f1696c6..5a83d08bf0a 100644 --- a/packages/zoe/src/zoeService/zoe.js +++ b/packages/zoe/src/zoeService/zoe.js @@ -26,6 +26,10 @@ import { getZcfBundleCap } from './createZCFVat.js'; import { defaultFeeIssuerConfig, prepareFeeMint } from './feeMint.js'; import { ZoeServiceI } from '../typeGuards.js'; +// XXX ambient types runtime imports until https://github.com/Agoric/agoric-sdk/issues/6512 +import '@agoric/internal/exported.js'; +import '@agoric/notifier/exported.js'; + /** @import {Baggage} from '@agoric/vat-data' */ const { Fail } = assert; From 2797d60da9ed72f61f9b3da5b7aed322e8e1e149 Mon Sep 17 00:00:00 2001 From: Turadg Aleahmad Date: Mon, 29 Apr 2024 10:19:44 -0700 Subject: [PATCH 03/14] chore(types): dedupe --- packages/internal/exported.d.ts | 1 - packages/notifier/exported.d.ts | 2 -- packages/notifier/src/stored-notifier.js | 4 +-- packages/notifier/src/types.js | 40 +++--------------------- packages/smart-wallet/src/types.d.ts | 1 + 5 files changed, 7 insertions(+), 41 deletions(-) diff --git a/packages/internal/exported.d.ts b/packages/internal/exported.d.ts index 2fae75c406e..290eb536ffb 100644 --- a/packages/internal/exported.d.ts +++ b/packages/internal/exported.d.ts @@ -16,7 +16,6 @@ import { declare global { export { _ERef as ERef, - _Passable as Passable, _Marshaller as Marshaller, _PromiseKit as PromiseKit, _PromiseRecord as PromiseRecord, diff --git a/packages/notifier/exported.d.ts b/packages/notifier/exported.d.ts index cc24194ec45..c71c0fe73f0 100644 --- a/packages/notifier/exported.d.ts +++ b/packages/notifier/exported.d.ts @@ -17,7 +17,6 @@ import { Subscription as _Subscription, SubscriptionRecord as _SubscriptionRecord, UpdateRecord as _UpdateRecord, - VStorageKey as _VStorageKey, } from './src/types.js'; declare global { @@ -38,6 +37,5 @@ declare global { _Subscription as Subscription, _SubscriptionRecord as SubscriptionRecord, _UpdateRecord as UpdateRecord, - _VStorageKey as VStorageKey, }; } diff --git a/packages/notifier/src/stored-notifier.js b/packages/notifier/src/stored-notifier.js index b432e2893b3..ef36fd952c4 100644 --- a/packages/notifier/src/stored-notifier.js +++ b/packages/notifier/src/stored-notifier.js @@ -7,8 +7,8 @@ import { observeNotifier } from './asyncIterableAdaptor.js'; /** * @import {ERef} from '@endo/far'; - * @import {BaseNotifier, Notifier, StoredFacet} from './types.js'; - * @import {Marshaller, StorageNode, Unserializer} from '@agoric/internal/src/lib-chainStorage.js'; + * @import {BaseNotifier, Notifier} from './types.js'; + * @import {Marshaller, StoredFacet, StorageNode, Unserializer} from '@agoric/internal/src/lib-chainStorage.js'; */ /** diff --git a/packages/notifier/src/types.js b/packages/notifier/src/types.js index e8e94e18f17..d8594fb07ee 100644 --- a/packages/notifier/src/types.js +++ b/packages/notifier/src/types.js @@ -1,5 +1,9 @@ // @jessie-check +/** + * @import {StoredFacet, Unserializer} from '@agoric/internal/src/lib-chainStorage.js'; + */ + // Ensure this is a module. export {}; @@ -281,42 +285,6 @@ export {}; // ///////////////////////////////////////////////////////////////////////////// -/** @template [Slot=unknown] @typedef {import('@endo/marshal').Marshal} Marshaller */ -/** @typedef {Pick} Unserializer */ - -/** - * Defined by vstorageStoreKey in vstorage.go - * - * @typedef VStorageKey - * @property {string} storeName - * @property {string} storeSubkey - * @property {string} dataPrefixBytes - * @property {string} [noDataValue] - */ - -/** - * This represents a node in an IAVL tree. - * - * The active implementation is x/vstorage, an Agoric extension of the Cosmos SDK. - * - * Vstorage is a hierarchical externally-reachable storage structure that - * identifies children by restricted ASCII name and is associated with arbitrary - * string-valued data for each node, defaulting to the empty string. - * - * @typedef {object} StorageNode - * @property {(data: string) => Promise} setValue publishes some data (append to the node) - * @property {() => string} getPath the chain storage path at which the node was constructed - * @property {() => Promise} getStoreKey DEPRECATED use getPath - * @property {(subPath: string, options?: {sequence?: boolean}) => StorageNode} makeChildNode - */ - -/** - * @typedef {object} StoredFacet - * @property {() => Promise} getPath the chain storage path at which the node was constructed - * @property {StorageNode['getStoreKey']} getStoreKey DEPRECATED use getPath - * @property {() => Unserializer} getUnserializer get the unserializer for the stored data - */ - /** * @deprecated use StoredSubscriber * @template T diff --git a/packages/smart-wallet/src/types.d.ts b/packages/smart-wallet/src/types.d.ts index f12822df490..fbce32281a6 100644 --- a/packages/smart-wallet/src/types.d.ts +++ b/packages/smart-wallet/src/types.d.ts @@ -9,6 +9,7 @@ import type { ERef } from '@endo/far'; import type { CapData } from '@endo/marshal'; import type { agoric } from '@agoric/cosmic-proto'; import type { AgoricNamesRemotes } from '@agoric/vats/tools/board-utils.js'; +import type { StoredFacet } from '@agoric/internal/src/lib-chainStorage.js'; import type { OfferSpec } from './offers.js'; declare const CapDataShape: unique symbol; From 514c7fa99b2dee859b90a0e17887ce5cc37828fb Mon Sep 17 00:00:00 2001 From: Turadg Aleahmad Date: Mon, 29 Apr 2024 10:36:54 -0700 Subject: [PATCH 04/14] chore(types): normalize exported.d.ts --- docs/typescript.md | 39 ++++++++++++++++++- packages/ERTP/exported.d.ts | 8 ++-- packages/ERTP/exported.js | 1 + packages/governance/exported.d.ts | 9 +---- packages/internal/exported.d.ts | 5 ++- packages/notifier/exported.d.ts | 5 ++- packages/store/exported.d.ts | 10 +---- packages/store/src/index.js | 2 + packages/store/src/legacy/legacyMap.js | 2 +- packages/store/src/legacy/legacyWeakMap.js | 2 +- packages/store/src/stores/scalarMapStore.js | 9 +++-- packages/store/src/stores/scalarSetStore.js | 5 +++ .../store/src/stores/scalarWeakMapStore.js | 2 + .../store/src/stores/scalarWeakSetStore.js | 2 +- packages/store/src/stores/store-utils.js | 5 ++- packages/store/test/perf-patterns.js | 6 ++- packages/vat-data/src/vat-data-bindings.js | 2 +- .../src/contractFacet/rightsConservation.js | 2 +- packages/zoe/src/contracts/priceAggregator.js | 2 +- 19 files changed, 80 insertions(+), 38 deletions(-) diff --git a/docs/typescript.md b/docs/typescript.md index 71ea63bc8f2..7e5aa98114e 100644 --- a/docs/typescript.md +++ b/docs/typescript.md @@ -6,7 +6,44 @@ Our use of TypeScript has to accomodate both .js development in agoric-sdk (whic - package entrypoint(s) exports explicit types - for packages upon which other packages expect ambient types: - - `exported.d.ts` exports the explicit types and ambient re-exports + - `exported.js` exports the explicit types and ambient re-exports + +## exported.js + +The `exported.js` re-exports types into global namespace, for consumers that expect these to +be ambient. This could be called "ambient.js" but we retain the filename for backwards compatibility. + +The pattern is to make these two files like this at package root: + + +`exported.js` + +```ts +// Dummy file for .d.ts twin to declare ambients +export {}; +``` + +`exported.d.ts` + +```ts +/** @file Ambient exports until https://github.com/Agoric/agoric-sdk/issues/6512 */ +/** @see {@link /docs/typescript.md} */ +/* eslint-disable -- doesn't understand .d.ts */ +import { + SomeType as _SomeType, +} from './src/types.js'; + +declare global { + export { + _SomeType as SomeType, + }; +} +``` + +Why the _ prefix? Because without it TS gets confused between the +import and export symbols. ([h/t](https://stackoverflow.com/a/66588974)) +Note one downside vs ambients is that these types will appear to be on `globalThis`. + ## Generating API docs diff --git a/packages/ERTP/exported.d.ts b/packages/ERTP/exported.d.ts index 45d5d6528db..176ac2c51b9 100644 --- a/packages/ERTP/exported.d.ts +++ b/packages/ERTP/exported.d.ts @@ -1,12 +1,10 @@ +/** @file Ambient exports until https://github.com/Agoric/agoric-sdk/issues/6512 */ +/** @see {@link /docs/typescript.md} */ /* eslint-disable -- doesn't understand .d.ts */ +// XXX also explicit exports because `@agoric/ertp` top level confuses the type and value of `AssetKind` export * from './src/types.js'; -// XXX re-export types into global namespace, for consumers that expect these to -// be ambient. Why the _ prefix? Because without it TS gets confused between the -// import and export symbols. h/t https://stackoverflow.com/a/66588974 -// Note one big downside vs ambients is that these types will appear to be on `globalThis`. -// UNTIL https://github.com/Agoric/agoric-sdk/issues/6512 import { Amount as _Amount, Brand as _Brand, diff --git a/packages/ERTP/exported.js b/packages/ERTP/exported.js index 469002eeeed..ff54cc24a93 100644 --- a/packages/ERTP/exported.js +++ b/packages/ERTP/exported.js @@ -1 +1,2 @@ // Dummy file for .d.ts twin to declare ambients +export {}; diff --git a/packages/governance/exported.d.ts b/packages/governance/exported.d.ts index 1cc353ee415..a3336ac36dd 100644 --- a/packages/governance/exported.d.ts +++ b/packages/governance/exported.d.ts @@ -1,12 +1,7 @@ +/** @file Ambient exports until https://github.com/Agoric/agoric-sdk/issues/6512 */ +/** @see {@link /docs/typescript.md} */ /* eslint-disable -- doesn't understand .d.ts */ -export * from './src/types.js'; - -// XXX re-export types into global namespace, for consumers that expect these to -// be ambient. Why the _ prefix? Because without it TS gets confused between the -// import and export symbols. h/t https://stackoverflow.com/a/66588974 -// Note one big downside vs ambients is that these types will appear to be on `globalThis`. -// UNTIL https://github.com/Agoric/agoric-sdk/issues/6512 import { GovernanceFacetKit as _GovernanceFacetKit, GovernanceTerms as _GovernanceTerms, diff --git a/packages/internal/exported.d.ts b/packages/internal/exported.d.ts index 290eb536ffb..043f11db074 100644 --- a/packages/internal/exported.d.ts +++ b/packages/internal/exported.d.ts @@ -1,5 +1,6 @@ -/** @file Declare common ambient types */ -/* eslint-disable import/named */ +/** @file Ambient exports until https://github.com/Agoric/agoric-sdk/issues/6512 */ +/** @see {@link /docs/typescript.md} */ +/* eslint-disable -- doesn't understand .d.ts */ import { ERef as _ERef } from '@endo/far'; import { Passable as _Passable } from '@endo/pass-style'; import { diff --git a/packages/notifier/exported.d.ts b/packages/notifier/exported.d.ts index c71c0fe73f0..4709364a419 100644 --- a/packages/notifier/exported.d.ts +++ b/packages/notifier/exported.d.ts @@ -1,5 +1,6 @@ -/** @file Declare common ambient types */ -/* eslint-disable import/named */ +/** @file Ambient exports until https://github.com/Agoric/agoric-sdk/issues/6512 */ +/** @see {@link /docs/typescript.md} */ +/* eslint-disable -- doesn't understand .d.ts */ import { EachTopic as _EachTopic, IterableEachTopic as _IterableEachTopic, diff --git a/packages/store/exported.d.ts b/packages/store/exported.d.ts index eb3dc666582..09575b61327 100644 --- a/packages/store/exported.d.ts +++ b/packages/store/exported.d.ts @@ -1,12 +1,6 @@ +/** @file Ambient exports until https://github.com/Agoric/agoric-sdk/issues/6512 */ +/** @see {@link /docs/typescript.md} */ /* eslint-disable -- doesn't understand .d.ts */ - -export * from './src/types.js'; - -// XXX re-export types into global namespace, for consumers that expect these to -// be ambient. Why the _ prefix? Because without it TS gets confused between the -// import and export symbols. h/t https://stackoverflow.com/a/66588974 -// Note one big downside vs ambients is that these types will appear to be on `globalThis`. -// UNTIL https://github.com/Agoric/agoric-sdk/issues/6512 import { LegacyMap as _LegacyMap, LegacyWeakMap as _LegacyWeakMap, diff --git a/packages/store/src/index.js b/packages/store/src/index.js index 92188765007..cbfe2aa7aa6 100755 --- a/packages/store/src/index.js +++ b/packages/store/src/index.js @@ -67,3 +67,5 @@ export { export { makeLegacyMap } from './legacy/legacyMap.js'; export { makeLegacyWeakMap } from './legacy/legacyWeakMap.js'; +// eslint-disable-next-line import/export +export * from './types.js'; diff --git a/packages/store/src/legacy/legacyMap.js b/packages/store/src/legacy/legacyMap.js index 9b40a0f2492..6c07685c9fa 100644 --- a/packages/store/src/legacy/legacyMap.js +++ b/packages/store/src/legacy/legacyMap.js @@ -1,4 +1,4 @@ -import '../types.js'; +/** @import {LegacyMap, LegacyWeakMap} from '../types.js'; */ // TODO, once migrated to endo, import from @endo/errors instead const { Fail, quote: q } = assert; diff --git a/packages/store/src/legacy/legacyWeakMap.js b/packages/store/src/legacy/legacyWeakMap.js index e7167137927..56ff91718b3 100644 --- a/packages/store/src/legacy/legacyWeakMap.js +++ b/packages/store/src/legacy/legacyWeakMap.js @@ -1,4 +1,4 @@ -import '../types.js'; +/** @import {LegacyWeakMap} from '../types.js'; */ // TODO, once migrated to endo, import from @endo/errors instead const { Fail, quote: q } = assert; diff --git a/packages/store/src/stores/scalarMapStore.js b/packages/store/src/stores/scalarMapStore.js index 8560c65f4d0..63ee0354485 100644 --- a/packages/store/src/stores/scalarMapStore.js +++ b/packages/store/src/stores/scalarMapStore.js @@ -15,13 +15,14 @@ import { import { makeWeakMapStoreMethods } from './scalarWeakMapStore.js'; import { makeCurrentKeysKit } from './store-utils.js'; -const { quote: q } = assert; - /** - * @import {Passable} from '@endo/pass-style') - * @import {Key} from '@endo/patterns') + * @import {Passable} from '@endo/pass-style'); + * @import {Key, Pattern} from '@endo/patterns'); + * @import {MapStore, StoreOptions} from '../types.js'; */ +const { quote: q } = assert; + /** * @template {Key} K * @template {Passable} V diff --git a/packages/store/src/stores/scalarSetStore.js b/packages/store/src/stores/scalarSetStore.js index 11146e5f28c..e7698954cd9 100644 --- a/packages/store/src/stores/scalarSetStore.js +++ b/packages/store/src/stores/scalarSetStore.js @@ -10,6 +10,11 @@ import { import { makeWeakSetStoreMethods } from './scalarWeakSetStore.js'; import { makeCurrentKeysKit } from './store-utils.js'; +/** + * @import {Key, Pattern} from '@endo/patterns'); + * @import {SetStore, StoreOptions} from '../types.js'; + */ + const { quote: q } = assert; /** diff --git a/packages/store/src/stores/scalarWeakMapStore.js b/packages/store/src/stores/scalarWeakMapStore.js index 1062ac554b8..ebfee6b9aa6 100644 --- a/packages/store/src/stores/scalarWeakMapStore.js +++ b/packages/store/src/stores/scalarWeakMapStore.js @@ -6,6 +6,8 @@ import { isCopyMap, } from '@endo/patterns'; +/** @import {WeakMapStore, StoreOptions} from '../types.js'; */ + const { quote: q, Fail } = assert; /** diff --git a/packages/store/src/stores/scalarWeakSetStore.js b/packages/store/src/stores/scalarWeakSetStore.js index 67cbb0dbcfa..8bc8cab8a9c 100644 --- a/packages/store/src/stores/scalarWeakSetStore.js +++ b/packages/store/src/stores/scalarWeakSetStore.js @@ -8,7 +8,7 @@ import { const { quote: q, Fail } = assert; -/** @import {WeakSetStore} from '@agoric/store/exported.js'; */ +/** @import {StoreOptions, WeakSetStore} from '@agoric/store'; */ /** * @template K diff --git a/packages/store/src/stores/store-utils.js b/packages/store/src/stores/store-utils.js index 46ed412836b..953386589fd 100644 --- a/packages/store/src/stores/store-utils.js +++ b/packages/store/src/stores/store-utils.js @@ -1,6 +1,9 @@ import { Far } from '@endo/marshal'; -/** @import {RankCompare} from '@endo/marshal' */ +/** + * @import {RankCompare} from '@endo/marshal'; + * @import {MapStore, WeakMapStore} from '../types.js'; + */ const { Fail, quote: q } = assert; diff --git a/packages/store/test/perf-patterns.js b/packages/store/test/perf-patterns.js index 22ea462e3af..734560057fa 100644 --- a/packages/store/test/perf-patterns.js +++ b/packages/store/test/perf-patterns.js @@ -16,8 +16,10 @@ import { PaymentShape, ProposalShape, } from './borrow-guards.js'; -import '../src/types.js'; -/** @import {Passable} from '@endo/pass-style' */ +/** + * @import {Passable} from '@endo/pass-style'; + * @import {Pattern} from '@endo/patterns'; + */ const gcAndFinalize = makeGcAndFinalize(engineGC); diff --git a/packages/vat-data/src/vat-data-bindings.js b/packages/vat-data/src/vat-data-bindings.js index b1fd9803391..39e3b5b759a 100644 --- a/packages/vat-data/src/vat-data-bindings.js +++ b/packages/vat-data/src/vat-data-bindings.js @@ -85,7 +85,7 @@ export const partialAssign = (target, source) => { }; harden(partialAssign); -/** @import {StoreOptions} from '@agoric/store/exported.js' */ +/** @import {StoreOptions} from '@agoric/store' */ /** * Unlike `provideLazy`, `provide` should be called at most once diff --git a/packages/zoe/src/contractFacet/rightsConservation.js b/packages/zoe/src/contractFacet/rightsConservation.js index 4f7fe3c2f3f..23b5a946907 100644 --- a/packages/zoe/src/contractFacet/rightsConservation.js +++ b/packages/zoe/src/contractFacet/rightsConservation.js @@ -4,7 +4,7 @@ import { AmountMath } from '@agoric/ertp'; import '../internal-types.js'; /** - * @import {MapStore} from '@agoric/store/exported.js' + * @import {MapStore} from '@agoric/store'; */ /** diff --git a/packages/zoe/src/contracts/priceAggregator.js b/packages/zoe/src/contracts/priceAggregator.js index 555f5002f98..857ba9352a8 100644 --- a/packages/zoe/src/contracts/priceAggregator.js +++ b/packages/zoe/src/contracts/priceAggregator.js @@ -32,7 +32,7 @@ import { } from '../contractSupport/ratio.js'; /** - * @import {LegacyMap} from '@agoric/store/exported.js' + * @import {LegacyMap} from '@agoric/store' */ /** @typedef {bigint | number | string} ParsableNumber */ /** From 12490a5fa25f22c58d4bdc80f943351aea537359 Mon Sep 17 00:00:00 2001 From: Turadg Aleahmad Date: Mon, 29 Apr 2024 10:56:43 -0700 Subject: [PATCH 05/14] docs: XXX for 6512 --- packages/ERTP/src/paymentLedger.js | 2 ++ packages/base-zone/src/index.js | 3 +++ packages/benchmark/src/benchmarkerator.js | 2 +- packages/boot/test/bootstrapTests/zcfProbe.js | 1 + packages/boot/tools/supports.ts | 3 +++ packages/cache/src/main.js | 1 + packages/governance/src/index.js | 1 + packages/governance/test/unitTests/test-binaryballotCount.js | 3 +++ packages/governance/test/unitTests/test-committee.js | 1 + packages/inter-protocol/src/proposals/econ-behaviors.js | 3 ++- packages/inter-protocol/src/psm/psm.js | 1 + packages/inter-protocol/src/vaultFactory/burn.js | 1 + packages/inter-protocol/src/vaultFactory/vault.js | 1 + packages/inter-protocol/src/vaultFactory/vaultFactory.js | 1 + packages/network/src/router.js | 1 + packages/notifier/src/index.js | 1 + packages/orchestration/src/service.js | 3 +++ packages/swingset-liveslots/src/index.js | 3 +++ 18 files changed, 30 insertions(+), 2 deletions(-) diff --git a/packages/ERTP/src/paymentLedger.js b/packages/ERTP/src/paymentLedger.js index fe5362d511b..5b9645f7e06 100644 --- a/packages/ERTP/src/paymentLedger.js +++ b/packages/ERTP/src/paymentLedger.js @@ -7,7 +7,9 @@ import { AmountMath } from './amountMath.js'; import { preparePaymentKind } from './payment.js'; import { preparePurseKind } from './purse.js'; +// XXX ambient types runtime imports until https://github.com/Agoric/agoric-sdk/issues/6512 import '@agoric/store/exported.js'; + import { BrandI, makeIssuerInterfaces } from './typeGuards.js'; /** diff --git a/packages/base-zone/src/index.js b/packages/base-zone/src/index.js index 5815984e058..a7b2ee98e34 100644 --- a/packages/base-zone/src/index.js +++ b/packages/base-zone/src/index.js @@ -1,5 +1,8 @@ // @jessie-check +// XXX ambient types runtime imports until https://github.com/Agoric/agoric-sdk/issues/6512 +import '@agoric/store/exported.js'; + // eslint-disable-next-line import/export export * from './exports.js'; diff --git a/packages/benchmark/src/benchmarkerator.js b/packages/benchmark/src/benchmarkerator.js index cb76b26d1e4..499717b6046 100644 --- a/packages/benchmark/src/benchmarkerator.js +++ b/packages/benchmark/src/benchmarkerator.js @@ -4,7 +4,7 @@ import fs from 'node:fs'; import '@endo/init/pre-bundle-source.js'; import '@endo/init'; -// XXX The following four imports are present only to make `tsc` shut up. They do no actual work. +// XXX ambient types runtime imports until https://github.com/Agoric/agoric-sdk/issues/6512 import '@agoric/vats/exported.js'; import '@agoric/inter-protocol/exported.js'; import '@agoric/zoe/exported.js'; diff --git a/packages/boot/test/bootstrapTests/zcfProbe.js b/packages/boot/test/bootstrapTests/zcfProbe.js index 16ab4fd1fa9..0addf85a667 100644 --- a/packages/boot/test/bootstrapTests/zcfProbe.js +++ b/packages/boot/test/bootstrapTests/zcfProbe.js @@ -1,3 +1,4 @@ +// XXX ambient types runtime imports until https://github.com/Agoric/agoric-sdk/issues/6512 import '@agoric/zoe/exported.js'; import { makeTracer } from '@agoric/internal'; diff --git a/packages/boot/tools/supports.ts b/packages/boot/tools/supports.ts index 64c83f98858..0939fad575e 100644 --- a/packages/boot/tools/supports.ts +++ b/packages/boot/tools/supports.ts @@ -17,7 +17,10 @@ import { initSwingStore } from '@agoric/swing-store'; import { loadSwingsetConfigFile } from '@agoric/swingset-vat'; import { makeSlogSender } from '@agoric/telemetry'; import { TimeMath, Timestamp } from '@agoric/time'; + +// XXX ambient types runtime imports until https://github.com/Agoric/agoric-sdk/issues/6512 import '@agoric/vats/exported.js'; + import { boardSlottingMarshaller, slotToBoardRemote, diff --git a/packages/cache/src/main.js b/packages/cache/src/main.js index aa2a6ba5c29..f13abd7ef3f 100644 --- a/packages/cache/src/main.js +++ b/packages/cache/src/main.js @@ -1,5 +1,6 @@ // @jessie-check +// XXX ambient types runtime imports until https://github.com/Agoric/agoric-sdk/issues/6512 import '@agoric/internal/exported.js'; // eslint-disable-next-line import/export diff --git a/packages/governance/src/index.js b/packages/governance/src/index.js index 7c527d3789f..481cff9b3d0 100644 --- a/packages/governance/src/index.js +++ b/packages/governance/src/index.js @@ -1,5 +1,6 @@ // XXX ambient types runtime imports until https://github.com/Agoric/agoric-sdk/issues/6512 import '@agoric/ertp/exported.js'; + import '@agoric/zoe/src/contractFacet/types-ambient.js'; import '@agoric/zoe/tools/types-ambient.js'; import '@agoric/zoe/src/types.js'; diff --git a/packages/governance/test/unitTests/test-binaryballotCount.js b/packages/governance/test/unitTests/test-binaryballotCount.js index 7e8197e1721..b726078fe58 100644 --- a/packages/governance/test/unitTests/test-binaryballotCount.js +++ b/packages/governance/test/unitTests/test-binaryballotCount.js @@ -1,6 +1,9 @@ /* eslint @typescript-eslint/no-floating-promises: "warn" */ import { test } from '@agoric/zoe/tools/prepare-test-env-ava.js'; + +// XXX ambient types runtime imports until https://github.com/Agoric/agoric-sdk/issues/6512 import '@agoric/zoe/exported.js'; + import { E } from '@endo/eventual-send'; import buildManualTimer from '@agoric/zoe/tools/manualTimer.js'; import { makeHandle } from '@agoric/zoe/src/makeHandle.js'; diff --git a/packages/governance/test/unitTests/test-committee.js b/packages/governance/test/unitTests/test-committee.js index d525cf01d7a..5672490b267 100644 --- a/packages/governance/test/unitTests/test-committee.js +++ b/packages/governance/test/unitTests/test-committee.js @@ -1,5 +1,6 @@ import { test } from '@agoric/zoe/tools/prepare-test-env-ava.js'; +// XXX ambient types runtime imports until https://github.com/Agoric/agoric-sdk/issues/6512 import '@agoric/zoe/exported.js'; import { makeMockChainStorageRoot } from '@agoric/internal/src/storage-test-utils.js'; diff --git a/packages/inter-protocol/src/proposals/econ-behaviors.js b/packages/inter-protocol/src/proposals/econ-behaviors.js index a63685a9017..f683e6357d1 100644 --- a/packages/inter-protocol/src/proposals/econ-behaviors.js +++ b/packages/inter-protocol/src/proposals/econ-behaviors.js @@ -1,9 +1,10 @@ // @jessie-check +// XXX ambient types runtime imports until https://github.com/Agoric/agoric-sdk/issues/6512 import '../../exported.js'; +import '@agoric/governance/exported.js'; import { AmountMath } from '@agoric/ertp'; -import '@agoric/governance/exported.js'; import { deeplyFulfilledObject, makeTracer } from '@agoric/internal'; import { makeStorageNodeChild } from '@agoric/internal/src/lib-chainStorage.js'; import { E } from '@endo/far'; diff --git a/packages/inter-protocol/src/psm/psm.js b/packages/inter-protocol/src/psm/psm.js index 6fb61a83ffd..fbd44b7d496 100644 --- a/packages/inter-protocol/src/psm/psm.js +++ b/packages/inter-protocol/src/psm/psm.js @@ -1,5 +1,6 @@ // @jessie-check +// XXX ambient types runtime imports until https://github.com/Agoric/agoric-sdk/issues/6512 import '@agoric/governance/exported.js'; import '@agoric/zoe/exported.js'; import '@agoric/zoe/src/contracts/exported.js'; diff --git a/packages/inter-protocol/src/vaultFactory/burn.js b/packages/inter-protocol/src/vaultFactory/burn.js index 9cfc83b7f7a..c8e5aee9f48 100644 --- a/packages/inter-protocol/src/vaultFactory/burn.js +++ b/packages/inter-protocol/src/vaultFactory/burn.js @@ -1,5 +1,6 @@ // @jessie-check +// XXX ambient types runtime imports until https://github.com/Agoric/agoric-sdk/issues/6512 import '@agoric/zoe/exported.js'; import { E } from '@endo/eventual-send'; diff --git a/packages/inter-protocol/src/vaultFactory/vault.js b/packages/inter-protocol/src/vaultFactory/vault.js index fe303209988..17ee452ccc7 100644 --- a/packages/inter-protocol/src/vaultFactory/vault.js +++ b/packages/inter-protocol/src/vaultFactory/vault.js @@ -13,6 +13,7 @@ import { calculateCurrentDebt, reverseInterest } from '../interest-math.js'; import { calculateDebtCosts } from './math.js'; import { prepareVaultKit } from './vaultKit.js'; +// XXX ambient types runtime imports until https://github.com/Agoric/agoric-sdk/issues/6512 import '@agoric/zoe/exported.js'; const { quote: q, Fail } = assert; diff --git a/packages/inter-protocol/src/vaultFactory/vaultFactory.js b/packages/inter-protocol/src/vaultFactory/vaultFactory.js index 3627675c8a9..e7ae15ff652 100644 --- a/packages/inter-protocol/src/vaultFactory/vaultFactory.js +++ b/packages/inter-protocol/src/vaultFactory/vaultFactory.js @@ -1,5 +1,6 @@ // @jessie-check +// XXX ambient types runtime imports until https://github.com/Agoric/agoric-sdk/issues/6512 import '@agoric/governance/exported.js'; import '@agoric/zoe/exported.js'; import '@agoric/zoe/src/contracts/exported.js'; diff --git a/packages/network/src/router.js b/packages/network/src/router.js index 919e1fe8fbf..27de1036b0a 100644 --- a/packages/network/src/router.js +++ b/packages/network/src/router.js @@ -5,6 +5,7 @@ import { Fail } from '@agoric/assert'; import { ENDPOINT_SEPARATOR, prepareNetworkProtocol } from './network.js'; import { Shape } from './shapes.js'; +// XXX ambient types runtime imports until https://github.com/Agoric/agoric-sdk/issues/6512 import '@agoric/store/exported.js'; /// diff --git a/packages/notifier/src/index.js b/packages/notifier/src/index.js index a45e02790a7..2a5f7fd6723 100644 --- a/packages/notifier/src/index.js +++ b/packages/notifier/src/index.js @@ -1,5 +1,6 @@ // @jessie-check +// XXX ambient types runtime imports until https://github.com/Agoric/agoric-sdk/issues/6512 import '@agoric/internal/exported.js'; export { diff --git a/packages/orchestration/src/service.js b/packages/orchestration/src/service.js index ced55999021..55e7f632922 100644 --- a/packages/orchestration/src/service.js +++ b/packages/orchestration/src/service.js @@ -2,7 +2,10 @@ /** @file Orchestration service */ import { NonNullish } from '@agoric/assert'; import { makeTracer } from '@agoric/internal'; + +// XXX ambient types runtime imports until https://github.com/Agoric/agoric-sdk/issues/6512 import '@agoric/network/exported.js'; + import { V as E } from '@agoric/vat-data/vow.js'; import { M } from '@endo/patterns'; import { PaymentShape, PurseShape } from '@agoric/ertp'; diff --git a/packages/swingset-liveslots/src/index.js b/packages/swingset-liveslots/src/index.js index 3139cc36d32..14f3b84af5d 100644 --- a/packages/swingset-liveslots/src/index.js +++ b/packages/swingset-liveslots/src/index.js @@ -1,3 +1,6 @@ +// XXX ambient types runtime imports until https://github.com/Agoric/agoric-sdk/issues/6512 +import '@agoric/store/exported.js'; + /* eslint-disable import/export -- types files have no named runtime exports */ export { makeLiveSlots, makeMarshaller } from './liveslots.js'; From 5ed655d3d918f8fffe361c19ebbb941c93520696 Mon Sep 17 00:00:00 2001 From: Turadg Aleahmad Date: Mon, 29 Apr 2024 10:58:37 -0700 Subject: [PATCH 06/14] test: fix arity --- packages/vat-data/test/test-scalar-only-keys.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/vat-data/test/test-scalar-only-keys.js b/packages/vat-data/test/test-scalar-only-keys.js index e3cebfaf941..179550ecb29 100644 --- a/packages/vat-data/test/test-scalar-only-keys.js +++ b/packages/vat-data/test/test-scalar-only-keys.js @@ -16,7 +16,7 @@ test('scalar maps should reject non-scalar keys', t => { test('scalar big maps should reject non-scalar keys', t => { const bigMap = makeScalarBigMapStore('dummy', { keyShape: M.key() }); - t.throws(() => bigMap.init(harden({ label: 'not a scalar' })), { + t.throws(() => bigMap.init(harden({ label: 'not a scalar' }), null), { message: /A "copyRecord" cannot be a scalar key: \{"label":"not a scalar"\}/, }); From f41ff2a365c7393d2257cc0600ab7a5864222e88 Mon Sep 17 00:00:00 2001 From: Turadg Aleahmad Date: Tue, 30 Apr 2024 06:59:47 -0700 Subject: [PATCH 07/14] refactor(types): inline --- packages/zoe/src/contractFacet/zcfSeat.js | 11 +++- packages/zoe/src/internal-types.js | 54 ++----------------- packages/zoe/src/issuerStorage.js | 5 +- packages/zoe/src/zoeService/internal-types.js | 8 +-- 4 files changed, 23 insertions(+), 55 deletions(-) diff --git a/packages/zoe/src/contractFacet/zcfSeat.js b/packages/zoe/src/contractFacet/zcfSeat.js index ee4ef6f3f33..9658f66512f 100644 --- a/packages/zoe/src/contractFacet/zcfSeat.js +++ b/packages/zoe/src/contractFacet/zcfSeat.js @@ -25,7 +25,16 @@ import { TransferPartShape } from '../contractSupport/atomicTransfer.js'; const { Fail } = assert; -/** @type {CreateSeatManager} */ +/** + * The SeatManager holds the active zcfSeats and can reallocate and + * make new zcfSeats. + * + * @param {ERef} zoeInstanceAdmin + * @param {GetAssetKindByBrand} getAssetKindByBrand + * @param {import('@agoric/swingset-vat').ShutdownWithFailure} shutdownWithFailure + * @param {import('@agoric/vat-data').Baggage} zcfBaggage + * @returns {{ seatManager: ZcfSeatManager, zcfMintReallocator: ZcfMintReallocator }} + */ export const createSeatManager = ( zoeInstanceAdmin, getAssetKindByBrand, diff --git a/packages/zoe/src/internal-types.js b/packages/zoe/src/internal-types.js index 0216b9fdcb1..7de031ab808 100644 --- a/packages/zoe/src/internal-types.js +++ b/packages/zoe/src/internal-types.js @@ -281,19 +281,6 @@ * @property {(zcfSeat: ZCFSeat, newAllocation: Allocation) => void} reallocate */ -/** - * @callback CreateSeatManager - * - * The SeatManager holds the active zcfSeats and can reallocate and - * make new zcfSeats. - * - * @param {ERef} zoeInstanceAdmin - * @param {GetAssetKindByBrand} getAssetKindByBrand - * @param {import('@agoric/swingset-vat').ShutdownWithFailure} shutdownWithFailure - * @param {import('@agoric/vat-data').Baggage} zcfBaggage - * @returns {{ seatManager: ZcfSeatManager, zcfMintReallocator: ZcfMintReallocator }} - */ - /** * @callback InstanceStateAddIssuer * @@ -305,44 +292,13 @@ * @returns {void} */ -/** - * @callback InstanceStateGetTerms - * @returns {AnyTerms} - */ - -/** - * @callback InstanceStateGetInstallation - * @returns {Installation} - */ - -/** - * @callback InstanceRecordGetIssuers - * @returns {IssuerKeywordRecord} - */ - -/** - * @callback InstanceRecordGetBrands - * @returns {BrandKeywordRecord} - */ - /** * @typedef {object} InstanceState * @property {InstanceStateAddIssuer} addIssuer - * @property {GetInstanceRecord} getInstanceRecord - * @property {InstanceStateGetTerms} getTerms - * @property {InstanceStateGetInstallation} getInstallation - * @property {InstanceRecordGetIssuers} getIssuers - * @property {InstanceRecordGetBrands} getBrands + * @property {() => InstanceRecord} getInstanceRecord + * @property {() => AnyTerms} getTerms + * @property {() => Installation} getInstallation + * @property {() => IssuerKeywordRecord} getIssuers + * @property {() => BrandKeywordRecord} getBrands * @property {(keyword: Keyword) => void} assertUniqueKeyword */ - -/** - * @callback GetInstanceRecord - * @returns {InstanceRecord} - */ - -/** - * @callback IssuerStorageGetIssuerRecords - * @param {Issuer[]} issuers - * @returns {IssuerRecords} - */ diff --git a/packages/zoe/src/issuerStorage.js b/packages/zoe/src/issuerStorage.js index b49bbc03555..55f776d35e5 100644 --- a/packages/zoe/src/issuerStorage.js +++ b/packages/zoe/src/issuerStorage.js @@ -170,7 +170,10 @@ export const provideIssuerStorage = zcfBaggage => { return brandToIssuerRecord.get(brand).issuer; }; - /** @type {IssuerStorageGetIssuerRecords} */ + /** + * @param {Issuer[]} issuers + * @returns {IssuerRecords} + */ const getIssuerRecords = issuers => { assertInstantiated(); return issuers.map(issuerToIssuerRecord.get); diff --git a/packages/zoe/src/zoeService/internal-types.js b/packages/zoe/src/zoeService/internal-types.js index fbf1938a2e4..eeb1f09281b 100644 --- a/packages/zoe/src/zoeService/internal-types.js +++ b/packages/zoe/src/zoeService/internal-types.js @@ -76,13 +76,13 @@ /** * @typedef {object} ZoeInstanceStorageManager - * @property {InstanceStateGetTerms} getTerms - * @property {InstanceRecordGetIssuers} getIssuers - * @property {InstanceRecordGetBrands} getBrands + * @property {() => AnyTerms} getTerms + * @property {() => IssuerKeywordRecord} getIssuers + * @property {() => BrandKeywordRecord} getBrands * @property {ZCF['saveIssuer']} saveIssuer * @property {MakeZoeMint} makeZoeMint * @property {RegisterFeeMint} registerFeeMint - * @property {GetInstanceRecord} getInstanceRecord + * @property {() => InstanceRecord} getInstanceRecord * @property {GetIssuerRecords} getIssuerRecords * @property {InitInstanceAdmin} initInstanceAdmin * @property {DeleteInstanceAdmin} deleteInstanceAdmin From 7d634c5d424ac73a7679106ba3dcc7e35e220ad7 Mon Sep 17 00:00:00 2001 From: Turadg Aleahmad Date: Sat, 27 Apr 2024 15:56:12 -0700 Subject: [PATCH 08/14] chore(type): work around '* Bundle' type bug --- packages/SwingSet/src/types-ambient.js | 87 ++------------------------ 1 file changed, 5 insertions(+), 82 deletions(-) diff --git a/packages/SwingSet/src/types-ambient.js b/packages/SwingSet/src/types-ambient.js index 5c83a481c2a..98f67fb9af4 100644 --- a/packages/SwingSet/src/types-ambient.js +++ b/packages/SwingSet/src/types-ambient.js @@ -1,87 +1,10 @@ +// XXX this file builds empty when `tsc --build` is run + +// XXX all on one line because otherwise tsc puts the `*` in the type name /** - * @import { - * Bundle, - * BundleCap, - * BundleFormat, - * BundleID, - * BundleRef, - * BundleSpec, - * DeviceInvocation, - * DeviceInvocationResult, - * DeviceInvocationResultError, - * DeviceInvocationResultOk, - * EndoZipBase64Bundle, - * GetExportBundle, - * KernelDeliveryBringOutYourDead, - * KernelDeliveryChangeVatOptions, - * KernelDeliveryDropExports, - * KernelDeliveryMessage, - * KernelDeliveryNotify, - * KernelDeliveryObject, - * KernelDeliveryOneNotify, - * KernelDeliveryRetireExports, - * KernelDeliveryRetireImports, - * KernelDeliveryStartVat, - * KernelKeeper, - * KernelOneResolution, - * KernelOptions, - * KernelSlog, - * KernelSyscallDropImports, - * KernelSyscallExit, - * KernelSyscallInvoke, - * KernelSyscallObject, - * KernelSyscallResolve, - * KernelSyscallResult, - * KernelSyscallResultError, - * KernelSyscallResultOk, - * KernelSyscallRetireExports, - * KernelSyscallRetireImports, - * KernelSyscallSend, - * KernelSyscallSubscribe, - * KernelSyscallVatstoreDelete, - * KernelSyscallVatstoreGet, - * KernelSyscallVatstoreGetNextKey, - * KernelSyscallVatstoreSet, - * ManagerType, - * Message, - * MeteringVatPowers, - * NestedEvaluateBundle, - * PolicyInput, - * PolicyInputCrankComplete, - * PolicyInputCrankFailed, - * PolicyInputCreateVat, - * PolicyInputNone, - * PolicyOutput, - * ResolutionPolicy, - * RunPolicy, - * SlogFinishDelivery, - * SlogFinishSyscall, - * SnapshotResult, - * SnapStore, - * SourceOfBundle, - * SourceSpec, - * StaticVatPowers, - * SwingSetCapData, - * SwingSetConfig, - * SwingSetConfigDescriptor, - * SwingSetConfigProperties, - * SwingSetKernelConfig, - * TerminationVatPowers, - * VatKeeper, - * VatPowers, - * VatSlog, - * VatStats, - * WaitUntilQuiescent, - * XSnap, - * } from './types-external.js') + * @import { Bundle, BundleCap, BundleFormat, BundleID, BundleRef, BundleSpec, DeviceInvocation, DeviceInvocationResult, DeviceInvocationResultError, DeviceInvocationResultOk, EndoZipBase64Bundle, GetExportBundle, KernelDeliveryBringOutYourDead, KernelDeliveryChangeVatOptions, KernelDeliveryDropExports, KernelDeliveryMessage, KernelDeliveryNotify, KernelDeliveryObject, KernelDeliveryOneNotify, KernelDeliveryRetireExports, KernelDeliveryRetireImports, KernelDeliveryStartVat, KernelKeeper, KernelOneResolution, KernelOptions, KernelSlog, KernelSyscallDropImports, KernelSyscallExit, KernelSyscallInvoke, KernelSyscallObject, KernelSyscallResolve, KernelSyscallResult, KernelSyscallResultError, KernelSyscallResultOk, KernelSyscallRetireExports, KernelSyscallRetireImports, KernelSyscallSend, KernelSyscallSubscribe, KernelSyscallVatstoreDelete, KernelSyscallVatstoreGet, KernelSyscallVatstoreGetNextKey, KernelSyscallVatstoreSet, ManagerType, Message, MeteringVatPowers, NestedEvaluateBundle, PolicyInput, PolicyInputCrankComplete, PolicyInputCrankFailed, PolicyInputCreateVat, PolicyInputNone, PolicyOutput, ResolutionPolicy, RunPolicy, SlogFinishDelivery, SlogFinishSyscall, SnapshotResult, SnapStore, SourceOfBundle, SourceSpec, StaticVatPowers, SwingSetCapData, SwingSetConfig, SwingSetConfigDescriptor, SwingSetConfigProperties, SwingSetKernelConfig, TerminationVatPowers, VatKeeper, VatPowers, VatSlog, VatStats, WaitUntilQuiescent, XSnap, } from './types-external.js'; */ /** - * @import { - * KVStore, - * TranscriptStore, - * SwingStore, - * SwingStoreKernelStorage, - * SwingStoreHostStorage, - * } from '@agoric/swing-store' + * @import { KVStore, TranscriptStore, SwingStore, SwingStoreKernelStorage, SwingStoreHostStorage, } from '@agoric/swing-store'; */ From 067a2068ec19695afb618ab6d47fce6621333c2c Mon Sep 17 00:00:00 2001 From: Turadg Aleahmad Date: Tue, 30 Apr 2024 10:07:33 -0700 Subject: [PATCH 09/14] refactor: consistent types-ambient --- packages/zoe/exported.js | 6 +++--- packages/zoe/src/contractSupport/ratio.js | 2 +- .../zoe/src/contractSupport/{types.js => types-ambient.js} | 0 packages/zoe/src/{types.js => types-ambient.js} | 0 packages/zoe/src/zoeService/originalZoeSeat.js | 2 +- packages/zoe/src/zoeService/{types.js => types-ambient.js} | 0 packages/zoe/src/zoeService/utils.d.ts | 7 +++---- packages/zoe/src/zoeService/zoeSeat.js | 2 +- packages/zoe/test/unitTests/contractSupport/test-ratio.js | 2 +- packages/zoe/typedoc.json | 4 ++-- 10 files changed, 12 insertions(+), 13 deletions(-) rename packages/zoe/src/contractSupport/{types.js => types-ambient.js} (100%) rename packages/zoe/src/{types.js => types-ambient.js} (100%) rename packages/zoe/src/zoeService/{types.js => types-ambient.js} (100%) diff --git a/packages/zoe/exported.js b/packages/zoe/exported.js index 03fb20ed65f..e3828978f72 100644 --- a/packages/zoe/exported.js +++ b/packages/zoe/exported.js @@ -1,10 +1,10 @@ // @jessie-check import './src/contractFacet/types-ambient.js'; -import './src/zoeService/types.js'; -import './src/contractSupport/types.js'; +import './src/zoeService/types-ambient.js'; +import './src/contractSupport/types-ambient.js'; import './src/contracts/exported.js'; -import './src/types.js'; +import './src/types-ambient.js'; import './tools/types-ambient.js'; import '@agoric/notifier/exported.js'; import '@agoric/ertp/exported.js'; diff --git a/packages/zoe/src/contractSupport/ratio.js b/packages/zoe/src/contractSupport/ratio.js index f01f259941b..c4659aa968b 100644 --- a/packages/zoe/src/contractSupport/ratio.js +++ b/packages/zoe/src/contractSupport/ratio.js @@ -1,4 +1,4 @@ -/// +/// import { q, Fail } from '@agoric/assert'; import { AmountMath } from '@agoric/ertp'; import { assertRecord } from '@endo/marshal'; diff --git a/packages/zoe/src/contractSupport/types.js b/packages/zoe/src/contractSupport/types-ambient.js similarity index 100% rename from packages/zoe/src/contractSupport/types.js rename to packages/zoe/src/contractSupport/types-ambient.js diff --git a/packages/zoe/src/types.js b/packages/zoe/src/types-ambient.js similarity index 100% rename from packages/zoe/src/types.js rename to packages/zoe/src/types-ambient.js diff --git a/packages/zoe/src/zoeService/originalZoeSeat.js b/packages/zoe/src/zoeService/originalZoeSeat.js index 0187d07dcd3..97e4660851d 100644 --- a/packages/zoe/src/zoeService/originalZoeSeat.js +++ b/packages/zoe/src/zoeService/originalZoeSeat.js @@ -6,7 +6,7 @@ import { deeplyFulfilled } from '@endo/marshal'; import { makePromiseKit } from '@endo/promise-kit'; import { satisfiesWant } from '../contractFacet/offerSafety.js'; -import '../types.js'; +import '../types-ambient.js'; import '../internal-types.js'; import { AmountKeywordRecordShape, diff --git a/packages/zoe/src/zoeService/types.js b/packages/zoe/src/zoeService/types-ambient.js similarity index 100% rename from packages/zoe/src/zoeService/types.js rename to packages/zoe/src/zoeService/types-ambient.js diff --git a/packages/zoe/src/zoeService/utils.d.ts b/packages/zoe/src/zoeService/utils.d.ts index e10f2ad5308..a94b16b491b 100644 --- a/packages/zoe/src/zoeService/utils.d.ts +++ b/packages/zoe/src/zoeService/utils.d.ts @@ -1,8 +1,7 @@ import type { Callable } from '@agoric/internal/src/utils.js'; import type { VatUpgradeResults } from '@agoric/swingset-vat'; import type { Baggage } from '@agoric/swingset-liveslots'; - -import type { IssuerKeywordRecord, Payment } from './types.js'; +import type { Issuer } from '@agoric/ertp/exported.js'; // XXX https://github.com/Agoric/agoric-sdk/issues/4565 type SourceBundle = Record; @@ -71,7 +70,7 @@ export type ContractOf = StartParams & StartResult; type StartContractInstance = ( installation: Installation, - issuerKeywordRecord?: IssuerKeywordRecord, + issuerKeywordRecord?: Record>, terms?: object, privateArgs?: object, ) => Promise<{ @@ -113,7 +112,7 @@ export type StartedInstanceKit = { */ export type StartInstance = ( installation: Installation | PromiseLike>, - issuerKeywordRecord?: IssuerKeywordRecord, + issuerKeywordRecord?: Record>, // 'brands' and 'issuers' need not be passed in; Zoe provides them as StandardTerms terms?: Omit['terms'], 'brands' | 'issuers'>, privateArgs?: Parameters[1], diff --git a/packages/zoe/src/zoeService/zoeSeat.js b/packages/zoe/src/zoeService/zoeSeat.js index 363932fb89b..688dcbb6a52 100644 --- a/packages/zoe/src/zoeService/zoeSeat.js +++ b/packages/zoe/src/zoeService/zoeSeat.js @@ -6,7 +6,7 @@ import { deeplyFulfilled } from '@endo/marshal'; import { makePromiseKit } from '@endo/promise-kit'; import { satisfiesWant } from '../contractFacet/offerSafety.js'; -import '../types.js'; +import '../types-ambient.js'; import '../internal-types.js'; import { declareOldZoeSeatAdminKind, diff --git a/packages/zoe/test/unitTests/contractSupport/test-ratio.js b/packages/zoe/test/unitTests/contractSupport/test-ratio.js index f229f19e2a2..69a3febe1b6 100644 --- a/packages/zoe/test/unitTests/contractSupport/test-ratio.js +++ b/packages/zoe/test/unitTests/contractSupport/test-ratio.js @@ -1,6 +1,6 @@ import { test } from '@agoric/swingset-vat/tools/prepare-test-env-ava.js'; -import '../../../src/contractSupport/types.js'; +import '../../../src/contractSupport/types-ambient.js'; import { makeIssuerKit, AmountMath } from '@agoric/ertp'; import { diff --git a/packages/zoe/typedoc.json b/packages/zoe/typedoc.json index e5a2997cfc2..bdab322c101 100644 --- a/packages/zoe/typedoc.json +++ b/packages/zoe/typedoc.json @@ -6,9 +6,9 @@ "src/contractFacet/internal-types.js", "src/contractFacet/types-ambient.d.ts", "src/contractSupport/index.js", - "src/contractSupport/types.js", + "src/contractSupport/types-ambient.js", "src/types.js", - "src/zoeService/types.js", + "src/zoeService/types-ambient.js", "src/zoeService/utils.d.ts", "src/zoeService/zoe.js", "tools/internal-types.js", From 0b04527365e11cf4fd1ab7593aa16c6f92f7ba15 Mon Sep 17 00:00:00 2001 From: Turadg Aleahmad Date: Tue, 30 Apr 2024 10:57:37 -0700 Subject: [PATCH 10/14] test: accomodate types --- packages/zoe/test/swingsetTests/runMint/vat-alice.js | 2 +- packages/zoe/test/unitTests/test-zoe-startInstance.js | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/zoe/test/swingsetTests/runMint/vat-alice.js b/packages/zoe/test/swingsetTests/runMint/vat-alice.js index e3b778f35be..9fdc73127bf 100644 --- a/packages/zoe/test/swingsetTests/runMint/vat-alice.js +++ b/packages/zoe/test/swingsetTests/runMint/vat-alice.js @@ -14,7 +14,7 @@ const build = async (log, zoe, installations, feeMintAccess) => { const { instance } = await E(zoe).startInstance( installations.offerArgsUsageContract, harden({ - RUN: E(zoe).getFeeIssuer(), + RUN: await E(zoe).getFeeIssuer(), }), undefined, ); diff --git a/packages/zoe/test/unitTests/test-zoe-startInstance.js b/packages/zoe/test/unitTests/test-zoe-startInstance.js index 318e237e48c..fb13072e98c 100644 --- a/packages/zoe/test/unitTests/test-zoe-startInstance.js +++ b/packages/zoe/test/unitTests/test-zoe-startInstance.js @@ -96,6 +96,7 @@ test('terms, issuerKeywordRecord switched', async t => { () => E(zoe).startInstance( installation, + // @ts-expect-error intentional error { something: 2 }, { Moola: moolaKit.issuer }, ), @@ -121,6 +122,7 @@ test('bad issuer, makeEmptyPurse throws', async t => { getBrand: () => brand, }); await t.throwsAsync( + // @ts-expect-error intentional error () => E(zoe).startInstance(installation, { Money: badIssuer }), { message: From 647afb6b50dd8f77f5fce3199e6e290a1d432fa7 Mon Sep 17 00:00:00 2001 From: Turadg Aleahmad Date: Tue, 30 Apr 2024 11:27:32 -0700 Subject: [PATCH 11/14] fix(types): netstring decode --- packages/internal/src/netstring.js | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/packages/internal/src/netstring.js b/packages/internal/src/netstring.js index 1e938bd3507..dffb05f58b1 100644 --- a/packages/internal/src/netstring.js +++ b/packages/internal/src/netstring.js @@ -43,10 +43,13 @@ export function netstringEncoderStream() { return new Transform({ transform, writableObjectMode: true }); } -// Input is a Buffer containing zero or more netstrings and maybe some -// leftover bytes. Output is zero or more decoded Buffers, one per netstring, -// plus a Buffer of leftover bytes. -// +/** + * + * @param {Buffer} data containing zero or more netstrings and maybe some + * leftover bytes + * @param {number} [optMaxChunkSize] + * @returns {{ leftover: Buffer, payloads: Buffer[] }} zero or more decoded Buffers, one per netstring, + */ export function decode(data, optMaxChunkSize) { // TODO: it would be more efficient to accumulate pending data in an array, // rather than doing a concat each time @@ -81,6 +84,11 @@ export function decode(data, optMaxChunkSize) { return { leftover, payloads }; } +/** + * + * @param {number} [optMaxChunkSize ] + * @returns {Transform} + */ // input is a byte pipe, output is a sequence of Buffers export function netstringDecoderStream(optMaxChunkSize) { let buffered = Buffer.from(''); From f70d2262e57b076662caa6e8f90e06b2711b7858 Mon Sep 17 00:00:00 2001 From: Turadg Aleahmad Date: Tue, 30 Apr 2024 11:21:21 -0700 Subject: [PATCH 12/14] chore(types): ambient VatAdminScv --- packages/SwingSet/src/types-ambient.js | 2 +- packages/zoe/src/zoeService/types-ambient.js | 4 ---- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/packages/SwingSet/src/types-ambient.js b/packages/SwingSet/src/types-ambient.js index 98f67fb9af4..352630af64b 100644 --- a/packages/SwingSet/src/types-ambient.js +++ b/packages/SwingSet/src/types-ambient.js @@ -2,7 +2,7 @@ // XXX all on one line because otherwise tsc puts the `*` in the type name /** - * @import { Bundle, BundleCap, BundleFormat, BundleID, BundleRef, BundleSpec, DeviceInvocation, DeviceInvocationResult, DeviceInvocationResultError, DeviceInvocationResultOk, EndoZipBase64Bundle, GetExportBundle, KernelDeliveryBringOutYourDead, KernelDeliveryChangeVatOptions, KernelDeliveryDropExports, KernelDeliveryMessage, KernelDeliveryNotify, KernelDeliveryObject, KernelDeliveryOneNotify, KernelDeliveryRetireExports, KernelDeliveryRetireImports, KernelDeliveryStartVat, KernelKeeper, KernelOneResolution, KernelOptions, KernelSlog, KernelSyscallDropImports, KernelSyscallExit, KernelSyscallInvoke, KernelSyscallObject, KernelSyscallResolve, KernelSyscallResult, KernelSyscallResultError, KernelSyscallResultOk, KernelSyscallRetireExports, KernelSyscallRetireImports, KernelSyscallSend, KernelSyscallSubscribe, KernelSyscallVatstoreDelete, KernelSyscallVatstoreGet, KernelSyscallVatstoreGetNextKey, KernelSyscallVatstoreSet, ManagerType, Message, MeteringVatPowers, NestedEvaluateBundle, PolicyInput, PolicyInputCrankComplete, PolicyInputCrankFailed, PolicyInputCreateVat, PolicyInputNone, PolicyOutput, ResolutionPolicy, RunPolicy, SlogFinishDelivery, SlogFinishSyscall, SnapshotResult, SnapStore, SourceOfBundle, SourceSpec, StaticVatPowers, SwingSetCapData, SwingSetConfig, SwingSetConfigDescriptor, SwingSetConfigProperties, SwingSetKernelConfig, TerminationVatPowers, VatKeeper, VatPowers, VatSlog, VatStats, WaitUntilQuiescent, XSnap, } from './types-external.js'; + * @import { Bundle, BundleCap, BundleFormat, BundleID, BundleRef, BundleSpec, DeviceInvocation, DeviceInvocationResult, DeviceInvocationResultError, DeviceInvocationResultOk, EndoZipBase64Bundle, GetExportBundle, KernelDeliveryBringOutYourDead, KernelDeliveryChangeVatOptions, KernelDeliveryDropExports, KernelDeliveryMessage, KernelDeliveryNotify, KernelDeliveryObject, KernelDeliveryOneNotify, KernelDeliveryRetireExports, KernelDeliveryRetireImports, KernelDeliveryStartVat, KernelKeeper, KernelOneResolution, KernelOptions, KernelSlog, KernelSyscallDropImports, KernelSyscallExit, KernelSyscallInvoke, KernelSyscallObject, KernelSyscallResolve, KernelSyscallResult, KernelSyscallResultError, KernelSyscallResultOk, KernelSyscallRetireExports, KernelSyscallRetireImports, KernelSyscallSend, KernelSyscallSubscribe, KernelSyscallVatstoreDelete, KernelSyscallVatstoreGet, KernelSyscallVatstoreGetNextKey, KernelSyscallVatstoreSet, ManagerType, Message, MeteringVatPowers, NestedEvaluateBundle, PolicyInput, PolicyInputCrankComplete, PolicyInputCrankFailed, PolicyInputCreateVat, PolicyInputNone, PolicyOutput, ResolutionPolicy, RunPolicy, SlogFinishDelivery, SlogFinishSyscall, SnapshotResult, SnapStore, SourceOfBundle, SourceSpec, StaticVatPowers, SwingSetCapData, SwingSetConfig, SwingSetConfigDescriptor, SwingSetConfigProperties, SwingSetKernelConfig, TerminationVatPowers, VatAdminSvc, VatKeeper, VatPowers, VatSlog, VatStats, WaitUntilQuiescent, XSnap, } from './types-external.js'; */ /** diff --git a/packages/zoe/src/zoeService/types-ambient.js b/packages/zoe/src/zoeService/types-ambient.js index 8d9b2c863fe..17d9f7a31e1 100644 --- a/packages/zoe/src/zoeService/types-ambient.js +++ b/packages/zoe/src/zoeService/types-ambient.js @@ -274,10 +274,6 @@ * @typedef {import('./utils.js').Instance} Instance */ -/** - * @import {VatAdminSvc} from '@agoric/swingset-vat' - */ - /** * @typedef {{bundleCap: import('@agoric/swingset-vat').BundleCap } | {name: string} | {id: BundleID}} ZCFSpec */ From 65c2075021dfb0ecf62a6009f7c411c7c49eb624 Mon Sep 17 00:00:00 2001 From: Turadg Aleahmad Date: Tue, 30 Apr 2024 11:35:51 -0700 Subject: [PATCH 13/14] feat(types): explicit exports from network --- packages/network/src/bytes.js | 4 ++ packages/network/src/index.js | 2 + packages/network/src/network.js | 47 +++++++++++-------- packages/network/src/router.js | 4 ++ packages/network/src/types.js | 3 ++ packages/network/test/test-network-misc.js | 4 +- packages/orchestration/src/service.js | 5 +- .../vats/src/proposals/network-proposal.js | 5 ++ 8 files changed, 52 insertions(+), 22 deletions(-) diff --git a/packages/network/src/bytes.js b/packages/network/src/bytes.js index f37082127bc..547d0dd5cd8 100644 --- a/packages/network/src/bytes.js +++ b/packages/network/src/bytes.js @@ -3,6 +3,10 @@ import { Fail } from '@agoric/assert'; import { encodeBase64, decodeBase64 } from '@endo/base64'; +/** + * @import {Bytes} from './types.js'; + */ + /** @typedef {Bytes | Buffer | Uint8Array | Iterable} ByteSource */ /** diff --git a/packages/network/src/index.js b/packages/network/src/index.js index 2bf1e45eacd..794df3a6b79 100644 --- a/packages/network/src/index.js +++ b/packages/network/src/index.js @@ -3,3 +3,5 @@ export * from './shapes.js'; export { prepareRouter, prepareRouterProtocol } from './router.js'; export * from './multiaddr.js'; export * from './bytes.js'; +// eslint-disable-next-line import/export -- doesn't know types +export * from './types.js'; diff --git a/packages/network/src/network.js b/packages/network/src/network.js index 2a09b56b33e..a5d4136ae10 100644 --- a/packages/network/src/network.js +++ b/packages/network/src/network.js @@ -8,6 +8,9 @@ import { Shape } from './shapes.js'; import '@agoric/store/exported.js'; /// +/** + * @import {AttemptDescription, Bytes, Closable, CloseReason, Connection, ConnectionHandler, Endpoint, ListenHandler, Port, Protocol, ProtocolHandler, ProtocolImpl} from './types.js'; + */ /** * Compatibility note: this must match what our peers use, so don't change it @@ -409,7 +412,7 @@ const preparePort = (zone, powers) => { * @param {MapStore>} opts.currentConnections * @param {MapStore} opts.boundPorts * @param {import('@agoric/vow').Remote} opts.protocolHandler - * @param {Remote} opts.protocolImpl + * @param {import('@agoric/vow').Remote} opts.protocolImpl */ const initPort = ({ localAddr, @@ -454,7 +457,9 @@ const preparePort = (zone, powers) => { } listening.set(localAddr, [ this.facets.port, - /** @type {Remote>} */ (listenHandler), + /** @type {import('@agoric/vow').Remote>} */ ( + listenHandler + ), ]); E(lhandler).onRemove(lport, lhandler).catch(rethrowUnlessMissing); } else { @@ -462,7 +467,9 @@ const preparePort = (zone, powers) => { localAddr, harden([ this.facets.port, - /** @type {Remote>} */ (listenHandler), + /** @type {import('@agoric/vow').Remote>} */ ( + listenHandler + ), ]), ); } @@ -481,7 +488,7 @@ const preparePort = (zone, powers) => { ); return watch(innerVow, this.facets.rethrowUnlessMissingWatcher); }, - /** @param {Remote} listenHandler */ + /** @param {import('@agoric/vow').Remote} listenHandler */ async removeListener(listenHandler) { const { listening, localAddr, protocolHandler } = this.state; listening.has(localAddr) || Fail`Port ${localAddr} is not listening`; @@ -503,11 +510,11 @@ const preparePort = (zone, powers) => { }, /** * @param {Endpoint} remotePort - * @param {Remote} [connectionHandler] + * @param {import('@agoric/vow').Remote} [connectionHandler] */ async connect( remotePort, - connectionHandler = /** @type {Remote} */ ( + connectionHandler = /** @type {import('@agoric/vow').Remote} */ ( makeIncapable() ), ) { @@ -724,8 +731,8 @@ const prepareBinder = (zone, powers) => { * @param {object} opts * @param {MapStore>} opts.currentConnections * @param {MapStore} opts.boundPorts - * @param {MapStore>]>} opts.listening - * @param {Remote} opts.protocolHandler + * @param {MapStore>]>} opts.listening + * @param {import('@agoric/vow').Remote} opts.protocolHandler */ ({ currentConnections, boundPorts, listening, protocolHandler }) => { /** @type {SetStore} */ @@ -771,7 +778,7 @@ const prepareBinder = (zone, powers) => { const innerVow = watch( E( - /** @type {Remote>} */ ( + /** @type {import('@agoric/vow').Remote>} */ ( protocolHandler ), ).onInstantiate( @@ -813,7 +820,7 @@ const prepareBinder = (zone, powers) => { // Allocate a local address. const instantiateInnerVow = watch( E( - /** @type {Remote>} */ ( + /** @type {import('@agoric/vow').Remote>} */ ( protocolHandler ), ).onInstantiate(port, localAddr, remoteAddr, protocolHandler), @@ -939,7 +946,7 @@ const prepareBinder = (zone, powers) => { const innerVow = watch( E( - /** @type {Remote>} */ ( + /** @type {import('@agoric/vow').Remote>} */ ( protocolHandler ), ).onInstantiate( @@ -1169,7 +1176,7 @@ export const prepareNetworkProtocol = (zone, powers) => { const makeBinderKit = prepareBinder(zone, powers); /** - * @param {Remote} protocolHandler + * @param {import('@agoric/vow').Remote} protocolHandler * @returns {Protocol} */ const makeNetworkProtocol = protocolHandler => { @@ -1181,7 +1188,7 @@ export const prepareNetworkProtocol = (zone, powers) => { /** @type {MapStore} */ const boundPorts = detached.mapStore('addrToPort'); - /** @type {MapStore>]>} */ + /** @type {MapStore>]>} */ const listening = detached.mapStore('listening'); const { binder, protocolImpl } = makeBinderKit({ @@ -1293,7 +1300,7 @@ export function prepareLoopbackProtocolHandler(zone, { watch, allVows }) { /** @param {string} [instancePrefix] */ const initHandler = (instancePrefix = 'nonce/') => { - /** @type {MapStore, Remote>]>} */ + /** @type {MapStore, import('@agoric/vow').Remote>]>} */ const listeners = detached.mapStore('localAddr'); return { @@ -1325,7 +1332,7 @@ export function prepareLoopbackProtocolHandler(zone, { watch, allVows }) { * @param {*} _port * @param {Endpoint} localAddr * @param {Endpoint} remoteAddr - * @returns {PromiseVow}} + * @returns {import('@agoric/vow').PromiseVow}} */ async onConnect(_port, localAddr, remoteAddr) { const { listeners } = this.state; @@ -1372,7 +1379,7 @@ export function prepareLoopbackProtocolHandler(zone, { watch, allVows }) { localAddr, harden([ port, - /** @type {Remote>} */ ( + /** @type {import('@agoric/vow').Remote>} */ ( listenHandler ), ]), @@ -1383,15 +1390,17 @@ export function prepareLoopbackProtocolHandler(zone, { watch, allVows }) { localAddr, harden([ port, - /** @type {Remote>} */ (listenHandler), + /** @type {import('@agoric/vow').Remote>} */ ( + listenHandler + ), ]), ); } }, /** - * @param {Remote} port + * @param {import('@agoric/vow').Remote} port * @param {Endpoint} localAddr - * @param {Remote} listenHandler + * @param {import('@agoric/vow').Remote} listenHandler * @param {*} _protocolHandler */ async onListenRemove(port, localAddr, listenHandler, _protocolHandler) { diff --git a/packages/network/src/router.js b/packages/network/src/router.js index 27de1036b0a..477a23f4f35 100644 --- a/packages/network/src/router.js +++ b/packages/network/src/router.js @@ -8,6 +8,10 @@ import { Shape } from './shapes.js'; // XXX ambient types runtime imports until https://github.com/Agoric/agoric-sdk/issues/6512 import '@agoric/store/exported.js'; /// +/** + * @import {AttemptDescription, Bytes, Closable, CloseReason, Connection, ConnectionHandler, Endpoint, ListenHandler, Port, Protocol, ProtocolHandler, ProtocolImpl} from './types.js'; + * @import {PromiseVow, Remote, VowKit, VowResolver, VowTools} from '@agoric/vow'; + */ /** * @template T diff --git a/packages/network/src/types.js b/packages/network/src/types.js index 43e0e90c366..204a8a4fcaf 100644 --- a/packages/network/src/types.js +++ b/packages/network/src/types.js @@ -1,5 +1,8 @@ // @ts-check +// Ensure this is a module. +export {}; + /** @import {PromiseVow, Remote} from '@agoric/vow' */ /** diff --git a/packages/network/test/test-network-misc.js b/packages/network/test/test-network-misc.js index 9c23e443b4d..e406e720f16 100644 --- a/packages/network/test/test-network-misc.js +++ b/packages/network/test/test-network-misc.js @@ -17,7 +17,9 @@ import { preparePortAllocator, } from '../src/index.js'; -import '../src/types.js'; +/** + * @import {ListenHandler} from '../src/types.js'; + */ // eslint-disable-next-line no-constant-condition const log = false ? console.log : () => {}; diff --git a/packages/orchestration/src/service.js b/packages/orchestration/src/service.js index 55e7f632922..a4443dd665d 100644 --- a/packages/orchestration/src/service.js +++ b/packages/orchestration/src/service.js @@ -14,11 +14,12 @@ import { makeICAConnectionAddress, parseAddress } from './utils/address.js'; import { makeTxPacket, parsePacketAck } from './utils/tx.js'; /** - * @import { ChainAccount, ChainAddress } from './types.js'; + * @import {Connection, Port, PortAllocator} from '@agoric/network'; + * @import {Remote} from '@agoric/vow'; * @import { IBCConnectionID } from '@agoric/vats'; * @import { Zone } from '@agoric/base-zone'; * @import { TxBody } from '@agoric/cosmic-proto/cosmos/tx/v1beta1/tx.js'; - * + * @import { AttenuatedNetwork, ChainAccount, ChainAddress } from './types.js'; */ const { Fail, bare } = assert; diff --git a/packages/vats/src/proposals/network-proposal.js b/packages/vats/src/proposals/network-proposal.js index 7b88b855ae4..cd3f2587bb9 100644 --- a/packages/vats/src/proposals/network-proposal.js +++ b/packages/vats/src/proposals/network-proposal.js @@ -11,6 +11,11 @@ import { makeScalarBigMapStore } from '@agoric/vat-data'; // bootstrap vat can't yet be upgraded. import { when } from '@agoric/vat-data/vow.js'; +/** + * @import {ProtocolHandler} from '@agoric/network'; + * @import {Remote} from '@agoric/vow'; + */ + const NUM_IBC_PORTS_PER_CLIENT = 3; /** From 001d8e44070ff14c1956be51f95619bb0340394e Mon Sep 17 00:00:00 2001 From: Turadg Aleahmad Date: Tue, 30 Apr 2024 11:36:01 -0700 Subject: [PATCH 14/14] chore(types): accomodate export changes --- packages/boot/test/bootstrapTests/ibcClientMock.js | 4 ++++ packages/boot/test/bootstrapTests/ibcServerMock.js | 4 ++++ .../deploy-script-support/src/coreProposalBehavior.js | 4 ++++ packages/governance/src/contractGovernance/governParam.js | 1 + packages/governance/src/index.js | 6 ++---- packages/governance/src/types.js | 2 ++ packages/inter-protocol/src/auction/auctionBook.js | 2 ++ packages/inter-protocol/src/proposals/econ-behaviors.js | 1 + packages/inter-protocol/src/provisionPoolKit.js | 2 +- .../orchestration/src/proposals/orchestration-proposal.js | 1 + packages/pegasus/src/courier.js | 2 ++ packages/pegasus/src/pegasus.js | 5 +++++ packages/pegasus/src/proposals/core-proposal.js | 4 ++++ packages/pegasus/src/types.js | 3 +++ packages/smart-wallet/src/invitations.js | 3 +++ packages/smart-wallet/src/offers.js | 3 +++ .../src/proposals/upgrade-wallet-factory2-proposal.js | 3 +++ packages/smart-wallet/src/smartWallet.js | 3 +++ packages/smart-wallet/src/utils.js | 4 ++++ packages/vats/src/ibc.js | 8 ++++++-- 20 files changed, 58 insertions(+), 7 deletions(-) diff --git a/packages/boot/test/bootstrapTests/ibcClientMock.js b/packages/boot/test/bootstrapTests/ibcClientMock.js index 33458da604e..9578d6dfe41 100644 --- a/packages/boot/test/bootstrapTests/ibcClientMock.js +++ b/packages/boot/test/bootstrapTests/ibcClientMock.js @@ -3,6 +3,10 @@ import { Far } from '@endo/far'; import { V as E } from '@agoric/vat-data/vow.js'; +/** + * @import {ListenHandler, PortAllocator} from '@agoric/network'; + */ + /** * @param {ZCF} zcf * @param {{ diff --git a/packages/boot/test/bootstrapTests/ibcServerMock.js b/packages/boot/test/bootstrapTests/ibcServerMock.js index 1370146c65e..11367cbf3fb 100644 --- a/packages/boot/test/bootstrapTests/ibcServerMock.js +++ b/packages/boot/test/bootstrapTests/ibcServerMock.js @@ -7,6 +7,10 @@ import { V as E } from '@agoric/vat-data/vow.js'; const { quote: q, Fail } = assert; const { log } = console; +/** + * @import {ListenHandler, PortAllocator} from '@agoric/network'; + */ + /** * * @param {ZCF} zcf diff --git a/packages/deploy-script-support/src/coreProposalBehavior.js b/packages/deploy-script-support/src/coreProposalBehavior.js index f473edf2a94..6551b0dfb92 100644 --- a/packages/deploy-script-support/src/coreProposalBehavior.js +++ b/packages/deploy-script-support/src/coreProposalBehavior.js @@ -1,6 +1,10 @@ // @ts-check const t = 'makeCoreProposalBehavior'; +/** + * @import {Installation} from '@agoric/zoe/src/zoeService/utils.js'; + */ + /** * TODO import these from @agoric/vats when the types are better managed * diff --git a/packages/governance/src/contractGovernance/governParam.js b/packages/governance/src/contractGovernance/governParam.js index 003877c0ae3..f06c7d4bb19 100644 --- a/packages/governance/src/contractGovernance/governParam.js +++ b/packages/governance/src/contractGovernance/governParam.js @@ -9,6 +9,7 @@ import { QuorumRule, } from '../question.js'; import { ParamChangesQuestionDetailsShape } from '../typeGuards.js'; + /** * @import {ParamValue, ParamChangePositions, QuestionSpec, ChangeParamsPosition, ParamChangeIssue, ParamGovernor, ParamManagerRetriever, PoserFacet, VoteOnParamChanges} from '../types.js'; */ diff --git a/packages/governance/src/index.js b/packages/governance/src/index.js index 481cff9b3d0..b3e2cc5a24d 100644 --- a/packages/governance/src/index.js +++ b/packages/governance/src/index.js @@ -1,9 +1,7 @@ // XXX ambient types runtime imports until https://github.com/Agoric/agoric-sdk/issues/6512 +import '@agoric/internal/exported.js'; import '@agoric/ertp/exported.js'; - -import '@agoric/zoe/src/contractFacet/types-ambient.js'; -import '@agoric/zoe/tools/types-ambient.js'; -import '@agoric/zoe/src/types.js'; +import '@agoric/zoe/exported.js'; /// diff --git a/packages/governance/src/types.js b/packages/governance/src/types.js index 23c8e3ddec7..cced1b34245 100644 --- a/packages/governance/src/types.js +++ b/packages/governance/src/types.js @@ -1,3 +1,5 @@ +import '@agoric/zoe/src/zoeService/types-ambient.js'; + export {}; /** @import {ContractStartFunction} from '@agoric/zoe/src/zoeService/utils.js' */ diff --git a/packages/inter-protocol/src/auction/auctionBook.js b/packages/inter-protocol/src/auction/auctionBook.js index 47f00e0e1c2..e819fe8f53c 100644 --- a/packages/inter-protocol/src/auction/auctionBook.js +++ b/packages/inter-protocol/src/auction/auctionBook.js @@ -1,3 +1,5 @@ +// XXX ambient types runtime imports until https://github.com/Agoric/agoric-sdk/issues/6512 +import '@agoric/internal/exported.js'; import '@agoric/governance/exported.js'; import '@agoric/zoe/exported.js'; import '@agoric/zoe/src/contracts/exported.js'; diff --git a/packages/inter-protocol/src/proposals/econ-behaviors.js b/packages/inter-protocol/src/proposals/econ-behaviors.js index f683e6357d1..ed220917ee4 100644 --- a/packages/inter-protocol/src/proposals/econ-behaviors.js +++ b/packages/inter-protocol/src/proposals/econ-behaviors.js @@ -3,6 +3,7 @@ // XXX ambient types runtime imports until https://github.com/Agoric/agoric-sdk/issues/6512 import '../../exported.js'; import '@agoric/governance/exported.js'; +import '@agoric/vats/src/core/types-ambient.js'; import { AmountMath } from '@agoric/ertp'; import { deeplyFulfilledObject, makeTracer } from '@agoric/internal'; diff --git a/packages/inter-protocol/src/provisionPoolKit.js b/packages/inter-protocol/src/provisionPoolKit.js index 7e2ee30f192..179c562b281 100644 --- a/packages/inter-protocol/src/provisionPoolKit.js +++ b/packages/inter-protocol/src/provisionPoolKit.js @@ -26,6 +26,7 @@ const { details: X, quote: q, Fail } = assert; /** * @import {ERef} from '@endo/far' * @import {Amount} from '@agoric/ertp/src/types.js' + * @import {Bank, BankManager} from '@agoric/vats/src/vat-bank.js' */ /** @@ -59,7 +60,6 @@ const { details: X, quote: q, Fail } = assert; * * @param {(depositBank: ERef) => Promise} sendInitialPayment * @param {() => void} onProvisioned - * @import {Bank} from '@agoric/vats/src/vat-bank.js' */ export const makeBridgeProvisionTool = (sendInitialPayment, onProvisioned) => { /** @param {ProvisionPoolKitReferences} refs */ diff --git a/packages/orchestration/src/proposals/orchestration-proposal.js b/packages/orchestration/src/proposals/orchestration-proposal.js index c889383bcda..c48eb0a4ef6 100644 --- a/packages/orchestration/src/proposals/orchestration-proposal.js +++ b/packages/orchestration/src/proposals/orchestration-proposal.js @@ -2,6 +2,7 @@ import { V as E } from '@agoric/vat-data/vow.js'; /** + * @import {Connection, Port, PortAllocator} from '@agoric/network'; * @import { OrchestrationService } from '../service.js' * @import { OrchestrationVat } from '../vat-orchestration.js' */ diff --git a/packages/pegasus/src/courier.js b/packages/pegasus/src/courier.js index 8ddd587ccfc..59eed5b1858 100644 --- a/packages/pegasus/src/courier.js +++ b/packages/pegasus/src/courier.js @@ -8,6 +8,8 @@ import { makeOncePromiseKit } from './once-promise-kit.js'; /** * @import {DepositFacet} from '@agoric/ertp/exported.js' + * @import {Connection} from '@agoric/network'; + * @import {Remote} from '@agoric/vow'; */ /** diff --git a/packages/pegasus/src/pegasus.js b/packages/pegasus/src/pegasus.js index b9ca77220fb..649eb4d40e7 100644 --- a/packages/pegasus/src/pegasus.js +++ b/packages/pegasus/src/pegasus.js @@ -17,6 +17,11 @@ import { IBCSourceTraceDenomTransformer } from './ibc-trace.js'; import { ICS20TransferProtocol } from './ics20.js'; import { makeCourierMaker, getCourierPK } from './courier.js'; +/** + * @import {CloseReason, Connection} from '@agoric/network'; + * @import {Remote} from '@agoric/vow'; + */ + const DEFAULT_DENOM_TRANSFORMER = IBCSourceTraceDenomTransformer; const DEFAULT_TRANSFER_PROTOCOL = ICS20TransferProtocol; diff --git a/packages/pegasus/src/proposals/core-proposal.js b/packages/pegasus/src/proposals/core-proposal.js index dde255ccad1..0bbfe5f71b3 100644 --- a/packages/pegasus/src/proposals/core-proposal.js +++ b/packages/pegasus/src/proposals/core-proposal.js @@ -3,6 +3,10 @@ import { E, Far } from '@endo/far'; import { makeNameHubKit } from '@agoric/vats/src/nameHub.js'; import { observeIteration, subscribeEach } from '@agoric/notifier'; +/** + * @import {Connection, Port, PortAllocator} from '@agoric/network'; + */ + export const CONTRACT_NAME = 'Pegasus'; const t = 'pegasus'; diff --git a/packages/pegasus/src/types.js b/packages/pegasus/src/types.js index 0747712963b..921139ce8f8 100644 --- a/packages/pegasus/src/types.js +++ b/packages/pegasus/src/types.js @@ -1,6 +1,9 @@ // @ts-check /// +/** + * @import {Bytes, ConnectionHandler} from '@agoric/network'; + */ /** * @typedef {string} Denom diff --git a/packages/smart-wallet/src/invitations.js b/packages/smart-wallet/src/invitations.js index 5acd5e7d428..34d34a6d872 100644 --- a/packages/smart-wallet/src/invitations.js +++ b/packages/smart-wallet/src/invitations.js @@ -4,6 +4,9 @@ import { InvitationHandleShape } from '@agoric/zoe/src/typeGuards.js'; import { E } from '@endo/far'; import { shape } from './typeGuards.js'; +// XXX ambient types runtime imports until https://github.com/Agoric/agoric-sdk/issues/6512 +import '@agoric/zoe/exported.js'; + const { Fail } = assert; // A safety limit diff --git a/packages/smart-wallet/src/offers.js b/packages/smart-wallet/src/offers.js index 6c78021ff9c..bd4b73c0f01 100644 --- a/packages/smart-wallet/src/offers.js +++ b/packages/smart-wallet/src/offers.js @@ -1,3 +1,6 @@ +// XXX ambient types runtime imports until https://github.com/Agoric/agoric-sdk/issues/6512 +import '@agoric/zoe/src/zoeService/types-ambient.js'; + /** * @typedef {number | string} OfferId */ diff --git a/packages/smart-wallet/src/proposals/upgrade-wallet-factory2-proposal.js b/packages/smart-wallet/src/proposals/upgrade-wallet-factory2-proposal.js index 60252d54616..2ebb86e3fc5 100644 --- a/packages/smart-wallet/src/proposals/upgrade-wallet-factory2-proposal.js +++ b/packages/smart-wallet/src/proposals/upgrade-wallet-factory2-proposal.js @@ -2,6 +2,9 @@ import { E } from '@endo/far'; import { makeStorageNodeChild } from '@agoric/internal/src/lib-chainStorage.js'; +// XXX ambient types runtime imports until https://github.com/Agoric/agoric-sdk/issues/6512 +import '@agoric/vats/src/core/types-ambient.js'; + /** * @param {BootstrapPowers & ChainBootstrapSpace} powers * @param {object} options diff --git a/packages/smart-wallet/src/smartWallet.js b/packages/smart-wallet/src/smartWallet.js index 270edb892e0..9ef0da19135 100644 --- a/packages/smart-wallet/src/smartWallet.js +++ b/packages/smart-wallet/src/smartWallet.js @@ -42,6 +42,9 @@ import { shape } from './typeGuards.js'; import { objectMapStoragePath } from './utils.js'; import { prepareOfferWatcher, watchOfferOutcomes } from './offerWatcher.js'; +// XXX ambient types runtime imports until https://github.com/Agoric/agoric-sdk/issues/6512 +import '@agoric/zoe/exported.js'; + const { Fail, quote: q } = assert; const trace = makeTracer('SmrtWlt'); diff --git a/packages/smart-wallet/src/utils.js b/packages/smart-wallet/src/utils.js index 9740bda9405..39dee3cbbd2 100644 --- a/packages/smart-wallet/src/utils.js +++ b/packages/smart-wallet/src/utils.js @@ -2,6 +2,10 @@ import { deeplyFulfilledObject, objectMap, makeTracer } from '@agoric/internal'; import { observeIteration, subscribeEach } from '@agoric/notifier'; import { E } from '@endo/far'; +// XXX ambient types runtime imports until https://github.com/Agoric/agoric-sdk/issues/6512 +import '@agoric/internal/exported.js'; +import '@agoric/notifier/exported.js'; + export const NO_SMART_WALLET_ERROR = 'no smart wallet'; const trace = makeTracer('WUTIL', false); diff --git a/packages/vats/src/ibc.js b/packages/vats/src/ibc.js index a48718bc8cc..a1e0e1c9486 100644 --- a/packages/vats/src/ibc.js +++ b/packages/vats/src/ibc.js @@ -14,7 +14,10 @@ import { encodeRemoteIbcAddress, } from '../tools/ibc-utils.js'; -/** @import {LocalIbcAddress, RemoteIbcAddress} from '../tools/ibc-utils.js' */ +/** + * @import {LocalIbcAddress, RemoteIbcAddress} from '../tools/ibc-utils.js'; + * @import {AttemptDescription} from '@agoric/network'; + */ // CAVEAT: IBC acks cannot be empty, as the Cosmos IAVL tree cannot represent // empty acknowledgements as distinct from unacknowledged packets. @@ -24,9 +27,10 @@ const DEFAULT_ACKNOWLEDGEMENT = '\x00'; const DEFAULT_PACKET_TIMEOUT_NS = 60n * 60n * 1_000_000_000n; /** + * @import {Endpoint, Connection, ConnectionHandler, InboundAttempt, Bytes, ProtocolHandler, ProtocolImpl} from '@agoric/network'; * @import {BridgeHandler, ScopedBridgeManager, ConnectingInfo, IBCChannelID, IBCChannelOrdering, IBCEvent, IBCPacket, IBCPortID, IBCDowncallPacket, IBCDowncallMethod, IBCDowncall, IBCBridgeEvent} from './types.js'; * @import {Zone} from '@agoric/base-zone'; - * @import {Remote, VowKit, VowResolver, VowTools} from '@agoric/vow'; + * @import {PromiseVow, Remote, VowKit, VowResolver, VowTools} from '@agoric/vow'; */ /** @typedef {VowKit} OnConnectP */