diff --git a/components/Accounts.tsx b/components/Accounts.tsx index 4d05944..eaa96ab 100644 --- a/components/Accounts.tsx +++ b/components/Accounts.tsx @@ -6,7 +6,7 @@ import { useNavigation } from '@react-navigation/native'; import { NativeStackNavigationProp } from '@react-navigation/native-stack'; import { AccountsProps, StackParamsList, Account } from '../types'; -import { addAccount } from '../utils'; +import { addAccount } from '../utils/Accounts'; import styles from '../styles/stylesheet'; import HDPathDialog from './HDPathDialog'; @@ -23,6 +23,7 @@ const Accounts: React.FC = ({ const [expanded, setExpanded] = useState(false); const [isAccountCreating, setIsAccountCreating] = useState(false); const [hdDialog, setHdDialog] = useState(false); + const [pathCode, setPathCode] = useState(''); const handlePress = () => setExpanded(!expanded); @@ -67,6 +68,7 @@ const Accounts: React.FC = ({ hideDialog={() => setHdDialog(false)} updateAccounts={updateAccounts} updateIndex={updateId} + pathCode={pathCode} // Pass pathCode here /> = ({ mode="contained" onPress={() => { setHdDialog(true); + switch (network) { + case 'eth': + setPathCode("m/44'/60'/"); + break; + case 'cosmos': + setPathCode("m/44'/118'/"); + break; + default: + setPathCode(''); + } }}> Add Account from HD path diff --git a/components/HDPath.tsx b/components/HDPath.tsx index f3cb123..1e66efe 100644 --- a/components/HDPath.tsx +++ b/components/HDPath.tsx @@ -1,15 +1,16 @@ import React, { useState } from 'react'; -import { ScrollView, View } from 'react-native'; +import { ScrollView, View, Text } from 'react-native'; import { Button, TextInput } from 'react-native-paper'; - -import { addAccountFromHDPath } from '../utils'; +import { addAccountFromHDPath } from '../utils/Accounts'; import { Account } from '../types'; const HDPath = ({ + pathCode, updateAccounts, updateIndex, hideDialog, }: { + pathCode: string; updateIndex: (index: number) => void; updateAccounts: (account: Account) => void; hideDialog: () => void; @@ -19,7 +20,8 @@ const HDPath = ({ const createFromHDPathHandler = async () => { setIsAccountCreating(true); - const newAccount = await addAccountFromHDPath(path); + const hdPath = pathCode + path; + const newAccount = await addAccountFromHDPath(hdPath); setIsAccountCreating(false); if (newAccount) { @@ -31,11 +33,17 @@ const HDPath = ({ return ( - setPath(text)} - value={path} - /> + + + {pathCode} + + setPath(text)} + value={path} + style={{ flex: 1 }} + /> +