Merge pull request #250 from Bitcoin-com/wallet/task/537
Wallet/task/537
This commit is contained in:
commit
0c15a83782
25 changed files with 416 additions and 195 deletions
|
|
@ -6256,7 +6256,6 @@ var ClickAction = /** @class */ (function (_super) {
|
|||
// Add event listener to all the elements found
|
||||
for (var i = 0; i < elements.length; i++) {
|
||||
var element = elements[i];
|
||||
console.log('init ' + this.name);
|
||||
element.addEventListener('click', this.listener);
|
||||
}
|
||||
};
|
||||
|
|
@ -6413,7 +6412,6 @@ var AdjustChannel = /** @class */ (function (_super) {
|
|||
_this.eventTypes = config.eventTypes;
|
||||
var os = _this.adjustedOs(config.os);
|
||||
_this.advertisingId = _this.getAdvertisingId(os);
|
||||
console.log('Advertising ID for adjust: ' + _this.advertisingId);
|
||||
// TODO: Different initialisation for Cordova.
|
||||
var sessionParams = {
|
||||
app_version: config.appVersion,
|
||||
|
|
@ -6656,7 +6654,7 @@ var MixpanelChannel = /** @class */ (function (_super) {
|
|||
function MixpanelChannel(name, config) {
|
||||
var _this = _super.call(this, name) || this;
|
||||
if (!config.token) {
|
||||
throw new DOMException('[BitAnalytics] Config incorrect.');
|
||||
throw new Error('[BitAnalytics] Config incorrect.');
|
||||
}
|
||||
_this.mixpanelInstance = mixpanel;
|
||||
mixpanel.init(config.token, config.config);
|
||||
|
|
@ -7037,7 +7035,7 @@ var LogEventHandlers = /** @class */ (function () {
|
|||
_this.channels.push(channel);
|
||||
}
|
||||
catch (error) {
|
||||
console.log('[BitAnalytics] ' + error.name + ': ' + error.message);
|
||||
console.log(error.message);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
'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 defaults = configService.getDefaults();
|
||||
|
|
@ -22,6 +22,7 @@ angular.module('copayApp.controllers').controller('addressbookViewController', f
|
|||
|
||||
$scope.sendTo = function() {
|
||||
$ionicHistory.removeBackView();
|
||||
sendFlowService.clear();
|
||||
$state.go('tabs.send');
|
||||
$timeout(function() {
|
||||
var to = '';
|
||||
|
|
@ -31,12 +32,16 @@ angular.module('copayApp.controllers').controller('addressbookViewController', f
|
|||
} else {
|
||||
to = $scope.addressbookEntry.address;
|
||||
}
|
||||
$state.transitionTo('tabs.send.amount', {
|
||||
|
||||
var stateParams = {
|
||||
toAddress: to,
|
||||
toName: $scope.addressbookEntry.name,
|
||||
toEmail: $scope.addressbookEntry.email,
|
||||
coin: $scope.addressbookEntry.coin
|
||||
});
|
||||
};
|
||||
|
||||
sendFlowService.pushState(stateParams);
|
||||
$state.transitionTo('tabs.send.origin');
|
||||
}, 100);
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
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;
|
||||
|
||||
vm.allowSend = false;
|
||||
|
|
@ -66,18 +66,23 @@ function amountController(configService, $filter, gettextCatalog, $ionicHistory,
|
|||
}
|
||||
|
||||
function onBeforeEnter(event, data) {
|
||||
console.log('amount onBeforeEnter sendflow ', sendFlowService.getState());
|
||||
|
||||
if (data.direction == "back") {
|
||||
sendFlowService.popState();
|
||||
}
|
||||
|
||||
initCurrencies();
|
||||
|
||||
passthroughParams = data.stateParams;
|
||||
passthroughParams = sendFlowService;
|
||||
|
||||
vm.fromWalletId = data.stateParams.fromWalletId;
|
||||
vm.toWalletId = data.stateParams.toWalletId;
|
||||
vm.minAmount = parseFloat(data.stateParams.minAmount);
|
||||
vm.maxAmount = parseFloat(data.stateParams.maxAmount);
|
||||
vm.fromWalletId = passthroughParams.fromWalletId;
|
||||
vm.toWalletId = passthroughParams.toWalletId;
|
||||
vm.minAmount = parseFloat(passthroughParams.minAmount);
|
||||
vm.maxAmount = parseFloat(passthroughParams.maxAmount);
|
||||
|
||||
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.id === 'shapeshift') {
|
||||
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;
|
||||
|
||||
|
|
@ -177,8 +182,8 @@ function amountController(configService, $filter, gettextCatalog, $ionicHistory,
|
|||
|
||||
// currency have preference
|
||||
var fiatName;
|
||||
if (data.stateParams.currency) {
|
||||
fiatCode = data.stateParams.currency;
|
||||
if (passthroughParams.currency) {
|
||||
fiatCode = passthroughParams.currency;
|
||||
altUnitIndex = unitIndex
|
||||
unitIndex = availableUnits.length;
|
||||
} else {
|
||||
|
|
@ -205,20 +210,11 @@ function amountController(configService, $filter, gettextCatalog, $ionicHistory,
|
|||
var fromWallet = profileService.getWallet(passthroughParams.fromWalletId);
|
||||
updateAvailableFundsFromWallet(fromWallet);
|
||||
}
|
||||
};
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
function goBack() {
|
||||
if (vm.thirdParty && vm.thirdParty.id === 'shapeshift') {
|
||||
$state.go('tabs.send').then(function() {
|
||||
$ionicHistory.clearHistory();
|
||||
$state.go('tabs.home').then(function() {
|
||||
$state.transitionTo('tabs.shapeshift');
|
||||
});
|
||||
});
|
||||
} else {
|
||||
$ionicHistory.goBack();
|
||||
}
|
||||
$ionicHistory.goBack();
|
||||
}
|
||||
|
||||
function paste(value) {
|
||||
|
|
@ -227,18 +223,18 @@ function amountController(configService, $filter, gettextCatalog, $ionicHistory,
|
|||
$timeout(function() {
|
||||
$scope.$apply();
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
function processClipboard() {
|
||||
if (!isNW) return;
|
||||
var value = nodeWebkitService.readFromClipboard();
|
||||
if (value && evaluate(value) > 0) paste(evaluate(value));
|
||||
};
|
||||
}
|
||||
|
||||
function sendMax() {
|
||||
useSendMax = true;
|
||||
finish();
|
||||
};
|
||||
}
|
||||
|
||||
function updateUnitUI() {
|
||||
vm.unit = availableUnits[unitIndex].shortName;
|
||||
|
|
@ -246,7 +242,7 @@ function amountController(configService, $filter, gettextCatalog, $ionicHistory,
|
|||
|
||||
processAmount();
|
||||
$log.debug('Update unit coin @amount unit:' + vm.unit + " alternativeUnit:" + vm.alternativeUnit);
|
||||
};
|
||||
}
|
||||
|
||||
function changeUnit() {
|
||||
|
||||
|
|
@ -267,7 +263,7 @@ function amountController(configService, $filter, gettextCatalog, $ionicHistory,
|
|||
|
||||
updateAvailableFundsStringIfNeeded();
|
||||
updateUnitUI();
|
||||
};
|
||||
}
|
||||
|
||||
function pushDigit(digit) {
|
||||
if (vm.amount && digit != '.') {
|
||||
|
|
@ -291,7 +287,7 @@ function amountController(configService, $filter, gettextCatalog, $ionicHistory,
|
|||
|
||||
vm.amount = (vm.amount + digit).replace('..', '.');
|
||||
processAmount();
|
||||
};
|
||||
}
|
||||
|
||||
function pushOperator(operator) {
|
||||
if (!vm.amount || vm.amount.length == 0) return;
|
||||
|
|
@ -303,18 +299,18 @@ function amountController(configService, $filter, gettextCatalog, $ionicHistory,
|
|||
} else {
|
||||
return val.slice(0, -1) + operator;
|
||||
}
|
||||
};
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
function isOperator(val) {
|
||||
var regex = /[\/\-\+\x\*]/;
|
||||
return regex.test(val);
|
||||
};
|
||||
}
|
||||
|
||||
function isExpression(val) {
|
||||
var regex = /^\.?\d+(\.?\d+)?([\/\-\+\*x]\d?\.?\d+)+$/;
|
||||
return regex.test(val);
|
||||
};
|
||||
}
|
||||
|
||||
function removeDigit() {
|
||||
vm.amount = (vm.amount).toString().slice(0, -1);
|
||||
|
|
@ -339,7 +335,7 @@ function amountController(configService, $filter, gettextCatalog, $ionicHistory,
|
|||
function close() {
|
||||
altCurrencyModal.remove();
|
||||
altCurrencyModal = null;
|
||||
};
|
||||
}
|
||||
|
||||
function processAmount() {
|
||||
var formatedValue = format(vm.amount);
|
||||
|
|
@ -409,22 +405,22 @@ function amountController(configService, $filter, gettextCatalog, $ionicHistory,
|
|||
} else {
|
||||
vm.errorMessage = '';
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
function processResult(val) {
|
||||
if (availableUnits[unitIndex].isFiat) return $filter('formatFiatAmount')(val);
|
||||
else return txFormatService.formatAmount(val.toFixed(unitDecimals) * unitToSatoshi, true);
|
||||
};
|
||||
}
|
||||
|
||||
function fromFiat(val) {
|
||||
return parseFloat((rateService.fromFiat(val, fiatCode, availableUnits[altUnitIndex].id) * satToUnit).toFixed(unitDecimals));
|
||||
};
|
||||
}
|
||||
|
||||
function toFiat(val) {
|
||||
if (!rateService.getRate(fiatCode)) return;
|
||||
|
||||
return parseFloat((rateService.toFiat(val * unitToSatoshi, fiatCode, availableUnits[unitIndex].id)).toFixed(2));
|
||||
};
|
||||
}
|
||||
|
||||
function evaluate(val) {
|
||||
var result;
|
||||
|
|
@ -435,7 +431,7 @@ function amountController(configService, $filter, gettextCatalog, $ionicHistory,
|
|||
}
|
||||
if (!lodash.isFinite(result)) return 0;
|
||||
return result;
|
||||
};
|
||||
}
|
||||
|
||||
function format(val) {
|
||||
if (!val) return;
|
||||
|
|
@ -445,7 +441,7 @@ function amountController(configService, $filter, gettextCatalog, $ionicHistory,
|
|||
if (isOperator(lodash.last(val))) result = result.slice(0, -1);
|
||||
|
||||
return result.replace('x', '*');
|
||||
};
|
||||
}
|
||||
|
||||
function finish() {
|
||||
var unit = availableUnits[unitIndex];
|
||||
|
|
@ -467,16 +463,17 @@ function amountController(configService, $filter, gettextCatalog, $ionicHistory,
|
|||
};
|
||||
|
||||
if (vm.thirdParty) {
|
||||
confirmData['thirdParty'] = JSON.stringify(this.thirdParty);
|
||||
confirmData['thirdParty'] = this.thirdParty;
|
||||
}
|
||||
|
||||
sendFlowService.pushState(confirmData);
|
||||
if (!confirmData.fromWalletId) {
|
||||
$state.transitionTo('tabs.paymentRequest.confirm', confirmData);
|
||||
} else {
|
||||
$state.transitionTo('tabs.send.review', confirmData);
|
||||
$scope.useSendMax = null;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
// Currency
|
||||
|
|
@ -495,7 +492,7 @@ function amountController(configService, $filter, gettextCatalog, $ionicHistory,
|
|||
{isoCode: 'CNY', order: 7},
|
||||
{isoCode: 'KRW', order: 8},
|
||||
{isoCode: 'HKD', order: 9},
|
||||
]
|
||||
];
|
||||
|
||||
function initCurrencies() {
|
||||
var unusedCurrencyList = [{
|
||||
|
|
@ -558,7 +555,7 @@ function amountController(configService, $filter, gettextCatalog, $ionicHistory,
|
|||
$timeout(function() {
|
||||
$scope.$apply();
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
function save(newAltCurrency) {
|
||||
var opts = {
|
||||
|
|
@ -584,7 +581,7 @@ function amountController(configService, $filter, gettextCatalog, $ionicHistory,
|
|||
updateUnitUI();
|
||||
close();
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
function updateAvailableFundsStringIfNeeded() {
|
||||
if (passthroughParams.fromWalletId && availableSatoshis !== null) {
|
||||
|
|
@ -639,5 +636,4 @@ function amountController(configService, $filter, gettextCatalog, $ionicHistory,
|
|||
vm.availableFunds = availableFundsInCrypto;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
'use strict';
|
||||
|
||||
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') {
|
||||
$scope.onboarding = true;
|
||||
|
|
@ -89,7 +89,8 @@ angular.module('copayApp.controllers').controller('backupController',
|
|||
$scope.setFlow(2);
|
||||
})
|
||||
} else {
|
||||
firebaseEventsService.logEvent('backed_up_wallet');
|
||||
|
||||
//firebaseEventsService.logEvent('backed_up_wallet');
|
||||
openConfirmBackupModal();
|
||||
}
|
||||
};
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
'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 FEE_TOO_HIGH_LIMIT_PER = 15;
|
||||
|
|
@ -708,8 +708,6 @@ angular.module('copayApp.controllers').controller('confirmController', function(
|
|||
}], [channel, "adjust"]);
|
||||
window.BitAnalytics.LogEventHandlers.postEvent(log);
|
||||
|
||||
// Should be removed
|
||||
firebaseEventsService.logEvent('sent_bitcoin', { coin: $scope.wallet.coin });
|
||||
$timeout(function() {
|
||||
$scope.$digest();
|
||||
}, 100);
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
'use strict';
|
||||
|
||||
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 */
|
||||
var COPAYER_PAIR_LIMITS = {
|
||||
|
|
@ -268,7 +268,7 @@ angular.module('copayApp.controllers').controller('createController',
|
|||
}, 100);
|
||||
}
|
||||
else {
|
||||
firebaseEventsService.logEvent('wallet_created', { coin: opts.coin });
|
||||
//firebaseEventsService.logEvent('wallet_created', { coin: opts.coin });
|
||||
$state.go('tabs.home');
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ angular
|
|||
.module('copayApp.controllers')
|
||||
.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;
|
||||
|
||||
vm.buttonText = '';
|
||||
|
|
@ -49,9 +49,10 @@ function reviewController(addressbookService, bitcoinCashJsService, bitcore, bit
|
|||
vm.memoExpanded = false;
|
||||
|
||||
// Functions
|
||||
vm.goBack = goBack;
|
||||
vm.onSuccessConfirm = onSuccessConfirm;
|
||||
|
||||
|
||||
var sendFlowData;
|
||||
var config = null;
|
||||
var countDown = null;
|
||||
var defaults = {};
|
||||
|
|
@ -74,22 +75,22 @@ function reviewController(addressbookService, bitcoinCashJsService, bitcore, bit
|
|||
|
||||
|
||||
function onBeforeEnter(event, data) {
|
||||
console.log('walletSelector onBeforeEnter sendflow ', sendFlowService.getState());
|
||||
defaults = configService.getDefaults();
|
||||
originWalletId = data.stateParams.fromWalletId;
|
||||
satoshis = parseInt(data.stateParams.amount, 10);
|
||||
toAddress = data.stateParams.toAddress;
|
||||
destinationWalletId = data.stateParams.toWalletId;
|
||||
sendFlowData = sendFlowService.getState();
|
||||
originWalletId = sendFlowData.fromWalletId;
|
||||
satoshis = parseInt(sendFlowData.amount, 10);
|
||||
toAddress = sendFlowData.toAddress;
|
||||
destinationWalletId = sendFlowData.toWalletId;
|
||||
|
||||
vm.originWallet = profileService.getWallet(originWalletId);
|
||||
vm.origin.currency = vm.originWallet.coin.toUpperCase();
|
||||
coin = vm.originWallet.coin;
|
||||
|
||||
if (data.stateParams.thirdParty) {
|
||||
vm.thirdParty = JSON.parse(data.stateParams.thirdParty); // Parse stringified JSON-object
|
||||
if (vm.thirdParty) {
|
||||
handleThirdPartyInitIfBip70();
|
||||
handleThirdPartyInitIfShapeshift();
|
||||
}
|
||||
if (sendFlowData.thirdParty) {
|
||||
vm.thirdParty = sendFlowData.thirdParty;
|
||||
handleThirdPartyInitIfBip70();
|
||||
handleThirdPartyInitIfShapeshift();
|
||||
}
|
||||
|
||||
configService.get(function onConfig(err, configCache) {
|
||||
|
|
@ -105,7 +106,7 @@ function reviewController(addressbookService, bitcoinCashJsService, bitcore, bit
|
|||
updateSendAmounts();
|
||||
getOriginWalletBalance(vm.originWallet);
|
||||
handleDestinationAsAddress(toAddress, coin);
|
||||
handleDestinationAsWallet(data.stateParams.toWalletId);
|
||||
handleDestinationAsWallet(sendFlowData.toWalletId);
|
||||
createVanityTransaction(data);
|
||||
});
|
||||
}
|
||||
|
|
@ -221,10 +222,10 @@ function reviewController(addressbookService, bitcoinCashJsService, bitcore, bit
|
|||
|
||||
// Grab stateParams
|
||||
tx = {
|
||||
amount: parseInt(data.stateParams.amount),
|
||||
sendMax: data.stateParams.sendMax === 'true' ? true : false,
|
||||
fromWalletId: data.stateParams.fromWalletId,
|
||||
toAddress: data.stateParams.toAddress,
|
||||
amount: parseInt(sendFlowData.amount),
|
||||
sendMax: sendFlowData.sendMax === 'true' ? true : false,
|
||||
fromWalletId: sendFlowData.fromWalletId,
|
||||
toAddress: sendFlowData.toAddress,
|
||||
paypro: txPayproData,
|
||||
|
||||
feeLevel: configFeeLevel,
|
||||
|
|
@ -241,7 +242,6 @@ function reviewController(addressbookService, bitcoinCashJsService, bitcore, bit
|
|||
};
|
||||
|
||||
|
||||
|
||||
if (data.stateParams.requiredFeeRate) {
|
||||
vm.usingMerchantFee = true;
|
||||
tx.feeRate = parseInt(data.stateParams.requiredFeeRate);
|
||||
|
|
@ -251,7 +251,7 @@ function reviewController(addressbookService, bitcoinCashJsService, bitcore, bit
|
|||
tx.feeLevel = 'normal';
|
||||
}
|
||||
|
||||
var B = data.stateParams.coin === 'bch' ? bitcoreCash : bitcore;
|
||||
var B = tx.coin === 'bch' ? bitcoreCash : bitcore;
|
||||
var networkName;
|
||||
try {
|
||||
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) {
|
||||
if (!address) {
|
||||
return;
|
||||
|
|
@ -403,16 +407,20 @@ function reviewController(addressbookService, bitcoinCashJsService, bitcore, bit
|
|||
// Check if the recipient is a contact
|
||||
addressbookService.get(originCoin + address, function(err, contact) {
|
||||
if (!err && contact) {
|
||||
handleDestinationAsContact(contact);
|
||||
handleDestinationAsAddressOfContact(contact);
|
||||
} else {
|
||||
vm.destination.address = address;
|
||||
if (originCoin === 'bch') {
|
||||
vm.destination.address = bitcoinCashJsService.readAddress(address).cashaddr;
|
||||
} else {
|
||||
vm.destination.address = address;
|
||||
}
|
||||
vm.destination.kind = 'address';
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
function handleDestinationAsContact(contact) {
|
||||
function handleDestinationAsAddressOfContact(contact) {
|
||||
vm.destination.kind = 'contact';
|
||||
vm.destination.name = contact.name;
|
||||
vm.destination.email = contact.email;
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
'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 walletsBch = [];
|
||||
|
||||
|
|
@ -63,15 +63,20 @@ angular.module('copayApp.controllers').controller('shapeshiftController', functi
|
|||
};
|
||||
|
||||
$scope.shapeshift = function() {
|
||||
var params = {
|
||||
thirdParty: JSON.stringify({id: 'shapeshift'})
|
||||
var stateParams = {
|
||||
thirdParty: {
|
||||
id: 'shapeshift'
|
||||
}
|
||||
};
|
||||
|
||||
// Starting new send flow, so ensure everything is reset
|
||||
sendFlowService.clear();
|
||||
$state.go('tabs.home').then(function() {
|
||||
$ionicHistory.clearHistory();
|
||||
$state.go('tabs.send').then(function() {
|
||||
$timeout(function () {
|
||||
$state.transitionTo('tabs.send.origin', params);
|
||||
sendFlowService.pushState(stateParams);
|
||||
$state.transitionTo('tabs.send.origin');
|
||||
}, 60);
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
'use strict';
|
||||
|
||||
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 listeners = [];
|
||||
var notifications = [];
|
||||
|
|
@ -20,7 +20,12 @@ angular.module('copayApp.controllers').controller('tabHomeController',
|
|||
$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();
|
||||
|
||||
bannerService.getBanner(function (banner) {
|
||||
|
|
@ -28,9 +33,10 @@ angular.module('copayApp.controllers').controller('tabHomeController',
|
|||
$scope.bannerUrl = banner.url;
|
||||
$scope.bannerIsLoading = false;
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
function onBeforeEnter (event, data) {
|
||||
|
||||
$scope.$on("$ionicView.beforeEnter", function(event, data) {
|
||||
if (!$scope.homeTip) {
|
||||
storageService.getHomeTipAccepted(function(error, value) {
|
||||
$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);
|
||||
updateAllWallets();
|
||||
|
||||
|
|
@ -97,26 +103,29 @@ angular.module('copayApp.controllers').controller('tabHomeController',
|
|||
}
|
||||
|
||||
$scope.showServices = true;
|
||||
pushNotificationsService.init();
|
||||
firebaseEventsService.init();
|
||||
|
||||
$timeout(function() {
|
||||
$ionicScrollDelegate.resize();
|
||||
$scope.$apply();
|
||||
}, 10);
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
$scope.$on("$ionicView.leave", function(event, data) {
|
||||
function onLeave (event, data) {
|
||||
lodash.each(listeners, function(x) {
|
||||
x();
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
$scope.createdWithinPastDay = function(time) {
|
||||
return timeService.withinPastDay(time);
|
||||
};
|
||||
|
||||
$scope.startFreshSend = function() {
|
||||
sendFlowService.clear();
|
||||
$state.go('tabs.send');
|
||||
}
|
||||
|
||||
$scope.openExternalLink = function() {
|
||||
var url = 'https://github.com/Bitcoin-com/Wallet/releases/latest';
|
||||
var optIn = true;
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
'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 clipboardHasContent = false;
|
||||
var originalList;
|
||||
|
|
@ -33,6 +33,9 @@ angular.module('copayApp.controllers').controller('tabSendController', function(
|
|||
text = text.substring(0, 200);
|
||||
}
|
||||
|
||||
var stateParams = sendFlowService.getState();
|
||||
$scope.fromWallet = profileService.getWallet(stateParams.fromWalletId);
|
||||
|
||||
$scope.clipboardHasAddress = 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
|
||||
|
|
@ -179,14 +182,30 @@ angular.module('copayApp.controllers').controller('tabSendController', function(
|
|||
}
|
||||
|
||||
$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
|
||||
$scope.createWallet = 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) {
|
||||
console.log(data);
|
||||
console.log('tab-send onBeforeEnter sendflow ', sendFlowService.getState());
|
||||
$scope.isIOS = platformInfo.isIOS && platformInfo.isCordova;
|
||||
$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';
|
||||
});
|
||||
|
||||
if (data.direction == "back") {
|
||||
sendFlowService.clear();
|
||||
}
|
||||
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
'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) {
|
||||
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.fromOnboarding = $stateParams.fromOnboarding;
|
||||
$timeout(function() {
|
||||
|
|
@ -23,7 +28,7 @@ angular.module('copayApp.controllers').controller('tabsController', function($ro
|
|||
};
|
||||
|
||||
$scope.chooseScanner = function() {
|
||||
|
||||
sendFlowService.clear();
|
||||
var isWindowsPhoneApp = platformInfo.isCordova && platformInfo.isWP;
|
||||
|
||||
if (!isWindowsPhoneApp) {
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
'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 currentTxHistoryPage = 0;
|
||||
|
|
@ -374,6 +374,7 @@ angular.module('copayApp.controllers').controller('walletDetailsController', fun
|
|||
});
|
||||
|
||||
$scope.$on("$ionicView.beforeEnter", function(event, data) {
|
||||
sendFlowService.clear();
|
||||
|
||||
configService.whenAvailable(function (config) {
|
||||
$scope.selectedPriceDisplay = config.wallet.settings.priceDisplay;
|
||||
|
|
@ -470,13 +471,18 @@ angular.module('copayApp.controllers').controller('walletDetailsController', fun
|
|||
function rgbToHex(r, g, b) {
|
||||
return "#" + componentToHex(r) + componentToHex(g) + componentToHex(b);
|
||||
}
|
||||
|
||||
$scope.goToSend = function() {
|
||||
$state.go('tabs.home', {
|
||||
walletId: $scope.wallet.id
|
||||
}).then(function () {
|
||||
sendFlowService.startSend({
|
||||
fromWalletId: $scope.wallet.id
|
||||
});
|
||||
|
||||
// Go home first so that the Home tab works properly
|
||||
$state.go('tabs.home').then(function () {
|
||||
$ionicHistory.clearHistory();
|
||||
$state.go('tabs.send');
|
||||
});
|
||||
|
||||
};
|
||||
$scope.goToReceive = function() {
|
||||
$state.go('tabs.home', {
|
||||
|
|
@ -488,6 +494,7 @@ angular.module('copayApp.controllers').controller('walletDetailsController', fun
|
|||
});
|
||||
});
|
||||
};
|
||||
|
||||
$scope.goToBuy = function() {
|
||||
$state.go('tabs.home', {
|
||||
walletId: $scope.wallet.id
|
||||
|
|
|
|||
|
|
@ -1,13 +1,24 @@
|
|||
'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 priceDisplayAsFiat = false;
|
||||
var unitDecimals = 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;
|
||||
priceDisplayAsFiat = config.priceDisplay === 'fiat';
|
||||
unitDecimals = config.unitDecimals;
|
||||
|
|
@ -18,7 +29,7 @@ angular.module('copayApp.controllers').controller('walletSelectorController', fu
|
|||
$scope.sendFlowTitle = gettextCatalog.getString('Wallet to Wallet Transfer');
|
||||
break;
|
||||
case 'tabs.send.destination':
|
||||
if (data.stateParams.fromWalletId) {
|
||||
if (stateParams.fromWalletId) {
|
||||
$scope.sendFlowTitle = gettextCatalog.getString('Wallet to Wallet Transfer');
|
||||
}
|
||||
break;
|
||||
|
|
@ -26,10 +37,14 @@ angular.module('copayApp.controllers').controller('walletSelectorController', fu
|
|||
// nop
|
||||
}
|
||||
|
||||
$scope.params = $state.params;
|
||||
$scope.params = sendFlowService;
|
||||
$scope.coin = false; // Wallets to show (for destination screen or contacts)
|
||||
$scope.type = data.stateParams && data.stateParams['fromWalletId'] ? 'destination' : 'origin'; // origin || destination
|
||||
fromWalletId = data.stateParams && data.stateParams.fromWalletId;
|
||||
$scope.type = $scope.params['fromWalletId'] ? 'destination' : 'origin'; // origin || destination
|
||||
fromWalletId = $scope.params['fromWalletId'];
|
||||
|
||||
if ($scope.type === 'destination' && $scope.params.toAddress) {
|
||||
$state.transitionTo(getNextStep());
|
||||
}
|
||||
|
||||
if ($scope.params.coin) {
|
||||
$scope.coin = $scope.params.coin; // Contacts have a coin embedded
|
||||
|
|
@ -41,11 +56,11 @@ angular.module('copayApp.controllers').controller('walletSelectorController', fu
|
|||
$scope.isPaymentRequest = true;
|
||||
}
|
||||
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) {
|
||||
$scope.selectedPriceDisplay = config.wallet.settings.priceDisplay;
|
||||
});
|
||||
|
|
@ -57,7 +72,7 @@ angular.module('copayApp.controllers').controller('walletSelectorController', fu
|
|||
|
||||
prepareWalletLists();
|
||||
formatRequestedAmount();
|
||||
});
|
||||
};
|
||||
|
||||
function formatRequestedAmount() {
|
||||
if ($scope.params.amount) {
|
||||
|
|
@ -90,7 +105,7 @@ angular.module('copayApp.controllers').controller('walletSelectorController', fu
|
|||
|
||||
function getNextStep() {
|
||||
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
|
||||
return 'tabs.send.destination';
|
||||
|
|
@ -178,11 +193,13 @@ angular.module('copayApp.controllers').controller('walletSelectorController', fu
|
|||
|
||||
|
||||
$scope.useWallet = function(wallet) {
|
||||
var params = sendFlowService.getState();
|
||||
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
|
||||
$scope.params['toWalletId'] = wallet.id;
|
||||
params.toWalletId = wallet.id;
|
||||
}
|
||||
sendFlowService.pushState(params);
|
||||
$state.transitionTo(getNextStep(), $scope.params);
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -32,11 +32,16 @@ angular.module('bitcoincom.directives')
|
|||
'3': ['BHD', 'IQD', 'JOD', 'KWD', 'OMR', 'TND'],
|
||||
'8': ['BCH', 'BTC']
|
||||
};
|
||||
var localizeNumbers = function(x, minimumFractionDigits = 0, useGrouping = true) {
|
||||
return parseFloat(x).toLocaleString(uxLanguage.getCurrentLanguage(), {
|
||||
var localizeNumbers = function(x, minimumFractionDigits) {
|
||||
var parsed = parseFloat(x);
|
||||
var opts = {
|
||||
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) {
|
||||
|
|
@ -61,7 +66,6 @@ angular.module('bitcoincom.directives')
|
|||
};
|
||||
|
||||
var formatNumbers = function() {
|
||||
|
||||
// During watch, may be changed from having a separate currency value,
|
||||
// to both being in value. Don't want to use previous currency value.
|
||||
// Try to extract currency from value..
|
||||
|
|
@ -69,6 +73,7 @@ angular.module('bitcoincom.directives')
|
|||
if (currencySplit.length === 2) {
|
||||
$scope.currency = currencySplit[1];
|
||||
}
|
||||
$scope.currency = $scope.currency || '';
|
||||
|
||||
|
||||
var parsed = parseFloat($scope.value);
|
||||
|
|
@ -79,7 +84,7 @@ angular.module('bitcoincom.directives')
|
|||
if (isNaN(parsed)) {
|
||||
buildAmount('-', '', '');
|
||||
} else {
|
||||
valueFormatted = localizeNumbers(Math.round(parsed));
|
||||
valueFormatted = localizeNumbers(Math.round(parsed), 0);
|
||||
buildAmount(valueFormatted, '', '');
|
||||
}
|
||||
break;
|
||||
|
|
@ -127,6 +132,44 @@ angular.module('bitcoincom.directives')
|
|||
$scope.$watchGroup(['currency', 'value'], function onFormattedAmountWatch() {
|
||||
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;
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
|
|
|
|||
|
|
@ -287,7 +287,7 @@ angular.module('copayApp').config(function(historicLogProvider, $provide, $logPr
|
|||
*/
|
||||
|
||||
.state('tabs.send.amount', {
|
||||
url: '/amount/:thirdParty/:fromWalletId/:maxAmount/:minAmount/:toWalletId/:toAddress',
|
||||
url: '/amount',
|
||||
views: {
|
||||
'tab-send@tabs': {
|
||||
controller: 'amountController',
|
||||
|
|
@ -306,7 +306,7 @@ angular.module('copayApp').config(function(historicLogProvider, $provide, $logPr
|
|||
}
|
||||
})
|
||||
.state('tabs.send.origin', {
|
||||
url: '/origin/:thirdParty/:amount/:toAddress/:toWalletId/:coin',
|
||||
url: '/origin',
|
||||
views: {
|
||||
'tab-send@tabs': {
|
||||
controller: 'walletSelectorController',
|
||||
|
|
@ -315,7 +315,7 @@ angular.module('copayApp').config(function(historicLogProvider, $provide, $logPr
|
|||
}
|
||||
})
|
||||
.state('tabs.send.destination', {
|
||||
url: '/destination/:thirdParty/:amount/:fromWalletId',
|
||||
url: '/destination',
|
||||
views: {
|
||||
'tab-send@tabs': {
|
||||
controller: 'walletSelectorController',
|
||||
|
|
@ -324,7 +324,7 @@ angular.module('copayApp').config(function(historicLogProvider, $provide, $logPr
|
|||
}
|
||||
})
|
||||
.state('tabs.send.confirm', {
|
||||
url: '/confirm/:thirdParty/:amount/:fromWalletId/:toWalletId/:toAddress',
|
||||
url: '/confirm',
|
||||
views: {
|
||||
'tab-send@tabs': {
|
||||
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() {
|
||||
|
||||
|
|
@ -1231,6 +1231,11 @@ angular.module('copayApp').config(function(historicLogProvider, $provide, $logPr
|
|||
}
|
||||
});
|
||||
|
||||
configService.whenAvailable(function(config) {
|
||||
pushNotificationsService.init();
|
||||
});
|
||||
//firebaseEventsService.init();
|
||||
|
||||
var channel = "ga";
|
||||
if (platformInfo.isCordova) {
|
||||
channel = "firebase";
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ angular.module('copayApp.services').factory('clipboardService', function ($http,
|
|||
nodeWebkitService.writeToClipboard(data);
|
||||
} else if (navigator && 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..");
|
||||
});
|
||||
} else if (clipboard.supported) {
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
'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 useEvents = platformInfo.isCordova && !platformInfo.isWP;
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
'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 = {};
|
||||
|
||||
|
|
@ -82,7 +82,7 @@ angular.module('copayApp.services').factory('incomingData', function($log, $stat
|
|||
});
|
||||
// Timeout is required to enable the "Back" button
|
||||
$timeout(function() {
|
||||
var params = {};
|
||||
var params = sendFlowService.getState();
|
||||
|
||||
if (amount) {
|
||||
params.amount = amount;
|
||||
|
|
@ -105,10 +105,11 @@ angular.module('copayApp.services').factory('incomingData', function($log, $stat
|
|||
params.thirdParty = [];
|
||||
params.thirdParty.id = serviceId;
|
||||
params.thirdParty.data = serviceData;
|
||||
params.thirdParty = JSON.stringify(params.thirdParty);
|
||||
$state.transitionTo('tabs.send.amount', params);
|
||||
sendFlowService.pushState(params);
|
||||
$state.transitionTo('tabs.send.amount');
|
||||
} else {
|
||||
$state.transitionTo('tabs.send.origin', params);
|
||||
sendFlowService.pushState(params);
|
||||
$state.transitionTo('tabs.send.origin');
|
||||
}
|
||||
}, 100);
|
||||
}
|
||||
|
|
@ -387,11 +388,13 @@ angular.module('copayApp.services').factory('incomingData', function($log, $stat
|
|||
'notify': $state.current.name == 'tabs.send' ? false : true
|
||||
});
|
||||
$timeout(function() {
|
||||
$state.transitionTo('tabs.send.origin', {
|
||||
var stateParams = {
|
||||
toAddress: toAddress,
|
||||
coin: coin,
|
||||
noPrefix: 1
|
||||
});
|
||||
};
|
||||
sendFlowService.pushState(stateParams);
|
||||
$state.transitionTo('tabs.send.origin');
|
||||
}, 100);
|
||||
}
|
||||
|
||||
|
|
@ -458,7 +461,8 @@ angular.module('copayApp.services').factory('incomingData', function($log, $stat
|
|||
'notify': $state.current.name == 'tabs.send' ? false : true
|
||||
}).then(function() {
|
||||
$timeout(function() {
|
||||
$state.transitionTo('tabs.send.origin', stateParams);
|
||||
sendFlowService.pushState(stateParams); // Need to do more here
|
||||
$state.transitionTo('tabs.send.origin');
|
||||
});
|
||||
});
|
||||
}
|
||||
|
|
|
|||
95
src/js/services/sendFlowService.js
Normal file
95
src/js/services/sendFlowService.js
Normal 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);
|
||||
};
|
||||
};
|
||||
|
||||
})();
|
||||
|
|
@ -2,15 +2,15 @@
|
|||
@extend .deflash-blue;
|
||||
|
||||
&-header{
|
||||
height: 300px;
|
||||
//height: 300px;
|
||||
width: 100%;
|
||||
}
|
||||
&-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 {
|
||||
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 {
|
||||
|
|
@ -223,12 +223,12 @@
|
|||
}
|
||||
}
|
||||
#tab-send-header {
|
||||
height: 270px;
|
||||
//height: 270px;
|
||||
}
|
||||
#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 {
|
||||
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
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11168,16 +11168,8 @@ qrcode {
|
|||
background-color: #fab915 !important; }
|
||||
|
||||
#tab-send-header {
|
||||
height: 300px;
|
||||
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 {
|
||||
width: 100%; }
|
||||
#tab-send .input input {
|
||||
|
|
@ -11358,14 +11350,7 @@ qrcode {
|
|||
#tab-send .send-wrapper .buttons .button-qr {
|
||||
height: 60px; }
|
||||
#tab-send .send-wrapper .buttons .button-qr span {
|
||||
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); } }
|
||||
font-size: 16px; } }
|
||||
|
||||
#wallet-origin-destination .header--request {
|
||||
padding: 30px 24px;
|
||||
|
|
@ -15551,31 +15536,28 @@ ion-content.padded-bottom-cta-with-summary {
|
|||
.fee-summary .amount .fee-crypto {
|
||||
color: #A7A7A7; }
|
||||
|
||||
.amount .start,
|
||||
.amount .middle,
|
||||
.amount .end,
|
||||
.amount .currency {
|
||||
.formatted-amount {
|
||||
display: inline-block; }
|
||||
|
||||
.amount .start {
|
||||
font-size: 1em; }
|
||||
|
||||
.amount .middle {
|
||||
font-size: 0.7857em;
|
||||
margin-left: 5px; }
|
||||
|
||||
.amount .end {
|
||||
font-size: 0.7857em;
|
||||
margin-left: 5px; }
|
||||
|
||||
.amount.size-equal .middle,
|
||||
.amount.size-equal .end {
|
||||
font-size: 1em; }
|
||||
|
||||
.amount .currency {
|
||||
font-size: 1em;
|
||||
margin-left: 5px;
|
||||
text-transform: uppercase; }
|
||||
.formatted-amount .start,
|
||||
.formatted-amount .middle,
|
||||
.formatted-amount .end,
|
||||
.formatted-amount .currency {
|
||||
display: inline-block; }
|
||||
.formatted-amount .start {
|
||||
font-size: 1em; }
|
||||
.formatted-amount .middle {
|
||||
font-size: 0.7857em;
|
||||
margin-left: 5px; }
|
||||
.formatted-amount .end {
|
||||
font-size: 0.7857em;
|
||||
margin-left: 5px; }
|
||||
.formatted-amount.size-equal .middle,
|
||||
.formatted-amount.size-equal .end {
|
||||
font-size: 1em; }
|
||||
.formatted-amount .currency {
|
||||
font-size: 1em;
|
||||
margin-left: 5px;
|
||||
text-transform: uppercase; }
|
||||
|
||||
/* This is for rules that don't yet have a home.
|
||||
* Our goal is to delete this file. Search the regex: /class=".*CLASS.*?"/
|
||||
|
|
|
|||
|
|
@ -3,8 +3,7 @@
|
|||
<ion-nav-title>
|
||||
{{'Review Transaction' | translate}}
|
||||
</ion-nav-title>
|
||||
<ion-nav-back-button>
|
||||
</ion-nav-back-button>
|
||||
<ion-nav-back-button ng-click="vm.goBack()"></ion-nav-back-button>
|
||||
</ion-nav-bar>
|
||||
|
||||
<ion-content class="padded-bottom-cta-with-summary bg-neutral">
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@
|
|||
<span translate>Buy Bitcoin</span>
|
||||
</div>
|
||||
<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>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -4,6 +4,25 @@
|
|||
</ion-nav-bar>
|
||||
<ion-content>
|
||||
<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 ? ' · ' + ( fromWallet.cachedBalanceUpdatedOn * 1000 | amTimeAgo) : '') : '' ) }}"></formatted-amount>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="send-wrapper item">
|
||||
<div class="row">
|
||||
<div class="input" ng-class="{'focus': searchFocus}">
|
||||
|
|
@ -22,7 +41,7 @@
|
|||
</button>
|
||||
</div>
|
||||
<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/>
|
||||
<span translate>Wallet to Wallet Transfer</span>
|
||||
</button>
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@
|
|||
<ion-nav-view name="tab-scan"></ion-nav-view>
|
||||
</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-tab>
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue