diff --git a/multichain-testing/test/account-balance-queries.test.ts b/multichain-testing/test/account-balance-queries.test.ts index c067ced9446..606d98f471e 100644 --- a/multichain-testing/test/account-balance-queries.test.ts +++ b/multichain-testing/test/account-balance-queries.test.ts @@ -40,7 +40,7 @@ const queryAccountBalances = test.macro({ const { wallets, provisionSmartWallet, - vstorageClient, + smartWalletKit, retryUntilCondition, } = t.context; @@ -67,7 +67,8 @@ const queryAccountBalances = test.macro({ }); const offerResult = await retryUntilCondition( - () => vstorageClient.queryData(`published.wallet.${agoricAddr}`), + () => smartWalletKit.readPublished(`wallet.${agoricAddr}`), + // @ts-expect-error UpdateRecord may not have 'status' ({ status }) => status.id === offerId && (status.result || status.error), `${offerId} offer result is in vstorage`, MAKE_ACCOUNT_AND_QUERY_BALANCE_TIMEOUT, @@ -83,6 +84,7 @@ const queryAccountBalances = test.macro({ ); const { + // @ts-expect-error UpdateRecord may not have 'status' status: { result, error }, } = offerResult; if (expectValidResult) { @@ -110,7 +112,7 @@ const queryAccountBalance = test.macro({ const { wallets, provisionSmartWallet, - vstorageClient, + smartWalletKit, retryUntilCondition, useChain, } = t.context; @@ -146,7 +148,8 @@ const queryAccountBalance = test.macro({ }); const offerResult = await retryUntilCondition( - () => vstorageClient.queryData(`published.wallet.${agoricAddr}`), + () => smartWalletKit.readPublished(`wallet.${agoricAddr}`), + // @ts-expect-error UpdateRecord may not have 'status' ({ status }) => status.id === offerId && (status.result || status.error), `${offerId} offer result is in vstorage`, MAKE_ACCOUNT_AND_QUERY_BALANCE_TIMEOUT, @@ -162,6 +165,7 @@ const queryAccountBalance = test.macro({ ); const { + // @ts-expect-error UpdateRecord may not have 'status' status: { result, error }, } = offerResult; if (expectValidResult) { diff --git a/multichain-testing/test/auto-stake-it.test.ts b/multichain-testing/test/auto-stake-it.test.ts index 10e3bac8db8..e13a9cca186 100644 --- a/multichain-testing/test/auto-stake-it.test.ts +++ b/multichain-testing/test/auto-stake-it.test.ts @@ -36,7 +36,7 @@ const autoStakeItScenario = test.macro({ // 1. setup const { wallets, - vstorageClient, + smartWalletKit, provisionSmartWallet, retryUntilCondition, useChain, @@ -98,9 +98,9 @@ const autoStakeItScenario = test.macro({ // FIXME https://github.com/Agoric/agoric-sdk/issues/9643 const currentWalletRecord = await retryUntilCondition( - () => - vstorageClient.queryData(`published.wallet.${agoricUserAddr}.current`), + () => smartWalletKit.readPublished(`wallet.${agoricUserAddr}.current`), ({ offerToPublicSubscriberPaths }) => + // @ts-expect-error retryUntilCondition expects a boolean return Object.fromEntries(offerToPublicSubscriberPaths)[offerId], `${offerId} continuing invitation is in vstorage`, ); @@ -118,6 +118,7 @@ const autoStakeItScenario = test.macro({ .split('.') .pop(); console.log({ lcaAddress, icaAddress }); + assert(lcaAddress && icaAddress); t.regex(lcaAddress, /^agoric1/, 'LOA address is valid'); t.regex( icaAddress, diff --git a/multichain-testing/test/basic-flows.test.ts b/multichain-testing/test/basic-flows.test.ts index 1d53b4aae8d..e8a16e48181 100644 --- a/multichain-testing/test/basic-flows.test.ts +++ b/multichain-testing/test/basic-flows.test.ts @@ -38,7 +38,7 @@ const makeAccountScenario = test.macro({ const { wallets, provisionSmartWallet, - vstorageClient, + smartWalletKit, retryUntilCondition, } = t.context; @@ -66,8 +66,9 @@ const makeAccountScenario = test.macro({ // TODO fix above so we don't have to poll for the offer result to be published // https://github.com/Agoric/agoric-sdk/issues/9643 const currentWalletRecord = await retryUntilCondition( - () => vstorageClient.queryData(`published.wallet.${agoricAddr}.current`), + () => smartWalletKit.readPublished(`wallet.${agoricAddr}.current`), ({ offerToPublicSubscriberPaths }) => + // @ts-expect-error retryUntilCondition expects a boolean return Object.fromEntries(offerToPublicSubscriberPaths)[offerId], `${offerId} continuing invitation is in vstorage`, ); @@ -80,17 +81,19 @@ const makeAccountScenario = test.macro({ .split('.') .pop(); t.log('Got address:', address); + assert(address); t.regex( address, new RegExp(`^${config.expectedAddressPrefix}1`), `address for ${chainName} is valid`, ); - const latestWalletUpdate = await vstorageClient.queryData( - `published.wallet.${agoricAddr}`, + const latestWalletUpdate = await smartWalletKit.readPublished( + `wallet.${agoricAddr}`, ); t.log('latest wallet update', latestWalletUpdate); t.like( + // @ts-expect-error UpdateRecord may not have 'status' latestWalletUpdate.status, { id: offerId, diff --git a/multichain-testing/test/chain-queries.test.ts b/multichain-testing/test/chain-queries.test.ts index 56673742582..b1c0fae4e54 100644 --- a/multichain-testing/test/chain-queries.test.ts +++ b/multichain-testing/test/chain-queries.test.ts @@ -48,7 +48,7 @@ const queryICQChain = test.macro({ const { wallets, provisionSmartWallet, - vstorageClient, + smartWalletKit, retryUntilCondition, useChain, } = t.context; @@ -108,7 +108,8 @@ const queryICQChain = test.macro({ }); const offerResult = await retryUntilCondition( - () => vstorageClient.queryData(`published.wallet.${agoricAddr}`), + () => smartWalletKit.readPublished(`wallet.${agoricAddr}`), + // @ts-expect-error UpdateRecord may not have 'status' ({ status }) => status.id === offerId && (status.result || status.error), `${offerId} offer result is in vstorage`, { @@ -117,6 +118,7 @@ const queryICQChain = test.macro({ ); t.log('ICQ Query Offer Result', offerResult); const { + // @ts-expect-error UpdateRecord may not have 'status' status: { result, error }, } = offerResult; t.is(error, undefined, 'No error observed'); @@ -160,7 +162,7 @@ const queryChainWithoutICQ = test.macro({ const { wallets, provisionSmartWallet, - vstorageClient, + smartWalletKit, retryUntilCondition, useChain, } = t.context; @@ -200,7 +202,8 @@ const queryChainWithoutICQ = test.macro({ }); const offerResult = await retryUntilCondition( - () => vstorageClient.queryData(`published.wallet.${agoricAddr}`), + () => smartWalletKit.readPublished(`wallet.${agoricAddr}`), + // @ts-expect-error UpdateRecord may not have 'status' ({ status }) => status.id === offerId && (status.result || status.error), `${offerId} continuing invitation is in vstorage`, { @@ -208,6 +211,7 @@ const queryChainWithoutICQ = test.macro({ }, ); t.is( + // @ts-expect-error UpdateRecord may not have 'status' offerResult.status.error, `Error: Queries not available for chain "${chain_id}"`, 'Queries not available error returned', @@ -216,7 +220,7 @@ const queryChainWithoutICQ = test.macro({ }); test.serial('Send Local Query from chain object', async t => { - const { wallets, provisionSmartWallet, vstorageClient, retryUntilCondition } = + const { wallets, provisionSmartWallet, smartWalletKit, retryUntilCondition } = t.context; const agoricAddr = wallets['agoric']; @@ -268,7 +272,8 @@ test.serial('Send Local Query from chain object', async t => { }); const offerResult = await retryUntilCondition( - () => vstorageClient.queryData(`published.wallet.${agoricAddr}`), + () => smartWalletKit.readPublished(`wallet.${agoricAddr}`), + // @ts-expect-error UpdateRecord may not have 'status' ({ status }) => status.id === offerId && (status.result || status.error), `${offerId} continuing invitation is in vstorage`, { @@ -276,6 +281,7 @@ test.serial('Send Local Query from chain object', async t => { }, ); + // @ts-expect-error UpdateRecord may not have 'status' const parsedResults = JSON.parse(offerResult.status.result); t.truthy(parsedResults[0].height, 'query height is returned'); t.is(parsedResults[0].error, '', 'error is empty'); diff --git a/multichain-testing/test/deposit-withdraw-lca.test.ts b/multichain-testing/test/deposit-withdraw-lca.test.ts index 7d1cbafa97c..1bcb54746ab 100644 --- a/multichain-testing/test/deposit-withdraw-lca.test.ts +++ b/multichain-testing/test/deposit-withdraw-lca.test.ts @@ -31,7 +31,7 @@ test('Deposit IST to orchAccount and then withdraw', async t => { const { wallets, provisionSmartWallet, - vstorageClient, + smartWalletKit, retryUntilCondition, useChain, } = t.context; @@ -61,8 +61,9 @@ test('Deposit IST to orchAccount and then withdraw', async t => { // Wait for the orchAccount to be created const { offerToPublicSubscriberPaths } = await retryUntilCondition( - () => vstorageClient.queryData(`published.wallet.${agoricAddr}.current`), + () => smartWalletKit.readPublished(`wallet.${agoricAddr}.current`), ({ offerToPublicSubscriberPaths }) => + // @ts-expect-error retryUntilCondition expects a boolean return Object.fromEntries(offerToPublicSubscriberPaths)[makeAccountOfferId], 'makeAccount offer result is in vstorage', ); @@ -72,10 +73,10 @@ test('Deposit IST to orchAccount and then withdraw', async t => { makeAccountOfferId ]!.account; const lcaAddress = accountStoragePath.split('.').at(-1); - t.truthy(lcaAddress, 'Account address is in storage path'); + assert(lcaAddress, 'Account address is in storage path'); // Get IST brand - const brands = await vstorageClient.queryData('published.agoricNames.brand'); + const brands = await smartWalletKit.readPublished('agoricNames.brand'); const istBrand = Object.fromEntries(brands).IST; // Deposit IST to orchAccount @@ -150,7 +151,7 @@ test('Deposit IST to orchAccount and then withdraw', async t => { test.todo('Deposit and Withdraw ATOM/OSMO to localOrchAccount via offer #9966'); test('Attempt to withdraw more than available balance', async t => { - const { wallets, provisionSmartWallet, vstorageClient, retryUntilCondition } = + const { wallets, provisionSmartWallet, smartWalletKit, retryUntilCondition } = t.context; // Provision the Agoric smart wallet @@ -178,8 +179,9 @@ test('Attempt to withdraw more than available balance', async t => { // Wait for the orchAccount to be created const { offerToPublicSubscriberPaths } = await retryUntilCondition( - () => vstorageClient.queryData(`published.wallet.${agoricAddr}.current`), + () => smartWalletKit.readPublished(`wallet.${agoricAddr}.current`), ({ offerToPublicSubscriberPaths }) => + // @ts-expect-error retryUntilCondition expects a boolean return Object.fromEntries(offerToPublicSubscriberPaths)[makeAccountOfferId], `${makeAccountOfferId} offer result is in vstorage`, ); @@ -191,7 +193,7 @@ test('Attempt to withdraw more than available balance', async t => { t.truthy(lcaAddress, 'Account address is in storage path'); // Get IST brand - const brands = await vstorageClient.queryData('published.agoricNames.brand'); + const brands = await smartWalletKit.readPublished('agoricNames.brand'); const istBrand = Object.fromEntries(brands).IST; // Attempt to withdraw more than available balance @@ -212,11 +214,13 @@ test('Attempt to withdraw more than available balance', async t => { // Verify that the withdrawal failed const offerResult = await retryUntilCondition( - () => vstorageClient.queryData(`published.wallet.${agoricAddr}`), + () => smartWalletKit.readPublished(`wallet.${agoricAddr}`), + // @ts-expect-error UpdateRecord may not have 'status' ({ status }) => status.id === withdrawOfferId && status.error !== undefined, 'Withdrawal offer error is in vstorage', ); t.is( + // @ts-expect-error UpdateRecord may not have 'status' offerResult.status.error, 'Error: One or more withdrawals failed ["[Error: cannot grab 200uist coins: 0uist is smaller than 200uist: insufficient funds]"]', ); diff --git a/multichain-testing/test/deposit-withdraw-portfolio.test.ts b/multichain-testing/test/deposit-withdraw-portfolio.test.ts index 49b7f3d8ad7..3e9416b2098 100644 --- a/multichain-testing/test/deposit-withdraw-portfolio.test.ts +++ b/multichain-testing/test/deposit-withdraw-portfolio.test.ts @@ -34,7 +34,7 @@ const portfolioAccountScenario = test.macro({ const { wallets, provisionSmartWallet, - vstorageClient, + smartWalletKit, retryUntilCondition, useChain, } = t.context; @@ -64,8 +64,9 @@ const portfolioAccountScenario = test.macro({ }); const { offerToPublicSubscriberPaths } = await retryUntilCondition( - () => vstorageClient.queryData(`published.wallet.${agoricAddr}.current`), + () => smartWalletKit.readPublished(`wallet.${agoricAddr}.current`), ({ offerToPublicSubscriberPaths }) => + // @ts-expect-error retryUntilCondition expects a boolean return Object.fromEntries(offerToPublicSubscriberPaths)[ makePortfolioAcctOfferId ], @@ -81,13 +82,11 @@ const portfolioAccountScenario = test.macro({ const agoricLcaAddress = accountPaths.agoric.split('.').at(-1); const remoteIcaAddress = accountPaths[chainName].split('.').at(-1); - t.truthy(agoricLcaAddress, 'Agoric LCA address is in storage path'); - t.truthy(remoteIcaAddress, `${chainName} ICA address is in storage path`); + assert(agoricLcaAddress, 'Agoric LCA address is in storage path'); + assert(remoteIcaAddress, `${chainName} ICA address is in storage path`); // Get IST brand - const brands = await vstorageClient.queryData( - 'published.agoricNames.brand', - ); + const brands = await smartWalletKit.readPublished('agoricNames.brand'); const istBrand = Object.fromEntries(brands).IST; // Setup query clients diff --git a/multichain-testing/test/fast-usdc/fast-usdc.test.ts b/multichain-testing/test/fast-usdc/fast-usdc.test.ts index a7fbf413e32..753e4344f5d 100644 --- a/multichain-testing/test/fast-usdc/fast-usdc.test.ts +++ b/multichain-testing/test/fast-usdc/fast-usdc.test.ts @@ -15,10 +15,7 @@ import { makeFeedPolicy, oracleMnemonics } from './config.js'; import { makeRandomDigits } from '../../tools/random.js'; import { balancesFromPurses } from '../../tools/purse.js'; import { makeTracer } from '@agoric/internal'; -import type { - CctpTxEvidence, - EvmAddress, -} from '@agoric/fast-usdc/src/types.js'; +import type { CctpTxEvidence, EvmAddress } from '@agoric/fast-usdc'; const log = makeTracer('MCFU'); @@ -110,8 +107,8 @@ test.after(async t => { const toOracleOfferId = (idx: number) => `oracle${idx + 1}-accept`; test.serial('oracles accept', async t => { - const { oracleWds, retryUntilCondition, vstorageClient, wallets } = t.context; - const brands = await vstorageClient.queryData('published.agoricNames.brand'); + const { oracleWds, retryUntilCondition, smartWalletKit, wallets } = t.context; + const brands = await smartWalletKit.readPublished('agoricNames.brand'); const { Invitation } = Object.fromEntries(brands); const description = 'oracle operator invitation'; @@ -119,9 +116,9 @@ test.serial('oracles accept', async t => { // ensure we have an unused (or used) oracle invitation in each purse let hasAccepted = false; for (const name of keys(oracleMnemonics)) { - const { offerToUsedInvitation, purses } = await vstorageClient.queryData( - `published.wallet.${wallets[name]}.current`, - ); + const { offerToUsedInvitation, purses } = + await smartWalletKit.readPublished(`wallet.${wallets[name]}.current`); + // @ts-expect-error Brand cannot be used as an index type const { value: invitations } = balancesFromPurses(purses)[Invitation]; const hasInvitation = invitations.some(x => x.description === description); const usedInvitation = offerToUsedInvitation?.[0]?.[0] === `${name}-accept`; @@ -136,7 +133,7 @@ test.serial('oracles accept', async t => { // accept oracle operator invitations const instance = fromEntries( - await vstorageClient.queryData('published.agoricNames.instance'), + await smartWalletKit.readPublished('agoricNames.instance'), )[contractName]; await Promise.all( oracleWds.map(makeDoOffer).map((doOffer, i) => @@ -156,7 +153,7 @@ test.serial('oracles accept', async t => { const addr = wallets[name]; await t.notThrowsAsync(() => retryUntilCondition( - () => vstorageClient.queryData(`published.wallet.${addr}.current`), + () => smartWalletKit.readPublished(`wallet.${addr}.current`), ({ offerToUsedInvitation }) => { return offerToUsedInvitation[0][0] === `${name}-accept`; }, @@ -168,16 +165,16 @@ test.serial('oracles accept', async t => { }); test.serial('lp deposits', async t => { - const { lpUser, retryUntilCondition, vstorageClient, wallets } = t.context; + const { lpUser, retryUntilCondition, smartWalletKit, wallets } = t.context; const lpDoOffer = makeDoOffer(lpUser); - const brands = await vstorageClient.queryData('published.agoricNames.brand'); + const brands = await smartWalletKit.readPublished('agoricNames.brand'); const { USDC, FastLP } = Object.fromEntries(brands); const usdcToGive = make(USDC, LP_DEPOSIT_AMOUNT); - const { shareWorth: currShareWorth } = await vstorageClient.queryData( - `published.${contractName}.poolMetrics`, + const { shareWorth: currShareWorth } = await smartWalletKit.readPublished( + `${contractName}.poolMetrics`, ); const poolSharesWanted = divideBy(usdcToGive, currShareWorth); @@ -196,7 +193,7 @@ test.serial('lp deposits', async t => { await t.notThrowsAsync(() => retryUntilCondition( - () => vstorageClient.queryData(`published.${contractName}.poolMetrics`), + () => smartWalletKit.readPublished(`${contractName}.poolMetrics`), ({ shareWorth }) => !isGTE(currShareWorth.numerator, shareWorth.numerator), 'share worth numerator increases from deposit', @@ -206,9 +203,9 @@ test.serial('lp deposits', async t => { await t.notThrowsAsync(() => retryUntilCondition( - () => - vstorageClient.queryData(`published.wallet.${wallets['lp']}.current`), + () => smartWalletKit.readPublished(`wallet.${wallets['lp']}.current`), ({ purses }) => { + // @ts-expect-error Brand cannot be used as an index type const currentPoolShares = balancesFromPurses(purses)[FastLP]; return currentPoolShares && isGTE(currentPoolShares, poolSharesWanted); }, @@ -230,7 +227,6 @@ const advanceAndSettleScenario = test.macro({ smartWalletKit, useChain, usdcOnOsmosis, - vstorageClient, } = t.context; // EUD wallet on the specified chain @@ -241,8 +237,8 @@ const advanceAndSettleScenario = test.macro({ t.log(`EUD wallet created: ${EUD}`); // parameterize agoric address - const { settlementAccount } = await vstorageClient.queryData( - `published.${contractName}`, + const { settlementAccount } = await smartWalletKit.readPublished( + `${contractName}`, ); t.log('settlementAccount address', settlementAccount); @@ -344,7 +340,7 @@ const advanceAndSettleScenario = test.macro({ nobleTools.mockCctpMint(mintAmt, userForwardingAddr); await t.notThrowsAsync(() => retryUntilCondition( - () => vstorageClient.queryData(`published.${contractName}.poolMetrics`), + () => smartWalletKit.readPublished(`${contractName}.poolMetrics`), ({ encumberedBalance }) => encumberedBalance && isEmpty(encumberedBalance), 'encumberedBalance returns to 0', @@ -365,23 +361,24 @@ test.serial('lp withdraws', async t => { retryUntilCondition, useChain, usdcDenom, - vstorageClient, + smartWalletKit, wallets, } = t.context; const queryClient = makeQueryClient( await useChain('agoric').getRestEndpoint(), ); const lpDoOffer = makeDoOffer(lpUser); - const brands = await vstorageClient.queryData('published.agoricNames.brand'); + const brands = await smartWalletKit.readPublished('agoricNames.brand'); const { FastLP } = Object.fromEntries(brands); t.log('FastLP brand', FastLP); - const { shareWorth: currShareWorth } = await vstorageClient.queryData( - `published.${contractName}.poolMetrics`, + const { shareWorth: currShareWorth } = await smartWalletKit.readPublished( + `${contractName}.poolMetrics`, ); - const { purses } = await vstorageClient.queryData( - `published.wallet.${wallets['lp']}.current`, + const { purses } = await smartWalletKit.readPublished( + `wallet.${wallets['lp']}.current`, ); + // @ts-expect-error Brand cannot be used as an index type const currentPoolShares = balancesFromPurses(purses)[FastLP]; t.log('currentPoolShares', currentPoolShares); const usdcWanted = multiplyBy(currentPoolShares, currShareWorth); @@ -408,9 +405,9 @@ test.serial('lp withdraws', async t => { await t.notThrowsAsync(() => retryUntilCondition( - () => - vstorageClient.queryData(`published.wallet.${wallets['lp']}.current`), + () => smartWalletKit.readPublished(`wallet.${wallets['lp']}.current`), ({ purses }) => { + // @ts-expect-error Brand cannot be used as an index type const currentPoolShares = balancesFromPurses(purses)[FastLP]; return !currentPoolShares || isEmpty(currentPoolShares); }, diff --git a/multichain-testing/test/fast-usdc/noble-forwarding.test.ts b/multichain-testing/test/fast-usdc/noble-forwarding.test.ts index 84ce4f3ae95..3c3b252fdf3 100644 --- a/multichain-testing/test/fast-usdc/noble-forwarding.test.ts +++ b/multichain-testing/test/fast-usdc/noble-forwarding.test.ts @@ -8,7 +8,7 @@ import { makeQueryClient } from '../../tools/query.js'; const test = anyTest as TestFn; test('noble forwarding', async t => { - const { nobleTools, retryUntilCondition, useChain, vstorageClient } = + const { nobleTools, retryUntilCondition, useChain, smartWalletKit } = await commonSetup(t); const agoricWallet = await createWallet('agoric'); @@ -21,7 +21,7 @@ test('noble forwarding', async t => { const connInfoPath = `published.agoricNames.chainConnection.${agoricChainId}_${nobleChainId}`; const { transferChannel: { counterPartyChannelId, channelId }, - }: IBCConnectionInfo = await vstorageClient.queryData(connInfoPath); + } = (await smartWalletKit.readLatestHead(connInfoPath)) as IBCConnectionInfo; t.regex( counterPartyChannelId, diff --git a/multichain-testing/test/ica-channel-close.test.ts b/multichain-testing/test/ica-channel-close.test.ts index 6ee59dc825f..4577be95421 100644 --- a/multichain-testing/test/ica-channel-close.test.ts +++ b/multichain-testing/test/ica-channel-close.test.ts @@ -61,7 +61,7 @@ const intentionalCloseAccountScenario = test.macro({ const { wallets, provisionSmartWallet, - vstorageClient, + smartWalletKit, retryUntilCondition, useChain, } = t.context; @@ -88,8 +88,9 @@ const intentionalCloseAccountScenario = test.macro({ proposal: {}, }); const currentWalletRecord = await retryUntilCondition( - () => vstorageClient.queryData(`published.wallet.${agoricAddr}.current`), + () => smartWalletKit.readPublished(`wallet.${agoricAddr}.current`), ({ offerToPublicSubscriberPaths }) => + // @ts-expect-error retryUntilCondition expects a boolean return Object.fromEntries(offerToPublicSubscriberPaths)[offerId], `${offerId} continuing invitation is in vstorage`, ); @@ -102,11 +103,10 @@ const intentionalCloseAccountScenario = test.macro({ const address = accountStoragePath.split('.').pop(); t.log('Got address:', address); - const { - remoteAddress, - localAddress, - }: CosmosOrchestrationAccountStorageState = - await vstorageClient.queryData(accountStoragePath); + const { remoteAddress, localAddress } = + (await smartWalletKit.readLatestHead( + accountStoragePath, + )) as CosmosOrchestrationAccountStorageState; const { rPortID, rChannelID } = parseRemoteAddress(remoteAddress); const remoteQueryClient = makeQueryClient( @@ -214,7 +214,7 @@ const channelCloseInitScenario = test.macro({ const { wallets, provisionSmartWallet, - vstorageClient, + smartWalletKit, retryUntilCondition, useChain, hermes, @@ -241,8 +241,9 @@ const channelCloseInitScenario = test.macro({ proposal: {}, }); const currentWalletRecord = await retryUntilCondition( - () => vstorageClient.queryData(`published.wallet.${agoricAddr}.current`), + () => smartWalletKit.readPublished(`wallet.${agoricAddr}.current`), ({ offerToPublicSubscriberPaths }) => + // @ts-expect-error retryUntilCondition expects boolean return Object.fromEntries(offerToPublicSubscriberPaths)[offerId], `${offerId} continuing invitation is in vstorage`, ); @@ -255,11 +256,10 @@ const channelCloseInitScenario = test.macro({ const address = accountStoragePath.split('.').pop(); t.log('Got address:', address); - const { - remoteAddress, - localAddress, - }: CosmosOrchestrationAccountStorageState = - await vstorageClient.queryData(accountStoragePath); + const { remoteAddress, localAddress } = + (await smartWalletKit.readLatestHead( + accountStoragePath, + )) as CosmosOrchestrationAccountStorageState; const { rPortID, rChannelID, rConnectionID } = parseRemoteAddress(remoteAddress); const { lPortID, lChannelID, lConnectionID } = diff --git a/multichain-testing/test/send-anywhere.test.ts b/multichain-testing/test/send-anywhere.test.ts index df4bbdca8d6..83071908311 100644 --- a/multichain-testing/test/send-anywhere.test.ts +++ b/multichain-testing/test/send-anywhere.test.ts @@ -51,7 +51,7 @@ const sendAnywhereScenario = test.macro({ const { wallets, provisionSmartWallet, - vstorageClient, + smartWalletKit, retryUntilCondition, useChain, } = t.context; @@ -69,9 +69,7 @@ const sendAnywhereScenario = test.macro({ const doOffer = makeDoOffer(wdUser1); - const brands = await vstorageClient.queryData( - 'published.agoricNames.brand', - ); + const brands = await smartWalletKit.readPublished('agoricNames.brand'); const brand = Object.fromEntries(brands)[brandKw]; const apiUrl = await useChain(destChainName).getRestEndpoint(); diff --git a/multichain-testing/test/smart-wallet.test.ts b/multichain-testing/test/smart-wallet.test.ts index 22faec70baa..016d8c61cba 100644 --- a/multichain-testing/test/smart-wallet.test.ts +++ b/multichain-testing/test/smart-wallet.test.ts @@ -17,13 +17,13 @@ test.after(async t => { }); test('provision smart wallet', async t => { - const { wallets, provisionSmartWallet, vstorageClient, useChain } = t.context; + const { wallets, provisionSmartWallet, smartWalletKit, useChain } = t.context; const wallet = await provisionSmartWallet(wallets.user1, { BLD: 100n }); t.log('wallet', wallet); - const walletCurrent = await vstorageClient.queryData( - `published.wallet.${wallets.user1}.current`, + const walletCurrent = await smartWalletKit.readPublished( + `wallet.${wallets.user1}.current`, ); t.like(walletCurrent, { liveOffers: [], offerToPublicSubscriberPaths: [] }); diff --git a/multichain-testing/test/stake-ica.test.ts b/multichain-testing/test/stake-ica.test.ts index 7ef65ad33eb..b5b2dd473c0 100644 --- a/multichain-testing/test/stake-ica.test.ts +++ b/multichain-testing/test/stake-ica.test.ts @@ -43,7 +43,7 @@ const stakeScenario = test.macro(async (t, scenario: StakeIcaScenario) => { const { wallets, provisionSmartWallet, - vstorageClient, + smartWalletKit, retryUntilCondition, useChain, startContract, @@ -77,8 +77,8 @@ const stakeScenario = test.macro(async (t, scenario: StakeIcaScenario) => { const { offerToPublicSubscriberPaths: makeAccountPublicSubscriberPaths } = await retryUntilCondition( () => - vstorageClient.queryData( - `published.wallet.${wallets[scenario.wallet]}.current`, + smartWalletKit.readPublished( + `wallet.${wallets[scenario.wallet]}.current`, ), ({ offerToPublicSubscriberPaths }) => !!offerToPublicSubscriberPaths.length, @@ -92,6 +92,7 @@ const stakeScenario = test.macro(async (t, scenario: StakeIcaScenario) => { .split('.') .pop(); t.log('Got address:', address); + assert(address); t.regex( address, new RegExp(`^${scenario.expectedAddressPrefix}1`), @@ -142,11 +143,12 @@ const stakeScenario = test.macro(async (t, scenario: StakeIcaScenario) => { proposal: {}, }); - const latestWalletUpdate = await vstorageClient.queryData( - `published.wallet.${wallets[scenario.wallet]}`, + const latestWalletUpdate = await smartWalletKit.readPublished( + `wallet.${wallets[scenario.wallet]}`, ); t.log('latest wallet update', latestWalletUpdate); t.like( + // @ts-expect-error UpdateRecord may not have 'status' latestWalletUpdate.status, { id: delegateOfferId, diff --git a/multichain-testing/test/support.ts b/multichain-testing/test/support.ts index f71e2c112cc..6961a6a82b1 100644 --- a/multichain-testing/test/support.ts +++ b/multichain-testing/test/support.ts @@ -113,9 +113,9 @@ export const commonSetup = async (t: ExecutionContext) => { contractBuilder: string, builderOpts?: Record, ) => { - const { vstorageClient } = tools; + const { smartWalletKit } = tools; const instances = Object.fromEntries( - await vstorageClient.queryData(`published.agoricNames.instance`), + await smartWalletKit.readPublished(`agoricNames.instance`), ); if (contractName in instances) { return t.log('Contract found. Skipping installation...'); @@ -123,7 +123,7 @@ export const commonSetup = async (t: ExecutionContext) => { t.log('bundle and install contract', contractName); await deployBuilder(contractBuilder, builderOpts); await retryUntilCondition( - () => vstorageClient.queryData(`published.agoricNames.instance`), + () => smartWalletKit.readPublished(`agoricNames.instance`), res => contractName in Object.fromEntries(res), `${contractName} instance is available`, ); diff --git a/multichain-testing/tools/e2e-tools.js b/multichain-testing/tools/e2e-tools.js index 448f8b81895..d2aaed9cbac 100644 --- a/multichain-testing/tools/e2e-tools.js +++ b/multichain-testing/tools/e2e-tools.js @@ -553,7 +553,6 @@ export const makeE2ETools = async ( ); return { - vstorageClient, smartWalletKit, installBundles, runCoreEval: buildAndRunCoreEval, 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 fc11550bbf5..66b25c755e7 100644 --- a/packages/client-utils/src/types.d.ts +++ b/packages/client-utils/src/types.d.ts @@ -10,6 +10,7 @@ import type { CurrentWalletRecord, UpdateRecord, } from '@agoric/smart-wallet/src/smartWallet.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 = { @@ -34,4 +35,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/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/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); diff --git a/packages/fast-usdc/src/fast-usdc.contract.js b/packages/fast-usdc/src/fast-usdc.contract.js index 80f8c4a6df1..4b5bae9bd23 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/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/types.ts b/packages/fast-usdc/src/types.ts index 0d3701e9d82..2e4aea441ec 100644 --- a/packages/fast-usdc/src/types.ts +++ b/packages/fast-usdc/src/types.ts @@ -43,6 +43,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 { diff --git a/packages/fast-usdc/src/utils/deploy-config.js b/packages/fast-usdc/src/utils/deploy-config.js index 7b160a7996c..b1688d441a7 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'; */