WIP
This commit is contained in:
parent
0aa457680c
commit
47db8e9ead
7 changed files with 136 additions and 114 deletions
151
lib/plugins.js
151
lib/plugins.js
|
|
@ -165,96 +165,95 @@ exports.loadOrConfigPlugin = loadOrConfigPlugin
|
|||
exports.configure = function configure (config) {
|
||||
cachedConfig = config
|
||||
|
||||
const accounts = configManager.loadAccounts()
|
||||
|
||||
const cryptoCodes = getCryptoCodes()
|
||||
|
||||
console.log('DEBUG30')
|
||||
|
||||
cryptoCodes.forEach(cryptoCode => {
|
||||
console.log('DEBUG31')
|
||||
const cryptoScopedConfig = configManager.cryptoScoped(cryptoCode, cachedConfig)
|
||||
return configManager.loadAccounts()
|
||||
.then(accounts => {
|
||||
cryptoCodes.forEach(cryptoCode => {
|
||||
console.log('DEBUG31')
|
||||
const cryptoScopedConfig = configManager.cryptoScoped(cryptoCode, cachedConfig)
|
||||
|
||||
console.log('DEBUG31.1')
|
||||
console.log('DEBUG31.1')
|
||||
|
||||
// TICKER [required] configure (or load)
|
||||
loadOrConfigPlugin(
|
||||
tickerPlugins[cryptoCode],
|
||||
'ticker',
|
||||
cryptoCode,
|
||||
cryptoScopedConfig,
|
||||
accounts,
|
||||
{currency: deviceCurrency},
|
||||
function onTickerChange (newTicker) {
|
||||
tickerPlugins[cryptoCode] = newTicker
|
||||
pollRate(cryptoCode)
|
||||
}
|
||||
)
|
||||
// TICKER [required] configure (or load)
|
||||
loadOrConfigPlugin(
|
||||
tickerPlugins[cryptoCode],
|
||||
'ticker',
|
||||
cryptoCode,
|
||||
cryptoScopedConfig,
|
||||
accounts,
|
||||
{currency: deviceCurrency},
|
||||
function onTickerChange (newTicker) {
|
||||
tickerPlugins[cryptoCode] = newTicker
|
||||
pollRate(cryptoCode)
|
||||
}
|
||||
)
|
||||
|
||||
console.log('DEBUG31.2')
|
||||
console.log('DEBUG31.2')
|
||||
|
||||
// Give each crypto a different derived seed so as not to allow any
|
||||
// plugin to spend another plugin's funds
|
||||
const cryptoSeed = hkdf.derive(cryptoCode, 32)
|
||||
// Give each crypto a different derived seed so as not to allow any
|
||||
// plugin to spend another plugin's funds
|
||||
const cryptoSeed = hkdf.derive(cryptoCode, 32)
|
||||
|
||||
loadOrConfigPlugin(
|
||||
walletPlugins[cryptoCode],
|
||||
'wallet',
|
||||
cryptoCode,
|
||||
cryptoScopedConfig,
|
||||
accounts,
|
||||
{masterSeed: cryptoSeed},
|
||||
function onWalletChange (newWallet) {
|
||||
walletPlugins[cryptoCode] = newWallet
|
||||
pollBalance(cryptoCode)
|
||||
}
|
||||
)
|
||||
loadOrConfigPlugin(
|
||||
walletPlugins[cryptoCode],
|
||||
'wallet',
|
||||
cryptoCode,
|
||||
cryptoScopedConfig,
|
||||
accounts,
|
||||
{masterSeed: cryptoSeed},
|
||||
function onWalletChange (newWallet) {
|
||||
walletPlugins[cryptoCode] = newWallet
|
||||
pollBalance(cryptoCode)
|
||||
}
|
||||
)
|
||||
|
||||
tradesQueues[cryptoCode] = tradesQueues[cryptoCode] || []
|
||||
tradesQueues[cryptoCode] = tradesQueues[cryptoCode] || []
|
||||
|
||||
loadOrConfigPlugin(
|
||||
traderPlugins[cryptoCode],
|
||||
'trader',
|
||||
cryptoCode,
|
||||
cryptoScopedConfig,
|
||||
accounts,
|
||||
loadOrConfigPlugin(
|
||||
traderPlugins[cryptoCode],
|
||||
'trader',
|
||||
cryptoCode,
|
||||
cryptoScopedConfig,
|
||||
accounts,
|
||||
null,
|
||||
function onTraderChange (newTrader) {
|
||||
traderPlugins[cryptoCode] = newTrader
|
||||
if (newTrader === null) stopTrader(cryptoCode)
|
||||
else startTrader(cryptoCode)
|
||||
}
|
||||
)
|
||||
})
|
||||
|
||||
const unscopedCfg = configManager.unscoped(cachedConfig)
|
||||
|
||||
// ID VERIFIER [optional] configure (or load)
|
||||
idVerifierPlugin = loadOrConfigPlugin(
|
||||
idVerifierPlugin,
|
||||
'idVerifier',
|
||||
null,
|
||||
function onTraderChange (newTrader) {
|
||||
traderPlugins[cryptoCode] = newTrader
|
||||
if (newTrader === null) stopTrader(cryptoCode)
|
||||
else startTrader(cryptoCode)
|
||||
}
|
||||
unscopedCfg,
|
||||
accounts
|
||||
)
|
||||
|
||||
emailPlugin = loadOrConfigPlugin(
|
||||
emailPlugin,
|
||||
'email',
|
||||
null,
|
||||
unscopedCfg,
|
||||
accounts
|
||||
)
|
||||
|
||||
smsPlugin = loadOrConfigPlugin(
|
||||
smsPlugin,
|
||||
'sms',
|
||||
null,
|
||||
unscopedCfg,
|
||||
accounts
|
||||
)
|
||||
})
|
||||
|
||||
const unscopedCfg = configManager.unscoped(cachedConfig)
|
||||
|
||||
// ID VERIFIER [optional] configure (or load)
|
||||
idVerifierPlugin = loadOrConfigPlugin(
|
||||
idVerifierPlugin,
|
||||
'idVerifier',
|
||||
null,
|
||||
unscopedCfg,
|
||||
accounts
|
||||
)
|
||||
|
||||
emailPlugin = loadOrConfigPlugin(
|
||||
emailPlugin,
|
||||
'email',
|
||||
null,
|
||||
unscopedCfg,
|
||||
accounts
|
||||
)
|
||||
|
||||
smsPlugin = loadOrConfigPlugin(
|
||||
smsPlugin,
|
||||
'sms',
|
||||
null,
|
||||
unscopedCfg,
|
||||
accounts
|
||||
)
|
||||
|
||||
console.log('DEBUG33')
|
||||
}
|
||||
|
||||
function getConfig (machineId) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue