Skip to content
This repository has been archived by the owner on Nov 21, 2019. It is now read-only.

Commit

Permalink
move web3 instance checking to decryptwallet
Browse files Browse the repository at this point in the history
  • Loading branch information
kvhnuke committed Sep 4, 2018
1 parent 795d427 commit 85d34d7
Show file tree
Hide file tree
Showing 4 changed files with 254 additions and 298 deletions.
8 changes: 8 additions & 0 deletions app/scripts/controllers/decryptWalletCtrl.js
Original file line number Diff line number Diff line change
Expand Up @@ -451,6 +451,14 @@ var decryptWalletCtrl = function($scope, $sce, walletService) {
return $scope.HDWallet.dPath;
};
$scope.scanMetamask = function() {
if (window.web3 === undefined) {
window.addEventListener('message', ({data}) => {
if (data && data.type && data.type === 'ETHEREUM_PROVIDER_SUCCESS') {
window.web3 = new Web3(ethereum);
}
});
window.postMessage({ type: 'ETHEREUM_PROVIDER_REQUEST', web3: true }, '*');
}
window.web3.eth.getAccounts(function (err, accounts) {
if (err) $scope.notifier.danger(err + '. Are you sure you are on a secure (SSL / HTTPS) connection?')
if (!accounts.length) {
Expand Down
13 changes: 0 additions & 13 deletions app/scripts/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,6 @@ var bip39 = require('bip39');
var HDKey = require('hdkey');
var xssFilters = require('xss-filters');
window.xssFilters = xssFilters;
var Web3 = require('web3');
if (window.web3 === undefined) {
window.addEventListener('message', ({data}) => {
if (data && data.type && data.type === 'ETHEREUM_PROVIDER_SUCCESS') {
// Use injected provider, start dapp...
window.web3 = new Web3(ethereum); // Should probably need to change this to the Metamask provider
}
});
window.postMessage({ type: 'ETHEREUM_PROVIDER_REQUEST' }, '*');
} else {
window.web3 = new Web3(ethereum); // Should probably need to change this to the Metamask provider
}
console.log("Here now?")
window.hd = { bip39: bip39, HDKey: HDKey };
var BigNumber = require('bignumber.js');
window.BigNumber = BigNumber;
Expand Down
Loading

0 comments on commit 85d34d7

Please sign in to comment.