@web3-onboard/injected-wallets
Advanced tools
Comparing version 2.6.2-alpha.1 to 2.6.2-alpha.2
@@ -20,2 +20,3 @@ // Maps a wallet name from the provider to its display name | ||
enkrypt: 'Enkrypt', | ||
trust: 'Trust Wallet', | ||
frontier: 'Frontier', | ||
@@ -22,0 +23,0 @@ zerion: 'Zerion', |
@@ -11,8 +11,15 @@ export class ProviderRpcError extends Error { | ||
export const isWalletAvailable = (provider, checkProviderIdentity, device) => { | ||
if (provider && provider.providers && Array.isArray(provider.providers)) { | ||
return !!provider.providers.filter(provider => checkProviderIdentity({ provider, device })).length; | ||
var _a; | ||
// No injected providers exist. | ||
if (!provider) { | ||
return false; | ||
} | ||
else { | ||
return checkProviderIdentity({ provider, device }); | ||
// Many injected providers add their own object into window. | ||
if (checkProviderIdentity({ provider, device })) { | ||
return true; | ||
} | ||
// For multiple injected providers, check providers array | ||
// example coinbase inj wallet pushes over-ridden wallets | ||
// into a providers array at window.ethereum | ||
return !!((_a = provider.providers) === null || _a === void 0 ? void 0 : _a.some(provider => checkProviderIdentity({ provider, device }))); | ||
}; |
@@ -119,4 +119,5 @@ import type { ExternalProvider } from '@ethersproject/providers'; | ||
Zeal = "zeal", | ||
Frontier = "frontier", | ||
Phantom = "phantom" | ||
Phantom = "phantom", | ||
Trust = "trustwallet", | ||
Frontier = "frontier" | ||
} | ||
@@ -152,2 +153,3 @@ export interface CustomWindow extends Window { | ||
}; | ||
trustwallet: InjectedProvider; | ||
} | ||
@@ -154,0 +156,0 @@ export type InjectedProvider = ExternalProvider & BinanceProvider & MeetOneProvider & Record<string, boolean> & Record<string, InjectedProvider[]>; |
@@ -112,4 +112,5 @@ /** | ||
InjectedNameSpace["Zeal"] = "zeal"; | ||
InjectedNameSpace["Phantom"] = "phantom"; | ||
InjectedNameSpace["Trust"] = "trustwallet"; | ||
InjectedNameSpace["Frontier"] = "frontier"; | ||
InjectedNameSpace["Phantom"] = "phantom"; | ||
})(InjectedNameSpace || (InjectedNameSpace = {})); |
@@ -135,15 +135,21 @@ import { createEIP1193Provider } from '@web3-onboard/common'; | ||
label: ProviderLabel.Trust, | ||
injectedNamespace: InjectedNameSpace.Ethereum, | ||
checkProviderIdentity: ({ provider }) => !!provider && | ||
!!provider[ProviderIdentityFlag.Trust] && | ||
!!provider && | ||
!provider[ProviderIdentityFlag.TokenPocket], | ||
injectedNamespace: InjectedNameSpace.Trust, | ||
checkProviderIdentity: ({ provider }) => !!provider && !!provider[ProviderIdentityFlag.Trust], | ||
getIcon: async () => (await import('./icons/trust.js')).default, | ||
getInterface: async () => ({ | ||
provider: createEIP1193Provider(window.ethereum, { | ||
wallet_switchEthereumChain: UNSUPPORTED_METHOD, | ||
eth_selectAccounts: UNSUPPORTED_METHOD | ||
}) | ||
}), | ||
platforms: ['mobile'] | ||
getInterface: async () => { | ||
const ethereumInjectionExists = window.hasOwnProperty(InjectedNameSpace.Ethereum); | ||
let provider; | ||
// check if trust is injected into window.ethereum | ||
if (ethereumInjectionExists && window[InjectedNameSpace.Ethereum].isTrust) { | ||
provider = window[InjectedNameSpace.Ethereum]; | ||
} | ||
else { | ||
// directly use the window.trustwallet injection | ||
provider = window[InjectedNameSpace.Trust]; | ||
} | ||
return { | ||
provider | ||
}; | ||
}, | ||
platforms: ['all'] | ||
}; | ||
@@ -150,0 +156,0 @@ const opera = { |
{ | ||
"name": "@web3-onboard/injected-wallets", | ||
"version": "2.6.2-alpha.1", | ||
"version": "2.6.2-alpha.2", | ||
"description": "Injected wallet module for connecting browser extension and mobile wallets to Web3-Onboard. Web3-Onboard makes it simple to connect Ethereum hardware and software wallets to your dapp. Features standardised spec compliant web3 providers for all supported wallets, framework agnostic modern javascript UI with code splitting, CSS customization, multi-chain and multi-account support, reactive wallet state subscriptions and real-time transaction state change notifications.", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
400994
3071