Skip to content
Permalink
Browse files

Merge pull request #224 from gnosis/bug/ledger-trezor-cannot-operate

Bug/ledger trezor cannot operate
  • Loading branch information...
giacomolicari committed Feb 7, 2019
2 parents 8cd19b0 + a1299c2 commit ca981359cf5acd6a1f9db18e44777e45027df5e0
Showing with 99 additions and 45 deletions.
  1. +2 −0 dapp/controllers/navCtrl.js
  2. +1 −1 dapp/index.html
  3. +1 −1 dapp/package.json
  4. +94 −42 dapp/services/Web3Service.js
  5. +1 −1 package.json
@@ -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(
@@ -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');
@@ -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>
@@ -1,6 +1,6 @@
{
"name": "multisigweb",
"version": "1.4.0",
"version": "1.4.1",
"eslintConfig": {
"env": {
"browser": true,
@@ -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];
@@ -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") {
@@ -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 () {
@@ -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();
}
});
});
}
);
};
@@ -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 */
@@ -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",

0 comments on commit ca98135

Please sign in to comment.
You can’t perform that action at this time.