@reown/appkit-react-native 0.0.0-develop-20251030154825 → 0.0.0-develop-20251114173726
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/commonjs/hooks/useAccount.js +4 -4
- package/lib/commonjs/hooks/useAccount.js.map +1 -1
- package/lib/commonjs/hooks/useAppKit.js +41 -9
- package/lib/commonjs/hooks/useAppKit.js.map +1 -1
- package/lib/commonjs/hooks/useAppKitContext.js +46 -0
- package/lib/commonjs/hooks/useAppKitContext.js.map +1 -0
- package/lib/commonjs/hooks/useAppKitEvents.js +64 -4
- package/lib/commonjs/hooks/useAppKitEvents.js.map +1 -1
- package/lib/commonjs/hooks/useAppKitLogs.js +2 -8
- package/lib/commonjs/hooks/useAppKitLogs.js.map +1 -1
- package/lib/commonjs/hooks/useAppKitState.js +35 -2
- package/lib/commonjs/hooks/useAppKitState.js.map +1 -1
- package/lib/commonjs/hooks/useAppKitTheme.js +74 -0
- package/lib/commonjs/hooks/useAppKitTheme.js.map +1 -0
- package/lib/commonjs/hooks/useProvider.js +3 -4
- package/lib/commonjs/hooks/useProvider.js.map +1 -1
- package/lib/commonjs/hooks/useWalletInfo.js +33 -2
- package/lib/commonjs/hooks/useWalletInfo.js.map +1 -1
- package/lib/commonjs/index.js +7 -0
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/modal/w3m-modal/styles.js +2 -1
- package/lib/commonjs/modal/w3m-modal/styles.js.map +1 -1
- package/lib/commonjs/partials/w3m-connecting-body/index.js +2 -0
- package/lib/commonjs/partials/w3m-connecting-body/index.js.map +1 -1
- package/lib/commonjs/partials/w3m-connecting-mobile/components/StoreLink.js +4 -0
- package/lib/commonjs/partials/w3m-connecting-mobile/components/StoreLink.js.map +1 -1
- package/lib/commonjs/partials/w3m-connecting-qrcode/index.js +5 -1
- package/lib/commonjs/partials/w3m-connecting-qrcode/index.js.map +1 -1
- package/lib/commonjs/partials/w3m-header/index.js +1 -0
- package/lib/commonjs/partials/w3m-header/index.js.map +1 -1
- package/lib/commonjs/partials/w3m-header/styles.js +3 -0
- package/lib/commonjs/partials/w3m-header/styles.js.map +1 -1
- package/lib/commonjs/views/w3m-connecting-external-view/index.js +4 -8
- package/lib/commonjs/views/w3m-connecting-external-view/index.js.map +1 -1
- package/lib/commonjs/views/w3m-connecting-view/index.js +17 -9
- package/lib/commonjs/views/w3m-connecting-view/index.js.map +1 -1
- package/lib/module/hooks/useAccount.js +4 -4
- package/lib/module/hooks/useAccount.js.map +1 -1
- package/lib/module/hooks/useAppKit.js +43 -10
- package/lib/module/hooks/useAppKit.js.map +1 -1
- package/lib/module/hooks/useAppKitContext.js +42 -0
- package/lib/module/hooks/useAppKitContext.js.map +1 -0
- package/lib/module/hooks/useAppKitEvents.js +65 -4
- package/lib/module/hooks/useAppKitEvents.js.map +1 -1
- package/lib/module/hooks/useAppKitLogs.js +3 -9
- package/lib/module/hooks/useAppKitLogs.js.map +1 -1
- package/lib/module/hooks/useAppKitState.js +36 -2
- package/lib/module/hooks/useAppKitState.js.map +1 -1
- package/lib/module/hooks/useAppKitTheme.js +71 -0
- package/lib/module/hooks/useAppKitTheme.js.map +1 -0
- package/lib/module/hooks/useProvider.js +3 -4
- package/lib/module/hooks/useProvider.js.map +1 -1
- package/lib/module/hooks/useWalletInfo.js +34 -2
- package/lib/module/hooks/useWalletInfo.js.map +1 -1
- package/lib/module/index.js +1 -0
- package/lib/module/index.js.map +1 -1
- package/lib/module/modal/w3m-modal/styles.js +2 -1
- package/lib/module/modal/w3m-modal/styles.js.map +1 -1
- package/lib/module/partials/w3m-connecting-body/index.js +2 -0
- package/lib/module/partials/w3m-connecting-body/index.js.map +1 -1
- package/lib/module/partials/w3m-connecting-mobile/components/StoreLink.js +4 -0
- package/lib/module/partials/w3m-connecting-mobile/components/StoreLink.js.map +1 -1
- package/lib/module/partials/w3m-connecting-qrcode/index.js +5 -1
- package/lib/module/partials/w3m-connecting-qrcode/index.js.map +1 -1
- package/lib/module/partials/w3m-header/index.js +1 -0
- package/lib/module/partials/w3m-header/index.js.map +1 -1
- package/lib/module/partials/w3m-header/styles.js +3 -0
- package/lib/module/partials/w3m-header/styles.js.map +1 -1
- package/lib/module/views/w3m-connecting-external-view/index.js +4 -8
- package/lib/module/views/w3m-connecting-external-view/index.js.map +1 -1
- package/lib/module/views/w3m-connecting-view/index.js +17 -9
- package/lib/module/views/w3m-connecting-view/index.js.map +1 -1
- package/lib/typescript/AppKitContext.d.ts +1 -1
- package/lib/typescript/AppKitContext.d.ts.map +1 -1
- package/lib/typescript/hooks/useAccount.d.ts.map +1 -1
- package/lib/typescript/hooks/useAppKit.d.ts +42 -0
- package/lib/typescript/hooks/useAppKit.d.ts.map +1 -1
- package/lib/typescript/hooks/useAppKitContext.d.ts +27 -0
- package/lib/typescript/hooks/useAppKitContext.d.ts.map +1 -0
- package/lib/typescript/hooks/useAppKitEvents.d.ts +66 -0
- package/lib/typescript/hooks/useAppKitEvents.d.ts.map +1 -1
- package/lib/typescript/hooks/useAppKitLogs.d.ts.map +1 -1
- package/lib/typescript/hooks/useAppKitState.d.ts +32 -0
- package/lib/typescript/hooks/useAppKitState.d.ts.map +1 -1
- package/lib/typescript/hooks/useAppKitTheme.d.ts +59 -0
- package/lib/typescript/hooks/useAppKitTheme.d.ts.map +1 -0
- package/lib/typescript/hooks/useProvider.d.ts +1 -4
- package/lib/typescript/hooks/useProvider.d.ts.map +1 -1
- package/lib/typescript/hooks/useWalletInfo.d.ts +31 -0
- package/lib/typescript/hooks/useWalletInfo.d.ts.map +1 -1
- package/lib/typescript/index.d.ts +1 -0
- package/lib/typescript/index.d.ts.map +1 -1
- package/lib/typescript/modal/w3m-modal/styles.d.ts +1 -0
- package/lib/typescript/modal/w3m-modal/styles.d.ts.map +1 -1
- package/lib/typescript/partials/w3m-connecting-body/index.d.ts.map +1 -1
- package/lib/typescript/partials/w3m-connecting-qrcode/index.d.ts.map +1 -1
- package/lib/typescript/partials/w3m-header/index.d.ts.map +1 -1
- package/lib/typescript/partials/w3m-header/styles.d.ts +3 -0
- package/lib/typescript/partials/w3m-header/styles.d.ts.map +1 -1
- package/lib/typescript/views/w3m-connecting-external-view/index.d.ts.map +1 -1
- package/lib/typescript/views/w3m-connecting-view/index.d.ts.map +1 -1
- package/package.json +5 -4
- package/src/AppKitContext.tsx +1 -1
- package/src/hooks/useAccount.ts +5 -3
- package/src/hooks/useAppKit.ts +45 -12
- package/src/hooks/useAppKitContext.ts +43 -0
- package/src/hooks/useAppKitEvents.ts +63 -3
- package/src/hooks/useAppKitLogs.ts +3 -11
- package/src/hooks/useAppKitState.ts +35 -2
- package/src/hooks/useAppKitTheme.ts +81 -0
- package/src/hooks/useProvider.ts +3 -4
- package/src/hooks/useWalletInfo.ts +33 -2
- package/src/index.ts +1 -0
- package/src/modal/w3m-modal/styles.ts +2 -1
- package/src/partials/w3m-connecting-body/index.tsx +3 -1
- package/src/partials/w3m-connecting-mobile/components/StoreLink.tsx +4 -1
- package/src/partials/w3m-connecting-qrcode/index.tsx +10 -1
- package/src/partials/w3m-header/index.tsx +6 -1
- package/src/partials/w3m-header/styles.ts +3 -0
- package/src/views/w3m-connecting-external-view/index.tsx +4 -8
- package/src/views/w3m-connecting-view/index.tsx +22 -10
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { useMemo } from 'react';
|
|
2
2
|
import { useSnapshot } from 'valtio';
|
|
3
3
|
import { LogController, type LogEntry, type LogLevel } from '@reown/appkit-core-react-native';
|
|
4
|
-
import {
|
|
4
|
+
import { useAppKitContext } from './useAppKitContext';
|
|
5
5
|
|
|
6
6
|
export interface UseAppKitLogsReturn {
|
|
7
7
|
/**
|
|
@@ -65,15 +65,7 @@ export interface UseAppKitLogsReturn {
|
|
|
65
65
|
* ```
|
|
66
66
|
*/
|
|
67
67
|
export const useAppKitLogs = (): UseAppKitLogsReturn => {
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
if (context === undefined) {
|
|
71
|
-
throw new Error('useAppKitLogs must be used within an AppKitProvider');
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
if (!context.appKit) {
|
|
75
|
-
throw new Error('AppKit instance is not yet available in context.');
|
|
76
|
-
}
|
|
68
|
+
useAppKitContext();
|
|
77
69
|
|
|
78
70
|
const { logs } = useSnapshot(LogController.state);
|
|
79
71
|
|
|
@@ -2,10 +2,43 @@
|
|
|
2
2
|
import { useMemo } from 'react';
|
|
3
3
|
import { useSnapshot } from 'valtio';
|
|
4
4
|
import { ConnectionsController, ModalController } from '@reown/appkit-core-react-native';
|
|
5
|
-
import {
|
|
5
|
+
import { useAppKitContext } from './useAppKitContext';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Hook to access the overall state of the AppKit modal and connection
|
|
9
|
+
*
|
|
10
|
+
* @remarks
|
|
11
|
+
* This hook provides a high-level view of the AppKit's current state, including
|
|
12
|
+
* whether the modal is open, if it's loading, connection status, and the active chain.
|
|
13
|
+
* It's useful for coordinating UI elements with the AppKit's state.
|
|
14
|
+
*
|
|
15
|
+
* @returns An object containing:
|
|
16
|
+
* - `isOpen`: Whether the AppKit modal is currently open
|
|
17
|
+
* - `isLoading`: Whether the AppKit is in a loading state
|
|
18
|
+
* - `isConnected`: Whether a wallet is currently connected
|
|
19
|
+
* - `chain`: The currently active blockchain network
|
|
20
|
+
*
|
|
21
|
+
* @throws {Error} If used outside of an AppKitProvider
|
|
22
|
+
*
|
|
23
|
+
* @example
|
|
24
|
+
* ```tsx
|
|
25
|
+
* function MyComponent() {
|
|
26
|
+
* const { isOpen, isLoading, isConnected, chain } = useAppKitState();
|
|
27
|
+
*
|
|
28
|
+
* return (
|
|
29
|
+
* <View>
|
|
30
|
+
* <Text>Modal: {isOpen ? 'Open' : 'Closed'}</Text>
|
|
31
|
+
* <Text>Loading: {isLoading ? 'Yes' : 'No'}</Text>
|
|
32
|
+
* <Text>Connected: {isConnected ? 'Yes' : 'No'}</Text>
|
|
33
|
+
* {chain && <Text>Chain: {chain.name}</Text>}
|
|
34
|
+
* </View>
|
|
35
|
+
* );
|
|
36
|
+
* }
|
|
37
|
+
* ```
|
|
38
|
+
*/
|
|
6
39
|
|
|
7
40
|
export function useAppKitState() {
|
|
8
|
-
|
|
41
|
+
useAppKitContext();
|
|
9
42
|
const { activeAddress: address, connection, networks } = useSnapshot(ConnectionsController.state);
|
|
10
43
|
const { open, loading } = useSnapshot(ModalController.state);
|
|
11
44
|
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { useMemo } from 'react';
|
|
2
|
+
import { useSnapshot } from 'valtio';
|
|
3
|
+
import type { ThemeMode, ThemeVariables } from '@reown/appkit-common-react-native';
|
|
4
|
+
import { ThemeController } from '@reown/appkit-core-react-native';
|
|
5
|
+
import { useAppKitContext } from './useAppKitContext';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Interface representing the result of the useAppKitTheme hook
|
|
9
|
+
*/
|
|
10
|
+
export interface UseAppKitThemeReturn {
|
|
11
|
+
/** The current theme mode ('dark' or 'light'), or undefined if using system default */
|
|
12
|
+
themeMode?: ThemeMode;
|
|
13
|
+
/** The current theme variables, currently only supports 'accent' color */
|
|
14
|
+
themeVariables: ThemeVariables;
|
|
15
|
+
/** Function to set the theme mode */
|
|
16
|
+
setThemeMode: (themeMode: ThemeMode | undefined) => void;
|
|
17
|
+
/** Function to set theme variables */
|
|
18
|
+
setThemeVariables: (themeVariables: ThemeVariables | undefined) => void;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Hook to control the visual appearance of the AppKit modal
|
|
23
|
+
*
|
|
24
|
+
* @remarks
|
|
25
|
+
* This hook provides access to the theme mode and theme variables, allowing you to
|
|
26
|
+
* customize the modal's appearance. Use this hook when you need to implement dark/light
|
|
27
|
+
* mode or match the modal's appearance with your application's theme.
|
|
28
|
+
*
|
|
29
|
+
* Currently, the only supported theme variable is `accent`, which controls the primary
|
|
30
|
+
* accent color used throughout the modal interface.
|
|
31
|
+
*
|
|
32
|
+
* @returns {UseAppKitThemeReturn} An object containing:
|
|
33
|
+
* - `themeMode`: The current theme mode ('dark' or 'light')
|
|
34
|
+
* - `themeVariables`: The current theme variables (only 'accent' is supported)
|
|
35
|
+
* - `setThemeMode`: Function to change the theme mode
|
|
36
|
+
* - `setThemeVariables`: Function to update theme variables
|
|
37
|
+
*
|
|
38
|
+
* @throws {Error} If used outside of an AppKitProvider
|
|
39
|
+
*
|
|
40
|
+
* @example
|
|
41
|
+
* ```typescript
|
|
42
|
+
* import { useAppKitTheme } from '@reown/appkit-react-native';
|
|
43
|
+
*
|
|
44
|
+
* function MyComponent() {
|
|
45
|
+
* const { themeMode, themeVariables, setThemeMode, setThemeVariables } = useAppKitTheme();
|
|
46
|
+
*
|
|
47
|
+
* // Set theme to dark mode
|
|
48
|
+
* setThemeMode('dark');
|
|
49
|
+
*
|
|
50
|
+
* // Customize the accent color
|
|
51
|
+
* setThemeVariables({
|
|
52
|
+
* accent: '#00BB7F'
|
|
53
|
+
* });
|
|
54
|
+
*
|
|
55
|
+
* return (
|
|
56
|
+
* <View>
|
|
57
|
+
* <Text>Current theme: {themeMode}</Text>
|
|
58
|
+
* <Text>Accent color: {themeVariables?.accent}</Text>
|
|
59
|
+
* </View>
|
|
60
|
+
* );
|
|
61
|
+
* }
|
|
62
|
+
* ```
|
|
63
|
+
*/
|
|
64
|
+
export function useAppKitTheme(): UseAppKitThemeReturn {
|
|
65
|
+
useAppKitContext();
|
|
66
|
+
const { themeMode, themeVariables } = useSnapshot(ThemeController.state);
|
|
67
|
+
|
|
68
|
+
const stableFunctions = useMemo(
|
|
69
|
+
() => ({
|
|
70
|
+
setThemeMode: ThemeController.setThemeMode.bind(ThemeController),
|
|
71
|
+
setThemeVariables: ThemeController.setThemeVariables.bind(ThemeController)
|
|
72
|
+
}),
|
|
73
|
+
[]
|
|
74
|
+
);
|
|
75
|
+
|
|
76
|
+
return {
|
|
77
|
+
themeMode,
|
|
78
|
+
themeVariables,
|
|
79
|
+
...stableFunctions
|
|
80
|
+
};
|
|
81
|
+
}
|
package/src/hooks/useProvider.ts
CHANGED
|
@@ -3,6 +3,7 @@ import { useMemo } from 'react';
|
|
|
3
3
|
import { useSnapshot } from 'valtio';
|
|
4
4
|
import { ConnectionsController, LogController } from '@reown/appkit-core-react-native';
|
|
5
5
|
import type { Provider, ChainNamespace } from '@reown/appkit-common-react-native';
|
|
6
|
+
import { useAppKitContext } from './useAppKitContext';
|
|
6
7
|
|
|
7
8
|
/**
|
|
8
9
|
* Interface representing the result of the useProvider hook
|
|
@@ -29,14 +30,12 @@ interface ProviderResult {
|
|
|
29
30
|
*
|
|
30
31
|
* if (provider) {
|
|
31
32
|
* // Use the provider for blockchain operations
|
|
32
|
-
* const balance = await provider.request({
|
|
33
|
-
* method: 'eth_getBalance',
|
|
34
|
-
* params: [address, 'latest']
|
|
35
|
-
* });
|
|
33
|
+
* const balance = await provider.request({...});
|
|
36
34
|
* }
|
|
37
35
|
* ```
|
|
38
36
|
*/
|
|
39
37
|
export function useProvider(): ProviderResult {
|
|
38
|
+
useAppKitContext();
|
|
40
39
|
const { connection } = useSnapshot(ConnectionsController.state);
|
|
41
40
|
|
|
42
41
|
const returnValue = useMemo(() => {
|
|
@@ -1,10 +1,41 @@
|
|
|
1
1
|
import { useMemo } from 'react';
|
|
2
2
|
import { useSnapshot } from 'valtio';
|
|
3
3
|
import { ConnectionsController } from '@reown/appkit-core-react-native';
|
|
4
|
-
import {
|
|
4
|
+
import { useAppKitContext } from './useAppKitContext';
|
|
5
5
|
|
|
6
|
+
/**
|
|
7
|
+
* Hook to access information about the currently connected wallet
|
|
8
|
+
*
|
|
9
|
+
* @remarks
|
|
10
|
+
* This hook provides access to metadata about the connected wallet, such as its name,
|
|
11
|
+
* icon, and other identifying information. It automatically subscribes to wallet info
|
|
12
|
+
* changes via valtio.
|
|
13
|
+
*
|
|
14
|
+
* @returns An object containing:
|
|
15
|
+
* - `walletInfo`: Metadata about the currently connected wallet (name, icon, etc.)
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
* ```tsx
|
|
19
|
+
* function MyComponent() {
|
|
20
|
+
* const { walletInfo } = useWalletInfo();
|
|
21
|
+
*
|
|
22
|
+
* return (
|
|
23
|
+
* <View>
|
|
24
|
+
* {walletInfo && (
|
|
25
|
+
* <>
|
|
26
|
+
* <Image source={{ uri: walletInfo.icon }} />
|
|
27
|
+
* <Text>{walletInfo.name}</Text>
|
|
28
|
+
* </>
|
|
29
|
+
* )}
|
|
30
|
+
* </View>
|
|
31
|
+
* );
|
|
32
|
+
* }
|
|
33
|
+
* ```
|
|
34
|
+
*
|
|
35
|
+
* @throws {Error} If used outside of an AppKitProvider
|
|
36
|
+
*/
|
|
6
37
|
export function useWalletInfo() {
|
|
7
|
-
|
|
38
|
+
useAppKitContext();
|
|
8
39
|
const { walletInfo: walletInfoSnapshot } = useSnapshot(ConnectionsController.state);
|
|
9
40
|
|
|
10
41
|
const walletInfo = useMemo(() => ({ walletInfo: walletInfoSnapshot }), [walletInfoSnapshot]);
|
package/src/index.ts
CHANGED
|
@@ -32,6 +32,7 @@ export type { AppKitConfig } from './types';
|
|
|
32
32
|
export { useAppKit } from './hooks/useAppKit';
|
|
33
33
|
export { useProvider } from './hooks/useProvider';
|
|
34
34
|
export { useAccount, type Account as UseAccountReturn } from './hooks/useAccount';
|
|
35
|
+
export { useAppKitTheme, type UseAppKitThemeReturn } from './hooks/useAppKitTheme';
|
|
35
36
|
export { useWalletInfo } from './hooks/useWalletInfo';
|
|
36
37
|
export { useAppKitEvents, useAppKitEventSubscription } from './hooks/useAppKitEvents';
|
|
37
38
|
export { useAppKitState } from './hooks/useAppKitState';
|
|
@@ -11,7 +11,9 @@ export interface ConnectingBodyProps {
|
|
|
11
11
|
export function ConnectingBody({ title, description }: ConnectingBodyProps) {
|
|
12
12
|
return (
|
|
13
13
|
<FlexView padding={['3xs', '2xl', '0', '2xl']} alignItems="center" style={styles.textContainer}>
|
|
14
|
-
<Text variant="paragraph-500">
|
|
14
|
+
<Text center numberOfLines={1} variant="paragraph-500">
|
|
15
|
+
{title}
|
|
16
|
+
</Text>
|
|
15
17
|
{description ? (
|
|
16
18
|
<Text center variant="small-400" color="fg-200" style={styles.descriptionText}>
|
|
17
19
|
{description}
|
|
@@ -12,7 +12,7 @@ export function StoreLink({ visible, walletName = 'Wallet', onPress }: StoreLink
|
|
|
12
12
|
|
|
13
13
|
return (
|
|
14
14
|
<ActionEntry style={styles.storeButton}>
|
|
15
|
-
<Text numberOfLines={1} variant="paragraph-500" color="fg-200">
|
|
15
|
+
<Text numberOfLines={1} style={styles.storeText} variant="paragraph-500" color="fg-200">
|
|
16
16
|
{`Don't have ${walletName}?`}
|
|
17
17
|
</Text>
|
|
18
18
|
<Button
|
|
@@ -34,5 +34,8 @@ const styles = StyleSheet.create({
|
|
|
34
34
|
paddingHorizontal: Spacing.l,
|
|
35
35
|
marginHorizontal: Spacing.xl,
|
|
36
36
|
marginTop: Spacing.l
|
|
37
|
+
},
|
|
38
|
+
storeText: {
|
|
39
|
+
flexShrink: 1
|
|
37
40
|
}
|
|
38
41
|
});
|
|
@@ -20,6 +20,9 @@ import styles from './styles';
|
|
|
20
20
|
import { ReownButton } from './components/ReownButton';
|
|
21
21
|
import { useWindowDimensions } from 'react-native';
|
|
22
22
|
|
|
23
|
+
const LOGO_SIZE = 60;
|
|
24
|
+
const LOGO_BORDER_RADIUS = 10;
|
|
25
|
+
|
|
23
26
|
export function ConnectingQrCode() {
|
|
24
27
|
const { height, width } = useWindowDimensions();
|
|
25
28
|
const windowSize = Math.min(height, width);
|
|
@@ -65,7 +68,13 @@ export function ConnectingQrCode() {
|
|
|
65
68
|
flexDirection={isPortrait ? 'column' : 'row'}
|
|
66
69
|
padding={['xl', 'xl', 'xs', 'xl']}
|
|
67
70
|
>
|
|
68
|
-
<QrCode
|
|
71
|
+
<QrCode
|
|
72
|
+
size={qrSize}
|
|
73
|
+
uri={wcUri}
|
|
74
|
+
testID="qr-code"
|
|
75
|
+
logoBorderRadius={LOGO_BORDER_RADIUS}
|
|
76
|
+
logoSize={LOGO_SIZE}
|
|
77
|
+
/>
|
|
69
78
|
<FlexView alignItems="center" margin="m">
|
|
70
79
|
<Text variant="paragraph-500">Scan this QR code with your phone</Text>
|
|
71
80
|
{showCopy ? (
|
|
@@ -100,7 +100,12 @@ export function Header() {
|
|
|
100
100
|
padding={['l', 'xl', bottomPadding, 'xl']}
|
|
101
101
|
>
|
|
102
102
|
{dynamicButtonTemplate()}
|
|
103
|
-
<Text
|
|
103
|
+
<Text
|
|
104
|
+
variant="paragraph-600"
|
|
105
|
+
numberOfLines={1}
|
|
106
|
+
style={styles.headerText}
|
|
107
|
+
testID="header-text"
|
|
108
|
+
>
|
|
104
109
|
{header}
|
|
105
110
|
</Text>
|
|
106
111
|
{showClose ? (
|
|
@@ -26,6 +26,7 @@ import styles from './styles';
|
|
|
26
26
|
import { useInternalAppKit } from '../../AppKitContext';
|
|
27
27
|
import { StoreLink } from '../../partials/w3m-connecting-mobile/components/StoreLink';
|
|
28
28
|
import { WcHelpersUtil } from '../../utils/HelpersUtil';
|
|
29
|
+
import { ErrorUtil } from '@reown/appkit-common-react-native';
|
|
29
30
|
|
|
30
31
|
export function ConnectingExternalView() {
|
|
31
32
|
const { data } = useSnapshot(RouterController.state);
|
|
@@ -94,16 +95,11 @@ export function ConnectingExternalView() {
|
|
|
94
95
|
}
|
|
95
96
|
} catch (error) {
|
|
96
97
|
LogController.sendError(error, 'ConnectingExternalView.tsx', 'onConnect');
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
} else if (/(rejected)/i.test((error as Error).message)) {
|
|
100
|
-
setErrorType('declined');
|
|
101
|
-
} else {
|
|
102
|
-
setErrorType('default');
|
|
103
|
-
}
|
|
98
|
+
const type = ErrorUtil.categorizeConnectionError(error);
|
|
99
|
+
setErrorType(type);
|
|
104
100
|
EventsController.sendEvent({
|
|
105
101
|
type: 'track',
|
|
106
|
-
event: 'CONNECT_ERROR',
|
|
102
|
+
event: type === 'declined' ? 'USER_REJECTED' : 'CONNECT_ERROR',
|
|
107
103
|
properties: { message: (error as Error)?.message ?? 'Unknown' }
|
|
108
104
|
});
|
|
109
105
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { useSnapshot } from 'valtio';
|
|
2
2
|
import { useEffect, useLayoutEffect, useState } from 'react';
|
|
3
|
-
import { type Platform } from '@reown/appkit-common-react-native';
|
|
3
|
+
import { ErrorUtil, type Platform } from '@reown/appkit-common-react-native';
|
|
4
4
|
import {
|
|
5
5
|
WcController,
|
|
6
6
|
ConstantsUtil,
|
|
@@ -32,41 +32,53 @@ export function ConnectingView() {
|
|
|
32
32
|
const onRetry = () => {
|
|
33
33
|
if (CoreHelperUtil.isAllowedRetry(lastRetry)) {
|
|
34
34
|
setLastRetry(Date.now());
|
|
35
|
-
WcController.clearUri();
|
|
36
35
|
initializeConnection(true);
|
|
37
36
|
} else {
|
|
38
37
|
SnackController.showError('Please wait a second before retrying');
|
|
39
38
|
}
|
|
40
39
|
};
|
|
41
40
|
|
|
42
|
-
const initializeConnection = async (retry = false) => {
|
|
41
|
+
const initializeConnection = async (retry = false, retryTimestamp?: number) => {
|
|
43
42
|
try {
|
|
44
43
|
const { wcPairingExpiry } = WcController.state;
|
|
45
44
|
const { data: routeData } = RouterController.state;
|
|
46
|
-
|
|
45
|
+
const isPairingExpired = CoreHelperUtil.isPairingExpired(wcPairingExpiry);
|
|
46
|
+
if (retry || isPairingExpired) {
|
|
47
47
|
WcController.setWcError(false);
|
|
48
|
+
WcController.clearUri();
|
|
48
49
|
|
|
49
50
|
const connectPromise = connect({
|
|
50
51
|
wallet: routeData?.wallet
|
|
51
52
|
});
|
|
52
53
|
WcController.setWcPromise(connectPromise);
|
|
54
|
+
await connectPromise;
|
|
53
55
|
}
|
|
54
56
|
} catch (error) {
|
|
55
57
|
LogController.sendError(error, 'ConnectingView.tsx', 'initializeConnection');
|
|
56
58
|
WcController.setWcError(true);
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
59
|
+
|
|
60
|
+
const isUserRejected = ErrorUtil.isUserRejectedRequestError(error);
|
|
61
|
+
const isProposalExpired = ErrorUtil.isProposalExpiredError(error);
|
|
62
|
+
if (!isProposalExpired) {
|
|
63
|
+
SnackController.showError(
|
|
64
|
+
isUserRejected ? 'User rejected the request' : 'Something went wrong'
|
|
65
|
+
);
|
|
62
66
|
}
|
|
67
|
+
|
|
63
68
|
EventsController.sendEvent({
|
|
64
69
|
type: 'track',
|
|
65
|
-
event: 'CONNECT_ERROR',
|
|
70
|
+
event: isUserRejected ? 'USER_REJECTED' : 'CONNECT_ERROR',
|
|
66
71
|
properties: {
|
|
67
72
|
message: (error as Error)?.message ?? 'Unknown'
|
|
68
73
|
}
|
|
69
74
|
});
|
|
75
|
+
|
|
76
|
+
const currentRetryTime = retryTimestamp ?? lastRetry;
|
|
77
|
+
if (isQr && CoreHelperUtil.isAllowedRetry(currentRetryTime)) {
|
|
78
|
+
const newRetryTime = Date.now();
|
|
79
|
+
setLastRetry(newRetryTime);
|
|
80
|
+
initializeConnection(true, newRetryTime);
|
|
81
|
+
}
|
|
70
82
|
}
|
|
71
83
|
};
|
|
72
84
|
|