From 5867edfa26e506af7e0d02d4596508350eab0f28 Mon Sep 17 00:00:00 2001 From: JDonadio Date: Wed, 20 Sep 2017 17:24:45 -0300 Subject: [PATCH] list available and unavailable wallets properly --- src/js/controllers/cashScan.js | 54 +++++++++++++++++++++++++++++----- www/views/cashScan.html | 39 +++++++++++++++++++----- 2 files changed, 77 insertions(+), 16 deletions(-) diff --git a/src/js/controllers/cashScan.js b/src/js/controllers/cashScan.js index f00ed3ebf..bf0fbeb51 100644 --- a/src/js/controllers/cashScan.js +++ b/src/js/controllers/cashScan.js @@ -45,19 +45,57 @@ angular.module('copayApp.controllers').controller('cashScanController', return !xPubKeyIndex[w.credentials.xPubKey]; }); - // Filter out non BIP44 wallets - var wallets = lodash.filter(walletsBTC, function(w) { - return w.credentials.derivationStrategy == 'BIP44' - }); + var availableWallets = []; + var nonEligibleWallets = []; - $scope.wallets = wallets; - $scope.nonBIP44Wallets = lodash.filter(walletsBTC, function(w) { + function addToNonEligibleWallets(wallets) { + if (!wallets) return; + lodash.each(wallets, function(w) { + nonEligibleWallets.push(w); + }); + }; + + // Filter out non BIP44 wallets + var nonBIP44Wallets = lodash.filter(walletsBTC, function(w) { return w.credentials.derivationStrategy != 'BIP44'; }); - var i = wallets.length; + if (!lodash.isEmpty(nonBIP44Wallets)) { + availableWallets = lodash.filter(walletsBTC, function(w) { + return w.credentials.derivationStrategy == 'BIP44'; + }); + addToNonEligibleWallets(nonBIP44Wallets); + } + + // Filter out read only wallets + var readOnlyWallets = lodash.filter(availableWallets, function(w) { + return !w.canSign(); + }); + + if (!lodash.isEmpty(readOnlyWallets)) { + availableWallets = lodash.filter(availableWallets, function(w) { + return w.canSign(); + }); + addToNonEligibleWallets(readOnlyWallets); + } + + // Filter out non backed up wallets + $scope.nonBackedUpWallets = lodash.filter(availableWallets, function(w) { + return w.needsBackup; + }); + + if (!lodash.isEmpty($scope.nonBackedUpWallets)) { + availableWallets = lodash.filter(availableWallets, function(w) { + return !w.needsBackup; + }); + } + + $scope.nonEligibleWallets = nonEligibleWallets; + $scope.availableWallets = availableWallets; + + var i = availableWallets.length; var j = 0; - lodash.each(wallets, function(wallet) { + lodash.each(availableWallets, function(wallet) { walletService.getBalance(wallet, { coin: 'bch' }, function(err, balance) { diff --git a/www/views/cashScan.html b/www/views/cashScan.html index e11c39172..551e11a18 100644 --- a/www/views/cashScan.html +++ b/www/views/cashScan.html @@ -10,7 +10,7 @@
-
+
No wallets eligible for Bitcoin Cash support
@@ -19,11 +19,13 @@
- BTC Wallets + BTC wallets
-
- +
+ + +
{{wallet.name || wallet.id}}
{{wallet.bchBalance || ('Checking...' | translate)}}
@@ -35,20 +37,41 @@
-
+
+
+ +
+ Backup needed +
+ +
+ + + + {{wallet.name || wallet.id}} +
+ +
+ Complete the backup process to use this option +
+
+ +
Non eligible BTC wallets
-
- +
+ + + {{wallet.name || wallet.id}}
- Some of you wallets are not eligible for Bitcon Cash support because there where created before Copay v1.2. Please use our recovery tool to access your Bitcoin Cash balance for those wallets + Some of you wallets are not eligible for Bitcon Cash support because both there where created before Copay v1.2 or are not available to sign. Please use our recovery tool to access your Bitcoin Cash balance for those wallets