diff --git a/packages/agoric-cli/src/commands/inter.js b/packages/agoric-cli/src/commands/inter.js index 74cd92cda85..5903a97d232 100644 --- a/packages/agoric-cli/src/commands/inter.js +++ b/packages/agoric-cli/src/commands/inter.js @@ -107,7 +107,7 @@ const makeFormatters = assets => { * Dynamic check that an OfferStatus is also a BidSpec. * * @param {import('@agoric/smart-wallet/src/offers.js').OfferStatus} offerStatus - * @param {Awaited>} agoricNames + * @param {import('../lib/wallet.js').AgoricNamesRemotes} agoricNames * @param {typeof console.warn} warn * returns null if offerStatus is not a BidSpec */ diff --git a/packages/agoric-cli/src/commands/test-upgrade.js b/packages/agoric-cli/src/commands/test-upgrade.js index 39e76fc8fee..f530b05dd12 100644 --- a/packages/agoric-cli/src/commands/test-upgrade.js +++ b/packages/agoric-cli/src/commands/test-upgrade.js @@ -82,7 +82,13 @@ export const makeTestCommand = ( publicInvitationMaker: 'makeInvitation', }, proposal: { - want: { Tokens: { brand: agoricNames.brand.GoodStuff, value: 32n } }, + want: { + Tokens: { + // @ts-expect-error BoardRemote not a Brand object + brand: agoricNames.brand.GoodStuff, + value: 32n, + }, + }, }, }; const result = await sendAction( diff --git a/packages/agoric-cli/src/lib/format.js b/packages/agoric-cli/src/lib/format.js index 9239c5842bc..7d24ea7c5ae 100644 --- a/packages/agoric-cli/src/lib/format.js +++ b/packages/agoric-cli/src/lib/format.js @@ -1,10 +1,8 @@ // @ts-check -import { makeBoardRemote } from '@agoric/vats/tools/board-utils.js'; -// eslint-disable-next-line no-unused-vars -- typeof below -import { makeAgoricNames } from './rpc.js'; // ambient types import '@agoric/ertp/src/types-ambient.js'; +import { makeBoardRemote } from '@agoric/vats/tools/board-utils.js'; /** @typedef {import('@agoric/vats/tools/board-utils.js').BoardRemote} BoardRemote */ @@ -30,16 +28,15 @@ export const Natural = str => { */ export const bigintReplacer = (k, v) => (typeof v === 'bigint' ? `${v}` : v); -/** @type {import('@agoric/vats/tools/board-utils.js').VBankAssetDetail} */ +/** @type {Partial} */ // eslint-disable-next-line no-unused-vars const exampleAsset = { - // @ts-expect-error cast brand: makeBoardRemote({ boardId: 'board0425', iface: 'Alleged: BLD brand' }), displayInfo: { assetKind: 'nat', decimalPlaces: 6 }, - // @ts-expect-error cast issuer: makeBoardRemote({ boardId: null, iface: undefined }), - petname: 'Agoric staking token', + proposedName: 'Agoric staking token', }; + /** @typedef {import('@agoric/vats/tools/board-utils.js').VBankAssetDetail } AssetDescriptor */ /** @@ -122,7 +119,7 @@ export const fmtRecordOfLines = record => { * Summarize the offerStatuses of the state as user-facing informative tuples * * @param {import('@agoric/smart-wallet/src/utils.js').CoalescedWalletState} state - * @param {Awaited>} agoricNames + * @param {import('./wallet.js').AgoricNamesRemotes} agoricNames */ export const offerStatusTuples = (state, agoricNames) => { const { offerStatuses } = state; @@ -179,7 +176,7 @@ export const offerStatusTuples = (state, agoricNames) => { /** * @param {import('@agoric/smart-wallet/src/smartWallet').CurrentWalletRecord} current * @param {ReturnType['state']} coalesced - * @param {Awaited>} agoricNames + * @param {import('./wallet.js').AgoricNamesRemotes} agoricNames */ export const summarize = (current, coalesced, agoricNames) => { return { diff --git a/packages/inter-protocol/src/clientSupport.js b/packages/inter-protocol/src/clientSupport.js index 26cf145f149..9ab281765d2 100644 --- a/packages/inter-protocol/src/clientSupport.js +++ b/packages/inter-protocol/src/clientSupport.js @@ -9,8 +9,6 @@ import { parseRatio } from '@agoric/zoe/src/contractSupport/ratio.js'; const COSMOS_UNIT = 1_000_000n; const scaleDecimals = num => BigInt(num * Number(COSMOS_UNIT)); -// TODO use '@satisfies" in TS 5.1 to make sure these each conform to OfferMaker interface - // NB: not really a Proposal because the brands are not remotes // Instead they're copyRecord like "{"boardId":"board0257","iface":"Alleged: IST brand"}" to pass through the boardId // mustMatch(harden(proposal), ProposalShape); @@ -143,11 +141,10 @@ export const lookupOfferIdForVault = async (vaultId, currentP) => { }; /** - * @param {Record} brands + * @param {Record} brands * @param {({ wantMinted: number, giveMinted?: undefined } | { giveMinted: number, wantMinted?: undefined })} opts - * @param {number} [fee=0] + * @param {number} [fee] * @param {string} [anchor] - * @returns {Proposal} XXX not a real proposal, uses BoardRemote */ const makePsmProposal = (brands, opts, fee = 0, anchor = 'AUSD') => { const giving = 'giveMinted' in opts ? 'minted' : 'anchor'; @@ -202,15 +199,13 @@ const makePsmSwapOffer = ({ brand }, instance, opts) => { instance, publicInvitationMaker: method, }, + // @ts-expect-error BoardRemote not a Brand object proposal, }; }; /** - * @param {{ - * brand: Record, - * vbankAsset: Record, - * }} agoricNames + * @param {Pick} agoricNames * @param {(msg: string) => Error} makeError error constructor * @returns {(a: string) => Amount<'nat'>} */ @@ -329,6 +324,7 @@ const makeAddCollateralOffer = ({ brand }, opts) => { /** @type {AmountKeywordRecord} */ const give = { Collateral: AmountMath.make( + // @ts-expect-error BoardRemote not a Brand object brand[opts.collateralBrandKey], scaleDecimals(opts.give), ), @@ -373,6 +369,9 @@ const makePushPriceOffer = (_agoricNames, opts, previousOffer) => { }; }; +/** + * @satisfies {Record>} + */ export const Offers = { auction: { Bid: makeBidOffer, diff --git a/packages/inter-protocol/test/test-clientSupport.js b/packages/inter-protocol/test/test-clientSupport.js index f330baf4f46..0e5678addea 100644 --- a/packages/inter-protocol/test/test-clientSupport.js +++ b/packages/inter-protocol/test/test-clientSupport.js @@ -8,19 +8,17 @@ import { withAmountUtils } from './supports.js'; const ist = withAmountUtils(makeIssuerKit('IST')); const atom = withAmountUtils(makeIssuerKit('ATOM')); -const brands = { - IST: ist.brand, - ATOM: atom.brand, -}; - -// XXX use @satisfies -/** @type {import('@agoric/vats/tools/board-utils.js').AgoricNamesRemotes} */ -const agoricNames = /** @type {any} */ ({ - brand: brands, +// uses actual Brand objects instead of BoardRemote to make the test output more legible +/** @satisfies {Partial} */ +const agoricNames = { + brand: { + IST: /** @type {any} */ (ist.brand), + ATOM: /** @type {any} */ (atom.brand), + }, vbankAsset: { uist: { denom: 'uist', - brand: ist.brand, + brand: /** @type {any} */ (ist.brand), displayInfo: { assetKind: 'nat', decimalPlaces: 6 }, issuer: /** @type {any} */ ({}), issuerName: 'IST', @@ -28,14 +26,14 @@ const agoricNames = /** @type {any} */ ({ }, 'ibc/toyatom': { denom: 'ibc/toyatom', - brand: atom.brand, + brand: /** @type {any} */ (atom.brand), displayInfo: { assetKind: 'nat', decimalPlaces: 6 }, issuer: /** @type {any} */ ({}), issuerName: 'ATOM', proposedName: 'ATOM', }, }, -}); +}; test('Offers.auction.Bid', async t => { const discounts = [ diff --git a/packages/vats/tools/board-utils.js b/packages/vats/tools/board-utils.js index 05c32a5e105..8c22af16f64 100644 --- a/packages/vats/tools/board-utils.js +++ b/packages/vats/tools/board-utils.js @@ -1,17 +1,17 @@ // @ts-check /** * @typedef {{ - * brand: import('@agoric/internal/src/marshal.js').BoardRemote & Brand, + * brand: import('@agoric/internal/src/marshal.js').BoardRemote, * denom: string, * displayInfo: DisplayInfo, - * issuer: import('@agoric/internal/src/marshal.js').BoardRemote & Issuer, + * issuer: import('@agoric/internal/src/marshal.js').BoardRemote, * issuerName: string, * proposedName: string, * }} VBankAssetDetail */ /** * @typedef {{ - * brand: Record, + * brand: Record, * instance: Record, * vbankAsset: Record, * reverse: Record,