UNPKG

@getclave/lifi-sdk

Version:

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

31 lines (30 loc) 1.19 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.isBatchingSupported = isBatchingSupported; const types_1 = require("@lifi/types"); const actions_1 = require("viem/actions"); const utils_1 = require("viem/utils"); const config_1 = require("../../config"); const sleep_1 = require("../../utils/sleep"); async function isBatchingSupported({ client, chainId, }) { const _client = client ?? (await config_1.config.getProvider(types_1.ChainType.EVM)?.getWalletClient?.()); if (!_client) { throw new Error('WalletClient is not provided.'); } try { const capabilities = await Promise.race([ (0, utils_1.getAction)(_client, actions_1.getCapabilities, 'getCapabilities')({ chainId }), (0, sleep_1.sleep)(2_000), ]); return (capabilities?.atomicBatch?.supported || capabilities?.atomic?.status === 'supported' || 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; } }