diff --git a/src/sections/web3-connect/accounts/Web3ConnectEvmAccount.tsx b/src/sections/web3-connect/accounts/Web3ConnectEvmAccount.tsx index 1ac9021e7..079af6f79 100644 --- a/src/sections/web3-connect/accounts/Web3ConnectEvmAccount.tsx +++ b/src/sections/web3-connect/accounts/Web3ConnectEvmAccount.tsx @@ -1,4 +1,4 @@ -import { useNavigate } from "@tanstack/react-location" +import { useNavigate, useSearch } from "@tanstack/react-location" import { Button } from "components/Button/Button" import { ComponentPropsWithoutRef, FC } from "react" import { useTranslation } from "react-i18next" @@ -21,6 +21,7 @@ export const Web3ConnectEvmAccount: FC< } = useWeb3ConnectStore() const { wallet } = useWallet() const navigate = useNavigate() + const search = useSearch() const isActive = currentAccount?.address === account.address @@ -36,7 +37,7 @@ export const Web3ConnectEvmAccount: FC< onClick={() => { setAccount(account) toggle() - navigate({ search: { account: undefined } }) + if (search.account) navigate({ search: { account: undefined } }) }} > = ({ balance, ...account }) => { const { account: currentAccount, setAccount, toggle } = useWeb3ConnectStore() const navigate = useNavigate() + const search = useSearch() const isActive = currentAccount?.address === account.address return ( @@ -18,7 +19,7 @@ export const Web3ConnectSubstrateAccount: React.FC< onClick={(account) => { setAccount(account) toggle() - navigate({ search: { account: undefined } }) + if (search.account) navigate({ search: { account: undefined } }) }} /> ) diff --git a/src/sections/web3-connect/constants/providers.ts b/src/sections/web3-connect/constants/providers.ts index e08965d73..05172ec84 100644 --- a/src/sections/web3-connect/constants/providers.ts +++ b/src/sections/web3-connect/constants/providers.ts @@ -6,6 +6,7 @@ export enum WalletProviderType { SubwalletEvm = "subwallet-evm", PolkadotJS = "polkadot-js", NovaWallet = "nova-wallet", + NovaWalletEvm = "nova-wallet-evm", TrustWallet = "trustwallet", BraveWallet = "bravewallet", Phantom = "phantom", @@ -20,6 +21,7 @@ export enum WalletProviderType { export const MOBILE_ONLY_PROVIDERS: WalletProviderType[] = [ WalletProviderType.NovaWallet, + WalletProviderType.NovaWalletEvm, ] export const DESKTOP_ONLY_PROVIDERS: WalletProviderType[] = [ @@ -30,6 +32,7 @@ export const EVM_PROVIDERS: WalletProviderType[] = [ WalletProviderType.MetaMask, WalletProviderType.TalismanEvm, WalletProviderType.SubwalletEvm, + WalletProviderType.NovaWalletEvm, //WalletProviderType.TrustWallet, WalletProviderType.BraveWallet, WalletProviderType.Phantom, diff --git a/src/sections/web3-connect/providers/Web3ConnectProviders.tsx b/src/sections/web3-connect/providers/Web3ConnectProviders.tsx index f67d8eeed..77973c143 100644 --- a/src/sections/web3-connect/providers/Web3ConnectProviders.tsx +++ b/src/sections/web3-connect/providers/Web3ConnectProviders.tsx @@ -117,7 +117,7 @@ const useWalletProviders = (mode: WalletMode, chain?: string) => { otherProviders, alternativeProviders, } - }, [isDesktop, mode, chain]) + }, [mode, isDesktop, chain]) } export const Web3ConnectProviders = () => { diff --git a/src/sections/web3-connect/wallets/NovaWalletEvm.ts b/src/sections/web3-connect/wallets/NovaWalletEvm.ts new file mode 100644 index 000000000..cbf455961 --- /dev/null +++ b/src/sections/web3-connect/wallets/NovaWalletEvm.ts @@ -0,0 +1,23 @@ +import NovaWalletLogo from "assets/icons/NovaWallet.svg" + +import { MetaMask } from "./MetaMask" +import { isNovaWalletEvm } from "utils/metamask" +import { WalletProviderType } from "sections/web3-connect/Web3Connect.utils" + +export class NovaWalletEvm extends MetaMask { + extensionName = WalletProviderType.NovaWalletEvm + title = "Nova Wallet EVM" + installUrl = "https://novawallet.io" + logo = { + src: NovaWalletLogo, + alt: "Nova Wallet Logo", + } + + get installed() { + return isNovaWalletEvm(window.ethereum) + } + + get rawExtension() { + return window.ethereum + } +} diff --git a/src/sections/web3-connect/wallets/index.ts b/src/sections/web3-connect/wallets/index.ts index 203664762..71db76e24 100644 --- a/src/sections/web3-connect/wallets/index.ts +++ b/src/sections/web3-connect/wallets/index.ts @@ -5,6 +5,7 @@ import { MetaMask } from "./MetaMask" import { Talisman } from "./Talisman" import { TalismanEvm } from "./TalismanEvm" import { NovaWallet } from "./NovaWallet" +import { NovaWalletEvm } from "./NovaWalletEvm" import { WalletConnect } from "./WalletConnect" import { H160, isEvmAddress } from "utils/evm" import { SubWalletEvm } from "./SubWalletEvm" @@ -48,6 +49,9 @@ const onMetaMaskLikeAccountChange = } const novaWallet: Wallet = new NovaWallet() +const novaWalletEvm: Wallet = new NovaWalletEvm({ + onAccountsChanged: onMetaMaskLikeAccountChange(WalletProviderType.NovaWallet), +}) const talisman = new Talisman() const talismanEvm: Wallet = new TalismanEvm({ @@ -99,6 +103,7 @@ export let SUPPORTED_WALLET_PROVIDERS: WalletProvider[] = [ subwallet, trustWallet, novaWallet, + novaWalletEvm, walletConnect, externalWallet, ].map((wallet) => ({ diff --git a/src/utils/metamask.ts b/src/utils/metamask.ts index b3f8372f7..3987df19c 100644 --- a/src/utils/metamask.ts +++ b/src/utils/metamask.ts @@ -10,6 +10,7 @@ const METAMASK_LIKE_CHECKS = [ "isTalisman", "isSubWallet", "isPhantom", + "isNovaWallet", "isTrust", "isBraveWallet", "isEnkrypt", @@ -89,6 +90,12 @@ export function isPhantom(provider: Maybe) { return isMetaMaskLike(provider) && !!provider?.isPhantom } +export function isNovaWalletEvm( + provider: Maybe, +): provider is Required { + return isMetaMaskLike(provider) && !!provider?.isNovaWallet +} + export function isTrustWallet(provider: Maybe) { return isMetaMaskLike(provider) && !!provider?.isTrust }