pulled in latest commits from yesterday, merged and handled conflicts
This commit is contained in:
commit
f15d597b25
123 changed files with 1686 additions and 1291 deletions
30
src/css/links.css
Normal file
30
src/css/links.css
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
@font-face {
|
||||
font-family: 'roboto-regular';
|
||||
font-style: normal;
|
||||
font-weight: 400;
|
||||
src: local('Roboto Regular'),
|
||||
local('Roboto-Regular'),
|
||||
url(../roboto-font/Roboto-Regular.ttf) format('truetype'),
|
||||
url(../roboto-font/Roboto-Regular.woff) format('woff'),
|
||||
url(../roboto-font/Roboto-Regular.woff2) format('woff2');
|
||||
}
|
||||
@font-face {
|
||||
font-family: 'roboto-bold';
|
||||
font-style: normal;
|
||||
font-weight: 700;
|
||||
src: local('Roboto Bold'),
|
||||
local('Roboto-Bold'),
|
||||
url(../roboto-font/Roboto-Bold.ttf) format('truetype'),
|
||||
url(../roboto-font/Roboto-Bold.woff) format('woff'),
|
||||
url(../roboto-font/Roboto-Bold.woff2) format('woff2');
|
||||
}
|
||||
@font-face {
|
||||
font-family: 'roboto-italic';
|
||||
font-style: italic;
|
||||
font-weight: 400;
|
||||
src: local('Roboto Italic'),
|
||||
local('Roboto-Italic'),
|
||||
url(../roboto-font/Roboto-Italic.ttf) format('truetype'),
|
||||
url(../roboto-font/Roboto-Italic.woff) format('woff'),
|
||||
url(../roboto-font/Roboto-Italic.woff2) format('woff2');
|
||||
}
|
||||
|
|
@ -4,43 +4,19 @@ angular.module('copayApp.controllers').controller('activityController',
|
|||
function($rootScope, $timeout, $scope, $state, lodash, profileService, walletService, configService, txFormatService, $ionicModal, $log, platformInfo) {
|
||||
var self = this;
|
||||
|
||||
var setNotifications = function(notifications) {
|
||||
var n = walletService.processNotifications(notifications);
|
||||
|
||||
$scope.notifications = n;
|
||||
$timeout(function() {
|
||||
$scope.$apply();
|
||||
}, 1);
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
$scope.init = function() {
|
||||
$scope.wallets = profileService.getWallets();
|
||||
|
||||
var i = $scope.wallets.length,
|
||||
j = 0;
|
||||
var timeSpan = 60 * 60 * 24 * 7;
|
||||
var notifications = [];
|
||||
|
||||
$scope.fetchingNotifications = true;
|
||||
|
||||
lodash.each($scope.wallets, function(wallet) {
|
||||
|
||||
walletService.getNotifications(wallet, {
|
||||
timeSpan: timeSpan
|
||||
}, function(err, n) {
|
||||
if (err) {
|
||||
console.log('[tab-home.js.35:err:]', $log.error(err)); //TODO
|
||||
return;
|
||||
}
|
||||
notifications.push(n);
|
||||
if (++j == i) {
|
||||
$scope.fetchingNotifications = false;
|
||||
setNotifications(lodash.compact(lodash.flatten(notifications)));
|
||||
};
|
||||
});
|
||||
profileService.getNotifications(50, function(err, n) {
|
||||
if (err) {
|
||||
console.log('[tab-home.js.35:err:]', $log.error(err)); //TODO
|
||||
return;
|
||||
}
|
||||
$scope.fetchingNotifications = false;
|
||||
$scope.notifications = n;
|
||||
$timeout(function() {
|
||||
$scope.$apply();
|
||||
}, 1);
|
||||
});
|
||||
}
|
||||
});
|
||||
|
|
|
|||
|
|
@ -1,11 +1,7 @@
|
|||
'use strict';
|
||||
|
||||
angular.module('copayApp.controllers').controller('amazonController',
|
||||
function($scope, $timeout, $ionicModal, $log, lodash, bwcError, amazonService, platformInfo, nodeWebkit) {
|
||||
|
||||
if (platformInfo.isCordova && StatusBar.isVisible) {
|
||||
StatusBar.backgroundColorByHexString("#4B6178");
|
||||
}
|
||||
function($scope, $timeout, $ionicModal, $log, lodash, bwcError, amazonService, platformInfo, nodeWebkit, popupService) {
|
||||
|
||||
$scope.openExternalLink = function(url, target) {
|
||||
if (platformInfo.isNW) {
|
||||
|
|
@ -21,7 +17,7 @@ angular.module('copayApp.controllers').controller('amazonController',
|
|||
$scope.network = amazonService.getEnvironment();
|
||||
amazonService.getPendingGiftCards(function(err, gcds) {
|
||||
if (err) {
|
||||
self.error = err;
|
||||
popupService.showAlert(err);
|
||||
return;
|
||||
}
|
||||
$scope.giftCards = lodash.isEmpty(gcds) ? null : gcds;
|
||||
|
|
@ -41,7 +37,7 @@ angular.module('copayApp.controllers').controller('amazonController',
|
|||
$log.debug("creating gift card");
|
||||
amazonService.createGiftCard(dataFromStorage, function(err, giftCard) {
|
||||
if (err) {
|
||||
$log.debug(bwcError.msg(err));
|
||||
popupService.showAlert(bwcError.msg(err));
|
||||
return;
|
||||
}
|
||||
if (giftCard.status != 'PENDING') {
|
||||
|
|
@ -61,7 +57,7 @@ angular.module('copayApp.controllers').controller('amazonController',
|
|||
$log.debug("Saving new gift card");
|
||||
amazonService.getPendingGiftCards(function(err, gcds) {
|
||||
if (err) {
|
||||
self.error = err;
|
||||
popupService.showAlert(err);
|
||||
return;
|
||||
}
|
||||
$scope.giftCards = gcds;
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
'use strict';
|
||||
|
||||
angular.module('copayApp.controllers').controller('amountController', function($rootScope, $scope, $filter, $timeout, $ionicScrollDelegate, platformInfo, lodash, configService, rateService, $stateParams, $window, $state, $log, txFormatService) {
|
||||
|
||||
angular.module('copayApp.controllers').controller('amountController', function($rootScope, $scope, $filter, $timeout, $ionicHistory, $ionicScrollDelegate, $ionicNavBarDelegate, gettextCatalog, platformInfo, lodash, configService, rateService, $stateParams, $window, $state, $log, txFormatService) {
|
||||
$ionicNavBarDelegate.title(gettextCatalog.getString('Enter Amount'));
|
||||
|
||||
var unitToSatoshi;
|
||||
var satToUnit;
|
||||
|
|
@ -63,7 +63,7 @@ angular.module('copayApp.controllers').controller('amountController', function($
|
|||
|
||||
// in SAT ALWAYS
|
||||
if ($stateParams.toAmount) {
|
||||
$scope.amount = (($stateParams.toAmount) * satToUnit).toFixed(unitDecimals) ;
|
||||
$scope.amount = (($stateParams.toAmount) * satToUnit).toFixed(unitDecimals);
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -188,13 +188,9 @@ angular.module('copayApp.controllers').controller('amountController', function($
|
|||
var amount = $scope.showAlternativeAmount ? fromFiat(_amount).toFixed(unitDecimals) : _amount.toFixed(unitDecimals);
|
||||
|
||||
$state.transitionTo('send.confirm', {
|
||||
toAmount:amount * unitToSatoshi,
|
||||
toAmount: amount * unitToSatoshi,
|
||||
toAddress: $scope.toAddress,
|
||||
toName: $scope.toName,
|
||||
});
|
||||
};
|
||||
|
||||
$scope.cancel = function() {
|
||||
$state.transitionTo('tabs.send');
|
||||
};
|
||||
});
|
||||
|
|
|
|||
19
src/js/controllers/backController.js
Normal file
19
src/js/controllers/backController.js
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
'use strict';
|
||||
|
||||
angular.module('copayApp.controllers').controller('backController', function($scope, $state, $stateParams, platformInfo) {
|
||||
|
||||
var isCordova = platformInfo.isCordova;
|
||||
var isWP = platformInfo.isWP;
|
||||
var usePushNotifications = isCordova && !isWP;
|
||||
|
||||
$scope.importGoBack = function() {
|
||||
if ($stateParams.fromOnboarding) $state.go('onboarding.welcome');
|
||||
else $state.go('tabs.add');
|
||||
};
|
||||
|
||||
$scope.onboardingMailSkip = function() {
|
||||
if (!usePushNotifications) $state.go('onboarding.backupRequest');
|
||||
else $state.go('onboarding.notifications');
|
||||
}
|
||||
|
||||
});
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
'use strict';
|
||||
|
||||
angular.module('copayApp.controllers').controller('backupController',
|
||||
function($rootScope, $scope, $timeout, $log, $state, $stateParams, $ionicPopup, $ionicNavBarDelegate, uxLanguage, lodash, fingerprintService, platformInfo, configService, profileService, bwcService, walletService, ongoingProcess) {
|
||||
function($rootScope, $scope, $timeout, $log, $state, $stateParams, $ionicPopup, $ionicNavBarDelegate, uxLanguage, lodash, fingerprintService, platformInfo, configService, profileService, bwcService, walletService, ongoingProcess, storageService) {
|
||||
var wallet = profileService.getWallet($stateParams.walletId);
|
||||
$ionicNavBarDelegate.title(wallet.credentials.walletName);
|
||||
$scope.n = wallet.n;
|
||||
|
|
@ -136,7 +136,7 @@ angular.module('copayApp.controllers').controller('backupController',
|
|||
}
|
||||
}
|
||||
|
||||
$rootScope.$emit('Local/BackupDone');
|
||||
profileService.setBackupFlag(walletClient.credentials.walletId);
|
||||
return cb();
|
||||
}, 1);
|
||||
};
|
||||
|
|
|
|||
|
|
@ -1,14 +1,10 @@
|
|||
'use strict';
|
||||
|
||||
angular.module('copayApp.controllers').controller('bitpayCardController', function($scope, $rootScope, $timeout, $log, $ionicModal, lodash, bitpayCardService, configService, profileService, walletService, ongoingProcess, pbkdf2Service, moment, platformInfo) {
|
||||
angular.module('copayApp.controllers').controller('bitpayCardController', function($scope, $timeout, $log, lodash, bitpayCardService, configService, profileService, walletService, ongoingProcess, pbkdf2Service, moment, popupService) {
|
||||
|
||||
var self = this;
|
||||
var wallet;
|
||||
|
||||
if (platformInfo.isCordova && StatusBar.isVisible) {
|
||||
StatusBar.backgroundColorByHexString("#293C92");
|
||||
}
|
||||
|
||||
$scope.$on('Wallet/Changed', function(event, w) {
|
||||
if (lodash.isEmpty(w)) {
|
||||
$log.debug('No wallet provided');
|
||||
|
|
@ -87,7 +83,7 @@ angular.module('copayApp.controllers').controller('bitpayCardController', functi
|
|||
bitpayCardService.transactionHistory(dateRange, function(err, history) {
|
||||
$scope.loadingHistory = false;
|
||||
if (err) {
|
||||
self.error = 'Error getting transactions';
|
||||
popupService.showAlert(gettextCatalog.getString('Error'), gettextCatalog.getString('Could not get transactions'));
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -120,13 +116,11 @@ angular.module('copayApp.controllers').controller('bitpayCardController', functi
|
|||
};
|
||||
|
||||
this.sendFunds = function() {
|
||||
self.error = null;
|
||||
|
||||
if (lodash.isEmpty(wallet)) return;
|
||||
|
||||
if (!wallet.canSign() && !wallet.isPrivKeyExternal()) {
|
||||
$log.info('No signing proposal: No private key');
|
||||
self.error = bwcError.msg('MISSING_PRIVATE_KEY');
|
||||
popupService.showAlert(gettextCatalog.getString('Error'), bwcError.msg('MISSING_PRIVATE_KEY'));
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -146,10 +140,7 @@ angular.module('copayApp.controllers').controller('bitpayCardController', functi
|
|||
bitpayCardService.topUp(dataSrc, function(err, invoiceId) {
|
||||
if (err) {
|
||||
ongoingProcess.set('Processing Transaction...', false);
|
||||
self.error = bwcError.msg(err);
|
||||
$timeout(function() {
|
||||
$scope.$digest();
|
||||
});
|
||||
popupService.showAlert(gettextCatalog.getString('Error'), bwcError.msg(err));
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -178,18 +169,12 @@ angular.module('copayApp.controllers').controller('bitpayCardController', functi
|
|||
|
||||
walletService.createTx(wallet, txp, function(err, createdTxp) {
|
||||
if (err) {
|
||||
self.error = bwcError.msg(err);
|
||||
$timeout(function() {
|
||||
$scope.$digest();
|
||||
});
|
||||
popupService.showAlert(gettextCatalog.getString('Error'), bwcError.msg(err));
|
||||
return;
|
||||
}
|
||||
walletService.publishAndSign(wallet, createdTxp, function(err, tx) {
|
||||
if (err) {
|
||||
self.error = err;
|
||||
$timeout(function() {
|
||||
$scope.$digest();
|
||||
});
|
||||
popupService.showAlert(gettextCatalog.getString('Error'), bwcError.msg(err));
|
||||
return;
|
||||
}
|
||||
self.update();
|
||||
|
|
@ -205,7 +190,6 @@ angular.module('copayApp.controllers').controller('bitpayCardController', functi
|
|||
};
|
||||
|
||||
this.authenticate = function() {
|
||||
self.error = null;
|
||||
|
||||
var data = {
|
||||
emailAddress : $scope.email,
|
||||
|
|
@ -219,7 +203,7 @@ angular.module('copayApp.controllers').controller('bitpayCardController', functi
|
|||
bitpayCardService.authenticate(data, function(err, auth) {
|
||||
self.authenticating = false;
|
||||
if (err && err.data && err.data.error && !err.data.error.twoFactorPending) {
|
||||
self.error = err.statusText || err.data.error || 'Authentiation error';
|
||||
popupService.showAlert(gettextCatalog.getString('Error'), err.statusText || err.data.error || 'Authentiation error');
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -231,7 +215,6 @@ angular.module('copayApp.controllers').controller('bitpayCardController', functi
|
|||
};
|
||||
|
||||
this.authenticate2FA = function() {
|
||||
self.error = null;
|
||||
|
||||
var data = {
|
||||
twoFactorCode : $scope.twoFactorCode
|
||||
|
|
@ -241,7 +224,7 @@ angular.module('copayApp.controllers').controller('bitpayCardController', functi
|
|||
bitpayCardService.authenticate2FA(data, function(err, auth) {
|
||||
self.authenticating = false;
|
||||
if (err) {
|
||||
self.error = 'Authentiation error';
|
||||
popupService.showAlert(gettextCatalog.getString('Error'), gettextCatalog.getString('Authentiation error'));
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
'use strict';
|
||||
|
||||
angular.module('copayApp.controllers').controller('buyAmazonController',
|
||||
function($rootScope, $scope, $ionicModal, $log, $timeout, $state, $ionicPopup, lodash, profileService, bwcError, gettext, configService, walletService, fingerprintService, amazonService, ongoingProcess, platformInfo, nodeWebkit) {
|
||||
function($scope, $log, $timeout, $state, lodash, profileService, bwcError, gettextCatalog, configService, walletService, amazonService, ongoingProcess, platformInfo, nodeWebkit, popupService) {
|
||||
|
||||
var self = this;
|
||||
var wallet;
|
||||
|
|
@ -33,14 +33,13 @@ angular.module('copayApp.controllers').controller('buyAmazonController',
|
|||
};
|
||||
|
||||
this.createTx = function() {
|
||||
self.error = null;
|
||||
self.errorInfo = null;
|
||||
|
||||
if (lodash.isEmpty(wallet)) return;
|
||||
|
||||
if (!wallet.canSign() && !wallet.isPrivKeyExternal()) {
|
||||
$log.info('No signing proposal: No private key');
|
||||
self.error = bwcError.msg('MISSING_PRIVATE_KEY');
|
||||
popupService.showAlert(gettextCatalog.getString('Error'), bwcError.msg('MISSING_PRIVATE_KEY'));
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -60,20 +59,14 @@ angular.module('copayApp.controllers').controller('buyAmazonController',
|
|||
amazonService.createBitPayInvoice(dataSrc, function(err, dataInvoice) {
|
||||
if (err) {
|
||||
ongoingProcess.set('Processing Transaction...', false);
|
||||
self.error = bwcError.msg(err);
|
||||
$timeout(function() {
|
||||
$scope.$digest();
|
||||
});
|
||||
popupService.showAlert(gettextCatalog.getString('Error'), bwcError.msg(err));
|
||||
return;
|
||||
}
|
||||
|
||||
amazonService.getBitPayInvoice(dataInvoice.invoiceId, function(err, invoice) {
|
||||
if (err) {
|
||||
ongoingProcess.set('Processing Transaction...', false);
|
||||
self.error = bwcError.msg(err);
|
||||
$timeout(function() {
|
||||
$scope.$digest();
|
||||
});
|
||||
popupService.showAlert(gettextCatalog.getString('Error'), bwcError.msg(err));
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -88,19 +81,16 @@ angular.module('copayApp.controllers').controller('buyAmazonController',
|
|||
$log.warn('Could not fetch payment request:', err);
|
||||
var msg = err.toString();
|
||||
if (msg.match('HTTP')) {
|
||||
msg = gettext('Could not fetch payment information');
|
||||
msg = gettextCatalog.getString('Could not fetch payment information');
|
||||
}
|
||||
self.error = msg;
|
||||
$timeout(function() {
|
||||
$scope.$digest();
|
||||
});
|
||||
popupService.showAlert(gettextCatalog.getString('Error'), msg);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!paypro.verified) {
|
||||
ongoingProcess.set('Processing Transaction...', false);
|
||||
$log.warn('Failed to verify payment protocol signatures');
|
||||
self.error = gettext('Payment Protocol Invalid');
|
||||
popupService.showAlert(gettextCatalog.getString('Error'), gettextCatalog.getString('Payment Protocol Invalid'));
|
||||
$timeout(function() {
|
||||
$scope.$digest();
|
||||
});
|
||||
|
|
@ -133,16 +123,13 @@ angular.module('copayApp.controllers').controller('buyAmazonController',
|
|||
walletService.createTx(wallet, txp, function(err, createdTxp) {
|
||||
ongoingProcess.set('Processing Transaction...', false);
|
||||
if (err) {
|
||||
self.error = bwcError.msg(err);
|
||||
$timeout(function() {
|
||||
$scope.$digest();
|
||||
});
|
||||
popupService.showAlert(gettextCatalog.getString('Error'), bwcError.msg(err));
|
||||
return;
|
||||
}
|
||||
walletService.publishAndSign(wallet, createdTxp, function(err, tx) {
|
||||
if (err) {
|
||||
ongoingProcess.set('Processing Transaction...', false);
|
||||
self.error = bwcError.msg(err);
|
||||
popupService.showAlert(gettextCatalog.getString('Error'), bwcError.msg(err));
|
||||
walletService.removeTx(wallet, tx, function(err) {
|
||||
if (err) $log.debug(err);
|
||||
});
|
||||
|
|
@ -182,7 +169,7 @@ angular.module('copayApp.controllers').controller('buyAmazonController',
|
|||
giftCard = {};
|
||||
giftCard.status = 'FAILURE';
|
||||
ongoingProcess.set('Processing Transaction...', false);
|
||||
self.error = bwcError.msg(err);
|
||||
popupService.showAlert(gettextCatalog.getString('Error'), bwcError.msg(err));
|
||||
self.errorInfo = dataSrc;
|
||||
$timeout(function() {
|
||||
$scope.$digest();
|
||||
|
|
|
|||
|
|
@ -1,19 +1,26 @@
|
|||
'use strict';
|
||||
|
||||
angular.module('copayApp.controllers').controller('buyGlideraController',
|
||||
function($scope, $timeout, $log, $ionicModal, profileService, walletService, glideraService, bwcError, lodash, ongoingProcess) {
|
||||
function($scope, $timeout, $log, profileService, walletService, glideraService, bwcError, lodash, ongoingProcess, popupService, gettextCatalog) {
|
||||
|
||||
var wallet;
|
||||
var self = this;
|
||||
this.show2faCodeInput = null;
|
||||
this.error = null;
|
||||
this.success = null;
|
||||
|
||||
$scope.$on('Wallet/Changed', function(event, w) {
|
||||
if (lodash.isEmpty(w)) {
|
||||
$log.debug('No wallet provided');
|
||||
return;
|
||||
}
|
||||
wallet = w;
|
||||
$log.debug('Wallet changed: ' + w.name);
|
||||
});
|
||||
|
||||
$scope.init = function(accessToken) {
|
||||
$scope.network = glideraService.getEnvironment();
|
||||
|
||||
$scope.token = accessToken;
|
||||
$scope.error = null;
|
||||
$scope.permissions = null;
|
||||
$scope.email = null;
|
||||
$scope.personalInfo = null;
|
||||
|
|
@ -25,7 +32,7 @@ angular.module('copayApp.controllers').controller('buyGlideraController',
|
|||
glideraService.init($scope.token, function(err, glidera) {
|
||||
ongoingProcess.set('connectingGlidera');
|
||||
if (err || !glidera) {
|
||||
$scope.error = err;
|
||||
if (err) popupService.showAlert(gettextCatalog.getString('Error'), err);
|
||||
return;
|
||||
}
|
||||
$scope.token = glidera.token;
|
||||
|
|
@ -33,21 +40,11 @@ angular.module('copayApp.controllers').controller('buyGlideraController',
|
|||
$scope.update({fullUpdate: true});
|
||||
});
|
||||
|
||||
self.allWallets = profileService.getWallets({
|
||||
$scope.wallets = profileService.getWallets({
|
||||
network: $scope.network,
|
||||
n: 1,
|
||||
onlyComplete: true
|
||||
});
|
||||
if (lodash.isEmpty(self.allWallets)) return;
|
||||
|
||||
wallet = self.allWallets[0];
|
||||
if (wallet) {
|
||||
$timeout(function() {
|
||||
self.selectedWalletId = wallet.credentials.walletId;
|
||||
self.selectedWalletName = wallet.credentials.walletName;
|
||||
$scope.$apply();
|
||||
}, 100);
|
||||
}
|
||||
};
|
||||
|
||||
$scope.update = function(opts) {
|
||||
|
|
@ -84,33 +81,6 @@ angular.module('copayApp.controllers').controller('buyGlideraController',
|
|||
}
|
||||
};
|
||||
|
||||
$scope.openWalletsModal = function(wallets) {
|
||||
self.error = null;
|
||||
|
||||
$scope.type = 'BUY';
|
||||
$scope.wallets = wallets;
|
||||
$scope.noColor = true;
|
||||
$scope.self = self;
|
||||
|
||||
$ionicModal.fromTemplateUrl('views/modals/wallets.html', {
|
||||
scope: $scope,
|
||||
animation: 'slide-in-up'
|
||||
}).then(function(modal) {
|
||||
$scope.walletsModal = modal;
|
||||
$scope.walletsModal.show();
|
||||
});
|
||||
|
||||
$scope.$on('walletSelected', function(ev, walletId) {
|
||||
$timeout(function() {
|
||||
wallet = profileService.getClient(walletId);
|
||||
self.selectedWalletId = walletId;
|
||||
self.selectedWalletName = wallet.credentials.walletName;
|
||||
$scope.$apply();
|
||||
}, 100);
|
||||
$scope.walletsModal.hide();
|
||||
});
|
||||
};
|
||||
|
||||
this.getBuyPrice = function(token, price) {
|
||||
var self = this;
|
||||
this.error = null;
|
||||
|
|
@ -122,7 +92,7 @@ angular.module('copayApp.controllers').controller('buyGlideraController',
|
|||
glideraService.buyPrice(token, price, function(err, buyPrice) {
|
||||
self.gettingBuyPrice = false;
|
||||
if (err) {
|
||||
self.error = 'Could not get exchange information. Please, try again.';
|
||||
popupService.showAlert(gettextCatalog.getString('Error'), gettextCatalog.getString('Could not get exchange information. Please, try again'));
|
||||
return;
|
||||
}
|
||||
self.buyPrice = buyPrice;
|
||||
|
|
@ -131,13 +101,12 @@ angular.module('copayApp.controllers').controller('buyGlideraController',
|
|||
|
||||
this.get2faCode = function(token) {
|
||||
var self = this;
|
||||
self.error = null;
|
||||
ongoingProcess.set('Sending 2FA code...', true);
|
||||
$timeout(function() {
|
||||
glideraService.get2faCode(token, function(err, sent) {
|
||||
ongoingProcess.set('Sending 2FA code...', false);
|
||||
if (err) {
|
||||
self.error = 'Could not send confirmation code to your phone';
|
||||
popupService.showAlert(gettextCatalog.getString('Error'), gettextCatalog.getString('Could not send confirmation code to your phone'));
|
||||
return;
|
||||
}
|
||||
self.show2faCodeInput = sent;
|
||||
|
|
@ -147,13 +116,12 @@ angular.module('copayApp.controllers').controller('buyGlideraController',
|
|||
|
||||
this.sendRequest = function(token, permissions, twoFaCode) {
|
||||
var self = this;
|
||||
self.error = null;
|
||||
ongoingProcess.set('Buying Bitcoin...', true);
|
||||
$timeout(function() {
|
||||
walletService.getAddress(wallet, false, function(err, walletAddr) {
|
||||
if (err) {
|
||||
ongoingProcess.set('Buying Bitcoin...', false);
|
||||
self.error = bwcError.cb(err, 'Could not create address');
|
||||
popupService.showAlert(gettextCatalog.getString('Error'), bwcError.cb(err, 'Could not create address'));
|
||||
return;
|
||||
}
|
||||
var data = {
|
||||
|
|
@ -166,11 +134,13 @@ angular.module('copayApp.controllers').controller('buyGlideraController',
|
|||
glideraService.buy(token, twoFaCode, data, function(err, data) {
|
||||
ongoingProcess.set('Buying Bitcoin...', false);
|
||||
if (err) {
|
||||
self.error = err;
|
||||
popupService.showAlert(gettextCatalog.getString('Error'), err);
|
||||
return;
|
||||
}
|
||||
self.success = data;
|
||||
$scope.$emit('Local/GlideraTx');
|
||||
$timeout(function() {
|
||||
$scope.$digest();
|
||||
});
|
||||
});
|
||||
});
|
||||
}, 100);
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
'use strict';
|
||||
|
||||
angular.module('copayApp.controllers').controller('confirmController', function($rootScope, $scope, $filter, $timeout, $ionicScrollDelegate, gettextCatalog, walletService, platformInfo, lodash, configService, rateService, $stateParams, $window, $state, $log, profileService, bitcore, $ionicPopup, txStatus, gettext, txFormatService, ongoingProcess, $ionicModal) {
|
||||
|
||||
angular.module('copayApp.controllers').controller('confirmController', function($rootScope, $scope, $filter, $timeout, $ionicScrollDelegate, $ionicNavBarDelegate, gettextCatalog, walletService, platformInfo, lodash, configService, rateService, $stateParams, $window, $state, $log, profileService, bitcore, $ionicPopup, txStatus, gettext, txFormatService, ongoingProcess, $ionicModal) {
|
||||
$ionicNavBarDelegate.title(gettextCatalog.getString('Confirm'));
|
||||
var cachedTxp = {};
|
||||
var isChromeApp = platformInfo.isChromeApp;
|
||||
|
||||
|
|
@ -198,7 +198,7 @@ angular.module('copayApp.controllers').controller('confirmController', function(
|
|||
$scope.$apply();
|
||||
};
|
||||
|
||||
var createTx = function(wallet, cb) {
|
||||
var createTx = function(wallet, cb) {
|
||||
var config = configService.getSync().wallet;
|
||||
var currentSpendUnconfirmed = config.spendUnconfirmed;
|
||||
var outputs = [];
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
'use strict';
|
||||
|
||||
angular.module('copayApp.controllers').controller('createController',
|
||||
function($scope, $rootScope, $timeout, $log, lodash, $state, profileService, configService, gettext, ledger, trezor, platformInfo, derivationPathHelper, ongoingProcess, walletService) {
|
||||
function($scope, $rootScope, $timeout, $log, lodash, $state, $ionicScrollDelegate, profileService, configService, gettext, ledger, trezor, platformInfo, derivationPathHelper, ongoingProcess, walletService, storageService) {
|
||||
|
||||
var isChromeApp = platformInfo.isChromeApp;
|
||||
var isCordova = platformInfo.isCordova;
|
||||
|
|
@ -37,6 +37,10 @@ angular.module('copayApp.controllers').controller('createController',
|
|||
return new Array(num);
|
||||
}
|
||||
|
||||
$scope.showAdvChange = function() {
|
||||
$ionicScrollDelegate.resize();
|
||||
};
|
||||
|
||||
var updateRCSelect = function(n) {
|
||||
$scope.totalCopayers = n;
|
||||
var maxReq = COPAYER_PAIR_LIMITS[n];
|
||||
|
|
@ -183,9 +187,7 @@ angular.module('copayApp.controllers').controller('createController',
|
|||
|
||||
|
||||
if (self.seedSourceId == 'set') {
|
||||
$timeout(function() {
|
||||
$rootScope.$emit('Local/BackupDone');
|
||||
}, 1);
|
||||
profileService.setBackupFlag(client.credentials.walletId);
|
||||
}
|
||||
$state.go('tabs.home')
|
||||
});
|
||||
|
|
|
|||
|
|
@ -1,69 +0,0 @@
|
|||
'use strict';
|
||||
|
||||
angular.module('copayApp.controllers').controller('disclaimerController',
|
||||
function($scope, $rootScope, $timeout, $log, $ionicSideMenuDelegate, profileService, applicationService, gettextCatalog, uxLanguage, $state, storageService, gettext, platformInfo, ongoingProcess) {
|
||||
var tries = 0;
|
||||
var isCordova = platformInfo.isCordova;
|
||||
|
||||
ongoingProcess.set('creatingWallet', true);
|
||||
|
||||
var create = function(opts) {
|
||||
opts = opts || {};
|
||||
$log.debug('Creating profile');
|
||||
|
||||
profileService.create(opts, function(err) {
|
||||
if (err) {
|
||||
$log.warn(err);
|
||||
$scope.error = err;
|
||||
$scope.$apply();
|
||||
|
||||
return $timeout(function() {
|
||||
$log.warn('Retrying to create profile......');
|
||||
if (tries == 3) {
|
||||
tries == 0;
|
||||
return create({
|
||||
noWallet: true
|
||||
});
|
||||
} else {
|
||||
tries += 1;
|
||||
return create();
|
||||
}
|
||||
}, 3000);
|
||||
};
|
||||
$scope.error = "";
|
||||
ongoingProcess.set('creatingWallet', false);
|
||||
});
|
||||
};
|
||||
|
||||
$scope.init = function(opts) {
|
||||
$ionicSideMenuDelegate.canDragContent(false);
|
||||
$scope.lang = uxLanguage.currentLanguage;
|
||||
|
||||
storageService.getProfile(function(err, profile) {
|
||||
if (!profile) {
|
||||
create(opts);
|
||||
} else {
|
||||
$log.info('There is already a profile');
|
||||
ongoingProcess.set('creatingWallet', false);
|
||||
profileService.bindProfile(profile, function(err) {
|
||||
if (!err || !err.message || !err.message.match('NONAGREEDDISCLAIMER')) {
|
||||
$log.debug('Disclaimer already accepted at #disclaimer. Redirect to Wallet Home.');
|
||||
$ionicSideMenuDelegate.canDragContent(true);
|
||||
$state.go('tabs.home');
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
$scope.accept = function() {
|
||||
profileService.setDisclaimerAccepted(function(err) {
|
||||
if (err) $log.error(err);
|
||||
else {
|
||||
$ionicSideMenuDelegate.canDragContent(true);
|
||||
$rootScope.$emit('disclaimerAccepted');
|
||||
$state.go('tabs.home');
|
||||
}
|
||||
});
|
||||
};
|
||||
});
|
||||
|
|
@ -1,11 +1,7 @@
|
|||
'use strict';
|
||||
|
||||
angular.module('copayApp.controllers').controller('glideraController',
|
||||
function($rootScope, $scope, $timeout, $ionicModal, $log, profileService, storageService, glideraService, lodash, ongoingProcess, platformInfo, nodeWebkit) {
|
||||
|
||||
if (platformInfo.isCordova && StatusBar.isVisible) {
|
||||
StatusBar.backgroundColorByHexString("#4B6178");
|
||||
}
|
||||
function($scope, $timeout, $ionicModal, $log, storageService, glideraService, ongoingProcess, platformInfo, nodeWebkit, popupService, gettextCatalog) {
|
||||
|
||||
$scope.openExternalLink = function(url, target) {
|
||||
if (platformInfo.isNW) {
|
||||
|
|
@ -20,7 +16,6 @@ angular.module('copayApp.controllers').controller('glideraController',
|
|||
$scope.network = glideraService.getEnvironment();
|
||||
|
||||
$scope.token = null;
|
||||
$scope.error = null;
|
||||
$scope.permissions = null;
|
||||
$scope.email = null;
|
||||
$scope.personalInfo = null;
|
||||
|
|
@ -32,7 +27,7 @@ angular.module('copayApp.controllers').controller('glideraController',
|
|||
glideraService.init($scope.token, function(err, glidera) {
|
||||
ongoingProcess.set('connectingGlidera');
|
||||
if (err || !glidera) {
|
||||
$scope.error = err;
|
||||
if (err) popupService.showAlert(gettextCatalog.getString('Error'), err);
|
||||
return;
|
||||
}
|
||||
$scope.token = glidera.token;
|
||||
|
|
@ -81,15 +76,11 @@ angular.module('copayApp.controllers').controller('glideraController',
|
|||
|
||||
this.submitOauthCode = function(code) {
|
||||
ongoingProcess.set('connectingGlidera', true);
|
||||
$scope.error = null;
|
||||
$timeout(function() {
|
||||
glideraService.getToken(code, function(err, data) {
|
||||
ongoingProcess.set('connectingGlidera', false);
|
||||
if (err) {
|
||||
$scope.error = err;
|
||||
$timeout(function() {
|
||||
$scope.$apply();
|
||||
}, 100);
|
||||
popupService.showAlert(gettextCatalog.getString('Error'), err);
|
||||
} else if (data && data.access_token) {
|
||||
storageService.setGlideraToken($scope.network, data.access_token, function() {
|
||||
$scope.init(data.access_token);
|
||||
|
|
@ -108,7 +99,11 @@ angular.module('copayApp.controllers').controller('glideraController',
|
|||
$scope.self = self;
|
||||
$scope.tx = tx;
|
||||
|
||||
glideraService.getTransaction(token, tx.transactionUuid, function(error, tx) {
|
||||
glideraService.getTransaction(token, tx.transactionUuid, function(err, tx) {
|
||||
if (err) {
|
||||
popupService.showAlert(gettextCatalog.getString('Error'), gettextCatalog.getString('Could not get transactions'));
|
||||
return;
|
||||
}
|
||||
$scope.tx = tx;
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -1,41 +1,34 @@
|
|||
'use strict';
|
||||
angular.module('copayApp.controllers').controller('glideraUriController',
|
||||
function($scope, $log, $stateParams, $timeout, profileService, configService, glideraService, storageService, $state, ongoingProcess) {
|
||||
function($scope, $log, $stateParams, $timeout, glideraService, storageService, $state, ongoingProcess, popupService, gettextCatalog) {
|
||||
|
||||
this.submitOauthCode = function(code) {
|
||||
var submitOauthCode = function(code) {
|
||||
$log.debug('Glidera Oauth Code:' + code);
|
||||
var self = this;
|
||||
var glideraTestnet = configService.getSync().glidera.testnet;
|
||||
var network = glideraTestnet ? 'testnet' : 'livenet';
|
||||
$scope.network = glideraService.getEnvironment();
|
||||
ongoingProcess.set('connectingGlidera', true);
|
||||
this.error = null;
|
||||
$timeout(function() {
|
||||
glideraService.getToken(code, function(err, data) {
|
||||
ongoingProcess.set('connectingGlidera', false);
|
||||
if (err) {
|
||||
self.error = err;
|
||||
$timeout(function() {
|
||||
$scope.$apply();
|
||||
}, 100);
|
||||
popupService.showAlert(gettextCatalog.getString('Error'), err);
|
||||
} else if (data && data.access_token) {
|
||||
storageService.setGlideraToken(network, data.access_token, function() {
|
||||
$scope.$emit('Local/GlideraUpdated', data.access_token);
|
||||
storageService.setGlideraToken($scope.network, data.access_token, function() {
|
||||
$timeout(function() {
|
||||
$state.go('glidera');
|
||||
$state.go('glidera.main');
|
||||
$scope.$apply();
|
||||
}, 100);
|
||||
}, 500);
|
||||
});
|
||||
}
|
||||
});
|
||||
}, 100);
|
||||
};
|
||||
|
||||
this.checkCode = function() {
|
||||
$scope.checkCode = function() {
|
||||
if ($stateParams.url) {
|
||||
var match = $stateParams.url.match(/code=(.+)/);
|
||||
if (match && match[1]) {
|
||||
this.code = match[1];
|
||||
return this.submitOauthCode(this.code);
|
||||
submitOauthCode(match[1]);
|
||||
return;
|
||||
}
|
||||
}
|
||||
$log.error('Bad state: ' + JSON.stringify($stateParams));
|
||||
|
|
|
|||
|
|
@ -15,10 +15,6 @@ angular.module('copayApp.controllers').controller('importController',
|
|||
$scope.account = 1;
|
||||
$scope.importErr = false;
|
||||
|
||||
$scope.goBack = function() {
|
||||
$ionicHistory.goBack();
|
||||
};
|
||||
|
||||
var updateSeedSourceSelect = function() {
|
||||
$scope.seedOptions = [];
|
||||
|
||||
|
|
@ -113,7 +109,12 @@ angular.module('copayApp.controllers').controller('importController',
|
|||
$log.debug('Remote preferences saved for:' + client.credentials.walletId)
|
||||
});
|
||||
|
||||
$rootScope.$emit('Local/WalletImported', client.credentials.walletId);
|
||||
profileService.setBackupFlag(client.credentials.walletId);
|
||||
if ($stateParams.fromOnboarding) {
|
||||
profileService.setDisclaimerAccepted(function(err) {
|
||||
if (err) $log.error(err);
|
||||
});
|
||||
}
|
||||
$state.go('tabs.home');
|
||||
});
|
||||
}, 100);
|
||||
|
|
@ -140,7 +141,12 @@ angular.module('copayApp.controllers').controller('importController',
|
|||
$log.debug('Remote preferences saved for:' + client.credentials.walletId)
|
||||
});
|
||||
|
||||
$rootScope.$emit('Local/WalletImported', client.credentials.walletId);
|
||||
profileService.setBackupFlag(client.credentials.walletId);
|
||||
if ($stateParams.fromOnboarding) {
|
||||
profileService.setDisclaimerAccepted(function(err) {
|
||||
if (err) $log.error(err);
|
||||
});
|
||||
}
|
||||
$state.go('tabs.home');
|
||||
});
|
||||
}, 100);
|
||||
|
|
@ -160,7 +166,13 @@ angular.module('copayApp.controllers').controller('importController',
|
|||
$scope.$apply();
|
||||
});
|
||||
}
|
||||
$rootScope.$emit('Local/WalletImported', walletId);
|
||||
|
||||
profileService.setBackupFlag(walletId);
|
||||
if ($stateParams.fromOnboarding) {
|
||||
profileService.setDisclaimerAccepted(function(err) {
|
||||
if (err) $log.error(err);
|
||||
});
|
||||
}
|
||||
$state.go('tabs.home');
|
||||
});
|
||||
}, 100);
|
||||
|
|
@ -189,7 +201,12 @@ angular.module('copayApp.controllers').controller('importController',
|
|||
$log.debug('Remote preferences saved for:' + client.credentials.walletId)
|
||||
});
|
||||
|
||||
$rootScope.$emit('Local/WalletImported', client.credentials.walletId);
|
||||
profileService.setBackupFlag(client.credentials.walletId);
|
||||
if ($stateParams.fromOnboarding) {
|
||||
profileService.setDisclaimerAccepted(function(err) {
|
||||
if (err) $log.error(err);
|
||||
});
|
||||
}
|
||||
$state.go('tabs.home');
|
||||
});
|
||||
}, 100);
|
||||
|
|
@ -323,7 +340,13 @@ angular.module('copayApp.controllers').controller('importController',
|
|||
walletService.updateRemotePreferences(wallet, {}, function() {
|
||||
$log.debug('Remote preferences saved for:' + wallet.walletId)
|
||||
});
|
||||
$rootScope.$emit('Local/WalletImported', wallet.walletId);
|
||||
|
||||
profileService.setBackupFlag(wallet.walletId);
|
||||
if ($stateParams.fromOnboarding) {
|
||||
profileService.setDisclaimerAccepted(function(err) {
|
||||
if (err) $log.error(err);
|
||||
});
|
||||
}
|
||||
$state.go('tabs.home');
|
||||
});
|
||||
}, 100);
|
||||
|
|
@ -400,7 +423,13 @@ angular.module('copayApp.controllers').controller('importController',
|
|||
walletService.updateRemotePreferences(wallet, {}, function() {
|
||||
$log.debug('Remote preferences saved for:' + wallet.walletId)
|
||||
});
|
||||
$rootScope.$emit('Local/WalletImported', wallet.walletId);
|
||||
|
||||
profileService.setBackupFlag(wallet.walletId);
|
||||
if ($stateParams.fromOnboarding) {
|
||||
profileService.setDisclaimerAccepted(function(err) {
|
||||
if (err) $log.error(err);
|
||||
});
|
||||
}
|
||||
$state.go('tabs.home');
|
||||
});
|
||||
}, 100);
|
||||
|
|
|
|||
|
|
@ -1,13 +1,13 @@
|
|||
'use strict';
|
||||
|
||||
angular.module('copayApp.controllers').controller('amazonCardDetailsController', function($scope, $log, $timeout, bwcError, amazonService, lodash, ongoingProcess) {
|
||||
angular.module('copayApp.controllers').controller('amazonCardDetailsController', function($scope, $log, $timeout, bwcError, amazonService, lodash, ongoingProcess, popupService, gettextCatalog) {
|
||||
|
||||
$scope.cancelGiftCard = function() {
|
||||
ongoingProcess.set('Canceling gift card...', true);
|
||||
amazonService.cancelGiftCard($scope.card, function(err, data) {
|
||||
ongoingProcess.set('Canceling gift card...', false);
|
||||
if (err) {
|
||||
$scope.error = bwcError.msg(err);
|
||||
popupService.showAlert(gettextCatalog.getString('Error'), bwcError.msg(err));
|
||||
return;
|
||||
}
|
||||
$scope.card.cardStatus = data.cardStatus;
|
||||
|
|
@ -29,7 +29,7 @@ angular.module('copayApp.controllers').controller('amazonCardDetailsController',
|
|||
$scope.refreshGiftCard = function() {
|
||||
amazonService.getPendingGiftCards(function(err, gcds) {
|
||||
if (err) {
|
||||
self.error = err;
|
||||
popupService.showAlert(gettextCatalog.getString('Error'), err);
|
||||
return;
|
||||
}
|
||||
lodash.forEach(gcds, function(dataFromStorage) {
|
||||
|
|
@ -37,8 +37,7 @@ angular.module('copayApp.controllers').controller('amazonCardDetailsController',
|
|||
$log.debug("creating gift card");
|
||||
amazonService.createGiftCard(dataFromStorage, function(err, giftCard) {
|
||||
if (err) {
|
||||
self.error = bwcError.msg(err);
|
||||
$log.debug(bwcError.msg(err));
|
||||
popupService.showAlert(gettextCatalog.getString('Error'), bwcError.msg(err));
|
||||
return;
|
||||
}
|
||||
if (!lodash.isEmpty(giftCard)) {
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
'use strict';
|
||||
|
||||
angular.module('copayApp.controllers').controller('backupWarningController', function($scope, $state, $ionicPopup, profileService) {
|
||||
angular.module('copayApp.controllers').controller('backupWarningController', function($scope, $state, $ionicPopup, $stateParams, profileService) {
|
||||
|
||||
$scope.openPopup = function() {
|
||||
var backupWarningPopup = $ionicPopup.show({
|
||||
|
|
@ -10,12 +10,10 @@ angular.module('copayApp.controllers').controller('backupWarningController', fun
|
|||
|
||||
$scope.close = function() {
|
||||
backupWarningPopup.close();
|
||||
var wallet = profileService.getWallets()[0];
|
||||
$state.go('wallet.backup', {
|
||||
walletId: wallet.credentials.walletId,
|
||||
walletId: $stateParams.walletId,
|
||||
fromOnboarding: true
|
||||
})
|
||||
};
|
||||
}
|
||||
|
||||
});
|
||||
|
|
|
|||
|
|
@ -6,11 +6,6 @@ angular.module('copayApp.controllers').controller('collectEmailController', func
|
|||
var isWP = platformInfo.isWP;
|
||||
var usePushNotifications = isCordova && !isWP;
|
||||
|
||||
$scope.skip = function() {
|
||||
if (!usePushNotifications) $state.go('onboarding.backupRequest');
|
||||
else $state.go('onboarding.notifications');
|
||||
}
|
||||
|
||||
$scope.save = function(form) {
|
||||
var wallet = profileService.getWallet($stateParams.walletId);
|
||||
var email = $scope.email || '';
|
||||
|
|
|
|||
|
|
@ -2,8 +2,9 @@
|
|||
angular.module('copayApp.controllers').controller('tourController',
|
||||
function($scope, $state, $log, $timeout, ongoingProcess, profileService) {
|
||||
|
||||
$scope.init = function() {
|
||||
var tries = 0;
|
||||
|
||||
$scope.init = function() {
|
||||
$scope.data = {
|
||||
index: 0
|
||||
};
|
||||
|
|
@ -16,33 +17,25 @@ angular.module('copayApp.controllers').controller('tourController',
|
|||
}
|
||||
};
|
||||
|
||||
$scope.createProfile = function(opts) {
|
||||
var tries = 0;
|
||||
opts = opts || {};
|
||||
$log.debug('Creating profile');
|
||||
$scope.createDefaultWallet = function() {
|
||||
ongoingProcess.set('creatingWallet', true);
|
||||
profileService.create(opts, function(err) {
|
||||
profileService.createDefaultWallet(function(err, walletClient) {
|
||||
if (err) {
|
||||
$log.warn(err);
|
||||
$scope.error = err;
|
||||
$scope.$apply();
|
||||
|
||||
return $timeout(function() {
|
||||
$log.warn('Retrying to create profile......');
|
||||
$log.warn('Retrying to create default wallet......');
|
||||
if (tries == 3) {
|
||||
tries == 0;
|
||||
return $scope.createProfile({
|
||||
noWallet: true
|
||||
});
|
||||
return $scope.createDefaultWallet();
|
||||
} else {
|
||||
tries += 1;
|
||||
return $scope.createProfile();
|
||||
return $scope.createDefaultWallet();
|
||||
}
|
||||
}, 3000);
|
||||
};
|
||||
$scope.error = "";
|
||||
ongoingProcess.set('creatingWallet', false);
|
||||
var wallet = profileService.getWallets()[0];
|
||||
var wallet = walletClient;
|
||||
$state.go('onboarding.collectEmail', {
|
||||
walletId: wallet.credentials.walletId
|
||||
});
|
||||
|
|
|
|||
18
src/js/controllers/onboarding/welcomeController.js
Normal file
18
src/js/controllers/onboarding/welcomeController.js
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
'use strict';
|
||||
|
||||
angular.module('copayApp.controllers').controller('welcomeController', function($scope, $state, $timeout, $log, $ionicPopup, profileService) {
|
||||
|
||||
$scope.goImport = function() {
|
||||
$state.go('tabs.import.phrase', {
|
||||
fromOnboarding: true
|
||||
});
|
||||
};
|
||||
|
||||
$scope.createProfile = function() {
|
||||
$log.debug('Creating profile');
|
||||
profileService.createProfile(function(err) {
|
||||
if (err) $log.warn(err);
|
||||
});
|
||||
};
|
||||
|
||||
});
|
||||
|
|
@ -1,14 +1,12 @@
|
|||
'use strict';
|
||||
|
||||
angular.module('copayApp.controllers').controller('preferencesDeleteWordsController', function($scope, $ionicHistory, $stateParams, $ionicNavBarDelegate, gettextCatalog, confirmDialog, lodash, profileService, walletService, gettext) {
|
||||
angular.module('copayApp.controllers').controller('preferencesDeleteWordsController', function($scope, $ionicHistory, $stateParams, $ionicNavBarDelegate, gettextCatalog, confirmDialog, lodash, profileService, gettext) {
|
||||
$ionicNavBarDelegate.title(gettextCatalog.getString('Delete recovery phrase'));
|
||||
var wallet = profileService.getWallet($stateParams.walletId);
|
||||
var msg = gettext('Are you sure you want to delete the recovery phrase?');
|
||||
var successMsg = gettext('Recovery phrase deleted');
|
||||
$scope.needsBackup = wallet.needsBackup;
|
||||
|
||||
walletService.needsBackup(wallet, function(needsBackup) {
|
||||
$scope.needsBackup = needsBackup;
|
||||
});
|
||||
if (lodash.isEmpty(wallet.credentials.mnemonic) && lodash.isEmpty(wallet.credentials.mnemonicEncrypted))
|
||||
$scope.deleted = true;
|
||||
|
||||
|
|
|
|||
|
|
@ -1,13 +1,12 @@
|
|||
'use strict';
|
||||
|
||||
angular.module('copayApp.controllers').controller('preferencesGlideraController',
|
||||
function($scope, $log, $ionicModal, ongoingProcess, glideraService) {
|
||||
function($scope, $log, $timeout, $state, ongoingProcess, glideraService, popupService, gettextCatalog) {
|
||||
|
||||
$scope.init = function(accessToken) {
|
||||
$scope.network = glideraService.getEnvironment();
|
||||
|
||||
$scope.token = accessToken;
|
||||
$scope.error = null;
|
||||
$scope.permissions = null;
|
||||
$scope.email = null;
|
||||
$scope.personalInfo = null;
|
||||
|
|
@ -19,7 +18,7 @@ angular.module('copayApp.controllers').controller('preferencesGlideraController'
|
|||
glideraService.init($scope.token, function(err, glidera) {
|
||||
ongoingProcess.set('connectingGlidera');
|
||||
if (err || !glidera) {
|
||||
$scope.error = err;
|
||||
if (err) popupService.showAlert(gettextCatalog.getString('Error'), err);
|
||||
return;
|
||||
}
|
||||
$scope.token = glidera.token;
|
||||
|
|
@ -63,11 +62,14 @@ angular.module('copayApp.controllers').controller('preferencesGlideraController'
|
|||
};
|
||||
|
||||
$scope.revokeToken = function() {
|
||||
$ionicModal.fromTemplateUrl('views/modals/glidera-confirmation.html', {
|
||||
scope: $scope
|
||||
}).then(function(modal) {
|
||||
$scope.glideraConfirmationModal = modal;
|
||||
$scope.glideraConfirmationModal.show();
|
||||
popupService.showConfirm('Glidera', 'Are you sure you would like to log out of your Glidera account?', function(res) {
|
||||
if (res) {
|
||||
glideraService.removeToken(function() {
|
||||
$timeout(function() {
|
||||
$state.go('glidera.main');
|
||||
}, 100);
|
||||
});
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -1,28 +1,27 @@
|
|||
'use strict';
|
||||
|
||||
angular.module('copayApp.controllers').controller('sellGlideraController',
|
||||
function($rootScope, $scope, $timeout, $ionicModal, $log, profileService, glideraService, bwcError, lodash, walletService, fingerprintService, configService, ongoingProcess) {
|
||||
function($scope, $timeout, $log, profileService, glideraService, bwcError, lodash, walletService, configService, ongoingProcess, popupService, gettextCatalog) {
|
||||
|
||||
var self = this;
|
||||
this.data = {};
|
||||
this.show2faCodeInput = null;
|
||||
this.success = null;
|
||||
this.error = null;
|
||||
var wallet;
|
||||
|
||||
var handleEncryptedWallet = function(wallet, cb) {
|
||||
if (!walletService.isEncrypted(wallet)) return cb();
|
||||
$rootScope.$emit('Local/NeedsPassword', false, function(err, password) {
|
||||
if (err) return cb(err);
|
||||
return cb(walletService.unlock(wallet, password));
|
||||
});
|
||||
};
|
||||
$scope.$on('Wallet/Changed', function(event, w) {
|
||||
if (lodash.isEmpty(w)) {
|
||||
$log.debug('No wallet provided');
|
||||
return;
|
||||
}
|
||||
wallet = w;
|
||||
$log.debug('Wallet changed: ' + w.name);
|
||||
});
|
||||
|
||||
$scope.init = function(accessToken) {
|
||||
$scope.network = glideraService.getEnvironment();
|
||||
|
||||
$scope.token = accessToken;
|
||||
$scope.error = null;
|
||||
$scope.permissions = null;
|
||||
$scope.email = null;
|
||||
$scope.personalInfo = null;
|
||||
|
|
@ -34,7 +33,7 @@ angular.module('copayApp.controllers').controller('sellGlideraController',
|
|||
glideraService.init($scope.token, function(err, glidera) {
|
||||
ongoingProcess.set('connectingGlidera');
|
||||
if (err || !glidera) {
|
||||
$scope.error = err;
|
||||
if (err) popupService.showAlert(gettextCatalog.getString('Error'), err);
|
||||
return;
|
||||
}
|
||||
$scope.token = glidera.token;
|
||||
|
|
@ -42,21 +41,11 @@ angular.module('copayApp.controllers').controller('sellGlideraController',
|
|||
$scope.update({fullUpdate: true});
|
||||
});
|
||||
|
||||
self.allWallets = profileService.getWallets({
|
||||
$scope.wallets = profileService.getWallets({
|
||||
network: $scope.network,
|
||||
n: 1,
|
||||
onlyComplete: true
|
||||
});
|
||||
if (lodash.isEmpty(self.allWallets)) return;
|
||||
|
||||
wallet = self.allWallets[0];
|
||||
if (wallet) {
|
||||
$timeout(function() {
|
||||
self.selectedWalletId = wallet.credentials.walletId;
|
||||
self.selectedWalletName = wallet.credentials.walletName;
|
||||
$scope.$apply();
|
||||
}, 100);
|
||||
}
|
||||
};
|
||||
|
||||
$scope.update = function(opts) {
|
||||
|
|
@ -93,36 +82,8 @@ angular.module('copayApp.controllers').controller('sellGlideraController',
|
|||
}
|
||||
};
|
||||
|
||||
$scope.openWalletsModal = function(wallets) {
|
||||
self.error = null;
|
||||
|
||||
$scope.type = 'SELL';
|
||||
$scope.wallets = wallets;
|
||||
$scope.noColor = true;
|
||||
$scope.self = self;
|
||||
|
||||
$ionicModal.fromTemplateUrl('views/modals/wallets.html', {
|
||||
scope: $scope,
|
||||
animation: 'slide-in-up'
|
||||
}).then(function(modal) {
|
||||
$scope.walletsModal = modal;
|
||||
$scope.walletsModal.show();
|
||||
});
|
||||
|
||||
$scope.$on('walletSelected', function(ev, walletId) {
|
||||
$timeout(function() {
|
||||
wallet = profileService.getClient(walletId);
|
||||
self.selectedWalletId = walletId;
|
||||
self.selectedWalletName = wallet.credentials.walletName;
|
||||
$scope.$apply();
|
||||
}, 100);
|
||||
$scope.walletsModal.hide();
|
||||
});
|
||||
};
|
||||
|
||||
this.getSellPrice = function(token, price) {
|
||||
var self = this;
|
||||
self.error = null;
|
||||
if (!price || (price && !price.qty && !price.fiat)) {
|
||||
self.sellPrice = null;
|
||||
return;
|
||||
|
|
@ -131,7 +92,7 @@ angular.module('copayApp.controllers').controller('sellGlideraController',
|
|||
glideraService.sellPrice(token, price, function(err, sellPrice) {
|
||||
self.gettingSellPrice = false;
|
||||
if (err) {
|
||||
self.error = 'Could not get exchange information. Please, try again.';
|
||||
popupService.showAlert(gettextCatalog.getString('Error'), gettextCatalog.getString('Could not get exchange information. Please, try again'));
|
||||
return;
|
||||
}
|
||||
self.sellPrice = sellPrice;
|
||||
|
|
@ -145,7 +106,7 @@ angular.module('copayApp.controllers').controller('sellGlideraController',
|
|||
glideraService.get2faCode(token, function(err, sent) {
|
||||
ongoingProcess.set('Sending 2FA code...', false);
|
||||
if (err) {
|
||||
self.error = 'Could not send confirmation code to your phone';
|
||||
popupService.showAlert(gettextCatalog.getString('Error'), gettextCatalog.getString('Could not send confirmation code to your phone'));
|
||||
} else {
|
||||
self.show2faCodeInput = sent;
|
||||
}
|
||||
|
|
@ -155,29 +116,27 @@ angular.module('copayApp.controllers').controller('sellGlideraController',
|
|||
|
||||
this.createTx = function(token, permissions, twoFaCode) {
|
||||
var self = this;
|
||||
self.error = null;
|
||||
var outputs = [];
|
||||
var config = configService.getSync();
|
||||
var configWallet = config.wallet;
|
||||
var walletSettings = configWallet.settings;
|
||||
|
||||
if (!wallet) {
|
||||
self.error = 'No wallet selected';
|
||||
popupService.showAlert(gettextCatalog.getString('Error'), gettextCatalog.getString('No wallet selected'));
|
||||
return;
|
||||
}
|
||||
|
||||
ongoingProcess.set('creatingTx', true);
|
||||
walletService.getAddress(wallet, null, function(err, refundAddress) {
|
||||
if (!refundAddress) {
|
||||
|
||||
ongoingProcess.clear();
|
||||
self.error = bwcError.msg(err, 'Could not create address');
|
||||
popupService.showAlert(gettextCatalog.getString('Error'), bwcError.msg(err, 'Could not create address'));
|
||||
return;
|
||||
}
|
||||
glideraService.getSellAddress(token, function(error, sellAddress) {
|
||||
if (!sellAddress) {
|
||||
glideraService.getSellAddress(token, function(err, sellAddress) {
|
||||
if (!sellAddress || err) {
|
||||
ongoingProcess.clear();
|
||||
self.error = 'Could not get the destination bitcoin address';
|
||||
popupService.showAlert(gettextCatalog.getString('Error'), gettextCatalog.getString('Could not get the destination bitcoin address'));
|
||||
return;
|
||||
}
|
||||
var amount = parseInt((self.sellPrice.qty * 100000000).toFixed(0));
|
||||
|
|
@ -205,28 +164,30 @@ angular.module('copayApp.controllers').controller('sellGlideraController',
|
|||
walletService.createTx(wallet, txp, function(err, createdTxp) {
|
||||
ongoingProcess.clear();
|
||||
if (err) {
|
||||
self.error = err.message || bwcError.msg(err);
|
||||
popupService.showAlert(gettextCatalog.getString('Error'), err.message || bwcError.msg(err));
|
||||
return;
|
||||
}
|
||||
walletService.prepare(wallet, txp, function(err, password) {
|
||||
walletService.prepare(wallet, function(err, password) {
|
||||
if (err) {
|
||||
self.error = err.message || bwcError.msg(err);
|
||||
ongoingProcess.clear();
|
||||
popupService.showAlert(gettextCatalog.getString('Error'), err.message || bwcError.msg(err));
|
||||
return;
|
||||
}
|
||||
ongoingProcess.set('signingTx', true);
|
||||
walletService.publishTx(wallet, createdTxp, function(err, publishedTxp) {
|
||||
if (err) {
|
||||
ongoingProcess.clear();
|
||||
self.error = err.message || bwcError.msg(err);
|
||||
popupService.showAlert(gettextCatalog.getString('Error'), err.message || bwcError.msg(err));
|
||||
return;
|
||||
}
|
||||
|
||||
walletService.signTx(wallet, publishedTxp, function(err, password, signedTxp) {
|
||||
walletService.removeTx(wallet, signedTxp, function(err) {
|
||||
if (err) $log.debug(err);
|
||||
});
|
||||
ongoingProcess.clear();
|
||||
walletService.signTx(wallet, publishedTxp, password, function(err, signedTxp) {
|
||||
if (err) {
|
||||
self.error = err.message || bwcError.msg(err);
|
||||
ongoingProcess.clear();
|
||||
popupService.showAlert(gettextCatalog.getString('Error'), err.message || bwcError.msg(err));
|
||||
walletService.removeTx(wallet, signedTxp, function(err) {
|
||||
if (err) $log.debug(err);
|
||||
});
|
||||
return;
|
||||
}
|
||||
var rawTx = signedTxp.raw;
|
||||
|
|
@ -237,15 +198,17 @@ angular.module('copayApp.controllers').controller('sellGlideraController',
|
|||
useCurrentPrice: self.sellPrice.priceUuid ? false : true,
|
||||
ip: null
|
||||
};
|
||||
ongoingProcess.set('Seling Bitcoin', true);
|
||||
ongoingProcess.set('Selling Bitcoin', true);
|
||||
glideraService.sell(token, twoFaCode, data, function(err, data) {
|
||||
ongoingProcess.clear();
|
||||
if (err) {
|
||||
self.error = err.message || bwcError.msg(err);
|
||||
popupService.showAlert(gettextCatalog.getString('Error'), err.message || bwcError.msg(err));
|
||||
return;
|
||||
}
|
||||
self.success = data;
|
||||
$scope.update();
|
||||
$timeout(function() {
|
||||
$scope.$digest();
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -1,12 +1,13 @@
|
|||
'use strict';
|
||||
|
||||
angular.module('copayApp.controllers').controller('tabHomeController',
|
||||
function($rootScope, $timeout, $scope, $state, lodash, profileService, walletService, configService, txFormatService, $ionicModal, $log, platformInfo, storageService) {
|
||||
function($rootScope, $timeout, $scope, $state, $ionicScrollDelegate, lodash, profileService, walletService, configService, txFormatService, $ionicModal, $log, platformInfo, storageService) {
|
||||
|
||||
$scope.externalServices = {};
|
||||
$scope.bitpayCardEnabled = true; // TODO
|
||||
|
||||
var setNotifications = function(notifications) {
|
||||
var n = walletService.processNotifications(notifications, 5);
|
||||
$scope.notifications = n;
|
||||
$scope.notificationsMore = notifications.length > 5 ? notifications.length - 5 : null;
|
||||
$scope.notifications = notifications;
|
||||
$timeout(function() {
|
||||
$scope.$apply();
|
||||
}, 1);
|
||||
|
|
@ -16,41 +17,33 @@ angular.module('copayApp.controllers').controller('tabHomeController',
|
|||
$scope.wallets = profileService.getWallets();
|
||||
if (lodash.isEmpty($scope.wallets)) return;
|
||||
|
||||
$timeout(function() {
|
||||
var i = $scope.wallets.length;
|
||||
var j = 0;
|
||||
var timeSpan = 60 * 60 * 24 * 7;
|
||||
var notifications = [];
|
||||
|
||||
$scope.fetchingNotifications = true;
|
||||
|
||||
lodash.each($scope.wallets, function(wallet) {
|
||||
|
||||
walletService.getStatus(wallet, {}, function(err, status) {
|
||||
if (err) {
|
||||
console.log('[tab-home.js.35:err:]', $log.error(err)); //TODO
|
||||
return;
|
||||
}
|
||||
wallet.status = status;
|
||||
});
|
||||
|
||||
walletService.getNotifications(wallet, {
|
||||
timeSpan: timeSpan
|
||||
}, function(err, n) {
|
||||
if (err) {
|
||||
console.log('[tab-home.js.35:err:]', $log.error(err)); //TODO
|
||||
return;
|
||||
}
|
||||
notifications.push(n);
|
||||
if (++j == i) {
|
||||
$scope.fetchingNotifications = false;
|
||||
setNotifications(lodash.compact(lodash.flatten(notifications)));
|
||||
};
|
||||
});
|
||||
var i = $scope.wallets.length;
|
||||
var j = 0;
|
||||
var timeSpan = 60 * 60 * 24 * 7;
|
||||
var notifications = [];
|
||||
|
||||
lodash.each($scope.wallets, function(wallet) {
|
||||
walletService.getStatus(wallet, {}, function(err, status) {
|
||||
if (err) {
|
||||
console.log('[tab-home.js.35:err:]', $log.error(err)); //TODO
|
||||
return;
|
||||
}
|
||||
wallet.status = status;
|
||||
});
|
||||
$scope.$digest();
|
||||
}, 100);
|
||||
});
|
||||
|
||||
$scope.fetchingNotifications = true;
|
||||
profileService.getNotifications({
|
||||
limit: 3
|
||||
}, function(err, n) {
|
||||
if (err) {
|
||||
console.log('[tab-home.js.35:err:]', $log.error(err)); //TODO
|
||||
return;
|
||||
}
|
||||
$scope.fetchingNotifications = false;
|
||||
setNotifications(n);
|
||||
$ionicScrollDelegate.resize();
|
||||
})
|
||||
};
|
||||
|
||||
$scope.updateWallet = function(wallet) {
|
||||
|
|
@ -61,23 +54,30 @@ angular.module('copayApp.controllers').controller('tabHomeController',
|
|||
return;
|
||||
}
|
||||
wallet.status = status;
|
||||
$timeout(function() {
|
||||
$scope.$apply();
|
||||
}, 1);
|
||||
|
||||
profileService.getNotifications({
|
||||
limit: 3
|
||||
}, function(err, n) {
|
||||
console.log('[tab-home.js.57]', n); //TODO
|
||||
if (err) {
|
||||
console.log('[tab-home.js.35:err:]', $log.error(err)); //TODO
|
||||
return;
|
||||
}
|
||||
setNotifications(n);
|
||||
$ionicScrollDelegate.resize();
|
||||
})
|
||||
});
|
||||
};
|
||||
|
||||
$scope.externalServices = {};
|
||||
$scope.nextStep = function() {
|
||||
lodash.each(['AmazonGiftCards', 'BitpayCard', 'BuyAndSell'], function(service) {
|
||||
storageService.getNextStep(service, function(err, value) {
|
||||
$scope.externalServices[service] = value ? true : false;
|
||||
$ionicScrollDelegate.resize();
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
$scope.bitpayCardEnabled = true; // TODO
|
||||
|
||||
var listeners = [
|
||||
$rootScope.$on('bwsEvent', function(e, walletId, type, n) {
|
||||
var wallet = profileService.getWallet(walletId);
|
||||
|
|
|
|||
|
|
@ -13,35 +13,28 @@ angular.module('copayApp.controllers').controller('tabReceiveController', functi
|
|||
}
|
||||
|
||||
$scope.$on('Wallet/Changed', function(event, wallet) {
|
||||
if (lodash.isEmpty(wallet)) {
|
||||
if (!wallet) {
|
||||
$log.debug('No wallet provided');
|
||||
return;
|
||||
}
|
||||
$scope.defaultWallet = wallet;
|
||||
$scope.wallet = wallet;
|
||||
$log.debug('Wallet changed: ' + wallet.name);
|
||||
$scope.setAddress(wallet);
|
||||
});
|
||||
|
||||
$scope.shareAddress = function(addr) {
|
||||
if ($scope.generatingAddress) return;
|
||||
if ($scope.isCordova) {
|
||||
window.plugins.socialsharing.share('bitcoin:' + addr, null, null, null);
|
||||
}
|
||||
};
|
||||
|
||||
$scope.setAddress = function(wallet, forceNew) {
|
||||
var wallet = wallet || $scope.defaultWallet;
|
||||
if ($scope.generatingAddress) return;
|
||||
|
||||
$scope.addr = null;
|
||||
var wallet = wallet || $scope.wallet;
|
||||
$scope.error = null;
|
||||
|
||||
if (wallet && !wallet.isComplete()) {
|
||||
$timeout(function() {
|
||||
$scope.$digest();
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
$scope.addr = null;
|
||||
$scope.generatingAddress = true;
|
||||
|
||||
$timeout(function() {
|
||||
|
|
@ -53,8 +46,9 @@ angular.module('copayApp.controllers').controller('tabReceiveController', functi
|
|||
if (addr)
|
||||
$scope.addr = addr;
|
||||
}
|
||||
$scope.$digest();
|
||||
|
||||
$scope.$apply();
|
||||
});
|
||||
});
|
||||
}, 1);
|
||||
};
|
||||
});
|
||||
|
|
|
|||
|
|
@ -36,6 +36,7 @@ angular.module('copayApp.controllers').controller('tabSettingsController', funct
|
|||
$scope.otherWallets = lodash.filter(profileService.getWallets(self.network), function(w) {
|
||||
return w.id != self.walletId;
|
||||
});
|
||||
$scope.wallets = profileService.getWallets();
|
||||
};
|
||||
|
||||
$scope.openAddressbookModal = function() {
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
'use strict';
|
||||
|
||||
angular.module('copayApp.controllers').controller('walletDetailsController', function($scope, $rootScope, $interval, $timeout, $filter, $log, $ionicModal, $ionicPopover, $ionicNavBarDelegate, $state, $stateParams, bwcError, profileService, lodash, configService, gettext, gettextCatalog, platformInfo, walletService, storageService, $ionicPopup) {
|
||||
angular.module('copayApp.controllers').controller('walletDetailsController', function($scope, $rootScope, $interval, $timeout, $filter, $log, $ionicModal, $ionicPopover, $ionicNavBarDelegate, $state, $stateParams, bwcError, profileService, lodash, configService, gettext, gettextCatalog, platformInfo, walletService, $ionicPopup) {
|
||||
|
||||
var isCordova = platformInfo.isCordova;
|
||||
var isWP = platformInfo.isWP;
|
||||
|
|
@ -175,16 +175,10 @@ angular.module('copayApp.controllers').controller('walletDetailsController', fun
|
|||
$scope.updateTxHistory(cb);
|
||||
}
|
||||
|
||||
var hideBalance = function() {
|
||||
storageService.getHideBalanceFlag(wallet.credentials.walletId, function(err, shouldHideBalance) {
|
||||
if (err) $scope.shouldHideBalance = false;
|
||||
else $scope.shouldHideBalance = (shouldHideBalance == 'true') ? true : false;
|
||||
});
|
||||
}
|
||||
|
||||
$scope.hideToggle = function() {
|
||||
$scope.shouldHideBalance = !$scope.shouldHideBalance;
|
||||
storageService.setHideBalanceFlag(wallet.credentials.walletId, $scope.shouldHideBalance.toString(), function() {});
|
||||
profileService.toggleHideBalanceFlag(wallet.credentials.walletId, function(err) {
|
||||
if (err) $log.error(err);
|
||||
});
|
||||
}
|
||||
|
||||
var currentTxHistoryPage;
|
||||
|
|
@ -204,7 +198,6 @@ angular.module('copayApp.controllers').controller('walletDetailsController', fun
|
|||
$scope.requiresMultipleSignatures = wallet.credentials.m > 1;
|
||||
$scope.newTx = false;
|
||||
|
||||
hideBalance();
|
||||
$ionicNavBarDelegate.title(wallet.name);
|
||||
|
||||
$scope.updateAll(function() {
|
||||
|
|
|
|||
400
src/js/routes.js
400
src/js/routes.js
|
|
@ -155,156 +155,18 @@ angular.module('copayApp').config(function(historicLogProvider, $provide, $logPr
|
|||
*
|
||||
*/
|
||||
|
||||
.state('wallet', {
|
||||
url: '/wallet/{walletId}/{fromOnboarding}',
|
||||
abstract: true,
|
||||
template: '<ion-nav-view name="wallet"></ion-nav-view>'
|
||||
})
|
||||
.state('wallet.details', {
|
||||
url: '/details',
|
||||
views: {
|
||||
'wallet': {
|
||||
templateUrl: 'views/walletDetails.html'
|
||||
}
|
||||
},
|
||||
params: {
|
||||
txid: null,
|
||||
txpId: null,
|
||||
},
|
||||
})
|
||||
.state('wallet.preferences', {
|
||||
url: '/preferences',
|
||||
views: {
|
||||
'wallet': {
|
||||
templateUrl: 'views/preferences.html'
|
||||
}
|
||||
.state('tabs.details', {
|
||||
url: '/details/{walletId}/{fromOnboarding}',
|
||||
views: {
|
||||
'tab-home': {
|
||||
templateUrl: 'views/walletDetails.html'
|
||||
}
|
||||
})
|
||||
.state('wallet.preferencesAlias', {
|
||||
url: '/preferencesAlias',
|
||||
views: {
|
||||
'wallet': {
|
||||
templateUrl: 'views/preferencesAlias.html'
|
||||
}
|
||||
}
|
||||
})
|
||||
.state('wallet.preferencesColor', {
|
||||
url: '/preferencesColor',
|
||||
views: {
|
||||
'wallet': {
|
||||
templateUrl: 'views/preferencesColor.html'
|
||||
}
|
||||
}
|
||||
})
|
||||
.state('wallet.preferencesEmail', {
|
||||
url: '/preferencesEmail',
|
||||
views: {
|
||||
'wallet': {
|
||||
templateUrl: 'views/preferencesEmail.html'
|
||||
}
|
||||
}
|
||||
})
|
||||
.state('wallet.backup', {
|
||||
url: '/backup',
|
||||
views: {
|
||||
'wallet': {
|
||||
templateUrl: 'views/backup.html'
|
||||
}
|
||||
}
|
||||
})
|
||||
.state('wallet.preferencesAdvanced', {
|
||||
url: '/preferencesAdvanced',
|
||||
views: {
|
||||
'wallet': {
|
||||
templateUrl: 'views/preferencesAdvanced.html'
|
||||
}
|
||||
}
|
||||
})
|
||||
.state('wallet.information', {
|
||||
url: '/information',
|
||||
views: {
|
||||
'wallet': {
|
||||
templateUrl: 'views/preferencesInformation.html'
|
||||
}
|
||||
}
|
||||
})
|
||||
.state('wallet.export', {
|
||||
abstract: true,
|
||||
url: '/export',
|
||||
views: {
|
||||
'wallet': {
|
||||
templateUrl: 'views/export.html'
|
||||
}
|
||||
}
|
||||
})
|
||||
.state('wallet.export.file', {
|
||||
url: '/tab-export-file',
|
||||
needProfile: true,
|
||||
views: {
|
||||
'tab-export-file': {
|
||||
templateUrl: 'views/tab-export-file.html',
|
||||
},
|
||||
}
|
||||
})
|
||||
.state('wallet.export.qrCode', {
|
||||
url: '/tab-export-qrCode',
|
||||
needProfile: true,
|
||||
views: {
|
||||
'tab-export-qrCode': {
|
||||
templateUrl: 'views/tab-export-qrCode.html',
|
||||
},
|
||||
}
|
||||
})
|
||||
.state('wallet.preferencesBwsUrl', {
|
||||
url: '/preferencesBwsUrl',
|
||||
views: {
|
||||
'wallet': {
|
||||
templateUrl: 'views/preferencesBwsUrl.html'
|
||||
}
|
||||
}
|
||||
})
|
||||
.state('wallet.preferencesHistory', {
|
||||
url: '/preferencesHistory',
|
||||
views: {
|
||||
'wallet': {
|
||||
templateUrl: 'views/preferencesHistory.html'
|
||||
}
|
||||
}
|
||||
})
|
||||
.state('wallet.deleteWords', {
|
||||
url: '/deleteWords',
|
||||
views: {
|
||||
'wallet': {
|
||||
templateUrl: 'views/preferencesDeleteWords.html'
|
||||
}
|
||||
}
|
||||
})
|
||||
.state('wallet.delete', {
|
||||
url: '/delete',
|
||||
views: {
|
||||
'wallet': {
|
||||
templateUrl: 'views/preferencesDeleteWallet.html'
|
||||
}
|
||||
}
|
||||
})
|
||||
.state('wallet.copayers', {
|
||||
url: '/copayers',
|
||||
views: {
|
||||
'wallet': {
|
||||
templateUrl: 'views/copayers.html'
|
||||
}
|
||||
}
|
||||
})
|
||||
.state('wallet.paperWallet', {
|
||||
url: '/paperWallet',
|
||||
views: {
|
||||
'wallet': {
|
||||
templateUrl: 'views/paperWallet.html'
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
},
|
||||
params: {
|
||||
txid: null,
|
||||
txpId: null,
|
||||
},
|
||||
})
|
||||
|
||||
/*
|
||||
*
|
||||
|
|
@ -357,12 +219,11 @@ angular.module('copayApp').config(function(historicLogProvider, $provide, $logPr
|
|||
*/
|
||||
|
||||
.state('send', {
|
||||
url: '/send',
|
||||
abstract: true,
|
||||
template: '<ion-nav-view name="send"></ion-nav-view>'
|
||||
})
|
||||
|
||||
.state('send.amount', {
|
||||
url: '/send',
|
||||
abstract: true,
|
||||
template: '<ion-nav-view name="send"></ion-nav-view>'
|
||||
})
|
||||
.state('send.amount', {
|
||||
url: '/amount/:toAddress/:toName',
|
||||
views: {
|
||||
'send': {
|
||||
|
|
@ -386,15 +247,10 @@ angular.module('copayApp').config(function(historicLogProvider, $provide, $logPr
|
|||
*
|
||||
*/
|
||||
|
||||
.state('add', {
|
||||
.state('tabs.add', {
|
||||
url: '/add',
|
||||
abstract: true,
|
||||
template: '<ion-nav-view name="add"></ion-nav-view>'
|
||||
})
|
||||
.state('add.main', {
|
||||
url: '/main',
|
||||
views: {
|
||||
'add': {
|
||||
'tab-home': {
|
||||
templateUrl: 'views/add.html',
|
||||
controller: function(platformInfo) {
|
||||
if (platformInfo.isCordova && StatusBar.isVisible) {
|
||||
|
|
@ -404,24 +260,24 @@ angular.module('copayApp').config(function(historicLogProvider, $provide, $logPr
|
|||
}
|
||||
}
|
||||
})
|
||||
.state('add.join', {
|
||||
.state('tabs.join', {
|
||||
url: '/join/:url',
|
||||
views: {
|
||||
'add': {
|
||||
'tab-home': {
|
||||
templateUrl: 'views/join.html'
|
||||
},
|
||||
}
|
||||
})
|
||||
.state('add.import', {
|
||||
url: '/import',
|
||||
.state('tabs.import', {
|
||||
url: '/import/:fromOnboarding',
|
||||
abstract: true,
|
||||
views: {
|
||||
'add': {
|
||||
'tab-home': {
|
||||
templateUrl: 'views/import.html'
|
||||
},
|
||||
}
|
||||
})
|
||||
.state('add.import.phrase', {
|
||||
.state('tabs.import.phrase', {
|
||||
url: '/tab-import-phrase',
|
||||
views: {
|
||||
'tab-import-phrase': {
|
||||
|
|
@ -429,7 +285,7 @@ angular.module('copayApp').config(function(historicLogProvider, $provide, $logPr
|
|||
},
|
||||
}
|
||||
})
|
||||
.state('add.import.file', {
|
||||
.state('tabs.import.file', {
|
||||
url: '/tab-import-file',
|
||||
views: {
|
||||
'tab-import-file': {
|
||||
|
|
@ -437,7 +293,7 @@ angular.module('copayApp').config(function(historicLogProvider, $provide, $logPr
|
|||
},
|
||||
}
|
||||
})
|
||||
.state('add.import.hardware', {
|
||||
.state('tabs.import.hardware', {
|
||||
url: '/tab-import-hardware',
|
||||
views: {
|
||||
'tab-import-hardware': {
|
||||
|
|
@ -445,17 +301,17 @@ angular.module('copayApp').config(function(historicLogProvider, $provide, $logPr
|
|||
},
|
||||
}
|
||||
})
|
||||
.state('add.create', {
|
||||
.state('tabs.create', {
|
||||
url: '/create',
|
||||
abstract: true,
|
||||
templateUrl: 'views/create.html',
|
||||
views: {
|
||||
'add': {
|
||||
'tab-home': {
|
||||
templateUrl: 'views/create.html'
|
||||
},
|
||||
}
|
||||
})
|
||||
.state('add.create.personal', {
|
||||
.state('tabs.create.personal', {
|
||||
url: '/tab-create-personal',
|
||||
views: {
|
||||
'tab-create-personal': {
|
||||
|
|
@ -463,7 +319,7 @@ angular.module('copayApp').config(function(historicLogProvider, $provide, $logPr
|
|||
},
|
||||
}
|
||||
})
|
||||
.state('add.create.shared', {
|
||||
.state('tabs.create.shared', {
|
||||
url: '/tab-create-shared',
|
||||
views: {
|
||||
'tab-create-shared': {
|
||||
|
|
@ -478,76 +334,225 @@ angular.module('copayApp').config(function(historicLogProvider, $provide, $logPr
|
|||
*
|
||||
*/
|
||||
|
||||
.state('settings', {
|
||||
url: '/settings',
|
||||
abstract: true,
|
||||
template: '<ion-nav-view name="settings"></ion-nav-view>'
|
||||
})
|
||||
.state('settings.language', {
|
||||
.state('tabs.language', {
|
||||
url: '/language',
|
||||
views: {
|
||||
'settings': {
|
||||
'tab-settings': {
|
||||
templateUrl: 'views/preferencesLanguage.html'
|
||||
}
|
||||
}
|
||||
})
|
||||
.state('settings.unit', {
|
||||
.state('tabs.unit', {
|
||||
url: '/unit',
|
||||
views: {
|
||||
'settings': {
|
||||
'tab-settings': {
|
||||
templateUrl: 'views/preferencesUnit.html'
|
||||
}
|
||||
}
|
||||
})
|
||||
.state('settings.fee', {
|
||||
.state('tabs.fee', {
|
||||
url: '/fee',
|
||||
views: {
|
||||
'settings': {
|
||||
'tab-settings': {
|
||||
templateUrl: 'views/preferencesFee.html'
|
||||
}
|
||||
}
|
||||
})
|
||||
.state('settings.altCurrency', {
|
||||
.state('tabs.altCurrency', {
|
||||
url: '/altCurrency',
|
||||
views: {
|
||||
'settings': {
|
||||
'tab-settings': {
|
||||
templateUrl: 'views/preferencesAltCurrency.html'
|
||||
}
|
||||
}
|
||||
})
|
||||
.state('settings.about', {
|
||||
.state('tabs.about', {
|
||||
url: '/about',
|
||||
views: {
|
||||
'settings': {
|
||||
'tab-settings': {
|
||||
templateUrl: 'views/preferencesAbout.html'
|
||||
}
|
||||
}
|
||||
})
|
||||
.state('settings.logs', {
|
||||
.state('tabs.logs', {
|
||||
url: '/logs',
|
||||
views: {
|
||||
'settings': {
|
||||
'tab-settings': {
|
||||
templateUrl: 'views/preferencesLogs.html'
|
||||
}
|
||||
}
|
||||
})
|
||||
.state('settings.termsOfUse', {
|
||||
.state('tabs.termsOfUse', {
|
||||
url: '/termsOfUse',
|
||||
views: {
|
||||
'settings': {
|
||||
'tab-settings': {
|
||||
templateUrl: 'views/termsOfUse.html',
|
||||
}
|
||||
}
|
||||
})
|
||||
.state('settings.translators', {
|
||||
.state('tabs.translators', {
|
||||
url: '/translators',
|
||||
views: {
|
||||
'settings': {
|
||||
'tab-settings': {
|
||||
templateUrl: 'views/translators.html'
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
/*
|
||||
*
|
||||
* Wallet preferences
|
||||
*
|
||||
*/
|
||||
|
||||
.state('tabs.preferences', {
|
||||
url: '/preferences/:walletId',
|
||||
abstract: true,
|
||||
views: {
|
||||
'tab-settings': {
|
||||
template: '<ion-nav-view name="preferences"></ion-nav-view>'
|
||||
},
|
||||
}
|
||||
})
|
||||
.state('tabs.preferences.main', {
|
||||
url: '/main',
|
||||
views: {
|
||||
'preferences': {
|
||||
templateUrl: 'views/preferences.html'
|
||||
}
|
||||
}
|
||||
})
|
||||
.state('tabs.preferences.preferencesAlias', {
|
||||
url: '/preferencesAlias',
|
||||
views: {
|
||||
'preferences': {
|
||||
templateUrl: 'views/preferencesAlias.html'
|
||||
}
|
||||
}
|
||||
})
|
||||
.state('tabs.preferences.preferencesColor', {
|
||||
url: '/preferencesColor',
|
||||
views: {
|
||||
'preferences': {
|
||||
templateUrl: 'views/preferencesColor.html'
|
||||
}
|
||||
}
|
||||
})
|
||||
.state('tabs.preferences.preferencesEmail', {
|
||||
url: '/preferencesEmail',
|
||||
views: {
|
||||
'preferences': {
|
||||
templateUrl: 'views/preferencesEmail.html'
|
||||
}
|
||||
}
|
||||
})
|
||||
.state('tabs.preferences.backup', {
|
||||
url: '/backup',
|
||||
views: {
|
||||
'preferences': {
|
||||
templateUrl: 'views/backup.html'
|
||||
}
|
||||
}
|
||||
})
|
||||
.state('tabs.preferences.preferencesAdvanced', {
|
||||
url: '/preferencesAdvanced',
|
||||
views: {
|
||||
'preferences': {
|
||||
templateUrl: 'views/preferencesAdvanced.html'
|
||||
}
|
||||
}
|
||||
})
|
||||
.state('tabs.preferences.information', {
|
||||
url: '/information',
|
||||
views: {
|
||||
'preferences': {
|
||||
templateUrl: 'views/preferencesInformation.html'
|
||||
}
|
||||
}
|
||||
})
|
||||
.state('tabs.preferences.export', {
|
||||
abstract: true,
|
||||
url: '/export',
|
||||
views: {
|
||||
'preferences': {
|
||||
templateUrl: 'views/export.html'
|
||||
}
|
||||
}
|
||||
})
|
||||
.state('tabs.preferences.export.file', {
|
||||
url: '/tab-export-file',
|
||||
needProfile: true,
|
||||
views: {
|
||||
'tab-export-file': {
|
||||
templateUrl: 'views/tab-export-file.html',
|
||||
},
|
||||
}
|
||||
})
|
||||
.state('tabs.preferences.export.qrCode', {
|
||||
url: '/tab-export-qrCode',
|
||||
needProfile: true,
|
||||
views: {
|
||||
'tab-export-qrCode': {
|
||||
templateUrl: 'views/tab-export-qrCode.html',
|
||||
},
|
||||
}
|
||||
})
|
||||
.state('tabs.preferences.preferencesBwsUrl', {
|
||||
url: '/preferencesBwsUrl',
|
||||
views: {
|
||||
'preferences': {
|
||||
templateUrl: 'views/preferencesBwsUrl.html'
|
||||
}
|
||||
}
|
||||
})
|
||||
.state('tabs.preferences.preferencesHistory', {
|
||||
url: '/preferencesHistory',
|
||||
views: {
|
||||
'preferences': {
|
||||
templateUrl: 'views/preferencesHistory.html'
|
||||
}
|
||||
}
|
||||
})
|
||||
.state('tabs.preferences.deleteWords', {
|
||||
url: '/deleteWords',
|
||||
views: {
|
||||
'preferences': {
|
||||
templateUrl: 'views/preferencesDeleteWords.html'
|
||||
}
|
||||
}
|
||||
})
|
||||
.state('tabs.preferences.delete', {
|
||||
url: '/delete',
|
||||
views: {
|
||||
'preferences': {
|
||||
templateUrl: 'views/preferencesDeleteWallet.html'
|
||||
}
|
||||
}
|
||||
})
|
||||
.state('tabs.preferences.paperWallet', {
|
||||
url: '/paperWallet',
|
||||
views: {
|
||||
'preferences': {
|
||||
templateUrl: 'views/paperWallet.html'
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
/*
|
||||
*
|
||||
*TO DO
|
||||
*
|
||||
*/
|
||||
|
||||
.state('tabs.copayers', {
|
||||
url: '/copayers',
|
||||
views: {
|
||||
'wallet': {
|
||||
templateUrl: 'views/copayers.html'
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
/*
|
||||
*
|
||||
* Onboarding
|
||||
|
|
@ -555,7 +560,7 @@ angular.module('copayApp').config(function(historicLogProvider, $provide, $logPr
|
|||
*/
|
||||
|
||||
.state('onboarding', {
|
||||
url: '/onboarding',
|
||||
url: '/onboarding/:walletId',
|
||||
abstract: true,
|
||||
template: '<ion-nav-view name="onboarding"></ion-nav-view>'
|
||||
})
|
||||
|
|
@ -825,7 +830,7 @@ angular.module('copayApp').config(function(historicLogProvider, $provide, $logPr
|
|||
});
|
||||
|
||||
$ionicPlatform.on('resume', function() {
|
||||
$rootScope.$emit('Local/Resume');
|
||||
// Nothing tot do
|
||||
});
|
||||
|
||||
$ionicPlatform.on('menubutton', function() {
|
||||
|
|
@ -854,6 +859,7 @@ angular.module('copayApp').config(function(historicLogProvider, $provide, $logPr
|
|||
} else {
|
||||
profileService.storeProfileIfDirty();
|
||||
$log.debug('Profile loaded ... Starting UX.');
|
||||
|
||||
$state.transitionTo('tabs.home');
|
||||
}
|
||||
});
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
'use strict';
|
||||
|
||||
angular.module('copayApp.services').factory('incomingData', function($log, $ionicModal, $state, bitcore) {
|
||||
|
||||
|
||||
var root = {};
|
||||
|
||||
root.redir = function(data) {
|
||||
|
|
@ -32,7 +32,7 @@ angular.module('copayApp.services').factory('incomingData', function($log, $ioni
|
|||
|
||||
data = sanitizeUri(data);
|
||||
|
||||
// BIP21
|
||||
// BIP21
|
||||
if (bitcore.URI.isValid(data)) {
|
||||
var parsed = new bitcore.URI(data);
|
||||
|
||||
|
|
@ -52,7 +52,7 @@ angular.module('copayApp.services').factory('incomingData', function($log, $ioni
|
|||
}
|
||||
return true;
|
||||
|
||||
// Plain URL
|
||||
// Plain URL
|
||||
} else if (/^https?:\/\//.test(data)) {
|
||||
return $state.go('send.confirm', {paypro: data})
|
||||
|
||||
|
|
@ -64,10 +64,10 @@ angular.module('copayApp.services').factory('incomingData', function($log, $ioni
|
|||
|
||||
|
||||
// copay: protocol
|
||||
} else if (data.indexOf('copay:glidera')==0) {
|
||||
return $state.go('send.uriglidera', {url: data})
|
||||
} else if (data.indexOf('copay:coinbase')==0) {
|
||||
return $state.go('send.uricoinbase', {url: data})
|
||||
} else if (data.indexOf('copay://glidera')==0) {
|
||||
return $state.go('uriglidera', {url: data})
|
||||
} else if (data.indexOf('copay://coinbase')==0) {
|
||||
return $state.go('uricoinbase', {url: data})
|
||||
|
||||
// Join
|
||||
} else if (data.match(/^copay:[0-9A-HJ-NP-Za-km-z]{70,80}$/)) {
|
||||
|
|
|
|||
117
src/js/services/popupService.js
Normal file
117
src/js/services/popupService.js
Normal file
|
|
@ -0,0 +1,117 @@
|
|||
'use strict';
|
||||
|
||||
angular.module('copayApp.services').service('popupService', function($log, $ionicPopup, platformInfo) {
|
||||
|
||||
var isCordova = platformInfo.isCordova;
|
||||
|
||||
/*************** Ionic ****************/
|
||||
|
||||
var _ionicAlert = function(title, message, cb) {
|
||||
if (!cb) cb = function() {};
|
||||
$ionicPopup.alert({
|
||||
title: title,
|
||||
template: message
|
||||
}).then(cb);
|
||||
};
|
||||
|
||||
var _ionicConfirm = function(title, message, cb) {
|
||||
$ionicPopup.confirm({
|
||||
title: title,
|
||||
template: message
|
||||
}).then(function(res) {
|
||||
return cb(res);
|
||||
});
|
||||
};
|
||||
|
||||
var _ionicPrompt = function(title, message, opts, cb) {
|
||||
opts = opts || {};
|
||||
$ionicPopup.prompt({
|
||||
title: title,
|
||||
template: message,
|
||||
inputType: opts.inputType || 'password',
|
||||
inputPlaceholder: opts.inputPlaceholder || 'Your password'
|
||||
}).then(function(res) {
|
||||
return cb(res)
|
||||
});
|
||||
};
|
||||
|
||||
/*************** Cordova ****************/
|
||||
|
||||
var _cordovaAlert = function(title, message, cb) {
|
||||
if (!cb) cb = function() {};
|
||||
navigator.notification.alert(message, cb, title);
|
||||
};
|
||||
|
||||
var _cordovaConfirm = function(title, message, cb) {
|
||||
var onConfirm = function (buttonIndex) {
|
||||
if (buttonIndex == 1) return cb(true);
|
||||
else return cb(false);
|
||||
}
|
||||
navigator.notification.confirm(message, onConfirm, title);
|
||||
};
|
||||
|
||||
var _cordovaPrompt = function(title, message, cb) {
|
||||
var onPrompt = function (results) {
|
||||
if (results.buttonIndex == 1) return cb(results.input1);
|
||||
else return cb();
|
||||
}
|
||||
navigator.notification.prompt(message, onPrompt, title);
|
||||
};
|
||||
|
||||
/**
|
||||
* Show a simple alert popup
|
||||
*
|
||||
* @param {String} Title
|
||||
* @param {String} Message (optional)
|
||||
* @param {Callback} Function (optional)
|
||||
*/
|
||||
|
||||
this.showAlert = function(title, msg, cb) {
|
||||
var message = (msg && msg.message) ? msg.message : msg;
|
||||
$log.warn(title + ": " + message);
|
||||
|
||||
if (isCordova)
|
||||
_cordovaAlert(title, message, cb);
|
||||
else
|
||||
_ionicAlert(title, message, cb);
|
||||
};
|
||||
|
||||
/**
|
||||
* Show a simple confirm popup
|
||||
*
|
||||
* @param {String} Title
|
||||
* @param {String} Message
|
||||
* @param {Callback} Function
|
||||
* @returns {Callback} OK: true, Cancel: false
|
||||
*/
|
||||
|
||||
this.showConfirm = function(title, message, cb) {
|
||||
$log.warn(title + ": " + message);
|
||||
|
||||
if (isCordova)
|
||||
_cordovaConfirm(title, message, cb);
|
||||
else
|
||||
_ionicConfirm(title, message, cb);
|
||||
};
|
||||
|
||||
/**
|
||||
* Show a simple prompt popup
|
||||
*
|
||||
* @param {String} Title
|
||||
* @param {String} Message
|
||||
* @param {Object} Object{ inputType, inputPlaceholder } (optional)
|
||||
* @param {Callback} Function
|
||||
* @returns {Callback} Return the value of the input if user presses OK
|
||||
*/
|
||||
|
||||
this.showPrompt = function(title, message, opts, cb) {
|
||||
$log.warn(title + ": " + message);
|
||||
|
||||
if (isCordova)
|
||||
_cordovaPrompt(title, message, cb);
|
||||
else
|
||||
_ionicPrompt(title, message, opts, cb);
|
||||
};
|
||||
|
||||
|
||||
});
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
'use strict';
|
||||
angular.module('copayApp.services')
|
||||
.factory('profileService', function profileServiceFactory($rootScope, $timeout, $filter, $log, sjcl, lodash, storageService, bwcService, configService, pushNotificationsService, gettext, gettextCatalog, bwcError, uxLanguage, bitcore, platformInfo, $ionicHistory) {
|
||||
.factory('profileService', function profileServiceFactory($rootScope, $timeout, $filter, $log, sjcl, lodash, storageService, bwcService, configService, pushNotificationsService, gettext, gettextCatalog, bwcError, uxLanguage, platformInfo, $ionicHistory, txFormatService, $state) {
|
||||
|
||||
|
||||
var isChromeApp = platformInfo.isChromeApp;
|
||||
|
|
@ -36,9 +36,42 @@ angular.module('copayApp.services')
|
|||
|
||||
wallet.name = config.aliasFor[wallet.id] || wallet.credentials.walletName;
|
||||
wallet.color = config.colorFor[wallet.id] || '#4A90E2';
|
||||
|
||||
}
|
||||
|
||||
root.setBackupFlag = function(walletId) {
|
||||
storageService.setBackupFlag(walletId, function(err) {
|
||||
if (err) $log.error(err);
|
||||
$log.debug('Backup flag stored');
|
||||
root.wallet[walletId].needsBackup = false;
|
||||
});
|
||||
};
|
||||
|
||||
function _requiresBackup(wallet) {
|
||||
if (wallet.isPrivKeyExternal()) return false;
|
||||
if (!wallet.credentials.mnemonic) return false;
|
||||
if (wallet.credentials.network == 'testnet') return false;
|
||||
|
||||
return true;
|
||||
};
|
||||
|
||||
function _needsBackup(wallet, cb) {
|
||||
if (!_requiresBackup(wallet))
|
||||
return cb(false);
|
||||
|
||||
storageService.getBackupFlag(wallet.credentials.walletId, function(err, val) {
|
||||
if (err) $log.error(err);
|
||||
if (val) return cb(false);
|
||||
return cb(true);
|
||||
});
|
||||
};
|
||||
|
||||
function _balanceIsHidden(wallet, cb) {
|
||||
storageService.getHideBalanceFlag(wallet.credentials.walletId, function(err, shouldHideBalance) {
|
||||
if (err) $log.error(err);
|
||||
var hideBalance = (shouldHideBalance == 'true') ? true : false;
|
||||
return cb(hideBalance);
|
||||
});
|
||||
};
|
||||
// Adds a wallet client to profileService
|
||||
root.bindWalletClient = function(wallet, opts) {
|
||||
var opts = opts || {};
|
||||
|
|
@ -52,18 +85,24 @@ angular.module('copayApp.services')
|
|||
wallet.id = walletId;
|
||||
wallet.started = true;
|
||||
wallet.doNotVerifyPayPro = isChromeApp;
|
||||
|
||||
|
||||
wallet.network = wallet.credentials.network;
|
||||
wallet.copayerId = wallet.credentials.copayerId;
|
||||
wallet.m = wallet.credentials.m;
|
||||
wallet.n = wallet.credentials.n;
|
||||
|
||||
root.updateWalletSettings(wallet);
|
||||
|
||||
root.wallet[walletId] = wallet;
|
||||
|
||||
_needsBackup(wallet, function(val) {
|
||||
wallet.needsBackup = val;
|
||||
});
|
||||
|
||||
_balanceIsHidden(wallet, function(val) {
|
||||
wallet.balanceHidden = val;
|
||||
});
|
||||
|
||||
wallet.removeAllListeners();
|
||||
|
||||
wallet.on('report', function(n) {
|
||||
$log.info('BWC Report:' + n);
|
||||
});
|
||||
|
|
@ -80,6 +119,9 @@ angular.module('copayApp.services')
|
|||
if (wallet.completeHistory)
|
||||
wallet.completeHistory.isValid = false;
|
||||
|
||||
if (wallet.cachedActivity)
|
||||
wallet.cachedActivity.isValid = false;
|
||||
|
||||
$rootScope.$emit('bwsEvent', wallet.id, n.type, n);
|
||||
});
|
||||
|
||||
|
|
@ -91,7 +133,9 @@ angular.module('copayApp.services')
|
|||
});
|
||||
});
|
||||
|
||||
wallet.initialize({}, function(err) {
|
||||
wallet.initialize({
|
||||
notificationIncludeOwn: true,
|
||||
}, function(err) {
|
||||
if (err) {
|
||||
$log.error('Could not init notifications err:', err);
|
||||
return;
|
||||
|
|
@ -103,7 +147,6 @@ angular.module('copayApp.services')
|
|||
});
|
||||
});
|
||||
|
||||
|
||||
$rootScope.$on('Local/SettingsUpdated', function(e, walletId) {
|
||||
if (!walletId || walletId == wallet.id) {
|
||||
$log.debug('Updating settings for wallet:' + wallet.id);
|
||||
|
|
@ -367,26 +410,6 @@ angular.module('copayApp.services')
|
|||
}, 50);
|
||||
};
|
||||
|
||||
// Creates the default Copay profile and its wallet
|
||||
root.createDefaultProfile = function(opts, cb) {
|
||||
var p = Profile.create();
|
||||
|
||||
if (opts.noWallet) {
|
||||
return cb(null, p);
|
||||
}
|
||||
|
||||
opts.m = 1;
|
||||
opts.n = 1;
|
||||
opts.network = 'livenet';
|
||||
|
||||
doCreateWallet(opts, function(err, walletClient) {
|
||||
if (err) return cb(err);
|
||||
|
||||
p.addWallet(JSON.parse(walletClient.export()));
|
||||
return cb(null, p);
|
||||
});
|
||||
};
|
||||
|
||||
// create and store a wallet
|
||||
root.createWallet = function(opts, cb) {
|
||||
doCreateWallet(opts, function(err, walletClient, secret) {
|
||||
|
|
@ -408,8 +431,8 @@ angular.module('copayApp.services')
|
|||
|
||||
// check if exist
|
||||
if (lodash.find(root.profile.credentials, {
|
||||
'walletId': walletData.walletId
|
||||
})) {
|
||||
'walletId': walletData.walletId
|
||||
})) {
|
||||
return cb(gettext('Cannot join the same wallet more that once'));
|
||||
}
|
||||
} catch (ex) {
|
||||
|
|
@ -633,26 +656,33 @@ angular.module('copayApp.services')
|
|||
});
|
||||
};
|
||||
|
||||
root.create = function(opts, cb) {
|
||||
$log.info('Creating profile', opts);
|
||||
root.createProfile = function(cb) {
|
||||
$log.info('Creating profile');
|
||||
var defaults = configService.getDefaults();
|
||||
|
||||
configService.get(function(err) {
|
||||
root.createDefaultProfile(opts, function(err, p) {
|
||||
if (err) return cb(err);
|
||||
if (err) $log.debug(err);
|
||||
|
||||
storageService.storeNewProfile(p, function(err) {
|
||||
if (err) return cb(err);
|
||||
root.bindProfile(p, function(err) {
|
||||
// ignore NONAGREEDDISCLAIMER
|
||||
if (err && err.toString().match('NONAGREEDDISCLAIMER')) return cb();
|
||||
return cb(err);
|
||||
});
|
||||
var p = Profile.create();
|
||||
storageService.storeNewProfile(p, function(err) {
|
||||
if (err) return cb(err);
|
||||
root.bindProfile(p, function(err) {
|
||||
// ignore NONAGREEDDISCLAIMER
|
||||
if (err && err.toString().match('NONAGREEDDISCLAIMER')) return cb();
|
||||
return cb(err);
|
||||
});
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
root.createDefaultWallet = function(cb) {
|
||||
var opts = {};
|
||||
opts.m = 1;
|
||||
opts.n = 1;
|
||||
opts.network = 'livenet';
|
||||
root.createWallet(opts, cb);
|
||||
};
|
||||
|
||||
root.setDisclaimerAccepted = function(cb) {
|
||||
root.profile.disclaimerAccepted = true;
|
||||
storageService.storeProfile(root.profile, function(err) {
|
||||
|
|
@ -708,9 +738,154 @@ angular.module('copayApp.services')
|
|||
});
|
||||
} else {}
|
||||
|
||||
return lodash.sortBy(ret, [function(x) {
|
||||
return x.isComplete();
|
||||
}, 'createdOn']);
|
||||
return lodash.sortBy(ret, [
|
||||
|
||||
function(x) {
|
||||
return x.isComplete();
|
||||
}, 'createdOn'
|
||||
]);
|
||||
};
|
||||
|
||||
root.toggleHideBalanceFlag = function(walletId, cb) {
|
||||
root.wallet[walletId].balanceHidden = !root.wallet[walletId].balanceHidden;
|
||||
storageService.setHideBalanceFlag(walletId, root.wallet[walletId].balanceHidden.toString(), cb);
|
||||
};
|
||||
|
||||
root.getNotifications = function(opts, cb) {
|
||||
opts = opts || {};
|
||||
|
||||
var TIME_STAMP = 60 * 60 * 24 * 7;
|
||||
var MAX = 100;
|
||||
|
||||
var ignored = {
|
||||
'NewBlock': 1,
|
||||
'BalanceUpdated': 1,
|
||||
'NewOutgoingTxByThirdParty': 1,
|
||||
'NewAddress': 1,
|
||||
'TxProposalFinallyAccepted': 1,
|
||||
'TxProposalFinallyRejected': 1,
|
||||
};
|
||||
|
||||
var w = root.getWallets();
|
||||
if (lodash.isEmpty(w)) return cb();
|
||||
|
||||
var l = w.length,
|
||||
j = 0,
|
||||
notifications = [];
|
||||
|
||||
|
||||
function isActivityCached(wallet) {
|
||||
return wallet.cachedActivity && wallet.cachedActivity.isValid;
|
||||
};
|
||||
|
||||
|
||||
function getNotifications(wallet, cb2) {
|
||||
if (isActivityCached(wallet) && !opts.force) return cb2();
|
||||
|
||||
wallet.getNotifications({
|
||||
timeSpan: TIME_STAMP,
|
||||
includeOwn: true,
|
||||
}, function(err, n) {
|
||||
if (err) return cb2(err);
|
||||
|
||||
wallet.cachedActivity = {
|
||||
n: n.slice(-MAX),
|
||||
isValid: true,
|
||||
};
|
||||
|
||||
return cb2();
|
||||
});
|
||||
};
|
||||
|
||||
function process(notifications) {
|
||||
if (!notifications) return [];
|
||||
|
||||
var shown = lodash.sortBy(notifications, 'createdOn').reverse();
|
||||
|
||||
shown = shown.splice(0, opts.limit || MAX);
|
||||
|
||||
lodash.each(shown, function(x) {
|
||||
x.txpId = x.data ? x.data.txProposalId : null;
|
||||
x.txid = x.data ? x.data.txid : null;
|
||||
x.types = [x.type];
|
||||
|
||||
if (x.data && x.data.amount)
|
||||
x.amountStr = txFormatService.formatAmountStr(x.data.amount);
|
||||
|
||||
x.action = function() {
|
||||
// TODO?
|
||||
$state.go('tabs.details', {
|
||||
walletId: x.walletId,
|
||||
txpId: x.txpId,
|
||||
txid: x.txid,
|
||||
});
|
||||
};
|
||||
});
|
||||
|
||||
// condense
|
||||
var finale = [],
|
||||
prev;
|
||||
|
||||
|
||||
lodash.each(shown, function(x) {
|
||||
if (prev && prev.walletId === x.walletId && prev.txpId && prev.txpId === x.txpId && prev.creatorId && prev.creatorId === x.creatorId) {
|
||||
prev.types.push(x.type);
|
||||
prev.data = lodash.assign(prev.data, x.data);
|
||||
prev.txid = prev.txid || x.txid;
|
||||
prev.amountStr = prev.amountStr || x.amountStr;
|
||||
prev.creatorName = prev.creatorName || x.creatorName;
|
||||
} else {
|
||||
finale.push(x);
|
||||
prev = x;
|
||||
}
|
||||
});
|
||||
|
||||
// messages...
|
||||
|
||||
var u = bwcService.getUtils();
|
||||
lodash.each(finale, function(x) {
|
||||
if (x.data && x.data.message && x.wallet && x.wallet.credentials.sharedEncryptingKey) {
|
||||
// TODO TODO TODO => BWC
|
||||
x.message = u.decryptMessage(x.data.message, x.wallet.credentials.sharedEncryptingKey);
|
||||
}
|
||||
});
|
||||
|
||||
return finale;
|
||||
};
|
||||
|
||||
lodash.each(w, function(wallet) {
|
||||
getNotifications(wallet, function(err) {
|
||||
j++;
|
||||
if (err) {
|
||||
$log.warn('Error updating notifications:' + err);
|
||||
} else {
|
||||
var n = lodash.filter(wallet.cachedActivity.n, function(x) {
|
||||
return !ignored[x.type];
|
||||
});
|
||||
|
||||
var idToName = {};
|
||||
if (wallet.cachedStatus) {
|
||||
lodash.each(wallet.cachedStatus.wallet.copayers, function(c) {
|
||||
idToName[c.id] = c.name;
|
||||
});
|
||||
}
|
||||
|
||||
lodash.each(n, function(x) {
|
||||
x.wallet = wallet;
|
||||
if (x.creatorId && wallet.cachedStatus) {
|
||||
x.creatorName = idToName[x.creatorId];
|
||||
};
|
||||
});
|
||||
|
||||
notifications.push(n);
|
||||
}
|
||||
if (j == l) {
|
||||
notifications = lodash.sortBy(notifications, 'createdOn');
|
||||
notifications = lodash.compact(lodash.flatten(notifications)).slice(0,MAX);
|
||||
return cb(null, process(notifications));
|
||||
};
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
return root;
|
||||
|
|
|
|||
|
|
@ -65,27 +65,6 @@ angular.module('copayApp.services').factory('walletService', function($log, $tim
|
|||
});
|
||||
};
|
||||
|
||||
root.requiresBackup = function(wallet) {
|
||||
if (wallet.isPrivKeyExternal()) return false;
|
||||
if (!wallet.credentials.mnemonic) return false;
|
||||
if (wallet.credentials.network == 'testnet') return false;
|
||||
|
||||
return true;
|
||||
};
|
||||
|
||||
root.needsBackup = function(wallet, cb) {
|
||||
|
||||
if (!root.requiresBackup(wallet))
|
||||
return cb(false);
|
||||
|
||||
storageService.getBackupFlag(wallet.credentials.walletId, function(err, val) {
|
||||
if (err) $log.error(err);
|
||||
if (val) return cb(false);
|
||||
return cb(true);
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
// TODO
|
||||
// This handles errors from BWS/index which normally
|
||||
// trigger from async events (like updates).
|
||||
|
|
@ -815,11 +794,9 @@ angular.module('copayApp.services').factory('walletService', function($log, $tim
|
|||
if (!wallet.isComplete())
|
||||
return cb('WALLET_NOT_COMPLETE');
|
||||
|
||||
root.needsBackup(wallet, function(needsBackup) {
|
||||
if (needsBackup)
|
||||
return cb('WALLET_NEEDS_BACKUP');
|
||||
return cb();
|
||||
});
|
||||
if (wallet.needsBackup)
|
||||
return cb('WALLET_NEEDS_BACKUP');
|
||||
return cb();
|
||||
};
|
||||
|
||||
|
||||
|
|
@ -859,7 +836,7 @@ angular.module('copayApp.services').factory('walletService', function($log, $tim
|
|||
askPassword(wallet.name, gettext('Enter new spending password'), function(password) {
|
||||
if (!password) return cb('no password');
|
||||
askPassword(wallet.name, gettext('Confirm you new spending password'), function(password2) {
|
||||
if (!password2 || password != password2)
|
||||
if (!password2 || password != password2)
|
||||
return cb('password mismatch');
|
||||
|
||||
wallet.encryptPrivateKey(password);
|
||||
|
|
@ -950,7 +927,7 @@ angular.module('copayApp.services').factory('walletService', function($log, $tim
|
|||
}
|
||||
|
||||
root.prepare(wallet, function(err, password) {
|
||||
if (err) return cb('Prepare error: ' + err);
|
||||
if (err) return cb('Prepare error: ' + err);
|
||||
|
||||
ongoingProcess.set('sendingTx', true);
|
||||
publishFn(wallet, txp, function(err, publishedTxp) {
|
||||
|
|
@ -999,33 +976,6 @@ angular.module('copayApp.services').factory('walletService', function($log, $tim
|
|||
});
|
||||
};
|
||||
|
||||
root.getNotifications = function(wallet, opts, cb) {
|
||||
|
||||
wallet.getNotifications(opts, function(err, notifications) {
|
||||
if (err) return cb(err);
|
||||
|
||||
notifications = lodash.filter(notifications, function(x) {
|
||||
return x.type != 'NewBlock' && x.type != 'BalanceUpdated' && x.type != 'NewOutgoingTxByThirdParty';
|
||||
});
|
||||
|
||||
var idToName = {};
|
||||
if (wallet.cachedStatus) {
|
||||
lodash.each(wallet.cachedStatus.wallet.copayers, function(c) {
|
||||
idToName[c.id] = c.name;
|
||||
});
|
||||
}
|
||||
|
||||
lodash.each(notifications, function(x) {
|
||||
x.wallet = wallet;
|
||||
if (x.creatorId && wallet.cachedStatus) {
|
||||
x.creatorName = idToName[x.creatorId];
|
||||
};
|
||||
});
|
||||
|
||||
return cb(null, notifications);
|
||||
});
|
||||
};
|
||||
|
||||
root.getEncodedWalletInfo = function(wallet, cb) {
|
||||
|
||||
var derivationPath = wallet.credentials.getBaseAddressDerivationPath();
|
||||
|
|
@ -1040,7 +990,7 @@ angular.module('copayApp.services').factory('walletService', function($log, $tim
|
|||
if (wallet.credentials.derivationStrategy != 'BIP44' || !wallet.canSign())
|
||||
return null;
|
||||
|
||||
root.getKeys(wallet, function(err, keys){
|
||||
root.getKeys(wallet, function(err, keys) {
|
||||
if (err || !keys) return cb(err);
|
||||
|
||||
if (keys.mnemonic) {
|
||||
|
|
@ -1059,64 +1009,6 @@ angular.module('copayApp.services').factory('walletService', function($log, $tim
|
|||
});
|
||||
};
|
||||
|
||||
root.processNotifications = function(notifications, limit) {
|
||||
if (!notifications) return [];
|
||||
|
||||
var shown = lodash.sortBy(notifications, 'createdOn').reverse();
|
||||
|
||||
if (limit)
|
||||
shown = shown.splice(0, limit);
|
||||
|
||||
lodash.each(shown, function(x) {
|
||||
x.txpId = x.data ? x.data.txProposalId : null;
|
||||
x.txid = x.data ? x.data.txid : null;
|
||||
x.types = [x.type];
|
||||
|
||||
if (x.data && x.data.amount)
|
||||
x.amountStr = txFormatService.formatAmountStr(x.data.amount);
|
||||
|
||||
x.action = function() {
|
||||
// TODO?
|
||||
$state.go('wallet.details', {
|
||||
walletId: x.walletId,
|
||||
txpId: x.txpId,
|
||||
txid: x.txid,
|
||||
});
|
||||
};
|
||||
});
|
||||
|
||||
// condense
|
||||
var finale = [],
|
||||
prev;
|
||||
|
||||
|
||||
lodash.each(shown, function(x) {
|
||||
if (prev && prev.walletId === x.walletId && prev.txpId && prev.txpId === x.txpId && prev.creatorId && prev.creatorId === x.creatorId) {
|
||||
prev.types.push(x.type);
|
||||
prev.data = lodash.assign(prev.data, x.data);
|
||||
prev.txid = prev.txid || x.txid;
|
||||
prev.amountStr = prev.amountStr || x.amountStr;
|
||||
prev.creatorName = prev.creatorName || x.creatorName;
|
||||
} else {
|
||||
finale.push(x);
|
||||
prev = x;
|
||||
}
|
||||
});
|
||||
|
||||
// messages...
|
||||
|
||||
var u = bwcService.getUtils();
|
||||
lodash.each(finale, function(x) {
|
||||
if (x.data && x.data.message && x.wallet && x.wallet.credentials.sharedEncryptingKey) {
|
||||
// TODO TODO TODO => BWC
|
||||
x.message = u.decryptMessage(x.data.message, x.wallet.credentials.sharedEncryptingKey);
|
||||
}
|
||||
});
|
||||
|
||||
return finale;
|
||||
};
|
||||
|
||||
|
||||
root.setTouchId = function(wallet, enabled, cb) {
|
||||
fingerprintService.check(wallet, function(err) {
|
||||
if (err) return cb(err); {
|
||||
|
|
|
|||
|
|
@ -3,6 +3,9 @@
|
|||
* Copay main CSS
|
||||
*
|
||||
*/
|
||||
body {
|
||||
font-family: 'roboto-regular';
|
||||
}
|
||||
|
||||
h3.title {
|
||||
margin-left: 10px !important;
|
||||
|
|
@ -882,6 +885,14 @@ input[type=file] {
|
|||
text-align: left;
|
||||
}
|
||||
|
||||
.right {
|
||||
float: right;
|
||||
}
|
||||
|
||||
.left {
|
||||
float: left;
|
||||
}
|
||||
|
||||
.input-label {
|
||||
max-width: none;
|
||||
width: inherit;
|
||||
|
|
@ -994,3 +1005,6 @@ input[type=number] {
|
|||
|
||||
@import 'mixins/mixins';
|
||||
@import 'views/onboarding/onboarding';
|
||||
@import "views/common";
|
||||
@import "views/tab-home";
|
||||
@import "views/includes/walletActivity";
|
||||
27
src/sass/views/common.scss
Normal file
27
src/sass/views/common.scss
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
.icon.nav-item-arrow-right {
|
||||
color: #666;
|
||||
font-size: 26px;
|
||||
}
|
||||
|
||||
.item.item-heading {
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.icon.list-add-button {
|
||||
color: #666;
|
||||
font-size: 38px;
|
||||
}
|
||||
|
||||
.item.item-big-icon-left {
|
||||
padding-left: 74px;
|
||||
}
|
||||
|
||||
.icon.big-icon-svg {
|
||||
padding: 0 7px;
|
||||
> img {
|
||||
border-radius: 50%;
|
||||
width: 40px;
|
||||
height: 40px;
|
||||
box-shadow: 0px 6px 12px 0px rgba(0, 0, 0, 0.3);
|
||||
}
|
||||
}
|
||||
27
src/sass/views/includes/walletActivity.scss
Normal file
27
src/sass/views/includes/walletActivity.scss
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
.wallet-activity {
|
||||
|
||||
&-amount {
|
||||
float: right;
|
||||
font-size: 18px;
|
||||
}
|
||||
|
||||
&-note {
|
||||
margin-top: 3px;
|
||||
font-size: 12px!important;
|
||||
|
||||
&-child {
|
||||
line-height: 30px;
|
||||
vertical-align: middle;
|
||||
}
|
||||
|
||||
> i {
|
||||
font-size: 21px;
|
||||
margin-right: 8px;
|
||||
}
|
||||
|
||||
> time {
|
||||
float: right;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
22
src/sass/views/tab-home.scss
Normal file
22
src/sass/views/tab-home.scss
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
#tab-home {
|
||||
.icon-create-wallet {
|
||||
background-image: url("../img/icon-bitcoin.svg");
|
||||
background-repeat:no-repeat;
|
||||
background-position: -5px -5px;
|
||||
}
|
||||
.icon-buy-bitcoin {
|
||||
background-image: url("../img/icon-gift.svg");
|
||||
background-repeat: no-repeat;
|
||||
background-position: -5px -6px;
|
||||
}
|
||||
.icon-bitpay-card {
|
||||
background-image: url("../img/icon-bitpay.svg");
|
||||
background-repeat: no-repeat;
|
||||
background-position: -5px -6px;
|
||||
}
|
||||
.icon-gift {
|
||||
background-image: url("../img/icon-gift.svg");
|
||||
background-repeat: no-repeat;
|
||||
background-position: -5px -6px;
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue