Merge pull request #1088 from chaotixkilla/feat-add-transaction-batching-option
Add transaction batching option to advanced wallet settings
This commit is contained in:
commit
7f4858ddd4
12 changed files with 29 additions and 74 deletions
|
|
@ -8,8 +8,6 @@ const { utils: coinUtils } = require('lamassu-coins')
|
|||
const cryptoRec = coinUtils.getCryptoCurrency('BCH')
|
||||
const unitScale = cryptoRec.unitScale
|
||||
|
||||
const SUPPORTS_BATCHING = false
|
||||
|
||||
const rpcConfig = jsonRpc.rpcConfig(cryptoRec)
|
||||
|
||||
function fetch (method, params) {
|
||||
|
|
@ -118,11 +116,6 @@ function cryptoNetwork (account, cryptoCode, settings, operatorId) {
|
|||
.then(() => parseInt(rpcConfig.port, 10) === 18332 ? 'test' : 'main')
|
||||
}
|
||||
|
||||
function supportsBatching (cryptoCode) {
|
||||
return checkCryptoCode(cryptoCode)
|
||||
.then(() => SUPPORTS_BATCHING)
|
||||
}
|
||||
|
||||
function checkBlockchainStatus (cryptoCode) {
|
||||
return checkCryptoCode(cryptoCode)
|
||||
.then(() => fetch('getblockchaininfo'))
|
||||
|
|
@ -136,6 +129,5 @@ module.exports = {
|
|||
getStatus,
|
||||
newFunding,
|
||||
cryptoNetwork,
|
||||
supportsBatching,
|
||||
checkBlockchainStatus
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,7 +9,6 @@ const { utils: coinUtils } = require('lamassu-coins')
|
|||
const cryptoRec = coinUtils.getCryptoCurrency('BTC')
|
||||
const unitScale = cryptoRec.unitScale
|
||||
|
||||
const SUPPORTS_BATCHING = true
|
||||
const rpcConfig = jsonRpc.rpcConfig(cryptoRec)
|
||||
|
||||
function fetch (method, params) {
|
||||
|
|
@ -171,11 +170,6 @@ function fetchRBF (txId) {
|
|||
})
|
||||
}
|
||||
|
||||
function supportsBatching (cryptoCode) {
|
||||
return checkCryptoCode(cryptoCode)
|
||||
.then(() => SUPPORTS_BATCHING)
|
||||
}
|
||||
|
||||
function checkBlockchainStatus (cryptoCode) {
|
||||
return checkCryptoCode(cryptoCode)
|
||||
.then(() => fetch('getblockchaininfo'))
|
||||
|
|
@ -192,6 +186,5 @@ module.exports = {
|
|||
fetchRBF,
|
||||
estimateFee,
|
||||
sendCoinsBatch,
|
||||
supportsBatching,
|
||||
checkBlockchainStatus
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,8 +14,6 @@ const NAME = 'BitGo'
|
|||
const SUPPORTED_COINS = ['BTC', 'ZEC', 'LTC', 'BCH', 'DASH']
|
||||
const BCH_CODES = ['BCH', 'TBCH']
|
||||
|
||||
const SUPPORTS_BATCHING = false
|
||||
|
||||
function buildBitgo (account) {
|
||||
const env = account.environment === 'test' ? 'test' : 'prod'
|
||||
return new BitGo.BitGo({ accessToken: account.token.trim(), env, userAgent: userAgent })
|
||||
|
|
@ -159,11 +157,6 @@ function cryptoNetwork (account, cryptoCode, settings, operatorId) {
|
|||
.then(() => account.environment === 'test' ? 'test' : 'main')
|
||||
}
|
||||
|
||||
function supportsBatching (cryptoCode) {
|
||||
return checkCryptoCode(cryptoCode)
|
||||
.then(() => SUPPORTS_BATCHING)
|
||||
}
|
||||
|
||||
function checkBlockchainStatus (cryptoCode) {
|
||||
return checkCryptoCode(cryptoCode)
|
||||
.then(() => Promise.resolve('ready'))
|
||||
|
|
@ -177,6 +170,5 @@ module.exports = {
|
|||
getStatus,
|
||||
newFunding,
|
||||
cryptoNetwork,
|
||||
supportsBatching,
|
||||
checkBlockchainStatus
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,7 +9,6 @@ const E = require('../../../error')
|
|||
const cryptoRec = coinUtils.getCryptoCurrency('DASH')
|
||||
const unitScale = cryptoRec.unitScale
|
||||
|
||||
const SUPPORTS_BATCHING = false
|
||||
const rpcConfig = jsonRpc.rpcConfig(cryptoRec)
|
||||
|
||||
function fetch (method, params) {
|
||||
|
|
@ -113,11 +112,6 @@ function newFunding (account, cryptoCode, settings, operatorId) {
|
|||
}))
|
||||
}
|
||||
|
||||
function supportsBatching (cryptoCode) {
|
||||
return checkCryptoCode(cryptoCode)
|
||||
.then(() => SUPPORTS_BATCHING)
|
||||
}
|
||||
|
||||
function checkBlockchainStatus (cryptoCode) {
|
||||
return checkCryptoCode(cryptoCode)
|
||||
.then(() => fetch('getblockchaininfo'))
|
||||
|
|
@ -130,6 +124,5 @@ module.exports = {
|
|||
newAddress,
|
||||
getStatus,
|
||||
newFunding,
|
||||
supportsBatching,
|
||||
checkBlockchainStatus
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,8 +17,6 @@ const paymentPrefixPath = "m/44'/60'/0'/0'"
|
|||
const defaultPrefixPath = "m/44'/60'/1'/0'"
|
||||
let lastUsedNonces = {}
|
||||
|
||||
const SUPPORTS_BATCHING = false
|
||||
|
||||
module.exports = {
|
||||
NAME,
|
||||
balance,
|
||||
|
|
@ -32,7 +30,6 @@ module.exports = {
|
|||
privateKey,
|
||||
isStrictAddress,
|
||||
connect,
|
||||
supportsBatching,
|
||||
checkBlockchainStatus
|
||||
}
|
||||
|
||||
|
|
@ -227,11 +224,6 @@ function newFunding (account, cryptoCode, settings, operatorId) {
|
|||
})
|
||||
}
|
||||
|
||||
function supportsBatching (cryptoCode) {
|
||||
return checkCryptoCode(cryptoCode)
|
||||
.then(() => SUPPORTS_BATCHING)
|
||||
}
|
||||
|
||||
function checkBlockchainStatus (cryptoCode) {
|
||||
return checkCryptoCode(cryptoCode)
|
||||
.then(pify(web3.eth.isSyncing))
|
||||
|
|
|
|||
|
|
@ -9,7 +9,6 @@ const E = require('../../../error')
|
|||
const cryptoRec = coinUtils.getCryptoCurrency('LTC')
|
||||
const unitScale = cryptoRec.unitScale
|
||||
|
||||
const SUPPORTS_BATCHING = false
|
||||
const rpcConfig = jsonRpc.rpcConfig(cryptoRec)
|
||||
|
||||
function fetch (method, params) {
|
||||
|
|
@ -113,11 +112,6 @@ function newFunding (account, cryptoCode, settings, operatorId) {
|
|||
}))
|
||||
}
|
||||
|
||||
function supportsBatching (cryptoCode) {
|
||||
return checkCryptoCode(cryptoCode)
|
||||
.then(() => SUPPORTS_BATCHING)
|
||||
}
|
||||
|
||||
function checkBlockchainStatus (cryptoCode) {
|
||||
return checkCryptoCode(cryptoCode)
|
||||
.then(() => fetch('getblockchaininfo'))
|
||||
|
|
@ -130,6 +124,5 @@ module.exports = {
|
|||
newAddress,
|
||||
getStatus,
|
||||
newFunding,
|
||||
supportsBatching,
|
||||
checkBlockchainStatus
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,7 +5,6 @@ const E = require('../../../error')
|
|||
const { utils: coinUtils } = require('lamassu-coins')
|
||||
|
||||
const NAME = 'FakeWallet'
|
||||
const BATCHABLE_COINS = ['BTC']
|
||||
|
||||
const SECONDS = 1000
|
||||
const PUBLISH_TIME = 3 * SECONDS
|
||||
|
|
@ -111,10 +110,6 @@ function getStatus (account, tx, requested, settings, operatorId) {
|
|||
return Promise.resolve({status: 'confirmed'})
|
||||
}
|
||||
|
||||
function supportsBatching (cryptoCode) {
|
||||
return Promise.resolve(_.includes(cryptoCode, BATCHABLE_COINS))
|
||||
}
|
||||
|
||||
function checkBlockchainStatus (cryptoCode) {
|
||||
return checkCryptoCode(cryptoCode)
|
||||
.then(() => Promise.resolve('ready'))
|
||||
|
|
@ -128,6 +123,5 @@ module.exports = {
|
|||
newAddress,
|
||||
getStatus,
|
||||
newFunding,
|
||||
supportsBatching,
|
||||
checkBlockchainStatus
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,8 +17,6 @@ const configPath = utils.configPath(cryptoRec, blockchainDir)
|
|||
const walletDir = path.resolve(utils.cryptoDir(cryptoRec, blockchainDir), 'wallets')
|
||||
const unitScale = cryptoRec.unitScale
|
||||
|
||||
const SUPPORTS_BATCHING = false
|
||||
|
||||
function rpcConfig () {
|
||||
try {
|
||||
const config = jsonRpc.parseConf(configPath)
|
||||
|
|
@ -200,11 +198,6 @@ function cryptoNetwork (account, cryptoCode) {
|
|||
})
|
||||
}
|
||||
|
||||
function supportsBatching (cryptoCode) {
|
||||
return checkCryptoCode(cryptoCode)
|
||||
.then(() => SUPPORTS_BATCHING)
|
||||
}
|
||||
|
||||
function checkBlockchainStatus (cryptoCode) {
|
||||
return checkCryptoCode(cryptoCode)
|
||||
.then(() => {
|
||||
|
|
@ -236,6 +229,5 @@ module.exports = {
|
|||
getStatus,
|
||||
newFunding,
|
||||
cryptoNetwork,
|
||||
supportsBatching,
|
||||
checkBlockchainStatus
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,7 +9,6 @@ const E = require('../../../error')
|
|||
|
||||
const cryptoRec = coinUtils.getCryptoCurrency('ZEC')
|
||||
const unitScale = cryptoRec.unitScale
|
||||
const SUPPORTS_BATCHING = false
|
||||
|
||||
const rpcConfig = jsonRpc.rpcConfig(cryptoRec)
|
||||
|
||||
|
|
@ -139,11 +138,6 @@ function newFunding (account, cryptoCode, settings, operatorId) {
|
|||
}))
|
||||
}
|
||||
|
||||
function supportsBatching (cryptoCode) {
|
||||
return checkCryptoCode(cryptoCode)
|
||||
.then(() => SUPPORTS_BATCHING)
|
||||
}
|
||||
|
||||
function checkBlockchainStatus (cryptoCode) {
|
||||
return checkCryptoCode(cryptoCode)
|
||||
.then(() => fetch('getblockchaininfo'))
|
||||
|
|
@ -156,6 +150,5 @@ module.exports = {
|
|||
newAddress,
|
||||
getStatus,
|
||||
newFunding,
|
||||
supportsBatching,
|
||||
checkBlockchainStatus
|
||||
}
|
||||
|
|
|
|||
|
|
@ -233,8 +233,7 @@ function isStrictAddress (settings, cryptoCode, toAddress) {
|
|||
}
|
||||
|
||||
function supportsBatching (settings, cryptoCode) {
|
||||
return fetchWallet(settings, cryptoCode)
|
||||
.then(r => r.wallet.supportsBatching(cryptoCode))
|
||||
return Promise.resolve(!!configManager.getWalletSettings(cryptoCode, settings.config).allowTransactionBatching)
|
||||
}
|
||||
|
||||
function checkBlockchainStatus (settings, cryptoCode) {
|
||||
|
|
|
|||
|
|
@ -7,7 +7,11 @@ import React from 'react'
|
|||
import { NamespacedTable as EditableTable } from 'src/components/editableTable'
|
||||
import { fromNamespace, toNamespace, namespaces } from 'src/utils/config'
|
||||
|
||||
import { AdvancedWalletSchema, getAdvancedWalletElements } from './helper'
|
||||
import {
|
||||
WalletSchema,
|
||||
AdvancedWalletSchema,
|
||||
getAdvancedWalletElements
|
||||
} from './helper'
|
||||
|
||||
const SAVE_CONFIG = gql`
|
||||
mutation Save($config: JSONObject, $accounts: JSONObject) {
|
||||
|
|
@ -51,8 +55,9 @@ const AdvancedWallet = () => {
|
|||
enableEdit
|
||||
editWidth={174}
|
||||
save={save}
|
||||
stripeWhen={it => !WalletSchema.isValidSync(it)}
|
||||
validationSchema={AdvancedWalletSchema}
|
||||
elements={getAdvancedWalletElements(cryptoCurrencies, coinUtils)}
|
||||
elements={getAdvancedWalletElements(cryptoCurrencies, coinUtils, config)}
|
||||
/>
|
||||
)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,8 +1,11 @@
|
|||
import * as R from 'ramda'
|
||||
import * as Yup from 'yup'
|
||||
|
||||
import { NumberInput } from 'src/components/inputs/formik'
|
||||
import Autocomplete from 'src/components/inputs/formik/Autocomplete.js'
|
||||
import {
|
||||
Autocomplete,
|
||||
Checkbox,
|
||||
NumberInput
|
||||
} from 'src/components/inputs/formik'
|
||||
import { disabledColor } from 'src/styling/variables'
|
||||
import { CURRENCY_MAX } from 'src/utils/constants'
|
||||
import { transformNumber } from 'src/utils/number'
|
||||
|
|
@ -29,10 +32,11 @@ const WalletSchema = Yup.object().shape({
|
|||
})
|
||||
|
||||
const AdvancedWalletSchema = Yup.object().shape({
|
||||
cryptoUnits: Yup.string().required()
|
||||
cryptoUnits: Yup.string().required(),
|
||||
allowTransactionBatching: Yup.boolean()
|
||||
})
|
||||
|
||||
const getAdvancedWalletElements = (cryptoCurrencies, coinUtils) => {
|
||||
const getAdvancedWalletElements = (cryptoCurrencies, coinUtils, config) => {
|
||||
const viewCryptoCurrency = it =>
|
||||
R.compose(
|
||||
R.prop(['display']),
|
||||
|
|
@ -66,6 +70,19 @@ const getAdvancedWalletElements = (cryptoCurrencies, coinUtils) => {
|
|||
valueProp: 'code',
|
||||
labelProp: 'display'
|
||||
}
|
||||
},
|
||||
{
|
||||
name: 'allowTransactionBatching',
|
||||
size: 'sm',
|
||||
stripe: true,
|
||||
width: 250,
|
||||
view: (_, ite) => {
|
||||
if (ite.id !== 'BTC')
|
||||
return <span style={classes.editDisabled}>{`No`}</span>
|
||||
return config[`${ite.id}_allowTransactionBatching`] ? 'Yes' : 'No'
|
||||
},
|
||||
input: Checkbox,
|
||||
editable: it => it.id === 'BTC'
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue