Clean UI. Adds amount parser for coinbaseService
This commit is contained in:
parent
89639a8d48
commit
8d1d59cb3b
9 changed files with 85 additions and 46 deletions
|
|
@ -1,6 +1,6 @@
|
|||
'use strict';
|
||||
|
||||
angular.module('copayApp.services').factory('coinbaseService', function($http, $log, $window, platformInfo, lodash, storageService, configService, appConfigService) {
|
||||
angular.module('copayApp.services').factory('coinbaseService', function($http, $log, $window, $filter, platformInfo, lodash, storageService, configService, appConfigService, txFormatService) {
|
||||
var root = {};
|
||||
var credentials = {};
|
||||
var isCordova = platformInfo.isCordova;
|
||||
|
|
@ -104,6 +104,35 @@ angular.module('copayApp.services').factory('coinbaseService', function($http, $
|
|||
});
|
||||
};
|
||||
|
||||
root.getAvailableCurrency = function() {
|
||||
var config = configService.getSync().wallet.settings;
|
||||
// ONLY "USD" and "EUR"
|
||||
switch(config.alternativeIsoCode) {
|
||||
case 'EUR' : return 'EUR';
|
||||
default : return 'USD'
|
||||
};
|
||||
};
|
||||
|
||||
root.parseAmount = function(amount, currency) {
|
||||
var config = configService.getSync().wallet.settings;
|
||||
var satToBtc = 1 / 100000000;
|
||||
var unitToSatoshi = config.unitToSatoshi;
|
||||
var amountUnitStr;
|
||||
|
||||
// IF 'USD'
|
||||
if (currency) {
|
||||
amountUnitStr = $filter('formatFiatAmount')(amount) + ' ' + currency;
|
||||
} else {
|
||||
var amountSat = parseInt((amount * unitToSatoshi).toFixed(0));
|
||||
amountUnitStr = txFormatService.formatAmountStr(amountSat);
|
||||
// convert unit to BTC
|
||||
amount = (amountSat * satToBtc).toFixed(8);
|
||||
currency = 'BTC';
|
||||
}
|
||||
|
||||
return [amount, currency, amountUnitStr];
|
||||
};
|
||||
|
||||
root.getOauthCodeUrl = function() {
|
||||
return credentials.HOST
|
||||
+ '/oauth/authorize?response_type=code&client_id='
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue