File tree Expand file tree Collapse file tree 4 files changed +47
-11
lines changed
wallets/provider-metamask/src Expand file tree Collapse file tree 4 files changed +47
-11
lines changed Original file line number Diff line number Diff line change @@ -20,7 +20,7 @@ import {
20
20
import { evmBlockchains } from 'rango-types' ;
21
21
22
22
import signer from '../signer.js' ;
23
- import { metamask as metamask_instance , type Provider } from '../utils.js' ;
23
+ import { metamask as metamask_instance } from '../utils.js' ;
24
24
25
25
const WALLET = WalletTypes . META_MASK ;
26
26
@@ -49,7 +49,8 @@ export const subscribe: Subscribe = subscribeToEvm;
49
49
export const switchNetwork : SwitchNetwork = switchNetworkForEvm ;
50
50
51
51
export const canSwitchNetworkTo : CanSwitchNetwork = canSwitchNetworkToEvm ;
52
-
52
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
53
+ type Provider = any ;
53
54
export const getSigners : ( provider : Provider ) => Promise < SignerFactory > =
54
55
signer ;
55
56
Original file line number Diff line number Diff line change 1
- import type { Provider } from './utils .js' ;
1
+ import type { Provider } from './types .js' ;
2
2
import type { SignerFactory } from 'rango-types' ;
3
3
4
4
import { LegacyNetworks as Networks } from '@rango-dev/wallets-core/legacy' ;
Original file line number Diff line number Diff line change
1
+ import type { LegacyNetworks } from '@rango-dev/wallets-core/legacy' ;
2
+ import type { ProviderAPI as EvmProviderApi } from '@rango-dev/wallets-core/namespaces/evm' ;
1
3
import type { WalletWithFeatures as StandardWalletWithFeatures } from '@wallet-standard/base' ;
2
4
3
5
import {
@@ -15,3 +17,38 @@ export type WalletStandardSolanaInstance = StandardWalletWithFeatures<
15
17
SolanaSignTransactionFeature &
16
18
SolanaSignMessageFeature
17
19
> ;
20
+ export type MetamaskEvmProviderApi = EvmProviderApi & {
21
+ isMetaMask ?: boolean ;
22
+ isBraveWallet ?: boolean ;
23
+ _events ?: boolean ;
24
+ _state ?: boolean ;
25
+ isApexWallet ?: boolean ;
26
+ isAvalanche ?: boolean ;
27
+ isBitKeep ?: boolean ;
28
+ isBlockWallet ?: boolean ;
29
+ isCoin98 ?: boolean ;
30
+ isFordefi ?: boolean ;
31
+ __XDEFI ?: boolean ;
32
+ isMathWallet ?: boolean ;
33
+ isOkxWallet ?: boolean ;
34
+ isOKExWallet ?: boolean ;
35
+ isOneInchIOSWallet ?: boolean ;
36
+ isOneInchAndroidWallet ?: boolean ;
37
+ isOpera ?: boolean ;
38
+ isPortal ?: boolean ;
39
+ isRabby ?: boolean ;
40
+ isDefiant ?: boolean ;
41
+ isTokenPocket ?: boolean ;
42
+ isTokenary ?: boolean ;
43
+ isZeal ?: boolean ;
44
+ isZerion ?: boolean ;
45
+ isSafePal ?: boolean ;
46
+ } ;
47
+ export type ProviderObject = {
48
+ [ LegacyNetworks . ETHEREUM ] : MetamaskEvmProviderApi ;
49
+ [ LegacyNetworks . SOLANA ] : WalletStandardSolanaInstance ;
50
+ } ;
51
+ export type Provider = Map <
52
+ keyof ProviderObject ,
53
+ ProviderObject [ keyof ProviderObject ]
54
+ > ;
Original file line number Diff line number Diff line change 1
- import type { WalletStandardSolanaInstance } from './types.js' ;
1
+ import type {
2
+ MetamaskEvmProviderApi ,
3
+ Provider ,
4
+ WalletStandardSolanaInstance ,
5
+ } from './types.js' ;
2
6
import type { ProviderAPI as EvmProviderApi } from '@rango-dev/wallets-core/namespaces/evm' ;
3
7
4
8
import { LegacyNetworks } from '@rango-dev/wallets-core/legacy' ;
@@ -9,9 +13,6 @@ import {
9
13
WALLET_STANDARD_NAME ,
10
14
} from './constants.js' ;
11
15
12
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
13
- export type Provider = Record < string , any > ;
14
-
15
16
export function metamask ( ) : Provider | null {
16
17
const { ethereum } = window ;
17
18
const solana = getSolanaWalletInstance ( ) ;
@@ -30,7 +31,7 @@ export function metamask(): Provider | null {
30
31
31
32
return instances ;
32
33
}
33
- function isEthereumMetamaskProvider ( ethereum : Provider ) : boolean {
34
+ function isEthereumMetamaskProvider ( ethereum : MetamaskEvmProviderApi ) : boolean {
34
35
if ( ! ethereum ?. isMetaMask ) {
35
36
return false ;
36
37
}
@@ -95,9 +96,6 @@ function isEthereumMetamaskProvider(ethereum: Provider): boolean {
95
96
if ( ethereum . isZerion ) {
96
97
return false ;
97
98
}
98
- if ( ethereum . isPhantom ) {
99
- return false ;
100
- }
101
99
if ( ethereum . isSafePal ) {
102
100
return false ;
103
101
}
You can’t perform that action at this time.
0 commit comments