mirror of
https://github.com/status-im/MyCrypto.git
synced 2025-01-10 11:05:47 +00:00
ab5fa1a799
* 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
105 lines
2.7 KiB
TypeScript
105 lines
2.7 KiB
TypeScript
import {
|
|
CustomNetworkConfig,
|
|
CustomNodeConfig,
|
|
NetworkConfig,
|
|
NetworkContract,
|
|
NodeConfig,
|
|
Token
|
|
} from 'config';
|
|
import { INode } from 'libs/nodes/INode';
|
|
import { AppState } from 'reducers';
|
|
import { getUnit } from 'selectors/transaction/meta';
|
|
import { isEtherUnit } from 'libs/units';
|
|
import { SHAPESHIFT_TOKEN_WHITELIST } from 'api/shapeshift';
|
|
|
|
export function getNode(state: AppState): string {
|
|
return state.config.nodeSelection;
|
|
}
|
|
|
|
export function getIsWeb3Node(state: AppState): boolean {
|
|
return getNode(state) === 'web3';
|
|
}
|
|
|
|
export function getNodeConfig(state: AppState): NodeConfig {
|
|
return state.config.node;
|
|
}
|
|
|
|
export function getNodeLib(state: AppState): INode {
|
|
return getNodeConfig(state).lib;
|
|
}
|
|
|
|
export function getNetworkConfig(state: AppState): NetworkConfig {
|
|
return state.config.network;
|
|
}
|
|
|
|
export function getNetworkContracts(state: AppState): NetworkContract[] | null {
|
|
const network = getNetworkConfig(state);
|
|
return network ? network.contracts : [];
|
|
}
|
|
|
|
export function getNetworkTokens(state: AppState): Token[] {
|
|
const network = getNetworkConfig(state);
|
|
return network ? network.tokens : [];
|
|
}
|
|
|
|
export function getAllTokens(state: AppState): Token[] {
|
|
const networkTokens = getNetworkTokens(state);
|
|
return networkTokens.concat(state.customTokens);
|
|
}
|
|
|
|
export function getSelectedTokenContractAddress(state: AppState): string {
|
|
const allTokens = getAllTokens(state);
|
|
const currentUnit = getUnit(state);
|
|
|
|
if (currentUnit === 'ether') {
|
|
return '';
|
|
}
|
|
|
|
return allTokens.reduce((tokenAddr, tokenInfo) => {
|
|
if (tokenAddr && tokenAddr.length) {
|
|
return tokenAddr;
|
|
}
|
|
|
|
if (tokenInfo.symbol === currentUnit) {
|
|
return tokenInfo.address;
|
|
}
|
|
|
|
return tokenAddr;
|
|
}, '');
|
|
}
|
|
|
|
export function tokenExists(state: AppState, token: string): boolean {
|
|
const existInWhitelist = SHAPESHIFT_TOKEN_WHITELIST.includes(token);
|
|
const existsInNetwork = !!getAllTokens(state).find(t => t.symbol === token);
|
|
return existsInNetwork || existInWhitelist;
|
|
}
|
|
|
|
export function getLanguageSelection(state: AppState): string {
|
|
return state.config.languageSelection;
|
|
}
|
|
|
|
export function getCustomNodeConfigs(state: AppState): CustomNodeConfig[] {
|
|
return state.config.customNodes;
|
|
}
|
|
|
|
export function getCustomNetworkConfigs(state: AppState): CustomNetworkConfig[] {
|
|
return state.config.customNetworks;
|
|
}
|
|
|
|
export function getOffline(state: AppState): boolean {
|
|
return state.config.offline;
|
|
}
|
|
|
|
export function getAutoGasLimitEnabled(state: AppState): boolean {
|
|
return state.config.autoGasLimit;
|
|
}
|
|
|
|
export function isSupportedUnit(state: AppState, unit: string) {
|
|
const isToken: boolean = tokenExists(state, unit);
|
|
const isEther: boolean = isEtherUnit(unit);
|
|
if (!isToken && !isEther) {
|
|
return false;
|
|
}
|
|
return true;
|
|
}
|