Merge pull request #250 from Bitcoin-com/wallet/task/537

Wallet/task/537
This commit is contained in:
Jean-Baptiste Dominguez 2018-08-09 15:41:29 +09:00 committed by GitHub
commit 0c15a83782
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
25 changed files with 416 additions and 195 deletions

View file

@ -6256,7 +6256,6 @@ var ClickAction = /** @class */ (function (_super) {
// Add event listener to all the elements found // Add event listener to all the elements found
for (var i = 0; i < elements.length; i++) { for (var i = 0; i < elements.length; i++) {
var element = elements[i]; var element = elements[i];
console.log('init ' + this.name);
element.addEventListener('click', this.listener); element.addEventListener('click', this.listener);
} }
}; };
@ -6413,7 +6412,6 @@ var AdjustChannel = /** @class */ (function (_super) {
_this.eventTypes = config.eventTypes; _this.eventTypes = config.eventTypes;
var os = _this.adjustedOs(config.os); var os = _this.adjustedOs(config.os);
_this.advertisingId = _this.getAdvertisingId(os); _this.advertisingId = _this.getAdvertisingId(os);
console.log('Advertising ID for adjust: ' + _this.advertisingId);
// TODO: Different initialisation for Cordova. // TODO: Different initialisation for Cordova.
var sessionParams = { var sessionParams = {
app_version: config.appVersion, app_version: config.appVersion,
@ -6656,7 +6654,7 @@ var MixpanelChannel = /** @class */ (function (_super) {
function MixpanelChannel(name, config) { function MixpanelChannel(name, config) {
var _this = _super.call(this, name) || this; var _this = _super.call(this, name) || this;
if (!config.token) { if (!config.token) {
throw new DOMException('[BitAnalytics] Config incorrect.'); throw new Error('[BitAnalytics] Config incorrect.');
} }
_this.mixpanelInstance = mixpanel; _this.mixpanelInstance = mixpanel;
mixpanel.init(config.token, config.config); mixpanel.init(config.token, config.config);
@ -7037,7 +7035,7 @@ var LogEventHandlers = /** @class */ (function () {
_this.channels.push(channel); _this.channels.push(channel);
} }
catch (error) { catch (error) {
console.log('[BitAnalytics] ' + error.name + ': ' + error.message); console.log(error.message);
} }
}); });
}; };

View file

@ -1,6 +1,6 @@
'use strict'; 'use strict';
angular.module('copayApp.controllers').controller('addressbookViewController', function($scope, $state, $timeout, lodash, addressbookService, popupService, $ionicHistory, platformInfo, gettextCatalog, configService, bitcoinCashJsService) { angular.module('copayApp.controllers').controller('addressbookViewController', function($scope, sendFlowService, $state, $timeout, lodash, addressbookService, popupService, $ionicHistory, platformInfo, gettextCatalog, configService, bitcoinCashJsService) {
var config = configService.getSync(); var config = configService.getSync();
var defaults = configService.getDefaults(); var defaults = configService.getDefaults();
@ -22,6 +22,7 @@ angular.module('copayApp.controllers').controller('addressbookViewController', f
$scope.sendTo = function() { $scope.sendTo = function() {
$ionicHistory.removeBackView(); $ionicHistory.removeBackView();
sendFlowService.clear();
$state.go('tabs.send'); $state.go('tabs.send');
$timeout(function() { $timeout(function() {
var to = ''; var to = '';
@ -31,12 +32,16 @@ angular.module('copayApp.controllers').controller('addressbookViewController', f
} else { } else {
to = $scope.addressbookEntry.address; to = $scope.addressbookEntry.address;
} }
$state.transitionTo('tabs.send.amount', {
var stateParams = {
toAddress: to, toAddress: to,
toName: $scope.addressbookEntry.name, toName: $scope.addressbookEntry.name,
toEmail: $scope.addressbookEntry.email, toEmail: $scope.addressbookEntry.email,
coin: $scope.addressbookEntry.coin coin: $scope.addressbookEntry.coin
}); };
sendFlowService.pushState(stateParams);
$state.transitionTo('tabs.send.origin');
}, 100); }, 100);
}; };

View file

@ -2,7 +2,7 @@
angular.module('copayApp.controllers').controller('amountController', amountController); angular.module('copayApp.controllers').controller('amountController', amountController);
function amountController(configService, $filter, gettextCatalog, $ionicHistory, $ionicModal, $ionicScrollDelegate, lodash, $log, nodeWebkitService, rateService, $scope, $state, $timeout, shapeshiftService, txFormatService, platformInfo, profileService, walletService, $window) { function amountController(configService, $filter, gettextCatalog, $ionicHistory, $ionicModal, $ionicScrollDelegate, lodash, $log, nodeWebkitService, rateService, $scope, $state, $timeout, sendFlowService, shapeshiftService, txFormatService, platformInfo, profileService, walletService, $window) {
var vm = this; var vm = this;
vm.allowSend = false; vm.allowSend = false;
@ -66,18 +66,23 @@ function amountController(configService, $filter, gettextCatalog, $ionicHistory,
} }
function onBeforeEnter(event, data) { function onBeforeEnter(event, data) {
console.log('amount onBeforeEnter sendflow ', sendFlowService.getState());
if (data.direction == "back") {
sendFlowService.popState();
}
initCurrencies(); initCurrencies();
passthroughParams = data.stateParams; passthroughParams = sendFlowService;
vm.fromWalletId = data.stateParams.fromWalletId; vm.fromWalletId = passthroughParams.fromWalletId;
vm.toWalletId = data.stateParams.toWalletId; vm.toWalletId = passthroughParams.toWalletId;
vm.minAmount = parseFloat(data.stateParams.minAmount); vm.minAmount = parseFloat(passthroughParams.minAmount);
vm.maxAmount = parseFloat(data.stateParams.maxAmount); vm.maxAmount = parseFloat(passthroughParams.maxAmount);
if (passthroughParams.thirdParty) { if (passthroughParams.thirdParty) {
vm.thirdParty = JSON.parse(passthroughParams.thirdParty); // Parse stringified JSON-object vm.thirdParty = passthroughParams.thirdParty; // Parse stringified JSON-object
if (vm.thirdParty) { if (vm.thirdParty) {
if (vm.thirdParty.id === 'shapeshift') { if (vm.thirdParty.id === 'shapeshift') {
if (!vm.thirdParty.data) { if (!vm.thirdParty.data) {
@ -96,7 +101,7 @@ function amountController(configService, $filter, gettextCatalog, $ionicHistory,
} }
} }
vm.isRequestingSpecificAmount = !data.stateParams.fromWalletId; vm.isRequestingSpecificAmount = !passthroughParams.fromWalletId;
var config = configService.getSync().wallet.settings; var config = configService.getSync().wallet.settings;
@ -177,8 +182,8 @@ function amountController(configService, $filter, gettextCatalog, $ionicHistory,
// currency have preference // currency have preference
var fiatName; var fiatName;
if (data.stateParams.currency) { if (passthroughParams.currency) {
fiatCode = data.stateParams.currency; fiatCode = passthroughParams.currency;
altUnitIndex = unitIndex altUnitIndex = unitIndex
unitIndex = availableUnits.length; unitIndex = availableUnits.length;
} else { } else {
@ -205,20 +210,11 @@ function amountController(configService, $filter, gettextCatalog, $ionicHistory,
var fromWallet = profileService.getWallet(passthroughParams.fromWalletId); var fromWallet = profileService.getWallet(passthroughParams.fromWalletId);
updateAvailableFundsFromWallet(fromWallet); updateAvailableFundsFromWallet(fromWallet);
} }
}; }
}; }
function goBack() { function goBack() {
if (vm.thirdParty && vm.thirdParty.id === 'shapeshift') { $ionicHistory.goBack();
$state.go('tabs.send').then(function() {
$ionicHistory.clearHistory();
$state.go('tabs.home').then(function() {
$state.transitionTo('tabs.shapeshift');
});
});
} else {
$ionicHistory.goBack();
}
} }
function paste(value) { function paste(value) {
@ -227,18 +223,18 @@ function amountController(configService, $filter, gettextCatalog, $ionicHistory,
$timeout(function() { $timeout(function() {
$scope.$apply(); $scope.$apply();
}); });
}; }
function processClipboard() { function processClipboard() {
if (!isNW) return; if (!isNW) return;
var value = nodeWebkitService.readFromClipboard(); var value = nodeWebkitService.readFromClipboard();
if (value && evaluate(value) > 0) paste(evaluate(value)); if (value && evaluate(value) > 0) paste(evaluate(value));
}; }
function sendMax() { function sendMax() {
useSendMax = true; useSendMax = true;
finish(); finish();
}; }
function updateUnitUI() { function updateUnitUI() {
vm.unit = availableUnits[unitIndex].shortName; vm.unit = availableUnits[unitIndex].shortName;
@ -246,7 +242,7 @@ function amountController(configService, $filter, gettextCatalog, $ionicHistory,
processAmount(); processAmount();
$log.debug('Update unit coin @amount unit:' + vm.unit + " alternativeUnit:" + vm.alternativeUnit); $log.debug('Update unit coin @amount unit:' + vm.unit + " alternativeUnit:" + vm.alternativeUnit);
}; }
function changeUnit() { function changeUnit() {
@ -267,7 +263,7 @@ function amountController(configService, $filter, gettextCatalog, $ionicHistory,
updateAvailableFundsStringIfNeeded(); updateAvailableFundsStringIfNeeded();
updateUnitUI(); updateUnitUI();
}; }
function pushDigit(digit) { function pushDigit(digit) {
if (vm.amount && digit != '.') { if (vm.amount && digit != '.') {
@ -291,7 +287,7 @@ function amountController(configService, $filter, gettextCatalog, $ionicHistory,
vm.amount = (vm.amount + digit).replace('..', '.'); vm.amount = (vm.amount + digit).replace('..', '.');
processAmount(); processAmount();
}; }
function pushOperator(operator) { function pushOperator(operator) {
if (!vm.amount || vm.amount.length == 0) return; if (!vm.amount || vm.amount.length == 0) return;
@ -303,18 +299,18 @@ function amountController(configService, $filter, gettextCatalog, $ionicHistory,
} else { } else {
return val.slice(0, -1) + operator; return val.slice(0, -1) + operator;
} }
}; }
}; }
function isOperator(val) { function isOperator(val) {
var regex = /[\/\-\+\x\*]/; var regex = /[\/\-\+\x\*]/;
return regex.test(val); return regex.test(val);
}; }
function isExpression(val) { function isExpression(val) {
var regex = /^\.?\d+(\.?\d+)?([\/\-\+\*x]\d?\.?\d+)+$/; var regex = /^\.?\d+(\.?\d+)?([\/\-\+\*x]\d?\.?\d+)+$/;
return regex.test(val); return regex.test(val);
}; }
function removeDigit() { function removeDigit() {
vm.amount = (vm.amount).toString().slice(0, -1); vm.amount = (vm.amount).toString().slice(0, -1);
@ -339,7 +335,7 @@ function amountController(configService, $filter, gettextCatalog, $ionicHistory,
function close() { function close() {
altCurrencyModal.remove(); altCurrencyModal.remove();
altCurrencyModal = null; altCurrencyModal = null;
}; }
function processAmount() { function processAmount() {
var formatedValue = format(vm.amount); var formatedValue = format(vm.amount);
@ -409,22 +405,22 @@ function amountController(configService, $filter, gettextCatalog, $ionicHistory,
} else { } else {
vm.errorMessage = ''; vm.errorMessage = '';
} }
}; }
function processResult(val) { function processResult(val) {
if (availableUnits[unitIndex].isFiat) return $filter('formatFiatAmount')(val); if (availableUnits[unitIndex].isFiat) return $filter('formatFiatAmount')(val);
else return txFormatService.formatAmount(val.toFixed(unitDecimals) * unitToSatoshi, true); else return txFormatService.formatAmount(val.toFixed(unitDecimals) * unitToSatoshi, true);
}; }
function fromFiat(val) { function fromFiat(val) {
return parseFloat((rateService.fromFiat(val, fiatCode, availableUnits[altUnitIndex].id) * satToUnit).toFixed(unitDecimals)); return parseFloat((rateService.fromFiat(val, fiatCode, availableUnits[altUnitIndex].id) * satToUnit).toFixed(unitDecimals));
}; }
function toFiat(val) { function toFiat(val) {
if (!rateService.getRate(fiatCode)) return; if (!rateService.getRate(fiatCode)) return;
return parseFloat((rateService.toFiat(val * unitToSatoshi, fiatCode, availableUnits[unitIndex].id)).toFixed(2)); return parseFloat((rateService.toFiat(val * unitToSatoshi, fiatCode, availableUnits[unitIndex].id)).toFixed(2));
}; }
function evaluate(val) { function evaluate(val) {
var result; var result;
@ -435,7 +431,7 @@ function amountController(configService, $filter, gettextCatalog, $ionicHistory,
} }
if (!lodash.isFinite(result)) return 0; if (!lodash.isFinite(result)) return 0;
return result; return result;
}; }
function format(val) { function format(val) {
if (!val) return; if (!val) return;
@ -445,7 +441,7 @@ function amountController(configService, $filter, gettextCatalog, $ionicHistory,
if (isOperator(lodash.last(val))) result = result.slice(0, -1); if (isOperator(lodash.last(val))) result = result.slice(0, -1);
return result.replace('x', '*'); return result.replace('x', '*');
}; }
function finish() { function finish() {
var unit = availableUnits[unitIndex]; var unit = availableUnits[unitIndex];
@ -467,16 +463,17 @@ function amountController(configService, $filter, gettextCatalog, $ionicHistory,
}; };
if (vm.thirdParty) { if (vm.thirdParty) {
confirmData['thirdParty'] = JSON.stringify(this.thirdParty); confirmData['thirdParty'] = this.thirdParty;
} }
sendFlowService.pushState(confirmData);
if (!confirmData.fromWalletId) { if (!confirmData.fromWalletId) {
$state.transitionTo('tabs.paymentRequest.confirm', confirmData); $state.transitionTo('tabs.paymentRequest.confirm', confirmData);
} else { } else {
$state.transitionTo('tabs.send.review', confirmData); $state.transitionTo('tabs.send.review', confirmData);
$scope.useSendMax = null; $scope.useSendMax = null;
} }
}; }
// Currency // Currency
@ -495,7 +492,7 @@ function amountController(configService, $filter, gettextCatalog, $ionicHistory,
{isoCode: 'CNY', order: 7}, {isoCode: 'CNY', order: 7},
{isoCode: 'KRW', order: 8}, {isoCode: 'KRW', order: 8},
{isoCode: 'HKD', order: 9}, {isoCode: 'HKD', order: 9},
] ];
function initCurrencies() { function initCurrencies() {
var unusedCurrencyList = [{ var unusedCurrencyList = [{
@ -558,7 +555,7 @@ function amountController(configService, $filter, gettextCatalog, $ionicHistory,
$timeout(function() { $timeout(function() {
$scope.$apply(); $scope.$apply();
}); });
}; }
function save(newAltCurrency) { function save(newAltCurrency) {
var opts = { var opts = {
@ -584,7 +581,7 @@ function amountController(configService, $filter, gettextCatalog, $ionicHistory,
updateUnitUI(); updateUnitUI();
close(); close();
}); });
}; }
function updateAvailableFundsStringIfNeeded() { function updateAvailableFundsStringIfNeeded() {
if (passthroughParams.fromWalletId && availableSatoshis !== null) { if (passthroughParams.fromWalletId && availableSatoshis !== null) {
@ -639,5 +636,4 @@ function amountController(configService, $filter, gettextCatalog, $ionicHistory,
vm.availableFunds = availableFundsInCrypto; vm.availableFunds = availableFundsInCrypto;
} }
} }
} }

View file

@ -1,7 +1,7 @@
'use strict'; 'use strict';
angular.module('copayApp.controllers').controller('backupController', angular.module('copayApp.controllers').controller('backupController',
function($scope, $timeout, $log, $state, $stateParams, $ionicHistory, lodash, profileService, bwcService, walletService, ongoingProcess, popupService, gettextCatalog, $ionicModal, firebaseEventsService) { function($scope, $timeout, $log, $state, $stateParams, $ionicHistory, lodash, profileService, bwcService, walletService, ongoingProcess, popupService, gettextCatalog, $ionicModal) {
if ($state.current.name == 'onboarding.backup') { if ($state.current.name == 'onboarding.backup') {
$scope.onboarding = true; $scope.onboarding = true;
@ -89,7 +89,8 @@ angular.module('copayApp.controllers').controller('backupController',
$scope.setFlow(2); $scope.setFlow(2);
}) })
} else { } else {
firebaseEventsService.logEvent('backed_up_wallet');
//firebaseEventsService.logEvent('backed_up_wallet');
openConfirmBackupModal(); openConfirmBackupModal();
} }
}; };

View file

@ -1,6 +1,6 @@
'use strict'; 'use strict';
angular.module('copayApp.controllers').controller('confirmController', function($rootScope, $scope, $interval, $filter, $timeout, $ionicScrollDelegate, $ionicLoading, ionicToast, addressbookService, gettextCatalog, walletService, platformInfo, lodash, configService, $stateParams, $window, $state, $log, profileService, bitcore, bitcoreCash, txFormatService, ongoingProcess, $ionicModal, popupService, $ionicHistory, $ionicConfig, payproService, feeService, bitcoinCashJsService, bwcError, txConfirmNotification, externalLinkService, firebaseEventsService, soundService, clipboardService) { angular.module('copayApp.controllers').controller('confirmController', function($rootScope, $scope, $interval, $timeout, $ionicScrollDelegate, $ionicLoading, ionicToast, addressbookService, gettextCatalog, walletService, platformInfo, lodash, configService, $state, $log, profileService, bitcore, bitcoreCash, txFormatService, ongoingProcess, $ionicModal, popupService, $ionicHistory, $ionicConfig, feeService, bitcoinCashJsService, bwcError, txConfirmNotification, soundService, clipboardService) {
var countDown = null; var countDown = null;
var FEE_TOO_HIGH_LIMIT_PER = 15; var FEE_TOO_HIGH_LIMIT_PER = 15;
@ -708,8 +708,6 @@ angular.module('copayApp.controllers').controller('confirmController', function(
}], [channel, "adjust"]); }], [channel, "adjust"]);
window.BitAnalytics.LogEventHandlers.postEvent(log); window.BitAnalytics.LogEventHandlers.postEvent(log);
// Should be removed
firebaseEventsService.logEvent('sent_bitcoin', { coin: $scope.wallet.coin });
$timeout(function() { $timeout(function() {
$scope.$digest(); $scope.$digest();
}, 100); }, 100);

View file

@ -1,7 +1,7 @@
'use strict'; 'use strict';
angular.module('copayApp.controllers').controller('createController', angular.module('copayApp.controllers').controller('createController',
function($scope, $rootScope, $timeout, $log, lodash, $state, $ionicScrollDelegate, $ionicHistory, profileService, configService, gettextCatalog, ledger, trezor, intelTEE, derivationPathHelper, ongoingProcess, walletService, storageService, popupService, appConfigService, pushNotificationsService, firebaseEventsService, $ionicNavBarDelegate) { function($scope, $timeout, $log, lodash, $state, $ionicScrollDelegate, $ionicHistory, profileService, configService, gettextCatalog, ledger, trezor, intelTEE, derivationPathHelper, ongoingProcess, walletService, popupService, appConfigService, pushNotificationsService, $ionicNavBarDelegate) {
/* For compressed keys, m*73 + n*34 <= 496 */ /* For compressed keys, m*73 + n*34 <= 496 */
var COPAYER_PAIR_LIMITS = { var COPAYER_PAIR_LIMITS = {
@ -268,7 +268,7 @@ angular.module('copayApp.controllers').controller('createController',
}, 100); }, 100);
} }
else { else {
firebaseEventsService.logEvent('wallet_created', { coin: opts.coin }); //firebaseEventsService.logEvent('wallet_created', { coin: opts.coin });
$state.go('tabs.home'); $state.go('tabs.home');
} }
} }

View file

@ -4,7 +4,7 @@ angular
.module('copayApp.controllers') .module('copayApp.controllers')
.controller('reviewController', reviewController); .controller('reviewController', reviewController);
function reviewController(addressbookService, bitcoinCashJsService, bitcore, bitcoreCash, bwcError, configService, feeService, gettextCatalog, $interval, $ionicHistory, $ionicModal, lodash, $log, ongoingProcess, platformInfo, popupService, profileService, $scope, shapeshiftService, soundService, $state, $timeout, txConfirmNotification, txFormatService, walletService) { function reviewController(addressbookService, bitcoinCashJsService, bitcore, bitcoreCash, bwcError, configService, feeService, gettextCatalog, $interval, $ionicHistory, $ionicModal, lodash, $log, ongoingProcess, platformInfo, popupService, profileService, $scope, sendFlowService, shapeshiftService, soundService, $state, $timeout, txConfirmNotification, txFormatService, walletService) {
var vm = this; var vm = this;
vm.buttonText = ''; vm.buttonText = '';
@ -49,9 +49,10 @@ function reviewController(addressbookService, bitcoinCashJsService, bitcore, bit
vm.memoExpanded = false; vm.memoExpanded = false;
// Functions // Functions
vm.goBack = goBack;
vm.onSuccessConfirm = onSuccessConfirm; vm.onSuccessConfirm = onSuccessConfirm;
var sendFlowData;
var config = null; var config = null;
var countDown = null; var countDown = null;
var defaults = {}; var defaults = {};
@ -74,22 +75,22 @@ function reviewController(addressbookService, bitcoinCashJsService, bitcore, bit
function onBeforeEnter(event, data) { function onBeforeEnter(event, data) {
console.log('walletSelector onBeforeEnter sendflow ', sendFlowService.getState());
defaults = configService.getDefaults(); defaults = configService.getDefaults();
originWalletId = data.stateParams.fromWalletId; sendFlowData = sendFlowService.getState();
satoshis = parseInt(data.stateParams.amount, 10); originWalletId = sendFlowData.fromWalletId;
toAddress = data.stateParams.toAddress; satoshis = parseInt(sendFlowData.amount, 10);
destinationWalletId = data.stateParams.toWalletId; toAddress = sendFlowData.toAddress;
destinationWalletId = sendFlowData.toWalletId;
vm.originWallet = profileService.getWallet(originWalletId); vm.originWallet = profileService.getWallet(originWalletId);
vm.origin.currency = vm.originWallet.coin.toUpperCase(); vm.origin.currency = vm.originWallet.coin.toUpperCase();
coin = vm.originWallet.coin; coin = vm.originWallet.coin;
if (data.stateParams.thirdParty) { if (sendFlowData.thirdParty) {
vm.thirdParty = JSON.parse(data.stateParams.thirdParty); // Parse stringified JSON-object vm.thirdParty = sendFlowData.thirdParty;
if (vm.thirdParty) { handleThirdPartyInitIfBip70();
handleThirdPartyInitIfBip70(); handleThirdPartyInitIfShapeshift();
handleThirdPartyInitIfShapeshift();
}
} }
configService.get(function onConfig(err, configCache) { configService.get(function onConfig(err, configCache) {
@ -105,7 +106,7 @@ function reviewController(addressbookService, bitcoinCashJsService, bitcore, bit
updateSendAmounts(); updateSendAmounts();
getOriginWalletBalance(vm.originWallet); getOriginWalletBalance(vm.originWallet);
handleDestinationAsAddress(toAddress, coin); handleDestinationAsAddress(toAddress, coin);
handleDestinationAsWallet(data.stateParams.toWalletId); handleDestinationAsWallet(sendFlowData.toWalletId);
createVanityTransaction(data); createVanityTransaction(data);
}); });
} }
@ -221,10 +222,10 @@ function reviewController(addressbookService, bitcoinCashJsService, bitcore, bit
// Grab stateParams // Grab stateParams
tx = { tx = {
amount: parseInt(data.stateParams.amount), amount: parseInt(sendFlowData.amount),
sendMax: data.stateParams.sendMax === 'true' ? true : false, sendMax: sendFlowData.sendMax === 'true' ? true : false,
fromWalletId: data.stateParams.fromWalletId, fromWalletId: sendFlowData.fromWalletId,
toAddress: data.stateParams.toAddress, toAddress: sendFlowData.toAddress,
paypro: txPayproData, paypro: txPayproData,
feeLevel: configFeeLevel, feeLevel: configFeeLevel,
@ -241,7 +242,6 @@ function reviewController(addressbookService, bitcoinCashJsService, bitcore, bit
}; };
if (data.stateParams.requiredFeeRate) { if (data.stateParams.requiredFeeRate) {
vm.usingMerchantFee = true; vm.usingMerchantFee = true;
tx.feeRate = parseInt(data.stateParams.requiredFeeRate); tx.feeRate = parseInt(data.stateParams.requiredFeeRate);
@ -251,7 +251,7 @@ function reviewController(addressbookService, bitcoinCashJsService, bitcore, bit
tx.feeLevel = 'normal'; tx.feeLevel = 'normal';
} }
var B = data.stateParams.coin === 'bch' ? bitcoreCash : bitcore; var B = tx.coin === 'bch' ? bitcoreCash : bitcore;
var networkName; var networkName;
try { try {
if (vm.destination.kind === 'wallet') { // This is a wallet-to-wallet transfer if (vm.destination.kind === 'wallet') { // This is a wallet-to-wallet transfer
@ -395,6 +395,10 @@ function reviewController(addressbookService, bitcoinCashJsService, bitcore, bit
}; };
} }
function goBack() {
$ionicHistory.goBack();
}
function handleDestinationAsAddress(address, originCoin) { function handleDestinationAsAddress(address, originCoin) {
if (!address) { if (!address) {
return; return;
@ -403,16 +407,20 @@ function reviewController(addressbookService, bitcoinCashJsService, bitcore, bit
// Check if the recipient is a contact // Check if the recipient is a contact
addressbookService.get(originCoin + address, function(err, contact) { addressbookService.get(originCoin + address, function(err, contact) {
if (!err && contact) { if (!err && contact) {
handleDestinationAsContact(contact); handleDestinationAsAddressOfContact(contact);
} else { } else {
vm.destination.address = address; if (originCoin === 'bch') {
vm.destination.address = bitcoinCashJsService.readAddress(address).cashaddr;
} else {
vm.destination.address = address;
}
vm.destination.kind = 'address'; vm.destination.kind = 'address';
} }
}); });
} }
function handleDestinationAsContact(contact) { function handleDestinationAsAddressOfContact(contact) {
vm.destination.kind = 'contact'; vm.destination.kind = 'contact';
vm.destination.name = contact.name; vm.destination.name = contact.name;
vm.destination.email = contact.email; vm.destination.email = contact.email;

View file

@ -1,6 +1,6 @@
'use strict'; 'use strict';
angular.module('copayApp.controllers').controller('shapeshiftController', function($scope, $state, $timeout, $ionicHistory, profileService, walletService, popupService, lodash, $ionicNavBarDelegate) { angular.module('copayApp.controllers').controller('shapeshiftController', function($scope, sendFlowService, $state, $timeout, $ionicHistory, profileService, walletService, popupService, lodash, $ionicNavBarDelegate) {
var walletsBtc = []; var walletsBtc = [];
var walletsBch = []; var walletsBch = [];
@ -63,15 +63,20 @@ angular.module('copayApp.controllers').controller('shapeshiftController', functi
}; };
$scope.shapeshift = function() { $scope.shapeshift = function() {
var params = { var stateParams = {
thirdParty: JSON.stringify({id: 'shapeshift'}) thirdParty: {
id: 'shapeshift'
}
}; };
// Starting new send flow, so ensure everything is reset
sendFlowService.clear();
$state.go('tabs.home').then(function() { $state.go('tabs.home').then(function() {
$ionicHistory.clearHistory(); $ionicHistory.clearHistory();
$state.go('tabs.send').then(function() { $state.go('tabs.send').then(function() {
$timeout(function () { $timeout(function () {
$state.transitionTo('tabs.send.origin', params); sendFlowService.pushState(stateParams);
$state.transitionTo('tabs.send.origin');
}, 60); }, 60);
}); });
}); });

View file

@ -1,7 +1,7 @@
'use strict'; 'use strict';
angular.module('copayApp.controllers').controller('tabHomeController', angular.module('copayApp.controllers').controller('tabHomeController',
function($rootScope, $timeout, $scope, $state, $stateParams, $ionicModal, $ionicScrollDelegate, $window, gettextCatalog, lodash, popupService, ongoingProcess, bannerService, externalLinkService, latestReleaseService, profileService, walletService, configService, $log, platformInfo, storageService, txpModalService, appConfigService, startupService, addressbookService, bwcError, nextStepsService, buyAndSellService, homeIntegrationsService, bitpayCardService, pushNotificationsService, timeService, bitcoincomService, pricechartService, firebaseEventsService, servicesService, shapeshiftService, $ionicNavBarDelegate, signVerifyMessageService) { function($rootScope, sendFlowService, $timeout, $scope, $state, $stateParams, $ionicScrollDelegate, $window, gettextCatalog, lodash, popupService, ongoingProcess, bannerService, externalLinkService, latestReleaseService, profileService, walletService, configService, $log, platformInfo, storageService, txpModalService, appConfigService, startupService, addressbookService, bwcError, nextStepsService, buyAndSellService, homeIntegrationsService, bitpayCardService, pushNotificationsService, timeService, $ionicNavBarDelegate) {
var wallet; var wallet;
var listeners = []; var listeners = [];
var notifications = []; var notifications = [];
@ -20,7 +20,12 @@ angular.module('copayApp.controllers').controller('tabHomeController',
$scope.bannerUrl = ''; $scope.bannerUrl = '';
$scope.$on("$ionicView.afterEnter", function() { $scope.$on("$ionicView.beforeEnter", onBeforeEnter);
$scope.$on("$ionicView.enter", onEnter);
$scope.$on("$ionicView.afterEnter", onAfterEnter);
$scope.$on("$ionicView.leave", onLeave);
function onAfterEnter () {
startupService.ready(); startupService.ready();
bannerService.getBanner(function (banner) { bannerService.getBanner(function (banner) {
@ -28,9 +33,10 @@ angular.module('copayApp.controllers').controller('tabHomeController',
$scope.bannerUrl = banner.url; $scope.bannerUrl = banner.url;
$scope.bannerIsLoading = false; $scope.bannerIsLoading = false;
}); });
}); };
function onBeforeEnter (event, data) {
$scope.$on("$ionicView.beforeEnter", function(event, data) {
if (!$scope.homeTip) { if (!$scope.homeTip) {
storageService.getHomeTipAccepted(function(error, value) { storageService.getHomeTipAccepted(function(error, value) {
$scope.homeTip = (value == 'accepted') ? false : true; $scope.homeTip = (value == 'accepted') ? false : true;
@ -51,9 +57,9 @@ angular.module('copayApp.controllers').controller('tabHomeController',
} }
}); });
} }
}); };
$scope.$on("$ionicView.enter", function(event, data) { function onEnter(event, data) {
$ionicNavBarDelegate.showBar(true); $ionicNavBarDelegate.showBar(true);
updateAllWallets(); updateAllWallets();
@ -97,26 +103,29 @@ angular.module('copayApp.controllers').controller('tabHomeController',
} }
$scope.showServices = true; $scope.showServices = true;
pushNotificationsService.init();
firebaseEventsService.init();
$timeout(function() { $timeout(function() {
$ionicScrollDelegate.resize(); $ionicScrollDelegate.resize();
$scope.$apply(); $scope.$apply();
}, 10); }, 10);
}); });
}); };
$scope.$on("$ionicView.leave", function(event, data) { function onLeave (event, data) {
lodash.each(listeners, function(x) { lodash.each(listeners, function(x) {
x(); x();
}); });
}); };
$scope.createdWithinPastDay = function(time) { $scope.createdWithinPastDay = function(time) {
return timeService.withinPastDay(time); return timeService.withinPastDay(time);
}; };
$scope.startFreshSend = function() {
sendFlowService.clear();
$state.go('tabs.send');
}
$scope.openExternalLink = function() { $scope.openExternalLink = function() {
var url = 'https://github.com/Bitcoin-com/Wallet/releases/latest'; var url = 'https://github.com/Bitcoin-com/Wallet/releases/latest';
var optIn = true; var optIn = true;

View file

@ -1,6 +1,6 @@
'use strict'; 'use strict';
angular.module('copayApp.controllers').controller('tabSendController', function($scope, $rootScope, $log, $timeout, $ionicScrollDelegate, $ionicLoading, addressbookService, profileService, lodash, $state, walletService, incomingData, popupService, platformInfo, bwcError, gettextCatalog, scannerService, configService, bitcoinCashJsService, $ionicPopup, $ionicNavBarDelegate, clipboardService) { angular.module('copayApp.controllers').controller('tabSendController', function($scope, $rootScope, $log, $timeout, $ionicScrollDelegate, $ionicLoading, addressbookService, profileService, lodash, $state, walletService, incomingData, popupService, platformInfo, sendFlowService, bwcError, gettextCatalog, scannerService, configService, bitcoinCashJsService, $ionicPopup, $ionicNavBarDelegate, clipboardService) {
var clipboardHasAddress = false; var clipboardHasAddress = false;
var clipboardHasContent = false; var clipboardHasContent = false;
var originalList; var originalList;
@ -33,6 +33,9 @@ angular.module('copayApp.controllers').controller('tabSendController', function(
text = text.substring(0, 200); text = text.substring(0, 200);
} }
var stateParams = sendFlowService.getState();
$scope.fromWallet = profileService.getWallet(stateParams.fromWalletId);
$scope.clipboardHasAddress = false; $scope.clipboardHasAddress = false;
$scope.clipboardHasContent = false; $scope.clipboardHasContent = false;
if ((text.indexOf('bitcoincash:') === 0 || text[0] === 'C' || text[0] === 'H' || text[0] === 'p' || text[0] === 'q') && text.replace('bitcoincash:', '').length === 42) { // CashAddr if ((text.indexOf('bitcoincash:') === 0 || text[0] === 'C' || text[0] === 'H' || text[0] === 'p' || text[0] === 'q') && text.replace('bitcoincash:', '').length === 42) { // CashAddr
@ -179,14 +182,30 @@ angular.module('copayApp.controllers').controller('tabSendController', function(
} }
$log.debug('Got toAddress:' + toAddress + ' | ' + item.name); $log.debug('Got toAddress:' + toAddress + ' | ' + item.name);
var stateParams = sendFlowService.getState();
stateParams.toAddress = toAddress,
stateParams.coin = item.coin;
sendFlowService.pushState(stateParams);
if (!stateParams.fromWalletId) { // If we have no toAddress or fromWallet
$state.transitionTo('tabs.send.origin');
} else {
$state.transitionTo('tabs.send.amount');
}
return $state.transitionTo('tabs.send.origin', {
toAddress: toAddress,
coin: item.coin
});
}); });
}; };
$scope.startWalletToWalletTransfer = function() {
console.log('startWalletToWalletTransfer()');
var params = sendFlowService.getState();
sendFlowService.pushState(params);
$state.transitionTo('tabs.send.wallet-to-wallet', {
fromWalletId: sendFlowService.fromWalletId
});
}
// This could probably be enhanced refactoring the routes abstract states // This could probably be enhanced refactoring the routes abstract states
$scope.createWallet = function() { $scope.createWallet = function() {
$state.go('tabs.home').then(function() { $state.go('tabs.home').then(function() {
@ -201,6 +220,8 @@ angular.module('copayApp.controllers').controller('tabSendController', function(
}; };
$scope.$on("$ionicView.beforeEnter", function(event, data) { $scope.$on("$ionicView.beforeEnter", function(event, data) {
console.log(data);
console.log('tab-send onBeforeEnter sendflow ', sendFlowService.getState());
$scope.isIOS = platformInfo.isIOS && platformInfo.isCordova; $scope.isIOS = platformInfo.isIOS && platformInfo.isCordova;
$scope.showWalletsBch = $scope.showWalletsBtc = $scope.showWallets = false; $scope.showWalletsBch = $scope.showWalletsBtc = $scope.showWallets = false;
@ -215,5 +236,9 @@ angular.module('copayApp.controllers').controller('tabSendController', function(
$scope.displayBalanceAsFiat = _config.wallet.settings.priceDisplay === 'fiat'; $scope.displayBalanceAsFiat = _config.wallet.settings.priceDisplay === 'fiat';
}); });
if (data.direction == "back") {
sendFlowService.clear();
}
}); });
}); });

View file

@ -1,6 +1,6 @@
'use strict'; 'use strict';
angular.module('copayApp.controllers').controller('tabsController', function($rootScope, $log, $scope, $state, $stateParams, $timeout, platformInfo, incomingData, lodash, popupService, gettextCatalog, scannerService) { angular.module('copayApp.controllers').controller('tabsController', function($rootScope, $log, $scope, $state, $stateParams, $timeout, platformInfo, incomingData, lodash, popupService, gettextCatalog, scannerService, sendFlowService) {
$scope.onScan = function(data) { $scope.onScan = function(data) {
if (!incomingData.redir(data)) { if (!incomingData.redir(data)) {
@ -15,6 +15,11 @@ angular.module('copayApp.controllers').controller('tabsController', function($ro
}; };
}; };
$scope.startFreshSend = function() {
sendFlowService.clear();
$state.go('tabs.send');
};
$scope.importInit = function() { $scope.importInit = function() {
$scope.fromOnboarding = $stateParams.fromOnboarding; $scope.fromOnboarding = $stateParams.fromOnboarding;
$timeout(function() { $timeout(function() {
@ -23,7 +28,7 @@ angular.module('copayApp.controllers').controller('tabsController', function($ro
}; };
$scope.chooseScanner = function() { $scope.chooseScanner = function() {
sendFlowService.clear();
var isWindowsPhoneApp = platformInfo.isCordova && platformInfo.isWP; var isWindowsPhoneApp = platformInfo.isCordova && platformInfo.isWP;
if (!isWindowsPhoneApp) { if (!isWindowsPhoneApp) {

View file

@ -1,6 +1,6 @@
'use strict'; 'use strict';
angular.module('copayApp.controllers').controller('walletDetailsController', function($scope, $rootScope, $interval, $timeout, $filter, $log, $ionicModal, $ionicPopover, $state, $stateParams, $ionicHistory, profileService, lodash, configService, platformInfo, walletService, txpModalService, externalLinkService, popupService, addressbookService, storageService, $ionicScrollDelegate, $window, bwcError, gettextCatalog, timeService, feeService, appConfigService, rateService) { angular.module('copayApp.controllers').controller('walletDetailsController', function($scope, $rootScope, $interval, $timeout, $filter, $log, $ionicModal, $ionicPopover, $state, $stateParams, $ionicHistory, profileService, lodash, configService, platformInfo, walletService, txpModalService, externalLinkService, popupService, addressbookService, sendFlowService, storageService, $ionicScrollDelegate, $window, bwcError, gettextCatalog, timeService, feeService, appConfigService, rateService) {
var HISTORY_SHOW_LIMIT = 10; var HISTORY_SHOW_LIMIT = 10;
var currentTxHistoryPage = 0; var currentTxHistoryPage = 0;
@ -374,6 +374,7 @@ angular.module('copayApp.controllers').controller('walletDetailsController', fun
}); });
$scope.$on("$ionicView.beforeEnter", function(event, data) { $scope.$on("$ionicView.beforeEnter", function(event, data) {
sendFlowService.clear();
configService.whenAvailable(function (config) { configService.whenAvailable(function (config) {
$scope.selectedPriceDisplay = config.wallet.settings.priceDisplay; $scope.selectedPriceDisplay = config.wallet.settings.priceDisplay;
@ -470,13 +471,18 @@ angular.module('copayApp.controllers').controller('walletDetailsController', fun
function rgbToHex(r, g, b) { function rgbToHex(r, g, b) {
return "#" + componentToHex(r) + componentToHex(g) + componentToHex(b); return "#" + componentToHex(r) + componentToHex(g) + componentToHex(b);
} }
$scope.goToSend = function() { $scope.goToSend = function() {
$state.go('tabs.home', { sendFlowService.startSend({
walletId: $scope.wallet.id fromWalletId: $scope.wallet.id
}).then(function () { });
// Go home first so that the Home tab works properly
$state.go('tabs.home').then(function () {
$ionicHistory.clearHistory(); $ionicHistory.clearHistory();
$state.go('tabs.send'); $state.go('tabs.send');
}); });
}; };
$scope.goToReceive = function() { $scope.goToReceive = function() {
$state.go('tabs.home', { $state.go('tabs.home', {
@ -488,6 +494,7 @@ angular.module('copayApp.controllers').controller('walletDetailsController', fun
}); });
}); });
}; };
$scope.goToBuy = function() { $scope.goToBuy = function() {
$state.go('tabs.home', { $state.go('tabs.home', {
walletId: $scope.wallet.id walletId: $scope.wallet.id

View file

@ -1,13 +1,24 @@
'use strict'; 'use strict';
angular.module('copayApp.controllers').controller('walletSelectorController', function($scope, $rootScope, $state, $log, $ionicHistory, configService, gettextCatalog, profileService, txFormatService) { angular.module('copayApp.controllers').controller('walletSelectorController', function($scope, $rootScope, $state, $log, $ionicHistory, sendFlowService, configService, gettextCatalog, profileService, txFormatService) {
var fromWalletId = ''; var fromWalletId = '';
var priceDisplayAsFiat = false; var priceDisplayAsFiat = false;
var unitDecimals = 0; var unitDecimals = 0;
var unitsFromSatoshis = 0; var unitsFromSatoshis = 0;
$scope.$on("$ionicView.beforeEnter", function(event, data) { $scope.$on("$ionicView.beforeEnter", onBeforeEnter);
$scope.$on("$ionicView.enter", onEnter);
function onBeforeEnter(event, data) {
console.log('walletSelector onBeforeEnter sendflow', sendFlowService.getState());
if (data.direction == "back") {
sendFlowService.popState();
}
var stateParams = sendFlowService.getState();
var config = configService.getSync().wallet.settings; var config = configService.getSync().wallet.settings;
priceDisplayAsFiat = config.priceDisplay === 'fiat'; priceDisplayAsFiat = config.priceDisplay === 'fiat';
unitDecimals = config.unitDecimals; unitDecimals = config.unitDecimals;
@ -18,7 +29,7 @@ angular.module('copayApp.controllers').controller('walletSelectorController', fu
$scope.sendFlowTitle = gettextCatalog.getString('Wallet to Wallet Transfer'); $scope.sendFlowTitle = gettextCatalog.getString('Wallet to Wallet Transfer');
break; break;
case 'tabs.send.destination': case 'tabs.send.destination':
if (data.stateParams.fromWalletId) { if (stateParams.fromWalletId) {
$scope.sendFlowTitle = gettextCatalog.getString('Wallet to Wallet Transfer'); $scope.sendFlowTitle = gettextCatalog.getString('Wallet to Wallet Transfer');
} }
break; break;
@ -26,10 +37,14 @@ angular.module('copayApp.controllers').controller('walletSelectorController', fu
// nop // nop
} }
$scope.params = $state.params; $scope.params = sendFlowService;
$scope.coin = false; // Wallets to show (for destination screen or contacts) $scope.coin = false; // Wallets to show (for destination screen or contacts)
$scope.type = data.stateParams && data.stateParams['fromWalletId'] ? 'destination' : 'origin'; // origin || destination $scope.type = $scope.params['fromWalletId'] ? 'destination' : 'origin'; // origin || destination
fromWalletId = data.stateParams && data.stateParams.fromWalletId; fromWalletId = $scope.params['fromWalletId'];
if ($scope.type === 'destination' && $scope.params.toAddress) {
$state.transitionTo(getNextStep());
}
if ($scope.params.coin) { if ($scope.params.coin) {
$scope.coin = $scope.params.coin; // Contacts have a coin embedded $scope.coin = $scope.params.coin; // Contacts have a coin embedded
@ -41,11 +56,11 @@ angular.module('copayApp.controllers').controller('walletSelectorController', fu
$scope.isPaymentRequest = true; $scope.isPaymentRequest = true;
} }
if ($scope.params.thirdParty) { if ($scope.params.thirdParty) {
$scope.thirdParty = JSON.parse($scope.params.thirdParty); // Parse stringified JSON-object $scope.thirdParty = $scope.params.thirdParty;
} }
}); };
$scope.$on("$ionicView.enter", function(event, data) { function onEnter (event, data) {
configService.whenAvailable(function(config) { configService.whenAvailable(function(config) {
$scope.selectedPriceDisplay = config.wallet.settings.priceDisplay; $scope.selectedPriceDisplay = config.wallet.settings.priceDisplay;
}); });
@ -57,7 +72,7 @@ angular.module('copayApp.controllers').controller('walletSelectorController', fu
prepareWalletLists(); prepareWalletLists();
formatRequestedAmount(); formatRequestedAmount();
}); };
function formatRequestedAmount() { function formatRequestedAmount() {
if ($scope.params.amount) { if ($scope.params.amount) {
@ -90,7 +105,7 @@ angular.module('copayApp.controllers').controller('walletSelectorController', fu
function getNextStep() { function getNextStep() {
if ($scope.thirdParty) { if ($scope.thirdParty) {
$scope.params.thirdParty = JSON.stringify($scope.thirdParty) // re-stringify JSON-object $scope.params.thirdParty = $scope.thirdParty
} }
if (!$scope.params.toWalletId && !$scope.params.toAddress) { // If we have no toAddress or fromWallet if (!$scope.params.toWalletId && !$scope.params.toAddress) { // If we have no toAddress or fromWallet
return 'tabs.send.destination'; return 'tabs.send.destination';
@ -178,11 +193,13 @@ angular.module('copayApp.controllers').controller('walletSelectorController', fu
$scope.useWallet = function(wallet) { $scope.useWallet = function(wallet) {
var params = sendFlowService.getState();
if ($scope.type === 'origin') { // we're on the origin screen, set wallet to send from if ($scope.type === 'origin') { // we're on the origin screen, set wallet to send from
$scope.params['fromWalletId'] = wallet.id; params.fromWalletId = wallet.id;
} else { // we're on the destination screen, set wallet to send to } else { // we're on the destination screen, set wallet to send to
$scope.params['toWalletId'] = wallet.id; params.toWalletId = wallet.id;
} }
sendFlowService.pushState(params);
$state.transitionTo(getNextStep(), $scope.params); $state.transitionTo(getNextStep(), $scope.params);
}; };

View file

@ -32,11 +32,16 @@ angular.module('bitcoincom.directives')
'3': ['BHD', 'IQD', 'JOD', 'KWD', 'OMR', 'TND'], '3': ['BHD', 'IQD', 'JOD', 'KWD', 'OMR', 'TND'],
'8': ['BCH', 'BTC'] '8': ['BCH', 'BTC']
}; };
var localizeNumbers = function(x, minimumFractionDigits = 0, useGrouping = true) { var localizeNumbers = function(x, minimumFractionDigits) {
return parseFloat(x).toLocaleString(uxLanguage.getCurrentLanguage(), { var parsed = parseFloat(x);
var opts = {
minimumFractionDigits: minimumFractionDigits, minimumFractionDigits: minimumFractionDigits,
useGrouping: useGrouping useGrouping: true
}); };
var lang = uxLanguage.getCurrentLanguage();
var localized = parsed.toLocaleString(lang, opts);
var corrected = ensureEnoughFractionalDigits(localized, x, minimumFractionDigits);
return corrected;
}; };
var buildAmount = function(start, middle, end) { var buildAmount = function(start, middle, end) {
@ -61,7 +66,6 @@ angular.module('bitcoincom.directives')
}; };
var formatNumbers = function() { var formatNumbers = function() {
// During watch, may be changed from having a separate currency value, // During watch, may be changed from having a separate currency value,
// to both being in value. Don't want to use previous currency value. // to both being in value. Don't want to use previous currency value.
// Try to extract currency from value.. // Try to extract currency from value..
@ -69,6 +73,7 @@ angular.module('bitcoincom.directives')
if (currencySplit.length === 2) { if (currencySplit.length === 2) {
$scope.currency = currencySplit[1]; $scope.currency = currencySplit[1];
} }
$scope.currency = $scope.currency || '';
var parsed = parseFloat($scope.value); var parsed = parseFloat($scope.value);
@ -79,7 +84,7 @@ angular.module('bitcoincom.directives')
if (isNaN(parsed)) { if (isNaN(parsed)) {
buildAmount('-', '', ''); buildAmount('-', '', '');
} else { } else {
valueFormatted = localizeNumbers(Math.round(parsed)); valueFormatted = localizeNumbers(Math.round(parsed), 0);
buildAmount(valueFormatted, '', ''); buildAmount(valueFormatted, '', '');
} }
break; break;
@ -127,6 +132,44 @@ angular.module('bitcoincom.directives')
$scope.$watchGroup(['currency', 'value'], function onFormattedAmountWatch() { $scope.$watchGroup(['currency', 'value'], function onFormattedAmountWatch() {
formatNumbers(); formatNumbers();
}); });
/**
* On Android 4.4, toLocaleString() only returns 3 fractional digits when 8 is specified.
*/
function ensureEnoughFractionalDigits(localizedString, number, desiredFractionDigits) {
if (desiredFractionDigits === 0) {
// Assume it is OK
return localizedString;
}
var fractionalRe = /^(\d*\D)(\d+)$/;
var match = fractionalRe.exec(localizedString);
if (match.length !== 3) {
// Don't know what's happening, just return what we have
return localizedString;
}
var decimals = match[2];
var decimalCount = decimals.length;
if (decimalCount >= desiredFractionDigits) {
// Everything is OK.
return localizedString;
}
if (typeof number !== 'number') {
number = parseFloat(number);
}
var fixed = number.toFixed(desiredFractionDigits);
var fixedMatch = fractionalRe.exec(fixed);
if (fixedMatch.length !== 3) {
// Don't know what's happening, just return what we have
return localizedString;
}
// Keeps locale decimal separator.
var enough = match[1] + fixedMatch[2];
return enough;
}
}); });
} }
}; };

View file

@ -287,7 +287,7 @@ angular.module('copayApp').config(function(historicLogProvider, $provide, $logPr
*/ */
.state('tabs.send.amount', { .state('tabs.send.amount', {
url: '/amount/:thirdParty/:fromWalletId/:maxAmount/:minAmount/:toWalletId/:toAddress', url: '/amount',
views: { views: {
'tab-send@tabs': { 'tab-send@tabs': {
controller: 'amountController', controller: 'amountController',
@ -306,7 +306,7 @@ angular.module('copayApp').config(function(historicLogProvider, $provide, $logPr
} }
}) })
.state('tabs.send.origin', { .state('tabs.send.origin', {
url: '/origin/:thirdParty/:amount/:toAddress/:toWalletId/:coin', url: '/origin',
views: { views: {
'tab-send@tabs': { 'tab-send@tabs': {
controller: 'walletSelectorController', controller: 'walletSelectorController',
@ -315,7 +315,7 @@ angular.module('copayApp').config(function(historicLogProvider, $provide, $logPr
} }
}) })
.state('tabs.send.destination', { .state('tabs.send.destination', {
url: '/destination/:thirdParty/:amount/:fromWalletId', url: '/destination',
views: { views: {
'tab-send@tabs': { 'tab-send@tabs': {
controller: 'walletSelectorController', controller: 'walletSelectorController',
@ -324,7 +324,7 @@ angular.module('copayApp').config(function(historicLogProvider, $provide, $logPr
} }
}) })
.state('tabs.send.confirm', { .state('tabs.send.confirm', {
url: '/confirm/:thirdParty/:amount/:fromWalletId/:toWalletId/:toAddress', url: '/confirm',
views: { views: {
'tab-send@tabs': { 'tab-send@tabs': {
controller: 'confirmController', controller: 'confirmController',
@ -1207,7 +1207,7 @@ angular.module('copayApp').config(function(historicLogProvider, $provide, $logPr
} }
}); });
}) })
.run(function($rootScope, $state, $location, $log, $timeout, startupService, ionicToast, fingerprintService, $ionicHistory, $ionicPlatform, $window, appConfigService, lodash, platformInfo, profileService, uxLanguage, gettextCatalog, openURLService, storageService, scannerService, configService, emailService, /* plugins START HERE => */ buydotbitcoindotcomService, glideraService, amazonService, bitpayCardService, applicationService, mercadoLibreService, rateService) { .run(function($rootScope, $state, $location, $log, $timeout, startupService, ionicToast, fingerprintService, $ionicHistory, $ionicPlatform, $window, appConfigService, lodash, platformInfo, profileService, uxLanguage, gettextCatalog, openURLService, storageService, scannerService, configService, emailService, /* plugins START HERE => */ buydotbitcoindotcomService, pushNotificationsService, glideraService, amazonService, bitpayCardService, applicationService, mercadoLibreService, rateService) {
$ionicPlatform.ready(function() { $ionicPlatform.ready(function() {
@ -1231,6 +1231,11 @@ angular.module('copayApp').config(function(historicLogProvider, $provide, $logPr
} }
}); });
configService.whenAvailable(function(config) {
pushNotificationsService.init();
});
//firebaseEventsService.init();
var channel = "ga"; var channel = "ga";
if (platformInfo.isCordova) { if (platformInfo.isCordova) {
channel = "firebase"; channel = "firebase";

View file

@ -13,7 +13,7 @@ angular.module('copayApp.services').factory('clipboardService', function ($http,
nodeWebkitService.writeToClipboard(data); nodeWebkitService.writeToClipboard(data);
} else if (navigator && navigator.clipboard) { } else if (navigator && navigator.clipboard) {
$log.debug("Use navigator clipboard.") $log.debug("Use navigator clipboard.")
navigator.clipboard.writeText(data).catch(err => { navigator.clipboard.writeText(data).catch(function onClipboardError(err) {
$log.debug("Clipboard writing is not supported in your browser.."); $log.debug("Clipboard writing is not supported in your browser..");
}); });
} else if (clipboard.supported) { } else if (clipboard.supported) {

View file

@ -1,5 +1,5 @@
'use strict'; 'use strict';
angular.module('copayApp.services').factory('firebaseEventsService', function firebaseEventsService($log, $state, $ionicHistory, sjcl, platformInfo, lodash, appConfigService, profileService, configService) { angular.module('copayApp.services').factory('firebaseEventsService', function firebaseEventsService($log, platformInfo) {
var root = {}; var root = {};
var useEvents = platformInfo.isCordova && !platformInfo.isWP; var useEvents = platformInfo.isCordova && !platformInfo.isWP;

View file

@ -1,6 +1,6 @@
'use strict'; 'use strict';
angular.module('copayApp.services').factory('incomingData', function($log, $state, $timeout, $ionicHistory, bitcore, bitcoreCash, $rootScope, payproService, scannerService, appConfigService, popupService, gettextCatalog, bitcoinCashJsService) { angular.module('copayApp.services').factory('incomingData', function($log, $state, $timeout, $ionicHistory, bitcore, bitcoreCash, $rootScope, payproService, scannerService, sendFlowService, appConfigService, popupService, gettextCatalog, bitcoinCashJsService) {
var root = {}; var root = {};
@ -82,7 +82,7 @@ angular.module('copayApp.services').factory('incomingData', function($log, $stat
}); });
// Timeout is required to enable the "Back" button // Timeout is required to enable the "Back" button
$timeout(function() { $timeout(function() {
var params = {}; var params = sendFlowService.getState();
if (amount) { if (amount) {
params.amount = amount; params.amount = amount;
@ -105,10 +105,11 @@ angular.module('copayApp.services').factory('incomingData', function($log, $stat
params.thirdParty = []; params.thirdParty = [];
params.thirdParty.id = serviceId; params.thirdParty.id = serviceId;
params.thirdParty.data = serviceData; params.thirdParty.data = serviceData;
params.thirdParty = JSON.stringify(params.thirdParty); sendFlowService.pushState(params);
$state.transitionTo('tabs.send.amount', params); $state.transitionTo('tabs.send.amount');
} else { } else {
$state.transitionTo('tabs.send.origin', params); sendFlowService.pushState(params);
$state.transitionTo('tabs.send.origin');
} }
}, 100); }, 100);
} }
@ -387,11 +388,13 @@ angular.module('copayApp.services').factory('incomingData', function($log, $stat
'notify': $state.current.name == 'tabs.send' ? false : true 'notify': $state.current.name == 'tabs.send' ? false : true
}); });
$timeout(function() { $timeout(function() {
$state.transitionTo('tabs.send.origin', { var stateParams = {
toAddress: toAddress, toAddress: toAddress,
coin: coin, coin: coin,
noPrefix: 1 noPrefix: 1
}); };
sendFlowService.pushState(stateParams);
$state.transitionTo('tabs.send.origin');
}, 100); }, 100);
} }
@ -458,7 +461,8 @@ angular.module('copayApp.services').factory('incomingData', function($log, $stat
'notify': $state.current.name == 'tabs.send' ? false : true 'notify': $state.current.name == 'tabs.send' ? false : true
}).then(function() { }).then(function() {
$timeout(function() { $timeout(function() {
$state.transitionTo('tabs.send.origin', stateParams); sendFlowService.pushState(stateParams); // Need to do more here
$state.transitionTo('tabs.send.origin');
}); });
}); });
} }

View file

@ -0,0 +1,95 @@
'use strict';
(function(){
angular
.module('copayApp.services')
.factory('sendFlowService', sendFlowService);
function sendFlowService($log) {
var service = {
amount: '',
fromWalletId: '',
sendMax: false,
thirdParty: null,
toAddress: '',
toWalletId: '',
previousStates: [],
// Functions
clear: clear,
getState: getState,
map: map,
popState: popState,
pushState: pushState,
startSend: startSend
};
return service;
function clear() {
console.log("sendFlow clear()");
clearCurrent();
service.previousStates = [];
}
function clearCurrent() {
console.log("sendFlow clearCurrent()");
service.amount = '';
service.fromWalletId = '';
service.sendMax = false;
service.thirdParty = null;
service.toAddress = '';
service.toWalletId = '';
}
/**
* Handy for debugging
*/
function getState() {
var currentState = {};
Object.keys(service).forEach(function forCurrentParam(key) {
if (typeof service[key] !== 'function' && key !== 'previousStates') {
currentState[key] = service[key];
}
});
return currentState;
}
/**
* Clears all previous state
*/
function startSend(params) {
console.log('startSend()');
clear();
map(params);
}
function map(params) {
Object.keys(params).forEach(function forNewParam(key) {
service[key] = params[key];
});
};
function popState() {
console.log('sendFlow pop');
if (service.previousStates.length) {
var params = service.previousStates.pop();
clearCurrent();
map(params);
} else {
clear();
}
};
function pushState(params) {
console.log('sendFlow push');
var currentParams = getState();
service.previousStates.push(currentParams);
clearCurrent();
map(params);
};
};
})();

View file

@ -2,15 +2,15 @@
@extend .deflash-blue; @extend .deflash-blue;
&-header{ &-header{
height: 300px; //height: 300px;
width: 100%; width: 100%;
} }
&-contacts { &-contacts {
height: calc(100vh - 300px - 50px - 44px); /* screen size - button container - bottom-tab-menu - header top */ //height: calc(100vh - 300px - 50px - 44px); /* screen size - button container - bottom-tab-menu - header top */
&.ios { &.ios {
height: calc(100vh - 300px - 50px - 44px - 18px); // Remove the notification-bar height on iOS //height: calc(100vh - 300px - 50px - 44px - 18px); // Remove the notification-bar height on iOS
} }
overflow: scroll; //overflow: scroll;
} }
.input { .input {
@ -223,12 +223,12 @@
} }
} }
#tab-send-header { #tab-send-header {
height: 270px; //height: 270px;
} }
#tab-send-contacts { #tab-send-contacts {
height: calc(100vh - 270px - 50px - 44px); /* screen size - button container - bottom-tab-menu - header top */ //height: calc(100vh - 270px - 50px - 44px); /* screen size - button container - bottom-tab-menu - header top */
&.ios { &.ios {
height: calc(100vh - 270px - 50px - 44px - 18px); // Remove the notification-bar height on iOS //height: calc(100vh - 270px - 50px - 44px - 18px); // Remove the notification-bar height on iOS
} }
} }
} }

View file

@ -11168,16 +11168,8 @@ qrcode {
background-color: #fab915 !important; } background-color: #fab915 !important; }
#tab-send-header { #tab-send-header {
height: 300px;
width: 100%; } width: 100%; }
#tab-send-contacts {
height: calc(100vh - 300px - 50px - 44px);
/* screen size - button container - bottom-tab-menu - header top */
overflow: scroll; }
#tab-send-contacts.ios {
height: calc(100vh - 300px - 50px - 44px - 18px); }
#tab-send .input { #tab-send .input {
width: 100%; } width: 100%; }
#tab-send .input input { #tab-send .input input {
@ -11358,14 +11350,7 @@ qrcode {
#tab-send .send-wrapper .buttons .button-qr { #tab-send .send-wrapper .buttons .button-qr {
height: 60px; } height: 60px; }
#tab-send .send-wrapper .buttons .button-qr span { #tab-send .send-wrapper .buttons .button-qr span {
font-size: 16px; } font-size: 16px; } }
#tab-send #tab-send-header {
height: 270px; }
#tab-send #tab-send-contacts {
height: calc(100vh - 270px - 50px - 44px);
/* screen size - button container - bottom-tab-menu - header top */ }
#tab-send #tab-send-contacts.ios {
height: calc(100vh - 270px - 50px - 44px - 18px); } }
#wallet-origin-destination .header--request { #wallet-origin-destination .header--request {
padding: 30px 24px; padding: 30px 24px;
@ -15551,31 +15536,28 @@ ion-content.padded-bottom-cta-with-summary {
.fee-summary .amount .fee-crypto { .fee-summary .amount .fee-crypto {
color: #A7A7A7; } color: #A7A7A7; }
.amount .start, .formatted-amount {
.amount .middle,
.amount .end,
.amount .currency {
display: inline-block; } display: inline-block; }
.formatted-amount .start,
.amount .start { .formatted-amount .middle,
font-size: 1em; } .formatted-amount .end,
.formatted-amount .currency {
.amount .middle { display: inline-block; }
font-size: 0.7857em; .formatted-amount .start {
margin-left: 5px; } font-size: 1em; }
.formatted-amount .middle {
.amount .end { font-size: 0.7857em;
font-size: 0.7857em; margin-left: 5px; }
margin-left: 5px; } .formatted-amount .end {
font-size: 0.7857em;
.amount.size-equal .middle, margin-left: 5px; }
.amount.size-equal .end { .formatted-amount.size-equal .middle,
font-size: 1em; } .formatted-amount.size-equal .end {
font-size: 1em; }
.amount .currency { .formatted-amount .currency {
font-size: 1em; font-size: 1em;
margin-left: 5px; margin-left: 5px;
text-transform: uppercase; } text-transform: uppercase; }
/* This is for rules that don't yet have a home. /* This is for rules that don't yet have a home.
* Our goal is to delete this file. Search the regex: /class=".*CLASS.*?"/ * Our goal is to delete this file. Search the regex: /class=".*CLASS.*?"/

View file

@ -3,8 +3,7 @@
<ion-nav-title> <ion-nav-title>
{{'Review Transaction' | translate}} {{'Review Transaction' | translate}}
</ion-nav-title> </ion-nav-title>
<ion-nav-back-button> <ion-nav-back-button ng-click="vm.goBack()"></ion-nav-back-button>
</ion-nav-back-button>
</ion-nav-bar> </ion-nav-bar>
<ion-content class="padded-bottom-cta-with-summary bg-neutral"> <ion-content class="padded-bottom-cta-with-summary bg-neutral">

View file

@ -34,7 +34,7 @@
<span translate>Buy Bitcoin</span> <span translate>Buy Bitcoin</span>
</div> </div>
<div class="button button-outline button-grey-outline" ng-class="{'ng-hide': !walletsWithFunds.length}" <div class="button button-outline button-grey-outline" ng-class="{'ng-hide': !walletsWithFunds.length}"
ui-sref="tabs.send"> ng-click="startFreshSend()">
<span translate>Send</span> <span translate>Send</span>
</div> </div>
</div> </div>

View file

@ -4,6 +4,25 @@
</ion-nav-bar> </ion-nav-bar>
<ion-content> <ion-content>
<div id="tab-send-header" ng-if="hasFunds"> <div id="tab-send-header" ng-if="hasFunds">
<div class="content-frame" ng-if="fromWallet">
<div class="card card-gutter-compact">
<div class="item item-compact" translate>From:</div>
<div class="item item-gutterless item-complex item-avatar">
<div class="item-content item-content-avatar">
<i class="icon big-icon-svg theme-circle theme-circle-services">
<div class="bg icon-wallet"
style="background-color: {{fromWallet.color}}"
></div>
</i>
<h2>{{fromWallet.name}}</h2>
<!--<p ng-show="vm.origin.balanceAmount">{{vm.origin.balanceAmount}} {{vm.origin.balanceCurrency}}</p>-->
<formatted-amount value="{{fromWallet.status.totalBalanceStr ? fromWallet.status.totalBalanceStr : ( fromWallet.cachedBalance ? fromWallet.cachedBalance + (fromWallet.cachedBalanceUpdatedOn ? ' &middot; ' + ( fromWallet.cachedBalanceUpdatedOn * 1000 | amTimeAgo) : '') : '' ) }}"></formatted-amount>
</div>
</div>
</div>
</div>
<div class="send-wrapper item"> <div class="send-wrapper item">
<div class="row"> <div class="row">
<div class="input" ng-class="{'focus': searchFocus}"> <div class="input" ng-class="{'focus': searchFocus}">
@ -22,7 +41,7 @@
</button> </button>
</div> </div>
<div class="col-60"> <div class="col-60">
<button class="button button-standard button-primary button-outline" ui-sref="tabs.send.wallet-to-wallet"> <button class="button button-standard button-primary button-outline" ng-click="startWalletToWalletTransfer()">
<img src="img/icon-w2w.svg"/><br/> <img src="img/icon-w2w.svg"/><br/>
<span translate>Wallet to Wallet Transfer</span> <span translate>Wallet to Wallet Transfer</span>
</button> </button>

View file

@ -11,7 +11,7 @@
<ion-nav-view name="tab-scan"></ion-nav-view> <ion-nav-view name="tab-scan"></ion-nav-view>
</ion-tab> </ion-tab>
<ion-tab class="track_tab_open" id="tab_open_send" title="{{'Send'|translate}}" icon-off="ico-send" icon-on="ico-send-selected" ui-sref="tabs.send"> <ion-tab class="track_tab_open" id="tab_open_send" title="{{'Send'|translate}}" icon-off="ico-send" icon-on="ico-send-selected" ng-click="startFreshSend()">
<ion-nav-view name="tab-send"></ion-nav-view> <ion-nav-view name="tab-send"></ion-nav-view>
</ion-tab> </ion-tab>