Skip to content

Commit

Permalink
Add Tokenary (#415)
Browse files Browse the repository at this point in the history
  • Loading branch information
grachyov authored and tmm committed May 5, 2022
1 parent 3d41aaa commit 01d3be9
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 6 deletions.
5 changes: 3 additions & 2 deletions packages/core/src/connectors/metaMask.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,9 @@ export class MetaMaskConnector extends InjectedConnector {

#getReady(ethereum?: Ethereum) {
const isMetaMask = !!ethereum?.isMetaMask
// Brave Wallet tries to make itself look like MetaMask
if (isMetaMask && !ethereum.isBraveWallet) return ethereum
// Some wallets (e.g. Brave Wallet) try to make themselves look like MetaMask
const notOtherWallet = !ethereum.isBraveWallet && !ethereum.isTokenary
if (isMetaMask && notOtherWallet) return ethereum
}

#findProvider(ethereum?: Ethereum) {
Expand Down
1 change: 1 addition & 0 deletions packages/core/src/types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ declare global {
isFrame?: true
isMetaMask?: true
isTally?: true
isTokenary?: true
isTrust?: true
}

Expand Down
5 changes: 3 additions & 2 deletions packages/core/src/utils/getInjectedName.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,14 @@ import { getInjectedName } from './getInjectedName'
describe.each`
ethereum | expected
${undefined} | ${'Injected'}
${{ isBraveWallet: true, isMetaMask: true }} | ${'Brave Wallet'}
${{ isMetaMask: true }} | ${'MetaMask'}
${{ isBraveWallet: true }} | ${'Brave Wallet'}
${{ isBraveWallet: true, isMetaMask: true }} | ${'Brave Wallet'}
${{ isCoinbaseWallet: true }} | ${'Coinbase Wallet'}
${{ isFrame: true }} | ${'Frame'}
${{ isTally: true }} | ${'Tally'}
${{ isTokenary: true, isMetaMask: true }} | ${'Tokenary'}
${{ isTrust: true }} | ${'Trust Wallet'}
${{ isMetaMask: true }} | ${'MetaMask'}
${{ providers: [{ isMetaMask: true }, { isCoinbaseWallet: true }] }} | ${['MetaMask', 'Coinbase Wallet']}
${{ providers: [{ isMetaMask: true }, { isFooWallet: true }, {}] }} | ${['MetaMask', 'Unknown Wallet #1', 'Unknown Wallet #2']}
${{}} | ${'Injected'}
Expand Down
5 changes: 3 additions & 2 deletions packages/core/src/utils/getInjectedName.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,17 @@ export function getInjectedName(ethereum?: Window['ethereum']) {
if (!ethereum) return 'Injected'

const getName = (provider: Ethereum) => {
if (provider.isMetaMask && !provider.isBraveWallet) return 'MetaMask'
if (provider.isBraveWallet) return 'Brave Wallet'
if (provider.isCoinbaseWallet) return 'Coinbase Wallet'
if (provider.isFrame) return 'Frame'
if (provider.isTally) return 'Tally'
if (provider.isTokenary) return 'Tokenary'
if (provider.isTrust) return 'Trust Wallet'
if (provider.isMetaMask) return 'MetaMask'
}

if (ethereum.providers?.length) {
// Deduplicated names using Set
// Deduplicate names using Set
// Coinbase Wallet puts multiple providers in `ethereum.providers`
const nameSet = new Set<string>()
let unknownCount = 1
Expand Down

1 comment on commit 01d3be9

@vercel
Copy link

@vercel vercel bot commented on 01d3be9 May 5, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

wagmi – ./

wagmi-zoo.vercel.app
wagmi-xyz.vercel.app
wagmi-git-main-zoo.vercel.app
www.wagmi.sh
wagmi.sh

Please sign in to comment.