Skip to content

[READY] filter out Nova Wallet option if not in the Nova app #635

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

Merged
Merged
23 changes: 22 additions & 1 deletion frontend/src/hooks/useConnectPolkadotWallet/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,33 @@ import { storageService } from '../../services/storage/local';
import { LocalStorageKeys } from '../useLocalStorage';
import { useToastMessage } from '../../helpers/notifications';

declare global {
interface Window {
walletExtension: {
isNovaWallet: boolean;
};
}
}

const alwaysShowWallets = ['talisman', 'subwallet-js', 'polkadot-js'];

function filterNovaWallet(wallet: Wallet) {
const isNovaWallet = window.walletExtension?.isNovaWallet;
return isNovaWallet ? true : wallet.title !== 'Nova Wallet';
}

function getFilteredWallets() {
const wallets = getWallets();

return wallets
.filter((wallet) => alwaysShowWallets.includes(wallet.extensionName) || wallet.installed)
.filter(filterNovaWallet);
}

export const useConnectPolkadotWallet = () => {
const [selectedWallet, setSelectedWallet] = useState<Wallet | undefined>();
const { showToast, ToastMessage } = useToastMessage();
const wallets = getWallets().filter((wallet) => alwaysShowWallets.includes(wallet.extensionName) || wallet.installed);
const wallets = getFilteredWallets();

const {
mutate: selectWallet,
Expand Down
Loading