mirror of
https://github.com/status-im/MyCrypto.git
synced 2025-02-02 14:23:42 +00:00
Get non web3 node switching working
This commit is contained in:
parent
46cbade177
commit
74e3cce1d8
@ -195,7 +195,7 @@ class Header extends Component<Props, State> {
|
|||||||
</li>
|
</li>
|
||||||
}
|
}
|
||||||
disabled={nodeSelection === 'web3'}
|
disabled={nodeSelection === 'web3'}
|
||||||
onChange={changeNodeIntent}
|
onChange={this.props.changeNodeIntent}
|
||||||
size="smr"
|
size="smr"
|
||||||
color="white"
|
color="white"
|
||||||
menuAlign="right"
|
menuAlign="right"
|
||||||
|
@ -47,9 +47,9 @@ import {
|
|||||||
WalletName,
|
WalletName,
|
||||||
knowledgeBaseURL
|
knowledgeBaseURL
|
||||||
} from 'config';
|
} from 'config';
|
||||||
import { unSupportedWalletFormatsOnNetwork } from 'utils/network';
|
import { getOffline } from '../../selectors/config';
|
||||||
import { getNetworkConfig, getOffline } from '../../selectors/config';
|
|
||||||
import { isWeb3NodeAvailable } from 'libs/nodes/web3';
|
import { isWeb3NodeAvailable } from 'libs/nodes/web3';
|
||||||
|
import { unSupportedWalletFormatsOnNetwork } from 'selectors/config/wallet';
|
||||||
|
|
||||||
interface OwnProps {
|
interface OwnProps {
|
||||||
hidden?: boolean;
|
hidden?: boolean;
|
||||||
@ -436,8 +436,7 @@ export class WalletDecrypt extends Component<Props, State> {
|
|||||||
|
|
||||||
function mapStateToProps(state: AppState, ownProps: Props) {
|
function mapStateToProps(state: AppState, ownProps: Props) {
|
||||||
const { disabledWallets } = ownProps;
|
const { disabledWallets } = ownProps;
|
||||||
const network = getNetworkConfig(state);
|
const networkDisabledFormats = unSupportedWalletFormatsOnNetwork(state);
|
||||||
const networkDisabledFormats = unSupportedWalletFormatsOnNetwork(network);
|
|
||||||
const computedDisabledWallets = disabledWallets
|
const computedDisabledWallets = disabledWallets
|
||||||
? disabledWallets.concat(networkDisabledFormats)
|
? disabledWallets.concat(networkDisabledFormats)
|
||||||
: networkDisabledFormats;
|
: networkDisabledFormats;
|
||||||
|
@ -7,9 +7,8 @@ import ledger from 'ledgerco';
|
|||||||
import { Spinner } from 'components/ui';
|
import { Spinner } from 'components/ui';
|
||||||
import { connect } from 'react-redux';
|
import { connect } from 'react-redux';
|
||||||
import { AppState } from 'reducers';
|
import { AppState } from 'reducers';
|
||||||
import { getNetworkConfig } from 'selectors/config';
|
|
||||||
import { SecureWalletName } from 'config';
|
import { SecureWalletName } from 'config';
|
||||||
import { getPaths, getSingleDPath } from 'utils/network';
|
import { getPaths, getSingleDPath } from 'selectors/config/wallet';
|
||||||
|
|
||||||
interface OwnProps {
|
interface OwnProps {
|
||||||
onUnlock(param: any): void;
|
onUnlock(param: any): void;
|
||||||
@ -17,6 +16,7 @@ interface OwnProps {
|
|||||||
|
|
||||||
interface StateProps {
|
interface StateProps {
|
||||||
dPath: DPath;
|
dPath: DPath;
|
||||||
|
dPaths: DPath[];
|
||||||
}
|
}
|
||||||
|
|
||||||
interface State {
|
interface State {
|
||||||
@ -122,7 +122,7 @@ class LedgerNanoSDecryptClass extends Component<Props, State> {
|
|||||||
publicKey={publicKey}
|
publicKey={publicKey}
|
||||||
chainCode={chainCode}
|
chainCode={chainCode}
|
||||||
dPath={dPath}
|
dPath={dPath}
|
||||||
dPaths={getPaths(SecureWalletName.LEDGER_NANO_S)}
|
dPaths={this.props.dPaths}
|
||||||
onCancel={this.handleCancel}
|
onCancel={this.handleCancel}
|
||||||
onConfirmAddress={this.handleUnlock}
|
onConfirmAddress={this.handleUnlock}
|
||||||
onPathChange={this.handlePathChange}
|
onPathChange={this.handlePathChange}
|
||||||
@ -188,9 +188,9 @@ class LedgerNanoSDecryptClass extends Component<Props, State> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function mapStateToProps(state: AppState): StateProps {
|
function mapStateToProps(state: AppState): StateProps {
|
||||||
const network = getNetworkConfig(state);
|
|
||||||
return {
|
return {
|
||||||
dPath: getSingleDPath(SecureWalletName.LEDGER_NANO_S, network)
|
dPath: getSingleDPath(state, SecureWalletName.LEDGER_NANO_S),
|
||||||
|
dPaths: getPaths(state, SecureWalletName.LEDGER_NANO_S)
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5,9 +5,8 @@ import DeterministicWalletsModal from './DeterministicWalletsModal';
|
|||||||
import { formatMnemonic } from 'utils/formatters';
|
import { formatMnemonic } from 'utils/formatters';
|
||||||
import { InsecureWalletName } from 'config';
|
import { InsecureWalletName } from 'config';
|
||||||
import { AppState } from 'reducers';
|
import { AppState } from 'reducers';
|
||||||
import { getNetworkConfig } from 'selectors/config';
|
|
||||||
import { connect } from 'react-redux';
|
import { connect } from 'react-redux';
|
||||||
import { getPaths, getSingleDPath } from 'utils/network';
|
import { getSingleDPath, getPaths } from 'selectors/config/wallet';
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
onUnlock(param: any): void;
|
onUnlock(param: any): void;
|
||||||
@ -15,6 +14,7 @@ interface Props {
|
|||||||
|
|
||||||
interface StateProps {
|
interface StateProps {
|
||||||
dPath: DPath;
|
dPath: DPath;
|
||||||
|
dPaths: DPath[];
|
||||||
}
|
}
|
||||||
|
|
||||||
interface State {
|
interface State {
|
||||||
@ -77,7 +77,7 @@ class MnemonicDecryptClass extends Component<Props & StateProps, State> {
|
|||||||
isOpen={!!seed}
|
isOpen={!!seed}
|
||||||
seed={seed}
|
seed={seed}
|
||||||
dPath={dPath}
|
dPath={dPath}
|
||||||
dPaths={getPaths(InsecureWalletName.MNEMONIC_PHRASE)}
|
dPaths={this.props.dPaths}
|
||||||
onCancel={this.handleCancel}
|
onCancel={this.handleCancel}
|
||||||
onConfirmAddress={this.handleUnlock}
|
onConfirmAddress={this.handleUnlock}
|
||||||
onPathChange={this.handlePathChange}
|
onPathChange={this.handlePathChange}
|
||||||
@ -144,9 +144,9 @@ class MnemonicDecryptClass extends Component<Props & StateProps, State> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function mapStateToProps(state: AppState): StateProps {
|
function mapStateToProps(state: AppState): StateProps {
|
||||||
const network = getNetworkConfig(state);
|
|
||||||
return {
|
return {
|
||||||
dPath: getSingleDPath(InsecureWalletName.MNEMONIC_PHRASE, network)
|
dPath: getSingleDPath(state, InsecureWalletName.MNEMONIC_PHRASE),
|
||||||
|
dPaths: getPaths(state, InsecureWalletName.MNEMONIC_PHRASE)
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5,11 +5,10 @@ import TrezorConnect from 'vendor/trezor-connect';
|
|||||||
import DeterministicWalletsModal from './DeterministicWalletsModal';
|
import DeterministicWalletsModal from './DeterministicWalletsModal';
|
||||||
import './Trezor.scss';
|
import './Trezor.scss';
|
||||||
import { Spinner } from 'components/ui';
|
import { Spinner } from 'components/ui';
|
||||||
import { getNetworkConfig } from 'selectors/config';
|
|
||||||
import { AppState } from 'reducers';
|
import { AppState } from 'reducers';
|
||||||
import { connect } from 'react-redux';
|
import { connect } from 'react-redux';
|
||||||
import { SecureWalletName } from 'config';
|
import { SecureWalletName } from 'config';
|
||||||
import { getPaths, getSingleDPath } from 'utils/network';
|
import { getSingleDPath, getPaths } from 'selectors/config/wallet';
|
||||||
|
|
||||||
//todo: conflicts with comment in walletDecrypt -> onUnlock method
|
//todo: conflicts with comment in walletDecrypt -> onUnlock method
|
||||||
interface OwnProps {
|
interface OwnProps {
|
||||||
@ -18,6 +17,7 @@ interface OwnProps {
|
|||||||
|
|
||||||
interface StateProps {
|
interface StateProps {
|
||||||
dPath: DPath;
|
dPath: DPath;
|
||||||
|
dPaths: DPath[];
|
||||||
}
|
}
|
||||||
|
|
||||||
// todo: nearly duplicates ledger component props
|
// todo: nearly duplicates ledger component props
|
||||||
@ -88,7 +88,7 @@ class TrezorDecryptClass extends Component<Props, State> {
|
|||||||
publicKey={publicKey}
|
publicKey={publicKey}
|
||||||
chainCode={chainCode}
|
chainCode={chainCode}
|
||||||
dPath={dPath}
|
dPath={dPath}
|
||||||
dPaths={getPaths(SecureWalletName.TREZOR)}
|
dPaths={this.props.dPaths}
|
||||||
onCancel={this.handleCancel}
|
onCancel={this.handleCancel}
|
||||||
onConfirmAddress={this.handleUnlock}
|
onConfirmAddress={this.handleUnlock}
|
||||||
onPathChange={this.handlePathChange}
|
onPathChange={this.handlePathChange}
|
||||||
@ -151,9 +151,9 @@ class TrezorDecryptClass extends Component<Props, State> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function mapStateToProps(state: AppState): StateProps {
|
function mapStateToProps(state: AppState): StateProps {
|
||||||
const network = getNetworkConfig(state);
|
|
||||||
return {
|
return {
|
||||||
dPath: getSingleDPath(SecureWalletName.TREZOR, network)
|
dPath: getSingleDPath(state, SecureWalletName.TREZOR),
|
||||||
|
dPaths: getPaths(state, SecureWalletName.TREZOR)
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -14,10 +14,8 @@ import {
|
|||||||
UnavailableWallets
|
UnavailableWallets
|
||||||
} from 'containers/Tabs/SendTransaction/components';
|
} from 'containers/Tabs/SendTransaction/components';
|
||||||
import SubTabs, { Tab } from 'components/SubTabs';
|
import SubTabs, { Tab } from 'components/SubTabs';
|
||||||
import { getNetworkConfig } from 'selectors/config';
|
|
||||||
import { isNetworkUnit } from 'utils/network';
|
|
||||||
import { RouteNotFound } from 'components/RouteNotFound';
|
import { RouteNotFound } from 'components/RouteNotFound';
|
||||||
import { NetworkConfig } from 'types/network';
|
import { isNetworkUnit } from 'selectors/config/wallet';
|
||||||
|
|
||||||
const Send = () => (
|
const Send = () => (
|
||||||
<React.Fragment>
|
<React.Fragment>
|
||||||
@ -28,7 +26,7 @@ const Send = () => (
|
|||||||
|
|
||||||
interface StateProps {
|
interface StateProps {
|
||||||
wallet: AppState['wallet']['inst'];
|
wallet: AppState['wallet']['inst'];
|
||||||
network: NetworkConfig;
|
requestDisabled: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
type Props = StateProps & RouteComponentProps<{}>;
|
type Props = StateProps & RouteComponentProps<{}>;
|
||||||
@ -46,7 +44,7 @@ class SendTransaction extends React.Component<Props> {
|
|||||||
{
|
{
|
||||||
path: 'request',
|
path: 'request',
|
||||||
name: translate('Request Payment'),
|
name: translate('Request Payment'),
|
||||||
disabled: !isNetworkUnit(this.props.network, 'ETH')
|
disabled: this.props.requestDisabled
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: 'info',
|
path: 'info',
|
||||||
@ -100,5 +98,5 @@ class SendTransaction extends React.Component<Props> {
|
|||||||
|
|
||||||
export default connect((state: AppState) => ({
|
export default connect((state: AppState) => ({
|
||||||
wallet: getWalletInst(state),
|
wallet: getWalletInst(state),
|
||||||
network: getNetworkConfig(state)
|
requestDisabled: !isNetworkUnit(state, 'ETH')
|
||||||
}))(SendTransaction);
|
}))(SendTransaction);
|
||||||
|
@ -8,6 +8,7 @@ const initalNode =
|
|||||||
INITIAL_DEFAULT_NODE_STATE[INITIAL_NODE_STATE.nodeId as keyof NonWeb3NodeConfigs];
|
INITIAL_DEFAULT_NODE_STATE[INITIAL_NODE_STATE.nodeId as keyof NonWeb3NodeConfigs];
|
||||||
|
|
||||||
export type State = string | StaticNetworkIds;
|
export type State = string | StaticNetworkIds;
|
||||||
|
|
||||||
const INITIAL_STATE: State = initalNode.network;
|
const INITIAL_STATE: State = initalNode.network;
|
||||||
|
|
||||||
const handleNodeChange = (_: State, { payload }: ChangeNodeAction) => payload.networkId;
|
const handleNodeChange = (_: State, { payload }: ChangeNodeAction) => payload.networkId;
|
||||||
@ -17,6 +18,6 @@ export const selectedNetwork = (state: State = INITIAL_STATE, action: NodeAction
|
|||||||
case TypeKeys.CONFIG_NODE_CHANGE:
|
case TypeKeys.CONFIG_NODE_CHANGE:
|
||||||
return handleNodeChange(state, action);
|
return handleNodeChange(state, action);
|
||||||
default:
|
default:
|
||||||
break;
|
return state;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -37,8 +37,8 @@ const INITIAL_STATE: State = {
|
|||||||
name: ethPlorer,
|
name: ethPlorer,
|
||||||
address: ETHTokenExplorer
|
address: ETHTokenExplorer
|
||||||
},
|
},
|
||||||
tokens: require('./tokens/eth.json'),
|
tokens: require('config/tokens/eth.json'),
|
||||||
contracts: require('./contracts/eth.json'),
|
contracts: require('config/contracts/eth.json'),
|
||||||
dPathFormats: {
|
dPathFormats: {
|
||||||
[SecureWalletName.TREZOR]: ETH_TREZOR,
|
[SecureWalletName.TREZOR]: ETH_TREZOR,
|
||||||
[SecureWalletName.LEDGER_NANO_S]: ETH_LEDGER,
|
[SecureWalletName.LEDGER_NANO_S]: ETH_LEDGER,
|
||||||
@ -52,8 +52,8 @@ const INITIAL_STATE: State = {
|
|||||||
isCustom: false,
|
isCustom: false,
|
||||||
color: '#adc101',
|
color: '#adc101',
|
||||||
blockExplorer: makeExplorer('https://ropsten.etherscan.io'),
|
blockExplorer: makeExplorer('https://ropsten.etherscan.io'),
|
||||||
tokens: require('./tokens/ropsten.json'),
|
tokens: require('config/tokens/ropsten.json'),
|
||||||
contracts: require('./contracts/ropsten.json'),
|
contracts: require('config/contracts/ropsten.json'),
|
||||||
isTestnet: true,
|
isTestnet: true,
|
||||||
dPathFormats: {
|
dPathFormats: {
|
||||||
[SecureWalletName.TREZOR]: ETH_TESTNET,
|
[SecureWalletName.TREZOR]: ETH_TESTNET,
|
||||||
@ -68,8 +68,8 @@ const INITIAL_STATE: State = {
|
|||||||
isCustom: false,
|
isCustom: false,
|
||||||
color: '#adc101',
|
color: '#adc101',
|
||||||
blockExplorer: makeExplorer('https://kovan.etherscan.io'),
|
blockExplorer: makeExplorer('https://kovan.etherscan.io'),
|
||||||
tokens: require('./tokens/ropsten.json'),
|
tokens: require('config/tokens/ropsten.json'),
|
||||||
contracts: require('./contracts/ropsten.json'),
|
contracts: require('config/contracts/ropsten.json'),
|
||||||
isTestnet: true,
|
isTestnet: true,
|
||||||
dPathFormats: {
|
dPathFormats: {
|
||||||
[SecureWalletName.TREZOR]: ETH_TESTNET,
|
[SecureWalletName.TREZOR]: ETH_TESTNET,
|
||||||
@ -84,8 +84,8 @@ const INITIAL_STATE: State = {
|
|||||||
isCustom: false,
|
isCustom: false,
|
||||||
color: '#adc101',
|
color: '#adc101',
|
||||||
blockExplorer: makeExplorer('https://rinkeby.etherscan.io'),
|
blockExplorer: makeExplorer('https://rinkeby.etherscan.io'),
|
||||||
tokens: require('./tokens/rinkeby.json'),
|
tokens: require('config/tokens/rinkeby.json'),
|
||||||
contracts: require('./contracts/rinkeby.json'),
|
contracts: require('config/contracts/rinkeby.json'),
|
||||||
isTestnet: true,
|
isTestnet: true,
|
||||||
dPathFormats: {
|
dPathFormats: {
|
||||||
[SecureWalletName.TREZOR]: ETH_TESTNET,
|
[SecureWalletName.TREZOR]: ETH_TESTNET,
|
||||||
@ -100,8 +100,8 @@ const INITIAL_STATE: State = {
|
|||||||
isCustom: false,
|
isCustom: false,
|
||||||
color: '#669073',
|
color: '#669073',
|
||||||
blockExplorer: makeExplorer('https://gastracker.io'),
|
blockExplorer: makeExplorer('https://gastracker.io'),
|
||||||
tokens: require('./tokens/etc.json'),
|
tokens: require('config/tokens/etc.json'),
|
||||||
contracts: require('./contracts/etc.json'),
|
contracts: require('config/contracts/etc.json'),
|
||||||
dPathFormats: {
|
dPathFormats: {
|
||||||
[SecureWalletName.TREZOR]: ETC_TREZOR,
|
[SecureWalletName.TREZOR]: ETC_TREZOR,
|
||||||
[SecureWalletName.LEDGER_NANO_S]: ETC_LEDGER,
|
[SecureWalletName.LEDGER_NANO_S]: ETC_LEDGER,
|
||||||
@ -115,8 +115,8 @@ const INITIAL_STATE: State = {
|
|||||||
isCustom: false,
|
isCustom: false,
|
||||||
color: '#b37aff',
|
color: '#b37aff',
|
||||||
blockExplorer: makeExplorer('https://ubiqscan.io/en'),
|
blockExplorer: makeExplorer('https://ubiqscan.io/en'),
|
||||||
tokens: require('./tokens/ubq.json'),
|
tokens: require('config/tokens/ubq.json'),
|
||||||
contracts: require('./contracts/ubq.json'),
|
contracts: require('config/contracts/ubq.json'),
|
||||||
dPathFormats: {
|
dPathFormats: {
|
||||||
[SecureWalletName.TREZOR]: UBQ_DEFAULT,
|
[SecureWalletName.TREZOR]: UBQ_DEFAULT,
|
||||||
[SecureWalletName.LEDGER_NANO_S]: UBQ_DEFAULT,
|
[SecureWalletName.LEDGER_NANO_S]: UBQ_DEFAULT,
|
||||||
@ -130,8 +130,8 @@ const INITIAL_STATE: State = {
|
|||||||
isCustom: false,
|
isCustom: false,
|
||||||
color: '#673ab7',
|
color: '#673ab7',
|
||||||
blockExplorer: makeExplorer('http://www.gander.tech'),
|
blockExplorer: makeExplorer('http://www.gander.tech'),
|
||||||
tokens: require('./tokens/exp.json'),
|
tokens: require('config/tokens/exp.json'),
|
||||||
contracts: require('./contracts/exp.json'),
|
contracts: require('config/contracts/exp.json'),
|
||||||
dPathFormats: {
|
dPathFormats: {
|
||||||
[SecureWalletName.TREZOR]: EXP_DEFAULT,
|
[SecureWalletName.TREZOR]: EXP_DEFAULT,
|
||||||
[SecureWalletName.LEDGER_NANO_S]: EXP_DEFAULT,
|
[SecureWalletName.LEDGER_NANO_S]: EXP_DEFAULT,
|
||||||
|
@ -18,7 +18,7 @@ export const INITIAL_STATE: NodeLoaded = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const changeNode = (_: State, { payload }: ChangeNodeAction): State => ({
|
const changeNode = (_: State, { payload }: ChangeNodeAction): State => ({
|
||||||
nodeId: payload.networkId,
|
nodeId: payload.nodeId,
|
||||||
pending: false
|
pending: false
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -143,7 +143,7 @@ export function* handleNodeChangeIntent({
|
|||||||
let timeout;
|
let timeout;
|
||||||
try {
|
try {
|
||||||
const { lb, to } = yield race({
|
const { lb, to } = yield race({
|
||||||
lb: apply(nextNodeConfig, nextNodeConfig.lib.getCurrentBlock),
|
lb: apply(nextNodeConfig.lib, nextNodeConfig.lib.getCurrentBlock),
|
||||||
to: call(delay, 5000)
|
to: call(delay, 5000)
|
||||||
});
|
});
|
||||||
currentBlock = lb;
|
currentBlock = lb;
|
||||||
|
@ -52,6 +52,7 @@ import { loadWalletConfig, saveWalletConfig } from 'utils/localStorage';
|
|||||||
import { getTokenBalances, filterScannedTokenBalances } from './helpers';
|
import { getTokenBalances, filterScannedTokenBalances } from './helpers';
|
||||||
import { Token } from 'types/network';
|
import { Token } from 'types/network';
|
||||||
import { Web3NodeConfig } from '../../../shared/types/node';
|
import { Web3NodeConfig } from '../../../shared/types/node';
|
||||||
|
import { initWeb3Node } from 'sagas/web3';
|
||||||
|
|
||||||
export interface TokenBalanceLookup {
|
export interface TokenBalanceLookup {
|
||||||
[symbol: string]: TokenBalance;
|
[symbol: string]: TokenBalance;
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
import { AppState } from 'reducers';
|
import { AppState } from 'reducers';
|
||||||
|
|
||||||
export * from './meta';
|
export * from './meta';
|
||||||
export * from './networks';
|
export * from './networks';
|
||||||
export * from './nodes';
|
export * from './nodes';
|
||||||
export * from './tokens';
|
export * from './tokens';
|
||||||
|
|
||||||
export const getConfig = (state: AppState) => state.config;
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import { AppState } from 'reducers';
|
import { AppState } from 'reducers';
|
||||||
import { getConfig } from 'sagas/config';
|
const getConfig = (state: AppState) => state.config;
|
||||||
|
|
||||||
export const getMeta = (state: AppState) => getConfig(state).meta;
|
export const getMeta = (state: AppState) => getConfig(state).meta;
|
||||||
|
|
||||||
@ -8,7 +8,8 @@ export function getOffline(state: AppState): boolean {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function getAutoGasLimitEnabled(state: AppState): boolean {
|
export function getAutoGasLimitEnabled(state: AppState): boolean {
|
||||||
return getMeta(state).autoGasLimit;
|
const meta = getMeta(state);
|
||||||
|
return meta.autoGasLimit;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getLanguageSelection(state: AppState): string {
|
export function getLanguageSelection(state: AppState): string {
|
||||||
|
@ -1,11 +1,11 @@
|
|||||||
import { AppState } from 'reducers';
|
import { AppState } from 'reducers';
|
||||||
import { getConfig } from 'selectors/config';
|
|
||||||
import {
|
import {
|
||||||
CustomNetworkConfig,
|
CustomNetworkConfig,
|
||||||
StaticNetworkConfig,
|
StaticNetworkConfig,
|
||||||
StaticNetworkIds,
|
StaticNetworkIds,
|
||||||
NetworkContract
|
NetworkContract
|
||||||
} from 'types/network';
|
} from 'types/network';
|
||||||
|
const getConfig = (state: AppState) => state.config;
|
||||||
|
|
||||||
export const getNetworks = (state: AppState) => getConfig(state).networks;
|
export const getNetworks = (state: AppState) => getConfig(state).networks;
|
||||||
|
|
||||||
|
@ -1,11 +1,19 @@
|
|||||||
import { AppState } from 'reducers';
|
import { AppState } from 'reducers';
|
||||||
import {
|
import {
|
||||||
getConfig,
|
|
||||||
getStaticNetworkConfigs,
|
getStaticNetworkConfigs,
|
||||||
getCustomNetworkConfigs,
|
getCustomNetworkConfigs,
|
||||||
isStaticNetworkId
|
isStaticNetworkId
|
||||||
} from 'selectors/config';
|
} from 'selectors/config';
|
||||||
import { CustomNodeConfig, StaticNodeConfig, StaticNodeId, Web3NodeConfig } from 'types/node';
|
import {
|
||||||
|
CustomNodeConfig,
|
||||||
|
StaticNodeConfig,
|
||||||
|
StaticNodeId,
|
||||||
|
Web3NodeConfig,
|
||||||
|
StaticNodeWithWeb3Id
|
||||||
|
} from 'types/node';
|
||||||
|
|
||||||
|
const getConfig = (state: AppState) => state.config;
|
||||||
|
|
||||||
import { INITIAL_STATE as SELECTED_NODE_INITIAL_STATE } from 'reducers/config/nodes/selectedNode';
|
import { INITIAL_STATE as SELECTED_NODE_INITIAL_STATE } from 'reducers/config/nodes/selectedNode';
|
||||||
|
|
||||||
export const getNodes = (state: AppState) => getConfig(state).nodes;
|
export const getNodes = (state: AppState) => getConfig(state).nodes;
|
||||||
@ -36,12 +44,12 @@ export const getStaticAltNodeToWeb3 = (state: AppState) => {
|
|||||||
export const getStaticNodeFromId = (state: AppState, nodeId: StaticNodeId) =>
|
export const getStaticNodeFromId = (state: AppState, nodeId: StaticNodeId) =>
|
||||||
getStaticNodeConfigs(state)[nodeId];
|
getStaticNodeConfigs(state)[nodeId];
|
||||||
|
|
||||||
export const isStaticNodeId = (state: AppState, nodeId: string): nodeId is StaticNodeId =>
|
export const isStaticNodeId = (state: AppState, nodeId: string): nodeId is StaticNodeWithWeb3Id =>
|
||||||
Object.keys(getStaticNodeConfigs(state)).includes(nodeId);
|
Object.keys(getStaticNodeConfigs(state)).includes(nodeId);
|
||||||
|
|
||||||
const getStaticNodeConfigs = (state: AppState) => getNodes(state).staticNodes;
|
const getStaticNodeConfigs = (state: AppState) => getNodes(state).staticNodes;
|
||||||
|
|
||||||
export const getStaticNodeConfig = (state: AppState): StaticNodeConfig | undefined => {
|
export const getStaticNodeConfig = (state: AppState) => {
|
||||||
const { staticNodes, selectedNode: { nodeId } } = getNodes(state);
|
const { staticNodes, selectedNode: { nodeId } } = getNodes(state);
|
||||||
|
|
||||||
const defaultNetwork = isStaticNodeId(state, nodeId) ? staticNodes[nodeId] : undefined;
|
const defaultNetwork = isStaticNodeId(state, nodeId) ? staticNodes[nodeId] : undefined;
|
||||||
@ -49,9 +57,11 @@ export const getStaticNodeConfig = (state: AppState): StaticNodeConfig | undefin
|
|||||||
};
|
};
|
||||||
|
|
||||||
export const getWeb3Node = (state: AppState): Web3NodeConfig | null => {
|
export const getWeb3Node = (state: AppState): Web3NodeConfig | null => {
|
||||||
|
const isWeb3Node = (nodeId: string, _: StaticNodeConfig | Web3NodeConfig): _ is Web3NodeConfig =>
|
||||||
|
nodeId === 'web3';
|
||||||
const currNode = getStaticNodeConfig(state);
|
const currNode = getStaticNodeConfig(state);
|
||||||
const currNodeId = getNodeId(state);
|
const currNodeId = getNodeId(state);
|
||||||
if (currNode && currNodeId && isStaticNodeId(state, currNodeId) && currNodeId === 'web3') {
|
if (currNode && currNodeId && isWeb3Node(currNodeId, currNode)) {
|
||||||
return currNode;
|
return currNode;
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
|
@ -5,6 +5,8 @@ import { SHAPESHIFT_TOKEN_WHITELIST } from 'api/shapeshift';
|
|||||||
import { getStaticNetworkConfig } from 'selectors/config';
|
import { getStaticNetworkConfig } from 'selectors/config';
|
||||||
import { Token } from 'types/network';
|
import { Token } from 'types/network';
|
||||||
|
|
||||||
|
const getConfig = (state: AppState) => state.config;
|
||||||
|
|
||||||
export function getNetworkTokens(state: AppState): Token[] {
|
export function getNetworkTokens(state: AppState): Token[] {
|
||||||
const network = getStaticNetworkConfig(state);
|
const network = getStaticNetworkConfig(state);
|
||||||
return network ? network.tokens : [];
|
return network ? network.tokens : [];
|
||||||
|
@ -2,14 +2,11 @@ import { InsecureWalletName, SecureWalletName, WalletName, walletNames } from 'c
|
|||||||
import { EXTRA_PATHS } from 'config/dpaths';
|
import { EXTRA_PATHS } from 'config/dpaths';
|
||||||
import sortedUniq from 'lodash/sortedUniq';
|
import sortedUniq from 'lodash/sortedUniq';
|
||||||
import difference from 'lodash/difference';
|
import difference from 'lodash/difference';
|
||||||
import {
|
import { StaticNetworkConfig, DPathFormats } from 'types/network';
|
||||||
CustomNetworkConfig,
|
|
||||||
StaticNetworkConfig,
|
|
||||||
NetworkConfig,
|
|
||||||
DPathFormats
|
|
||||||
} from 'types/network';
|
|
||||||
import { AppState } from 'reducers';
|
import { AppState } from 'reducers';
|
||||||
import { getStaticNetworkConfigs, getStaticNetworkConfig } from 'selectors/config';
|
import { getStaticNetworkConfigs, getStaticNetworkConfig } from 'selectors/config';
|
||||||
|
const getConfig = (state: AppState) => state.config;
|
||||||
|
|
||||||
type PathType = keyof DPathFormats;
|
type PathType = keyof DPathFormats;
|
||||||
|
|
||||||
type DPathFormat =
|
type DPathFormat =
|
||||||
|
@ -1,6 +1,9 @@
|
|||||||
import throttle from 'lodash/throttle';
|
import throttle from 'lodash/throttle';
|
||||||
import { routerMiddleware } from 'react-router-redux';
|
import { routerMiddleware } from 'react-router-redux';
|
||||||
|
|
||||||
|
/*
|
||||||
import { State as ConfigState, INITIAL_STATE as configInitialState } from 'reducers/config';
|
import { State as ConfigState, INITIAL_STATE as configInitialState } from 'reducers/config';
|
||||||
|
*/
|
||||||
import {
|
import {
|
||||||
State as CustomTokenState,
|
State as CustomTokenState,
|
||||||
INITIAL_STATE as customTokensInitialState
|
INITIAL_STATE as customTokensInitialState
|
||||||
@ -88,10 +91,11 @@ const configureStore = () => {
|
|||||||
const customTokens = dedupeCustomTokens(initialNetwork.tokens, savedCustomTokensState);
|
const customTokens = dedupeCustomTokens(initialNetwork.tokens, savedCustomTokensState);
|
||||||
*/
|
*/
|
||||||
const persistedInitialState = {
|
const persistedInitialState = {
|
||||||
|
/*
|
||||||
config: {
|
config: {
|
||||||
...configInitialState,
|
...configInitialState,
|
||||||
...savedConfigState
|
...savedConfigState
|
||||||
},
|
},*/
|
||||||
transaction: {
|
transaction: {
|
||||||
...transactionInitialState,
|
...transactionInitialState,
|
||||||
fields: {
|
fields: {
|
||||||
@ -112,10 +116,11 @@ const configureStore = () => {
|
|||||||
|
|
||||||
// if 'web3' has persisted as node selection, reset to app default
|
// if 'web3' has persisted as node selection, reset to app default
|
||||||
// necessary because web3 is only initialized as a node upon MetaMask / Mist unlock
|
// necessary because web3 is only initialized as a node upon MetaMask / Mist unlock
|
||||||
|
/*
|
||||||
if (persistedInitialState.config.nodeSelection === 'web3') {
|
if (persistedInitialState.config.nodeSelection === 'web3') {
|
||||||
persistedInitialState.config.nodeSelection = configInitialState.nodeSelection;
|
persistedInitialState.config.nodeSelection = configInitialState.nodeSelection;
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
store = createStore(RootReducer, persistedInitialState, middleware);
|
store = createStore(RootReducer, persistedInitialState, middleware);
|
||||||
|
|
||||||
// Add all of the sagas to the middleware
|
// Add all of the sagas to the middleware
|
||||||
|
@ -1,7 +1,3 @@
|
|||||||
import { InsecureWalletName, SecureWalletName, WalletName, walletNames } from 'config';
|
|
||||||
import { EXTRA_PATHS } from 'config/dpaths';
|
|
||||||
import sortedUniq from 'lodash/sortedUniq';
|
|
||||||
import difference from 'lodash/difference';
|
|
||||||
import { CustomNetworkConfig } from 'types/network';
|
import { CustomNetworkConfig } from 'types/network';
|
||||||
|
|
||||||
export function makeCustomNetworkId(config: CustomNetworkConfig): string {
|
export function makeCustomNetworkId(config: CustomNetworkConfig): string {
|
||||||
|
2
shared/types/node.d.ts
vendored
2
shared/types/node.d.ts
vendored
@ -46,6 +46,8 @@ declare enum StaticNodeId {
|
|||||||
EXP_TECH = 'exp_tech'
|
EXP_TECH = 'exp_tech'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type StaticNodeWithWeb3Id = StaticNodeId | 'web3';
|
||||||
|
|
||||||
type NonWeb3NodeConfigs = { [key in StaticNodeId]: StaticNodeConfig };
|
type NonWeb3NodeConfigs = { [key in StaticNodeId]: StaticNodeConfig };
|
||||||
|
|
||||||
interface Web3NodeConfigs {
|
interface Web3NodeConfigs {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user