UNPKG

@ledgerhq/live-common

Version:
30 lines 1.18 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.useRampCatalog = useRampCatalog; const react_1 = require("react"); const helpers_1 = require("./helpers"); const index_1 = require("./index"); function useRampCatalog() { const state = (0, index_1.useRampCatalogContext)(); /** @param mode "onRamp" for can buy, "offRamp" for can sell. */ const getSupportedCryptoCurrencyIds = (0, react_1.useCallback)((mode) => { if (!state.value) { return null; } return (0, helpers_1.getCryptoCurrencyIds)(state.value[mode]); }, [state.value]); /** @param mode "onRamp" for can buy, "offRamp" for can sell. * @returns true if the currency is supported, false if not, null if the catalog is not loaded yet. */ const isCurrencyAvailable = (0, react_1.useCallback)((currencyId, mode) => { if (!state.value) { return false; } return (0, helpers_1.isCurrencyInCatalog)(currencyId, state.value, mode); }, [state.value]); return { getSupportedCryptoCurrencyIds, isCurrencyAvailable, }; } //# sourceMappingURL=useRampCatalog.js.map