Skip to content

Commit

Permalink
feat: env change
Browse files Browse the repository at this point in the history
  • Loading branch information
lance10030 committed Aug 21, 2024
1 parent 43f98ee commit ab05244
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 19 deletions.
4 changes: 2 additions & 2 deletions src/components/Cards/SurfaceCards/ClaimCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -44,7 +44,7 @@ const ClaimCard: FC<Partial<ClaimCardProps>> = ({ claimData = {} }) => {
name={<div title="Game Address">Claimant</div>}
value={
<Link
href={`https://sepolia.etherscan.io/address/${claimant}`}
href={`${EXPLORER_L1}/address/${claimant}`}
isExternal
>
{shortenAddress(claimant)}
Expand Down
4 changes: 2 additions & 2 deletions src/components/Cards/SurfaceCards/CreditCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -26,7 +26,7 @@ const CreditCard: FC<Partial<CreditCardProps>> = function ({
<div className="flex gap-1 text-contentSecondary-light dark:text-contentSecondary-dark">
Address{" "}
<Link
href={`${EXPLORER_L2}/address/${address}`}
href={`${EXPLORER_L1}/address/${address}`}
isExternal
>
{shortenAddress(address)}
Expand Down
5 changes: 3 additions & 2 deletions src/components/Cards/SurfaceCards/EventCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -25,7 +26,7 @@ const EventCard: FC<Partial<EventCardProps>> = function ({
{event_hash ? (
<div className="flex gap-1 text-contentSecondary-light dark:text-contentSecondary-dark">
<Link
href={`https://sepolia.etherscan.io/tx/${tx_hash}`}
href={`${EXPLORER_L1}/tx/${tx_hash}`}
isExternal
>
{shortenAddress(event_hash, 10)}
Expand Down Expand Up @@ -56,7 +57,7 @@ const EventCard: FC<Partial<EventCardProps>> = function ({
{contract_address ? (
<div className="flex w-full gap-1">
<div>Contract Address: </div>
<Link href={`https://sepolia.etherscan.io/address/${contract_address}`}>{shortenAddress(contract_address)}</Link>
<Link href={`${EXPLORER_L1}/address/${contract_address}`}>{shortenAddress(contract_address)}</Link>
</div>
) : (
<Skeleton width={300} size="xs" />
Expand Down
4 changes: 2 additions & 2 deletions src/components/Cards/SurfaceCards/GameCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -79,7 +79,7 @@ const GameCard: FC<Partial<GameCardProps>> = function ({
<span>
tx hash{" "}
<Link
href={`https://sepolia.etherscan.io/tx/${tx_hash}`}
href={`${EXPLORER_L1}/tx/${tx_hash}`}
isExternal
>
{shortenAddress(tx_hash as string)}
Expand Down
4 changes: 3 additions & 1 deletion src/components/NavMenusSection/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}


Expand Down
4 changes: 2 additions & 2 deletions src/pages/game/[game].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -35,7 +35,7 @@ const GameDetail = () => {
name="Game Address"
content={
<Link
href={`${EXPLORER_L2}/address/${game?.hits[0].game_contract}`}
href={`${EXPLORER_L1}/address/${game?.hits[0].game_contract}`}
isExternal
>
{shortenAddress(game?.hits[0].game_contract!, 8)}
Expand Down
17 changes: 9 additions & 8 deletions src/utils/env.ts
Original file line number Diff line number Diff line change
@@ -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<Network, string> = {
'mainnet': '',
'sepolia': '',
'base-sepolia': ''
}
'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')

0 comments on commit ab05244

Please sign in to comment.