1
0
mirror of https://github.com/trezor/trezor-wallet synced 2024-11-24 09:18:09 +00:00

fixed warning about different network address

This commit is contained in:
Szymon Lesisz 2018-05-10 14:24:27 +02:00
parent 8d851c5c8f
commit 9bf1f61495

View File

@ -233,18 +233,21 @@ export const validation = (): ThunkAction => {
if (state.touched.address) { if (state.touched.address) {
const accounts = getState().accounts; const accounts = getState().accounts;
const myAccount = accounts.find(a => a.address.toLowerCase() === state.address.toLowerCase()); const savedAccounts = accounts.filter(a => a.address.toLowerCase() === state.address.toLowerCase());
if (state.address.length < 1) { if (state.address.length < 1) {
errors.address = 'Address is not set'; errors.address = 'Address is not set';
} else if (!EthereumjsUtil.isValidAddress(state.address)) { } else if (!EthereumjsUtil.isValidAddress(state.address)) {
errors.address = 'Address is not valid'; errors.address = 'Address is not valid';
} else if (myAccount) { } else if (savedAccounts.length > 0) {
if (myAccount.network === accountState.network) { // check if founded account belongs to this network
infos.address = `TREZOR Address #${ (myAccount.index + 1) }`; // corner-case: when same derivation path is used on different networks
const currentNetworkAccount = savedAccounts.find(a => a.network === accountState.network);
if (currentNetworkAccount) {
infos.address = `TREZOR Address #${ (currentNetworkAccount.index + 1) }`;
} else { } else {
// TODO: load coins from config // TODO: load coins from config
warnings.address = `Looks like it's TREZOR address in Account #${ (myAccount.index + 1) } of ${ myAccount.network.toUpperCase() } network`; warnings.address = `Looks like it's TREZOR address in Account #${ (savedAccounts[0].index + 1) } of ${ savedAccounts[0].network.toUpperCase() } network`;
} }
} }
} }