import { ChainType } from '../../utils/chainType.js'; import type { EclipseProvider, EclipseProviderOptions } from './types.js'; import type { StepExecutorOptions } from '../types.js'; import { isAddress } from './isAddress.js'; import { getEclipseBalance } from './getEclipseBalance.js'; import { useEclipseAddress } from './getEclipseAddress.js'; import { EclipseStepExecutor } from './EclipseStepExecutor.js'; export function Eclipse(options?: EclipseProviderOptions): EclipseProvider { const _options: EclipseProviderOptions = options ?? {}; return { get type() { return ChainType.ECLIPSE as any; }, isAddress, resolveAddress: useEclipseAddress, getBalance: getEclipseBalance as any, async getStepExecutor( options: StepExecutorOptions, ): Promise { if (!_options.getWalletAdapter) { throw new Error(`getWalletAdapter is not provided.`); } const walletAdapter = await _options.getWalletAdapter(); const executor = new EclipseStepExecutor({ routeId: options.routeId, walletAdapter: walletAdapter, executionOptions: { ...options.executionOptions, slippage: _options.slippage, }, }); return executor; }, setOptions(options: EclipseProviderOptions) { Object.assign(_options, options); }, }; }