Clean code. Fix coinbase tx modal

This commit is contained in:
Gustavo Maximiliano Cortez 2017-01-13 01:05:52 -03:00
commit 9ac1e565ac
No known key found for this signature in database
GPG key ID: 15EDAD8D9F2EB1AF
5 changed files with 77 additions and 62 deletions

View file

@ -97,6 +97,13 @@ angular.module('copayApp.services').factory('coinbaseService', function($http, $
return credentials.NETWORK;
};
root.getStoredToken = function(cb) {
storageService.getCoinbaseToken(credentials.NETWORK, function(err, accessToken) {
if (err || !accessToken) return cb();
return cb(accessToken);
});
};
root.getOauthCodeUrl = function() {
return credentials.HOST
+ '/oauth/authorize?response_type=code&client_id='
@ -478,16 +485,17 @@ angular.module('copayApp.services').factory('coinbaseService', function($http, $
};
root.getPendingTransactions = function(coinbasePendingTransactions) {
root.init(function(err, data) {
if (err || lodash.isEmpty(data)) {
if (err) $log.error(err);
return;
}
var accessToken = data.accessToken;
var accountId = data.accountId;
storageService.getCoinbaseTxs(credentials.NETWORK, function(err, txs) {
txs = txs ? JSON.parse(txs) : {};
coinbasePendingTransactions.data = lodash.isEmpty(txs) ? null : txs;
storageService.getCoinbaseTxs(credentials.NETWORK, function(err, txs) {
txs = txs ? JSON.parse(txs) : {};
coinbasePendingTransactions.data = lodash.isEmpty(txs) ? null : txs;
root.init(function(err, data) {
if (err || lodash.isEmpty(data)) {
if (err) $log.error(err);
return;
}
var accessToken = data.accessToken;
var accountId = data.accountId;
lodash.forEach(coinbasePendingTransactions.data, function(dataFromStorage, txId) {
if ((dataFromStorage.type == 'sell' && dataFromStorage.status == 'completed') ||