diff --git a/patches/vitest+0.32.2.patch b/patches/vitest+0.32.0.patch similarity index 96% rename from patches/vitest+0.32.2.patch rename to patches/vitest+0.32.0.patch index 72438d35..d5b68abc 100644 --- a/patches/vitest+0.32.2.patch +++ b/patches/vitest+0.32.0.patch @@ -1,3 +1,4 @@ +# UNTIL https://github.com/vitest-dev/vitest/pull/3527 diff --git a/node_modules/vitest/dist/vendor-rpc.4d3d7a54.js b/node_modules/vitest/dist/vendor-rpc.4d3d7a54.js index c98baeb..e365e91 100644 --- a/node_modules/vitest/dist/vendor-rpc.4d3d7a54.js diff --git a/src/components/ProvisionSmartWalletNoticeDialog.tsx b/src/components/ProvisionSmartWalletNoticeDialog.tsx index 7c377c58..e86f024c 100644 --- a/src/components/ProvisionSmartWalletNoticeDialog.tsx +++ b/src/components/ProvisionSmartWalletNoticeDialog.tsx @@ -1,7 +1,7 @@ -import { agoric } from '@agoric/cosmic-proto'; import { useAtomValue } from 'jotai'; import { useEffect, useState } from 'react'; import { rpcNodeAtom } from 'store/app'; +import { querySwingsetParams } from 'utils/swingsetParams'; import ActionsDialog from './ActionsDialog'; const useSmartWalletFeeQuery = (rpc: string | null) => { @@ -12,19 +12,14 @@ const useSmartWalletFeeQuery = (rpc: string | null) => { const fetchParams = async () => { assert(rpc); try { - const client = await agoric.ClientFactory.createRPCQueryClient({ - rpcEndpoint: rpc, - }); - const params = await client.agoric.swingset.params(); + const params = await querySwingsetParams(rpc); console.debug('swingset params', params); const beansPerSmartWallet = params.params.beansPerUnit.find( ({ key }: { key: string }) => key === 'smartWalletProvision', )?.beans; - assert(beansPerSmartWallet); const feeUnit = params.params.beansPerUnit.find( ({ key }: { key: string }) => key === 'feeUnit', )?.beans; - assert(feeUnit); setFee(BigInt(beansPerSmartWallet) / BigInt(feeUnit)); } catch (e) { setError(e as Error); diff --git a/src/store/app.ts b/src/store/app.ts index 7aadba4d..09c0d7da 100644 --- a/src/store/app.ts +++ b/src/store/app.ts @@ -7,7 +7,7 @@ import { import { atom } from 'jotai'; import { atomWithStorage } from 'jotai/utils'; import { atomWithStore } from 'jotai-zustand'; -import { createStore } from 'zustand/vanilla'; +import createStore from 'zustand/vanilla'; import { persist } from 'zustand/middleware'; import { makeDisplayFunctions } from 'utils/displayFunctions'; import { makeWalletService } from 'service/wallet'; diff --git a/src/store/vaults.ts b/src/store/vaults.ts index 76295b89..54fbaa12 100644 --- a/src/store/vaults.ts +++ b/src/store/vaults.ts @@ -1,5 +1,5 @@ -import { createStore } from 'zustand/vanilla'; -import { create } from 'zustand'; +import createStore from 'zustand/vanilla'; +import create from 'zustand'; import type { Brand, Amount } from '@agoric/ertp/src/types'; import { atom } from 'jotai'; import { getPriceDescription } from '@agoric/zoe/src/contractSupport'; diff --git a/src/utils/swingsetParams.ts b/src/utils/swingsetParams.ts new file mode 100644 index 00000000..40bc3b39 --- /dev/null +++ b/src/utils/swingsetParams.ts @@ -0,0 +1,21 @@ +import { QueryClient, createProtobufRpcClient } from '@cosmjs/stargate'; +import { + QueryClientImpl, + QueryParamsResponse, +} from '@agoric/cosmic-proto/swingset/query.js'; +import { HttpClient, Tendermint34Client } from '@cosmjs/tendermint-rpc'; + +/** + * Query swingset params. + */ +export const querySwingsetParams = async ( + endpoint: string, +): Promise => { + const http = new HttpClient(endpoint); + const trpc = await Tendermint34Client.create(http); + const base = QueryClient.withExtensions(trpc); + const rpc = createProtobufRpcClient(base); + const queryService = new QueryClientImpl(rpc); + + return queryService.Params({}); +}; diff --git a/src/vite-env.d.ts b/src/vite-env.d.ts index 7d7f1cc6..9a1ad543 100644 --- a/src/vite-env.d.ts +++ b/src/vite-env.d.ts @@ -45,3 +45,8 @@ declare module '@agoric/inter-protocol/src/vaultFactory/math' { declare module 'react-view-slider' { export const ViewSlider; } + +declare module '@agoric/cosmic-proto/swingset/query.js' { + export const QueryClientImpl; + export const QueryParamsResponse; +} diff --git a/vitest.config.ts b/vitest.config.ts index 101e633c..3860d826 100644 --- a/vitest.config.ts +++ b/vitest.config.ts @@ -1,5 +1,5 @@ import { mergeConfig } from 'vite'; -import { defineConfig } from 'vitest/config'; +import { defineConfig, configDefaults } from 'vitest/config'; import viteConfig from './vite.config'; export default mergeConfig( @@ -7,6 +7,10 @@ export default mergeConfig( defineConfig({ test: { environment: 'happy-dom', + exclude: [ + ...configDefaults.exclude, + 'tests/e2e/**' + ] }, }), );