UNPKG

@0xsequence/connect

Version:
50 lines 2.26 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.useWalletSettings = void 0; const WalletConfig_js_1 = require("../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 * ]) * ``` */ const useWalletSettings = () => { const { setDisplayedAssets, displayedAssets, readOnlyNetworks, hideExternalConnectOptions, hideConnectedWallets, hideSocialConnectOptions } = (0, WalletConfig_js_1.useWalletConfigContext)(); return { displayedAssets, readOnlyNetworks, setDisplayedAssets, hideExternalConnectOptions, hideConnectedWallets, hideSocialConnectOptions }; }; exports.useWalletSettings = useWalletSettings; //# sourceMappingURL=useWalletSettings.js.map