Fixes typos and re-factory throw errors

This commit is contained in:
Gustavo Cortez 2014-07-07 14:53:34 -03:00
commit ac2eda3670
2 changed files with 26 additions and 41 deletions

View file

@ -186,26 +186,19 @@ angular.module('copayApp.controllers').controller('SendController',
}, 500); }, 500);
}; };
$scope.addressbook = {};
$scope.verifyAddressbookSignature = function(key) { $scope.verifyAddressbookSignature = function(key) {
if (key) {
$timeout(function() { $timeout(function() {
var w = $rootScope.wallet; var w = $rootScope.wallet;
var signature = w.verfifyAddressbookSignature(key); var isValid = w.verfifyAddressbookSignature(key);
$scope.addressbook[key] = signature; if (!isValid) {
if (!signature) {
notification.error('Wrong signature', 'Entry of Addressbooks was deleted'); notification.error('Wrong signature', 'Entry of Addressbooks was deleted');
} }
}, 10); }, 10);
}
}; };
$scope.toggleAddressBookEntry = function(key) { $scope.toggleAddressBookEntry = function(key) {
if (key) {
var w = $rootScope.wallet; var w = $rootScope.wallet;
w.toggleAddressBookEntry(key); w.toggleAddressBookEntry(key);
}
}; };
$scope.copyAddress = function(address) { $scope.copyAddress = function(address) {

View file

@ -853,7 +853,7 @@ Wallet.prototype.setAddressBook = function(key, label) {
}; };
Wallet.prototype.verfifyAddressbookSignature = function(key) { Wallet.prototype.verfifyAddressbookSignature = function(key) {
if (key) { if (!key) throw new Error('Key is required');
var signature = this.addressBook[key].signature; var signature = this.addressBook[key].signature;
var payload = { var payload = {
address: key, address: key,
@ -869,19 +869,11 @@ Wallet.prototype.verfifyAddressbookSignature = function(key) {
} }
return isVerified; return isVerified;
} }
else {
throw new Error('Key is required');
}
}
Wallet.prototype.toggleAddressBookEntry = function(key) { Wallet.prototype.toggleAddressBookEntry = function(key) {
if (key) { if (!key) throw new Error('Key is required');
this.addressBook[key].hidden = !this.addressBook[key].hidden; this.addressBook[key].hidden = !this.addressBook[key].hidden;
this.store(); this.store();
}
else {
throw new Error('Key is required');
}
}; };
Wallet.prototype.isReady = function() { Wallet.prototype.isReady = function() {