diff --git a/a3p-integration/proposals/z:acceptance/governance.test.js b/a3p-integration/proposals/z:acceptance/governance.test.js index faf0736335bc..31a8642dddd8 100644 --- a/a3p-integration/proposals/z:acceptance/governance.test.js +++ b/a3p-integration/proposals/z:acceptance/governance.test.js @@ -20,22 +20,15 @@ test.serial( 'economic committee can make governance proposal and vote on it', async t => { const { waitUntil } = makeTimerUtils({ setTimeout }); - const { readLatestHead, getLastUpdate } = await makeWalletUtils( - { delay, fetch }, - networkConfig, - ); + const { readLatestHead, getLastUpdate, getCurrentWalletRecord } = + await makeWalletUtils({ delay, fetch }, networkConfig); const governanceDriver = await makeGovernanceDriver(fetch, networkConfig); /** @type {any} */ const instance = await readLatestHead(`published.agoricNames.instance`); const instances = Object.fromEntries(instance); - const wallet = - /** @type {import('@agoric/smart-wallet/src/smartWallet.js').CurrentWalletRecord} */ ( - await readLatestHead( - `published.wallet.${governanceAddresses[0]}.current`, - ) - ); + const wallet = await getCurrentWalletRecord(governanceAddresses[0]); const usedInvitations = wallet.offerToUsedInvitation; const charterInvitation = usedInvitations.find( diff --git a/a3p-integration/proposals/z:acceptance/test-lib/utils.js b/a3p-integration/proposals/z:acceptance/test-lib/utils.js index 498cb019c826..69b67992f7c4 100644 --- a/a3p-integration/proposals/z:acceptance/test-lib/utils.js +++ b/a3p-integration/proposals/z:acceptance/test-lib/utils.js @@ -1,5 +1,5 @@ /* eslint-env node */ -import { makeVstorageKit, makeStargateClient } from '@agoric/client-utils'; +import { makeStargateClient, makeVstorageKit } from '@agoric/client-utils'; import { readFile, writeFile } from 'node:fs/promises'; import { networkConfig } from './rpc.js'; @@ -56,11 +56,8 @@ export const getBalances = async (addresses, targetDenom = undefined) => { * @param {WalletUtils} walletUtils * @returns {Promise} */ -export const listVaults = async (addr, { readLatestHead }) => { - // TODO parameterize readLatestHead to match these string types - const current = /** @type {CurrentWalletRecord} */ ( - await readLatestHead(`published.wallet.${addr}.current`) - ); +export const listVaults = async (addr, { getCurrentWalletRecord }) => { + const current = await getCurrentWalletRecord(addr); const vaultStoragePaths = current.offerToPublicSubscriberPaths.map( ([_offerId, pathmap]) => pathmap.vault, ); diff --git a/packages/client-utils/src/wallet-utils.js b/packages/client-utils/src/wallet-utils.js index 582b57a035af..27dc250ce1f6 100644 --- a/packages/client-utils/src/wallet-utils.js +++ b/packages/client-utils/src/wallet-utils.js @@ -5,6 +5,7 @@ import { boardSlottingMarshaller, makeVstorageKit } from './vstorage-kit.js'; /** * @import {Amount, Brand} from '@agoric/ertp/src/types.js' + * @import {CurrentWalletRecord, UpdateRecord} from '@agoric/smart-wallet/src/smartWallet.js'; * @import {MinimalNetworkConfig} from './rpc.js'; */ @@ -82,11 +83,22 @@ export const makeWalletUtils = async ({ fetch, delay }, networkConfig) => { /** * @param {string} addr - * @returns {Promise} + * @returns {Promise} */ const getLastUpdate = addr => { - // @ts-expect-error cast - return readLatestHead(`published.wallet.${addr}`); + return /** @type {Promise} */ ( + readLatestHead(`published.wallet.${addr}`) + ); + }; + + /** + * @param {string} addr + * @returns {Promise} + */ + const getCurrentWalletRecord = addr => { + return /** @type {Promise} */ ( + readLatestHead(`published.wallet.${addr}.current`) + ); }; return { @@ -96,6 +108,7 @@ export const makeWalletUtils = async ({ fetch, delay }, networkConfig) => { marshaller, vstorage, getLastUpdate, + getCurrentWalletRecord, readLatestHead, storedWalletState, pollOffer,