BUY/SELL bitcoin
This commit is contained in:
parent
e266ded1d1
commit
1a0a7eb5ad
7 changed files with 299 additions and 47 deletions
|
|
@ -1,13 +1,60 @@
|
|||
'use strict';
|
||||
|
||||
angular.module('copayApp.controllers').controller('buyGlideraController',
|
||||
function() {
|
||||
function($scope, $timeout, profileService, addressService, glideraService) {
|
||||
|
||||
this.addr = {};
|
||||
|
||||
this.setDestinationAddress = function() {
|
||||
var self = this;
|
||||
this.addrError = null;
|
||||
var fc = profileService.focusedClient;
|
||||
if (!fc) return;
|
||||
|
||||
$timeout(function() {
|
||||
addressService.getAddress(fc.credentials.walletId, null, function(err, addr) {
|
||||
if (err) {
|
||||
self.addrError = err;
|
||||
} else {
|
||||
if (addr) self.addr[fc.credentials.walletId] = addr;
|
||||
}
|
||||
$scope.$digest();
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
this.getBuyPrice = function(token, price) {
|
||||
var self = this;
|
||||
glideraService.buyPrice(token, price, function(error, sellPrice) {
|
||||
self.sellPrice = sellPrice;
|
||||
this.buyAmount = price.qty;
|
||||
glideraService.buyPrice(token, price, function(error, buyPrice) {
|
||||
self.buyPrice = buyPrice;
|
||||
self.setDestinationAddress();
|
||||
});
|
||||
};
|
||||
};
|
||||
|
||||
this.get2faCode = function(token, cb) {
|
||||
var self = this;
|
||||
glideraService.get2faCode(token, function(error, sent) {
|
||||
self.show2faCodeInput = sent;
|
||||
});
|
||||
};
|
||||
|
||||
this.send = function(token, twoFaCode) {
|
||||
var fc = profileService.focusedClient;
|
||||
var self = this;
|
||||
var data = {
|
||||
destinationAddress: self.addr[fc.credentials.walletId],
|
||||
qty: self.buyPrice.qty,
|
||||
priceUuid: self.buyPrice.priceUuid,
|
||||
useCurrentPrice: false,
|
||||
ip: null
|
||||
};
|
||||
console.log('[sellGlidera.js:128]',token, twoFaCode, data); //TODO
|
||||
glideraService.buy(token, twoFaCode, data, function(error, data) {
|
||||
console.log('[sellGlidera.js:116]',data); //TODO
|
||||
|
||||
});
|
||||
|
||||
};
|
||||
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue