Skip to content

Commit

Permalink
fix: revert enableLmp and isBridgeEnable
Browse files Browse the repository at this point in the history
  • Loading branch information
minikas committed Jul 5, 2024
1 parent 17ca374 commit 42f1cf7
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 22 deletions.
2 changes: 2 additions & 0 deletions apps/hestia/next.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ const nextConfig = {
LANDING_PAGE: process.env.LANDING_PAGE,
MAINTENACE_MODE: process.env.MAINTENACE_MODE,
UNDER_MAINTENACE: process.env.UNDER_MAINTENACE,
ENABLE_LMP: process.env.ENABLE_LMP,
IS_BRIDGE_ENABLED: process.env.IS_BRIDGE_ENABLED,
BLOCKED_ASSETS: process.env.BLOCKED_ASSETS,
DEFAULT_TRANSFER_TOKEN: process.env.DEFAULT_TRANSFER_TOKEN,
SUBSCAN_API: process.env.SUBSCAN_API,
Expand Down
9 changes: 5 additions & 4 deletions apps/hestia/src/components/ui/Header/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { Fragment, forwardRef, useMemo, useState } from "react";
import Link from "next/link";
import { useSettingsProvider } from "@orderbook/core/providers/public/settings";
import { Logo } from "@polkadex/ux";
import { enabledFeatures, getMarketUrl } from "@orderbook/core/helpers";
import { getMarketUrl } from "@orderbook/core/helpers";
import { defaultConfig } from "@orderbook/core/config";
import {
RiRedditFill,
Expand All @@ -24,7 +24,6 @@ import { NotificationsModal } from "./NotificationsModal";
import { FundWalletModal } from "./fundWalletModal";

const { defaultTheaSourceChain, defaultTheaDestinationChain } = defaultConfig;
const { lmp: isRewardsEnabled, bridge: isBridgeEnabled } = enabledFeatures;

export const Header = forwardRef<HTMLDivElement>((_, ref) => {
const [menu, setMenu] = useState(false);
Expand All @@ -36,6 +35,8 @@ export const Header = forwardRef<HTMLDivElement>((_, ref) => {
notifications: allNotifications,
onToogleFundWallet,
} = useSettingsProvider();
const isRewardDisabled = !defaultConfig.enableLmp;
const isBridgeDisabled = !defaultConfig.isBridgeEnabled;
const lastUsedMarketUrl = getMarketUrl();

const unreadNotifications = useMemo(() => {
Expand Down Expand Up @@ -72,11 +73,11 @@ export const Header = forwardRef<HTMLDivElement>((_, ref) => {
</HeaderLink.Single>
<HeaderLink.Single
href={`/thea?from=${defaultTheaSourceChain}&to=${defaultTheaDestinationChain}`}
disabled={!isBridgeEnabled}
disabled={isBridgeDisabled}
>
Bridge
</HeaderLink.Single>
<HeaderLink.Single disabled={!isRewardsEnabled} href="/rewards">
<HeaderLink.Single disabled={isRewardDisabled} href="/rewards">
Rewards
</HeaderLink.Single>
<HeaderLink.Dropdown
Expand Down
10 changes: 6 additions & 4 deletions apps/hestia/src/components/ui/Header/responsiveMenuModal.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React, { Dispatch, SetStateAction } from "react";
import { Button, Modal, Typography } from "@polkadex/ux";
import Image from "next/image";
import { enabledFeatures, getMarketUrl } from "@orderbook/core/helpers";
import { getMarketUrl } from "@orderbook/core/helpers";
import { useWindowSize } from "usehooks-ts";
import {
RiCloseLine,
Expand All @@ -14,11 +14,11 @@ import {
RiTwitterXFill,
RiDiscordFill,
} from "@remixicon/react";
import { defaultConfig } from "@orderbook/core/config";

import QrCode from "../../../../public/img/qrCode.png";

import { HeaderLink } from "./headerLink";
const { lmp: isRewardsEnabled, bridge: isBridgeEnabled } = enabledFeatures;
export const ResponsiveMenuModal = ({
open,
onOpenChange,
Expand All @@ -27,6 +27,8 @@ export const ResponsiveMenuModal = ({
onOpenChange: Dispatch<SetStateAction<boolean>>;
}) => {
const lastUsedMarketUrl = getMarketUrl();
const isRewardDisabled = !defaultConfig.enableLmp;
const isBridgeDisabled = !defaultConfig.isBridgeEnabled;
const { width } = useWindowSize();
return (
<Modal
Expand Down Expand Up @@ -70,15 +72,15 @@ export const ResponsiveMenuModal = ({
size="lg"
href="/thea"
className="text-lg"
disabled={!isBridgeEnabled}
disabled={isBridgeDisabled}
>
Bridge
</HeaderLink.Single>
<HeaderLink.Single
size="lg"
href="/rewards"
className="text-lg"
disabled={!isRewardsEnabled}
disabled={isRewardDisabled}
>
Rewards
</HeaderLink.Single>
Expand Down
11 changes: 6 additions & 5 deletions apps/hestia/src/middleware.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
import { defaultConfig } from "@orderbook/core/config";
import { enabledFeatures } from "@orderbook/core/helpers";
import { NextResponse } from "next/server";
import type { NextRequest } from "next/server";
export function middleware(req: NextRequest) {
const { maintenanceMode } = defaultConfig;

const { lmp: isRewardsEnabled, bridge: isBridgeEnabled } = enabledFeatures;
const {
enableLmp: isRewardsActive,
isBridgeEnabled,
maintenanceMode,
} = defaultConfig;

const isTransferPage = req.nextUrl.pathname.startsWith("/transfer");

if (maintenanceMode) {
return NextResponse.redirect(new URL("/maintenance", req.url));
}
if (!isRewardsEnabled && req.nextUrl.pathname.startsWith("/rewards")) {
if (!isRewardsActive && req.nextUrl.pathname.startsWith("/rewards")) {
return NextResponse.redirect(new URL("/", req.url));
}
if (!isBridgeEnabled && req.nextUrl.pathname.startsWith("/thea")) {
Expand Down
4 changes: 3 additions & 1 deletion packages/core/src/config/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ export const defaultConfig: DefaultConfig = {
gaTrackerKey: process.env.GA_MEASUREMENT_ID ?? "G-PWZK8JEFLX",
landingPageMarket: process.env.LANDING_PAGE || "DOTUSDT",
maintenanceMode: process.env.MAINTENACE_MODE === "true",
enableLmp: process.env.ENABLE_LMP === "true",
isBridgeEnabled: process.env.IS_BRIDGE_ENABLED !== "false",
availableRoutes: ["/trading", "/balances", "/transfer"],
underMaintenance: process.env.UNDER_MAINTENACE?.split(",") ?? [],
blockedAssets: process.env.BLOCKED_ASSETS?.split(",") || [],
Expand All @@ -27,7 +29,7 @@ export const defaultConfig: DefaultConfig = {
googleClientId: process.env.GOOGLE_CLIENT_ID ?? "",
disabledFeatures: (process.env.DISABLED_FEATURES?.split(
","
) as Array<Features>) ?? ["payWithAnotherFee", "lmp"],
) as Array<Features>) ?? ["payWithAnotherFee"],
defaultTheaSourceChain: process.env.DEFAULT_THEA_SOURCE_CHAIN ?? "Polkadot",
defaultTheaDestinationChain:
process.env.DEFAULT_THEA_DESTINATION_CHAIN ?? "Polkadex",
Expand Down
9 changes: 3 additions & 6 deletions packages/core/src/config/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ export type DefaultConfig = {
gaTrackerKey: string;
landingPageMarket: string;
maintenanceMode: boolean;
enableLmp: boolean;
isBridgeEnabled: boolean;
availableRoutes: string[];
underMaintenance: string[];
blockedAssets: string[];
Expand All @@ -17,9 +19,4 @@ export type DefaultConfig = {
};

export type Features = (typeof features)[number];
export const features = [
"googleDriveStore",
"payWithAnotherFee",
"lmp",
"bridge",
] as const;
export const features = ["googleDriveStore", "payWithAnotherFee"] as const;
2 changes: 0 additions & 2 deletions packages/core/src/helpers/isFeatureDisabled.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,4 @@ export const isFeatureDisabled = (v: Features) =>
export const enabledFeatures = {
googleDriveStore: isFeatureDisabled("googleDriveStore"),
payWithAnotherFee: isFeatureDisabled("payWithAnotherFee"),
bridge: isFeatureDisabled("bridge"),
lmp: isFeatureDisabled("lmp"),
};

0 comments on commit 42f1cf7

Please sign in to comment.