-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
63 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import detectEthereumProvider from '@metamask/detect-provider'; | ||
|
||
/** | ||
* to check if metamask Flask is installed of not | ||
*/ | ||
export async function hasFlask() { | ||
// This resolves to the value of window.ethereum or null | ||
const provider = await detectEthereumProvider(); | ||
|
||
// web3_clientVersion returns the installed MetaMask version as a string | ||
const isFlask = ( | ||
await (provider as any)?.request({ method: 'web3_clientVersion' }) | ||
)?.includes('flask'); | ||
|
||
if (provider && isFlask) { | ||
console.log('MetaMask Flask successfully detected!'); | ||
|
||
// Now you can use Snaps! | ||
return true; | ||
} else { | ||
console.error('Please install MetaMask Flask!'); | ||
|
||
return false; | ||
} | ||
} |