Skip to content

Commit

Permalink
fix: import path on window object
Browse files Browse the repository at this point in the history
  • Loading branch information
bangjelkoski committed Aug 9, 2023
1 parent 8a4c729 commit 28463b0
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ function getMetamaskFromWindow() {
return null
}

// Metamask Wallet was injected into $window.ethereum.
if (isMetamask($window.ethereum)) {
return $window.ethereum
}
Expand All @@ -57,6 +56,5 @@ function getMetamaskFromWindow() {
return $window.providers.find(isMetamask) ?? null
}

// @ts-ignore
return window['ethereum'] ?? null
return null
}
Original file line number Diff line number Diff line change
Expand Up @@ -46,22 +46,27 @@ function getTrustWalletFromWindow() {
}

const injectedProviderExist =
typeof window !== 'undefined' && typeof $window.ethereum !== 'undefined'
typeof window !== 'undefined' &&
(typeof $window.ethereum !== 'undefined' ||
typeof $window.trustWallet !== 'undefined')

// No injected providers exist.
if (!injectedProviderExist) {
return null
}

// Trust Wallet was injected into $window.ethereum.
if ($window.trustWallet) {
return $window.trustWallet
}

if (isTrustWallet($window.ethereum)) {
// Trust Wallet was injected into $window.ethereum.
return $window.ethereum
}

if ($window.providers) {
return $window.providers.find(isTrustWallet) ?? null
}

// @ts-ignore
return window['trustwallet'] ?? null
return null
}
1 change: 1 addition & 0 deletions packages/wallet-ts/src/strategies/wallet-strategy/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ export interface BrowserEip1993Provider extends Eip1993Provider {
export interface WindowWithEip1193Provider extends Window {
ethereum: BrowserEip1993Provider
providers: BrowserEip1993Provider[]
trustWallet?: BrowserEip1993Provider
}

export interface WindowWithLedgerSupport extends Window {
Expand Down

0 comments on commit 28463b0

Please sign in to comment.