From 125c99320b231bab80ae37188692628d9c4c4fff Mon Sep 17 00:00:00 2001 From: Yemel Jardi Date: Mon, 4 Aug 2014 10:14:03 -0300 Subject: [PATCH 01/44] Replace You with Me --- views/includes/peer-list.html | 2 +- views/includes/video.html | 2 +- views/transactions.html | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/views/includes/peer-list.html b/views/includes/peer-list.html index cdccb5a91..951039881 100644 --- a/views/includes/peer-list.html +++ b/views/includes/peer-list.html @@ -25,7 +25,7 @@ src="./img/satoshi.gif" alt="{{copayer}}"> - you + Me {{copayer.nick}} diff --git a/views/includes/video.html b/views/includes/video.html index 78e757262..11e04ccb6 100644 --- a/views/includes/video.html +++ b/views/includes/video.html @@ -18,7 +18,7 @@ class="ellipsis" tooltip="ID: {{copayer.peerId}}" tooltip-placement="bottom"> - you + Me {{copayer.nick}} diff --git a/views/transactions.html b/views/transactions.html index 72be42b57..d924b3465 100644 --- a/views/transactions.html +++ b/views/transactions.html @@ -41,7 +41,7 @@
- + {{cId}}
@@ -70,7 +70,7 @@

- {{$root.wallet.publicKeyRing.nicknameForCopayer(cId)}} + {{cId === $root.wallet.getMyCopayerId() ? 'Me' : $root.wallet.publicKeyRing.nicknameForCopayer(cId)}}

From 698bd3f61620324cce2721f7498bd3ffac2f753d Mon Sep 17 00:00:00 2001 From: Yemel Jardi Date: Mon, 4 Aug 2014 10:22:02 -0300 Subject: [PATCH 02/44] Fix typo, closes #1015 --- views/modals/qr-address.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/views/modals/qr-address.html b/views/modals/qr-address.html index 357ee7738..b1768df8d 100644 --- a/views/modals/qr-address.html +++ b/views/modals/qr-address.html @@ -10,7 +10,7 @@ {{address.balance || 0|noFractionNumber}} {{$root.unitName}}

From 9b1708b88ef2e9c8b7f34d7d300dd5da4cb25bd3 Mon Sep 17 00:00:00 2001 From: Yemel Jardi Date: Mon, 4 Aug 2014 15:10:01 -0300 Subject: [PATCH 03/44] Save last opened wallet --- js/controllers/open.js | 2 +- js/models/core/WalletFactory.js | 4 ++++ js/models/storage/LocalEncrypted.js | 7 +++++++ test/mocks/FakeStorage.js | 7 +++++++ test/test.WalletFactory.js | 31 +++++++++++++++++++++++++++++ test/test.storage.LocalEncrypted.js | 12 +++++++++++ 6 files changed, 62 insertions(+), 1 deletion(-) diff --git a/js/controllers/open.js b/js/controllers/open.js index 02d47dd1f..917d1a281 100644 --- a/js/controllers/open.js +++ b/js/controllers/open.js @@ -9,7 +9,7 @@ angular.module('copayApp.controllers').controller('OpenController', }; $scope.loading = false; $scope.wallets = walletFactory.getWallets().sort(cmp); - $scope.selectedWalletId = $scope.wallets.length ? $scope.wallets[0].id : null; + $scope.selectedWalletId = walletFactory.storage.getLastOpened() || ($scope.wallets[0] && $scope.wallets[0].id); $scope.openPassword = ''; $scope.open = function(form) { diff --git a/js/models/core/WalletFactory.js b/js/models/core/WalletFactory.js index f689c1c6a..6f335ed0f 100644 --- a/js/models/core/WalletFactory.js +++ b/js/models/core/WalletFactory.js @@ -143,6 +143,7 @@ WalletFactory.prototype.create = function(opts) { opts.version = opts.version || this.version; var w = new Wallet(opts); w.store(); + this.storage.setLastOpened(w.id); return w; }; @@ -179,6 +180,8 @@ WalletFactory.prototype.open = function(walletId, opts) { if (w) { w.store(); } + + this.storage.setLastOpened(walletId); return w; }; @@ -194,6 +197,7 @@ WalletFactory.prototype.delete = function(walletId, cb) { var s = this.storage; this.log('## DELETING WALLET ID:' + walletId); //TODO s.deleteWallet(walletId); + s.setLastOpened(undefined); return cb(); }; diff --git a/js/models/storage/LocalEncrypted.js b/js/models/storage/LocalEncrypted.js index dd5a0f6d7..df9c9c703 100644 --- a/js/models/storage/LocalEncrypted.js +++ b/js/models/storage/LocalEncrypted.js @@ -172,6 +172,13 @@ Storage.prototype.deleteWallet = function(walletId) { } }; +Storage.prototype.setLastOpened = function(walletId) { + this.setGlobal('lastOpened', walletId); +} + +Storage.prototype.getLastOpened = function() { + return this.getGlobal('lastOpened'); +} //obj contains keys to be set Storage.prototype.setFromObj = function(walletId, obj) { diff --git a/test/mocks/FakeStorage.js b/test/mocks/FakeStorage.js index 9ea94c1b0..c7d86f3c1 100644 --- a/test/mocks/FakeStorage.js +++ b/test/mocks/FakeStorage.js @@ -19,6 +19,13 @@ FakeStorage.prototype.getGlobal = function(id) { return this.storage[id]; }; +FakeStorage.prototype.setLastOpened = function(val) { + this.storage['lastOpened'] = val; +}; + +FakeStorage.prototype.getLastOpened = function() { + return this.storage['lastOpened']; +}; FakeStorage.prototype.removeGlobal = function(id) { delete this.storage[id]; diff --git a/test/test.WalletFactory.js b/test/test.WalletFactory.js index 00cad01ce..c61787932 100644 --- a/test/test.WalletFactory.js +++ b/test/test.WalletFactory.js @@ -317,6 +317,20 @@ describe('WalletFactory model', function() { }); }); + it('should clean lastOpened on delete wallet', function(done) { + var wf = new WalletFactory(config, '0.0.1'); + var w = wf.create({ + name: 'test wallet' + }); + + wf.storage.setLastOpened(w.id); + wf.delete(w.id, function() { + var last = wf.storage.getLastOpened(); + should.equal(last, undefined); + done(); + }); + }); + it('should return false if wallet does not exist', function() { var opts = { 'requiredCopayers': 2, @@ -343,6 +357,23 @@ describe('WalletFactory model', function() { wf.read.calledWith(walletId).should.be.true; }); + it('should save lastOpened on create/open a wallet', function() { + var opts = { + 'requiredCopayers': 2, + 'totalCopayers': 3 + }; + var wf = new WalletFactory(config, '0.0.1'); + var w = wf.create(opts); + var last = wf.storage.getLastOpened(); + should.equal(last, w.id); + + wf.storage.setLastOpened('other_id'); + + var wo = wf.open(w.id, opts); + last = wf.storage.getLastOpened(); + should.equal(last, w.id); + }); + it('should return error if network are differents', function() { var opts = { 'requiredCopayers': 2, diff --git a/test/test.storage.LocalEncrypted.js b/test/test.storage.LocalEncrypted.js index 779f3542b..2212ab41f 100644 --- a/test/test.storage.LocalEncrypted.js +++ b/test/test.storage.LocalEncrypted.js @@ -148,6 +148,18 @@ describe('Storage/LocalEncrypted model', function() { s.getName(1).should.equal('hola'); }); }); + + describe('#getLastOpened #setLastOpened', function() { + it('should get/set names', function() { + var s = new LocalEncrypted({ + localStorage: localMock, + password: 'password' + }); + s.setLastOpened('hey'); + s.getLastOpened().should.equal('hey'); + }); + }); + describe('#getWallets', function() { it('should retreive wallets from storage', function() { var s = new LocalEncrypted({ From 523a48b0562db7d28b669c5c233868e3c1efa8fb Mon Sep 17 00:00:00 2001 From: Yemel Jardi Date: Mon, 4 Aug 2014 16:27:58 -0300 Subject: [PATCH 04/44] Remove Name field and copayer list on 1-of-1 wallets --- js/controllers/send.js | 2 +- js/models/core/Wallet.js | 4 ++++ test/test.Wallet.js | 8 ++++++++ views/includes/sidebar.html | 2 +- views/send.html | 4 ++-- views/setup.html | 2 +- views/transactions.html | 8 ++++---- 7 files changed, 21 insertions(+), 9 deletions(-) diff --git a/js/controllers/send.js b/js/controllers/send.js index 3af9941d2..a87e5c256 100644 --- a/js/controllers/send.js +++ b/js/controllers/send.js @@ -50,7 +50,7 @@ angular.module('copayApp.controllers').controller('SendController', var w = $rootScope.wallet; w.createTx(address, amount, commentText, function(ntxid) { - if (w.totalCopayers > 1) { + if (w.isShared()) { $scope.loading = false; var message = 'The transaction proposal has been created'; notification.success('Success!', message); diff --git a/js/models/core/Wallet.js b/js/models/core/Wallet.js index db37355cf..c7ae6403d 100644 --- a/js/models/core/Wallet.js +++ b/js/models/core/Wallet.js @@ -913,6 +913,10 @@ Wallet.prototype.toggleAddressBookEntry = function(key) { this.store(); }; +Wallet.prototype.isShared = function() { + return this.totalCopayers > 1; +} + Wallet.prototype.isReady = function() { var ret = this.publicKeyRing.isComplete() && this.publicKeyRing.isFullyBackup(); return ret; diff --git a/test/test.Wallet.js b/test/test.Wallet.js index 04b1626de..92810302b 100644 --- a/test/test.Wallet.js +++ b/test/test.Wallet.js @@ -363,6 +363,14 @@ describe('Wallet model', function() { }, w.reconnectDelay * callCount * (callCount + 1) / 2); }); + it('#isSingleUser', function() { + var w = createW(); + w.isShared().should.equal(true); + + w.totalCopayers = 1; + w.isShared().should.equal(false); + }); + it('#isReady', function() { var w = createW(); w.publicKeyRing.isComplete().should.equal(false); diff --git a/views/includes/sidebar.html b/views/includes/sidebar.html index 220358562..00e71bcd5 100644 --- a/views/includes/sidebar.html +++ b/views/includes/sidebar.html @@ -64,7 +64,7 @@ -
+
diff --git a/views/send.html b/views/send.html index e80ccda0e..816b02e3f 100644 --- a/views/send.html +++ b/views/send.html @@ -77,7 +77,7 @@ -
+