fix extension alert

This commit is contained in:
SvyatoslavArtymovych 2023-06-08 10:02:21 +03:00
parent 07360a6fcd
commit 0e5a10b81c
3 changed files with 10 additions and 152640 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -13,15 +13,21 @@ export function initWallet() {
// protocol, hostname and port number of the URL
const origin = window.location.origin;
// connect to ethereum network and sign transactions with Metamask
if (!window.hasOwnProperty('ethereum')) {
const showExtensionAlert = localStorage.getItem('showExtensionAlert');
if (!window.hasOwnProperty('ethereum') && showExtensionAlert != 'false') {
let result = confirm(
"You don't have needed extension! Do you want to install it?",
);
localStorage.setItem('showExtensionAlert', 'false');
if (result) {
window.open('https://metamask.io/', '_blank');
}
return;
}
if (showExtensionAlert == 'false' && !window.hasOwnProperty('ethereum')) {
console.error('Required extension not found');
return;
}
const eOwner: IEthereumOwner = window as any;
const provider = new ethers.providers.Web3Provider(eOwner.ethereum);
const signer = provider.getSigner();