@openfort/react 0.0.12 → 0.0.13
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/build/assets/browsers.d.ts +1 -1
- package/build/assets/logos.d.ts +1 -0
- package/build/components/Openfort/OpenfortProvider.d.ts +25 -12
- package/build/components/Openfort/context.d.ts +2 -0
- package/build/components/Openfort/types.d.ts +19 -15
- package/build/components/Pages/EmailLogin/styles.d.ts +1 -0
- package/build/components/Pages/Providers/styles.d.ts +2 -0
- package/build/components/PasswordStrength/password-utility.d.ts +50 -16
- package/build/components/contexts/web3/index.d.ts +18 -1
- package/build/constants/openfort.d.ts +0 -1
- package/build/defaultTransports.d.ts +27 -4
- package/build/hooks/openfort/auth/useAuthCallback.d.ts +63 -0
- package/build/hooks/openfort/auth/useConnectToWalletPostAuth.d.ts +26 -4
- package/build/hooks/openfort/auth/useEmailAuth.d.ts +71 -0
- package/build/hooks/openfort/auth/useGuestAuth.d.ts +59 -0
- package/build/hooks/openfort/auth/useOAuth.d.ts +74 -0
- package/build/hooks/openfort/auth/useSignOut.d.ts +57 -0
- package/build/hooks/openfort/useStatus.d.ts +42 -0
- package/build/hooks/openfort/useUI.d.ts +63 -0
- package/build/hooks/openfort/useUser.d.ts +44 -0
- package/build/hooks/openfort/useWallet.d.ts +50 -0
- package/build/hooks/openfort/useWallets.d.ts +56 -0
- package/build/hooks/useChainIsSupported.d.ts +24 -1
- package/build/hooks/useChains.d.ts +39 -0
- package/build/hooks/useConnect.d.ts +18 -10
- package/build/index.es.js +3362 -2541
- package/build/index.es.js.map +1 -1
- package/build/openfort/core/client.d.ts +26 -7
- package/build/styles/styled/index.d.ts +5 -7
- package/build/styles/themes/base.d.ts +12 -12
- package/build/styles/themes/minimal.d.ts +2 -17
- package/build/styles/themes/retro.d.ts +3 -1
- package/build/styles/themes/rounded.d.ts +3 -1
- package/build/styles/themes/web95.d.ts +3 -1
- package/build/utils/localstorage.d.ts +61 -2
- package/build/version.d.ts +1 -1
- package/build/wallets/walletConfigs.d.ts +2 -2
- package/package.json +1 -1
- package/build/components/Pages/EmailSignup/index.d.ts +0 -3
|
@@ -23,6 +23,80 @@ export type StoreCredentialsOptions = {
|
|
|
23
23
|
export type AuthHookOptions = {
|
|
24
24
|
redirectTo?: string;
|
|
25
25
|
} & OpenfortHookOptions<StoreCredentialsResult | InitOAuthReturnType> & CreateWalletPostAuthOptions;
|
|
26
|
+
/**
|
|
27
|
+
* Hook for OAuth-based authentication operations
|
|
28
|
+
*
|
|
29
|
+
* This hook manages OAuth authentication flows including provider initialization,
|
|
30
|
+
* credential storage, and wallet connection after successful OAuth authentication.
|
|
31
|
+
* It supports multiple OAuth providers and handles the complete authentication lifecycle
|
|
32
|
+
* from provider selection to wallet setup.
|
|
33
|
+
*
|
|
34
|
+
* @param hookOptions - Optional configuration with callback functions and authentication options
|
|
35
|
+
* @returns Current OAuth authentication state and actions
|
|
36
|
+
*
|
|
37
|
+
* @example
|
|
38
|
+
* ```tsx
|
|
39
|
+
* const oauth = useOAuth({
|
|
40
|
+
* onInitializeOAuthSuccess: (result) => console.log('OAuth initialized'),
|
|
41
|
+
* onInitializeOAuthError: (error) => console.error('OAuth init failed:', error),
|
|
42
|
+
* onStoreCredentialsSuccess: (result) => console.log('Authenticated:', result.user),
|
|
43
|
+
* redirectTo: 'https://yourapp.com/auth/callback',
|
|
44
|
+
* recoverWalletAutomatically: true,
|
|
45
|
+
* });
|
|
46
|
+
*
|
|
47
|
+
* // Initialize OAuth with a provider
|
|
48
|
+
* const handleGoogleAuth = async () => {
|
|
49
|
+
* await oauth.initOAuth({
|
|
50
|
+
* provider: OAuthProvider.GOOGLE,
|
|
51
|
+
* redirectTo: 'https://yourapp.com/auth/callback',
|
|
52
|
+
* });
|
|
53
|
+
* };
|
|
54
|
+
*
|
|
55
|
+
* const handleDiscordAuth = async () => {
|
|
56
|
+
* await oauth.initOAuth({
|
|
57
|
+
* provider: OAuthProvider.DISCORD,
|
|
58
|
+
* });
|
|
59
|
+
* };
|
|
60
|
+
*
|
|
61
|
+
* // Store OAuth credentials (typically called from callback handler)
|
|
62
|
+
* const handleStoreCredentials = async () => {
|
|
63
|
+
* await oauth.storeCredentials({
|
|
64
|
+
* player: 'player-id-from-callback',
|
|
65
|
+
* accessToken: 'access-token-from-callback',
|
|
66
|
+
* refreshToken: 'refresh-token-from-callback',
|
|
67
|
+
* });
|
|
68
|
+
* };
|
|
69
|
+
*
|
|
70
|
+
* // Link OAuth provider to existing authenticated account
|
|
71
|
+
* const handleLinkOAuth = async () => {
|
|
72
|
+
* await oauth.linkOauth({
|
|
73
|
+
* provider: OAuthProvider.GOOGLE,
|
|
74
|
+
* redirectTo: 'https://yourapp.com/auth/callback',
|
|
75
|
+
* });
|
|
76
|
+
* };
|
|
77
|
+
*
|
|
78
|
+
* // Check authentication state
|
|
79
|
+
* if (oauth.isLoading) {
|
|
80
|
+
* console.log('Processing OAuth authentication...');
|
|
81
|
+
* } else if (oauth.isError) {
|
|
82
|
+
* console.error('OAuth error:', oauth.error);
|
|
83
|
+
* } else if (oauth.isSuccess) {
|
|
84
|
+
* console.log('OAuth authentication successful');
|
|
85
|
+
* }
|
|
86
|
+
*
|
|
87
|
+
* // Example usage in component with multiple providers
|
|
88
|
+
* return (
|
|
89
|
+
* <div>
|
|
90
|
+
* <button onClick={handleGoogleAuth} disabled={oauth.isLoading}>
|
|
91
|
+
* Sign in with Google
|
|
92
|
+
* </button>
|
|
93
|
+
* <button onClick={handleDiscordAuth} disabled={oauth.isLoading}>
|
|
94
|
+
* Sign in with Discord
|
|
95
|
+
* </button>
|
|
96
|
+
* </div>
|
|
97
|
+
* );
|
|
98
|
+
* ```
|
|
99
|
+
*/
|
|
26
100
|
export declare const useOAuth: (hookOptions?: AuthHookOptions) => {
|
|
27
101
|
isLoading: boolean;
|
|
28
102
|
isError: boolean;
|
|
@@ -1,4 +1,61 @@
|
|
|
1
1
|
import { OpenfortError, OpenfortHookOptions } from '../../../types';
|
|
2
|
+
/**
|
|
3
|
+
* Hook for user sign out operations
|
|
4
|
+
*
|
|
5
|
+
* This hook manages user logout functionality, clearing authentication state
|
|
6
|
+
* and disconnecting from all services. It provides a clean way to sign out users
|
|
7
|
+
* while handling any cleanup operations and providing loading/error states.
|
|
8
|
+
* The hook ensures complete logout by clearing all stored credentials and state.
|
|
9
|
+
*
|
|
10
|
+
* @param hookOptions - Optional configuration with callback functions
|
|
11
|
+
* @returns Current sign out state and actions
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* ```tsx
|
|
15
|
+
* const signOutHook = useSignOut({
|
|
16
|
+
* onSignOutSuccess: () => console.log('User signed out successfully'),
|
|
17
|
+
* onSignOutError: (error) => console.error('Sign out failed:', error),
|
|
18
|
+
* });
|
|
19
|
+
*
|
|
20
|
+
* // Sign out user
|
|
21
|
+
* const handleSignOut = async () => {
|
|
22
|
+
* try {
|
|
23
|
+
* await signOutHook.signOut();
|
|
24
|
+
* console.log('User has been signed out');
|
|
25
|
+
* // Redirect to login page or update UI
|
|
26
|
+
* } catch (error) {
|
|
27
|
+
* console.error('Sign out failed:', error);
|
|
28
|
+
* }
|
|
29
|
+
* };
|
|
30
|
+
*
|
|
31
|
+
* // Sign out with custom options
|
|
32
|
+
* const handleCustomSignOut = async () => {
|
|
33
|
+
* await signOutHook.signOut({
|
|
34
|
+
* onSuccess: () => console.log('Custom success handler'),
|
|
35
|
+
* onError: (error) => console.error('Custom error handler:', error),
|
|
36
|
+
* });
|
|
37
|
+
* };
|
|
38
|
+
*
|
|
39
|
+
* // Check sign out state
|
|
40
|
+
* if (signOutHook.isLoading) {
|
|
41
|
+
* console.log('Signing out...');
|
|
42
|
+
* } else if (signOutHook.isError) {
|
|
43
|
+
* console.error('Sign out error:', signOutHook.error);
|
|
44
|
+
* } else if (signOutHook.isSuccess) {
|
|
45
|
+
* console.log('Sign out successful');
|
|
46
|
+
* }
|
|
47
|
+
*
|
|
48
|
+
* // Example usage in component
|
|
49
|
+
* return (
|
|
50
|
+
* <button
|
|
51
|
+
* onClick={handleSignOut}
|
|
52
|
+
* disabled={signOutHook.isLoading}
|
|
53
|
+
* >
|
|
54
|
+
* {signOutHook.isLoading ? 'Signing out...' : 'Sign Out'}
|
|
55
|
+
* </button>
|
|
56
|
+
* );
|
|
57
|
+
* ```
|
|
58
|
+
*/
|
|
2
59
|
export declare function useSignOut(hookOptions?: OpenfortHookOptions): {
|
|
3
60
|
signOut: (options?: OpenfortHookOptions) => Promise<{}>;
|
|
4
61
|
isLoading: boolean;
|
|
@@ -4,6 +4,48 @@ export declare enum OpenfortStatus {
|
|
|
4
4
|
LOADING = 2,
|
|
5
5
|
CONNECTED = 3
|
|
6
6
|
}
|
|
7
|
+
/**
|
|
8
|
+
* Hook for monitoring Openfort connection and authentication status
|
|
9
|
+
*
|
|
10
|
+
* This hook provides real-time status information about the user's connection to Openfort
|
|
11
|
+
* services and embedded wallet state. It tracks various states including loading, connected,
|
|
12
|
+
* disconnected, and authentication status based on embedded wallet configuration and connection.
|
|
13
|
+
*
|
|
14
|
+
* @returns Current connection and authentication status flags
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* ```tsx
|
|
18
|
+
* const status = useStatus();
|
|
19
|
+
*
|
|
20
|
+
* // Check connection states
|
|
21
|
+
* if (status.isLoading) {
|
|
22
|
+
* console.log('Initializing Openfort connection...');
|
|
23
|
+
* } else if (status.isConnecting) {
|
|
24
|
+
* console.log('Connecting to wallet...');
|
|
25
|
+
* } else if (status.isConnected) {
|
|
26
|
+
* console.log('Successfully connected to Openfort');
|
|
27
|
+
* } else if (status.isDisconnected) {
|
|
28
|
+
* console.log('Not connected to Openfort');
|
|
29
|
+
* }
|
|
30
|
+
*
|
|
31
|
+
* // Check authentication state
|
|
32
|
+
* if (status.isAuthenticated) {
|
|
33
|
+
* console.log('User is authenticated');
|
|
34
|
+
* // Show authenticated UI
|
|
35
|
+
* } else {
|
|
36
|
+
* console.log('User is not authenticated');
|
|
37
|
+
* // Show login UI
|
|
38
|
+
* }
|
|
39
|
+
*
|
|
40
|
+
* // Conditional rendering based on status
|
|
41
|
+
* const renderContent = () => {
|
|
42
|
+
* if (status.isLoading) return <LoadingSpinner />;
|
|
43
|
+
* if (status.isConnecting) return <ConnectingIndicator />;
|
|
44
|
+
* if (status.isConnected && status.isAuthenticated) return <AuthenticatedApp />;
|
|
45
|
+
* return <LoginForm />;
|
|
46
|
+
* };
|
|
47
|
+
* ```
|
|
48
|
+
*/
|
|
7
49
|
export declare function useStatus(): {
|
|
8
50
|
isLoading: boolean;
|
|
9
51
|
isConnected: boolean;
|
|
@@ -1,3 +1,66 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Hook for controlling Openfort UI modal and navigation
|
|
3
|
+
*
|
|
4
|
+
* This hook provides programmatic control over the Openfort UI modal, including opening,
|
|
5
|
+
* closing, and navigating between different screens. It handles route validation and
|
|
6
|
+
* automatically selects appropriate screens based on user connection and authentication state.
|
|
7
|
+
* The hook ensures safe navigation by validating routes against user's current state.
|
|
8
|
+
*
|
|
9
|
+
* @returns UI control functions and modal state
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* ```tsx
|
|
13
|
+
* const ui = useUI();
|
|
14
|
+
*
|
|
15
|
+
* // Check if modal is open
|
|
16
|
+
* if (ui.isOpen) {
|
|
17
|
+
* console.log('Openfort modal is currently open');
|
|
18
|
+
* }
|
|
19
|
+
*
|
|
20
|
+
* // Open modal with default route (auto-determined by user state)
|
|
21
|
+
* const handleConnect = () => {
|
|
22
|
+
* ui.open(); // Opens providers screen if not connected, profile if connected
|
|
23
|
+
* };
|
|
24
|
+
*
|
|
25
|
+
* // Close modal
|
|
26
|
+
* const handleClose = () => {
|
|
27
|
+
* ui.close();
|
|
28
|
+
* };
|
|
29
|
+
*
|
|
30
|
+
* // Programmatically control modal state
|
|
31
|
+
* const toggleModal = () => {
|
|
32
|
+
* ui.setIsOpen(!ui.isOpen);
|
|
33
|
+
* };
|
|
34
|
+
*
|
|
35
|
+
* // Open specific screens
|
|
36
|
+
* const handleProfileClick = () => {
|
|
37
|
+
* ui.openProfile(); // Opens user profile screen (connected users only)
|
|
38
|
+
* };
|
|
39
|
+
*
|
|
40
|
+
* const handleProvidersClick = () => {
|
|
41
|
+
* ui.openProviders(); // Opens authentication providers screen
|
|
42
|
+
* };
|
|
43
|
+
*
|
|
44
|
+
* const handleWalletsClick = () => {
|
|
45
|
+
* ui.openWallets(); // Opens wallet connectors screen
|
|
46
|
+
* };
|
|
47
|
+
*
|
|
48
|
+
* const handleNetworkClick = () => {
|
|
49
|
+
* ui.openSwitchNetworks(); // Opens network switching screen (connected users only)
|
|
50
|
+
* };
|
|
51
|
+
*
|
|
52
|
+
* // Example usage in component
|
|
53
|
+
* return (
|
|
54
|
+
* <div>
|
|
55
|
+
* <button onClick={handleConnect}>
|
|
56
|
+
* {ui.isOpen ? 'Close' : 'Open'} Openfort
|
|
57
|
+
* </button>
|
|
58
|
+
* <button onClick={handleProfileClick}>Profile</button>
|
|
59
|
+
* <button onClick={handleWalletsClick}>Wallets</button>
|
|
60
|
+
* </div>
|
|
61
|
+
* );
|
|
62
|
+
* ```
|
|
63
|
+
*/
|
|
1
64
|
export declare function useUI(): {
|
|
2
65
|
isOpen: boolean;
|
|
3
66
|
open: () => void;
|
|
@@ -1,3 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Hook for accessing current user information and authentication state
|
|
3
|
+
*
|
|
4
|
+
* This hook provides access to the current authenticated user's information and
|
|
5
|
+
* authentication status. It also offers methods to manage access tokens and validate
|
|
6
|
+
* user sessions. The hook automatically updates when authentication state changes.
|
|
7
|
+
*
|
|
8
|
+
* @returns Current user state and authentication utilities
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* ```tsx
|
|
12
|
+
* const userHook = useUser();
|
|
13
|
+
*
|
|
14
|
+
* // Check if user is authenticated
|
|
15
|
+
* if (userHook.isAuthenticated && userHook.user) {
|
|
16
|
+
* console.log('User is authenticated:', userHook.user);
|
|
17
|
+
* console.log('User ID:', userHook.user.id);
|
|
18
|
+
* console.log('User email:', userHook.user.email);
|
|
19
|
+
* console.log('Linked accounts:', userHook.user.linkedAccounts);
|
|
20
|
+
* } else {
|
|
21
|
+
* console.log('User is not authenticated');
|
|
22
|
+
* }
|
|
23
|
+
*
|
|
24
|
+
* // Get fresh access token
|
|
25
|
+
* const getToken = async () => {
|
|
26
|
+
* try {
|
|
27
|
+
* const token = await userHook.getAccessToken();
|
|
28
|
+
* console.log('Access token:', token);
|
|
29
|
+
* } catch (error) {
|
|
30
|
+
* console.error('Failed to get access token:', error);
|
|
31
|
+
* }
|
|
32
|
+
* };
|
|
33
|
+
*
|
|
34
|
+
* // Validate and refresh token if needed
|
|
35
|
+
* const refreshToken = async () => {
|
|
36
|
+
* try {
|
|
37
|
+
* await userHook.validateAndRefreshToken();
|
|
38
|
+
* console.log('Token validated and refreshed');
|
|
39
|
+
* } catch (error) {
|
|
40
|
+
* console.error('Token validation failed:', error);
|
|
41
|
+
* }
|
|
42
|
+
* };
|
|
43
|
+
* ```
|
|
44
|
+
*/
|
|
1
45
|
export declare function useUser(): {
|
|
2
46
|
user: import("@openfort/openfort-js").AuthPlayerResponse | null;
|
|
3
47
|
isAuthenticated: boolean;
|
|
@@ -1 +1,51 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Hook for accessing the currently active wallet
|
|
3
|
+
*
|
|
4
|
+
* This hook provides access to the user's currently active/connected wallet.
|
|
5
|
+
* It's a simplified interface that returns just the active wallet from the
|
|
6
|
+
* useWallets hook, making it convenient when you only need the current wallet
|
|
7
|
+
* without all the wallet management functionality.
|
|
8
|
+
*
|
|
9
|
+
* @returns Currently active wallet or undefined if no wallet is connected
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* ```tsx
|
|
13
|
+
* const activeWallet = useWallet();
|
|
14
|
+
*
|
|
15
|
+
* // Check if user has an active wallet
|
|
16
|
+
* if (activeWallet) {
|
|
17
|
+
* console.log('Active wallet:', {
|
|
18
|
+
* address: activeWallet.address,
|
|
19
|
+
* type: activeWallet.connectorType,
|
|
20
|
+
* id: activeWallet.id,
|
|
21
|
+
* });
|
|
22
|
+
* } else {
|
|
23
|
+
* console.log('No active wallet');
|
|
24
|
+
* }
|
|
25
|
+
*
|
|
26
|
+
* // Access wallet properties
|
|
27
|
+
* const walletAddress = activeWallet?.address;
|
|
28
|
+
* const walletType = activeWallet?.connectorType;
|
|
29
|
+
* const isEmbedded = activeWallet?.connectorType === 'embedded';
|
|
30
|
+
*
|
|
31
|
+
* // Example usage in component
|
|
32
|
+
* return (
|
|
33
|
+
* <div>
|
|
34
|
+
* {activeWallet ? (
|
|
35
|
+
* <div>
|
|
36
|
+
* <h3>Connected Wallet</h3>
|
|
37
|
+
* <p>Address: {activeWallet.address}</p>
|
|
38
|
+
* <p>Type: {activeWallet.connectorType}</p>
|
|
39
|
+
* {activeWallet.isConnecting && <span>Connecting...</span>}
|
|
40
|
+
* </div>
|
|
41
|
+
* ) : (
|
|
42
|
+
* <div>
|
|
43
|
+
* <p>No wallet connected</p>
|
|
44
|
+
* <button>Connect Wallet</button>
|
|
45
|
+
* </div>
|
|
46
|
+
* )}
|
|
47
|
+
* </div>
|
|
48
|
+
* );
|
|
49
|
+
* ```
|
|
50
|
+
*/
|
|
1
51
|
export declare function useWallet(): import("./useWallets").UserWallet | undefined;
|
|
@@ -44,6 +44,62 @@ type SetRecoveryOptions = {
|
|
|
44
44
|
newRecovery: RecoveryParams;
|
|
45
45
|
} & OpenfortHookOptions<CreateWalletResult>;
|
|
46
46
|
type WalletOptions = OpenfortHookOptions<SetActiveWalletResult | CreateWalletResult>;
|
|
47
|
+
/**
|
|
48
|
+
* Hook for managing and interacting with user wallets
|
|
49
|
+
*
|
|
50
|
+
* This hook manages both embedded Openfort wallets and external wallets connected via Wagmi.
|
|
51
|
+
* It handles wallet creation, recovery, connection, and switching between different wallet types.
|
|
52
|
+
* The hook provides comprehensive wallet management functionality including creating embedded wallets,
|
|
53
|
+
* recovering existing ones, and managing wallet connections across multiple providers.
|
|
54
|
+
*
|
|
55
|
+
* @param hookOptions - Optional configuration with callback functions and wallet options
|
|
56
|
+
* @returns Current wallet state with management actions
|
|
57
|
+
*
|
|
58
|
+
* @example
|
|
59
|
+
* ```tsx
|
|
60
|
+
* const wallets = useWallets({
|
|
61
|
+
* onCreateWalletSuccess: (result) => console.log('Wallet created:', result.wallet),
|
|
62
|
+
* onCreateWalletError: (error) => console.error('Wallet creation failed:', error),
|
|
63
|
+
* onSetActiveWalletSuccess: (result) => console.log('Wallet activated:', result.wallet),
|
|
64
|
+
* });
|
|
65
|
+
*
|
|
66
|
+
* // Check available wallets
|
|
67
|
+
* if (wallets.hasWallet) {
|
|
68
|
+
* console.log('Available wallets:', wallets.wallets);
|
|
69
|
+
* console.log('Active wallet:', wallets.activeWallet);
|
|
70
|
+
* }
|
|
71
|
+
*
|
|
72
|
+
* // Create a new embedded wallet with automatic recovery
|
|
73
|
+
* await wallets.createWallet({
|
|
74
|
+
* recovery: { recoveryMethod: RecoveryMethod.AUTOMATIC },
|
|
75
|
+
* accountType: AccountTypeEnum.SMART_ACCOUNT,
|
|
76
|
+
* });
|
|
77
|
+
*
|
|
78
|
+
* // Set active wallet by ID
|
|
79
|
+
* await wallets.setActiveWallet('embedded-wallet-id');
|
|
80
|
+
*
|
|
81
|
+
* // Set active wallet with custom recovery
|
|
82
|
+
* await wallets.setActiveWallet({
|
|
83
|
+
* walletId: 'embedded-wallet-id',
|
|
84
|
+
* recovery: { recoveryMethod: RecoveryMethod.PASSWORD, password: 'user-password' },
|
|
85
|
+
* showUI: true,
|
|
86
|
+
* });
|
|
87
|
+
*
|
|
88
|
+
* // Set recovery method for existing wallet
|
|
89
|
+
* await wallets.setRecovery({
|
|
90
|
+
* previousRecovery: { recoveryMethod: RecoveryMethod.AUTOMATIC },
|
|
91
|
+
* newRecovery: { recoveryMethod: RecoveryMethod.PASSWORD, password: 'new-password' },
|
|
92
|
+
* });
|
|
93
|
+
*
|
|
94
|
+
* // Export private key from embedded wallet (requires authentication)
|
|
95
|
+
* try {
|
|
96
|
+
* const privateKey = await wallets.exportPrivateKey();
|
|
97
|
+
* console.log('Private key exported:', privateKey);
|
|
98
|
+
* } catch (error) {
|
|
99
|
+
* console.error('Failed to export private key:', error);
|
|
100
|
+
* }
|
|
101
|
+
* ```
|
|
102
|
+
*/
|
|
47
103
|
export declare function useWallets(hookOptions?: WalletOptions): {
|
|
48
104
|
exportPrivateKey: () => Promise<string>;
|
|
49
105
|
error: OpenfortError | null | undefined;
|
|
@@ -1 +1,24 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Hook for checking if a blockchain chain is supported.
|
|
3
|
+
*
|
|
4
|
+
* This hook verifies whether a specific blockchain chain ID is part of the
|
|
5
|
+
* configured Wagmi chains. Use it to validate chain compatibility before
|
|
6
|
+
* attempting operations or rendering chain-specific UI.
|
|
7
|
+
*
|
|
8
|
+
* @param chainId - The blockchain chain ID to check for support.
|
|
9
|
+
* @returns `true` when the chain is configured, `false` otherwise.
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* ```tsx
|
|
13
|
+
* const ChainStatus: React.FC<{ chainId?: number }> = ({ chainId }) => {
|
|
14
|
+
* const isSupported = useChainIsSupported(chainId);
|
|
15
|
+
*
|
|
16
|
+
* return (
|
|
17
|
+
* <span>
|
|
18
|
+
* {chainId ?? 'Unknown chain'}: {isSupported ? 'Supported' : 'Unsupported'}
|
|
19
|
+
* </span>
|
|
20
|
+
* );
|
|
21
|
+
* };
|
|
22
|
+
* ```
|
|
23
|
+
*/
|
|
24
|
+
export declare function useChainIsSupported(chainId?: number): boolean;
|
|
@@ -1,2 +1,41 @@
|
|
|
1
1
|
import { Chain } from 'viem';
|
|
2
|
+
/**
|
|
3
|
+
* Hook for accessing configured blockchain chains
|
|
4
|
+
*
|
|
5
|
+
* This hook provides access to all blockchain chains configured in the Wagmi config.
|
|
6
|
+
* It returns an array of chain objects containing network information such as
|
|
7
|
+
* chain ID, name, RPC URLs, and other blockchain-specific configuration.
|
|
8
|
+
*
|
|
9
|
+
* @returns Array of configured blockchain chains
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* ```tsx
|
|
13
|
+
* const chains = useChains();
|
|
14
|
+
*
|
|
15
|
+
* // Display available chains
|
|
16
|
+
* console.log('Available chains:', chains.map(chain => ({
|
|
17
|
+
* id: chain.id,
|
|
18
|
+
* name: chain.name,
|
|
19
|
+
* nativeCurrency: chain.nativeCurrency,
|
|
20
|
+
* })));
|
|
21
|
+
*
|
|
22
|
+
* // Check if specific chains are available
|
|
23
|
+
* const hasEthereum = chains.some(chain => chain.id === 1);
|
|
24
|
+
* const hasPolygon = chains.some(chain => chain.id === 137);
|
|
25
|
+
*
|
|
26
|
+
* // Example usage in component
|
|
27
|
+
* return (
|
|
28
|
+
* <div>
|
|
29
|
+
* <h3>Available Networks:</h3>
|
|
30
|
+
* <ul>
|
|
31
|
+
* {chains.map(chain => (
|
|
32
|
+
* <li key={chain.id}>
|
|
33
|
+
* {chain.name} (ID: {chain.id})
|
|
34
|
+
* </li>
|
|
35
|
+
* ))}
|
|
36
|
+
* </ul>
|
|
37
|
+
* </div>
|
|
38
|
+
* );
|
|
39
|
+
* ```
|
|
40
|
+
*/
|
|
2
41
|
export declare function useChains(): Chain[];
|
|
@@ -1,6 +1,14 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
*
|
|
2
|
+
* Custom wrapper around {@link wagmiUseConnect} that adds Openfort specific logic.
|
|
3
|
+
*
|
|
4
|
+
* @param props - Optional configuration passed through to Wagmi's hook.
|
|
5
|
+
* @returns Connection helpers augmented with Openfort defaults and logging.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```ts
|
|
9
|
+
* const { connect, connectors } = useConnect();
|
|
10
|
+
* await connect({ connector: connectors[0] });
|
|
11
|
+
* ```
|
|
4
12
|
*/
|
|
5
13
|
import { Connector, CreateConnectorFn, type UseConnectParameters } from 'wagmi';
|
|
6
14
|
export declare function useConnect({ ...props }?: UseConnectParameters): {
|
|
@@ -27,11 +35,11 @@ export declare function useConnect({ ...props }?: UseConnectParameters): {
|
|
|
27
35
|
connector: CreateConnectorFn | Connector;
|
|
28
36
|
chainId?: number;
|
|
29
37
|
mutation?: UseConnectParameters["mutation"];
|
|
30
|
-
}) => Promise<import("wagmi/query").ConnectData<import("wagmi").Config>>;
|
|
38
|
+
}) => Promise<import("wagmi/query").ConnectData<import("wagmi").Config, Connector, boolean>>;
|
|
31
39
|
connectors: readonly Connector<CreateConnectorFn>[];
|
|
32
40
|
} | {
|
|
33
41
|
data: undefined;
|
|
34
|
-
variables: import("wagmi/query").ConnectVariables<import("wagmi").Config, Connector<CreateConnectorFn
|
|
42
|
+
variables: import("wagmi/query").ConnectVariables<import("wagmi").Config, Connector<CreateConnectorFn>, boolean>;
|
|
35
43
|
error: null;
|
|
36
44
|
isError: false;
|
|
37
45
|
isIdle: false;
|
|
@@ -53,11 +61,11 @@ export declare function useConnect({ ...props }?: UseConnectParameters): {
|
|
|
53
61
|
connector: CreateConnectorFn | Connector;
|
|
54
62
|
chainId?: number;
|
|
55
63
|
mutation?: UseConnectParameters["mutation"];
|
|
56
|
-
}) => Promise<import("wagmi/query").ConnectData<import("wagmi").Config>>;
|
|
64
|
+
}) => Promise<import("wagmi/query").ConnectData<import("wagmi").Config, Connector, boolean>>;
|
|
57
65
|
connectors: readonly Connector<CreateConnectorFn>[];
|
|
58
66
|
} | {
|
|
59
67
|
data: undefined;
|
|
60
|
-
variables: import("wagmi/query").ConnectVariables<import("wagmi").Config, Connector<CreateConnectorFn
|
|
68
|
+
variables: import("wagmi/query").ConnectVariables<import("wagmi").Config, Connector<CreateConnectorFn>, boolean>;
|
|
61
69
|
error: import("@wagmi/core").ConnectErrorType;
|
|
62
70
|
isError: true;
|
|
63
71
|
isIdle: false;
|
|
@@ -79,11 +87,11 @@ export declare function useConnect({ ...props }?: UseConnectParameters): {
|
|
|
79
87
|
connector: CreateConnectorFn | Connector;
|
|
80
88
|
chainId?: number;
|
|
81
89
|
mutation?: UseConnectParameters["mutation"];
|
|
82
|
-
}) => Promise<import("wagmi/query").ConnectData<import("wagmi").Config>>;
|
|
90
|
+
}) => Promise<import("wagmi/query").ConnectData<import("wagmi").Config, Connector, boolean>>;
|
|
83
91
|
connectors: readonly Connector<CreateConnectorFn>[];
|
|
84
92
|
} | {
|
|
85
|
-
data: import("wagmi/query").ConnectData<import("wagmi").Config>;
|
|
86
|
-
variables: import("wagmi/query").ConnectVariables<import("wagmi").Config, Connector<CreateConnectorFn
|
|
93
|
+
data: import("wagmi/query").ConnectData<import("wagmi").Config, Connector<CreateConnectorFn>, boolean>;
|
|
94
|
+
variables: import("wagmi/query").ConnectVariables<import("wagmi").Config, Connector<CreateConnectorFn>, boolean>;
|
|
87
95
|
error: null;
|
|
88
96
|
isError: false;
|
|
89
97
|
isIdle: false;
|
|
@@ -105,6 +113,6 @@ export declare function useConnect({ ...props }?: UseConnectParameters): {
|
|
|
105
113
|
connector: CreateConnectorFn | Connector;
|
|
106
114
|
chainId?: number;
|
|
107
115
|
mutation?: UseConnectParameters["mutation"];
|
|
108
|
-
}) => Promise<import("wagmi/query").ConnectData<import("wagmi").Config>>;
|
|
116
|
+
}) => Promise<import("wagmi/query").ConnectData<import("wagmi").Config, Connector, boolean>>;
|
|
109
117
|
connectors: readonly Connector<CreateConnectorFn>[];
|
|
110
118
|
};
|