feat: use lamassu-coins to display crypto units options
This commit is contained in:
parent
168257bcc4
commit
2ff160cc68
3 changed files with 17 additions and 12 deletions
|
|
@ -2,11 +2,11 @@ const { saveConfig } = require('../lib/new-settings-loader')
|
|||
|
||||
exports.up = function (next) {
|
||||
const cryptoUnits = {
|
||||
wallets_BTC_cryptoUnits: 'mUnits',
|
||||
wallets_ETH_cryptoUnits: 'mUnits',
|
||||
wallets_LTC_cryptoUnits: 'mUnits',
|
||||
wallets_ZEC_cryptoUnits: 'mUnits',
|
||||
wallets_BCH_cryptoUnits: 'mUnits'
|
||||
wallets_BTC_cryptoUnits: 'mili',
|
||||
wallets_ETH_cryptoUnits: 'mili',
|
||||
wallets_LTC_cryptoUnits: 'mili',
|
||||
wallets_ZEC_cryptoUnits: 'mili',
|
||||
wallets_BCH_cryptoUnits: 'mili'
|
||||
}
|
||||
|
||||
return saveConfig(cryptoUnits)
|
||||
|
|
|
|||
|
|
@ -8,6 +8,8 @@ import { fromNamespace, toNamespace, namespaces } from 'src/utils/config'
|
|||
|
||||
import { AdvancedWalletSchema, getAdvancedWalletElements } from './helper'
|
||||
|
||||
const { utils: coinUtils } = require('lamassu-coins')
|
||||
|
||||
const SAVE_CONFIG = gql`
|
||||
mutation Save($config: JSONObject, $accounts: JSONObject) {
|
||||
saveConfig(config: $config)
|
||||
|
|
@ -52,7 +54,7 @@ const AdvancedWallet = () => {
|
|||
editWidth={174}
|
||||
save={save}
|
||||
validationSchema={AdvancedWalletSchema}
|
||||
elements={getAdvancedWalletElements(cryptoCurrencies)}
|
||||
elements={getAdvancedWalletElements(cryptoCurrencies, coinUtils)}
|
||||
/>
|
||||
</>
|
||||
)
|
||||
|
|
|
|||
|
|
@ -32,13 +32,20 @@ const AdvancedWalletSchema = Yup.object().shape({
|
|||
cryptoUnits: Yup.string().required()
|
||||
})
|
||||
|
||||
const getAdvancedWalletElements = (cryptoCurrencies, config) => {
|
||||
const getAdvancedWalletElements = (cryptoCurrencies, coinUtils) => {
|
||||
const viewCryptoCurrency = it =>
|
||||
R.compose(
|
||||
R.prop(['display']),
|
||||
R.find(R.propEq('code', it))
|
||||
)(cryptoCurrencies)
|
||||
|
||||
const getOptions = R.curry((coinUtils, it) => {
|
||||
const options = R.keys(coinUtils.getCryptoCurrency(it.id).units)
|
||||
return R.map(option => {
|
||||
return { code: option, display: option }
|
||||
})(options)
|
||||
})
|
||||
|
||||
return [
|
||||
{
|
||||
name: 'id',
|
||||
|
|
@ -52,14 +59,10 @@ const getAdvancedWalletElements = (cryptoCurrencies, config) => {
|
|||
name: 'cryptoUnits',
|
||||
size: 'sm',
|
||||
stripe: true,
|
||||
view: it => it,
|
||||
width: 190,
|
||||
input: Autocomplete,
|
||||
inputProps: {
|
||||
options: [
|
||||
{ code: 'mUnits', display: 'mUnits' },
|
||||
{ code: 'fUnits', display: 'fUnits' }
|
||||
],
|
||||
options: getOptions(coinUtils),
|
||||
valueProp: 'code',
|
||||
labelProp: 'display'
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue