Skip to content

Commit

Permalink
refactor: use agoric.ClientFactory
Browse files Browse the repository at this point in the history
  • Loading branch information
turadg committed Mar 7, 2024
1 parent f84d6f4 commit a9b4873
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 19 deletions.
10 changes: 7 additions & 3 deletions src/components/ProvisionSmartWalletNoticeDialog.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import { agoric } from '@agoric/cosmic-proto';
import { useAtomValue } from 'jotai';
import { useEffect, useState } from 'react';
import { rpcNodeAtom } from 'store/app';
import { agoric } from '@agoric/cosmic-proto';
import { querySwingsetParams } from 'utils/swingsetParams';
import ActionsDialog from './ActionsDialog';

const useSmartWalletFeeQuery = (rpc: string | null) => {
Expand All @@ -13,14 +12,19 @@ const useSmartWalletFeeQuery = (rpc: string | null) => {
const fetchParams = async () => {
assert(rpc);
try {
const params = await querySwingsetParams(rpc);
const client = await agoric.ClientFactory.createRPCQueryClient({
rpcEndpoint: rpc,
});
const params = await client.agoric.swingset.params();
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
16 changes: 0 additions & 16 deletions src/utils/swingsetParams.ts

This file was deleted.

0 comments on commit a9b4873

Please sign in to comment.