@reservoir0x/relay-kit-ui
Version:
Relay is the Fastest and Cheapest Way to Bridge and Transact Across Chains.
33 lines • 1.22 kB
JavaScript
import {} from '@reservoir0x/relay-sdk';
import { useState, useEffect, useMemo } from 'react';
const useAtomicBatchSupport = (wallet, chainId) => {
const [state, setState] = useState({
isSupported: null,
isLoading: false,
error: null
});
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 useMemo(() => state, [state]);
};
export default useAtomicBatchSupport;
//# sourceMappingURL=useAtomicBatchSupport.js.map