UNPKG

@reservoir0x/relay-kit-ui

Version:

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

34 lines 1.28 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const react_1 = require("react"); const useAtomicBatchSupport = (wallet, chainId) => { const [state, setState] = (0, react_1.useState)({ isSupported: null, isLoading: false, error: null }); (0, react_1.useEffect)(() => { const checkAtomicBatchSupport = async () => { if (!wallet?.supportsAtomicBatch || !chainId) { setState({ isSupported: false, isLoading: false, error: null }); return; } setState((s) => ({ ...s, isLoading: true })); try { const supported = await wallet.supportsAtomicBatch(chainId); setState({ isSupported: supported, isLoading: false, error: null }); } catch (e) { setState({ isSupported: false, isLoading: false, error: e instanceof Error ? e : new Error('Unknown error') }); } }; checkAtomicBatchSupport(); }, [wallet, chainId]); return (0, react_1.useMemo)(() => state, [state]); }; exports.default = useAtomicBatchSupport; //# sourceMappingURL=useAtomicBatchSupport.js.map