Skip to content

Commit

Permalink
fix: Fixed multiple wallets conficts resulting in undetectable issues. (
Browse files Browse the repository at this point in the history
#51)

* docs: Add test result table to PULL_REQUEST_TEMPLATE

* fix: fixed multiple wallet conflicts resulting in undetectable issues

* chore: Add changeset log
  • Loading branch information
wenty22 authored Dec 4, 2023
1 parent 27335c0 commit 78c9fc8
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 20 deletions.
5 changes: 5 additions & 0 deletions .changeset/honest-numbers-hug.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@totejs/walletkit': patch
---

Fixed multiple wallets conficts resulting in undetectable issues.
22 changes: 12 additions & 10 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,17 +33,19 @@

## For adding a new wallet

For more detail, please click [here](../CONTRIBUTING.md#notice-test-cases-for-adding-a-new-wallet)

<!--- If you are adding a new wallet, we hope you can complete the following tests before the code is merged into the main branch -->
|test case|support?|connected?|switch networks?|support testnet?|
|-|-|-|-|-|
|PC, browser extension|[ ]|[ ]|[ ]|[ ]|
|Android, in system browser|[ ]|[ ]|[ ]|[ ]|
|Android, in wallet dapp browser|[ ]|[ ]|[ ]|[ ]|
|iOS, in system browser|[ ]|[ ]|[ ]|[ ]|
|iOS, in wallet dapp browser|[ ]|[ ]|[ ]|[ ]|
|WalletConnect, PC|[ ]|[ ]|[ ]|[ ]|
|WalletConnect, Android, in system browser|[ ]|[ ]|[ ]|[ ]|
|WalletConnect, Android, in wallet dapp browser|[ ]|[ ]|[ ]|[ ]|
|WalletConnect, iOS, in system browser|[ ]|[ ]|[ ]|[ ]|
|WalletConnect, iOS, in wallet dapp browser|[ ]|[ ]|[ ]|[ ]|
|PC, browser extension| ✔️ | ✔️ |||
|Android, in system browser| | | | |
|Android, in wallet dapp browser| | | | |
|iOS, in system browser| | | | |
|iOS, in wallet dapp browser| | | | |
|WalletConnect, PC| | | | |
|WalletConnect, Android, in system browser| | | | |
|WalletConnect, Android, in wallet dapp browser| | | | |
|WalletConnect, iOS, in system browser| | | | |
|WalletConnect, iOS, in wallet dapp browser| | | | |

2 changes: 1 addition & 1 deletion packages/walletkit/src/wallets/coinbaseWallet/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,5 +56,5 @@ export function coinbaseWallet(props: CoinbaseWalletProps = {}): WalletProps {
export function isCoinbaseWallet() {
if (typeof window === 'undefined') return false;

return hasInjectedProvider('isCoinbaseWallet');
return hasInjectedProvider('isCoinbaseWallet') || !!window.coinbaseWalletExtension;
}
14 changes: 7 additions & 7 deletions packages/walletkit/src/wallets/metaMask/index.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { Chain, Connector } from 'wagmi';
import { MetaMaskConnector } from 'wagmi/connectors/metaMask';
import { PartialWalletProps, WalletProps, isTokenPocket } from '..';
import { PartialWalletProps, WalletProps } from '..';
import { MetaMaskIcon, MetaMaskTransparentIcon } from './icon';
import { getInjectedProvider, hasInjectedProvider } from '../utils';

export const META_MASK_ID = 'metaMask';

Expand Down Expand Up @@ -35,8 +36,11 @@ export function metaMask(props: MetaMaskProps = {}): WalletProps {
options: {
shimDisconnect: true,
UNSTABLE_shimOnConnectSelectAccount: false,
getProvider() {
return getInjectedProvider('isMetaMask');
},
...connectorOptions,
},
} as any,
});
},
getDeepLink: () => {
Expand All @@ -51,11 +55,7 @@ export function metaMask(props: MetaMaskProps = {}): WalletProps {
}

export function isMetaMask() {
if (typeof window === 'undefined') return false;

if (isTokenPocket()) return false;

return window?.ethereum?.isMetaMask;
return hasInjectedProvider('isMetaMask');
}

export function isMetaMaskConnector(connector?: Connector) {
Expand Down
8 changes: 6 additions & 2 deletions packages/walletkit/src/wallets/tokenPocket/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,11 @@ export function tokenPocket(props: PartialCustomProps = {}): WalletProps {
getProvider() {
if (typeof window === 'undefined') return;

const provider = getInjectedProvider('isTokenPocket') ?? window.tokenpocket;
const provider =
getInjectedProvider('isTokenPocket') ??
window.tokenpocket?.ethereum ??
window.tokenpocket;

return provider;
},
...connectorOptions,
Expand All @@ -55,5 +59,5 @@ export function tokenPocket(props: PartialCustomProps = {}): WalletProps {
export function isTokenPocket() {
if (typeof window === 'undefined') return false;

return hasInjectedProvider('isTokenPocket') || window.tokenpocket;
return hasInjectedProvider('isTokenPocket') || window.tokenpocket?.ethereum || window.tokenpocket;
}

0 comments on commit 78c9fc8

Please sign in to comment.