feat: migrate fee discount config field for each installed coin
This commit is contained in:
parent
d6771840bd
commit
32f79bc450
3 changed files with 11 additions and 16 deletions
|
|
@ -60,22 +60,15 @@ function _balance (settings, cryptoCode) {
|
||||||
function sendCoins (settings, tx) {
|
function sendCoins (settings, tx) {
|
||||||
return fetchWallet(settings, tx.cryptoCode)
|
return fetchWallet(settings, tx.cryptoCode)
|
||||||
.then(r => {
|
.then(r => {
|
||||||
if (tx.cryptoCode === 'BTC') {
|
|
||||||
return loadLatestConfig()
|
return loadLatestConfig()
|
||||||
.then(config => {
|
.then(config => {
|
||||||
const feeDiscount = config.wallets_BTC_feeDiscount
|
const feeMultiplier = config[`wallets_${tx.cryptoCode}_feeMultiplier`]
|
||||||
return r.wallet.sendCoins(r.account, tx, settings, r.operatorId, feeDiscount)
|
return r.wallet.sendCoins(r.account, tx, settings, r.operatorId, feeMultiplier)
|
||||||
})
|
})
|
||||||
.then(res => {
|
.then(res => {
|
||||||
mem.clear(module.exports.balance)
|
mem.clear(module.exports.balance)
|
||||||
return res
|
return res
|
||||||
})
|
})
|
||||||
}
|
|
||||||
return r.wallet.sendCoins(r.account, tx, settings, r.operatorId)
|
|
||||||
.then(res => {
|
|
||||||
mem.clear(module.exports.balance)
|
|
||||||
return res
|
|
||||||
})
|
|
||||||
})
|
})
|
||||||
.catch(err => {
|
.catch(err => {
|
||||||
if (err.name === INSUFFICIENT_FUNDS_NAME) {
|
if (err.name === INSUFFICIENT_FUNDS_NAME) {
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,13 @@
|
||||||
|
const _ = require('lodash/fp')
|
||||||
const { saveConfig, loadLatest } = require('../lib/new-settings-loader')
|
const { saveConfig, loadLatest } = require('../lib/new-settings-loader')
|
||||||
|
const { getCryptosFromWalletNamespace } = require('../lib/new-config-manager')
|
||||||
|
|
||||||
exports.up = function (next) {
|
exports.up = function (next) {
|
||||||
const newConfig = {
|
const newConfig = {}
|
||||||
wallets_BTC_feeDiscount: '1'
|
|
||||||
}
|
|
||||||
return loadLatest()
|
return loadLatest()
|
||||||
.then(config => {
|
.then(config => {
|
||||||
|
const coins = getCryptosFromWalletNamespace(config)
|
||||||
|
_.map(coin => { newConfig[`wallets_${coin}_feeMultiplier`] = '1' }, coins)
|
||||||
return saveConfig(newConfig)
|
return saveConfig(newConfig)
|
||||||
})
|
})
|
||||||
.then(next)
|
.then(next)
|
||||||
|
|
|
||||||
|
|
@ -227,7 +227,7 @@ const Wallet = ({ name: SCREEN_KEY }) => {
|
||||||
<DialogActions className={classes.actions}>
|
<DialogActions className={classes.actions}>
|
||||||
<Button
|
<Button
|
||||||
onClick={() =>
|
onClick={() =>
|
||||||
saveFeeDiscount({ BTC_feeDiscount: selectedDiscount })
|
saveFeeDiscount({ BTC_feeMultiplier: selectedDiscount })
|
||||||
}>
|
}>
|
||||||
Confirm
|
Confirm
|
||||||
</Button>
|
</Button>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue