UNPKG

@dynamic-labs/sdk-react-core

Version:

A React SDK for implementing wallet web3 authentication and authorization to your website.

52 lines (49 loc) 1.7 kB
'use client' import { getChainInfo } from '@dynamic-labs/wallet-connector-core'; import '@dynamic-labs/sdk-api-core'; import { logger } from '../../../shared/logger.js'; import '@dynamic-labs/iconic'; import 'react'; import 'react/jsx-runtime'; import '../../../context/ViewContext/ViewContext.js'; import '@dynamic-labs/wallet-book'; import '@dynamic-labs/utils'; import '../../constants/colors.js'; import '../../constants/values.js'; import '../../../shared/consts/index.js'; const getNetworkInfoEntry = ({ chain, networkId, networkInfo, }) => { var _a, _b; logger.logVerboseTroubleshootingMessage('[getNetworkInfoEntry]', { chain, networkId, networkInfo, }); if (!chain || !networkId) { return; } const normalizedChain = (_a = getChainInfo(chain)) === null || _a === void 0 ? void 0 : _a.name; if (!normalizedChain) return; const networkData = networkInfo[normalizedChain]; if (!networkData) return; logger.logVerboseTroubleshootingMessage('[getNetworkInfoEntry]', { networkData, normalizedChain, }); // Not all networks have a valid chainId, so default to the first network if the chainId is not found return ((_b = networkData.find((e) => e.chainId.toString() === networkId.toString())) !== null && _b !== void 0 ? _b : networkData[0]); }; const getEvmChainName = (chainId) => { const map = { 1: 'Ethereum', 10: 'OP Mainnet', 11155111: 'Sepolia', 137: 'Polygon', 42161: 'Arbitrum One', 43114: 'Avalanche', 8453: 'Base', }; return map[chainId] || 'Unknown'; }; export { getEvmChainName, getNetworkInfoEntry };