Skip to content
This repository has been archived by the owner on Aug 24, 2021. It is now read-only.

Commit

Permalink
Merge pull request #224 from gnosis/bug/ledger-trezor-cannot-operate
Browse files Browse the repository at this point in the history
Bug/ledger trezor cannot operate
  • Loading branch information
giacomolicari committed Feb 7, 2019
2 parents 8cd19b0 + a1299c2 commit ca98135
Show file tree
Hide file tree
Showing 5 changed files with 99 additions and 45 deletions.
2 changes: 2 additions & 0 deletions dapp/controllers/navCtrl.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
$scope.isElectron = isElectron;
$scope.config = Config.getConfiguration();
$scope.metamaskInjected = Web3Service.isMetamaskInjected();
$scope.web3ProviderName = null;

// Reload config when it changes
$scope.$watch(
Expand Down Expand Up @@ -219,6 +220,7 @@
Connection.checkConnection();
$scope.updateConnectionStatus();
$scope.connectionInterval = $interval($scope.updateConnectionStatus, txDefault.connectionChecker.checkInterval);
$scope.web3ProviderName = txDefault.wallet;

$scope.updateInfo().then(function () {
var chooseWeb3ProviderShown = Config.getConfiguration('chooseWeb3ProviderShown');
Expand Down
2 changes: 1 addition & 1 deletion dapp/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@
<span class="navbar-text">{{ethereumChain.chain.substr(0, 1).toUpperCase() + ethereumChain.chain.substr(1)}}</span>
<span class="navbar-text" ng-bind-html="statusIcon"></span>
</li>
<li ng-show="metamaskInjected && !loggedIn">
<li ng-show="web3ProviderName === 'injected' && metamaskInjected && !loggedIn">
<a hef="#" ng-click="openMetamaskWidget()">Unlock Metamask</a>
</li>
</ul>
Expand Down
2 changes: 1 addition & 1 deletion dapp/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "multisigweb",
"version": "1.4.0",
"version": "1.4.1",
"eslintConfig": {
"env": {
"browser": true,
Expand Down
136 changes: 94 additions & 42 deletions dapp/services/Web3Service.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
*/
factory.enableMetamask = function (callback) {
$window.ethereum.enable().then(function (accounts) {
factory.reloadWeb3Provider();
factory.reloadWeb3Provider(null, callback);
// Set accounts and coinbase
factory.accounts = accounts;
factory.coinbase = accounts[0];
Expand Down Expand Up @@ -67,26 +67,26 @@
// Ledger wallet
if (txDefault.wallet == "ledger") {
if (isElectron) {
factory.ledgerElectronSetup();
factory.web3.eth.getAccounts(function (e, accounts) {
if (e) {
if (reject) {
reject(e);
}
} else {
factory.accounts = accounts;
factory.coinbase = factory.accounts[0];
if (resolve) {
resolve();
}
factory.ledgerElectronSetup().then(function () {
if (resolve) {
resolve()
}
});
}, function (e) {
if (reject) {
reject(e)
}
})
}
else {
factory.ledgerSetup();
if (resolve) {
resolve();
}
factory.ledgerSetup().then(function () {
if (resolve) {
resolve()
}
}, function (e) {
if (reject) {
reject(e)
}
})
}
}
else if (txDefault.wallet == "trezor") {
Expand Down Expand Up @@ -240,42 +240,70 @@
});
};

// /**
// * Get ethereum accounts and update account list.
// */
// factory.updateAccounts = function (cb) {
// if (!isElectron && factory.coinbase) {
// return factory.web3.eth.getAccounts(
// function (e, accounts) {
// if (e) {
// cb(e);
// }
// else {
// factory.accounts = accounts;
//
// if (factory.coinbase && accounts && accounts.length && accounts.indexOf(factory.coinbase) != -1) {
// // same coinbase
// }
// else if (accounts) {
// factory.coinbase = accounts[0];
// }
// else {
// factory.coinbase = null;
// }
//
// cb(null, accounts);
// }
// }
// );
// }
// else {
// cb(null, null);
// }
// };

/**
* Get ethereum accounts and update account list.
*/
factory.updateAccounts = function (cb) {
if (!isElectron && factory.coinbase) {
return factory.web3.eth.getAccounts(
function (e, accounts) {
if (e) {
cb(e);
return factory.web3.eth.getAccounts(
function (e, accounts) {
if (e) {
cb(e);
}
else {
factory.accounts = accounts;

if (factory.coinbase && accounts && accounts.length && accounts.indexOf(factory.coinbase) != -1) {
// same coinbase
}
else if (accounts) {
factory.coinbase = accounts[0];
}
else {
factory.accounts = accounts;

if (factory.coinbase && accounts && accounts.length && accounts.indexOf(factory.coinbase) != -1) {
// same coinbase
}
else if (accounts) {
factory.coinbase = accounts[0];
}
else {
factory.coinbase = null;
}

cb(null, accounts);
factory.coinbase = null;
}

cb(null, accounts);
}
);
}
else {
cb(null, null);
}
}
);
};

/* Ledger setup on browser*/
factory.ledgerSetup = function () {
ledgerwallet(
return ledgerwallet(
{
rpcUrl: txDefault.ethereumNode,
onSubmit: function () {
Expand Down Expand Up @@ -332,6 +360,18 @@
$scope.checkCoinbase();
}
});

return new Promise(function(resolve, reject) {
factory.web3.eth.getAccounts(function (e, accounts) {
if (e) {
reject(e);
} else {
factory.accounts = accounts;
factory.coinbase = factory.accounts[0];
resolve();
}
});
});
}
);
};
Expand Down Expand Up @@ -424,6 +464,18 @@
$scope.checkCoinbase();
}
});

return new Promise(function(resolve, reject) {
factory.web3.eth.getAccounts(function (e, accounts) {
if (e) {
reject(e);
} else {
factory.accounts = accounts;
factory.coinbase = factory.accounts[0];
resolve();
}
});
});
};

/* Trezor setup */
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "multisig-wallet-gnosis",
"version": "1.4.0",
"version": "1.4.1",
"description": "Main module, for installing all dependencies",
"scripts": {
"test-dapp": "cd dapp && npm test",
Expand Down

0 comments on commit ca98135

Please sign in to comment.