-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy pathuseWalletSettings.ts
More file actions
54 lines (52 loc) · 1.99 KB
/
useWalletSettings.ts
File metadata and controls
54 lines (52 loc) · 1.99 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
import { useWalletConfigContext } from '../contexts/WalletConfig.js'
/**
* Hook to access and modify wallet configuration settings.
*
* This hook provides access to wallet settings including:
* - Displayed assets configuration (which tokens/contracts to show)
* - Read-only networks (networks where transactions are disabled)
* - See if external wallets are visible on the Connect Modal
* - See if linked wallets are visible on the Connect Modal
*
* @see {@link https://docs.sequence.xyz/sdk/web/wallet-sdk/ecosystem/hooks/useWalletSettings} for more detailed documentation.
*
* @returns An object containing:
* - `displayedAssets` - Array of assets to display, each with a contract address and chain ID
* - `readOnlyNetworks` - Array of network IDs where transactions are disabled
* - `setDisplayedAssets` - Function to update the list of displayed assets
* - `hideExternalConnectOptions` - Hide external wallets on the Connect Modal
* - `hideConnectedWallets` - Hide connected wallets on the Connect Modal
* - `hideSocialConnectOptions` - Hide social wallets on the Connect Modal
*
* @example
* ```tsx
* const { displayedAssets, readOnlyNetworks, setDisplayedAssets, hideExternalConnectOptions, hideConnectedWallets, hideSocialConnectOptions } = useWalletSettings()
*
* // Check if a network is read-only
* const isReadOnly = readOnlyNetworks?.includes(1) // true if Ethereum mainnet is read-only
*
* // Update displayed assets
* setDisplayedAssets([
* { contractAddress: '0x...', chainId: 1 }, // ETH mainnet token
* { contractAddress: '0x...', chainId: 137 } // Polygon token
* ])
* ```
*/
export const useWalletSettings = () => {
const {
setDisplayedAssets,
displayedAssets,
readOnlyNetworks,
hideExternalConnectOptions,
hideConnectedWallets,
hideSocialConnectOptions
} = useWalletConfigContext()
return {
displayedAssets,
readOnlyNetworks,
setDisplayedAssets,
hideExternalConnectOptions,
hideConnectedWallets,
hideSocialConnectOptions
}
}