From ab05244ee4a7231a552e62c40cc1522a1ba3e019 Mon Sep 17 00:00:00 2001 From: lance10030 Date: Wed, 21 Aug 2024 17:36:22 +0800 Subject: [PATCH] feat: env change --- src/components/Cards/SurfaceCards/ClaimCard.tsx | 4 ++-- .../Cards/SurfaceCards/CreditCard.tsx | 4 ++-- src/components/Cards/SurfaceCards/EventCard.tsx | 5 +++-- src/components/Cards/SurfaceCards/GameCard.tsx | 4 ++-- src/components/NavMenusSection/index.tsx | 4 +++- src/pages/game/[game].tsx | 4 ++-- src/utils/env.ts | 17 +++++++++-------- 7 files changed, 23 insertions(+), 19 deletions(-) diff --git a/src/components/Cards/SurfaceCards/ClaimCard.tsx b/src/components/Cards/SurfaceCards/ClaimCard.tsx index cc0870c..6c9f1e6 100644 --- a/src/components/Cards/SurfaceCards/ClaimCard.tsx +++ b/src/components/Cards/SurfaceCards/ClaimCard.tsx @@ -5,7 +5,7 @@ import { Link } from "@/components/Link"; import { Skeleton } from "@/components/Skeleton"; import { CardField } from "../Card"; import { shortenAddress } from "@/utils"; -import { EXPLORER_L2 } from "@/utils/env"; +import { EXPLORER_L1, EXPLORER_L2 } from "@/utils/env"; type ClaimCardProps = { claimData: ClaimData; @@ -44,7 +44,7 @@ const ClaimCard: FC> = ({ claimData = {} }) => { name={
Claimant
} value={ {shortenAddress(claimant)} diff --git a/src/components/Cards/SurfaceCards/CreditCard.tsx b/src/components/Cards/SurfaceCards/CreditCard.tsx index 264d522..e58b99c 100644 --- a/src/components/Cards/SurfaceCards/CreditCard.tsx +++ b/src/components/Cards/SurfaceCards/CreditCard.tsx @@ -7,7 +7,7 @@ import { SurfaceCardBase } from "./SurfaceCardBase"; import { Credit } from "@/types"; import { shortenAddress } from "@/utils"; import { EtherUnitDisplay } from "@/components/Displays/EtherUnitDisplay"; -import { EXPLORER_L2 } from "@/utils/env"; +import { EXPLORER_L1 } from "@/utils/env"; type CreditCardProps = { credit: Credit; @@ -26,7 +26,7 @@ const CreditCard: FC> = function ({
Address{" "} {shortenAddress(address)} diff --git a/src/components/Cards/SurfaceCards/EventCard.tsx b/src/components/Cards/SurfaceCards/EventCard.tsx index 41a46ed..6456621 100644 --- a/src/components/Cards/SurfaceCards/EventCard.tsx +++ b/src/components/Cards/SurfaceCards/EventCard.tsx @@ -7,6 +7,7 @@ import { SurfaceCardBase } from "./SurfaceCardBase"; import { LatestEvents } from "@/types"; import { shortenAddress } from "@/utils"; import { useRouter } from "next/router"; +import { EXPLORER_L1 } from "@/utils/env"; type EventCardProps = { events: LatestEvents; @@ -25,7 +26,7 @@ const EventCard: FC> = function ({ {event_hash ? (
{shortenAddress(event_hash, 10)} @@ -56,7 +57,7 @@ const EventCard: FC> = function ({ {contract_address ? (
Contract Address:
- {shortenAddress(contract_address)} + {shortenAddress(contract_address)}
) : ( diff --git a/src/components/Cards/SurfaceCards/GameCard.tsx b/src/components/Cards/SurfaceCards/GameCard.tsx index 01f2d43..132d2bb 100644 --- a/src/components/Cards/SurfaceCards/GameCard.tsx +++ b/src/components/Cards/SurfaceCards/GameCard.tsx @@ -10,7 +10,7 @@ import { shortenAddress } from "@/utils"; import shield from "@/icons/shield.png"; import sword from "@/icons/sword.png"; import Image from "next/image"; -import { EXPLORER_L2 } from "@/utils/env"; +import { EXPLORER_L1, EXPLORER_L2 } from "@/utils/env"; type GameCardProps = { game: Game; @@ -79,7 +79,7 @@ const GameCard: FC> = function ({ tx hash{" "} {shortenAddress(tx_hash as string)} diff --git a/src/components/NavMenusSection/index.tsx b/src/components/NavMenusSection/index.tsx index 8e97193..a8aa0e1 100644 --- a/src/components/NavMenusSection/index.tsx +++ b/src/components/NavMenusSection/index.tsx @@ -20,7 +20,9 @@ export const NavMenusSection: React.FC = () => { const [isMobileMenuOpen, setIsMobileMenuOpen] = useState(false); const handleSelectNetwork = (e: Network) => { - window.open(SuperProofUrls[e]) + const url = SuperProofUrls[e] + if (url.includes(window.location.origin)) return + window.open(url) } diff --git a/src/pages/game/[game].tsx b/src/pages/game/[game].tsx index 8011438..dd1d7e4 100644 --- a/src/pages/game/[game].tsx +++ b/src/pages/game/[game].tsx @@ -14,7 +14,7 @@ import { ClockIcon, FlagIcon } from "@heroicons/react/24/outline"; import { Card } from "@/components/Cards/Card"; import ClaimCard from "@/components/Cards/SurfaceCards/ClaimCard"; import { SlidableList } from "@/components/SlidableList"; -import { EXPLORER_L2 } from "@/utils/env"; +import { EXPLORER_L1, EXPLORER_L2 } from "@/utils/env"; const GameDetail = () => { const router = useRouter(); @@ -35,7 +35,7 @@ const GameDetail = () => { name="Game Address" content={ {shortenAddress(game?.hits[0].game_contract!, 8)} diff --git a/src/utils/env.ts b/src/utils/env.ts index 1ba510e..eed6ba0 100644 --- a/src/utils/env.ts +++ b/src/utils/env.ts @@ -1,13 +1,14 @@ export type Network = 'mainnet' | 'sepolia' | 'base-sepolia' -export const EXPLORER_L1 = process.env.NEXT_PUBLIC_L1_EXPLORER || 'https://optimistic.etherscan.io' -export const EXPLORER_L2 = process.env.NEXT_PUBLIC_L1_EXPLORER || 'https://sepolia-optimism.etherscan.io' +export const EXPLORER_L1 = process.env.NEXT_PUBLIC_L1_EXPLORER || 'https://sepolia.etherscan.io' +export const EXPLORER_L2 = process.env.NEXT_PUBLIC_L2_EXPLORER || 'https://sepolia-optimism.etherscan.io' export const network = process.env.NEXT_PUBLIC_NETWORK as Network || 'sepolia' - -export const ApiDoc = "http://144.76.97.175:8080/swagger/index.html" +export const ApiDoc = process.env.NEXT_API_DOC || '' export const SuperProofUrls: Record = { - 'mainnet': '', - 'sepolia': '', - 'base-sepolia': '' -} \ No newline at end of file + 'mainnet': process.env.NEXT_PUBLIC_OP_MAINNET_URL || '', + 'sepolia': process.env.NEXT_PUBLIC_OP_SEPOLIA_URL || '', + 'base-sepolia': process.env.NEXT_PUBLIC_BASE_SEPOLIA_URL || '' +} + +console.log(SuperProofUrls, 'ssss')