From df2f6bd3483c4dc894550895b51bec9ba68d9a2a Mon Sep 17 00:00:00 2001 From: Turadg Aleahmad Date: Tue, 17 Dec 2024 06:30:12 -0800 Subject: [PATCH 1/5] chore(types): FU ContractRecord --- packages/fast-usdc/src/fast-usdc.contract.js | 7 ++----- packages/fast-usdc/src/types.ts | 5 +++++ 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/packages/fast-usdc/src/fast-usdc.contract.js b/packages/fast-usdc/src/fast-usdc.contract.js index cb3ed9bd8e7..99e3ba7008d 100644 --- a/packages/fast-usdc/src/fast-usdc.contract.js +++ b/packages/fast-usdc/src/fast-usdc.contract.js @@ -38,7 +38,7 @@ const ADDRESSES_BAGGAGE_KEY = 'addresses'; * @import {Marshaller, StorageNode} from '@agoric/internal/src/lib-chainStorage.js' * @import {Zone} from '@agoric/zone'; * @import {OperatorKit} from './exos/operator-kit.js'; - * @import {CctpTxEvidence, FeeConfig} from './types.js'; + * @import {CctpTxEvidence, ContractRecord, FeeConfig} from './types.js'; */ /** @@ -76,10 +76,7 @@ const publishFeeConfig = async (node, marshaller, feeConfig) => { /** * @param {Remote} contractNode - * @param {{ - * poolAccount: ChainAddress['value']; - * settlementAccount: ChainAddress['value']; - * }} addresses + * @param {ContractRecord} addresses */ const publishAddresses = (contractNode, addresses) => { return E(contractNode).setValue(JSON.stringify(addresses)); diff --git a/packages/fast-usdc/src/types.ts b/packages/fast-usdc/src/types.ts index 44f9669613d..fa3619b5ea4 100644 --- a/packages/fast-usdc/src/types.ts +++ b/packages/fast-usdc/src/types.ts @@ -45,6 +45,11 @@ export interface TransactionRecord extends CopyRecord { status: TxStatus; } +export interface ContractRecord extends CopyRecord { + poolAccount: ChainAddress['value']; + settlementAccount: ChainAddress['value']; +} + export type LogFn = (...args: unknown[]) => void; export interface PendingTx extends CctpTxEvidence { From 123e7963e523b7ad062c16170fa490693488188f Mon Sep 17 00:00:00 2001 From: Turadg Aleahmad Date: Tue, 17 Dec 2024 06:30:32 -0800 Subject: [PATCH 2/5] chore(types): expand PublishedTypeMap --- packages/client-utils/src/types.d.ts | 14 +++++++++++++- packages/fast-usdc/src/cli/lp-commands.js | 1 - 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/packages/client-utils/src/types.d.ts b/packages/client-utils/src/types.d.ts index fc11550bbf5..53d692d49e8 100644 --- a/packages/client-utils/src/types.d.ts +++ b/packages/client-utils/src/types.d.ts @@ -10,6 +10,10 @@ import type { CurrentWalletRecord, UpdateRecord, } from '@agoric/smart-wallet/src/smartWallet.js'; +import type { + ContractRecord, + PoolMetrics, +} from '@agoric/fast-usdc/src/types.js'; // For static string key types. String template matching has to be in the ternary below. type PublishedTypeMap = { @@ -34,4 +38,12 @@ export type TypedPublished = T extends keyof PublishedTypeMap ? OutcomeRecord : T extends `vaultFactory.managers.manager${number}.metrics` ? VaultManagerMetrics - : unknown; + : T extends 'agoricNames.instance' + ? Array<[string, Instance]> + : T extends 'agoricNames.brand' + ? Array<[string, Brand]> + : T extends 'fastUsdc' + ? ContractRecord + : T extends 'fastUsdc.poolMetrics' + ? PoolMetrics + : unknown; diff --git a/packages/fast-usdc/src/cli/lp-commands.js b/packages/fast-usdc/src/cli/lp-commands.js index afcbd063650..246d13bb19b 100644 --- a/packages/fast-usdc/src/cli/lp-commands.js +++ b/packages/fast-usdc/src/cli/lp-commands.js @@ -142,7 +142,6 @@ export const addLPCommands = ( const usdcAmount = parseUSDCAmount(opts.amount, usdc); /** @type {import('../types.js').PoolMetrics} */ - // @ts-expect-error it treats this as "unknown" const metrics = await swk.readPublished('fastUsdc.poolMetrics'); const fastLPAmount = ceilDivideBy(usdcAmount, metrics.shareWorth); From 5372566be8984ac5f1998140bbd9748658b19ac0 Mon Sep 17 00:00:00 2001 From: Turadg Aleahmad Date: Tue, 17 Dec 2024 06:48:38 -0800 Subject: [PATCH 3/5] chore(types): fast-usdc package export types --- .../test/fast-usdc/fast-usdc.test.ts | 28 +++++++++---------- multichain-testing/tools/noble-tools.ts | 2 +- .../fast-usdc/fast-usdc-update.build.js | 2 +- .../scripts/fast-usdc/init-fast-usdc.js | 2 +- packages/client-utils/src/types.d.ts | 5 +--- packages/fast-usdc/package.json | 1 + packages/fast-usdc/src/main.js | 1 + packages/fast-usdc/src/utils/deploy-config.js | 2 +- 8 files changed, 21 insertions(+), 22 deletions(-) create mode 100644 packages/fast-usdc/src/main.js diff --git a/multichain-testing/test/fast-usdc/fast-usdc.test.ts b/multichain-testing/test/fast-usdc/fast-usdc.test.ts index 1b0958a3441..f9dea6796bb 100644 --- a/multichain-testing/test/fast-usdc/fast-usdc.test.ts +++ b/multichain-testing/test/fast-usdc/fast-usdc.test.ts @@ -1,27 +1,27 @@ import anyTest from '@endo/ses-ava/prepare-endo.js'; -import type { TestFn } from 'ava'; import { encodeAddressHook } from '@agoric/cosmic-proto/address-hooks.js'; +import type { QueryBalanceResponseSDKType } from '@agoric/cosmic-proto/cosmos/bank/v1beta1/query.js'; import { AmountMath } from '@agoric/ertp'; -import type { Denom } from '@agoric/orchestration'; -import { divideBy, multiplyBy } from '@agoric/zoe/src/contractSupport/ratio.js'; -import type { IBCChannelID } from '@agoric/vats'; -import { makeDoOffer, type WalletDriver } from '../../tools/e2e-tools.js'; -import { makeDenomTools } from '../../tools/asset-info.js'; -import { createWallet } from '../../tools/wallet.js'; -import { makeQueryClient } from '../../tools/query.js'; -import { commonSetup, type SetupContextWithWallets } from '../support.js'; -import { makeFeedPolicy, oracleMnemonics } from './config.js'; -import { makeRandomDigits } from '../../tools/random.js'; -import { makeTracer } from '@agoric/internal'; +import type { USDCProposalShapes } from '@agoric/fast-usdc/src/pool-share-math.js'; import type { CctpTxEvidence, EvmAddress, PoolMetrics, } from '@agoric/fast-usdc/src/types.js'; +import { makeTracer } from '@agoric/internal'; +import type { Denom } from '@agoric/orchestration'; import type { CurrentWalletRecord } from '@agoric/smart-wallet/src/smartWallet.js'; -import type { QueryBalanceResponseSDKType } from '@agoric/cosmic-proto/cosmos/bank/v1beta1/query.js'; -import type { USDCProposalShapes } from '@agoric/fast-usdc/src/pool-share-math.js'; +import type { IBCChannelID } from '@agoric/vats'; +import { divideBy, multiplyBy } from '@agoric/zoe/src/contractSupport/ratio.js'; +import type { TestFn } from 'ava'; +import { makeDenomTools } from '../../tools/asset-info.js'; +import { makeDoOffer, type WalletDriver } from '../../tools/e2e-tools.js'; +import { makeQueryClient } from '../../tools/query.js'; +import { makeRandomDigits } from '../../tools/random.js'; +import { createWallet } from '../../tools/wallet.js'; +import { commonSetup, type SetupContextWithWallets } from '../support.js'; +import { makeFeedPolicy, oracleMnemonics } from './config.js'; const log = makeTracer('MCFU'); diff --git a/multichain-testing/tools/noble-tools.ts b/multichain-testing/tools/noble-tools.ts index cd72a332857..c6aab6c5e0d 100644 --- a/multichain-testing/tools/noble-tools.ts +++ b/multichain-testing/tools/noble-tools.ts @@ -1,7 +1,7 @@ import type { IBCChannelID } from '@agoric/vats'; import type { ExecSync } from './agd-lib.js'; import type { ChainAddress } from '@agoric/orchestration'; -import type { NobleAddress } from '@agoric/fast-usdc/src/types.js'; +import type { NobleAddress } from '@agoric/fast-usdc'; const kubectlBinary = 'kubectl'; const noblePod = 'noblelocal-genesis-0'; diff --git a/packages/builders/scripts/fast-usdc/fast-usdc-update.build.js b/packages/builders/scripts/fast-usdc/fast-usdc-update.build.js index 21a1e6a0573..4f8ab6993ac 100644 --- a/packages/builders/scripts/fast-usdc/fast-usdc-update.build.js +++ b/packages/builders/scripts/fast-usdc/fast-usdc-update.build.js @@ -7,7 +7,7 @@ import { makeHelpers } from '@agoric/deploy-script-support'; /** * @import {CoreEvalBuilder, DeployScriptFunction} from '@agoric/deploy-script-support/src/externalTypes.js' * @import {ParseArgsConfig} from 'node:util' - * @import {FastUSDCConfig} from '@agoric/fast-usdc/src/types.js' + * @import {FastUSDCConfig} from '@agoric/fast-usdc'; */ /** @type {ParseArgsConfig['options']} */ diff --git a/packages/builders/scripts/fast-usdc/init-fast-usdc.js b/packages/builders/scripts/fast-usdc/init-fast-usdc.js index fade01cea83..a25e044e853 100644 --- a/packages/builders/scripts/fast-usdc/init-fast-usdc.js +++ b/packages/builders/scripts/fast-usdc/init-fast-usdc.js @@ -17,7 +17,7 @@ import { parseArgs } from 'node:util'; /** * @import {CoreEvalBuilder, DeployScriptFunction} from '@agoric/deploy-script-support/src/externalTypes.js' * @import {ParseArgsConfig} from 'node:util' - * @import {FastUSDCConfig} from '@agoric/fast-usdc/src/types.js' + * @import {FastUSDCConfig} from '@agoric/fast-usdc'; */ const { keys } = Object; diff --git a/packages/client-utils/src/types.d.ts b/packages/client-utils/src/types.d.ts index 53d692d49e8..66b25c755e7 100644 --- a/packages/client-utils/src/types.d.ts +++ b/packages/client-utils/src/types.d.ts @@ -10,10 +10,7 @@ import type { CurrentWalletRecord, UpdateRecord, } from '@agoric/smart-wallet/src/smartWallet.js'; -import type { - ContractRecord, - PoolMetrics, -} from '@agoric/fast-usdc/src/types.js'; +import type { ContractRecord, PoolMetrics } from '@agoric/fast-usdc'; // For static string key types. String template matching has to be in the ternary below. type PublishedTypeMap = { diff --git a/packages/fast-usdc/package.json b/packages/fast-usdc/package.json index 30e20a49253..9816516b698 100644 --- a/packages/fast-usdc/package.json +++ b/packages/fast-usdc/package.json @@ -8,6 +8,7 @@ "src", "tools" ], + "main": "src/main.js", "bin": { "fast-usdc": "./src/cli/bin.js" }, diff --git a/packages/fast-usdc/src/main.js b/packages/fast-usdc/src/main.js new file mode 100644 index 00000000000..d4702960d54 --- /dev/null +++ b/packages/fast-usdc/src/main.js @@ -0,0 +1 @@ +export * from './types.js'; diff --git a/packages/fast-usdc/src/utils/deploy-config.js b/packages/fast-usdc/src/utils/deploy-config.js index 22b2cd5a593..5c59f1241b3 100644 --- a/packages/fast-usdc/src/utils/deploy-config.js +++ b/packages/fast-usdc/src/utils/deploy-config.js @@ -2,7 +2,7 @@ import { denomHash, withChainCapabilities } from '@agoric/orchestration'; import fetchedChainInfo from '@agoric/orchestration/src/fetched-chain-info.js'; /** - * @import {FastUSDCConfig} from '@agoric/fast-usdc/src/types.js' + * @import {FastUSDCConfig} from '@agoric/fast-usdc'; * @import {Passable} from '@endo/marshal'; * @import {CosmosChainInfo, Denom, DenomDetail} from '@agoric/orchestration'; */ From c7d166b97fc010d1f09f89891aed985cca7b7c56 Mon Sep 17 00:00:00 2001 From: Turadg Aleahmad Date: Wed, 18 Dec 2024 11:28:23 -0800 Subject: [PATCH 4/5] docs: fix run-policy link path Fixes this warning from typdoc, ``` ./packages/SwingSet/src/controller/controller.js:480:21 - [warning] The relative path ../docs/run-policy.md is not a file and will not be copied to the output directory 480 * [`runPolicy`](../docs/run-policy.md) to rate-limit cleanups. ``` --- packages/SwingSet/src/controller/controller.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/SwingSet/src/controller/controller.js b/packages/SwingSet/src/controller/controller.js index eace725d4ce..613f36fdaad 100644 --- a/packages/SwingSet/src/controller/controller.js +++ b/packages/SwingSet/src/controller/controller.js @@ -477,7 +477,7 @@ export async function makeSwingsetController( * * The first `controller.run()` after this call will delete all * the old vat's state at once, unless you use a - * [`runPolicy`](../docs/run-policy.md) to rate-limit cleanups. + * [`runPolicy`](../../docs/run-policy.md) to rate-limit cleanups. * * @param {VatID} vatID * @param {SwingSetCapData} reasonCD From e49ad004bd57fa8e71b72653331254e5529bb26c Mon Sep 17 00:00:00 2001 From: Turadg Aleahmad Date: Wed, 18 Dec 2024 15:42:04 -0800 Subject: [PATCH 5/5] chore: settlementAddress no longer optional --- packages/fast-usdc/src/exos/advancer.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/fast-usdc/src/exos/advancer.js b/packages/fast-usdc/src/exos/advancer.js index a96c781f140..1b9466ebd96 100644 --- a/packages/fast-usdc/src/exos/advancer.js +++ b/packages/fast-usdc/src/exos/advancer.js @@ -276,8 +276,8 @@ export const prepareAdvancerKit = ( notifyFacet: M.remotable(), borrowerFacet: M.remotable(), poolAccount: M.remotable(), + settlementAddress: ChainAddressShape, intermediateRecipient: M.opt(ChainAddressShape), - settlementAddress: M.opt(ChainAddressShape), }), }, );