Skip to content

Commit

Permalink
chore(types): explicit ERTP type imports (#10823)
Browse files Browse the repository at this point in the history
_incidental_

## Description
While working on Agoric/agoric-subql#46 I ran into type errors because some types in Fast USDC relies on ambients that weren't loaded in this usage.

This makes the imports explicit so they resolve when the package is used outside agoric-sdk.

### Security Considerations
n/a

### Scaling Considerations
n/a
### Documentation Considerations
n/a
### Testing Considerations
CI
### Upgrade Considerations
No compat concerns
  • Loading branch information
mergify[bot] authored Jan 9, 2025
2 parents 0e4c5b5 + bfdb3e0 commit b5d1abe
Show file tree
Hide file tree
Showing 16 changed files with 29 additions and 9 deletions.
1 change: 1 addition & 0 deletions packages/fast-usdc/src/cli/lp-commands.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/* eslint-env node */
/**
* @import {Command} from 'commander';
* @import {Amount, Brand} from '@agoric/ertp';
* @import {OfferSpec} from '@agoric/smart-wallet/src/offers.js';
* @import {ExecuteOfferAction} from '@agoric/smart-wallet/src/smartWallet.js';
* @import {USDCProposalShapes} from '../pool-share-math.js';
Expand Down
1 change: 1 addition & 0 deletions packages/fast-usdc/src/exos/advancer.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import { makeFeeTools } from '../utils/fees.js';

/**
* @import {HostInterface} from '@agoric/async-flow';
* @import {Amount, Brand} from '@agoric/ertp';
* @import {TypedPattern} from '@agoric/internal'
* @import {NatAmount} from '@agoric/ertp';
* @import {ChainAddress, ChainHub, Denom, OrchestrationAccount} from '@agoric/orchestration';
Expand Down
1 change: 1 addition & 0 deletions packages/fast-usdc/src/exos/liquidity-pool.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import {
} from '../type-guards.js';

/**
* @import {Amount, Brand, Payment} from '@agoric/ertp';
* @import {Zone} from '@agoric/zone';
* @import {Remote} from '@agoric/internal'
* @import {StorageNode} from '@agoric/internal/src/lib-chainStorage.js'
Expand Down
1 change: 1 addition & 0 deletions packages/fast-usdc/src/exos/settler.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import {

/**
* @import {FungibleTokenPacketData} from '@agoric/cosmic-proto/ibc/applications/transfer/v2/packet.js';
* @import {Amount, Brand, NatValue, Payment} from '@agoric/ertp';
* @import {Denom, OrchestrationAccount, ChainHub, ChainAddress} from '@agoric/orchestration';
* @import {WithdrawToSeat} from '@agoric/orchestration/src/utils/zoe-tools'
* @import {IBCChannelID, VTransferIBCEvent} from '@agoric/vats';
Expand Down
1 change: 1 addition & 0 deletions packages/fast-usdc/src/fast-usdc-policy.core.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { fromExternalConfig } from './utils/config-marshal.js';
import { FeedPolicyShape } from './type-guards.js';

/**
* @import {Issuer} from '@agoric/ertp';
* @import {Passable} from '@endo/pass-style'
* @import {BootstrapManifest} from '@agoric/vats/src/core/lib-boot.js'
* @import {LegibleCapData} from './utils/config-marshal.js'
Expand Down
2 changes: 1 addition & 1 deletion packages/fast-usdc/src/fast-usdc.start.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import {
import { fromExternalConfig } from './utils/config-marshal.js';

/**
* @import {DepositFacet} from '@agoric/ertp/src/types.js'
* @import {Amount, Brand, DepositFacet, Issuer, Payment} from '@agoric/ertp';
* @import {TypedPattern} from '@agoric/internal'
* @import {Instance, StartParams} from '@agoric/zoe/src/zoeService/utils'
* @import {Board} from '@agoric/vats'
Expand Down
1 change: 1 addition & 0 deletions packages/fast-usdc/src/pool-share-math.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { Fail, q } from '@endo/errors';
const { getValue, add, isEmpty, isEqual, isGTE, subtract } = AmountMath;

/**
* @import {Amount, Brand, DepositFacet, NatValue, Payment} from '@agoric/ertp';
* @import {PoolStats} from './types';
* @import {RepayAmountKWR} from './exos/liquidity-pool';
*/
Expand Down
1 change: 1 addition & 0 deletions packages/fast-usdc/src/type-guards.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { M } from '@endo/patterns';
import { PendingTxStatus } from './constants.js';

/**
* @import {Amount, Brand, NatValue, Payment} from '@agoric/ertp';
* @import {TypedPattern} from '@agoric/internal';
* @import {FastUsdcTerms} from './fast-usdc.contract.js';
* @import {USDCProposalShapes} from './pool-share-math.js';
Expand Down
4 changes: 3 additions & 1 deletion packages/fast-usdc/test/config-marshal.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ import {
toLegible,
} from '../src/utils/config-marshal.js';

/** @import {SmallCapsStructureOf} from '../src/utils/config-marshal.js' */
/**
* @import {Amount, Brand, DepositFacet, NatValue, Payment} from '@agoric/ertp';
*/

const testMatches = (t, specimen, pattern) => {
t.notThrows(() => mustMatch(specimen, pattern));
Expand Down
1 change: 1 addition & 0 deletions packages/fast-usdc/test/fast-usdc.contract.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import { E } from '@endo/far';
import { matches } from '@endo/patterns';
import { makePromiseKit } from '@endo/promise-kit';
import path from 'path';
import type { Amount, Issuer, NatValue, Purse } from '@agoric/ertp';
import type { OperatorKit } from '../src/exos/operator-kit.js';
import type { FastUsdcSF } from '../src/fast-usdc.contract.js';
import { CctpTxEvidenceShape, PoolMetricsShape } from '../src/type-guards.js';
Expand Down
8 changes: 3 additions & 5 deletions packages/fast-usdc/test/mocks.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
import type { HostInterface } from '@agoric/async-flow';
import type { Brand, Issuer, Payment } from '@agoric/ertp';
import type {
ChainAddress,
DenomAmount,
OrchestrationAccount,
} from '@agoric/orchestration';
import type { Zone } from '@agoric/zone';
import type { VowTools } from '@agoric/vow';
import { makeRatio } from '@agoric/zoe/src/contractSupport/ratio.js';
import type {
AmountUtils,
withAmountUtils,
} from '@agoric/zoe/tools/test-utils.js';
import type { AmountUtils } from '@agoric/zoe/tools/test-utils.js';
import type { Zone } from '@agoric/zone';
import type { FeeConfig, LogFn } from '../src/types.js';

export const prepareMockOrchAccounts = (
Expand Down
2 changes: 1 addition & 1 deletion packages/fast-usdc/test/pool-share-math.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { test } from '@agoric/zoe/tools/prepare-test-env-ava.js';
import { testProp, fc } from '@fast-check/ava';
import { AmountMath, makeIssuerKit } from '@agoric/ertp';
import { AmountMath, makeIssuerKit, type Amount } from '@agoric/ertp';
import {
multiplyBy,
parseRatio,
Expand Down
2 changes: 1 addition & 1 deletion packages/fast-usdc/test/utils/fees.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { test } from '@agoric/zoe/tools/prepare-test-env-ava.js';
import { makeIssuerKit, AmountMath } from '@agoric/ertp';
import { makeIssuerKit, AmountMath, type Amount } from '@agoric/ertp';
import { makeRatioFromAmounts } from '@agoric/zoe/src/contractSupport/ratio.js';
import { withAmountUtils } from '@agoric/zoe/tools/test-utils.js';
import { q } from '@endo/errors';
Expand Down
4 changes: 4 additions & 0 deletions packages/inter-protocol/src/interest-math.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ import {
ratiosSame,
} from '@agoric/zoe/src/contractSupport/ratio.js';

/**
* @import {Amount, Brand, Payment} from '@agoric/ertp';
*/

/**
* @param {Ratio} currentCompoundedInterest as coefficient
* @param {Ratio} previousCompoundedInterest as coefficient
Expand Down
4 changes: 4 additions & 0 deletions packages/zoe/tools/test-utils.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
import { AmountMath } from '@agoric/ertp';
import { makeRatio } from '../src/contractSupport/ratio.js';

/**
* @import {Amount, Brand, DepositFacet, Issuer, IssuerKit, NatValue} from '@agoric/ertp';
*/

/** @param {Pick<IssuerKit<'nat'>, 'brand' | 'issuer' | 'mint'>} kit */
export const withAmountUtils = kit => {
const decimalPlaces = kit.issuer.getDisplayInfo?.()?.decimalPlaces ?? 6;
Expand Down
4 changes: 4 additions & 0 deletions packages/zoe/tools/types.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
// Ensure this is a module.
export {};

/**
* @import {Amount, Brand, DepositFacet, Issuer, IssuerKit, Payment} from '@agoric/ertp';
*/

/**
* @typedef {object} PriceQuote
* @property {Amount<'set', PriceDescription>} quoteAmount
Expand Down

0 comments on commit b5d1abe

Please sign in to comment.