WIPP
This commit is contained in:
parent
4184e99273
commit
493e669e6d
5 changed files with 198 additions and 196 deletions
|
|
@ -1,9 +1,8 @@
|
|||
const settingsLoader = require('./settings-loader')
|
||||
const configManager = require('./config-manager')
|
||||
|
||||
function fetchExchange (cryptoCode) {
|
||||
return settingsLoader.settings()
|
||||
.then(settings => {
|
||||
function fetchExchange (settings, cryptoCode) {
|
||||
return Promise.resolve()
|
||||
.then(() => {
|
||||
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
|
||||
|
|
@ -13,18 +12,18 @@ function fetchExchange (cryptoCode) {
|
|||
})
|
||||
}
|
||||
|
||||
function buy (cryptoAtoms, fiatCode, cryptoCode) {
|
||||
return fetchExchange(cryptoCode)
|
||||
function buy (settings, cryptoAtoms, fiatCode, cryptoCode) {
|
||||
return fetchExchange(settings, cryptoCode)
|
||||
.then(r => r.exchange.buy(r.account, cryptoAtoms, fiatCode, cryptoCode))
|
||||
}
|
||||
|
||||
function sell (cryptoAtoms, fiatCode, cryptoCode) {
|
||||
return fetchExchange(cryptoCode)
|
||||
function sell (settings, cryptoAtoms, fiatCode, cryptoCode) {
|
||||
return fetchExchange(settings, cryptoCode)
|
||||
.then(r => r.exchange.sell(r.account, cryptoAtoms, fiatCode, cryptoCode))
|
||||
}
|
||||
|
||||
function active (cryptoCode) {
|
||||
return fetchExchange(cryptoCode)
|
||||
function active (settings, cryptoCode) {
|
||||
return fetchExchange(settings, cryptoCode)
|
||||
.then(() => true)
|
||||
.catch(() => false)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue