* Oauth2 and first view * Connect with Coinbase using mobile * Buy and Sell through Coinbase * Fix buy * Receive and send bitcoin to Coinbase account * Receive bitcoin from Coinbase to Copay * Complete user and account information. Connection errors * Improves error handler * Removes console.log * Coinbase background color. Send to Coinbase form validation * Fix send from different wallet * Send and receive using Coinbase * Pagination activity * Fix Buy and Sell * One option in the sidebar to Buy and Sell * Native balance on Coinbase homepage * Rename receive and send * Auto-close window after authenticate * Reorder * Get payment methods * Fix when token expired * Fix token expired * Integration: sell and send to Coinbase * Store pending transaction before sell * Sell flow completed * Removing files * Fix sell * Fix sell * Fix sell * Sell completed * Buy bitcoin through coinbase * Buy auto * Currency set to USD * Select payment methods. Limits * Removes payment methods from preferences * Fix signs. Tx ordered by updated. Minor fixes * Removes console.log * Improving ux-language things * Fix selectedpaymentmethod if not verified * Set error if tx not found * Price sensitivity. Minor fixes * Adds coinbase api key to gitignore * Coinbase production ready * Fix sell in usd * Bug fixes * New Sensitivity step * Refresh token with a simple click * Refresh token * Refactor * Fix auto reconnect if token expired Signed-off-by: Gustavo Maximiliano Cortez <cmgustavo83@gmail.com> * Fix calls if token expired
155 lines
3.5 KiB
JavaScript
155 lines
3.5 KiB
JavaScript
'use strict';
|
|
|
|
angular.module('copayApp.services').factory('configService', function(storageService, lodash, $log) {
|
|
var root = {};
|
|
|
|
var defaultConfig = {
|
|
// wallet limits
|
|
limits: {
|
|
totalCopayers: 6,
|
|
mPlusN: 100,
|
|
},
|
|
|
|
// Bitcore wallet service URL
|
|
bws: {
|
|
url: 'https://bws.bitpay.com/bws/api',
|
|
},
|
|
|
|
// wallet default config
|
|
wallet: {
|
|
requiredCopayers: 2,
|
|
totalCopayers: 3,
|
|
spendUnconfirmed: true,
|
|
reconnectDelay: 5000,
|
|
idleDurationMin: 4,
|
|
settings: {
|
|
unitName: 'bits',
|
|
unitToSatoshi: 100,
|
|
unitDecimals: 2,
|
|
unitCode: 'bit',
|
|
alternativeName: 'US Dollar',
|
|
alternativeIsoCode: 'USD',
|
|
}
|
|
},
|
|
|
|
// External services
|
|
glidera: {
|
|
enabled: true,
|
|
testnet: false
|
|
},
|
|
|
|
coinbase: {
|
|
enabled: true,
|
|
testnet: false
|
|
},
|
|
|
|
rates: {
|
|
url: 'https://insight.bitpay.com:443/api/rates',
|
|
},
|
|
|
|
release: {
|
|
url: 'https://api.github.com/repos/bitpay/copay/releases/latest'
|
|
},
|
|
|
|
pushNotifications: {
|
|
enabled: true,
|
|
config: {
|
|
android: {
|
|
senderID: '1036948132229',
|
|
icon: 'push',
|
|
iconColor: '#2F4053'
|
|
},
|
|
ios: {
|
|
alert: 'true',
|
|
badge: 'true',
|
|
sound: 'true',
|
|
},
|
|
windows: {},
|
|
}
|
|
},
|
|
};
|
|
|
|
var configCache = null;
|
|
|
|
|
|
root.getSync = function() {
|
|
if (!configCache)
|
|
throw new Error('configService#getSync called when cache is not initialized');
|
|
|
|
return configCache;
|
|
};
|
|
|
|
root.get = function(cb) {
|
|
|
|
storageService.getConfig(function(err, localConfig) {
|
|
if (localConfig) {
|
|
configCache = JSON.parse(localConfig);
|
|
|
|
//these ifs are to avoid migration problems
|
|
if (!configCache.bws) {
|
|
configCache.bws = defaultConfig.bws;
|
|
}
|
|
if (!configCache.wallet) {
|
|
configCache.wallet = defaultConfig.wallet;
|
|
}
|
|
if (!configCache.wallet.settings.unitCode) {
|
|
configCache.wallet.settings.unitCode = defaultConfig.wallet.settings.unitCode;
|
|
}
|
|
if (!configCache.glidera) {
|
|
configCache.glidera = defaultConfig.glidera;
|
|
}
|
|
if (!configCache.coinbase) {
|
|
configCache.coinbase = defaultConfig.coinbase;
|
|
}
|
|
if (!configCache.pushNotifications) {
|
|
configCache.pushNotifications = defaultConfig.pushNotifications;
|
|
}
|
|
|
|
} else {
|
|
configCache = lodash.clone(defaultConfig);
|
|
};
|
|
|
|
// Glidera
|
|
// Disabled for testnet
|
|
configCache.glidera.testnet = false;
|
|
|
|
// Coinbase
|
|
// Disabled for testnet
|
|
configCache.coinbase.testnet = false;
|
|
|
|
$log.debug('Preferences read:', configCache)
|
|
return cb(err, configCache);
|
|
});
|
|
};
|
|
|
|
root.set = function(newOpts, cb) {
|
|
var config = lodash.cloneDeep(defaultConfig);
|
|
storageService.getConfig(function(err, oldOpts) {
|
|
if (lodash.isString(oldOpts)) {
|
|
oldOpts = JSON.parse(oldOpts);
|
|
}
|
|
if (lodash.isString(config)) {
|
|
config = JSON.parse(config);
|
|
}
|
|
if (lodash.isString(newOpts)) {
|
|
newOpts = JSON.parse(newOpts);
|
|
}
|
|
lodash.merge(config, oldOpts, newOpts);
|
|
configCache = config;
|
|
|
|
storageService.storeConfig(JSON.stringify(config), cb);
|
|
});
|
|
};
|
|
|
|
root.reset = function(cb) {
|
|
configCache = lodash.clone(defaultConfig);
|
|
storageService.removeConfig(cb);
|
|
};
|
|
|
|
root.getDefaults = function() {
|
|
return lodash.clone(defaultConfig);
|
|
};
|
|
|
|
|
|
return root;
|
|
});
|