Skip to content
This repository has been archived by the owner on May 24, 2022. It is now read-only.

Commit

Permalink
review-fix: Rename function name that matches current chain id with i…
Browse files Browse the repository at this point in the history
…mported chain id of address
  • Loading branch information
Luke Schoen committed Apr 8, 2019
1 parent 20e3088 commit de3396f
Showing 1 changed file with 10 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -144,12 +144,12 @@ class AccountImportOptions extends Component {
return;
}

const signerChainId = parseInt(chainIdString);
const signerChainIdInt = parseInt(chainIdString);

if (!this.isCurrentChainIdTheAddressForImportChainId(signerChainId)) {
if (!this.isCurrentChainIdTheImportChainIdOfTheAddress(signerChainIdInt)) {
console.error(
`Parity Signer account chainId ${chainIdString} (${
PARITY_SIGNER_NETWORKS[signerChainId].parityName
PARITY_SIGNER_NETWORKS[signerChainIdInt].parityName
}) must match current chainId ${currentChainIdBN.valueOf()} (${chainName}).`
);

Expand All @@ -161,11 +161,11 @@ class AccountImportOptions extends Component {
return;
}

if (this.hasExistingAddressForImport(address, signerChainId)) {
if (this.hasExistingAddressForImport(address, signerChainIdInt)) {
return;
}

await importFromSigner({ address, signerChainId });
await importFromSigner({ address, signerChainIdInt });

this.handleNextStep();
};
Expand All @@ -176,20 +176,20 @@ class AccountImportOptions extends Component {
});
};

isCurrentChainIdTheAddressForImportChainId = chainIdInt => {
isCurrentChainIdTheImportChainIdOfTheAddress = signerChainIdInt => {
const { chainId: currentChainIdBN } = this.props;

return BigNumber(chainIdInt).eq(currentChainIdBN);
return BigNumber(signerChainIdInt).eq(currentChainIdBN);
};

hasExistingAddressForImport = (addressForImport, chainIdInt) => {
hasExistingAddressForImport = (addressForImport, signerChainIdInt) => {
const { accountsInfo } = this.props;
const isExistingAddress = Object.keys(accountsInfo).some(
key =>
key.toLowerCase() === addressForImport.toLowerCase() &&
(!accountsInfo[key].chainId ||
!chainIdInt ||
accountsInfo[key].chainId === chainIdInt)
!signerChainIdInt ||
accountsInfo[key].chainId === signerChainIdInt)
);

if (isExistingAddress) {
Expand Down

0 comments on commit de3396f

Please sign in to comment.