WIPP
This commit is contained in:
parent
3a99b7a6bc
commit
00d986376e
8 changed files with 149 additions and 155 deletions
|
|
@ -1,8 +1,10 @@
|
|||
const configManager = require('./config-manager')
|
||||
const settingsLoader = require('./settings-loader')
|
||||
|
||||
function fetchExchange (settings, cryptoCode) {
|
||||
function fetchExchange (cryptoCode) {
|
||||
return Promise.resolve()
|
||||
.then(() => {
|
||||
const settings = settingsLoader.settings
|
||||
const plugin = configManager.cryptoScoped(cryptoCode, settings.config).cryptoServices.wallet
|
||||
if (!plugin) throw new Error('No exchange plugin defined for: ' + cryptoCode)
|
||||
const account = settings.accounts.plugin
|
||||
|
|
@ -12,18 +14,18 @@ function fetchExchange (settings, cryptoCode) {
|
|||
})
|
||||
}
|
||||
|
||||
function buy (settings, cryptoAtoms, fiatCode, cryptoCode) {
|
||||
return fetchExchange(settings, cryptoCode)
|
||||
function buy (cryptoAtoms, fiatCode, cryptoCode) {
|
||||
return fetchExchange(cryptoCode)
|
||||
.then(r => r.exchange.buy(r.account, cryptoAtoms, fiatCode, cryptoCode))
|
||||
}
|
||||
|
||||
function sell (settings, cryptoAtoms, fiatCode, cryptoCode) {
|
||||
return fetchExchange(settings, cryptoCode)
|
||||
function sell (cryptoAtoms, fiatCode, cryptoCode) {
|
||||
return fetchExchange(cryptoCode)
|
||||
.then(r => r.exchange.sell(r.account, cryptoAtoms, fiatCode, cryptoCode))
|
||||
}
|
||||
|
||||
function active (settings, cryptoCode) {
|
||||
return fetchExchange(settings, cryptoCode)
|
||||
function active (cryptoCode) {
|
||||
return fetchExchange(cryptoCode)
|
||||
.then(() => true)
|
||||
.catch(() => false)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue