Skip to content

Commit

Permalink
fix(dcellar-web-ui): fix no wallet link & tips (#176)
Browse files Browse the repository at this point in the history
  • Loading branch information
wenty22 authored Aug 30, 2023
1 parent d89f1d7 commit 144a4f4
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ import { useWallet } from '@/context/WalletConnectContext/hooks/useWallet';
import { GREENFIELD_CHAIN_ID } from '@/base/env';
import { useCallback, useEffect, useState } from 'react';
import { ConnectorNotFoundError } from 'wagmi';
import { InjectedConnector } from 'wagmi/connectors/injected';
import { MetaMaskConnector } from 'wagmi/connectors/metaMask';
import { useAppLogin } from '@/modules/welcome/hooks/useAppLogin';
import { useAppSelector } from '@/store';

Expand All @@ -32,9 +30,9 @@ export function WalletConnectModal(props: WalletConnectModalProps) {
if (err instanceof ConnectorNotFoundError) {
const { connector } = args;

if (connector instanceof InjectedConnector && connector.name === 'Trust Wallet') {
if (connector.id === 'trust') {
window.open(TRUST_WALLET_DOWNLOAD_URL, '_blank');
} else if (connector instanceof MetaMaskConnector) {
} else if (connector.id === 'metaMask') {
window.open(METAMASK_DOWNLOAD_URL, '_blank');
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export type TrustWalletConnectorOptions = {
}

export class TrustWalletConnector extends WagmiMetaMaskConnector {
readonly id: any = 'trustWallet';
readonly id: any = 'trust';

constructor({
chains,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,16 @@
import { ErrorMsgMap } from '@/context/WalletConnectContext/error/error';
import { toast } from '@totejs/uikit';
import { ConnectorNotFoundError } from 'wagmi';
import { InjectedConnector } from 'wagmi/connectors/injected';
import { MetaMaskConnector } from 'wagmi/connectors/metaMask';

export function handleWalletError(err: any, args: any, context: unknown) {
let text = '';

switch (true) {
case err instanceof ConnectorNotFoundError:
const { connector } = args;
if (connector instanceof MetaMaskConnector) {
if (connector.id === 'metaMask') {
text = `Metamask not installed. Please install and reconnect.`;
} else if (connector instanceof InjectedConnector && connector.name === 'Trust Wallet') {
} else if (connector.id === 'trust') {
text = `Trust wallet not installed. Please install and reconnect.`;
} else {
text = `Wallet not installed. Please install and reconnect.`;
Expand Down

0 comments on commit 144a4f4

Please sign in to comment.