Skip to content
Permalink
Browse files

feat(ui): ability to set defnetwork and autopilot for mainnet

resolve #2093 resolve #2091
  • Loading branch information...
korhaliv committed Apr 24, 2019
1 parent 3cd04ce commit 618e2b6ec92b9a1966a1895b7e8da5dfc630591b
@@ -31,7 +31,7 @@ module.exports = {
chain: 'bitcoin',

// Default network for new wallets.
network: 'testnet',
network: 'mainnet',

// Default settings for lnd.
lnd: {
@@ -98,10 +98,8 @@ module.exports = {
// feature flags to enable/disable experimental functionality
features: {
autopay: false,
// enables/disables mainnet as default network type when creating a wallet
mainnetAsDefault: false,
// enables/disables mainnet lnd autopilot setting
mainnetAutopilot: false,
mainnetAutopilot: true,
},

// number of onchain confirmations for the specified periods
@@ -4,6 +4,7 @@ import { Redirect } from 'react-router-dom'
import { FormattedMessage } from 'react-intl'
import { Flex, Box } from 'rebass'
import { Panel, Wizard } from 'components/UI'
import { isMainnetAutopilot } from '@zap/utils/featureFlag'
import {
Autopilot,
ConnectionType,
@@ -81,7 +82,7 @@ class Onboarding extends React.Component {
*/
removeAutopilotStepIfMainnet = formSteps => {
const { network } = this.props
if (network === 'mainnet') {
if (network === 'mainnet' && !isMainnetAutopilot()) {
const index = formSteps.findIndex(s => s.key === 'Autopilot')
if (index >= 0) {
formSteps.splice(index, 1)
@@ -2,11 +2,12 @@ import React from 'react'
import PropTypes from 'prop-types'
import { FormattedMessage } from 'react-intl'
import { Bar, Form, Header, Message, RadioGroup, Radio } from 'components/UI'
import { isMainnetAsDefault, isMainnetAutopilot } from '@zap/utils/featureFlag'
import messages from './messages'

class Network extends React.Component {
static propTypes = {
network: PropTypes.string, // eslint-disable-line react/boolean-prop-naming
network: PropTypes.string,
setAutopilot: PropTypes.func.isRequired,
setNetwork: PropTypes.func.isRequired,
wizardApi: PropTypes.object,
@@ -23,9 +24,7 @@ class Network extends React.Component {
const { network } = values
setNetwork(network)

// It is currently not recommended to use autopilot on mainnet.
// If user has selected mainnet, disable it
if (network === 'mainnet') {
if (network === 'mainnet' && !isMainnetAutopilot()) {
setAutopilot(false)
}
}
@@ -38,6 +37,20 @@ class Network extends React.Component {
const { wizardApi, wizardState, network, setNetwork, setAutopilot, ...rest } = this.props
const { getApi, onChange, onSubmit, onSubmitFailure } = wizardApi
const { currentItem } = wizardState
const networkTypes = [
<Radio
key="mainnet"
description=<FormattedMessage {...messages.network_mainnet_description} />
label={<FormattedMessage {...messages.network_mainnet} />}
value="mainnet"
/>,
<Radio
key="testnet"
description=<FormattedMessage {...messages.network_testnet_description} />
label={<FormattedMessage {...messages.network_testnet} />}
value="testnet"
/>,
]
return (
<Form
{...rest}
@@ -68,16 +81,7 @@ class Network extends React.Component {
/>
<Bar my={4} />
<RadioGroup field="network" initialValue={network} isRequired name="network">
<Radio
description=<FormattedMessage {...messages.network_testnet_description} />
label={<FormattedMessage {...messages.network_testnet} />}
value="testnet"
/>
<Radio
description=<FormattedMessage {...messages.network_mainnet_description} />
label={<FormattedMessage {...messages.network_mainnet} />}
value="mainnet"
/>
{isMainnetAsDefault() ? networkTypes : networkTypes.reverse()}
</RadioGroup>

{isMainnet && (
@@ -3,3 +3,11 @@ import config from 'config'
export function isAutopayEnabled() {
return config.features.autopay
}

export function isMainnetAsDefault() {
return config.network === 'mainnet'
}

export function isMainnetAutopilot() {
return config.features.mainnetAutopilot
}

0 comments on commit 618e2b6

Please sign in to comment.
You can’t perform that action at this time.