WIPP
This commit is contained in:
parent
3a99b7a6bc
commit
00d986376e
8 changed files with 149 additions and 155 deletions
|
|
@ -1,11 +1,13 @@
|
|||
const mem = require('mem')
|
||||
const configManager = require('./config-manager')
|
||||
const settingsLoader = require('./settings-loader')
|
||||
|
||||
const FETCH_INTERVAL = 5000
|
||||
|
||||
function fetchWallet (settings, cryptoCode) {
|
||||
function fetchWallet (cryptoCode) {
|
||||
return Promise.resolve()
|
||||
.then(() => {
|
||||
const settings = settingsLoader.settings
|
||||
const plugin = configManager.cryptoScoped(cryptoCode, settings.config).cryptoServices.wallet
|
||||
const account = settings.accounts.plugin
|
||||
const wallet = require('lamassu-' + plugin)
|
||||
|
|
@ -14,8 +16,8 @@ function fetchWallet (settings, cryptoCode) {
|
|||
})
|
||||
}
|
||||
|
||||
function balance (settings, cryptoCode) {
|
||||
return fetchWallet(settings, cryptoCode)
|
||||
function balance (cryptoCode) {
|
||||
return fetchWallet(cryptoCode)
|
||||
.then(r => r.wallet.balance(r.account))
|
||||
.then(balance => ({balance, timestamp: Date.now()}))
|
||||
}
|
||||
|
|
@ -31,13 +33,13 @@ function sendCoins (toAddress, cryptoAtoms, cryptoCode) {
|
|||
})
|
||||
}
|
||||
|
||||
function newAddress (settings, cryptoCode, info) {
|
||||
return fetchWallet(settings, cryptoCode)
|
||||
function newAddress (cryptoCode, info) {
|
||||
return fetchWallet(cryptoCode)
|
||||
.then(r => r.wallet.newAddress(r.account, cryptoCode, info))
|
||||
}
|
||||
|
||||
function getStatus (settings, toAdress, cryptoAtoms, cryptoCode) {
|
||||
return fetchWallet(settings, cryptoCode)
|
||||
function getStatus (toAdress, cryptoAtoms, cryptoCode) {
|
||||
return fetchWallet(cryptoCode)
|
||||
.then(r => r.wallet.getStatus(r.account, toAdress, cryptoAtoms, cryptoCode))
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue