@reown/appkit-react-native 0.0.0-chore-spring-effect-20250909214820 → 0.0.0-develop-20251008155354
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/AppKit.js +135 -89
- package/lib/commonjs/AppKit.js.map +1 -1
- package/lib/commonjs/AppKitContext.js +16 -10
- package/lib/commonjs/AppKitContext.js.map +1 -1
- package/lib/commonjs/connectors/WalletConnectConnector.js +24 -57
- package/lib/commonjs/connectors/WalletConnectConnector.js.map +1 -1
- package/lib/commonjs/hooks/useAccount.js +4 -3
- package/lib/commonjs/hooks/useAccount.js.map +1 -1
- package/lib/commonjs/hooks/useAppKit.js +12 -12
- package/lib/commonjs/hooks/useAppKit.js.map +1 -1
- package/lib/commonjs/hooks/useAppKitLogs.js +88 -0
- package/lib/commonjs/hooks/useAppKitLogs.js.map +1 -0
- package/lib/commonjs/hooks/useAppKitState.js +32 -0
- package/lib/commonjs/hooks/useAppKitState.js.map +1 -0
- package/lib/commonjs/hooks/useProvider.js +26 -8
- package/lib/commonjs/hooks/useProvider.js.map +1 -1
- package/lib/commonjs/hooks/useWalletInfo.js +6 -4
- package/lib/commonjs/hooks/useWalletInfo.js.map +1 -1
- package/lib/commonjs/index.js +22 -0
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/modal/w3m-modal/index.js +9 -1
- package/lib/commonjs/modal/w3m-modal/index.js.map +1 -1
- package/lib/commonjs/modal/w3m-router/index.js +19 -21
- package/lib/commonjs/modal/w3m-router/index.js.map +1 -1
- package/lib/commonjs/partials/w3m-account-wallet-features/index.js +1 -1
- package/lib/commonjs/partials/w3m-account-wallet-features/index.js.map +1 -1
- package/lib/commonjs/partials/w3m-all-wallets-list/components/WalletItem.js +6 -3
- package/lib/commonjs/partials/w3m-all-wallets-list/components/WalletItem.js.map +1 -1
- package/lib/commonjs/partials/w3m-all-wallets-list/components/WalletList.js +66 -22
- package/lib/commonjs/partials/w3m-all-wallets-list/components/WalletList.js.map +1 -1
- package/lib/commonjs/partials/w3m-all-wallets-list/index.js +2 -1
- package/lib/commonjs/partials/w3m-all-wallets-list/index.js.map +1 -1
- package/lib/commonjs/partials/w3m-all-wallets-search/index.js +4 -1
- package/lib/commonjs/partials/w3m-all-wallets-search/index.js.map +1 -1
- package/lib/commonjs/partials/w3m-connecting-mobile/index.js +21 -1
- package/lib/commonjs/partials/w3m-connecting-mobile/index.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-connecting-web/index.js +8 -2
- package/lib/commonjs/partials/w3m-connecting-web/index.js.map +1 -1
- package/lib/commonjs/partials/w3m-header/index.js +4 -4
- package/lib/commonjs/partials/w3m-header/index.js.map +1 -1
- package/lib/commonjs/utils/SIWXUtil.js +278 -0
- package/lib/commonjs/utils/SIWXUtil.js.map +1 -0
- package/lib/commonjs/views/w3m-account-default-view/index.js +3 -2
- package/lib/commonjs/views/w3m-account-default-view/index.js.map +1 -1
- package/lib/commonjs/views/w3m-all-wallets-view/index.js +7 -4
- package/lib/commonjs/views/w3m-all-wallets-view/index.js.map +1 -1
- package/lib/commonjs/views/w3m-connect-view/components/all-wallet-list.js +33 -6
- package/lib/commonjs/views/w3m-connect-view/components/all-wallet-list.js.map +1 -1
- package/lib/commonjs/views/w3m-connect-view/index.js +6 -3
- package/lib/commonjs/views/w3m-connect-view/index.js.map +1 -1
- package/lib/commonjs/views/w3m-connecting-external-view/index.js +21 -1
- package/lib/commonjs/views/w3m-connecting-external-view/index.js.map +1 -1
- package/lib/commonjs/views/w3m-connecting-social-view/index.js +1 -0
- package/lib/commonjs/views/w3m-connecting-social-view/index.js.map +1 -1
- package/lib/commonjs/views/w3m-connecting-view/index.js +12 -31
- package/lib/commonjs/views/w3m-connecting-view/index.js.map +1 -1
- package/lib/commonjs/views/w3m-network-switch-view/index.js +1 -0
- package/lib/commonjs/views/w3m-network-switch-view/index.js.map +1 -1
- package/lib/commonjs/views/w3m-onramp-settings-view/components/Country.js +3 -1
- package/lib/commonjs/views/w3m-onramp-settings-view/components/Country.js.map +1 -1
- package/lib/commonjs/views/w3m-onramp-settings-view/index.js +2 -1
- package/lib/commonjs/views/w3m-onramp-settings-view/index.js.map +1 -1
- package/lib/commonjs/views/w3m-onramp-view/components/LoadingView.js +1 -1
- package/lib/commonjs/views/w3m-onramp-view/components/LoadingView.js.map +1 -1
- package/lib/commonjs/views/{w3m-connecting-siwe-view → w3m-siwx-sign-view}/index.js +7 -43
- package/lib/commonjs/views/w3m-siwx-sign-view/index.js.map +1 -0
- package/lib/commonjs/views/w3m-siwx-sign-view/styles.js.map +1 -0
- package/lib/commonjs/views/w3m-swap-view/index.js +1 -1
- package/lib/commonjs/views/w3m-swap-view/index.js.map +1 -1
- package/lib/commonjs/views/w3m-what-is-a-wallet-view/index.js +1 -1
- package/lib/commonjs/views/w3m-what-is-a-wallet-view/index.js.map +1 -1
- package/lib/module/AppKit.js +135 -89
- package/lib/module/AppKit.js.map +1 -1
- package/lib/module/AppKitContext.js +17 -11
- package/lib/module/AppKitContext.js.map +1 -1
- package/lib/module/connectors/WalletConnectConnector.js +22 -56
- package/lib/module/connectors/WalletConnectConnector.js.map +1 -1
- package/lib/module/hooks/useAccount.js +3 -3
- package/lib/module/hooks/useAccount.js.map +1 -1
- package/lib/module/hooks/useAppKit.js +13 -13
- package/lib/module/hooks/useAppKit.js.map +1 -1
- package/lib/module/hooks/useAppKitLogs.js +83 -0
- package/lib/module/hooks/useAppKitLogs.js.map +1 -0
- package/lib/module/hooks/useAppKitState.js +27 -0
- package/lib/module/hooks/useAppKitState.js.map +1 -0
- package/lib/module/hooks/useProvider.js +26 -9
- package/lib/module/hooks/useProvider.js.map +1 -1
- package/lib/module/hooks/useWalletInfo.js +6 -4
- package/lib/module/hooks/useWalletInfo.js.map +1 -1
- package/lib/module/index.js +7 -0
- package/lib/module/index.js.map +1 -1
- package/lib/module/modal/w3m-modal/index.js +9 -1
- package/lib/module/modal/w3m-modal/index.js.map +1 -1
- package/lib/module/modal/w3m-router/index.js +20 -22
- package/lib/module/modal/w3m-router/index.js.map +1 -1
- package/lib/module/partials/w3m-account-wallet-features/index.js +1 -1
- package/lib/module/partials/w3m-account-wallet-features/index.js.map +1 -1
- package/lib/module/partials/w3m-all-wallets-list/components/WalletItem.js +6 -3
- package/lib/module/partials/w3m-all-wallets-list/components/WalletItem.js.map +1 -1
- package/lib/module/partials/w3m-all-wallets-list/components/WalletList.js +67 -23
- package/lib/module/partials/w3m-all-wallets-list/components/WalletList.js.map +1 -1
- package/lib/module/partials/w3m-all-wallets-list/index.js +3 -2
- package/lib/module/partials/w3m-all-wallets-list/index.js.map +1 -1
- package/lib/module/partials/w3m-all-wallets-search/index.js +5 -2
- package/lib/module/partials/w3m-all-wallets-search/index.js.map +1 -1
- package/lib/module/partials/w3m-connecting-mobile/index.js +22 -2
- package/lib/module/partials/w3m-connecting-mobile/index.js.map +1 -1
- package/lib/module/partials/w3m-connecting-qrcode/index.js +6 -2
- package/lib/module/partials/w3m-connecting-qrcode/index.js.map +1 -1
- package/lib/module/partials/w3m-connecting-web/index.js +9 -3
- package/lib/module/partials/w3m-connecting-web/index.js.map +1 -1
- package/lib/module/partials/w3m-header/index.js +4 -4
- package/lib/module/partials/w3m-header/index.js.map +1 -1
- package/lib/module/utils/SIWXUtil.js +275 -0
- package/lib/module/utils/SIWXUtil.js.map +1 -0
- package/lib/module/views/w3m-account-default-view/index.js +4 -3
- package/lib/module/views/w3m-account-default-view/index.js.map +1 -1
- package/lib/module/views/w3m-all-wallets-view/index.js +7 -4
- package/lib/module/views/w3m-all-wallets-view/index.js.map +1 -1
- package/lib/module/views/w3m-connect-view/components/all-wallet-list.js +34 -7
- package/lib/module/views/w3m-connect-view/components/all-wallet-list.js.map +1 -1
- package/lib/module/views/w3m-connect-view/index.js +6 -3
- package/lib/module/views/w3m-connect-view/index.js.map +1 -1
- package/lib/module/views/w3m-connecting-external-view/index.js +22 -2
- package/lib/module/views/w3m-connecting-external-view/index.js.map +1 -1
- package/lib/module/views/w3m-connecting-social-view/index.js +2 -1
- package/lib/module/views/w3m-connecting-social-view/index.js.map +1 -1
- package/lib/module/views/w3m-connecting-view/index.js +14 -33
- package/lib/module/views/w3m-connecting-view/index.js.map +1 -1
- package/lib/module/views/w3m-network-switch-view/index.js +2 -1
- package/lib/module/views/w3m-network-switch-view/index.js.map +1 -1
- package/lib/module/views/w3m-onramp-settings-view/components/Country.js +3 -1
- package/lib/module/views/w3m-onramp-settings-view/components/Country.js.map +1 -1
- package/lib/module/views/w3m-onramp-settings-view/index.js +2 -1
- package/lib/module/views/w3m-onramp-settings-view/index.js.map +1 -1
- package/lib/module/views/w3m-onramp-view/components/LoadingView.js +1 -1
- package/lib/module/views/w3m-onramp-view/components/LoadingView.js.map +1 -1
- package/lib/module/views/{w3m-connecting-siwe-view → w3m-siwx-sign-view}/index.js +7 -43
- package/lib/module/views/w3m-siwx-sign-view/index.js.map +1 -0
- package/lib/module/views/w3m-siwx-sign-view/styles.js.map +1 -0
- package/lib/module/views/w3m-swap-view/index.js +1 -1
- package/lib/module/views/w3m-swap-view/index.js.map +1 -1
- package/lib/module/views/w3m-what-is-a-wallet-view/index.js +1 -1
- package/lib/module/views/w3m-what-is-a-wallet-view/index.js.map +1 -1
- package/lib/typescript/AppKit.d.ts +13 -4
- package/lib/typescript/AppKit.d.ts.map +1 -1
- package/lib/typescript/AppKitContext.d.ts +1 -1
- package/lib/typescript/AppKitContext.d.ts.map +1 -1
- package/lib/typescript/connectors/WalletConnectConnector.d.ts.map +1 -1
- package/lib/typescript/hooks/useAccount.d.ts +1 -1
- package/lib/typescript/hooks/useAccount.d.ts.map +1 -1
- package/lib/typescript/hooks/useAppKit.d.ts +2 -2
- package/lib/typescript/hooks/useAppKit.d.ts.map +1 -1
- package/lib/typescript/hooks/useAppKitEvents.d.ts +88 -21
- package/lib/typescript/hooks/useAppKitEvents.d.ts.map +1 -1
- package/lib/typescript/hooks/useAppKitLogs.d.ts +57 -0
- package/lib/typescript/hooks/useAppKitLogs.d.ts.map +1 -0
- package/lib/typescript/hooks/useAppKitState.d.ts +38 -0
- package/lib/typescript/hooks/useAppKitState.d.ts.map +1 -0
- package/lib/typescript/hooks/useProvider.d.ts.map +1 -1
- package/lib/typescript/hooks/useWalletInfo.d.ts +1 -0
- package/lib/typescript/hooks/useWalletInfo.d.ts.map +1 -1
- package/lib/typescript/index.d.ts +6 -0
- package/lib/typescript/index.d.ts.map +1 -1
- package/lib/typescript/modal/w3m-modal/index.d.ts.map +1 -1
- package/lib/typescript/modal/w3m-router/index.d.ts.map +1 -1
- package/lib/typescript/partials/w3m-all-wallets-list/components/WalletItem.d.ts +4 -2
- package/lib/typescript/partials/w3m-all-wallets-list/components/WalletItem.d.ts.map +1 -1
- package/lib/typescript/partials/w3m-all-wallets-list/components/WalletList.d.ts +4 -2
- package/lib/typescript/partials/w3m-all-wallets-list/components/WalletList.d.ts.map +1 -1
- package/lib/typescript/partials/w3m-all-wallets-list/index.d.ts +1 -1
- package/lib/typescript/partials/w3m-all-wallets-list/index.d.ts.map +1 -1
- package/lib/typescript/partials/w3m-all-wallets-search/index.d.ts +1 -1
- package/lib/typescript/partials/w3m-all-wallets-search/index.d.ts.map +1 -1
- package/lib/typescript/partials/w3m-connecting-mobile/index.d.ts.map +1 -1
- package/lib/typescript/partials/w3m-connecting-qrcode/index.d.ts.map +1 -1
- package/lib/typescript/partials/w3m-connecting-web/index.d.ts.map +1 -1
- package/lib/typescript/types.d.ts +6 -7
- package/lib/typescript/types.d.ts.map +1 -1
- package/lib/typescript/utils/SIWXUtil.d.ts +34 -0
- package/lib/typescript/utils/SIWXUtil.d.ts.map +1 -0
- package/lib/typescript/views/w3m-account-default-view/index.d.ts.map +1 -1
- package/lib/typescript/views/w3m-all-wallets-view/index.d.ts.map +1 -1
- package/lib/typescript/views/w3m-connect-view/components/all-wallet-list.d.ts +1 -1
- package/lib/typescript/views/w3m-connect-view/components/all-wallet-list.d.ts.map +1 -1
- package/lib/typescript/views/w3m-connect-view/index.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-social-view/index.d.ts.map +1 -1
- package/lib/typescript/views/w3m-connecting-view/index.d.ts.map +1 -1
- package/lib/typescript/views/w3m-network-switch-view/index.d.ts.map +1 -1
- package/lib/typescript/views/w3m-onramp-settings-view/components/Country.d.ts +2 -1
- package/lib/typescript/views/w3m-onramp-settings-view/components/Country.d.ts.map +1 -1
- package/lib/typescript/views/w3m-onramp-settings-view/index.d.ts.map +1 -1
- package/lib/typescript/views/w3m-siwx-sign-view/index.d.ts +2 -0
- package/lib/typescript/views/w3m-siwx-sign-view/index.d.ts.map +1 -0
- package/lib/typescript/views/w3m-siwx-sign-view/styles.d.ts.map +1 -0
- package/package.json +9 -9
- package/src/AppKit.ts +148 -97
- package/src/AppKitContext.tsx +19 -11
- package/src/connectors/WalletConnectConnector.ts +33 -69
- package/src/hooks/useAccount.ts +9 -4
- package/src/hooks/useAppKit.ts +19 -13
- package/src/hooks/useAppKitLogs.ts +129 -0
- package/src/hooks/useAppKitState.ts +26 -0
- package/src/hooks/useProvider.ts +21 -6
- package/src/hooks/useWalletInfo.ts +5 -2
- package/src/index.ts +14 -0
- package/src/modal/w3m-modal/index.tsx +9 -1
- package/src/modal/w3m-router/index.tsx +15 -18
- package/src/partials/w3m-account-wallet-features/index.tsx +1 -1
- package/src/partials/w3m-all-wallets-list/components/WalletItem.tsx +13 -3
- package/src/partials/w3m-all-wallets-list/components/WalletList.tsx +79 -24
- package/src/partials/w3m-all-wallets-list/index.tsx +4 -2
- package/src/partials/w3m-all-wallets-search/index.tsx +16 -3
- package/src/partials/w3m-connecting-mobile/index.tsx +24 -2
- package/src/partials/w3m-connecting-qrcode/index.tsx +8 -2
- package/src/partials/w3m-connecting-web/index.tsx +11 -3
- package/src/partials/w3m-header/index.tsx +4 -4
- package/src/types.ts +7 -8
- package/src/utils/SIWXUtil.ts +359 -0
- package/src/views/w3m-account-default-view/index.tsx +5 -3
- package/src/views/w3m-all-wallets-view/index.tsx +11 -4
- package/src/views/w3m-connect-view/components/all-wallet-list.tsx +46 -15
- package/src/views/w3m-connect-view/index.tsx +6 -3
- package/src/views/w3m-connecting-external-view/index.tsx +24 -2
- package/src/views/w3m-connecting-social-view/index.tsx +3 -1
- package/src/views/w3m-connecting-view/index.tsx +16 -33
- package/src/views/w3m-network-switch-view/index.tsx +2 -0
- package/src/views/w3m-onramp-settings-view/components/Country.tsx +3 -1
- package/src/views/w3m-onramp-settings-view/index.tsx +1 -0
- package/src/views/w3m-onramp-view/components/LoadingView.tsx +1 -1
- package/src/views/{w3m-connecting-siwe-view → w3m-siwx-sign-view}/index.tsx +7 -37
- package/src/views/w3m-swap-view/index.tsx +1 -1
- package/src/views/w3m-what-is-a-wallet-view/index.tsx +1 -1
- package/lib/commonjs/views/w3m-connecting-siwe-view/index.js.map +0 -1
- package/lib/commonjs/views/w3m-connecting-siwe-view/styles.js.map +0 -1
- package/lib/module/views/w3m-connecting-siwe-view/index.js.map +0 -1
- package/lib/module/views/w3m-connecting-siwe-view/styles.js.map +0 -1
- package/lib/typescript/views/w3m-connecting-siwe-view/index.d.ts +0 -2
- package/lib/typescript/views/w3m-connecting-siwe-view/index.d.ts.map +0 -1
- package/lib/typescript/views/w3m-connecting-siwe-view/styles.d.ts.map +0 -1
- /package/lib/commonjs/views/{w3m-connecting-siwe-view → w3m-siwx-sign-view}/styles.js +0 -0
- /package/lib/module/views/{w3m-connecting-siwe-view → w3m-siwx-sign-view}/styles.js +0 -0
- /package/lib/typescript/views/{w3m-connecting-siwe-view → w3m-siwx-sign-view}/styles.d.ts +0 -0
- /package/src/views/{w3m-connecting-siwe-view → w3m-siwx-sign-view}/styles.ts +0 -0
package/src/hooks/useAccount.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
/* eslint-disable valtio/state-snapshot-rule */
|
|
2
|
+
import { useMemo } from 'react';
|
|
1
3
|
import { useSnapshot } from 'valtio';
|
|
2
4
|
import { ConnectionsController, CoreHelperUtil } from '@reown/appkit-core-react-native';
|
|
3
5
|
import { useAppKit } from './useAppKit';
|
|
@@ -12,10 +14,13 @@ export function useAccount() {
|
|
|
12
14
|
networks
|
|
13
15
|
} = useSnapshot(ConnectionsController.state);
|
|
14
16
|
|
|
15
|
-
const activeChain =
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
17
|
+
const activeChain = useMemo(
|
|
18
|
+
() =>
|
|
19
|
+
connection?.caipNetwork
|
|
20
|
+
? networks.find(network => network.caipNetworkId === connection?.caipNetwork)
|
|
21
|
+
: undefined,
|
|
22
|
+
[connection?.caipNetwork, networks]
|
|
23
|
+
);
|
|
19
24
|
|
|
20
25
|
return {
|
|
21
26
|
address: CoreHelperUtil.getPlainAddress(address),
|
package/src/hooks/useAppKit.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import { useContext } from 'react';
|
|
2
|
-
import {
|
|
3
|
-
import { ModalController } from '@reown/appkit-core-react-native';
|
|
1
|
+
import { useContext, useMemo } from 'react';
|
|
2
|
+
import type { ChainNamespace } from '@reown/appkit-common-react-native';
|
|
4
3
|
|
|
5
4
|
import type { AppKit } from '../AppKit';
|
|
6
5
|
import { AppKitContext } from '../AppKitContext';
|
|
@@ -8,28 +7,35 @@ import { AppKitContext } from '../AppKitContext';
|
|
|
8
7
|
interface UseAppKitReturn {
|
|
9
8
|
open: AppKit['open'];
|
|
10
9
|
close: AppKit['close'];
|
|
11
|
-
disconnect: (namespace?:
|
|
10
|
+
disconnect: (namespace?: ChainNamespace) => void;
|
|
12
11
|
switchNetwork: AppKit['switchNetwork'];
|
|
13
|
-
isOpen: boolean;
|
|
14
12
|
}
|
|
15
13
|
|
|
16
14
|
export const useAppKit = (): UseAppKitReturn => {
|
|
17
15
|
const context = useContext(AppKitContext);
|
|
18
|
-
const { open } = useSnapshot(ModalController.state);
|
|
19
16
|
|
|
20
17
|
if (context === undefined) {
|
|
21
18
|
throw new Error('useAppKit must be used within an AppKitProvider');
|
|
22
19
|
}
|
|
20
|
+
|
|
23
21
|
if (!context.appKit) {
|
|
24
22
|
// This might happen if the provider is rendered before AppKit is initialized
|
|
25
23
|
throw new Error('AppKit instance is not yet available in context.');
|
|
26
24
|
}
|
|
27
25
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
26
|
+
const stableFunctions = useMemo(() => {
|
|
27
|
+
if (!context.appKit) {
|
|
28
|
+
throw new Error('AppKit instance is not available');
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
return {
|
|
32
|
+
open: context.appKit.open.bind(context.appKit),
|
|
33
|
+
close: context.appKit.close.bind(context.appKit),
|
|
34
|
+
disconnect: (namespace?: ChainNamespace) =>
|
|
35
|
+
context.appKit!.disconnect.bind(context.appKit!)(namespace),
|
|
36
|
+
switchNetwork: context.appKit.switchNetwork.bind(context.appKit)
|
|
37
|
+
};
|
|
38
|
+
}, [context.appKit]);
|
|
39
|
+
|
|
40
|
+
return stableFunctions;
|
|
35
41
|
};
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
import { useContext, useMemo } from 'react';
|
|
2
|
+
import { useSnapshot } from 'valtio';
|
|
3
|
+
import { LogController, type LogEntry, type LogLevel } from '@reown/appkit-core-react-native';
|
|
4
|
+
import { AppKitContext } from '../AppKitContext';
|
|
5
|
+
|
|
6
|
+
export interface UseAppKitLogsReturn {
|
|
7
|
+
/**
|
|
8
|
+
* All logs from AppKit
|
|
9
|
+
*/
|
|
10
|
+
logs: LogEntry[];
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Get logs filtered by level
|
|
14
|
+
*/
|
|
15
|
+
getLogsByLevel: (level: LogLevel) => LogEntry[];
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Get recent logs (default: 100)
|
|
19
|
+
*/
|
|
20
|
+
getRecentLogs: (count?: number) => LogEntry[];
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Export all logs as JSON string
|
|
24
|
+
*/
|
|
25
|
+
exportLogs: () => string;
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Get logging statistics by level
|
|
29
|
+
*/
|
|
30
|
+
getLogsStats: () => Record<LogLevel, number>;
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Clear all logs
|
|
34
|
+
*/
|
|
35
|
+
clearLogs: () => void;
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Convenience getters for different log levels (regular arrays, safe for console.log)
|
|
39
|
+
*/
|
|
40
|
+
errorLogs: LogEntry[];
|
|
41
|
+
warningLogs: LogEntry[];
|
|
42
|
+
infoLogs: LogEntry[];
|
|
43
|
+
debugLogs: LogEntry[];
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* React hook for accessing AppKit logs
|
|
48
|
+
*
|
|
49
|
+
* This hook provides reactive access to AppKit's internal logging system.
|
|
50
|
+
* It automatically updates when new logs are added or when logs are cleaned up.
|
|
51
|
+
*
|
|
52
|
+
* @example
|
|
53
|
+
* ```typescript
|
|
54
|
+
* function MyComponent() {
|
|
55
|
+
* const { logs, errorLogs, exportLogs, clearLogs } = useAppKitLogs();
|
|
56
|
+
*
|
|
57
|
+
* return (
|
|
58
|
+
* <View>
|
|
59
|
+
* <Text>Total logs: {logs.length}</Text>
|
|
60
|
+
* <Text>Error logs: {errorLogs.length}</Text>
|
|
61
|
+
* <Button onPress={clearLogs} title="Clear Logs" />
|
|
62
|
+
* </View>
|
|
63
|
+
* );
|
|
64
|
+
* }
|
|
65
|
+
* ```
|
|
66
|
+
*/
|
|
67
|
+
export const useAppKitLogs = (): UseAppKitLogsReturn => {
|
|
68
|
+
const context = useContext(AppKitContext);
|
|
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
|
+
}
|
|
77
|
+
|
|
78
|
+
const { logs } = useSnapshot(LogController.state);
|
|
79
|
+
|
|
80
|
+
// Memoized functions that don't need to change on every render
|
|
81
|
+
const stableFunctions = useMemo(
|
|
82
|
+
() => ({
|
|
83
|
+
getLogsByLevel: (level: LogLevel) => LogController.getLogsByLevel(level),
|
|
84
|
+
getRecentLogs: (count?: number) => LogController.getRecentLogs(count),
|
|
85
|
+
exportLogs: () => LogController.exportLogs(),
|
|
86
|
+
getLogsStats: () => LogController.getLogsStats(),
|
|
87
|
+
clearLogs: () => LogController.clearLogs()
|
|
88
|
+
}),
|
|
89
|
+
[]
|
|
90
|
+
);
|
|
91
|
+
|
|
92
|
+
const regularArrays = useMemo(() => {
|
|
93
|
+
const allLogs = [...logs]; // Convert proxy to regular array
|
|
94
|
+
const errorLogs: LogEntry[] = [];
|
|
95
|
+
const warningLogs: LogEntry[] = [];
|
|
96
|
+
const infoLogs: LogEntry[] = [];
|
|
97
|
+
const debugLogs: LogEntry[] = [];
|
|
98
|
+
|
|
99
|
+
for (const log of allLogs) {
|
|
100
|
+
switch (log.level) {
|
|
101
|
+
case 'error':
|
|
102
|
+
errorLogs.push(log);
|
|
103
|
+
break;
|
|
104
|
+
case 'warn':
|
|
105
|
+
warningLogs.push(log);
|
|
106
|
+
break;
|
|
107
|
+
case 'info':
|
|
108
|
+
infoLogs.push(log);
|
|
109
|
+
break;
|
|
110
|
+
case 'debug':
|
|
111
|
+
debugLogs.push(log);
|
|
112
|
+
break;
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
return {
|
|
117
|
+
logs: allLogs,
|
|
118
|
+
errorLogs,
|
|
119
|
+
warningLogs,
|
|
120
|
+
infoLogs,
|
|
121
|
+
debugLogs
|
|
122
|
+
};
|
|
123
|
+
}, [logs]);
|
|
124
|
+
|
|
125
|
+
return {
|
|
126
|
+
...regularArrays,
|
|
127
|
+
...stableFunctions
|
|
128
|
+
};
|
|
129
|
+
};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/* eslint-disable valtio/state-snapshot-rule */
|
|
2
|
+
import { useMemo } from 'react';
|
|
3
|
+
import { useSnapshot } from 'valtio';
|
|
4
|
+
import { ConnectionsController, ModalController } from '@reown/appkit-core-react-native';
|
|
5
|
+
import { useAppKit } from './useAppKit';
|
|
6
|
+
|
|
7
|
+
export function useAppKitState() {
|
|
8
|
+
useAppKit(); // Use the hook for checks
|
|
9
|
+
const { activeAddress: address, connection, networks } = useSnapshot(ConnectionsController.state);
|
|
10
|
+
const { open, loading } = useSnapshot(ModalController.state);
|
|
11
|
+
|
|
12
|
+
const activeChain = useMemo(
|
|
13
|
+
() =>
|
|
14
|
+
connection?.caipNetwork
|
|
15
|
+
? networks.find(network => network.caipNetworkId === connection?.caipNetwork)
|
|
16
|
+
: undefined,
|
|
17
|
+
[connection?.caipNetwork, networks]
|
|
18
|
+
);
|
|
19
|
+
|
|
20
|
+
return {
|
|
21
|
+
isOpen: open,
|
|
22
|
+
isLoading: loading,
|
|
23
|
+
isConnected: !!address,
|
|
24
|
+
chain: activeChain
|
|
25
|
+
};
|
|
26
|
+
}
|
package/src/hooks/useProvider.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
|
+
/* eslint-disable valtio/state-snapshot-rule */
|
|
2
|
+
import { useMemo } from 'react';
|
|
1
3
|
import { useSnapshot } from 'valtio';
|
|
2
|
-
import { ConnectionsController } from '@reown/appkit-core-react-native';
|
|
4
|
+
import { ConnectionsController, LogController } from '@reown/appkit-core-react-native';
|
|
3
5
|
import type { Provider, ChainNamespace } from '@reown/appkit-common-react-native';
|
|
4
6
|
|
|
5
7
|
/**
|
|
@@ -37,10 +39,23 @@ interface ProviderResult {
|
|
|
37
39
|
export function useProvider(): ProviderResult {
|
|
38
40
|
const { connection } = useSnapshot(ConnectionsController.state);
|
|
39
41
|
|
|
40
|
-
|
|
42
|
+
const returnValue = useMemo(() => {
|
|
43
|
+
if (!connection || !connection.adapter) {
|
|
44
|
+
return { provider: undefined, providerType: undefined };
|
|
45
|
+
}
|
|
41
46
|
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
47
|
+
try {
|
|
48
|
+
return {
|
|
49
|
+
provider: connection.adapter.getProvider(),
|
|
50
|
+
providerType: connection.adapter.getSupportedNamespace()
|
|
51
|
+
};
|
|
52
|
+
} catch (error) {
|
|
53
|
+
LogController.sendError(error, 'useProvider', 'useProvider');
|
|
54
|
+
|
|
55
|
+
// Provider not initialized yet during session restoration
|
|
56
|
+
return { provider: undefined, providerType: undefined };
|
|
57
|
+
}
|
|
58
|
+
}, [connection]);
|
|
59
|
+
|
|
60
|
+
return returnValue;
|
|
46
61
|
}
|
|
@@ -1,10 +1,13 @@
|
|
|
1
|
+
import { useMemo } from 'react';
|
|
1
2
|
import { useSnapshot } from 'valtio';
|
|
2
3
|
import { ConnectionsController } from '@reown/appkit-core-react-native';
|
|
3
4
|
import { useAppKit } from './useAppKit';
|
|
4
5
|
|
|
5
6
|
export function useWalletInfo() {
|
|
6
7
|
useAppKit(); // Use the hook for checks
|
|
7
|
-
const { walletInfo } = useSnapshot(ConnectionsController.state);
|
|
8
|
+
const { walletInfo: walletInfoSnapshot } = useSnapshot(ConnectionsController.state);
|
|
8
9
|
|
|
9
|
-
|
|
10
|
+
const walletInfo = useMemo(() => ({ walletInfo: walletInfoSnapshot }), [walletInfoSnapshot]);
|
|
11
|
+
|
|
12
|
+
return walletInfo;
|
|
10
13
|
}
|
package/src/index.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import '@walletconnect/react-native-compat';
|
|
2
|
+
|
|
1
3
|
/********** Components **********/
|
|
2
4
|
export {
|
|
3
5
|
AccountButton as AccountButton,
|
|
@@ -17,6 +19,13 @@ export { AppKit } from './modal/w3m-modal';
|
|
|
17
19
|
/********** Types **********/
|
|
18
20
|
export type * from '@reown/appkit-core-react-native';
|
|
19
21
|
export type { AppKitNetwork, Storage } from '@reown/appkit-common-react-native';
|
|
22
|
+
export type {
|
|
23
|
+
SIWXConfig,
|
|
24
|
+
SIWXMessage,
|
|
25
|
+
SIWXSession,
|
|
26
|
+
SIWXStorage,
|
|
27
|
+
SIWXVerifier
|
|
28
|
+
} from '@reown/appkit-common-react-native';
|
|
20
29
|
export type { AppKitConfig } from './types';
|
|
21
30
|
|
|
22
31
|
/****** Hooks *******/
|
|
@@ -25,11 +34,16 @@ export { useProvider } from './hooks/useProvider';
|
|
|
25
34
|
export { useAccount } from './hooks/useAccount';
|
|
26
35
|
export { useWalletInfo } from './hooks/useWalletInfo';
|
|
27
36
|
export { useAppKitEvents, useAppKitEventSubscription } from './hooks/useAppKitEvents';
|
|
37
|
+
export { useAppKitState } from './hooks/useAppKitState';
|
|
38
|
+
export { useAppKitLogs, type UseAppKitLogsReturn } from './hooks/useAppKitLogs';
|
|
28
39
|
|
|
29
40
|
/********** Networks **********/
|
|
30
41
|
export { solana, solanaDevnet, solanaTestnet } from '@reown/appkit-common-react-native';
|
|
31
42
|
export { bitcoin, bitcoinTestnet } from '@reown/appkit-common-react-native';
|
|
32
43
|
|
|
44
|
+
/********** SIWX **********/
|
|
45
|
+
export { ReownAuthentication } from '@reown/appkit-core-react-native';
|
|
46
|
+
|
|
33
47
|
/********** Main **********/
|
|
34
48
|
export { createAppKit } from './AppKit';
|
|
35
49
|
export { AppKitProvider } from './AppKitContext';
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { useSnapshot } from 'valtio';
|
|
2
2
|
import { useCallback, useEffect } from 'react';
|
|
3
|
+
import { useColorScheme } from 'react-native';
|
|
3
4
|
import { Card, Modal, ThemeProvider } from '@reown/appkit-ui-react-native';
|
|
4
5
|
import {
|
|
5
6
|
ApiController,
|
|
@@ -18,10 +19,11 @@ import { useInternalAppKit } from '../../AppKitContext';
|
|
|
18
19
|
import styles from './styles';
|
|
19
20
|
|
|
20
21
|
export function AppKit() {
|
|
22
|
+
const theme = useColorScheme();
|
|
21
23
|
const { bottom, top } = useSafeAreaInsets();
|
|
22
24
|
const { close } = useInternalAppKit();
|
|
23
25
|
const { open } = useSnapshot(ModalController.state);
|
|
24
|
-
const { themeMode, themeVariables } = useSnapshot(ThemeController.state);
|
|
26
|
+
const { themeMode, themeVariables, defaultThemeMode } = useSnapshot(ThemeController.state);
|
|
25
27
|
const { projectId } = useSnapshot(OptionsController.state);
|
|
26
28
|
|
|
27
29
|
const handleBackPress = () => {
|
|
@@ -32,6 +34,12 @@ export function AppKit() {
|
|
|
32
34
|
return handleModalClose();
|
|
33
35
|
};
|
|
34
36
|
|
|
37
|
+
useEffect(() => {
|
|
38
|
+
if (theme && !defaultThemeMode) {
|
|
39
|
+
ThemeController.setThemeMode(theme);
|
|
40
|
+
}
|
|
41
|
+
}, [theme, defaultThemeMode]);
|
|
42
|
+
|
|
35
43
|
const prefetch = useCallback(async () => {
|
|
36
44
|
await ApiController.prefetch();
|
|
37
45
|
EventsController.sendEvent({ type: 'track', event: 'MODAL_LOADED' });
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { useSnapshot } from 'valtio';
|
|
2
|
-
import {
|
|
2
|
+
import { useMemo } from 'react';
|
|
3
3
|
import { RouterController } from '@reown/appkit-core-react-native';
|
|
4
4
|
|
|
5
5
|
import { AccountDefaultView } from '../../views/w3m-account-default-view';
|
|
@@ -10,7 +10,7 @@ import { ConnectSocialsView } from '../../views/w3m-connect-socials-view';
|
|
|
10
10
|
import { ConnectingView } from '../../views/w3m-connecting-view';
|
|
11
11
|
import { ConnectingExternalView } from '../../views/w3m-connecting-external-view';
|
|
12
12
|
import { ConnectingSocialView } from '../../views/w3m-connecting-social-view';
|
|
13
|
-
import {
|
|
13
|
+
import { SIWXSignMessageView } from '../../views/w3m-siwx-sign-view';
|
|
14
14
|
import { GetWalletView } from '../../views/w3m-get-wallet-view';
|
|
15
15
|
import { NetworksView } from '../../views/w3m-networks-view';
|
|
16
16
|
import { NetworkSwitchView } from '../../views/w3m-network-switch-view';
|
|
@@ -31,8 +31,8 @@ import { WalletSendPreviewView } from '../../views/w3m-wallet-send-preview-view'
|
|
|
31
31
|
import { WalletSendSelectTokenView } from '../../views/w3m-wallet-send-select-token-view';
|
|
32
32
|
import { WhatIsANetworkView } from '../../views/w3m-what-is-a-network-view';
|
|
33
33
|
import { WhatIsAWalletView } from '../../views/w3m-what-is-a-wallet-view';
|
|
34
|
-
import { UiUtil } from '../../utils/UiUtil';
|
|
35
|
-
import { useRouteTransition } from '../../hooks/useRouteTransition';
|
|
34
|
+
// import { UiUtil } from '../../utils/UiUtil';
|
|
35
|
+
// import { useRouteTransition } from '../../hooks/useRouteTransition';
|
|
36
36
|
|
|
37
37
|
import { Animated } from 'react-native';
|
|
38
38
|
import { useCustomDimensions } from '@reown/appkit-ui-react-native';
|
|
@@ -40,18 +40,15 @@ import { useCustomDimensions } from '@reown/appkit-ui-react-native';
|
|
|
40
40
|
export function AppKitRouter() {
|
|
41
41
|
const { view } = useSnapshot(RouterController.state);
|
|
42
42
|
const { maxHeight } = useCustomDimensions();
|
|
43
|
-
const { animateTransition, getAnimatedStyle } = useRouteTransition(
|
|
44
|
-
duration: 300,
|
|
45
|
-
useNativeDriver: true
|
|
46
|
-
});
|
|
43
|
+
// const { animateTransition, getAnimatedStyle } = useRouteTransition();
|
|
47
44
|
|
|
48
|
-
useEffect(() => {
|
|
49
|
-
|
|
50
|
-
}, [animateTransition]);
|
|
45
|
+
// useEffect(() => {
|
|
46
|
+
// UiUtil.setRouteTransition(animateTransition);
|
|
47
|
+
// }, [animateTransition]);
|
|
51
48
|
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
}, [view]);
|
|
49
|
+
// useEffect(() => {
|
|
50
|
+
// UiUtil.createViewTransition();
|
|
51
|
+
// }, [view]);
|
|
55
52
|
|
|
56
53
|
const ViewComponent = useMemo(() => {
|
|
57
54
|
switch (view) {
|
|
@@ -67,11 +64,11 @@ export function AppKitRouter() {
|
|
|
67
64
|
return ConnectSocialsView;
|
|
68
65
|
case 'ConnectingExternal':
|
|
69
66
|
return ConnectingExternalView;
|
|
70
|
-
case '
|
|
71
|
-
return
|
|
67
|
+
case 'SIWXSignMessage':
|
|
68
|
+
return SIWXSignMessageView;
|
|
72
69
|
case 'ConnectingSocial':
|
|
73
70
|
return ConnectingSocialView;
|
|
74
|
-
case '
|
|
71
|
+
case 'WalletConnect':
|
|
75
72
|
return ConnectingView;
|
|
76
73
|
case 'GetWallet':
|
|
77
74
|
return GetWalletView;
|
|
@@ -119,7 +116,7 @@ export function AppKitRouter() {
|
|
|
119
116
|
}, [view]);
|
|
120
117
|
|
|
121
118
|
return (
|
|
122
|
-
<Animated.View style={
|
|
119
|
+
<Animated.View style={{ maxHeight }}>
|
|
123
120
|
<ViewComponent />
|
|
124
121
|
</Animated.View>
|
|
125
122
|
);
|
|
@@ -21,7 +21,7 @@ export function AccountWalletFeatures() {
|
|
|
21
21
|
const { features, isOnRampEnabled } = useSnapshot(OptionsController.state);
|
|
22
22
|
const { activeNetwork, balances, activeNamespace } = useSnapshot(ConnectionsController.state);
|
|
23
23
|
const balance = CoreHelperUtil.calculateAndFormatBalance(balances as BalanceType[]);
|
|
24
|
-
const network = ConnectionsController.state.activeNetwork?.caipNetworkId
|
|
24
|
+
const network = ConnectionsController.state.activeNetwork?.caipNetworkId;
|
|
25
25
|
const isSmartAccount = ConnectionsController.state.accountType === 'smartAccount';
|
|
26
26
|
const showSend =
|
|
27
27
|
activeNamespace && ConstantsUtil.SEND_SUPPORTED_NAMESPACES.includes(activeNamespace);
|
|
@@ -7,12 +7,21 @@ import { memo } from 'react';
|
|
|
7
7
|
|
|
8
8
|
interface WalletItemProps {
|
|
9
9
|
item: WcWallet;
|
|
10
|
+
displayIndex: number;
|
|
10
11
|
imageHeaders?: Record<string, string>;
|
|
11
|
-
onItemPress: (wallet: WcWallet) => void;
|
|
12
|
+
onItemPress: (wallet: WcWallet, displayIndex: number) => void;
|
|
12
13
|
style?: StyleProp<ViewStyle>;
|
|
14
|
+
testID?: string;
|
|
13
15
|
}
|
|
14
16
|
|
|
15
|
-
export function WalletItem({
|
|
17
|
+
export function WalletItem({
|
|
18
|
+
item,
|
|
19
|
+
displayIndex,
|
|
20
|
+
imageHeaders,
|
|
21
|
+
onItemPress,
|
|
22
|
+
style,
|
|
23
|
+
testID
|
|
24
|
+
}: WalletItemProps) {
|
|
16
25
|
const { walletImages } = useSnapshot(AssetController.state);
|
|
17
26
|
const isInstalled = ApiController.state.installed.find(wallet => wallet?.id === item?.id);
|
|
18
27
|
const imageSrc = AssetUtil.getWalletImage(item, walletImages);
|
|
@@ -27,8 +36,9 @@ export function WalletItem({ item, imageHeaders, onItemPress, style }: WalletIte
|
|
|
27
36
|
style={style}
|
|
28
37
|
imageHeaders={imageHeaders}
|
|
29
38
|
name={item?.name ?? 'Unknown'}
|
|
30
|
-
onPress={() => onItemPress(item)}
|
|
39
|
+
onPress={() => onItemPress(item, displayIndex)}
|
|
31
40
|
installed={!!isInstalled}
|
|
41
|
+
testID={testID}
|
|
32
42
|
/>
|
|
33
43
|
);
|
|
34
44
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { FlatList, StyleSheet, type StyleProp, type ViewStyle } from 'react-native';
|
|
1
|
+
import { FlatList, StyleSheet, type StyleProp, type ViewStyle, type ViewToken } from 'react-native';
|
|
2
2
|
import { WalletItem } from './WalletItem';
|
|
3
3
|
import {
|
|
4
4
|
CardSelectHeight,
|
|
@@ -7,8 +7,9 @@ import {
|
|
|
7
7
|
CardSelectLoader,
|
|
8
8
|
CardSelectWidth
|
|
9
9
|
} from '@reown/appkit-ui-react-native';
|
|
10
|
-
import { ApiController } from '@reown/appkit-core-react-native';
|
|
10
|
+
import { ApiController, EventsController } from '@reown/appkit-core-react-native';
|
|
11
11
|
import type { WcWallet } from '@reown/appkit-common-react-native';
|
|
12
|
+
import { useCallback, useRef } from 'react';
|
|
12
13
|
|
|
13
14
|
const imageHeaders = ApiController._getApiHeaders();
|
|
14
15
|
|
|
@@ -18,12 +19,14 @@ const ITEM_HEIGHT_WITH_GAP = ITEM_HEIGHT + Spacing['3xs'];
|
|
|
18
19
|
|
|
19
20
|
interface Props {
|
|
20
21
|
data: WcWallet[];
|
|
21
|
-
onItemPress: (wallet: WcWallet) => void;
|
|
22
|
+
onItemPress: (wallet: WcWallet, displayIndex: number) => void;
|
|
22
23
|
onEndReached?: () => void;
|
|
23
24
|
onEndReachedThreshold?: number;
|
|
24
25
|
isLoading?: boolean;
|
|
25
26
|
loadingItems?: number;
|
|
26
27
|
style?: StyleProp<ViewStyle>;
|
|
28
|
+
testIDKey?: string;
|
|
29
|
+
searchQuery?: string;
|
|
27
30
|
}
|
|
28
31
|
|
|
29
32
|
export function WalletList({
|
|
@@ -33,15 +36,78 @@ export function WalletList({
|
|
|
33
36
|
onEndReachedThreshold,
|
|
34
37
|
isLoading = false,
|
|
35
38
|
loadingItems = 20,
|
|
36
|
-
|
|
39
|
+
testIDKey,
|
|
40
|
+
style,
|
|
41
|
+
searchQuery
|
|
37
42
|
}: Props) {
|
|
38
43
|
const { padding, maxHeight } = useCustomDimensions();
|
|
44
|
+
const viewedWalletsRef = useRef<Set<string>>(new Set());
|
|
39
45
|
|
|
40
46
|
// Create loading data if isLoading is true
|
|
41
47
|
const displayData = isLoading
|
|
42
48
|
? Array.from({ length: loadingItems }, (_, index) => ({ id: `loading-${index}` }) as WcWallet)
|
|
43
49
|
: data;
|
|
44
50
|
|
|
51
|
+
const keyExtractor = useCallback(
|
|
52
|
+
(item: WcWallet, index: number) => item?.id ?? `item-${index}`,
|
|
53
|
+
[]
|
|
54
|
+
);
|
|
55
|
+
|
|
56
|
+
const getItemLayout = useCallback((_: any, index: number) => {
|
|
57
|
+
return {
|
|
58
|
+
length: ITEM_HEIGHT_WITH_GAP,
|
|
59
|
+
offset: ITEM_HEIGHT_WITH_GAP * index,
|
|
60
|
+
index
|
|
61
|
+
};
|
|
62
|
+
}, []);
|
|
63
|
+
|
|
64
|
+
const renderItem = useCallback(
|
|
65
|
+
({ item, index }: { item: WcWallet; index: number }) => {
|
|
66
|
+
if (isLoading) {
|
|
67
|
+
return <CardSelectLoader style={styles.itemContainer} />;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
return (
|
|
71
|
+
<WalletItem
|
|
72
|
+
item={item}
|
|
73
|
+
imageHeaders={imageHeaders}
|
|
74
|
+
displayIndex={index}
|
|
75
|
+
onItemPress={onItemPress}
|
|
76
|
+
style={styles.itemContainer}
|
|
77
|
+
testID={testIDKey ? `${testIDKey}-${item?.id}` : undefined}
|
|
78
|
+
/>
|
|
79
|
+
);
|
|
80
|
+
},
|
|
81
|
+
[isLoading, onItemPress, testIDKey]
|
|
82
|
+
);
|
|
83
|
+
|
|
84
|
+
const onViewableItemsChanged = useCallback(
|
|
85
|
+
({ viewableItems }: { viewableItems: ViewToken[] }) => {
|
|
86
|
+
if (isLoading) return;
|
|
87
|
+
|
|
88
|
+
viewableItems.forEach(({ item }, index) => {
|
|
89
|
+
const wallet = item as WcWallet;
|
|
90
|
+
if (wallet?.id && !viewedWalletsRef.current.has(wallet.id)) {
|
|
91
|
+
viewedWalletsRef.current.add(wallet.id);
|
|
92
|
+
const isInstalled = !!ApiController.state.installed.find(w => w?.id === item?.id);
|
|
93
|
+
EventsController.trackWalletImpression({
|
|
94
|
+
wallet,
|
|
95
|
+
view: 'AllWallets',
|
|
96
|
+
displayIndex: index,
|
|
97
|
+
query: searchQuery,
|
|
98
|
+
installed: isInstalled
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
});
|
|
102
|
+
},
|
|
103
|
+
[isLoading, searchQuery]
|
|
104
|
+
);
|
|
105
|
+
|
|
106
|
+
const viewabilityConfig = useRef({
|
|
107
|
+
itemVisiblePercentThreshold: 50, // Item is considered visible when 50% is visible
|
|
108
|
+
minimumViewTime: 100 // Must be visible for at least 100ms
|
|
109
|
+
}).current;
|
|
110
|
+
|
|
45
111
|
return (
|
|
46
112
|
<FlatList
|
|
47
113
|
fadingEdgeLength={20}
|
|
@@ -50,29 +116,18 @@ export function WalletList({
|
|
|
50
116
|
data={displayData}
|
|
51
117
|
style={[styles.list, { height: maxHeight }, style]}
|
|
52
118
|
columnWrapperStyle={styles.columnWrapperStyle}
|
|
53
|
-
renderItem={
|
|
54
|
-
if (isLoading) {
|
|
55
|
-
return <CardSelectLoader style={styles.itemContainer} />;
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
return (
|
|
59
|
-
<WalletItem
|
|
60
|
-
item={item}
|
|
61
|
-
imageHeaders={imageHeaders}
|
|
62
|
-
onItemPress={onItemPress}
|
|
63
|
-
style={styles.itemContainer}
|
|
64
|
-
/>
|
|
65
|
-
);
|
|
66
|
-
}}
|
|
119
|
+
renderItem={renderItem}
|
|
67
120
|
contentContainerStyle={[styles.contentContainer, { paddingHorizontal: padding }]}
|
|
121
|
+
initialNumToRender={32}
|
|
122
|
+
maxToRenderPerBatch={12}
|
|
123
|
+
windowSize={10}
|
|
68
124
|
onEndReached={onEndReached}
|
|
69
125
|
onEndReachedThreshold={onEndReachedThreshold}
|
|
70
|
-
keyExtractor={
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
})}
|
|
126
|
+
keyExtractor={keyExtractor}
|
|
127
|
+
removeClippedSubviews={true}
|
|
128
|
+
getItemLayout={getItemLayout}
|
|
129
|
+
onViewableItemsChanged={onViewableItemsChanged}
|
|
130
|
+
viewabilityConfig={viewabilityConfig}
|
|
76
131
|
/>
|
|
77
132
|
);
|
|
78
133
|
}
|
|
@@ -2,6 +2,7 @@ import { useEffect, useState } from 'react';
|
|
|
2
2
|
import { useSnapshot } from 'valtio';
|
|
3
3
|
import {
|
|
4
4
|
ApiController,
|
|
5
|
+
LogController,
|
|
5
6
|
OptionsController,
|
|
6
7
|
SnackController,
|
|
7
8
|
type OptionsControllerState
|
|
@@ -14,7 +15,7 @@ import { Loading } from './components/Loading';
|
|
|
14
15
|
import { WalletList } from './components/WalletList';
|
|
15
16
|
|
|
16
17
|
interface AllWalletsListProps {
|
|
17
|
-
onItemPress: (wallet: WcWallet) => void;
|
|
18
|
+
onItemPress: (wallet: WcWallet, displayIndex: number) => void;
|
|
18
19
|
headerHeight?: number;
|
|
19
20
|
}
|
|
20
21
|
|
|
@@ -61,6 +62,7 @@ export function AllWalletsList({ onItemPress }: AllWalletsListProps) {
|
|
|
61
62
|
await ApiController.fetchWallets({ page: 1 });
|
|
62
63
|
setLoading(false);
|
|
63
64
|
} catch (error) {
|
|
65
|
+
LogController.sendError(error, 'AllWalletsList.tsx', 'initialFetch');
|
|
64
66
|
SnackController.showError('Failed to load wallets');
|
|
65
67
|
setLoading(false);
|
|
66
68
|
setLoadingError(true);
|
|
@@ -114,7 +116,7 @@ export function AllWalletsList({ onItemPress }: AllWalletsListProps) {
|
|
|
114
116
|
<WalletList
|
|
115
117
|
data={walletList}
|
|
116
118
|
onEndReached={fetchNextPage}
|
|
117
|
-
onEndReachedThreshold={
|
|
119
|
+
onEndReachedThreshold={0.5}
|
|
118
120
|
onItemPress={onItemPress}
|
|
119
121
|
/>
|
|
120
122
|
);
|