Get protocol handler from walletService

This commit is contained in:
Gustavo Maximiliano Cortez 2017-09-09 19:42:48 -03:00
commit 779d21e9e9
No known key found for this signature in database
GPG key ID: 15EDAD8D9F2EB1AF
5 changed files with 18 additions and 2 deletions

View file

@ -8,6 +8,10 @@ angular.module('copayApp.controllers').controller('customAmountController', func
});
};
var setProtocolHandler = function() {
$scope.protocolHandler = walletService.getProtocolHandler($scope.wallet);
}
$scope.$on("$ionicView.beforeEnter", function(event, data) {
var walletId = data.stateParams.id;
@ -20,6 +24,8 @@ angular.module('copayApp.controllers').controller('customAmountController', func
$scope.wallet = profileService.getWallet(walletId);
setProtocolHandler();
walletService.getAddress($scope.wallet, false, function(err, addr) {
if (!addr) {
showErrorAndBack('Error', 'Could not get the address');

View file

@ -124,8 +124,13 @@ angular.module('copayApp.controllers').controller('tabReceiveController', functi
return wallet;
}
var setProtocolHandler = function() {
$scope.protocolHandler = walletService.getProtocolHandler($scope.wallet);
}
$scope.onWalletSelect = function(wallet) {
$scope.wallet = wallet;
setProtocolHandler();
$scope.setAddress();
};

View file

@ -1232,5 +1232,10 @@ angular.module('copayApp.services').factory('walletService', function($log, $tim
});
};
root.getProtocolHandler = function(wallet) {
if (wallet.coin== 'bch') return 'bitcoincash';
else return 'bitcoin';
}
return root;
});