Skip to content

Commit

Permalink
Merge branch 'main' into rs-inter-dapp-test-cases
Browse files Browse the repository at this point in the history
  • Loading branch information
rabi-siddique committed Mar 14, 2024
2 parents 9ad9490 + 76acfef commit ad58629
Show file tree
Hide file tree
Showing 7 changed files with 34 additions and 11 deletions.
Original file line number Diff line number Diff line change
@@ -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
Expand Down
9 changes: 2 additions & 7 deletions src/components/ProvisionSmartWalletNoticeDialog.tsx
Original file line number Diff line number Diff line change
@@ -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) => {
Expand All @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion src/store/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
4 changes: 2 additions & 2 deletions src/store/vaults.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand Down
21 changes: 21 additions & 0 deletions src/utils/swingsetParams.ts
Original file line number Diff line number Diff line change
@@ -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<typeof QueryParamsResponse> => {
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({});
};
5 changes: 5 additions & 0 deletions src/vite-env.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
3 changes: 2 additions & 1 deletion vitest.config.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import { mergeConfig } from 'vite';
import { defineConfig } from 'vitest/config';
import { defineConfig, configDefaults } from 'vitest/config';
import viteConfig from './vite.config';

export default mergeConfig(
viteConfig,
defineConfig({
test: {
environment: 'happy-dom',
exclude: [...configDefaults.exclude, 'tests/e2e/**'],
},
}),
);

0 comments on commit ad58629

Please sign in to comment.