@openfort/react-native 0.1.9 → 0.1.10
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/dist/components/AuthBoundary.js +7 -8
- package/dist/components/index.js +3 -6
- package/dist/constants/config.js +2 -2
- package/dist/core/client.js +31 -10
- package/dist/core/context.js +41 -4
- package/dist/core/provider.js +35 -4
- package/dist/core/storage.js +17 -7
- package/dist/hooks/auth/index.js +1 -1
- package/dist/hooks/auth/useCreateWalletPostAuth.js +9 -1
- package/dist/hooks/auth/useEmailAuth.js +26 -0
- package/dist/hooks/auth/useGuestAuth.js +21 -0
- package/dist/hooks/auth/useOAuth.js +15 -21
- package/dist/hooks/auth/useSignOut.js +32 -0
- package/dist/hooks/auth/useWalletAuth.js +25 -0
- package/dist/hooks/core/index.js +1 -1
- package/dist/hooks/core/useOpenfort.js +24 -27
- package/dist/hooks/core/useOpenfortClient.js +8 -13
- package/dist/hooks/core/useUser.js +28 -0
- package/dist/hooks/index.js +7 -6
- package/dist/hooks/wallet/index.js +1 -1
- package/dist/hooks/wallet/useWallet.js +27 -0
- package/dist/hooks/wallet/useWallets.js +21 -19
- package/dist/index.js +5 -6
- package/dist/lib/hookConsistency.js +42 -0
- package/dist/native/oauth.js +38 -1
- package/dist/native/storage.js +23 -8
- package/dist/types/components/AuthBoundary.d.ts +7 -8
- package/dist/types/components/index.d.ts +3 -6
- package/dist/types/constants/config.d.ts +2 -2
- package/dist/types/core/client.d.ts +22 -6
- package/dist/types/core/context.d.ts +56 -19
- package/dist/types/core/provider.d.ts +55 -29
- package/dist/types/core/storage.d.ts +7 -4
- package/dist/types/hooks/auth/index.d.ts +1 -1
- package/dist/types/hooks/auth/useCreateWalletPostAuth.d.ts +9 -0
- package/dist/types/hooks/auth/useEmailAuth.d.ts +26 -0
- package/dist/types/hooks/auth/useGuestAuth.d.ts +16 -18
- package/dist/types/hooks/auth/useOAuth.d.ts +15 -21
- package/dist/types/hooks/auth/useSignOut.d.ts +32 -0
- package/dist/types/hooks/auth/useWalletAuth.d.ts +25 -3
- package/dist/types/hooks/core/index.d.ts +1 -1
- package/dist/types/hooks/core/useOpenfort.d.ts +24 -24
- package/dist/types/hooks/core/useOpenfortClient.d.ts +8 -16
- package/dist/types/hooks/core/useUser.d.ts +28 -0
- package/dist/types/hooks/index.d.ts +7 -6
- package/dist/types/hooks/wallet/index.d.ts +1 -1
- package/dist/types/hooks/wallet/useWallet.d.ts +27 -0
- package/dist/types/hooks/wallet/useWallets.d.ts +21 -19
- package/dist/types/index.d.ts +5 -6
- package/dist/types/lib/hookConsistency.d.ts +42 -0
- package/dist/types/native/oauth.d.ts +38 -1
- package/dist/types/native/storage.d.ts +21 -9
- package/dist/types/predicates.js +20 -1
- package/dist/types/types/index.d.ts +8 -8
- package/dist/types/types/predicates.d.ts +55 -1
- package/package.json +1 -1
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Hook for embedded Ethereum wallet functionality
|
|
3
|
-
*/
|
|
4
1
|
import { AccountTypeEnum, ChainTypeEnum, Provider, RecoveryParams } from '@openfort/openfort-js';
|
|
5
2
|
import { Hex } from '../../types/hex';
|
|
6
3
|
import { OpenfortHookOptions } from '../../types/hookOption';
|
|
@@ -32,31 +29,36 @@ type WalletOptions = {
|
|
|
32
29
|
chainId?: number;
|
|
33
30
|
} & OpenfortHookOptions<SetActiveWalletResult | CreateWalletResult>;
|
|
34
31
|
/**
|
|
35
|
-
* Hook for interacting with embedded
|
|
32
|
+
* Hook for interacting with embedded wallets
|
|
36
33
|
*
|
|
37
|
-
* This hook manages embedded
|
|
38
|
-
*
|
|
34
|
+
* This hook manages embedded wallets based on the user's state from the provider. Wallet state is determined by
|
|
35
|
+
* polling in the provider, not by local state management. It provides wallet creation, recovery, and management capabilities.
|
|
39
36
|
*
|
|
40
|
-
* @param
|
|
41
|
-
* @returns Current embedded
|
|
37
|
+
* @param hookOptions - Optional configuration with callback functions and chain ID settings
|
|
38
|
+
* @returns Current embedded wallet state with actions and wallet collection
|
|
42
39
|
*
|
|
43
40
|
* @example
|
|
44
41
|
* ```tsx
|
|
45
|
-
* const
|
|
46
|
-
*
|
|
47
|
-
*
|
|
42
|
+
* const { wallets, activeWallet, createWallet, setActiveWallet, isCreating } = useWallets({
|
|
43
|
+
* onSuccess: ({ wallet }) => console.log('Wallet operation successful:', wallet?.address),
|
|
44
|
+
* onError: ({ error }) => console.error('Wallet operation failed:', error?.message),
|
|
45
|
+
* chainId: 1, // Ethereum mainnet
|
|
48
46
|
* });
|
|
49
47
|
*
|
|
50
|
-
* //
|
|
51
|
-
* if (
|
|
52
|
-
* await
|
|
53
|
-
*
|
|
48
|
+
* // Create a new wallet if none exist
|
|
49
|
+
* if (wallets.length === 0 && !isCreating) {
|
|
50
|
+
* await createWallet({ chainId: 1 });
|
|
51
|
+
* }
|
|
52
|
+
*
|
|
53
|
+
* // Use existing wallets
|
|
54
|
+
* if (wallets.length > 0 && !activeWallet) {
|
|
55
|
+
* await setActiveWallet({ address: wallets[0].address });
|
|
54
56
|
* }
|
|
55
57
|
*
|
|
56
|
-
* //
|
|
57
|
-
* if (
|
|
58
|
-
* const provider = await
|
|
59
|
-
* // Use provider for
|
|
58
|
+
* // Access active wallet
|
|
59
|
+
* if (activeWallet) {
|
|
60
|
+
* const provider = await activeWallet.getProvider();
|
|
61
|
+
* // Use provider for transactions
|
|
60
62
|
* }
|
|
61
63
|
* ```
|
|
62
64
|
*/
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* @packageDocumentation
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
* This SDK provides authentication, embedded wallets, session management, and UI components
|
|
6
|
-
* for building decentralized applications on React Native.
|
|
4
|
+
* Entry point for the Openfort React Native SDK.
|
|
7
5
|
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
6
|
+
* This package re-exports the core SDK functionality, hooks, components and native helpers
|
|
7
|
+
* required to integrate Openfort authentication and embedded wallets into React Native and
|
|
8
|
+
* Expo applications.
|
|
10
9
|
*/
|
|
11
10
|
export { AuthPlayerResponse, OpenfortError, RecoveryMethod, Openfort as OpenfortClient, Provider, OpenfortConfiguration, ShieldConfiguration, EmbeddedState, } from '@openfort/openfort-js';
|
|
12
11
|
export { OAuthProvider, } from '@openfort/openfort-js';
|
|
@@ -1,10 +1,52 @@
|
|
|
1
1
|
import { OpenfortHookOptions } from "../types/hookOption";
|
|
2
2
|
import { OpenfortError } from "../types/openfortError";
|
|
3
|
+
/**
|
|
4
|
+
* Handles successful hook operation callbacks
|
|
5
|
+
*
|
|
6
|
+
* This utility function invokes success and settled callbacks from hook options,
|
|
7
|
+
* ensuring consistent callback execution across all hooks in the SDK.
|
|
8
|
+
*
|
|
9
|
+
* @param params - Object containing hook options and success data
|
|
10
|
+
* @returns The success data that was passed in
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* ```tsx
|
|
14
|
+
* const result = await someAsyncOperation();
|
|
15
|
+
* return onSuccess({
|
|
16
|
+
* hookOptions,
|
|
17
|
+
* options,
|
|
18
|
+
* data: { user: result.user },
|
|
19
|
+
* });
|
|
20
|
+
* ```
|
|
21
|
+
*/
|
|
3
22
|
export declare const onSuccess: <T>({ hookOptions, options, data, }: {
|
|
4
23
|
hookOptions?: OpenfortHookOptions<T>;
|
|
5
24
|
options?: OpenfortHookOptions<T>;
|
|
6
25
|
data: T;
|
|
7
26
|
}) => T;
|
|
27
|
+
/**
|
|
28
|
+
* Handles failed hook operation callbacks
|
|
29
|
+
*
|
|
30
|
+
* This utility function invokes error and settled callbacks from hook options,
|
|
31
|
+
* and optionally throws the error if throwOnError is configured.
|
|
32
|
+
*
|
|
33
|
+
* @param params - Object containing hook options and error information
|
|
34
|
+
* @returns Object containing the error, or throws if throwOnError is enabled
|
|
35
|
+
*
|
|
36
|
+
* @example
|
|
37
|
+
* ```tsx
|
|
38
|
+
* try {
|
|
39
|
+
* await someAsyncOperation();
|
|
40
|
+
* } catch (e) {
|
|
41
|
+
* const error = new OpenfortError('Operation failed', OpenfortErrorType.GENERIC);
|
|
42
|
+
* return onError({
|
|
43
|
+
* hookOptions,
|
|
44
|
+
* options,
|
|
45
|
+
* error,
|
|
46
|
+
* });
|
|
47
|
+
* }
|
|
48
|
+
* ```
|
|
49
|
+
*/
|
|
8
50
|
export declare const onError: <T>({ hookOptions, options, error, }: {
|
|
9
51
|
hookOptions?: OpenfortHookOptions<T>;
|
|
10
52
|
options?: OpenfortHookOptions<T>;
|
|
@@ -43,7 +43,25 @@ export declare function authenticateWithApple(options: {
|
|
|
43
43
|
*/
|
|
44
44
|
export declare function isAppleSignInAvailable(): Promise<boolean>;
|
|
45
45
|
/**
|
|
46
|
-
* Parses OAuth parameters from a URL
|
|
46
|
+
* Parses OAuth parameters from a redirect URL
|
|
47
|
+
*
|
|
48
|
+
* This function extracts OAuth authentication parameters from a callback URL after
|
|
49
|
+
* a successful or failed OAuth flow. It safely handles URL parsing errors.
|
|
50
|
+
*
|
|
51
|
+
* @param url - The OAuth redirect URL containing query parameters
|
|
52
|
+
* @returns Object containing parsed OAuth parameters including tokens and error information
|
|
53
|
+
*
|
|
54
|
+
* @example
|
|
55
|
+
* ```tsx
|
|
56
|
+
* const redirectUrl = 'myapp://oauth/callback?access_token=abc123&player_id=player_123';
|
|
57
|
+
* const result = parseOAuthUrl(redirectUrl);
|
|
58
|
+
*
|
|
59
|
+
* if (result.access_token && result.player_id) {
|
|
60
|
+
* console.log('OAuth successful:', result.player_id);
|
|
61
|
+
* } else if (result.error) {
|
|
62
|
+
* console.error('OAuth failed:', result.errorDescription);
|
|
63
|
+
* }
|
|
64
|
+
* ```
|
|
47
65
|
*/
|
|
48
66
|
export declare function parseOAuthUrl(url: string): {
|
|
49
67
|
access_token?: string;
|
|
@@ -54,6 +72,25 @@ export declare function parseOAuthUrl(url: string): {
|
|
|
54
72
|
};
|
|
55
73
|
/**
|
|
56
74
|
* Creates a redirect URI for OAuth flows
|
|
75
|
+
*
|
|
76
|
+
* This function generates a deep link URL that OAuth providers can redirect back to
|
|
77
|
+
* after authentication. The URL follows the app's custom URL scheme.
|
|
78
|
+
*
|
|
79
|
+
* @param path - The path component for the redirect URI, defaults to '/'
|
|
80
|
+
* @returns A complete redirect URI that can be used in OAuth flows
|
|
81
|
+
*
|
|
82
|
+
* @example
|
|
83
|
+
* ```tsx
|
|
84
|
+
* // Create default OAuth callback URI
|
|
85
|
+
* const callbackUri = createOAuthRedirectUri('/oauth/callback');
|
|
86
|
+
* console.log(callbackUri); // 'myapp://oauth/callback'
|
|
87
|
+
*
|
|
88
|
+
* // Use in OAuth configuration
|
|
89
|
+
* const oauthConfig = {
|
|
90
|
+
* redirectUri: createOAuthRedirectUri('/auth/success'),
|
|
91
|
+
* provider: 'google',
|
|
92
|
+
* };
|
|
93
|
+
* ```
|
|
57
94
|
*/
|
|
58
95
|
export declare function createOAuthRedirectUri(path?: string): string;
|
|
59
96
|
/**
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as SecureStore from 'expo-secure-store';
|
|
2
2
|
/**
|
|
3
|
-
*
|
|
3
|
+
* Shape of messages sent from the embedded WebView when interacting with secure storage.
|
|
4
4
|
*/
|
|
5
5
|
export interface SecureStorageMessage {
|
|
6
6
|
event: string;
|
|
@@ -8,7 +8,7 @@ export interface SecureStorageMessage {
|
|
|
8
8
|
data: Record<string, any>;
|
|
9
9
|
}
|
|
10
10
|
/**
|
|
11
|
-
*
|
|
11
|
+
* Shape of responses returned to the WebView after processing a storage message.
|
|
12
12
|
*/
|
|
13
13
|
export interface SecureStorageResponse {
|
|
14
14
|
event: string;
|
|
@@ -16,31 +16,43 @@ export interface SecureStorageResponse {
|
|
|
16
16
|
data: Record<string, any>;
|
|
17
17
|
}
|
|
18
18
|
/**
|
|
19
|
-
* Checks if
|
|
19
|
+
* Checks if the provided value is a secure storage related message.
|
|
20
|
+
*
|
|
21
|
+
* @param message - Incoming message payload.
|
|
22
|
+
* @returns `true` when the payload matches the {@link SecureStorageMessage} structure.
|
|
20
23
|
*/
|
|
21
24
|
export declare function isSecureStorageMessage(message: unknown): message is SecureStorageMessage;
|
|
22
25
|
/**
|
|
23
|
-
* Handles secure storage operations from WebView messages
|
|
26
|
+
* Handles secure storage operations initiated from WebView messages.
|
|
27
|
+
*
|
|
28
|
+
* @param message - Parsed WebView message describing the desired storage action.
|
|
29
|
+
* @returns The response payload that should be sent back to the WebView.
|
|
30
|
+
* @throws {Error} When the message event is unknown.
|
|
24
31
|
*/
|
|
25
32
|
export declare function handleSecureStorageMessage(message: SecureStorageMessage): Promise<SecureStorageResponse>;
|
|
26
33
|
/**
|
|
27
|
-
* Native storage utilities for platform-specific operations
|
|
34
|
+
* Native storage utilities for platform-specific operations.
|
|
28
35
|
*/
|
|
29
36
|
export declare const NativeStorageUtils: {
|
|
30
37
|
/**
|
|
31
|
-
* Checks if secure storage is available on the current platform
|
|
38
|
+
* Checks if secure storage is available on the current platform.
|
|
32
39
|
*/
|
|
33
40
|
isAvailable(): boolean;
|
|
34
41
|
/**
|
|
35
|
-
* Gets the platform-specific storage options
|
|
42
|
+
* Gets the platform-specific storage options.
|
|
36
43
|
*/
|
|
37
44
|
getStorageOptions(): SecureStore.SecureStoreOptions;
|
|
38
45
|
/**
|
|
39
|
-
* Safely checks if a key exists in secure storage
|
|
46
|
+
* Safely checks if a key exists in secure storage.
|
|
47
|
+
*
|
|
48
|
+
* @param key - Storage key to look up.
|
|
49
|
+
* @returns `true` if the key is present, otherwise `false`.
|
|
40
50
|
*/
|
|
41
51
|
keyExists(key: string): Promise<boolean>;
|
|
42
52
|
/**
|
|
43
|
-
* Gets
|
|
53
|
+
* Gets diagnostic information about the native storage capabilities.
|
|
54
|
+
*
|
|
55
|
+
* @returns Platform availability information and keychain accessibility value.
|
|
44
56
|
*/
|
|
45
57
|
getStorageInfo(): Promise<{
|
|
46
58
|
isAvailable: boolean;
|
package/dist/types/predicates.js
CHANGED
|
@@ -26,7 +26,26 @@ export function needsRecovery(s) {
|
|
|
26
26
|
* Additional utility predicates
|
|
27
27
|
*/
|
|
28
28
|
/**
|
|
29
|
-
* Type guard to check if wallet is in a loading state
|
|
29
|
+
* Type guard to check if wallet is in a loading state
|
|
30
|
+
*
|
|
31
|
+
* This function determines whether a wallet is currently in a transitional state
|
|
32
|
+
* (connecting, creating, or reconnecting) and should show loading indicators.
|
|
33
|
+
*
|
|
34
|
+
* @param s - The embedded wallet state to check
|
|
35
|
+
* @returns True if the wallet is in any loading state, false otherwise
|
|
36
|
+
*
|
|
37
|
+
* @example
|
|
38
|
+
* ```tsx
|
|
39
|
+
* const { wallets } = useWallets();
|
|
40
|
+
* const wallet = wallets[0];
|
|
41
|
+
*
|
|
42
|
+
* if (isLoading(wallet)) {
|
|
43
|
+
* return <ActivityIndicator />; // Show spinner
|
|
44
|
+
* }
|
|
45
|
+
*
|
|
46
|
+
* // Safe to show wallet interface
|
|
47
|
+
* return <WalletInterface wallet={wallet} />;
|
|
48
|
+
* ```
|
|
30
49
|
*/
|
|
31
50
|
export function isLoading(s) {
|
|
32
51
|
return s.status === 'connecting' || s.status === 'creating' || s.status === 'reconnecting';
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Core Openfort hook interface
|
|
2
|
+
* Core Openfort hook interface.
|
|
3
3
|
*/
|
|
4
4
|
export interface UseOpenfort {
|
|
5
|
-
/** The current authenticated user, or null when unauthenticated */
|
|
5
|
+
/** The current authenticated user, or null when unauthenticated. */
|
|
6
6
|
user: import('@openfort/openfort-js').AuthPlayerResponse | null;
|
|
7
|
-
/** Whether or not the SDK has initialized and is ready for use */
|
|
7
|
+
/** Whether or not the SDK has initialized and is ready for use. */
|
|
8
8
|
isReady: boolean;
|
|
9
|
-
/** Any error encountered during SDK initialization */
|
|
9
|
+
/** Any error encountered during SDK initialization. */
|
|
10
10
|
error: Error | null;
|
|
11
|
-
/** A function that logs the current user out and clears any stored tokens */
|
|
11
|
+
/** A function that logs the current user out and clears any stored tokens. */
|
|
12
12
|
logout: () => Promise<void>;
|
|
13
|
-
/** A function that gets the current authenticated user's access token */
|
|
13
|
+
/** A function that gets the current authenticated user's access token. */
|
|
14
14
|
getAccessToken: () => Promise<string | null>;
|
|
15
15
|
}
|
|
16
16
|
export type { PasswordFlowState, SiweFlowState, RecoveryFlowState, CustomAuthFlowState, AuthSuccessCallback, AuthLinkSuccessCallback, ErrorCallback, EmailLoginHookOptions, EmailLinkHookOptions, EmailLoginHookResult, EmailLinkHookResult, SiweLoginHookOptions, SiweLinkHookOptions, SiweLoginHookResult, SiweLinkHookResult, GenerateSiweMessageResponse, GenerateSiweMessage, } from './auth';
|
|
@@ -19,7 +19,7 @@ export type { OpenfortEmbeddedWalletAccount, WalletRecoveryCallbacks, SolanaWall
|
|
|
19
19
|
export type { CustomAuthProviderConfig, UseGuestAuth, UseOnEmbeddedWalletStateChange, SetRecoveryParams, UseSetEmbeddedWalletRecoveryResult, UseSetEmbeddedWalletRecovery, } from './config';
|
|
20
20
|
export { isConnected, isReconnecting, isConnecting, isDisconnected, isNotCreated, isCreating, hasError, needsRecovery, isLoading, isReady, needsUserAction, isStable, canTransact, getStateDescription, getActionText, } from './predicates';
|
|
21
21
|
/**
|
|
22
|
-
* Embedded wallet hook options with callbacks
|
|
22
|
+
* Embedded wallet hook options with callbacks.
|
|
23
23
|
*/
|
|
24
24
|
export type UseEmbeddedEthereumWallet = {
|
|
25
25
|
onCreateWalletSuccess?: (provider: import('@openfort/openfort-js').Provider) => void;
|
|
@@ -30,7 +30,7 @@ export type UseEmbeddedEthereumWallet = {
|
|
|
30
30
|
onSetWalletRecoveryError?: (error: Error) => void;
|
|
31
31
|
};
|
|
32
32
|
/**
|
|
33
|
-
* Embedded Solana wallet hook options with callbacks
|
|
33
|
+
* Embedded Solana wallet hook options with callbacks.
|
|
34
34
|
*/
|
|
35
35
|
export type UseEmbeddedSolanaWallet = {
|
|
36
36
|
onCreateWalletSuccess?: (account: import('@openfort/openfort-js').EmbeddedAccount) => void;
|
|
@@ -1,6 +1,24 @@
|
|
|
1
1
|
import type { EmbeddedEthereumWalletState, EmbeddedSolanaWalletState, EmbeddedSolanaWalletConnectedState, EmbeddedSolanaWalletConnectingState, EmbeddedSolanaWalletReconnectingState, EmbeddedSolanaWalletDisconnectedState, EmbeddedSolanaWalletNeedsRecoveryState, EmbeddedSolanaWalletCreatingState, EmbeddedSolanaWalletErrorState } from './wallet';
|
|
2
2
|
/**
|
|
3
3
|
* Type guard to check if embedded wallet is connected
|
|
4
|
+
*
|
|
5
|
+
* This function determines whether an embedded wallet is in a connected state and ready for use.
|
|
6
|
+
* It provides TypeScript type narrowing for wallet state management.
|
|
7
|
+
*
|
|
8
|
+
* @param s - The embedded wallet state to check
|
|
9
|
+
* @returns True if the wallet is connected, false otherwise
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* ```tsx
|
|
13
|
+
* const { wallets } = useWallets();
|
|
14
|
+
* const wallet = wallets[0];
|
|
15
|
+
*
|
|
16
|
+
* if (isConnected(wallet)) {
|
|
17
|
+
* // TypeScript knows wallet is connected, safe to use
|
|
18
|
+
* const provider = await wallet.getProvider();
|
|
19
|
+
* console.log('Wallet is connected:', wallet.address);
|
|
20
|
+
* }
|
|
21
|
+
* ```
|
|
4
22
|
*/
|
|
5
23
|
export declare function isConnected(s: EmbeddedSolanaWalletState): s is EmbeddedSolanaWalletConnectedState;
|
|
6
24
|
/**
|
|
@@ -13,6 +31,23 @@ export declare function isReconnecting(s: EmbeddedSolanaWalletState): s is Embed
|
|
|
13
31
|
export declare function isConnecting(s: EmbeddedSolanaWalletState): s is EmbeddedSolanaWalletConnectingState;
|
|
14
32
|
/**
|
|
15
33
|
* Type guard to check if embedded wallet is disconnected
|
|
34
|
+
*
|
|
35
|
+
* This function determines whether an embedded wallet is in a disconnected state.
|
|
36
|
+
* Disconnected wallets need to be connected before they can be used for transactions.
|
|
37
|
+
*
|
|
38
|
+
* @param s - The embedded wallet state to check
|
|
39
|
+
* @returns True if the wallet is disconnected, false otherwise
|
|
40
|
+
*
|
|
41
|
+
* @example
|
|
42
|
+
* ```tsx
|
|
43
|
+
* const { wallets, setActiveWallet } = useWallets();
|
|
44
|
+
* const wallet = wallets[0];
|
|
45
|
+
*
|
|
46
|
+
* if (isDisconnected(wallet)) {
|
|
47
|
+
* console.log('Wallet needs connection');
|
|
48
|
+
* await setActiveWallet({ address: wallet.address });
|
|
49
|
+
* }
|
|
50
|
+
* ```
|
|
16
51
|
*/
|
|
17
52
|
export declare function isDisconnected(s: EmbeddedSolanaWalletState): s is EmbeddedSolanaWalletDisconnectedState;
|
|
18
53
|
/**
|
|
@@ -35,7 +70,26 @@ export declare function needsRecovery(s: EmbeddedSolanaWalletState): s is Embedd
|
|
|
35
70
|
* Additional utility predicates
|
|
36
71
|
*/
|
|
37
72
|
/**
|
|
38
|
-
* Type guard to check if wallet is in a loading state
|
|
73
|
+
* Type guard to check if wallet is in a loading state
|
|
74
|
+
*
|
|
75
|
+
* This function determines whether a wallet is currently in a transitional state
|
|
76
|
+
* (connecting, creating, or reconnecting) and should show loading indicators.
|
|
77
|
+
*
|
|
78
|
+
* @param s - The embedded wallet state to check
|
|
79
|
+
* @returns True if the wallet is in any loading state, false otherwise
|
|
80
|
+
*
|
|
81
|
+
* @example
|
|
82
|
+
* ```tsx
|
|
83
|
+
* const { wallets } = useWallets();
|
|
84
|
+
* const wallet = wallets[0];
|
|
85
|
+
*
|
|
86
|
+
* if (isLoading(wallet)) {
|
|
87
|
+
* return <ActivityIndicator />; // Show spinner
|
|
88
|
+
* }
|
|
89
|
+
*
|
|
90
|
+
* // Safe to show wallet interface
|
|
91
|
+
* return <WalletInterface wallet={wallet} />;
|
|
92
|
+
* ```
|
|
39
93
|
*/
|
|
40
94
|
export declare function isLoading(s: EmbeddedEthereumWalletState | EmbeddedSolanaWalletState): boolean;
|
|
41
95
|
/**
|