Skip to content

Commit

Permalink
fix: update types/dependencies for new @agoric/time
Browse files Browse the repository at this point in the history
This updates a lot of downstream packages to get their Time-related
types from the right place, and adds package.json dependencies so they
can import those types.
  • Loading branch information
warner committed Jan 31, 2023
1 parent c522016 commit 5cb6fff
Show file tree
Hide file tree
Showing 46 changed files with 103 additions and 72 deletions.
1 change: 1 addition & 0 deletions packages/governance/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
"@agoric/notifier": "^0.5.1",
"@agoric/store": "^0.8.3",
"@agoric/swingset-vat": "^0.30.2",
"@agoric/time": "^0.2.1",
"@agoric/vat-data": "^0.4.3",
"@agoric/vats": "^0.13.0",
"@agoric/zoe": "^0.25.3",
Expand Down
2 changes: 1 addition & 1 deletion packages/governance/src/contractGovernance/governApi.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ const makeApiInvocationPositions = (apiMethodName, methodArgs) => {
* @param {Instance} governedInstance
* @param {ERef<{ [methodName: string]: (...args: any) => unknown }>} governedApis
* @param {Array<string | symbol>} governedNames names of the governed API methods
* @param {ERef<TimerService>} timer
* @param {ERef<import('@agoric/time/src/types').TimerService>} timer
* @param {() => Promise<PoserFacet>} getUpdatedPoserFacet
* @returns {Promise<ApiGovernor>}
*/
Expand Down
2 changes: 1 addition & 1 deletion packages/governance/src/contractGovernance/governFilter.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ const makeOfferFilterPositions = strings => {
*
* @param {ERef<ZoeService>} zoe
* @param {Instance} governedInstance
* @param {ERef<TimerService>} timer
* @param {ERef<import('@agoric/time/src/types').TimerService>} timer
* @param {() => Promise<PoserFacet>} getUpdatedPoserFacet
* @param {GovernorFacet<{}>} governorFacet
* @returns {Promise<FilterGovernor>}
Expand Down
6 changes: 3 additions & 3 deletions packages/governance/src/contractGovernor.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ const validateQuestionFromCounter = async (zoe, electorate, voteCounter) => {

/**
* @typedef {StandardTerms} ContractGovernorTerms
* @property {TimerService} timer
* @property {import('@agoric/time/src/types').TimerService} timer
* @property {Installation} governedContractInstallation
*/

Expand Down Expand Up @@ -111,7 +111,7 @@ const validateQuestionFromCounter = async (zoe, electorate, voteCounter) => {
* GovernorPublic,
* GovernedContractFacetAccess<PF,CF>,
* {
* timer: TimerService,
* timer: import('@agoric/time/src/types').TimerService,
* governedContractInstallation: Installation<CF>,
* governed: {
* issuerKeywordRecord: IssuerKeywordRecord,
Expand All @@ -123,7 +123,7 @@ const validateQuestionFromCounter = async (zoe, electorate, voteCounter) => {
/**
* @template {() => {creatorFacet: GovernorFacet<any>, publicFacet: GovernedPublicFacetMethods} } SF Start function of governed contract
* @param {ZCF<{
* timer: TimerService,
* timer: import('@agoric/time/src/types').TimerService,
* governedContractInstallation: Installation<SF>,
* governed: {
* issuerKeywordRecord: IssuerKeywordRecord,
Expand Down
2 changes: 1 addition & 1 deletion packages/governance/src/electorateTools.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { deeplyFulfilled, Far } from '@endo/marshal';
* @typedef {object} QuestionRecord
* @property {ERef<VoteCounterCreatorFacet>} voteCap
* @property {VoteCounterPublicFacet} publicFacet
* @property {Timestamp} deadline
* @property {import('@agoric/time/src/types').Timestamp} deadline
*/

/**
Expand Down
14 changes: 7 additions & 7 deletions packages/governance/src/types-ambient.js
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,7 @@
/**
* @typedef {object} ClosingRule
* @property {ERef<Timer>} timer
* @property {Timestamp} deadline
* @property {import('@agoric/time/src/types').Timestamp} deadline
*/

/**
Expand All @@ -343,7 +343,7 @@
* @property {VoteCounterPublicFacet} publicFacet
* @property {VoteCounterCreatorFacet} creatorFacet
* @property {import('@agoric/zoe/src/zoeService/utils.js').Instance<typeof import('./binaryVoteCounter.js').start>} instance
* @property {Timestamp} deadline
* @property {import('@agoric/time/src/types').Timestamp} deadline
* @property {Handle<'Question'>} questionHandle
*/

Expand Down Expand Up @@ -640,7 +640,7 @@
*
* @callback VoteOnParamChanges
* @param {Installation} voteCounterInstallation
* @param {Timestamp} deadline
* @param {import('@agoric/time/src/types').Timestamp} deadline
* @param {ParamChangesSpec<P>} paramSpec
* @returns {ContractGovernanceVoteResult}
*/
Expand All @@ -650,14 +650,14 @@
* @param {string} apiMethodName
* @param {unknown[]} methodArgs
* @param {Installation} voteCounterInstallation
* @param {Timestamp} deadline
* @param {import('@agoric/time/src/types').Timestamp} deadline
* @returns {ContractGovernanceVoteResult}
*/

/**
* @callback VoteOnOfferFilter
* @param {Installation} voteCounterInstallation
* @param {Timestamp} deadline
* @param {import('@agoric/time/src/types').Timestamp} deadline
* @param {string[]} strings
* @returns {ContractGovernanceVoteResult}
*/
Expand Down Expand Up @@ -685,7 +685,7 @@
* @param {ERef<ZoeService>} zoe
* @param {ERef<ParamManagerRetriever>} paramManagerRetriever
* @param {Instance} contractInstance
* @param {TimerService} timer
* @param {import('@agoric/time/src/types').TimerService} timer
* @param {() => Promise<PoserFacet>} getUpdatedPoserFacet
* @returns {ParamGovernor}
*/
Expand All @@ -706,7 +706,7 @@

/**
* @typedef {object} GovernedContractTerms
* @property {TimerService} timer
* @property {import('@agoric/time/src/types').TimerService} timer
* @property {IssuerKeywordRecord} issuerKeywordRecord
* @property {object} privateArgs
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ const makeVoterVat = async (log, vats, zoe) => {
/**
*
* @param {Pick<QuestionDetails, 'issue' | 'positions' | 'electionType'>} qDetails
* @param {TimestampValue} closingTime
* @param {{ electorateFacet: import('../../../src/committee.js').CommitteeElectorateCreatorFacet, installations: Record<string, Installation>, timer: TimerService }} tools
* @param {import('@agoric/time/src/types').Timestamp} closingTime
* @param {{ electorateFacet: import('../../../src/committee.js').CommitteeElectorateCreatorFacet, installations: Record<string, Installation>, timer: import('@agoric/time/src/types').TimerService }} tools
* @param {*} quorumRule
*/
const createQuestion = async (qDetails, closingTime, tools, quorumRule) => {
Expand Down
2 changes: 1 addition & 1 deletion packages/governance/tools/puppetContractGovernor.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import { CONTRACT_ELECTORATE } from '../src/contractGovernance/governParam.js';
/**
* @template {() => {creatorFacet: GovernorFacet<any>, publicFacet: GovernedPublicFacetMethods} } SF Start function of governed contract
* @param {ZCF<{
* timer: TimerService,
* timer: import('@agoric/time/src/types').TimerService,
* governedContractInstallation: Installation<SF>,
* governed: {
* issuerKeywordRecord: IssuerKeywordRecord,
Expand Down
5 changes: 5 additions & 0 deletions packages/inter-protocol/src/feeDistributor.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@ import { makeScalarSetStore } from '@agoric/store';

const { details: X } = assert;

/**
* @typedef {import('@agoric/time/src/types').RelativeTime} RelativeTime
* @typedef {import('@agoric/time/src/types').TimerService} TimerService
*/

/**
* @typedef {object} FeeCollector
*
Expand Down
5 changes: 5 additions & 0 deletions packages/inter-protocol/src/interest.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@ import {
import { Fail } from '@agoric/assert';
import { TimeMath } from '@agoric/time';

/**
* @typedef {import('@agoric/time/src/types').Timestamp} Timestamp
* @typedef {import('@agoric/time/src/types').RelativeTime} RelativeTime
*/

export const SECONDS_PER_YEAR = 60n * 60n * 24n * 365n;
const BASIS_POINTS = 10000;
// single digit APR is less than a basis point per day.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,14 @@ import { makeRoundsManagerKit } from './roundsManager.js';

export const INVITATION_MAKERS_DESC = 'oracle invitation';

/** @typedef {import('@agoric/vat-data').Baggage} Baggage */
/**
* @typedef {import('@agoric/vat-data').Baggage} Baggage
* @typedef {import('@agoric/time/src/types').Timestamp} Timestamp
* @typedef {import('@agoric/time/src/types').RelativeTime} RelativeTime
* // TODO: use RelativeTime, not RelativeTimeValue
* @typedef {import('@agoric/time/src/types').RelativeTimeValue} RelativeTimeValue
* @typedef {import('@agoric/time/src/types').TimerService} TimerService
*/

/** @type {(quote: PriceQuote) => PriceDescription} */
const priceDescriptionFromQuote = quote => quote.quoteAmount.value[0];
Expand Down
4 changes: 4 additions & 0 deletions packages/inter-protocol/src/price/roundsManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ import { UnguardedHelperI } from '../typeGuards.js';
const { add, subtract, multiply, floorDivide, ceilDivide, isGTE } = natSafeMath;

/** @typedef {import('./priceOracleAdmin.js').OracleStatus} OracleStatus */
/**
* @typedef {import('@agoric/time/src/types').Timestamp} Timestamp
* @typedef {import('@agoric/time/src/types').TimerService} TimerService
*/

/** @type {string} */
const V3_NO_DATA_ERROR = 'No data present';
Expand Down
2 changes: 1 addition & 1 deletion packages/inter-protocol/src/proposals/demoIssuers.js
Original file line number Diff line number Diff line change
Expand Up @@ -511,7 +511,7 @@ export const fundAMM = async ({
kits[Stable.symbol]
);

/** @type {[ XYKAMMPublicFacet, TimerService]} */
/** @type {[ XYKAMMPublicFacet, import('@agoric/time/src/types').TimerService]} */
const [ammPublicFacet, timer] = await Promise.all([
E(zoe).getPublicFacet(ammInstance),
chainTimerService,
Expand Down
2 changes: 1 addition & 1 deletion packages/inter-protocol/src/stakeFactory/stakeFactory.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ const { values } = Object;
* charge interest according to `chargingPeriod` and `recordingPeriod`.
*
* @typedef { GovernanceTerms<StakeFactoryParams> & {
* timerService: TimerService,
* timerService: import('@agoric/time/src/types').TimerService,
* chargingPeriod: bigint,
* recordingPeriod: bigint,
* lienAttestationName?: string,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@ import { ManagerKW as KW } from './constants.js';
const { details: X } = assert;

const trace = makeTracer('RSM', false);
/**
* @typedef {import('@agoric/time/src/types').Timestamp} Timestamp
* @typedef {import('@agoric/time/src/types').RelativeTime} RelativeTime
* @typedef {import('@agoric/time/src/types').TimerService} TimerService
*/

/**
* @typedef {{
Expand Down
1 change: 1 addition & 0 deletions packages/inter-protocol/src/stakeFactory/types.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
*/

/**
* @typedef {import('@agoric/time/src/types').Timestamp} Timestamp
* @typedef {{getTime: () => Timestamp, updateTime: (currentTime:
* Timestamp) => void}} StoredTime
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ const trace = makeTracer('LiqI', false);
* amm: XYKAMMPublicFacet,
* priceAuthority: PriceAuthority,
* reservePublicFacet: AssetReservePublicFacet,
* timerService: TimerService,
* timerService: import('@agoric/time/src/types').TimerService,
* debtBrand: Brand<'nat'>,
* MaxImpactBP: NatValue,
* OracleTolerance: Ratio,
Expand Down
2 changes: 1 addition & 1 deletion packages/inter-protocol/src/vaultFactory/params.js
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ harden(makeVaultDirectorParamManager);
* minInitialDebt: Amount,
* bootstrapPaymentValue: bigint,
* priceAuthority: ERef<PriceAuthority>,
* timer: ERef<TimerService>,
* timer: ERef<import('@agoric/time/src/types').TimerService>,
* reservePublicFacet: AssetReservePublicFacet,
* liquidationInstall: Installation,
* loanTiming: LoanTiming,
Expand Down
2 changes: 2 additions & 0 deletions packages/inter-protocol/src/vaultFactory/types.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
* @typedef {import('../reserve/assetReserve.js').AssetReserveLimitedCreatorFacet} AssetReserveCreatorFacet
* @typedef {import('../reserve/assetReserve.js').AssetReservePublicFacet} AssetReservePublicFacet
* @typedef {import('./vaultFactory.js').VaultFactoryContract['publicFacet']} VaultFactoryPublicFacet
*
* @typedef {import('@agoric/time/src/types').RelativeTime} RelativeTime
*/

/**
Expand Down
2 changes: 1 addition & 1 deletion packages/inter-protocol/src/vaultFactory/vaultFactory.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ import { prepareVaultDirector } from './vaultDirector.js';
* minInitialDebt: Amount,
* priceAuthority: ERef<PriceAuthority>,
* reservePublicFacet: AssetReservePublicFacet,
* timerService: TimerService,
* timerService: import('@agoric/time/src/types').TimerService,
* shortfallInvitation: 'invitation',
* }>} VaultFactoryZCF
*/
Expand Down
1 change: 1 addition & 0 deletions packages/inter-protocol/src/vaultFactory/vaultManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ const { details: X } = assert;
const trace = makeTracer('VM', false);

/** @typedef {import('./storeUtils.js').NormalizedDebt} NormalizedDebt */
/** @typedef {import('@agoric/time/src/types').RelativeTime} RelativeTime */

// Metrics naming scheme: nouns are present values; past-participles are accumulative.
/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,15 +47,15 @@ const trace = makeTracer('XykAmm', false);

/** @typedef {GovernanceTerms< {MinInitialPoolLiquidity: 'amount'} & {ProtocolFee: 'amount'} & {PoolFee: 'amount'}>} AmmGovernanceParams */

/** @typedef {{brands:BrandKeywordRecord,timer:TimerService}} AmmTerms */
/** @typedef {{brands:BrandKeywordRecord,timer:import('@agoric/time/src/types').TimerService}} AmmTerms */

/**
* @typedef {Readonly<{
* zcf: ZCF<AmmTerms>,
* secondaryBrandToPool: WeakMapStore<Brand,PoolFacets>,
* secondaryBrandToLiquidityMint: WeakMapStore<Brand,ZCFMint<'nat'>>,
* centralBrand: Brand<'nat'>,
* timer: TimerService,
* timer: import('@agoric/time/src/types').TimerService,
* quoteIssuerKit: IssuerKit<'set'>,
* params: import('@agoric/governance/src/contractGovernance/typedParamManager').Getters<import('./params.js').AmmParams>,
* protocolSeat: ZCFSeat,
Expand Down Expand Up @@ -509,7 +509,7 @@ export { start };
* }> & {
* brands: { Central: Brand },
* issuers: {},
* timer: TimerService,
* timer: import('@agoric/time/src/types').TimerService,
* poolFeeBP: BasisPoints, // portion of the fees that go into the pool
* protocolFeeBP: BasisPoints, // portion of the fees that are shared with validators
* }} AMMTerms
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import { makeOnewayPriceAuthorityKit } from '@agoric/zoe/src/contractSupport/ind
* @param {*} getInputForWantedOutput
* @param {Brand<'nat'>} actualBrandIn
* @param {Brand<'nat'>} actualBrandOut
* @param {TimerService} timer
* @param {import('@agoric/time/src/types').TimerService} timer
* @param {Subscriber<import('./pool').NotificationState>} subscriber
* @param {IssuerKit<'set'>} quoteIssuerKit
* @returns {PriceAuthority}
Expand Down
2 changes: 1 addition & 1 deletion packages/inter-protocol/test/amm/vpool-xyk-amm/setup.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ harden(setUpZoeForTest);

/**
*
* @param {TimerService} timer
* @param {import('@agoric/time/src/types').TimerService} timer
* @param {ERef<FarZoeKit>} [farZoeKit]
*/
export const setupAMMBootstrap = async (
Expand Down
2 changes: 1 addition & 1 deletion packages/inter-protocol/test/psm/setupPsm.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ harden(setUpZoeForTest);
*/

/**
* @param {TimerService} timer
* @param {import('@agoric/time/src/types').TimerService} timer
* @param {FarZoeKit} [farZoeKit]
*/
export const setupPsmBootstrap = async (
Expand Down
2 changes: 1 addition & 1 deletion packages/inter-protocol/test/supports.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ harden(setUpZoeForTest);
/**
*
* @param {*} t
* @param {TimerService} [optTimer]
* @param {import('@agoric/time/src/types').TimerService} [optTimer]
*/
export const setupBootstrap = (t, optTimer) => {
const trace = makeTracer('PromiseSpace', false);
Expand Down
4 changes: 2 additions & 2 deletions packages/inter-protocol/test/vaultFactory/driver.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ const defaultParamValues = debt =>
* rates: any,
* run: IssuerKit & import('../supports.js').AmountUtils,
* runInitialLiquidity: Amount<'nat'>,
* timer: TimerService,
* timer: import('@agoric/time/src/types').TimerService,
* zoe: ZoeService,
* }} DriverContext
*/
Expand Down Expand Up @@ -252,7 +252,7 @@ const getRunFromFaucet = async (t, runInitialLiquidity) => {
* @param {import('ava').ExecutionContext<DriverContext>} t
* @param {Amount} initialPrice
* @param {Amount} priceBase
* @param {TimerService} timer
* @param {import('@agoric/time/src/types').TimerService} timer
*/
const setupServices = async (
t,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ const legacyOfferResult = vaultSeat => {
* @param {import('ava').ExecutionContext<Context>} t
* @param {Array<NatValue> | Ratio} priceOrList
* @param {Amount | undefined} unitAmountIn
* @param {TimerService} timer
* @param {import('@agoric/time/src/types').TimerService} timer
* @param {RelativeTime} quoteInterval
* @param {bigint} runInitialLiquidity
*/
Expand Down
1 change: 1 addition & 0 deletions packages/vats/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
"@agoric/sharing-service": "^0.2.6",
"@agoric/store": "^0.8.3",
"@agoric/swingset-vat": "^0.30.2",
"@agoric/time": "^0.2.1",
"@agoric/zoe": "^0.25.3",
"@endo/far": "^0.2.14",
"@endo/import-bundle": "^0.3.0",
Expand Down
5 changes: 1 addition & 4 deletions packages/vats/src/core/startWalletFactory.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,6 @@ import { CONTRACT_ELECTORATE, ParamTypes } from '@agoric/governance';
import { makeStorageNodeChild } from '@agoric/internal/src/lib-chainStorage.js';
import { Stable } from '../tokens.js';

// Ambient types (globals)
import '@agoric/swingset-vat/src/vats/timer/types.js';

/**
* @param {ERef<ZoeService>} zoe
* @param {Installation<import('@agoric/smart-wallet/src/walletFactory').start>} inst
Expand All @@ -31,7 +28,7 @@ const StableUnit = BigInt(10 ** Stable.displayInfo.decimalPlaces);
* }} zoeArgs
* @param {{
* governedParams: Record<string, unknown>,
* timer: ERef<TimerService>,
* timer: ERef<import('@agoric/time/src/types').TimerService>,
* contractGovernor: ERef<Installation>,
* economicCommitteeCreatorFacet: import('@agoric/inter-protocol/src/proposals/econ-behaviors.js').EconomyBootstrapPowers['consume']['economicCommitteeCreatorFacet']
* }} govArgs
Expand Down
Loading

0 comments on commit 5cb6fff

Please sign in to comment.