Migrate plugins to lib directory

This commit is contained in:
Josh Harvey 2017-04-15 19:12:29 +03:00
parent 09b29bba56
commit e7ab8223c2
27 changed files with 869 additions and 858 deletions

View file

@ -1,11 +1,5 @@
const configManager = require('./config-manager')
function noExchangeError (cryptoCode) {
const err = new Error('No exchange plugin defined for: ' + cryptoCode)
err.name = 'NoExchangeError'
return err
}
const ph = require('./plugin-helper')
function lookupExchange (settings, cryptoCode) {
return configManager.cryptoScoped(cryptoCode, settings.config).exchange
@ -15,9 +9,8 @@ function fetchExchange (settings, cryptoCode) {
return Promise.resolve()
.then(() => {
const plugin = lookupExchange(settings, cryptoCode)
if (!plugin) throw noExchangeError(cryptoCode)
const exchange = ph.load(ph.EXCHANGE, plugin)
const account = settings.accounts[plugin]
const exchange = require('lamassu-' + plugin)
return {exchange, account}
})