@ledgerhq/live-common
Version:
Common ground for the Ledger Live apps
54 lines • 2.67 kB
JavaScript
;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.useWalletFeaturesConfig = void 0;
const react_1 = require("react");
const useFeature_1 = __importDefault(require("../useFeature"));
const types_1 = require("./types");
/**
* Hook for wallet4.0 configuration.
* Works for both desktop (lwdWallet40) and mobile (lwmWallet40).
*
* When adding platform-specific params in types-live:
* 1. Add the param to Feature_LwdWallet40 or Feature_LwmWallet40
* 2. Add the corresponding boolean getter in WalletFeaturesConfig
* 3. Add the logic in the useMemo below
*
* @param platform - The platform to get the feature flag for ("desktop" or "mobile")
* @returns Configuration object with boolean flags for each feature
*
* @example
* // Desktop usage
* const config = useWalletFeaturesConfig("desktop");
*
* @example
* // Mobile usage
* const config = useWalletFeaturesConfig("mobile");
*/
const useWalletFeaturesConfig = (platform) => {
const featureFlagKey = types_1.FEATURE_FLAG_KEYS[platform];
const walletFeatureFlag = (0, useFeature_1.default)(featureFlagKey);
return (0, react_1.useMemo)(() => {
const isEnabled = walletFeatureFlag?.enabled ?? false;
const params = walletFeatureFlag?.params;
return {
isEnabled,
shouldDisplayMarketBanner: isEnabled && Boolean(params?.marketBanner),
shouldDisplayGraphRework: isEnabled && Boolean(params?.graphRework),
shouldDisplayQuickActionCtas: isEnabled && Boolean(params?.quickActionCtas),
shouldDisplayNewReceiveDialog: isEnabled && Boolean(params?.newReceiveDialog),
shouldDisplayWallet40MainNav: isEnabled && Boolean(params?.mainNavigation),
shouldUseLazyOnboarding: isEnabled && Boolean(params?.lazyOnboarding),
shouldDisplayBalanceRefreshRework: isEnabled && Boolean(params?.balanceRefreshRework),
shouldDisplayTour: isEnabled && Boolean(params?.tour),
shouldDisplayAssetSection: isEnabled && Boolean(params?.assetSection),
shouldDisplayOnboardingWidget: isEnabled && Boolean(params && "onboardingWidget" in params && params.onboardingWidget),
shouldDisplayBrazePlacement: isEnabled && Boolean(params?.brazePlacement),
shouldDisplayOperationsList: isEnabled && Boolean(params?.operationsList),
};
}, [walletFeatureFlag]);
};
exports.useWalletFeaturesConfig = useWalletFeaturesConfig;
//# sourceMappingURL=useWalletFeaturesConfig.js.map