Daniel Ternyak ab5fa1a799
Support Non-Ethereum Networks (#849)
* Make UnlockHeader a PureComponent

* MVP

* actually disable wallet format if not determined to be valid format for wallet

* default to correct derivation in mnemonic modal

* cleanup

* fix tslint

* use enums for HD wallet getPath

* Add stricter typing

* Fix labels not updating on selector

* Ban hardware wallet support for custom network unsupported chainIds

* Fix type error

* Fix custom node dPath not being saved

* Fix mnemonic modal

* default path bugfixes

* add react-select

* misc fixes; rabbit holing hard.

* fix tslint

* revert identicon changes

* reload on network change :/

* actually reload on network change

* really really reload on network change

* tslint fixes

* Update styles

* set table width

* fix package versioning

* push broken sagas

* Fix saga test

* fix tslint

* address round of review

* move non-selectors out to utilty; adjust reload timer

* cleanup network util comments

* manage wallet disable at WalletDecrypt instead of in both WalletDecrypt and WalletButton

* Separate WalletDecrypt props into ownProps / StateProps

* disable payment requests on non-eth networks

* specialize connect; separate props

* remove unused state prop

* remove bad import

* create tests for networks

* Clarify Lite-Send error on non-ethereum networkS

* remove string option for network config name

* Create concept of always-on 'EXTRA_PATHS'; include SINGULAR_DTV legacy dPath in 'EXTRA_PATHS'

* fix multiple imports

* address PR comments
2018-01-20 14:06:28 -06:00

59 lines
1.7 KiB
TypeScript

import React, { Component } from 'react';
import WalletDecrypt from 'components/WalletDecrypt';
import { OnlyUnlocked } from 'components/renderCbs';
import { Fields } from './Fields';
import { isUnlocked as isUnlockedSelector } from 'selectors/wallet';
import { getNetworkConfig } from 'selectors/config';
import { configureLiteSend, TConfigureLiteSend } from 'actions/swap';
import { connect } from 'react-redux';
import { AppState } from 'reducers';
import { shouldDisplayLiteSend } from 'selectors/swap';
import { NetworkConfig } from 'config';
interface DispatchProps {
configureLiteSend: TConfigureLiteSend;
}
interface StateProps {
shouldDisplay: boolean;
isUnlocked: boolean;
network: NetworkConfig;
}
type Props = StateProps & DispatchProps;
class LiteSendClass extends Component<Props> {
public componentDidMount() {
this.props.configureLiteSend();
}
public render() {
if (!this.props.shouldDisplay) {
return null;
}
const { network, isUnlocked } = this.props;
let renderMe;
if (network.chainId !== 1) {
renderMe = (
<div className="row">
<div className="col-xs-8 col-xs-push-2 text-center">
<h5>Note: Send is only supported on Ethereum Mainnet.</h5>
</div>
</div>
);
} else {
renderMe = isUnlocked ? <OnlyUnlocked whenUnlocked={<Fields />} /> : <WalletDecrypt />;
}
return <React.Fragment>{renderMe}</React.Fragment>;
}
}
export const LiteSend = connect(
(state: AppState) => ({
shouldDisplay: shouldDisplayLiteSend(state),
isUnlocked: isUnlockedSelector(state),
network: getNetworkConfig(state)
}),
{ configureLiteSend }
)(LiteSendClass);