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] create new account description #1381

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion src/components/styled/Containers.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,7 @@ export const OptionListContainer = styled.View`

export const OptionList = styled.TouchableOpacity`
background-color: ${({theme: {dark}}) => (dark ? LightBlack : Feather)};
height: 100px;
height: auto;
border-radius: 12px;
margin-bottom: ${ScreenGutter};
flex-direction: row;
Expand Down
11 changes: 8 additions & 3 deletions src/navigation/onboarding/screens/CreateKey.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ import {
showBottomNotificationModal,
} from '../../../store/app/app.actions';
import {sleep} from '../../../utils/helper-methods';
import {LogActions} from '../../../store/log';

const CreateKeyContainer = styled.SafeAreaView`
flex: 1;
Expand Down Expand Up @@ -164,11 +165,15 @@ const CreateOrImportKey = ({
key: createdKey,
}),
);
} catch (e: any) {
logger.error(e.message);
} catch (err: any) {
const errstring =
err instanceof Error ? err.message : JSON.stringify(err);
dispatch(
LogActions.error(`Error creating key: ${errstring}`),
);
dispatch(dismissOnGoingProcessModal());
await sleep(500);
showErrorModal(e.message);
showErrorModal(errstring);
}
}}>
{t('Create a Key')}
Expand Down
81 changes: 57 additions & 24 deletions src/navigation/wallet/screens/AddingOptions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,16 @@ import {Option} from './CreationOptions';
import {useTranslation} from 'react-i18next';
import {useAppDispatch, useAppSelector} from '../../../utils/hooks';
import {Analytics} from '../../../store/analytics/analytics.effects';
import {dismissOnGoingProcessModal} from '../../../store/app/app.actions';
import {
dismissOnGoingProcessModal,
showBottomNotificationModal,
} from '../../../store/app/app.actions';
import {startOnGoingProcessModal} from '../../../store/app/app.effects';
import {createMultipleWallets} from '../../../store/wallet/effects';
import {getBaseAccountCreationCoinsAndTokens} from '../../../constants/currencies';
import {successAddWallet} from '../../../store/wallet/wallet.actions';
import {LogActions} from '../../../store/log';
import {sleep} from '../../../utils/helper-methods';

export type AddingOptionsParamList = {
key: Key;
Expand All @@ -51,7 +56,7 @@ const AddingOptions: React.FC = () => {
id: 'utxo-wallet',
title: t('UTXO Wallet'),
description: t(
'Dedicated to a single cryptocurrency like Bitcoin, Bitcoin Cash, Litecoin, and Dogecoin. Perfect for users focusing on one specific coin.',
'Dedicated to a single cryptocurrency like Bitcoin, Bitcoin Cash, Litecoin, and Dogecoin. Perfect for users focusing on one specific coin',
),
cta: () => {
dispatch(
Expand All @@ -69,41 +74,69 @@ const AddingOptions: React.FC = () => {
id: 'account-based-wallet',
title: t('Account-Based Wallet'),
description: t(
'An account for Ethereum and EVM-compatible chains like Solana, Ethereum. Supports smart contracts and DeFi across multiple networks.',
'An account for Ethereum and EVM-compatible networks like Ethereum, Polygon, Base and more. This account type supports Smart Contracts, Dapps and DeFi',
),
cta: async () => {
dispatch(
Analytics.track('Clicked Create Basic Wallet', {
context: 'AddingOptions',
}),
);
const _key = key.methods as KeyMethods;
await dispatch(startOnGoingProcessModal('ADDING_ACCOUNT'));
const wallets = await dispatch(
createMultipleWallets({
key: _key,
currencies: getBaseAccountCreationCoinsAndTokens(),
options: {
network,
},
}),
);
key.wallets.push(...(wallets as Wallet[]));
try {
dispatch(
Analytics.track('Clicked Create Basic Wallet', {
context: 'AddingOptions',
}),
);
const _key = key.methods as KeyMethods;
await dispatch(startOnGoingProcessModal('ADDING_ACCOUNT'));
const wallets = await dispatch(
createMultipleWallets({
key: _key,
currencies: getBaseAccountCreationCoinsAndTokens(),
options: {
network,
},
}),
);
key.wallets.push(...(wallets as Wallet[]));

dispatch(successAddWallet({key}));
dispatch(dismissOnGoingProcessModal());
navigation.goBack();
dispatch(successAddWallet({key}));
dispatch(dismissOnGoingProcessModal());
navigation.goBack();
} catch (err) {
const errstring =
err instanceof Error ? err.message : JSON.stringify(err);
dispatch(LogActions.error(`Error adding account: ${errstring}`));
dispatch(dismissOnGoingProcessModal());
await sleep(1000);
showErrorModal(errstring);
}
},
},
{
id: 'multisig-wallet',
title: t('Multisig Wallet'),
description: t(
'Requires multiple approvals for transactions for wallets like Bitcoin, Bitcoin Cash, Litecoin, and Dogecoin. Ideal for shared funds or enhanced security.',
'Requires multiple approvals for transactions for wallets like Bitcoin, Bitcoin Cash, Litecoin, and Dogecoin. Ideal for shared funds or enhanced security',
),
cta: () => setShowMultisigOptions(true),
},
];

const showErrorModal = (e: string) => {
dispatch(
showBottomNotificationModal({
type: 'warning',
title: t('Something went wrong'),
message: e,
enableBackdropDismiss: true,
actions: [
{
text: t('OK'),
action: () => {},
primary: true,
},
],
}),
);
};

return (
<>
<OptionContainer>
Expand Down
11 changes: 7 additions & 4 deletions src/navigation/wallet/screens/CreationOptions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import {
} from '../../../store/app/app.actions';
import {sleep} from '../../../utils/helper-methods';
import {getBaseKeyCreationCoinsAndTokens} from '../../../constants/currencies';
import {LogActions} from '../../../store/log';

type CreationOptionsScreenProps = NativeStackScreenProps<
WalletGroupParamList,
Expand Down Expand Up @@ -79,19 +80,21 @@ const CreationOptions: React.FC<CreationOptionsScreenProps> = ({

navigation.navigate('BackupKey', {context, key: createdKey});
dispatch(dismissOnGoingProcessModal());
} catch (e: any) {
logger.error(e.message);
} catch (err: any) {
const errstring =
err instanceof Error ? err.message : JSON.stringify(err);
dispatch(LogActions.error(`Error creating key: ${errstring}`));
dispatch(dismissOnGoingProcessModal());
await sleep(500);
showErrorModal(e.message);
showErrorModal(errstring);
}
},
},
{
id: 'import',
title: t('Import Key'),
description: t(
'Recover an existing key by entering your 12-word passphrase to access your wallets and accounts.',
'Recover an existing key by entering your 12-word passphrase to access your wallets and accounts',
),
cta: () => {
dispatch(
Expand Down
9 changes: 6 additions & 3 deletions src/navigation/wallet/screens/CurrencySelection.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ import SearchComponent, {
} from '../../../components/chain-search/ChainSearch';
import {ignoreGlobalListContextList} from '../../../components/modal/chain-selector/ChainSelector';
import cloneDeep from 'lodash.clonedeep';
import {LogActions} from '../../../store/log';

type CurrencySelectionScreenProps = NativeStackScreenProps<
WalletGroupParamList,
Expand Down Expand Up @@ -464,11 +465,13 @@ const CurrencySelection = ({route}: CurrencySelectionScreenProps) => {
}),
);
dispatch(dismissOnGoingProcessModal());
} catch (e: any) {
logger.error(e.message);
} catch (err: any) {
const errstring =
err instanceof Error ? err.message : JSON.stringify(err);
dispatch(LogActions.error(`Error creating key: ${errstring}`));
dispatch(dismissOnGoingProcessModal());
await sleep(500);
showErrorModal(e.message);
showErrorModal(errstring);
}
},
selectedCurrencies,
Expand Down
5 changes: 1 addition & 4 deletions src/store/wallet/effects/create/create.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,10 +112,7 @@ export const startCreateKey =
);
resolve(key);
} catch (err) {
const errstring =
err instanceof Error ? err.message : JSON.stringify(err);
dispatch(LogActions.error(`Error creating key: ${errstring}`));
reject();
reject(err);
}
});
};
Expand Down