This commit is contained in:
Jean-Baptiste Dominguez 2018-08-06 22:17:15 +09:00
commit 59b9167ff0
7 changed files with 47 additions and 29 deletions

View file

@ -470,7 +470,7 @@ function amountController(configService, $filter, gettextCatalog, $ionicHistory,
amount: useSendMax ? undefined : satoshis,
fromWalletId: passthroughParams.fromWalletId,
sendMax: useSendMax,
toAddr: passthroughParams.toAddress,
toAddress: passthroughParams.toAddress,
toWalletId: passthroughParams.toWalletId
};

View file

@ -67,7 +67,7 @@ function reviewController(addressbookService, bitcoinCashJsService, bitcore, bit
defaults = configService.getDefaults();
originWalletId = data.stateParams.fromWalletId;
satoshis = parseInt(data.stateParams.amount, 10);
toAddress = data.stateParams.toAddr;
toAddress = data.stateParams.toAddress;
vm.originWallet = profileService.getWallet(originWalletId);
vm.origin.currency = vm.originWallet.coin.toUpperCase();
@ -105,6 +105,10 @@ function reviewController(addressbookService, bitcoinCashJsService, bitcore, bit
}
vm.approve = function() {
if (vm.thirdParty.id === 'shapeshift') {
shapeshiftService.shiftIt();
return;
}
if (!tx || !vm.originWallet) return;
@ -218,7 +222,7 @@ function reviewController(addressbookService, bitcoinCashJsService, bitcore, bit
amount: parseInt(data.stateParams.amount),
sendMax: data.stateParams.sendMax === 'true' ? true : false,
fromWalletId: data.stateParams.fromWalletId,
toAddress: data.stateParams.toAddr,
toAddress: data.stateParams.toAddress,
feeLevel: configFeeLevel,
spendUnconfirmed: config.wallet.spendUnconfirmed,
@ -594,7 +598,7 @@ function reviewController(addressbookService, bitcoinCashJsService, bitcore, bit
channel = "ga";
}
// When displaying Fiat, if the formatting fails, the crypto will be the primary amount.
var amount = priceDisplayIsFiat ? vm.secondaryAmount || vm.primaryAmount : vm.primaryAmount;
var amount = unitFromSat * satoshis;
var log = new window.BitAnalytics.LogEvent("transfer_success", [{
"coin": vm.originWallet.coin,
"type": "outgoing",
@ -678,7 +682,8 @@ function reviewController(addressbookService, bitcoinCashJsService, bitcore, bit
tx.sendMaxInfo = sendMaxInfo;
tx.amount = tx.sendMaxInfo.amount;
updateAmount();
satoshis = tx.amount;
updateSendAmounts();
ongoingProcess.set('calculatingFee', false);
$timeout(function() {
showSendMaxWarning(wallet, sendMaxInfo);

View file

@ -4,7 +4,6 @@ angular.module('copayApp.controllers').controller('walletSelectorController', fu
var fromWalletId = '';
var priceDisplayAsFiat = false;
var requestedSatoshis = 0;
var unitDecimals = 0;
var unitsFromSatoshis = 0;
@ -39,8 +38,6 @@ angular.module('copayApp.controllers').controller('walletSelectorController', fu
if ($scope.params.amount) { // There is an amount, so presume that it is a payment request
$scope.sendFlowTitle = gettextCatalog.getString('Payment Request');
$scope.specificAmount = $scope.specificAlternativeAmount = '';
//requestedAmountCrypto = (($state.params.amount) * (1 / config.unitToSatoshi)).toFixed(config.unitDecimals);
requestedSatoshis = $state.params.amount;
$scope.isPaymentRequest = true;
}
if ($scope.params.thirdParty) {
@ -55,7 +52,6 @@ angular.module('copayApp.controllers').controller('walletSelectorController', fu
if ($scope.thirdParty) {
// Third party services specific logic
handleThirdPartyIfBip70PaymentProtocol();
handleThirdPartyIfShapeshift();
}
@ -64,11 +60,11 @@ angular.module('copayApp.controllers').controller('walletSelectorController', fu
});
function formatRequestedAmount() {
if (requestedSatoshis) {
var cryptoAmount = (unitsFromSatoshis * requestedSatoshis).toFixed(unitDecimals);
if ($scope.params.amount) {
var cryptoAmount = (unitsFromSatoshis * $scope.params.amount).toFixed(unitDecimals);
var cryptoCoin = $scope.coin.toUpperCase();
txFormatService.formatAlternativeStr($scope.coin, requestedSatoshis, function onFormatAlternativeStr(formatted){
txFormatService.formatAlternativeStr($scope.coin, $scope.params.amount, function onFormatAlternativeStr(formatted){
if (formatted) {
var fiatParts = formatted.split(' ');
var fiatAmount = fiatParts[0];
@ -105,12 +101,6 @@ angular.module('copayApp.controllers').controller('walletSelectorController', fu
}
}
function handleThirdPartyIfBip70PaymentProtocol() {
if ($scope.thirdParty.id === 'bitpay') {
console.log('paypro details:', $scope.thirdParty.details);
}
}
function handleThirdPartyIfShapeshift() {
if ($scope.thirdParty.id === 'shapeshift' && $scope.type === 'destination') { // Shapeshift wants to know the
if ($scope.coin === 'bch') {
@ -169,8 +159,10 @@ angular.module('copayApp.controllers').controller('walletSelectorController', fu
}
} else if ($scope.type === 'destination') {
$scope.fromWallet = profileService.getWallet(fromWalletId);
$scope.coin = $scope.fromWallet.coin; // Only show wallets with the select origin wallet coin
if (!$scope.coin) { // Allow for the coin to be set by a third party
$scope.fromWallet = profileService.getWallet(fromWalletId);
$scope.coin = $scope.fromWallet.coin; // Only show wallets with the select origin wallet coin
}
$scope.headerTitle = gettextCatalog.getString('Choose a wallet to send to');
if ($scope.coin === 'btc') { // if no specific coin is set or coin is set btc