Skip to content

Commit

Permalink
Revert "use Telescope-based cosmic-proto" (#253)
Browse files Browse the repository at this point in the history
  • Loading branch information
samsiegart authored Mar 14, 2024
1 parent b2f624b commit 76acfef
Show file tree
Hide file tree
Showing 8 changed files with 357 additions and 222 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
},
"dependencies": {
"@agoric/casting": "^0.4.3-u13.0",
"@agoric/cosmic-proto": "^0.4.1-dev-c5284e4.0",
"@agoric/cosmic-proto": "^0.3.0",
"@agoric/ertp": "^0.16.2",
"@agoric/inter-protocol": "^0.16.1",
"@agoric/rpc": "^0.9.0",
Expand Down
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;
}
Loading

0 comments on commit 76acfef

Please sign in to comment.