diff --git a/packages/SwingSet/src/types-external.js b/packages/SwingSet/src/types-external.js index b27d225eacb7..7b45acfa86ca 100644 --- a/packages/SwingSet/src/types-external.js +++ b/packages/SwingSet/src/types-external.js @@ -2,6 +2,11 @@ export {}; +/** + * @import {Guarded} from '@endo/exo') + * @import {Passable, RemotableObject} from '@endo/pass-style') + */ + /* This file defines types that part of the external API of swingset. That * includes standard services which user-provided vat code might interact * with, like VatAdminService. */ @@ -350,9 +355,7 @@ export {}; * incarnation. * * - * @typedef {object} CreateVatResults - * @property {object} root - * @property {VatAdminFacet} adminNode + * @typedef {{ adminNode: Guarded, root: object }} CreateVatResults * * @typedef {object} VatAdminSvc * @property {(id: BundleID) => ERef} waitForBundleCap diff --git a/packages/agoric-cli/src/lib/format.js b/packages/agoric-cli/src/lib/format.js index cad70a023dc2..9e50c4d6e33e 100644 --- a/packages/agoric-cli/src/lib/format.js +++ b/packages/agoric-cli/src/lib/format.js @@ -54,7 +54,9 @@ export const makeAmountFormatter = assets => amt => { return [issuerName, Number(value) / 10 ** decimalPlaces]; case 'set': assert(Array.isArray(value)); + // @ts-expect-error narrowed if (value[0]?.handle?.iface?.includes('InvitationHandle')) { + // @ts-expect-error narrowed return [issuerName, value.map(v => v.description)]; } return [issuerName, value]; diff --git a/packages/base-zone/src/types.js b/packages/base-zone/src/types.js index 7a5cfae1d35b..1eaaab903a92 100644 --- a/packages/base-zone/src/types.js +++ b/packages/base-zone/src/types.js @@ -30,9 +30,9 @@ export {}; * @typedef {object} Stores * @property {() => Stores} detached obtain store providers which are detached (the stores are anonymous rather than bound to `label` in the zone) * @property {(specimen: unknown) => boolean} isStorable return true if the specimen can be stored in the zone, whether as exo-object state or in a store - * @property {(label: string, options?: StoreOptions) => MapStore} mapStore provide a Map-like store named `label` in the zone - * @property {(label: string, options?: StoreOptions) => SetStore} setStore provide a Set-like store named `label` in the zone - * @property {( + * @property {(label: string, options?: StoreOptions) => MapStore} mapStore provide a Map-like store named `label` in the zone + * @property {(label: string, options?: StoreOptions) => SetStore} setStore provide a Set-like store named `label` in the zone + * @property {( * label: string, options?: StoreOptions) => WeakMapStore * } weakMapStore provide a WeakMap-like store named `label` in the zone * @property {( diff --git a/packages/governance/src/types.js b/packages/governance/src/types.js index 3a3f0b531a10..c47b567dc0db 100644 --- a/packages/governance/src/types.js +++ b/packages/governance/src/types.js @@ -731,7 +731,7 @@ export {}; * Akin to StartedInstanceKit but designed for the results of starting governed contracts. Used in bootstrap space. * @property {AdminFacet} adminFacet of the governed contract * @property {LimitedCF} creatorFacet creator-like facet within the governed contract (without the powers the governor needs) - * @property {GovernorCreatorFacet} governorCreatorFacet of the governing contract + * @property {Guarded>} governorCreatorFacet of the governing contract * @property {AdminFacet} governorAdminFacet of the governing contract * @property {Awaited>['publicFacet']} publicFacet * @property {Instance} instance diff --git a/packages/inter-protocol/src/provisionPoolKit.js b/packages/inter-protocol/src/provisionPoolKit.js index 768a4440e96a..cd87e8571dfe 100644 --- a/packages/inter-protocol/src/provisionPoolKit.js +++ b/packages/inter-protocol/src/provisionPoolKit.js @@ -348,7 +348,6 @@ export const prepareProvisionPoolKit = ( console.log('provisionPool notified of new asset', desc.brand); await zcf.saveIssuer(desc.issuer, desc.issuerName); /** @type {ERef} */ - // @ts-expect-error vbank purse is close enough for our use. const exchangePurse = E(poolBank).getPurse(desc.brand); void observeNotifier( E(exchangePurse).getCurrentAmountNotifier(), diff --git a/packages/pegasus/src/contract.js b/packages/pegasus/src/contract.js index ae874a60a1ff..16d4c33f4c05 100644 --- a/packages/pegasus/src/contract.js +++ b/packages/pegasus/src/contract.js @@ -7,6 +7,10 @@ import '@agoric/zoe/exported.js'; import '../exported.js'; +/** + * @import {Remote} from '@agoric/vow'; + */ + /** * @type {ContractStartFn, diff --git a/packages/smart-wallet/src/smartWallet.js b/packages/smart-wallet/src/smartWallet.js index 52d427dcedc2..34aa63d65939 100644 --- a/packages/smart-wallet/src/smartWallet.js +++ b/packages/smart-wallet/src/smartWallet.js @@ -770,7 +770,6 @@ export const prepareSmartWallet = (baggage, shared) => { const { registry, invitationBrand } = shared; if (registry.has(brand)) { - // @ts-expect-error virtual purse return E(state.bank).getPurse(brand); } else if (invitationBrand === brand) { return state.invitationPurse; diff --git a/packages/smart-wallet/test/contexts.js b/packages/smart-wallet/test/contexts.js index 7429634122ae..728c64a090ab 100644 --- a/packages/smart-wallet/test/contexts.js +++ b/packages/smart-wallet/test/contexts.js @@ -62,7 +62,6 @@ export const makeDefaultTestContext = async (t, makeSpace) => { }; const anchor = withAmountUtils( - // @ts-expect-error incomplete typedef await deeplyFulfilledObject(consume.testFirstAnchorKit), ); diff --git a/packages/smart-wallet/test/test-marshal-contexts.js b/packages/smart-wallet/test/test-marshal-contexts.js index 596096da37f6..7ee179d0eac8 100644 --- a/packages/smart-wallet/test/test-marshal-contexts.js +++ b/packages/smart-wallet/test/test-marshal-contexts.js @@ -62,10 +62,13 @@ test('makeImportContext preserves identity across AMM and wallet', t => { slots: ['board011'], }); - /** @type {Brand[]} */ - const [b1] = context.fromBoard.fromCapData(ammMetricsCapData); - /** @type {Brand[]} */ - const [b2] = context.fromBoard.fromCapData(amm.getMetrics()); + const [b1] = /** @type {Brand[]} */ ( + context.fromBoard.fromCapData(ammMetricsCapData) + ); + + const [b2] = /** @type {Brand[]} */ ( + context.fromBoard.fromCapData(amm.getMetrics()) + ); t.is(b1, b2, 'unserialization twice from same source'); const myWallet = makeOnChainWallet(board); @@ -85,6 +88,7 @@ test('makeImportContext preserves identity across AMM and wallet', t => { slots: ['board011', 'purse:ATOM'], }); + /** @type {any} */ const walletState = context.fromMyWallet.fromCapData(walletCapData); t.is(walletState[0].brand, b1, 'unserialization across sources'); diff --git a/packages/solo/src/pipe-entrypoint.js b/packages/solo/src/pipe-entrypoint.js index 0914ccfa36eb..81781f78f9da 100644 --- a/packages/solo/src/pipe-entrypoint.js +++ b/packages/solo/src/pipe-entrypoint.js @@ -29,6 +29,7 @@ const main = async () => { mutex.resolve(undefined); return; } + /** @type {any} */ const as = parse(`${msg}`); deliverator(...as).then(() => send('go')); }); diff --git a/packages/solo/src/pipe.js b/packages/solo/src/pipe.js index 4a743e4144e1..ade11381e697 100644 --- a/packages/solo/src/pipe.js +++ b/packages/solo/src/pipe.js @@ -31,6 +31,7 @@ export const connectToPipe = async ({ method, args, deliverInboundToMbx }) => { return; } // console.log('pipe.js', msg); + /** @type {any} */ const as = parse(`${msg}`); deliverInboundToMbx(...as).then(() => cp.send('go')); }); diff --git a/packages/telemetry/src/slog-to-otel.js b/packages/telemetry/src/slog-to-otel.js index 0cadc4911d03..e53583d1b21d 100644 --- a/packages/telemetry/src/slog-to-otel.js +++ b/packages/telemetry/src/slog-to-otel.js @@ -139,7 +139,10 @@ export const makeSlogToOtelKit = (tracer, overrideAttrs = {}) => { serializeBodyFormat: 'smallcaps', }); - /** @param {import('@agoric/swingset-vat').SwingSetCapData} data */ + /** + * @param {import('@agoric/swingset-vat').SwingSetCapData} data + * @returns {any} + */ const unserialize = data => { try { const body = rawUnserialize(data); diff --git a/packages/vat-data/src/vat-data-bindings.js b/packages/vat-data/src/vat-data-bindings.js index 2c2235d952d8..f336d606ea05 100644 --- a/packages/vat-data/src/vat-data-bindings.js +++ b/packages/vat-data/src/vat-data-bindings.js @@ -9,8 +9,8 @@ import { provideLazy } from '@agoric/store'; let VatDataGlobal; if ('VatData' in globalThis) { globalThis.VatData || Fail`VatData defined in global as null or undefined`; - // @ts-expect-error XXX - VatDataGlobal = globalThis.VatData; + // XXX types incompatibility + VatDataGlobal = /** @type {any} */ (globalThis.VatData); } else { // XXX this module has been known to get imported (transitively) in cases that // never use it so we make a version that will satisfy module resolution but diff --git a/packages/vats/src/core/basic-behaviors.js b/packages/vats/src/core/basic-behaviors.js index c25922d5ea8c..c5cc5dcee130 100644 --- a/packages/vats/src/core/basic-behaviors.js +++ b/packages/vats/src/core/basic-behaviors.js @@ -63,6 +63,7 @@ export const makeVatsFromBundles = async ({ // NOTE: we rely on multiple createVatAdminService calls // to return cooperating services. const svc = E(vats.vatAdmin).createVatAdminService(devices.vatAdmin); + // @ts-expect-error XXX vatAdminSvc.resolve(svc); const durableStore = await vatStore; @@ -77,6 +78,7 @@ export const makeVatsFromBundles = async ({ if (bundleName) { console.info(`createVatByName(${bundleName})`); /** @type {Promise} */ + // @ts-expect-error XXX const vatInfo = E(svc).createVatByName(bundleName, { ...defaultVatCreationOptions, name: vatName, @@ -87,6 +89,7 @@ export const makeVatsFromBundles = async ({ assert(bundleID); const bcap = await E(svc).getBundleCap(bundleID); /** @type {Promise} */ + // @ts-expect-error XXX const vatInfo = E(svc).createVat(bcap, { ...defaultVatCreationOptions, name: vatName, diff --git a/packages/vats/src/types.d.ts b/packages/vats/src/types.d.ts index 465fc541d326..081567ee76f5 100644 --- a/packages/vats/src/types.d.ts +++ b/packages/vats/src/types.d.ts @@ -93,12 +93,12 @@ export type BridgeHandler = { }; /** An object which handles messages for a specific bridge */ -export type ScopedBridgeManager = { +export type ScopedBridgeManager = Guarded<{ toBridge: (obj: any) => Promise; fromBridge: (obj: any) => PromiseVow; initHandler: (handler: ERef) => void; setHandler: (handler: ERef) => void; -}; +}>; /** The object to manage this bridge */ export type BridgeManager = { diff --git a/packages/vats/src/vat-bank.js b/packages/vats/src/vat-bank.js index ce22cef1bca3..8025f269d45c 100644 --- a/packages/vats/src/vat-bank.js +++ b/packages/vats/src/vat-bank.js @@ -21,6 +21,11 @@ import { import '@agoric/notifier/exported.js'; +/** + * @import {Guarded} from '@endo/exo') + * @import {Passable, RemotableObject} from '@endo/pass-style') + */ + const { Fail } = assert; const { VirtualPurseControllerI } = makeVirtualPurseKitIKit(); @@ -38,8 +43,9 @@ const BridgeChannelI = M.interface('BridgeChannel', { */ /** - * @typedef {object} BalanceUpdater - * @property {(value: string, nonce?: string) => void} update + * @typedef {Guarded<{ + * update: (value: string, nonce?: string) => void; + * }>} BalanceUpdater */ const BalanceUpdaterI = M.interface('BalanceUpdater', { @@ -362,12 +368,17 @@ const AssetIssuerKitShape = M.splitRecord(BaseIssuerKitShape, { mint: M.remotable('Mint'), }); -/** @typedef {AssetIssuerKit & { denom: string; escrowPurse?: ERef }} AssetRecord */ +/** + * @typedef {AssetIssuerKit & { + * denom: string; + * escrowPurse?: RemotableObject & ERef; + * }} AssetRecord + */ /** * @typedef {object} AssetDescriptor * @property {Brand} brand - * @property {ERef} issuer + * @property {RemotableObject & ERef} issuer * @property {string} issuerName * @property {string} denom * @property {string} proposedName @@ -411,6 +422,7 @@ const prepareBank = ( // (which we emulate, since we know both address and denom are JSONable). If // we decide to partition the provider and use `brandToVPurse` directly, we'd // need ephemera for each `makeBank` call. + /** @type {MapStore} */ const addressDenomToPurse = zone.mapStore('addressDenomToPurse'); /** * @type {import('@agoric/store/src/stores/store-utils.js').AtomicProvider< @@ -584,7 +596,7 @@ const prepareBankManager = ( /** * @type {MapStore< * string, - * { bank: Bank; brandToVPurse: MapStore } + * { bank: Guarded; brandToVPurse: MapStore } * >} */ const addressToBank = detachedZone.mapStore('addressToBank'); diff --git a/packages/vats/test/test-bootstrapPayment.js b/packages/vats/test/test-bootstrapPayment.js index efc1081e5123..b59f636df001 100644 --- a/packages/vats/test/test-bootstrapPayment.js +++ b/packages/vats/test/test-bootstrapPayment.js @@ -40,7 +40,6 @@ test.before(async (/** @type {CentralSupplyTestContext} */ t) => { }; t.context = await deeplyFulfilled( - // @ts-expect-error XXX harden({ zoe, feeMintAccess: feeMintAccessP, diff --git a/packages/vats/test/test-lib-board.js b/packages/vats/test/test-lib-board.js index e9ec6d264c31..70e90b159491 100644 --- a/packages/vats/test/test-lib-board.js +++ b/packages/vats/test/test-lib-board.js @@ -51,6 +51,7 @@ test('makeBoard', async t => { test('board values must be scalar keys', async t => { const board = makeFakeBoard(); const nonKey = harden({ a: 1 }); + // @ts-expect-error intentional error await t.throwsAsync(() => E(board).getId(nonKey), { message: /arg 0: A "copyRecord" cannot be a scalar key: {"a":1}/, }); diff --git a/packages/wallet/api/src/lib-wallet.js b/packages/wallet/api/src/lib-wallet.js index fd0947ea11a9..50793f3fc3ef 100644 --- a/packages/wallet/api/src/lib-wallet.js +++ b/packages/wallet/api/src/lib-wallet.js @@ -756,6 +756,7 @@ export function makeWalletRoot({ const addContact = async (petname, actions, address = undefined) => { // @ts-expect-error XXX ERef const already = await E(board).has(actions); + /** @type {any} */ let depositFacet; if (already) { depositFacet = actions; diff --git a/packages/zoe/src/contractSupport/priceAuthorityQuoteMint.js b/packages/zoe/src/contractSupport/priceAuthorityQuoteMint.js index f17718e5add2..de26f9bb0c3d 100644 --- a/packages/zoe/src/contractSupport/priceAuthorityQuoteMint.js +++ b/packages/zoe/src/contractSupport/priceAuthorityQuoteMint.js @@ -1,6 +1,11 @@ import { AssetKind, prepareIssuerKit } from '@agoric/ertp'; import { provideDurableMapStore } from '@agoric/vat-data'; +/** + * @import {EOnly} from '@endo/eventual-send'; + * @import {MutableQuote, PriceAuthority, PriceDescription, PriceQuote, PriceQuoteValue, PriceQuery,} from '@agoric/zoe/tools/types.js'; + */ + /** * * @param {import('@agoric/vat-data').Baggage} baggage diff --git a/packages/zoe/src/contractSupport/priceAuthorityTransform.js b/packages/zoe/src/contractSupport/priceAuthorityTransform.js index 69fe75368a8d..fbfd509c7078 100644 --- a/packages/zoe/src/contractSupport/priceAuthorityTransform.js +++ b/packages/zoe/src/contractSupport/priceAuthorityTransform.js @@ -6,7 +6,7 @@ import { makeNotifier } from '@agoric/notifier'; /** * @import {EOnly} from '@endo/eventual-send'; - * @import {MutableQuote, PriceAuthority, PriceQuote, PriceQuoteValue, PriceQuery,} from '@agoric/zoe/tools/types.js'; + * @import {MutableQuote, PriceAuthority, PriceQuote, PriceDescription,} from '@agoric/zoe/tools/types.js'; */ /** @@ -14,7 +14,7 @@ import { makeNotifier } from '@agoric/notifier'; * @param {Amount<'nat'>} amountIn * @param {Amount<'nat'>} amountOut * @param {import('@agoric/time').TimerService} timer - * @param {import('@agoric/time').Timestamp} timestamp + * @param {import('@agoric/time').TimestampRecord} timestamp * @param {ERef>} quoteMint * @returns {Promise} */ diff --git a/packages/zoe/src/zoeService/utils.d.ts b/packages/zoe/src/zoeService/utils.d.ts index 395b47714dde..f94b6762d98a 100644 --- a/packages/zoe/src/zoeService/utils.d.ts +++ b/packages/zoe/src/zoeService/utils.d.ts @@ -37,7 +37,7 @@ export type ContractStartFunction = ( baggage?: Baggage, ) => ERef<{ creatorFacet?: {}; publicFacet?: {} }>; -export type AdminFacet = { +export type AdminFacet = RemotableObject & { // Completion, which is currently any getVatShutdownPromise: () => Promise; upgradeContract: Parameters[1] extends undefined diff --git a/packages/zoe/tools/types.js b/packages/zoe/tools/types.js index 94c2d1d60df5..527b2d79676f 100644 --- a/packages/zoe/tools/types.js +++ b/packages/zoe/tools/types.js @@ -24,7 +24,7 @@ export {}; * The quoted result of trading `amountIn` * @property {import('@endo/pass-style').RemotableObject & import('@agoric/time').TimerService} timer * The service that gave the `timestamp` - * @property {import('@agoric/time').Timestamp} timestamp + * @property {import('@agoric/time').TimestampRecord} timestamp * A timestamp according to `timer` for the quote * @property {any} [conditions] * Additional conditions for the quote