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 4aecf11f3dc..d57798bc041 100644 --- a/multichain-testing/test/fast-usdc/fast-usdc.test.ts +++ b/multichain-testing/test/fast-usdc/fast-usdc.test.ts @@ -233,8 +233,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); diff --git a/multichain-testing/test/fast-usdc/noble-forwarding.test.ts b/multichain-testing/test/fast-usdc/noble-forwarding.test.ts index 3f797deb8e4..604c0d534d3 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, { config: '../config.fusdc.yaml' }); 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 13ad3ee2264..df1d87fc0b6 100644 --- a/multichain-testing/test/ica-channel-close.test.ts +++ b/multichain-testing/test/ica-channel-close.test.ts @@ -63,7 +63,7 @@ const intentionalCloseAccountScenario = test.macro({ const { wallets, provisionSmartWallet, - vstorageClient, + smartWalletKit, retryUntilCondition, useChain, } = t.context; @@ -90,8 +90,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`, ); @@ -104,11 +105,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( @@ -217,7 +217,7 @@ const channelCloseInitScenario = test.macro({ const { wallets, provisionSmartWallet, - vstorageClient, + smartWalletKit, retryUntilCondition, useChain, relayer, @@ -244,8 +244,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`, ); @@ -258,11 +259,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 c0d118734b7..82fdb942d13 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 a728c3851fd..2dc525991ba 100644 --- a/multichain-testing/test/support.ts +++ b/multichain-testing/test/support.ts @@ -119,9 +119,9 @@ export const commonSetup = async ( 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...'); @@ -129,7 +129,7 @@ export const commonSetup = async ( 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`, );