@ledgerhq/live-common
Version:
Common ground for the Ledger Live apps
19 lines (14 loc) • 677 B
text/typescript
import { CryptoCurrency } from "@ledgerhq/types-cryptoassets";
import { ConfigInfo, LiveConfig } from "@ledgerhq/live-config/LiveConfig";
import { CurrencyConfig } from "@ledgerhq/coin-framework/config";
export type CurrencyLiveConfigDefinition = Record<`config_currency_${string}`, ConfigInfo>;
const getCurrencyConfiguration = <T extends CurrencyConfig>(
currency: CryptoCurrency,
): T & Record<string, unknown> => {
const currencyData = LiveConfig.getValueByKey(`config_currency_${currency.id}`);
if (!currencyData) {
throw new Error(`No currency configuration available for ${currency.id}`);
}
return currencyData;
};
export { getCurrencyConfiguration };