diff --git a/.github/workflows/deploy-to-cf-pages.yaml b/.github/workflows/deploy-to-cf-pages.yaml index 5b1844db..bc2da7e8 100644 --- a/.github/workflows/deploy-to-cf-pages.yaml +++ b/.github/workflows/deploy-to-cf-pages.yaml @@ -21,6 +21,8 @@ jobs: pull-requests: write runs-on: ubuntu-latest timeout-minutes: 5 + env: + BRANCH_NAME: ${{ github.head_ref }} steps: - name: "Checkout Github Action" uses: actions/checkout@v4 @@ -40,6 +42,7 @@ jobs: run: | touch .env echo VITE_FEATURE_TOGGLE_CLIENT_KEY=${{ vars.VITE_FEATURE_TOGGLE_CLIENT_KEY }} >> .env + echo VITE_BRANCH_NAME=${{ env.BRANCH_NAME }} >> .env - name: Build Project run: | npm run build diff --git a/src/components/Header/Header.tsx b/src/components/Header/Header.tsx index 5540a7f6..6c9ca2d0 100644 --- a/src/components/Header/Header.tsx +++ b/src/components/Header/Header.tsx @@ -15,6 +15,8 @@ import { useMedia } from "@hooks/useMedia"; import { useStores } from "@stores"; import { MODAL_TYPE } from "@stores/ModalStore"; +import { CONFIG } from "@utils/getConfig"; + import { ConnectWalletButton } from "../ConnectWalletButton"; import { AccountInfoSheet } from "../Modal"; import { SmartFlex } from "../SmartFlex"; @@ -31,6 +33,8 @@ const Header: React.FC = observer(() => { const [isMobileMenuOpen, openMobileMenu, closeMobileMenu] = useFlag(); const [isAccountInfoSheetOpen, openAccountInfo, closeAccountInfo] = useFlag(); + const SparkLogo = CONFIG.APP.isMainnet ? Logo : LogoStyled; + useEffect(() => { if (media.desktop) { closeMobileMenu(); @@ -68,7 +72,7 @@ const Header: React.FC = observer(() => { <> - + BETA @@ -96,7 +100,7 @@ const Header: React.FC = observer(() => { <> - + BETA @@ -190,3 +194,9 @@ const WalletContainer = styled(SmartFlex)<{ isVisible?: boolean }>` } } `; + +const LogoStyled = styled(Logo)` + path { + fill: ${({ theme }) => theme.colors.greenLight}; + } +`; diff --git a/src/typings/vite-env.d.ts b/src/typings/vite-env.d.ts index d00e6238..46f2059c 100644 --- a/src/typings/vite-env.d.ts +++ b/src/typings/vite-env.d.ts @@ -2,4 +2,13 @@ /// /// /// -/// \ No newline at end of file +/// + +interface ImportMetaEnv { + VITE_FEATURE_TOGGLE_CLIENT_KEY: string | undefined; + VITE_BRANCH_NAME: string | undefined; +} + +interface ImportMeta { + readonly env: ImportMetaEnv; +} \ No newline at end of file diff --git a/src/utils/getConfig.ts b/src/utils/getConfig.ts index 969070fb..cdc62612 100644 --- a/src/utils/getConfig.ts +++ b/src/utils/getConfig.ts @@ -1,5 +1,7 @@ import assert from "assert"; +import { Undefinable } from "tsdef"; + import TOKEN_LOGOS from "@constants/tokenLogos"; import { Token } from "@entity"; @@ -21,8 +23,21 @@ export interface Market { contractId: string; } +function getConfigByBranch(branchName: Undefinable) { + if (branchName === "main") { + return configProdJSON; + } + + if (branchName?.includes("stage/")) { + return configDevJSON; + } + + return configDevJSON; +} + function createConfig() { - const configJSON = import.meta.env.DEV ? configDevJSON : configProdJSON; + const configJSON = getConfigByBranch(import.meta.env.VITE_BRANCH_NAME); + assert(configJSON.version === CURRENT_CONFIG_VER, "Version mismatch"); console.warn("SPARK CONFIG", configJSON);