Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: custom path derivation with known network #508

Merged
merged 3 commits into from
Jan 2, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 8 additions & 11 deletions src/screens/PathDerivation.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ import {
navigateToPathsList,
unlockSeedPhrase
} from '../util/navigationHelpers';
import { NETWORK_LIST, UnknownNetworkKeys } from '../constants';
import { NETWORK_LIST } from '../constants';
import { alertPathDerivationError } from '../util/alertUtils';
import testIDs from '../../e2e/testIDs';
import Separator from '../components/Separator';
Expand All @@ -43,16 +43,13 @@ function PathDerivation({ accounts, navigation }) {
const [derivationPath, setDerivationPath] = useState('');
const [keyPairsName, setKeyPairsName] = useState('');
const [isPathValid, setIsPathValid] = useState(true);
const networkKey = navigation.getParam(
'networkKey',
getNetworkKeyByPath(derivationPath)
);

const currentNetworkPath =
networkKey !== UnknownNetworkKeys.UNKNOWN
? `//${NETWORK_LIST[networkKey].pathId}`
: '';
const completePath = `${currentNetworkPath}${derivationPath}`;
const inheritNetworkKey = navigation.getParam('networkKey');
const isCustomPath = inheritNetworkKey === undefined;
const networkKey = inheritNetworkKey || getNetworkKeyByPath(derivationPath);
const currentNetworkPath = `//${NETWORK_LIST[networkKey].pathId}`;
const completePath = isCustomPath
? derivationPath
: `${currentNetworkPath}${derivationPath}`;

const onPathDerivation = async () => {
if (!validateDerivedPath(derivationPath)) {
Expand Down