diff --git a/packages/ERTP/src/issuerKit.js b/packages/ERTP/src/issuerKit.js index fa6b15d30441..65cce4993c5e 100644 --- a/packages/ERTP/src/issuerKit.js +++ b/packages/ERTP/src/issuerKit.js @@ -11,11 +11,6 @@ import { preparePaymentLedger } from './paymentLedger.js'; import './types-ambient.js'; -// TODO Why does TypeScript lose the `MapStore` typing of `Baggage` here, even -// though it knows the correct type at the exporting `@agoric/vat-data` -/** @typedef {import('@agoric/vat-data').Baggage} Baggage */ -/** @typedef {import('@agoric/zone').Zone} Zone */ - /** * @template {AssetKind} K * @typedef {object} IssuerRecord @@ -30,7 +25,7 @@ import './types-ambient.js'; * * @template {AssetKind} K * @param {IssuerRecord} issuerRecord - * @param {Zone} issuerZone + * @param {import('@agoric/zone').Zone} issuerZone * @param {ShutdownWithFailure} [optShutdownWithFailure] If this issuer fails in * the middle of an atomic action (which btw should never happen), it * potentially leaves its ledger in a corrupted state. If this function was @@ -88,7 +83,7 @@ const INSTANCE_KEY = 'issuer'; * make a new one. * * @template {AssetKind} K - * @param {Baggage} issuerBaggage + * @param {import('@agoric/vat-data').Baggage} issuerBaggage * @param {ShutdownWithFailure} [optShutdownWithFailure] If this issuer fails in * the middle of an atomic action (which btw should never happen), it * potentially leaves its ledger in a corrupted state. If this function was @@ -111,7 +106,7 @@ harden(upgradeIssuerKit); /** * Does baggage already have an issuerKit? * - * @param {Baggage} baggage + * @param {import('@agoric/vat-data').Baggage} baggage */ export const hasIssuer = baggage => baggage.has(INSTANCE_KEY); @@ -145,7 +140,7 @@ export const hasIssuer = baggage => baggage.has(INSTANCE_KEY); * basic fungible tokens. * * `displayInfo` gives information to the UI on how to display the amount. - * @param {Baggage} issuerBaggage + * @param {import('@agoric/vat-data').Baggage} issuerBaggage * @param {string} name * @param {K} [assetKind] * @param {AdditionalDisplayInfo} [displayInfo] @@ -191,7 +186,7 @@ harden(makeDurableIssuerKit); * basic fungible tokens. * * `displayInfo` gives information to the UI on how to display the amount. - * @param {Baggage} issuerBaggage + * @param {import('@agoric/vat-data').Baggage} issuerBaggage * @param {string} name * @param {K} [assetKind] * @param {AdditionalDisplayInfo} [displayInfo] diff --git a/packages/ERTP/src/mathHelpers/copyBagMathHelpers.js b/packages/ERTP/src/mathHelpers/copyBagMathHelpers.js index 20305c246100..10ae707124bd 100644 --- a/packages/ERTP/src/mathHelpers/copyBagMathHelpers.js +++ b/packages/ERTP/src/mathHelpers/copyBagMathHelpers.js @@ -12,10 +12,10 @@ import { } from '@agoric/store'; import '../types-ambient.js'; -/** @type {CopyBag} */ +/** @type {import('@endo/patterns').CopyBag} */ const empty = makeCopyBag([]); -/** @type {MathHelpers} */ +/** @type {MathHelpers} */ export const copyBagMathHelpers = harden({ doCoerce: bag => { mustMatch(bag, M.bag(), 'bag of amount'); diff --git a/packages/ERTP/src/payment.js b/packages/ERTP/src/payment.js index 499151966f82..2bc61cab4aab 100644 --- a/packages/ERTP/src/payment.js +++ b/packages/ERTP/src/payment.js @@ -2,19 +2,13 @@ import { initEmpty } from '@agoric/store'; -/** @typedef {import('@endo/patterns').MethodGuard} MethodGuard */ -/** - * @template {Record} [T=Record] - * @typedef {import('@endo/patterns').InterfaceGuard} InterfaceGuard - */ -/** @typedef {import('@agoric/zone').Zone} Zone */ - +// TODO Type InterfaceGuard better than InterfaceGuard /** * @template {AssetKind} K - * @param {Zone} issuerZone + * @param {import('@agoric/zone').Zone} issuerZone * @param {string} name * @param {Brand} brand - * @param {InterfaceGuard} PaymentI + * @param {import('@endo/patterns').InterfaceGuard} PaymentI * @returns {() => Payment} */ export const preparePaymentKind = (issuerZone, name, brand, PaymentI) => { diff --git a/packages/ERTP/src/paymentLedger.js b/packages/ERTP/src/paymentLedger.js index 4bb674124cf4..bfa57b74f53d 100644 --- a/packages/ERTP/src/paymentLedger.js +++ b/packages/ERTP/src/paymentLedger.js @@ -10,8 +10,6 @@ import { preparePurseKind } from './purse.js'; import '@agoric/store/exported.js'; import { BrandI, makeIssuerInterfaces } from './typeGuards.js'; -/** @typedef {import('@agoric/zone').Zone} Zone */ - const { details: X, quote: q, Fail } = assert; /** @@ -69,7 +67,7 @@ const amountShapeFromElementShape = (brand, assetKind, elementShape) => { * minting and transfer authority originates here. * * @template {AssetKind} K - * @param {Zone} issuerZone + * @param {import('@agoric/zone').Zone} issuerZone * @param {string} name * @param {K} assetKind * @param {DisplayInfo} displayInfo diff --git a/packages/ERTP/src/purse.js b/packages/ERTP/src/purse.js index acc7080acc97..e8cafa50fa56 100644 --- a/packages/ERTP/src/purse.js +++ b/packages/ERTP/src/purse.js @@ -3,20 +3,17 @@ import { AmountMath } from './amountMath.js'; import { makeTransientNotifierKit } from './transientNotifier.js'; import { makeAmountStore } from './amountStore.js'; -// TODO `InterfaceGuard` type parameter -/** @typedef {import('@endo/patterns').InterfaceGuard} InterfaceGuard */ -/** @typedef {import('@agoric/zone').Zone} Zone */ - const { Fail } = assert; +// TODO Type InterfaceGuard better than InterfaceGuard /** - * @param {Zone} issuerZone + * @param {import('@agoric/zone').Zone} issuerZone * @param {string} name * @param {AssetKind} assetKind * @param {Brand} brand * @param {{ - * purse: InterfaceGuard; - * depositFacet: InterfaceGuard; + * purse: import('@endo/patterns').InterfaceGuard; + * depositFacet: import('@endo/patterns').InterfaceGuard; * }} PurseIKit * @param {{ * depositInternal: any; diff --git a/packages/ERTP/src/types-ambient.js b/packages/ERTP/src/types-ambient.js index 0bdc50acee09..59c4388b7d06 100644 --- a/packages/ERTP/src/types-ambient.js +++ b/packages/ERTP/src/types-ambient.js @@ -2,11 +2,6 @@ /// -/** - * @template {Key} [K=Key] - * @typedef {import('@endo/patterns').CopyBag} CopyBag - */ - /** * @template {AssetKind} [K=AssetKind] * @typedef {object} Amount Amounts are descriptions of digital assets, @@ -22,8 +17,8 @@ */ /** - * @typedef {NatValue | SetValue | CopySet | CopyBag} AmountValue An - * `AmountValue` describes a set or quantity of assets that can be owned or + * @typedef {NatValue | SetValue | CopySet | import('@endo/patterns').CopyBag} AmountValue + * An `AmountValue` describes a set or quantity of assets that can be owned or * shared. * * A fungible `AmountValue` uses a non-negative bigint to represent a quantity @@ -58,7 +53,7 @@ * : K extends 'copySet' * ? CopySet * : K extends 'copyBag' - * ? CopyBag + * ? import('@endo/patterns').CopyBag * : never} AssetValueForKind */ @@ -70,7 +65,7 @@ * ? 'set' * : V extends CopySet * ? 'copySet' - * : V extends CopyBag + * : V extends import('@endo/patterns').CopyBag * ? 'copyBag' * : never} AssetKindForValue */ diff --git a/packages/ERTP/test/unitTests/mathHelpers/test-copyBagMathHelpers.js b/packages/ERTP/test/unitTests/mathHelpers/test-copyBagMathHelpers.js index 64e0ed9bd858..b3e7e6df9cfe 100644 --- a/packages/ERTP/test/unitTests/mathHelpers/test-copyBagMathHelpers.js +++ b/packages/ERTP/test/unitTests/mathHelpers/test-copyBagMathHelpers.js @@ -65,7 +65,7 @@ test('copyBag with strings getValue', t => { ); t.deepEqual( getCopyBagEntries( - /** @type {CopyBag} */ ( + /** @type {import('@endo/patterns').CopyBag} */ ( m.getValue( mockBrand, harden({ brand: mockBrand, value: makeBag(['1']) }),