Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nova Wallet EVM #1448

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
5 changes: 3 additions & 2 deletions src/sections/web3-connect/accounts/Web3ConnectEvmAccount.tsx
Original file line number Diff line number Diff line change
@@ -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"
Expand All @@ -21,6 +21,7 @@ export const Web3ConnectEvmAccount: FC<
} = useWeb3ConnectStore()
const { wallet } = useWallet()
const navigate = useNavigate()
const search = useSearch()

const isActive = currentAccount?.address === account.address

Expand All @@ -36,7 +37,7 @@ export const Web3ConnectEvmAccount: FC<
onClick={() => {
setAccount(account)
toggle()
navigate({ search: { account: undefined } })
if (search.account) navigate({ search: { account: undefined } })
}}
>
<Web3ConnectAccountSelect
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
import { ComponentPropsWithoutRef } from "react"
import { useWeb3ConnectStore } from "sections/web3-connect/store/useWeb3ConnectStore"
import { useNavigate } from "@tanstack/react-location"
import { useNavigate, useSearch } from "@tanstack/react-location"
import { Web3ConnectAccount } from "./Web3ConnectAccount"

export const Web3ConnectSubstrateAccount: React.FC<
ComponentPropsWithoutRef<typeof Web3ConnectAccount>
> = ({ balance, ...account }) => {
const { account: currentAccount, setAccount, toggle } = useWeb3ConnectStore()
const navigate = useNavigate()
const search = useSearch()
const isActive = currentAccount?.address === account.address

return (
Expand All @@ -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 } })
}}
/>
)
Expand Down
3 changes: 3 additions & 0 deletions src/sections/web3-connect/constants/providers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -20,6 +21,7 @@ export enum WalletProviderType {

export const MOBILE_ONLY_PROVIDERS: WalletProviderType[] = [
WalletProviderType.NovaWallet,
WalletProviderType.NovaWalletEvm,
]

export const DESKTOP_ONLY_PROVIDERS: WalletProviderType[] = [
Expand All @@ -30,6 +32,7 @@ export const EVM_PROVIDERS: WalletProviderType[] = [
WalletProviderType.MetaMask,
WalletProviderType.TalismanEvm,
WalletProviderType.SubwalletEvm,
WalletProviderType.NovaWalletEvm,
//WalletProviderType.TrustWallet,
WalletProviderType.BraveWallet,
WalletProviderType.Phantom,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ const useWalletProviders = (mode: WalletMode, chain?: string) => {
otherProviders,
alternativeProviders,
}
}, [isDesktop, mode, chain])
}, [mode, isDesktop, chain])
}

export const Web3ConnectProviders = () => {
Expand Down
23 changes: 23 additions & 0 deletions src/sections/web3-connect/wallets/NovaWalletEvm.ts
Original file line number Diff line number Diff line change
@@ -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
}
}
5 changes: 5 additions & 0 deletions src/sections/web3-connect/wallets/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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({
Expand Down Expand Up @@ -99,6 +103,7 @@ export let SUPPORTED_WALLET_PROVIDERS: WalletProvider[] = [
subwallet,
trustWallet,
novaWallet,
novaWalletEvm,
walletConnect,
externalWallet,
].map((wallet) => ({
Expand Down
7 changes: 7 additions & 0 deletions src/utils/metamask.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ const METAMASK_LIKE_CHECKS = [
"isTalisman",
"isSubWallet",
"isPhantom",
"isNovaWallet",
"isTrust",
"isBraveWallet",
"isEnkrypt",
Expand Down Expand Up @@ -89,6 +90,12 @@ export function isPhantom(provider: Maybe<ExternalProvider>) {
return isMetaMaskLike(provider) && !!provider?.isPhantom
}

export function isNovaWalletEvm(
provider: Maybe<ExternalProvider>,
): provider is Required<MetaMaskLikeProvider> {
return isMetaMaskLike(provider) && !!provider?.isNovaWallet
}

export function isTrustWallet(provider: Maybe<ExternalProvider>) {
return isMetaMaskLike(provider) && !!provider?.isTrust
}
Expand Down
Loading