UNPKG

@lifi/sdk

Version:

LI.FI Any-to-Any Cross-Chain-Swap SDK

28 lines 1.1 kB
import { ChainType } from '@lifi/types'; import { getCapabilities } from 'viem/actions'; import { getAction } from 'viem/utils'; import { config } from '../../config.js'; import { sleep } from '../../utils/sleep.js'; export async function isBatchingSupported({ client, chainId, skipReady = false, }) { const _client = client ?? (await config.getProvider(ChainType.EVM)?.getWalletClient?.()); if (!_client) { throw new Error('WalletClient is not provided.'); } try { const capabilities = await Promise.race([ getAction(_client, getCapabilities, 'getCapabilities')({ chainId }), sleep(2_000), ]); return (capabilities?.atomicBatch?.supported || capabilities?.atomic?.status === 'supported' || (!skipReady && capabilities?.atomic?.status === 'ready') || false); } catch { // If the wallet does not support getCapabilities or the call fails, // we assume that atomic batch is not supported return false; } } //# sourceMappingURL=isBatchingSupported.js.map