From 9bf1f614951877866553327cd02cc421bec83e63 Mon Sep 17 00:00:00 2001 From: Szymon Lesisz Date: Thu, 10 May 2018 14:24:27 +0200 Subject: [PATCH] fixed warning about different network address --- src/js/actions/SendFormActions.js | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/js/actions/SendFormActions.js b/src/js/actions/SendFormActions.js index d8986b48..f72feeb2 100644 --- a/src/js/actions/SendFormActions.js +++ b/src/js/actions/SendFormActions.js @@ -233,18 +233,21 @@ export const validation = (): ThunkAction => { if (state.touched.address) { 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) { errors.address = 'Address is not set'; } else if (!EthereumjsUtil.isValidAddress(state.address)) { errors.address = 'Address is not valid'; - } else if (myAccount) { - if (myAccount.network === accountState.network) { - infos.address = `TREZOR Address #${ (myAccount.index + 1) }`; + } else if (savedAccounts.length > 0) { + // check if founded account belongs to this network + // 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 { // 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`; } } }