Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
yanok87 committed Oct 31, 2023
1 parent bcc450e commit 4fa5a1a
Show file tree
Hide file tree
Showing 5 changed files with 1,304 additions and 1,095 deletions.
9 changes: 6 additions & 3 deletions explorer/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
},
"dependencies": {
"@cosmjs/math": "^0.26.2",
"@cosmos-kit/keplr": "^2.4.4",
"@cosmos-kit/react": "^2.9.3",
"@cosmos-kit/keplr": "^2.3.11",
"@cosmos-kit/react": "^2.8.2",
"@emotion/react": "^11.4.1",
"@emotion/styled": "^11.3.0",
"@mui/icons-material": "^5.0.0",
Expand All @@ -33,7 +33,7 @@
"@nymproject/react": "^1.0.0",
"big.js": "^6.2.1",
"buffer": "^6.0.3",
"chain-registry": "^1.20.0",
"chain-registry": "^1.19.0",
"d3-scale": "^4.0.0",
"date-fns": "^2.24.0",
"i18n-iso-countries": "^6.8.0",
Expand Down Expand Up @@ -114,6 +114,9 @@
"webpack-favicons": "^1.3.8",
"webpack-merge": "^5.8.0"
},



"browserslist": {
"production": [
">0.2%",
Expand Down
23 changes: 9 additions & 14 deletions explorer/src/components/ConnectKeplrWallet.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import { useChain, useWallet, ChainProvider } from '@cosmos-kit/react';
import { useChain } from '@cosmos-kit/react';
import { Box, Button, Card } from '@mui/material';
import Big from 'big.js';

import { useEffect, useState, useMemo } from 'react';

import '@interchain-ui/react/styles';

export function useIsClient() {
const [isClient, setIsClient] = useState(false);

Expand All @@ -28,17 +30,10 @@ export const uNYMtoNYM = (unym: string, rounding = 6) => {
};

export default function ConnectKeplrWallet() {
const { username, connect, disconnect, wallet, openView, address, getCosmWasmClient } = useChain('nyx');
const { status: globalStatus, mainWallet } = useWallet(); // status here is the global wallet status for all activated chains (chain is activated when call useChain)
const { username, connect, disconnect, wallet, openView, address, getCosmWasmClient, isWalletConnected } =
useChain('nyx');
const isClient = useIsClient();

useEffect(() => {
const fn = async () => {
await mainWallet?.connect();
};
fn();
}, []);

const [balance, setBalance] = useState<{
status: 'loading' | 'success';
data?: string;
Expand All @@ -65,10 +60,10 @@ export default function ConnectKeplrWallet() {
if (!isClient) return null;

const getGlobalbutton = () => {
if (globalStatus === 'Connecting') {
return <Button onClick={() => connect()}>{`Connecting ${wallet?.prettyName}`}</Button>;
}
if (globalStatus === 'Connected') {
// if (globalStatus === 'Connecting') {
// return <Button onClick={() => connect()}>{`Connecting ${wallet?.prettyName}`}</Button>;
// }
if (isWalletConnected) {
return (
<Box display={'flex'} alignItems={'center'}>
<Button onClick={() => openView()}>
Expand Down
6 changes: 4 additions & 2 deletions explorer/src/components/Nav.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,11 @@ import { DarkLightSwitchDesktop } from './Switch';
import { NavOptionType } from '../context/nav';
import ConnectKeplrWallet from './ConnectKeplrWallet';
import { assets, chains } from 'chain-registry';
import { useChain, useWallet, ChainProvider } from '@cosmos-kit/react';
import { ChainProvider } from '@cosmos-kit/react';
import { wallets as keplr } from '@cosmos-kit/keplr';
import { useEffect, useState, useMemo } from 'react';
import { useMemo } from 'react';

import '@interchain-ui/react/styles';

const drawerWidth = 255;
const bannerHeight = 80;
Expand Down
1 change: 0 additions & 1 deletion explorer/src/routes/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import { PageOverview } from '../pages/Overview';
import { PageMixnodesMap } from '../pages/MixnodesMap';
import { Page404 } from '../pages/404';
import { NetworkComponentsRoutes } from './network-components';
import ConnectKeplrWallet from '../components/ConnectKeplrWallet';

export const Routes: FCWithChildren = () => (
<ReactRouterRoutes>
Expand Down
Loading

0 comments on commit 4fa5a1a

Please sign in to comment.