fixed bug where user could send to shapeshift from wrong wallet
This commit is contained in:
parent
7c5e6077e6
commit
64b11fba3a
7 changed files with 31 additions and 3 deletions
|
|
@ -34,6 +34,7 @@ angular.module('copayApp.controllers').controller('amountController', function($
|
|||
$scope.minShapeshiftAmount = parseFloat(data.stateParams.minShapeshiftAmount);
|
||||
$scope.maxShapeshiftAmount = parseFloat(data.stateParams.maxShapeshiftAmount);
|
||||
$scope.shapeshiftOrderId = data.stateParams.shapeshiftOrderId;
|
||||
$scope.fromWalletId = data.stateParams.fromWalletId;
|
||||
}
|
||||
|
||||
var config = configService.getSync().wallet.settings;
|
||||
|
|
@ -427,6 +428,7 @@ angular.module('copayApp.controllers').controller('amountController', function($
|
|||
var shapeshiftOrderUrl = 'https://www.shapeshift.io/#/status/';
|
||||
shapeshiftOrderUrl += $scope.shapeshiftOrderId;
|
||||
confirmData.description = shapeshiftOrderUrl;
|
||||
confirmData.fromWalletId = $scope.fromWalletId;
|
||||
}
|
||||
|
||||
$state.transitionTo('tabs.send.confirm', confirmData);
|
||||
|
|
|
|||
|
|
@ -81,6 +81,14 @@ angular.module('copayApp.controllers').controller('confirmController', function(
|
|||
coin: coin
|
||||
});
|
||||
|
||||
if (tx.fromWalletId) {
|
||||
$scope.wallets = lodash.filter($scope.wallets, function(w) {
|
||||
return w.id == tx.fromWalletId;
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
if (!$scope.wallets || !$scope.wallets.length) {
|
||||
setNoWallet(gettextCatalog.getString('No wallets available'), true);
|
||||
return cb();
|
||||
|
|
@ -150,6 +158,7 @@ angular.module('copayApp.controllers').controller('confirmController', function(
|
|||
tx = {
|
||||
toAmount: parseInt(data.stateParams.toAmount),
|
||||
sendMax: data.stateParams.useSendMax == 'true' ? true : false,
|
||||
fromWalletId: data.stateParams.fromWalletId,
|
||||
toAddress: data.stateParams.toAddress,
|
||||
description: data.stateParams.description,
|
||||
paypro: data.stateParams.paypro,
|
||||
|
|
|
|||
|
|
@ -13,6 +13,7 @@ angular.module('copayApp.directives').directive('shapeshiftCoinSelector', functi
|
|||
amount:'=amount',
|
||||
marketData:'=marketData',
|
||||
coinAddress:'=coinAddress',
|
||||
walletId:'=walletId',
|
||||
direction:'=direction',
|
||||
},
|
||||
link: function(scope, element, attrs, controllers) {
|
||||
|
|
@ -35,6 +36,12 @@ angular.module('copayApp.directives').directive('shapeshiftCoinSelector', functi
|
|||
scope.$watch('amount', function(newVal) {
|
||||
coinTraderCtrl.amount(newVal)
|
||||
});
|
||||
scope.$watch('walletId', function(newVal) {
|
||||
if(scope.direction === 'in')
|
||||
coinTraderCtrl.fromWalletId(newVal);
|
||||
else if(scope.direction === 'out')
|
||||
coinTraderCtrl.toWalletId(newVal);
|
||||
});
|
||||
},
|
||||
templateUrl: 'views/includes/shapeshift-coin-selector.html'
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,6 +19,12 @@ angular.module('copayApp.directives').directive('shapeshiftCoinTrader', function
|
|||
this.amount = function(amount) {
|
||||
$scope.amount = amount;
|
||||
};
|
||||
this.fromWalletId = function(id) {
|
||||
$scope.fromWalletId = id;
|
||||
};
|
||||
this.toWalletId = function(id) {
|
||||
$scope.toWalletId = id;
|
||||
};
|
||||
|
||||
$scope.getMarketDataIn = function(coin) {
|
||||
if(coin === $scope.coinOut) return $scope.getMarketData($scope.coinOut, $scope.coinIn);
|
||||
|
|
@ -99,6 +105,7 @@ angular.module('copayApp.directives').directive('shapeshiftCoinTrader', function
|
|||
sendAddress = sendAddress.replace('bitcoin cash', 'bitcoincash');
|
||||
|
||||
var shapeshiftData = {
|
||||
fromWalletId: $scope.fromWalletId,
|
||||
minAmount: $scope.marketData.minimum,
|
||||
maxAmount: $scope.marketData.maxLimit,
|
||||
orderId: $scope.depositInfo.orderId
|
||||
|
|
|
|||
|
|
@ -287,7 +287,7 @@ angular.module('copayApp').config(function(historicLogProvider, $provide, $logPr
|
|||
*/
|
||||
|
||||
.state('tabs.send.amount', {
|
||||
url: '/amount/:recipientType/:toAddress/:toName/:toEmail/:toColor/:coin/:fixedUnit/:minShapeshiftAmount/:maxShapeshiftAmount/:shapeshiftOrderId',
|
||||
url: '/amount/:recipientType/:toAddress/:toName/:toEmail/:toColor/:coin/:fixedUnit/:fromWalletId/:minShapeshiftAmount/:maxShapeshiftAmount/:shapeshiftOrderId',
|
||||
views: {
|
||||
'tab-send@tabs': {
|
||||
controller: 'amountController',
|
||||
|
|
@ -296,7 +296,7 @@ angular.module('copayApp').config(function(historicLogProvider, $provide, $logPr
|
|||
}
|
||||
})
|
||||
.state('tabs.send.confirm', {
|
||||
url: '/confirm/:recipientType/:toAddress/:toName/:toAmount/:toEmail/:toColor/:description/:coin/:useSendMax',
|
||||
url: '/confirm/:recipientType/:toAddress/:toName/:toAmount/:toEmail/:toColor/:description/:coin/:useSendMax/:fromWalletId',
|
||||
views: {
|
||||
'tab-send@tabs': {
|
||||
controller: 'confirmController',
|
||||
|
|
|
|||
|
|
@ -63,6 +63,7 @@ angular.module('copayApp.services').factory('incomingData', function($log, $stat
|
|||
} else {
|
||||
var params = { toAddress: addr, coin: coin };
|
||||
if (shapeshiftData) {
|
||||
params['fromWalletId'] = shapeshiftData.fromWalletId;
|
||||
params['minShapeshiftAmount'] = shapeshiftData.minAmount;
|
||||
params['maxShapeshiftAmount'] = shapeshiftData.maxAmount;
|
||||
params['shapeshiftOrderId'] = shapeshiftData.orderId;
|
||||
|
|
|
|||
|
|
@ -67,13 +67,14 @@
|
|||
</div>
|
||||
</div>
|
||||
|
||||
<shapeshift-coin-selector
|
||||
<shapeshift-coin-selector
|
||||
coins="coins"
|
||||
label="'Return Address'"
|
||||
get-market-data="getMarketDataIn"
|
||||
market-data="marketData"
|
||||
selected-coin="fromWallet.coin"
|
||||
coin-address="fromWalletAddress"
|
||||
wallet-id="fromWallet.id"
|
||||
amount="amount"
|
||||
direction="'in'">
|
||||
</shapeshift-coin-selector>
|
||||
|
|
@ -84,6 +85,7 @@
|
|||
get-market-data="getMarketDataOut"
|
||||
selected-coin="toWallet.coin"
|
||||
coin-address="toWalletAddress"
|
||||
wallet-id="toWallet.id"
|
||||
direction="'out'">
|
||||
</shapeshift-coin-selector>
|
||||
<shapeshift-coin-error ssError="ssError"></shapeshift-coin-error>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue