TONS of work in shapeshift integration
This commit is contained in:
parent
8e2263cc9a
commit
b16a4215d2
14 changed files with 267 additions and 58 deletions
|
|
@ -1,6 +1,7 @@
|
|||
'use strict';
|
||||
|
||||
angular.module('copayApp.controllers').controller('amountController', function($scope, $filter, $timeout, $ionicScrollDelegate, $ionicHistory, gettextCatalog, platformInfo, lodash, configService, rateService, $stateParams, $window, $state, $log, txFormatService, ongoingProcess, popupService, bwcError, payproService, profileService, bitcore, amazonService, nodeWebkitService) {
|
||||
|
||||
var _id;
|
||||
var unitToSatoshi;
|
||||
var satToUnit;
|
||||
|
|
@ -24,6 +25,12 @@ angular.module('copayApp.controllers').controller('amountController', function($
|
|||
});
|
||||
|
||||
$scope.$on("$ionicView.beforeEnter", function(event, data) {
|
||||
|
||||
if (data.stateParams.minShapeshiftAmount.length > 0 && data.stateParams.maxShapeshiftAmount.length > 0) {
|
||||
$scope.minShapeshiftAmount = parseFloat(data.stateParams.minShapeshiftAmount);
|
||||
$scope.maxShapeshiftAmount = parseFloat(data.stateParams.maxShapeshiftAmount);
|
||||
}
|
||||
|
||||
var config = configService.getSync().wallet.settings;
|
||||
|
||||
function setAvailableUnits() {
|
||||
|
|
@ -297,7 +304,11 @@ angular.module('copayApp.controllers').controller('amountController', function($
|
|||
function processAmount() {
|
||||
var formatedValue = format($scope.amount);
|
||||
var result = evaluate(formatedValue);
|
||||
$scope.allowSend = lodash.isNumber(result) && +result > 0;
|
||||
$scope.allowSend = lodash.isNumber(result) && +result > 0
|
||||
&& ((!$scope.minShapeshiftAmount && !$scope.maxShapeshiftAmount)
|
||||
|| ($scope.minShapeshiftAmount && $scope.maxShapeshiftAmount
|
||||
&& result >= $scope.minShapeshiftAmount && result <= $scope.maxShapeshiftAmount));
|
||||
|
||||
if (lodash.isNumber(result)) {
|
||||
$scope.globalResult = isExpression($scope.amount) ? '= ' + processResult(result) : '';
|
||||
|
||||
|
|
|
|||
|
|
@ -1,3 +1,80 @@
|
|||
'use strict';
|
||||
|
||||
angular.module('copayApp.controllers').controller('shapeshiftController', function($scope, $interval){ });
|
||||
angular.module('copayApp.controllers').controller('shapeshiftController', function($scope, $interval, profileService, walletService, popupService) {
|
||||
|
||||
var walletsBtc = [];
|
||||
var walletsBch = [];
|
||||
|
||||
function generateAddress(wallet, cb) {
|
||||
if (!wallet) return;
|
||||
walletService.getAddress(wallet, false, function(err, addr) {
|
||||
if (err) {
|
||||
popupService.showAlert(err);
|
||||
}
|
||||
return cb(addr);
|
||||
});
|
||||
}
|
||||
|
||||
function showToWallets() {
|
||||
$scope.toWallets = $scope.fromWallet.coin == 'btc' ? walletsBch : walletsBtc;
|
||||
$scope.onToWalletSelect($scope.toWallets[0]);
|
||||
$scope.singleToWallet = $scope.toWallets.length == 1;
|
||||
}
|
||||
|
||||
$scope.onFromWalletSelect = function(wallet) {
|
||||
$scope.fromWallet = wallet;
|
||||
showToWallets();
|
||||
generateAddress(wallet, function(addr) {
|
||||
$scope.fromWalletAddress = addr;
|
||||
});
|
||||
};
|
||||
|
||||
$scope.onToWalletSelect = function(wallet) {
|
||||
$scope.toWallet = wallet;
|
||||
generateAddress(wallet, function(addr) {
|
||||
$scope.toWalletAddress = addr;
|
||||
});
|
||||
}
|
||||
|
||||
$scope.$on("$ionicView.beforeEnter", function(event, data) {
|
||||
walletsBtc = profileService.getWallets({coin: 'btc'});
|
||||
walletsBch = profileService.getWallets({coin: 'bch'});
|
||||
$scope.fromWallets = walletsBtc.concat(walletsBch);
|
||||
$scope.toWallets = walletsBch;
|
||||
if ($scope.fromWallets.length == 0 || $scope.toWallets.length == 0) return;
|
||||
$scope.onFromWalletSelect($scope.fromWallets[0]);
|
||||
$scope.onToWalletSelect($scope.toWallets[0]);
|
||||
$scope.singleFromWallet = $scope.fromWallets.length == 1;
|
||||
$scope.singleToWallet = $scope.toWallets.length == 1;
|
||||
$scope.toWalletSelectorTitle = 'To';
|
||||
$scope.showFromWallets = false;
|
||||
$scope.showToWallets = false;
|
||||
});
|
||||
|
||||
$scope.showFromWalletSelector = function() {
|
||||
$scope.showFromWallets = true;
|
||||
}
|
||||
|
||||
$scope.showToWalletSelector = function() {
|
||||
$scope.showToWallets = true;
|
||||
}
|
||||
|
||||
/*var setAddress = function(newAddr) {
|
||||
$scope.addr = null;
|
||||
if (!$scope.wallet || $scope.generatingAddress || !$scope.wallet.isComplete()) return;
|
||||
$scope.generatingAddress = true;
|
||||
walletService.getAddress($scope.wallet, newAddr, function(err, addr) {
|
||||
$scope.generatingAddress = false;
|
||||
|
||||
if (err) {
|
||||
//Error is already formated
|
||||
popupService.showAlert(err);
|
||||
}
|
||||
|
||||
$scope.addr = addr;
|
||||
$timeout(function() {
|
||||
$scope.$apply();
|
||||
}, 10);
|
||||
});
|
||||
};*/
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue