From 6b3bcc65b2813b9f8454826ac7bc31300720dbef Mon Sep 17 00:00:00 2001 From: Martin Dobrev Date: Thu, 11 Jan 2024 11:23:01 +0200 Subject: [PATCH] Wallet type warning added --- src/components/Header.tsx | 38 ++++++++++++++++++++++++++++++++++++-- src/interfaces/common.ts | 5 +++++ 2 files changed, 41 insertions(+), 2 deletions(-) diff --git a/src/components/Header.tsx b/src/components/Header.tsx index 43fd5bdf..425d4696 100644 --- a/src/components/Header.tsx +++ b/src/components/Header.tsx @@ -1,15 +1,20 @@ -import React, { useCallback, useContext, useEffect, useState } from 'react'; +import { useCallback, useContext, useEffect, useState } from 'react'; import { hethers } from '@hashgraph/hethers'; import { GlobalContext } from '../providers/Global'; import { Md5 } from 'ts-md5/dist/md5'; +import Tippy from '@tippyjs/react'; +import axios from 'axios'; import Button from './Button'; import Modal from './Modal'; +import Icon from './Icon'; import ConnectModalContent from './Modals/ConnectModalContent'; import UserAccountModalContent from './Modals/UserAccountModalContent'; import { formatHBARStringToPrice, formatStringETHtoPriceFormatted } from '../utils/numberUtils'; +import { KeyType } from '../interfaces/common'; + import { BALLANCE_FETCH_INTERVAL, useQueryOptionsProvideSwapRemove } from '../constants'; import usePoolsByTokensList from '../hooks/usePoolsByTokensList'; @@ -58,6 +63,7 @@ const Header = () => { const [showUserAccountModal, setShowUserAccountModal] = useState(false); const [userBalance, setUserBalance] = useState('0.0'); + const [keyType, setKeyType] = useState(); const handleConnectButtonClick = () => { setShowConnectModal(true); @@ -91,6 +97,21 @@ const Header = () => { }; }, [getUserTokensData]); + useEffect(() => { + const getUserAccountType = async (userId: string) => { + const url = `${process.env.REACT_APP_MIRROR_NODE_URL}/api/v1/accounts/${userId}`; + try { + const { data } = await axios(url); + setKeyType(data.key._type); + } catch (e) { + console.error(e); + return 0; + } + }; + + userId && getUserAccountType(userId); + }, [userId]); + return (
@@ -162,7 +183,20 @@ const Header = () => { className="container-address mt-2 mt-sm-0" onClick={() => setShowUserAccountModal(true)} > -
{userId}
+
+ {userId} +
+ {keyType === KeyType.ECDSA_SECP256K1 ? ( + + + + + + ) : null}