rename walletFactory to identity. Test passing

This commit is contained in:
Matias Alejo Garcia 2014-09-26 05:00:43 -03:00
commit eb9ab115d7
14 changed files with 652 additions and 115 deletions

View file

@ -1,7 +1,7 @@
'use strict';
angular.module('copayApp.controllers').controller('CopayersController',
function($scope, $rootScope, $location, backupService, walletFactory, controllerUtils) {
function($scope, $rootScope, $location, backupService, identity, controllerUtils) {
$scope.isSafari = Object.prototype.toString.call(window.HTMLElement).indexOf('Constructor') > 0;
$scope.hideAdv = true;
@ -36,7 +36,7 @@ angular.module('copayApp.controllers').controller('CopayersController',
$scope.deleteWallet = function() {
var w = $rootScope.wallet;
walletFactory.delete(w.id, function() {
identity.delete(w.id, function() {
controllerUtils.logout();
});
};

View file

@ -1,71 +0,0 @@
'use strict';
angular.module('copayApp.controllers').controller('CreateController',
function($scope, $rootScope, $location, $timeout, walletFactory, controllerUtils, Passphrase, backupService, notification, defaults) {
controllerUtils.redirIfLogged();
$rootScope.fromSetup = true;
$scope.loading = false;
$scope.walletPassword = $rootScope.walletPassword;
$scope.isMobile = !!window.cordova;
$scope.hideAdv = true;
$scope.networkName = config.networkName;
$scope.networkUrl = config.network[$scope.networkName].url;
// ng-repeat defined number of times instead of repeating over array?
$scope.getNumber = function(num) {
return new Array(num);
}
$scope.totalCopayers = config.wallet.totalCopayers;
$scope.TCValues = _.range(1, config.limits.totalCopayers + 1);
var updateRCSelect = function(n) {
var maxReq = copay.Wallet.getMaxRequiredCopayers(n);
$scope.RCValues = _.range(1, maxReq + 1);
$scope.requiredCopayers = Math.min(parseInt(n / 2 + 1), maxReq);
};
updateRCSelect($scope.totalCopayers);
$scope.$watch('totalCopayers', function(tc) {
updateRCSelect(tc);
});
$scope.$watch('networkName', function(tc) {
$scope.networkUrl = config.network[$scope.networkName].url;
});
$scope.showNetwork = function(){
return $scope.networkUrl != defaults.network.livenet.url && $scope.networkUrl != defaults.network.testnet.url;
};
$scope.create = function(form) {
if (form && form.$invalid) {
notification.error('Error', 'Please enter the required fields');
return;
}
$scope.loading = true;
Passphrase.getBase64Async($scope.walletPassword, function(passphrase) {
var opts = {
requiredCopayers: $scope.requiredCopayers,
totalCopayers: $scope.totalCopayers,
name: $scope.walletName,
nickname: $scope.myNickname,
passphrase: passphrase,
privateKeyHex: $scope.private,
networkName: $scope.networkName,
};
walletFactory.create(opts, function(err, w) {
controllerUtils.startNetwork(w, $scope);
});
});
};
$scope.isSetupWalletPage = 0;
$scope.setupWallet = function() {
$scope.isSetupWalletPage = !$scope.isSetupWalletPage;
};
});

View file

@ -1,11 +1,11 @@
'use strict';
angular.module('copayApp.controllers').controller('HomeController', function($scope, $rootScope, $location, walletFactory, notification, controllerUtils) {
angular.module('copayApp.controllers').controller('HomeController', function($scope, $rootScope, $location, identity, notification, controllerUtils) {
controllerUtils.redirIfLogged();
$scope.retreiving = true;
walletFactory.getWallets(function(err,ret) {
identity.getWallets(function(err,ret) {
$scope.retreiving = false;
$scope.hasWallets = (ret && ret.length > 0) ? true : false;
});

View file

@ -1,7 +1,7 @@
'use strict';
angular.module('copayApp.controllers').controller('ImportController',
function($scope, $rootScope, $location, walletFactory, controllerUtils, Passphrase, notification, isMobile) {
function($scope, $rootScope, $location, identity, controllerUtils, Passphrase, notification, isMobile) {
controllerUtils.redirIfLogged();
$scope.title = 'Import a backup';
@ -30,7 +30,7 @@ angular.module('copayApp.controllers').controller('ImportController',
// try to import encrypted wallet with passphrase
try {
w = walletFactory.import(encryptedObj, passphrase, skipFields);
w = identity.import(encryptedObj, passphrase, skipFields);
} catch (e) {
errMsg = e.message;
}

View file

@ -1,7 +1,7 @@
'use strict';
angular.module('copayApp.controllers').controller('JoinController',
function($scope, $rootScope, $timeout, walletFactory, controllerUtils, Passphrase, notification) {
function($scope, $rootScope, $timeout, identity, controllerUtils, Passphrase, notification) {
controllerUtils.redirIfLogged();
$rootScope.fromSetup = false;
$scope.loading = false;
@ -121,12 +121,13 @@ angular.module('copayApp.controllers').controller('JoinController',
$scope.loading = true;
Passphrase.getBase64Async($scope.joinPassword, function(passphrase) {
walletFactory.joinCreateSession({
identity.joinCreateSession({
secret: $scope.connectionId,
nickname: $scope.nickname,
passphrase: passphrase,
privateHex: $scope.private,
}, function(err, w) {
$scope.loading = false;
if (err || !w) {
if (err === 'joinError')
@ -137,8 +138,6 @@ angular.module('copayApp.controllers').controller('JoinController',
notification.error('Network Error', 'Wallet network configuration missmatch');
else if (err === 'badSecret')
notification.error('Bad secret', 'The secret string you entered is invalid');
else if (err === 'connectionError')
notification.error('Networking Error', 'Could not connect to the Insight server. Check your settings and network configuration');
else
notification.error('Unknown error');
controllerUtils.onErrorDigest();

View file

@ -1,7 +1,7 @@
'use strict';
angular.module('copayApp.controllers').controller('MoreController',
function($scope, $rootScope, $location, $filter, backupService, walletFactory, controllerUtils, notification, rateService) {
function($scope, $rootScope, $location, $filter, backupService, identity, controllerUtils, notification, rateService) {
var w = $rootScope.wallet;
$scope.isSafari = Object.prototype.toString.call(window.HTMLElement).indexOf('Constructor') > 0;
@ -81,7 +81,7 @@ angular.module('copayApp.controllers').controller('MoreController',
};
$scope.deleteWallet = function() {
walletFactory.delete(w.id, function() {
identity.delete(w.id, function() {
controllerUtils.logout();
});
};

View file

@ -1,6 +1,6 @@
'use strict';
angular.module('copayApp.controllers').controller('OpenController', function($scope, $rootScope, $location, walletFactory, controllerUtils, Passphrase, notification) {
angular.module('copayApp.controllers').controller('OpenController', function($scope, $rootScope, $location, identity, controllerUtils, Passphrase, notification) {
controllerUtils.redirIfLogged();
if ($rootScope.pendingPayment) {
@ -16,7 +16,7 @@ angular.module('copayApp.controllers').controller('OpenController', function($sc
$scope.loading = false;
$scope.retreiving = true;
walletFactory.getWallets(function(err, wallets) {
identity.getWallets(function(err, wallets) {
if (err || !wallets || !wallets.length) {
$location.path('/');
@ -48,7 +48,7 @@ angular.module('copayApp.controllers').controller('OpenController', function($sc
Passphrase.getBase64Async(password, function(passphrase) {
var w, errMsg;
walletFactory.open($scope.selectedWalletId, passphrase, function(err, w) {
identity.open($scope.selectedWalletId, passphrase, function(err, w) {
if (!w) {
$scope.loading = false;
notification.error('Error', err.errMsg || 'Wrong password');