From 3010f0ad7faee17b363cdddf2b9a32d9f0132278 Mon Sep 17 00:00:00 2001 From: Owocki Date: Mon, 8 Apr 2019 11:00:34 -0600 Subject: [PATCH] handle non-metamask web3 browsers --- app/assets/v2/js/metamask-approval.js | 2 +- app/assets/v2/js/shared.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/assets/v2/js/metamask-approval.js b/app/assets/v2/js/metamask-approval.js index 69750887eb0..94fef0ef7d4 100644 --- a/app/assets/v2/js/metamask-approval.js +++ b/app/assets/v2/js/metamask-approval.js @@ -3,7 +3,7 @@ var is_metamask_approved = is_metamask_approved || false; var is_metamask_unlocked = is_metamask_unlocked || false; async function metamaskApproval() { - if (window.ethereum) { + if (window.ethereum && window.ethereum._metamask) { window.web3 = new Web3(ethereum); is_metamask_approved = await window.ethereum._metamask.isApproved(); is_metamask_unlocked = await window.ethereum._metamask.isUnlocked(); diff --git a/app/assets/v2/js/shared.js b/app/assets/v2/js/shared.js index 502b79d35bc..be2a3279e60 100644 --- a/app/assets/v2/js/shared.js +++ b/app/assets/v2/js/shared.js @@ -991,7 +991,7 @@ var listen_for_web3_changes = async function() { } } - if (window.ethereum && !document.has_checked_for_ethereum_enable) { + if (window.ethereum && !document.has_checked_for_ethereum_enable && window.ethereum._metamask) { document.has_checked_for_ethereum_enable = true; is_metamask_approved = await window.ethereum._metamask.isApproved(); is_metamask_unlocked = await window.ethereum._metamask.isUnlocked();