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

View file

@ -345,7 +345,7 @@ angular.module('copayApp').config(function(historicLogProvider, $provide, $logPr
}
})
.state('tabs.send.review', {
url: '/review/:thirdParty/:amount/:fromWalletId/:sendMax/:toAddr/:toWalletId',
url: '/review/:thirdParty/:amount/:fromWalletId/:sendMax/:toAddress/:toWalletId',
views: {
'tab-send@tabs': {
controller: 'reviewController',

View file

@ -423,8 +423,22 @@ angular.module('copayApp.services').factory('incomingData', function($log, $stat
function handlePayPro(payProDetails, coin) {
var thirdPartyData = {
id: payProDetails.name,
details: payProDetails
caName: payProDetails.caName,
caTrusted: payProDetails.caTrusted,
coin: coin,
domain: payProDetails.domain,
expires: payProDetails.expires,
id: 'bip70PaymentProtocol',
memo: payProDetails.memo,
merchant_data: payProDetails.merchant_data,
network: payProDetails.network,
requiredFeeRate: payProDetails.requiredFeeRate,
selfSigned: payProDetails.selfSigned,
time: payProDetails.time,
url: payProDetails.url,
verified: payProDetails.verified
};
var stateParams = {
amount: payProDetails.amount,
toAddr: payProDetails.toAddress,

View file

@ -1,26 +1,32 @@
'use strict';
angular.module('copayApp.services').factory('shapeshiftService', function($http, $log, lodash, moment, ongoingProcess, shapeshiftApiService, storageService, configService, platformInfo, servicesService) {
angular.module('copayApp.services').factory('shapeshiftService', function($http, $interval, $log, lodash, moment, ongoingProcess, shapeshiftApiService, storageService, configService, incomingData, platformInfo, servicesService) {
var root = {};
root.ShiftState = 'Shift';
root.withdrawalAddress = ''
root.returnAddress = ''
root.amount = '';
root.marketData = {}
this.withdrawalAddress = function(address) {
root.withdrawalAddress = function(address) {
root.withdrawalAddress = address;
};
this.returnAddress = function(address) {
root.returnAddress = function(address) {
root.returnAddress = address;
};
this.amount = function(amount) {
root.amount = function(amount) {
root.amount = amount;
};
this.fromWalletId = function(id) {
root.fromWalletId = function(id) {
root.fromWalletId = id;
};
this.toWalletId = function(id) {
root.toWalletId = function(id) {
root.toWalletId = id;
};
root.coinIn = function(coinIn) {
root.coinIn = coinIn.toUpperCase();
};
root.coinOut = function(coinOut) {
root.coinOut = coinOut.toUpperCase();
};
root.getMarketDataIn = function(coin) {
if(coin === root.coinOut) return root.getMarketData(root.coinOut, root.coinIn);
@ -104,6 +110,7 @@ angular.module('copayApp.services').factory('shapeshiftService', function($http,
var shapeshiftData = {
fromWalletId: root.fromWalletId,
toWalletId: root.toWalletId,
minAmount: root.marketData.minimum,
maxAmount: root.marketData.maxLimit,
orderId: root.depositInfo.orderId

View file

@ -18,6 +18,6 @@
}
}
.header.shapeshift {
background: url(../img/shapeshiftbg.jpg) center center no-repeat #28394d;
background: url(../img/shapeshiftbg.jpg) center center repeat #28394d;
opacity: 0.99;
}