Merge branch 'ref/design' of github.com:matiu/copay into ref/design
This commit is contained in:
commit
1f5e55efae
12 changed files with 149 additions and 48 deletions
|
|
@ -92,7 +92,7 @@ angular.module('copayApp.controllers').controller('copayersController',
|
|||
}
|
||||
|
||||
var wallet = profileService.getWallet($stateParams.walletId);
|
||||
var secret = wallet.status.wallet.secret;
|
||||
var secret;
|
||||
try {
|
||||
secret = wallet.status.wallet.secret;
|
||||
} catch (e) {};
|
||||
|
|
|
|||
|
|
@ -166,7 +166,7 @@ angular.module('copayApp.controllers').controller('createController',
|
|||
ongoingProcess.set('creatingWallet', true);
|
||||
$timeout(function() {
|
||||
|
||||
profileService.createWallet(opts, function(err, wallet) {
|
||||
profileService.createWallet(opts, function(err, client) {
|
||||
ongoingProcess.set('creatingWallet', false);
|
||||
if (err) {
|
||||
$log.warn(err);
|
||||
|
|
@ -177,8 +177,8 @@ angular.module('copayApp.controllers').controller('createController',
|
|||
return;
|
||||
}
|
||||
|
||||
walletService.updateRemotePreferences(wallet, {}, function() {
|
||||
$log.debug('Remote preferences saved for:' + wallet.walletId)
|
||||
walletService.updateRemotePreferences(client, {}, function() {
|
||||
$log.debug('Remote preferences saved for:' + client.credentials.walletId)
|
||||
});
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
'use strict';
|
||||
|
||||
angular.module('copayApp.controllers').controller('importController',
|
||||
function($scope, $rootScope, $timeout, $log, profileService, configService, notification, go, sjcl, gettext, ledger, trezor, derivationPathHelper, platformInfo, bwcService, ongoingProcess) {
|
||||
function($scope, $rootScope, $timeout, $log, profileService, configService, notification, go, sjcl, gettext, ledger, trezor, derivationPathHelper, platformInfo, bwcService, ongoingProcess, walletService) {
|
||||
|
||||
var isChromeApp = platformInfo.isChromeApp;
|
||||
var isDevel = platformInfo.isDevel;
|
||||
|
|
@ -95,7 +95,7 @@ angular.module('copayApp.controllers').controller('importController',
|
|||
opts.password = null;
|
||||
|
||||
$timeout(function() {
|
||||
profileService.importWallet(str2, opts, function(err, wallet) {
|
||||
profileService.importWallet(str2, opts, function(err, client) {
|
||||
ongoingProcess.set('importingWallet', false);
|
||||
if (err) {
|
||||
$scope.error = err;
|
||||
|
|
@ -103,11 +103,11 @@ angular.module('copayApp.controllers').controller('importController',
|
|||
|
||||
}
|
||||
|
||||
walletService.updateRemotePreferences(wallet, {}, function() {
|
||||
$log.debug('Remote preferences saved for:' + wallet.walletId)
|
||||
walletService.updateRemotePreferences(client, {}, function() {
|
||||
$log.debug('Remote preferences saved for:' + client.credentials.walletId)
|
||||
});
|
||||
|
||||
$rootScope.$emit('Local/WalletImported', wallet.walletId);
|
||||
$rootScope.$emit('Local/WalletImported', client.credentials.walletId);
|
||||
notification.success(gettext('Success'), gettext('Your wallet has been imported correctly'));
|
||||
go.walletHome();
|
||||
});
|
||||
|
|
@ -117,7 +117,7 @@ angular.module('copayApp.controllers').controller('importController',
|
|||
var _importExtendedPrivateKey = function(xPrivKey, opts) {
|
||||
ongoingProcess.set('importingWallet', true);
|
||||
$timeout(function() {
|
||||
profileService.importExtendedPrivateKey(xPrivKey, opts, function(err, wallet) {
|
||||
profileService.importExtendedPrivateKey(xPrivKey, opts, function(err, client) {
|
||||
ongoingProcess.set('importingWallet', false);
|
||||
if (err) {
|
||||
if (err instanceof errors.NOT_AUTHORIZED) {
|
||||
|
|
@ -131,11 +131,11 @@ angular.module('copayApp.controllers').controller('importController',
|
|||
}
|
||||
|
||||
|
||||
walletService.updateRemotePreferences(wallet, {}, function() {
|
||||
$log.debug('Remote preferences saved for:' + wallet.walletId)
|
||||
walletService.updateRemotePreferences(client, {}, function() {
|
||||
$log.debug('Remote preferences saved for:' + client.credentials.walletId)
|
||||
});
|
||||
|
||||
$rootScope.$emit('Local/WalletImported', wallet.walletId);
|
||||
$rootScope.$emit('Local/WalletImported', client.credentials.walletId);
|
||||
notification.success(gettext('Success'), gettext('Your wallet has been imported correctly'));
|
||||
go.walletHome();
|
||||
});
|
||||
|
|
@ -168,7 +168,7 @@ angular.module('copayApp.controllers').controller('importController',
|
|||
ongoingProcess.set('importingWallet', true);
|
||||
|
||||
$timeout(function() {
|
||||
profileService.importMnemonic(words, opts, function(err, wallet) {
|
||||
profileService.importMnemonic(words, opts, function(err, client) {
|
||||
ongoingProcess.set('importingWallet', false);
|
||||
|
||||
if (err) {
|
||||
|
|
@ -182,11 +182,11 @@ angular.module('copayApp.controllers').controller('importController',
|
|||
});
|
||||
}
|
||||
|
||||
walletService.updateRemotePreferences(wallet, {}, function() {
|
||||
$log.debug('Remote preferences saved for:' + wallet.walletId)
|
||||
walletService.updateRemotePreferences(client, {}, function() {
|
||||
$log.debug('Remote preferences saved for:' + client.credentials.walletId)
|
||||
});
|
||||
|
||||
$rootScope.$emit('Local/WalletImported', wallet.walletId);
|
||||
$rootScope.$emit('Local/WalletImported', client.credentials.walletId);
|
||||
notification.success(gettext('Success'), gettext('Your wallet has been imported correctly'));
|
||||
go.walletHome();
|
||||
});
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
'use strict';
|
||||
|
||||
angular.module('copayApp.controllers').controller('joinController',
|
||||
function($scope, $rootScope, $timeout, go, notification, profileService, configService, storageService, applicationService, gettext, lodash, ledger, trezor, platformInfo, derivationPathHelper, ongoingProcess) {
|
||||
function($scope, $rootScope, $timeout, go, notification, profileService, configService, storageService, applicationService, gettext, lodash, ledger, trezor, platformInfo, derivationPathHelper, ongoingProcess, walletService, $log) {
|
||||
|
||||
var isChromeApp = platformInfo.isChromeApp;
|
||||
var isDevel = platformInfo.isDevel;
|
||||
|
|
@ -128,7 +128,7 @@ angular.module('copayApp.controllers').controller('joinController',
|
|||
this._join = function(opts) {
|
||||
ongoingProcess.set('joiningWallet', true);
|
||||
$timeout(function() {
|
||||
profileService.joinWallet(opts, function(err, wallet) {
|
||||
profileService.joinWallet(opts, function(err, client) {
|
||||
ongoingProcess.set('joiningWallet', false);
|
||||
if (err) {
|
||||
self.error = err;
|
||||
|
|
@ -136,8 +136,8 @@ angular.module('copayApp.controllers').controller('joinController',
|
|||
return;
|
||||
}
|
||||
|
||||
walletService.updateRemotePreferences(wallet, {}, function() {
|
||||
$log.debug('Remote preferences saved for:' + wallet.walletId)
|
||||
walletService.updateRemotePreferences(client, {}, function() {
|
||||
$log.debug('Remote preferences saved for:' + client.credentials.walletId)
|
||||
});
|
||||
|
||||
go.walletHome();
|
||||
|
|
|
|||
|
|
@ -1,11 +1,91 @@
|
|||
'use strict';
|
||||
|
||||
angular.module('copayApp.controllers').controller('tabScanController', function($scope, $timeout, $ionicModal, gettextCatalog, platformInfo) {
|
||||
angular.module('copayApp.controllers').controller('tabScanController', function($scope, $timeout, $ionicModal, $log, $ionicPopup, configService, gettextCatalog, platformInfo, go, bitcore, lodash) {
|
||||
|
||||
var isCordova = platformInfo.isCordova;
|
||||
var isWP = platformInfo.isWP;
|
||||
var isIOS = platformInfo.isIOS;
|
||||
|
||||
var config = configService.getSync();
|
||||
var configWallet = config.wallet;
|
||||
var walletSettings = configWallet.settings;
|
||||
|
||||
var unitToSatoshi = walletSettings.unitToSatoshi;
|
||||
var unitDecimals = walletSettings.unitDecimals;
|
||||
var satToUnit = 1 / unitToSatoshi;
|
||||
|
||||
var _showAlert = function(title, msg, cb) {
|
||||
$log.warn(title + ":"+ msg);
|
||||
var alertPopup = $ionicPopup.alert({
|
||||
title: title,
|
||||
template: msg
|
||||
});
|
||||
|
||||
if (!cb) cb = function(res) {};
|
||||
|
||||
alertPopup.then(cb);
|
||||
};
|
||||
|
||||
var _dataScanned = function(data) {
|
||||
var parsedData = _parseFromUri(data);
|
||||
|
||||
if (lodash.isEmpty(parsedData)) {
|
||||
_showAlert('Bad bitcoin address', 'Could not recognize the bitcoin address', function(res) {
|
||||
$scope.init();
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
go.confirm(parsedData);
|
||||
};
|
||||
|
||||
var _parseFromUri = function(uri) {
|
||||
|
||||
function sanitizeUri(uri) {
|
||||
// Fixes when a region uses comma to separate decimals
|
||||
var regex = /[\?\&]amount=(\d+([\,\.]\d+)?)/i;
|
||||
var match = regex.exec(uri);
|
||||
if (!match || match.length === 0) {
|
||||
return uri;
|
||||
}
|
||||
var value = match[0].replace(',', '.');
|
||||
var newUri = uri.replace(regex, value);
|
||||
return newUri;
|
||||
};
|
||||
|
||||
var satToUnit = 1 / unitToSatoshi;
|
||||
|
||||
// URI extensions for Payment Protocol with non-backwards-compatible request
|
||||
if ((/^bitcoin:\?r=[\w+]/).exec(uri)) {
|
||||
// TODO: PAYPRO
|
||||
} else {
|
||||
uri = sanitizeUri(uri);
|
||||
|
||||
if (!bitcore.URI.isValid(uri)) {
|
||||
return uri;
|
||||
}
|
||||
var parsed = new bitcore.URI(uri);
|
||||
|
||||
var addr = parsed.address ? parsed.address.toString() : '';
|
||||
var message = parsed.message;
|
||||
|
||||
var amount = parsed.amount ?
|
||||
(parsed.amount.toFixed(0) * satToUnit).toFixed(unitDecimals) : 0;
|
||||
|
||||
|
||||
if (parsed.r) {
|
||||
// TODO: PAYPRO
|
||||
} else {
|
||||
// TODO: message
|
||||
return {
|
||||
toAddress: addr,
|
||||
toAmount: amount
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
var onSuccess = function(result) {
|
||||
$timeout(function() {
|
||||
window.plugins.spinnerDialog.hide();
|
||||
|
|
@ -14,6 +94,11 @@ angular.module('copayApp.controllers').controller('tabScanController', function(
|
|||
|
||||
$timeout(function() {
|
||||
var data = isIOS ? result : result.text;
|
||||
// Check if the current page is tabs.scan
|
||||
if (go.is('tabs.scan')) {
|
||||
_dataScanned(data);
|
||||
return;
|
||||
}
|
||||
$scope.onScan({
|
||||
data: data
|
||||
});
|
||||
|
|
@ -103,7 +188,12 @@ angular.module('copayApp.controllers').controller('tabScanController', function(
|
|||
prevResult = data;
|
||||
return;
|
||||
}
|
||||
// Check if the current page is tabs.scan
|
||||
_scanStop();
|
||||
if (go.is('tabs.scan')) {
|
||||
_dataScanned(data);
|
||||
return;
|
||||
}
|
||||
$scope.cancel();
|
||||
$scope.onScan({
|
||||
data: data
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue