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

Error Messaging for Onboarding #42

Merged
merged 1 commit into from
Feb 16, 2024
Merged
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
4 changes: 3 additions & 1 deletion src/i18n/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -71,5 +71,7 @@
"discover": "Discover",

"valid_address": "Valid Ethereum Address",
"message_requests_from_new_addresses": "Message requests from addresses you’ve never interacted with show up here"
"message_requests_from_new_addresses": "Message requests from addresses you’ve never interacted with show up here",

"wallet_error": "Wallet Error"
}
37 changes: 19 additions & 18 deletions src/screens/OnboardingConnectWalletScreen.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import {BlurView} from '@react-native-community/blur';
import {
WalletConfig,
coinbaseWallet,
localWallet,
metamaskWallet,
Expand All @@ -8,8 +9,8 @@ import {
walletConnect,
} from '@thirdweb-dev/react-native';
import {VStack} from 'native-base';
import React, {useEffect, useState} from 'react';
import {Image, Linking} from 'react-native';
import React, {useCallback, useEffect, useState} from 'react';
import {Alert, Image, Linking} from 'react-native';
import {WalletOptionButton} from '../components/WalletOptionButton';
import {Button} from '../components/common/Button';
import {Icon} from '../components/common/Icon';
Expand Down Expand Up @@ -43,6 +44,18 @@ export const OnboardingConnectWalletScreen = () => {
}
}, [address, navigate]);

const handleConnect = useCallback(
async (config: WalletConfig<any>) => {
try {
await connect(config);
setShowModal(false);
} catch (error: any) {
Alert.alert(translate('wallet_error'), error?.message);
}
},
[connect],
);

return (
<>
<Screen testId={TestIds.ONBOARDING_CONNECT_WALLET_SCREEN}>
Expand Down Expand Up @@ -93,37 +106,25 @@ export const OnboardingConnectWalletScreen = () => {
{translate('you_can_connect_or_create')}
</Text>
<WalletOptionButton
onPress={async () => {
await connect(walletConnectConfig);
setShowModal(false);
}}
onPress={() => handleConnect(walletConnectConfig)}
title={translate('walletconnect')}
icon={'walletconnect'}
testId={TestIds.ONBOARDING_CONNECT_WALLET_CONNECT_OPTION_BUTTON}
/>
<WalletOptionButton
onPress={async () => {
await connect(metamaskConfig);
setShowModal(false);
}}
onPress={() => handleConnect(metamaskConfig)}
title={translate('metamask')}
icon={'metamask'}
testId={TestIds.ONBOARDING_CONNECT_METAMASK_OPTION_BUTTON}
/>
<WalletOptionButton
onPress={async () => {
await connect(coinbaseWalletConfig);
setShowModal(false);
}}
onPress={() => handleConnect(coinbaseWalletConfig)}
title={translate('coinbase_wallet')}
icon={'coinbase-wallet'}
testId={TestIds.ONBOARDING_CONNECT_COINBASE_OPTION_BUTTON}
/>
<WalletOptionButton
onPress={async () => {
await connect(localWalletConfig);
setShowModal(false);
}}
onPress={() => handleConnect(localWalletConfig)}
title={translate('guest_wallet')}
icon={'wallet'}
testId={TestIds.ONBOARDING_CONNECT_GUEST_OPTION_BUTTON}
Expand Down
7 changes: 4 additions & 3 deletions src/screens/OnboardingEnableIdentityScreen.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import {useDisconnect, useSigner} from '@thirdweb-dev/react-native';
import {Client} from '@xmtp/react-native-sdk';
import {VStack} from 'native-base';
import React, {useCallback, useEffect, useState} from 'react';
import {DeviceEventEmitter, Image} from 'react-native';
import {useCallback, useEffect, useState} from 'react';
import {Alert, DeviceEventEmitter, Image} from 'react-native';
import {Button} from '../components/common/Button';
import {Icon} from '../components/common/Icon';
import {Screen} from '../components/common/Screen';
Expand Down Expand Up @@ -69,8 +69,9 @@ export const OnboardingEnableIdentityScreen = () => {
const address = await signer.getAddress();
saveClientKeys(address as `0x${string}`, keys);
setClient(client);
} catch (e) {
} catch (e: any) {
console.log('Error creating client', e);
Alert.alert('Error creating client', e?.message);
}
};
startClientCreation();
Expand Down
Loading