popup warning about coin if plain address used
This commit is contained in:
parent
d31a2115b1
commit
ec6b066e19
1 changed files with 66 additions and 53 deletions
|
|
@ -397,67 +397,80 @@ angular.module('copayApp.controllers').controller('amountController', function($
|
||||||
|
|
||||||
$scope.finish = function() {
|
$scope.finish = function() {
|
||||||
|
|
||||||
var unit = availableUnits[unitIndex];
|
function finish() {
|
||||||
var _amount = evaluate(format($scope.amountModel.amount));
|
var unit = availableUnits[unitIndex];
|
||||||
var coin = unit.id;
|
var _amount = evaluate(format($scope.amountModel.amount));
|
||||||
if (unit.isFiat) {
|
var coin = unit.id;
|
||||||
coin = availableUnits[altUnitIndex].id;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($scope.nextStep) {
|
|
||||||
$state.transitionTo($scope.nextStep, {
|
|
||||||
id: _id,
|
|
||||||
amount: $scope.useSendMax ? null : _amount,
|
|
||||||
currency: unit.id.toUpperCase(),
|
|
||||||
coin: coin,
|
|
||||||
useSendMax: $scope.useSendMax
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
var amount = _amount;
|
|
||||||
|
|
||||||
if (unit.isFiat) {
|
if (unit.isFiat) {
|
||||||
amount = (fromFiat(amount) * unitToSatoshi).toFixed(0);
|
coin = availableUnits[altUnitIndex].id;
|
||||||
} else {
|
|
||||||
amount = (amount * unitToSatoshi).toFixed(0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var confirmData = {
|
if ($scope.nextStep) {
|
||||||
recipientType: $scope.recipientType,
|
$state.transitionTo($scope.nextStep, {
|
||||||
toAmount: amount,
|
id: _id,
|
||||||
toAddress: $scope.toAddress,
|
amount: $scope.useSendMax ? null : _amount,
|
||||||
displayAddress: $scope.displayAddress || $scope.toAddress,
|
currency: unit.id.toUpperCase(),
|
||||||
toName: $scope.toName,
|
coin: coin,
|
||||||
toEmail: $scope.toEmail,
|
useSendMax: $scope.useSendMax
|
||||||
toColor: $scope.toColor,
|
});
|
||||||
coin: coin,
|
} else {
|
||||||
useSendMax: $scope.useSendMax,
|
var amount = _amount;
|
||||||
};
|
|
||||||
|
|
||||||
if ($scope.shapeshiftOrderId) {
|
if (unit.isFiat) {
|
||||||
var shapeshiftOrderUrl = 'https://www.shapeshift.io/#/status/';
|
amount = (fromFiat(amount) * unitToSatoshi).toFixed(0);
|
||||||
shapeshiftOrderUrl += $scope.shapeshiftOrderId;
|
} else {
|
||||||
confirmData.description = shapeshiftOrderUrl;
|
amount = (amount * unitToSatoshi).toFixed(0);
|
||||||
confirmData.fromWalletId = $scope.fromWalletId;
|
}
|
||||||
|
|
||||||
if (confirmData.useSendMax) {
|
var confirmData = {
|
||||||
var wallet = lodash.find(profileService.getWallets({ coin: coin }),
|
recipientType: $scope.recipientType,
|
||||||
function(w) {
|
toAmount: amount,
|
||||||
return w.id == $scope.fromWalletId;
|
toAddress: $scope.toAddress,
|
||||||
});
|
displayAddress: $scope.displayAddress || $scope.toAddress,
|
||||||
|
toName: $scope.toName,
|
||||||
|
toEmail: $scope.toEmail,
|
||||||
|
toColor: $scope.toColor,
|
||||||
|
coin: coin,
|
||||||
|
useSendMax: $scope.useSendMax,
|
||||||
|
};
|
||||||
|
|
||||||
var balance = parseFloat(wallet.cachedBalance.substring(0, wallet.cachedBalance.length-4));
|
if ($scope.shapeshiftOrderId) {
|
||||||
if (balance < $scope.minShapeshiftAmount * 1.04) {
|
var shapeshiftOrderUrl = 'https://www.shapeshift.io/#/status/';
|
||||||
confirmData.useSendMax = false;
|
shapeshiftOrderUrl += $scope.shapeshiftOrderId;
|
||||||
confirmData.toAmount = $scope.minShapeshiftAmount * unitToSatoshi;
|
confirmData.description = shapeshiftOrderUrl;
|
||||||
} else if (balance > $scope.maxShapeshiftAmount) {
|
confirmData.fromWalletId = $scope.fromWalletId;
|
||||||
confirmData.useSendMax = false;
|
|
||||||
confirmData.toAmount = $scope.maxShapeshiftAmount * unitToSatoshi * 0.99;
|
if (confirmData.useSendMax) {
|
||||||
|
var wallet = lodash.find(profileService.getWallets({ coin: coin }),
|
||||||
|
function(w) {
|
||||||
|
return w.id == $scope.fromWalletId;
|
||||||
|
});
|
||||||
|
|
||||||
|
var balance = parseFloat(wallet.cachedBalance.substring(0, wallet.cachedBalance.length-4));
|
||||||
|
if (balance < $scope.minShapeshiftAmount * 1.04) {
|
||||||
|
confirmData.useSendMax = false;
|
||||||
|
confirmData.toAmount = $scope.minShapeshiftAmount * unitToSatoshi;
|
||||||
|
} else if (balance > $scope.maxShapeshiftAmount) {
|
||||||
|
confirmData.useSendMax = false;
|
||||||
|
confirmData.toAmount = $scope.maxShapeshiftAmount * unitToSatoshi * 0.99;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
$state.transitionTo('tabs.send.confirm', confirmData);
|
$state.transitionTo('tabs.send.confirm', confirmData);
|
||||||
|
}
|
||||||
|
$scope.useSendMax = null;
|
||||||
}
|
}
|
||||||
$scope.useSendMax = null;
|
|
||||||
|
if ($scope.showWarningMessage) {
|
||||||
|
var message = 'Are you sure you want to send ' + $scope.unit.toUpperCase() + '?';
|
||||||
|
popupService.showConfirm(message, null, 'Yes', 'No', function(res) {
|
||||||
|
if (!res) return;
|
||||||
|
finish();
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
finish();
|
||||||
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue