diff --git a/packages/agoric-cli/src/commands/inter.js b/packages/agoric-cli/src/commands/inter.js index 34c3e398c78..e59c7aa264c 100644 --- a/packages/agoric-cli/src/commands/inter.js +++ b/packages/agoric-cli/src/commands/inter.js @@ -10,6 +10,12 @@ import { makeOfferSpecShape } from '@agoric/inter-protocol/src/auction/auctionBo import { Offers } from '@agoric/inter-protocol/src/clientSupport.js'; import { objectMap } from '@agoric/internal'; import { M, matches } from '@agoric/store'; + +// XXX scare away ambient type zombies to fix ScheduleNotification.activeStartTime etc. +// https://github.com/Agoric/agoric-sdk/issues/6512 +// https://github.com/Agoric/agoric-sdk/issues/6343 +import '@agoric/inter-protocol/src/vaultFactory/types.js'; + import { normalizeAddressWithOptions, pollBlocks } from '../lib/chain.js'; import { asBoardRemote, @@ -64,8 +70,12 @@ const makeFormatters = assets => { const discount = r => r4(100 - (Number(r.numerator.value) / Number(r.denominator.value)) * 100); - /** @param {import('@agoric/time/src/types.js').TimestampRecord} tr */ - const absTime = tr => new Date(Number(tr.absValue) * 1000).toISOString(); + // XXX real TimeMath.absValue requires real Remotable timerBrand + /** @param {import('@agoric/time/src/types.js').Timestamp} ts */ + const absValue = ts => (typeof ts === 'bigint' ? ts : ts.absValue); + + /** @param {import('@agoric/time/src/types.js').Timestamp} tr */ + const absTime = tr => new Date(Number(absValue(tr)) * 1000).toISOString(); /** @param {import('@agoric/time/src/types.js').RelativeTimeRecord} tr */ const relTime = tr => new Date(Number(tr.relValue) * 1000).toISOString().slice(11, 19); @@ -290,8 +300,8 @@ inter auction status const info = { schedule: { activeStartTime: fmt.absTimeOpt(schedule.activeStartTime), - nextStartTime: fmt.absTime(schedule.nextStartTime), - nextDescendingStepTime: fmt.absTime( + nextStartTime: fmt.absTimeOpt(schedule.nextStartTime), + nextDescendingStepTime: fmt.absTimeOpt( schedule.nextDescendingStepTime, ), }, diff --git a/packages/agoric-cli/test/test-inter-cli.js b/packages/agoric-cli/test/test-inter-cli.js index a6afc8db66c..18af8a9c98c 100644 --- a/packages/agoric-cli/test/test-inter-cli.js +++ b/packages/agoric-cli/test/test-inter-cli.js @@ -445,84 +445,108 @@ test('README: inter auction status', async t => { const { brand } = agoricNames; const timerBrand = brand.timer; - const net = makeNet({ - ...publishedNames, - auction: { - schedule: { - _: { - activeStartTime: undefined, - nextDescendingStepTime: { absValue: 1681875302n, timerBrand }, - nextStartTime: { absValue: 1681875302n, timerBrand }, + const auctionInfo = { + schedule: { + _: { + activeStartTime: undefined, + nextDescendingStepTime: { absValue: 1681875302n, timerBrand }, + nextStartTime: { absValue: 1681875302n, timerBrand }, + }, + }, + book0: { + _: { + collateralAvailable: { brand: brand.ATOM, value: 0n }, + currentPriceLevel: { + denominator: { brand: brand.ATOM, value: 10000000000n }, + numerator: { brand: brand.IST, value: 44955000000n }, }, + proceedsRaised: undefined, + remainingProceedsGoal: null, + startCollateral: { brand: brand.ATOM, value: 0n }, + startPrice: { + denominator: { brand: brand.ATOM, value: 1000000n }, + numerator: { brand: brand.IST, value: 9990000n }, + }, + startProceedsGoal: null, }, - book0: { - _: { - collateralAvailable: { brand: brand.ATOM, value: 0n }, - currentPriceLevel: { - denominator: { brand: brand.ATOM, value: 10000000000n }, - numerator: { brand: brand.IST, value: 44955000000n }, + }, + governance: { + _: { + current: { + AuctionStartDelay: { + type: 'relativeTime', + value: { relValue: 2n, timerBrand }, }, - proceedsRaised: undefined, - remainingProceedsGoal: null, - startCollateral: { brand: brand.ATOM, value: 0n }, - startPrice: { - denominator: { brand: brand.ATOM, value: 1000000n }, - numerator: { brand: brand.IST, value: 9990000n }, + ClockStep: { + type: 'relativeTime', + value: { relValue: 10n, timerBrand }, }, - startProceedsGoal: null, - }, - }, - governance: { - _: { - current: { - AuctionStartDelay: { - type: 'relativeTime', - value: { relValue: 2n, timerBrand }, - }, - ClockStep: { - type: 'relativeTime', - value: { relValue: 10n, timerBrand }, - }, - DiscountStep: { type: 'nat', value: 500n }, - Electorate: { - type: 'invitation', - value: { - brand: brand.Invitation, - value: [ - { - description: 'questionPoser', - handle: {}, - installation: {}, - instance: {}, - }, - ], - }, - }, - LowestRate: { - type: 'nat', - value: 4500n, - }, - PriceLockPeriod: { - type: 'relativeTime', - value: { relValue: 60n, timerBrand }, - }, - StartFrequency: { - type: 'relativeTime', - value: { relValue: 300n, timerBrand }, - }, - StartingRate: { - type: 'nat', - value: 10500n, + DiscountStep: { type: 'nat', value: 500n }, + Electorate: { + type: 'invitation', + value: { + brand: brand.Invitation, + value: [ + { + description: 'questionPoser', + handle: {}, + installation: {}, + instance: {}, + }, + ], }, }, + LowestRate: { + type: 'nat', + value: 4500n, + }, + PriceLockPeriod: { + type: 'relativeTime', + value: { relValue: 60n, timerBrand }, + }, + StartFrequency: { + type: 'relativeTime', + value: { relValue: 300n, timerBrand }, + }, + StartingRate: { + type: 'nat', + value: 10500n, + }, }, }, }, + }; + const net = makeNet({ + ...publishedNames, + auction: auctionInfo, }); const cmd = await makeInterCommand(makeProcess(t, testKeyring, out), net); await cmd.parseAsync(argv); t.deepEqual(JSON.parse(out.join('')), expected); + + // schedule fields can be null + const auctionInfo2 = { + ...auctionInfo, + schedule: { + _: { + activeStartTime: null, + nextDescendingStepTime: null, + nextStartTime: 1681875302n, + }, + }, + }; + + const { nextDescendingStepTime: _, ...schedule2 } = expected.schedule; + const net2 = makeNet({ + ...publishedNames, + auction: auctionInfo2, + }); + + out.splice(0); + const cmd2 = await makeInterCommand(makeProcess(t, testKeyring, out), net2); + await cmd2.parseAsync(argv); + t.deepEqual(JSON.parse(out.join('')), { ...expected, schedule: schedule2 }); }); test('README: inter vbank list', async t => {