import { CryptoCurrency, CryptoCurrencyId } from "@ledgerhq/types-cryptoassets"; import { MissingCoinConfig } from "./errors"; import type { FeatureConfig } from "./features/types"; type ConfigStatus = | { type: "active"; features?: FeatureConfig[]; } | { type: "under_maintenance"; message?: string; } | { type: "migration"; chain: CryptoCurrencyId; from: string; to: string; link: string; } | { type: "feature_unavailable"; link: string; feature: | "history" | "swap" | "token_history" | "send_and_receive" | "send" | "receive" | "sending_tokens" | "receiving_tokens" | "staking" | "claiming_staking_rewards"; } | { type: "will_be_deprecated"; deprecated_date: string; link: string; } | { type: "deprecated"; }; type Banner = { isDisplay: boolean; bannerText: string; bannerLink?: string; bannerLinkText?: string; }; export type CurrencyConfig = { status: ConfigStatus; customBanner?: Banner; [key: string]: unknown; }; export type CoinConfig = (currency?: CryptoCurrency) => T; function buildCoinConfig() { let coinConfig: CoinConfig | undefined; const setCoinConfig = (config: CoinConfig): void => { coinConfig = config; }; const getCoinConfig = (currency?: CryptoCurrency): T => { if (!coinConfig) { throw new MissingCoinConfig(); } return coinConfig(currency); }; return { setCoinConfig, getCoinConfig, }; } export default buildCoinConfig;