UNPKG

@reservoir0x/relay-kit-ui

Version:

Relay is the Fastest and Cheapest Way to Bridge and Transact Across Chains.

42 lines 2.08 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const tslib_1 = require("tslib"); const react_1 = require("react"); const walletCompatibility_js_1 = require("../constants/walletCompatibility.js"); const viem_1 = require("viem"); const useIsAGW_js_1 = tslib_1.__importDefault(require("./useIsAGW.js")); const useCexAddresses_js_1 = tslib_1.__importDefault(require("./useCexAddresses.js")); exports.default = (chainId, address, wallets, onAnalyticEvent) => { const normalizedAddress = address && (0, viem_1.isAddress)(address) ? address.toLowerCase() : address; const linkedWallet = wallets?.find((wallet) => (wallet.vmType === 'evm' ? wallet.address.toLowerCase() : wallet.address) === normalizedAddress); const isRecipientAGW = (0, useIsAGW_js_1.default)(address, !linkedWallet, onAnalyticEvent); const { data: cexAddresses } = (0, useCexAddresses_js_1.default)(); const isRecipientCEX = cexAddresses?.addresses.includes(normalizedAddress ?? ''); return (0, react_1.useMemo)(() => { if (!chainId || !address) { return true; } if (chainId === 1337) { return true; } if (!linkedWallet) { if (isRecipientCEX) { return false; } return isRecipientAGW ? chainId === 2741 : true; } const normalizedWalletName = walletCompatibility_js_1.NormalizedWalletName[linkedWallet.connector] ?? linkedWallet.connector; const incompatibleChains = walletCompatibility_js_1.WalletChainIncompatible[normalizedWalletName]; if (incompatibleChains && incompatibleChains.includes(chainId)) { return false; } const restrictedChains = walletCompatibility_js_1.WalletChainRestricted[normalizedWalletName]; if (restrictedChains && !restrictedChains.includes(chainId)) { return false; } return true; }, [chainId, address, linkedWallet, isRecipientAGW, isRecipientCEX]); }; //# sourceMappingURL=useIsWalletCompatible.js.map