Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ import { LineChart, Line, CartesianGrid, XAxis, YAxis, Tooltip } from 'recharts'
import { ChartContainer, ChartTooltipContent } from '@/components/ui/chart'
import { hexToBytes, decodeWeekIdAndProofSetId } from '@/utility/helper'

const SECONDS_IN_WEEK = 604800

interface ProofSetActivityChartProps {
activities: WeeklyProofSetActivity[]
isLoading: boolean
Expand Down Expand Up @@ -54,7 +56,7 @@ export const ProofSetActivityChart: React.FC<ProofSetActivityChartProps> = ({
)
.map((act) => {
const { weekId } = decodeWeekIdAndProofSetId(hexToBytes(act.id))
const date = new Date(weekId * 604800 * 1000) // Convert weekId to timestamp
const date = new Date((weekId + 1) * SECONDS_IN_WEEK * 1000) // Convert weekId to timestamp
return {
totalProofs: Number(act.totalProofs),
totalFaultedRoots: Number(act.totalFaultedRoots),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ import { LineChart, Line, CartesianGrid, XAxis, YAxis, Tooltip } from 'recharts'
import { ChartContainer, ChartTooltipContent } from '@/components/ui/chart'
import { hexToBytes, decodeWeekIdAndProviderId } from '@/utility/helper'

const SECONDS_IN_WEEK = 604800

const getLabelAndColor = (activityType: string) => {
switch (activityType) {
case 'totalProofs':
Expand Down Expand Up @@ -66,7 +68,7 @@ export const ProviderActivityChart: React.FC<ProviderActivityChartProps> = ({
)
.map((act) => {
const { weekId } = decodeWeekIdAndProviderId(hexToBytes(act.id))
const date = new Date(weekId * 604800 * 1000)
const date = new Date((weekId + 1) * SECONDS_IN_WEEK * 1000)
return {
totalProofs: Number(act.totalProofs),
totalFaultedPeriods: Number(act.totalFaultedPeriods),
Expand Down
7 changes: 7 additions & 0 deletions subgraph-client/src/components/go-home.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { Link } from "react-router-dom";

export default function GoHomeLink() {
return (<Link to="/" className="text-blue-500 hover:underline">
← Go Home
</Link>)
}
1 change: 1 addition & 0 deletions subgraph-client/src/components/page-header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ export default function PageHeader() {
>
<Github className="h-5 w-5 mr-2" /> GitHub
</Link>
<NetworkSelector />
</div>
)}
</div>
Expand Down
4 changes: 2 additions & 2 deletions subgraph-client/src/pages/Documentation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import remarkGfm from 'remark-gfm'
import slugify from 'slugify'
import { useParams, Link, useNavigate } from 'react-router-dom'
import { ChevronRight, FileText, Book } from 'lucide-react'
import GoBackLink from '@/components/go-back'
import GoHomeLink from '@/components/go-home'

// Documentation structure
const docs = [
Expand Down Expand Up @@ -89,7 +89,7 @@ export const Documentation = () => {
<div className="p-6 max-w-7xl mx-auto">
{/* Back button */}
<div className="mb-6">
<GoBackLink />
<GoHomeLink />
</div>

<div className="flex flex-col md:flex-row gap-8 relative">
Expand Down
4 changes: 2 additions & 2 deletions subgraph-client/src/pages/GasCalculator.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
SelectTrigger,
SelectValue,
} from '@/components/ui/select'
import GoBackLink from '@/components/go-back'
import GoHomeLink from '@/components/go-home'

interface GasMetrics {
gasHigh: string
Expand Down Expand Up @@ -127,7 +127,7 @@ export const GasCalculator = () => {
<div>
<div className="mb-8">
<div className="mb-6">
<GoBackLink />
<GoHomeLink />
</div>
<h1 className="text-2xl font-bold mb-4">
PDP Gas & Costs Calculator
Expand Down
14 changes: 13 additions & 1 deletion subgraph-client/src/pages/Landing.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,12 @@ import {
X, Search
} from 'lucide-react'
import { search, SearchResult } from '@/api/apiService'
import { formatDataSize, bytesToHex, parseCidToHex } from '@/utility/helper'
import {
formatDataSize,
bytesToHex,
parseCidToHex,
normalizeBytesFilter,
} from '@/utility/helper'
import { networkContractAddresses, explorerUrls } from '@/utility/constants'
import useGraphQL from '@/hooks/useGraphQL'
import { landingDataQuery, weeklyProviderActivitiesQuery } from '@/utility/queries'
Expand Down Expand Up @@ -106,6 +111,13 @@ export const Landing = () => {
return
}

const isProvider =
/^0x[0-9a-fA-F]+$/.test(trimmedQuery) && !trimmedQuery.startsWith('bafk')
if (isProvider) {
navigate(`/${network}/providers/${normalizeBytesFilter(trimmedQuery)}`)
return
}

const response = await search(subgraphUrl, trimmedQuery, toast)
const results = response

Expand Down
4 changes: 2 additions & 2 deletions subgraph-client/src/pages/PieceDetails.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { useParams } from 'react-router-dom'
import { PieceOverviewCard } from '@/components/PieceDetails/PieceOverviewCard'
import { PieceDataSetsTable } from '@/components/PieceDetails/PieceDataSetsTable'
import usePiecePageData from '@/hooks/usePiecePageData'
import GoBackLink from '@/components/go-back'
import GoHomeLink from '@/components/go-home'

export const PieceDetails = () => {
const ITEMS_PER_PAGE = 10
Expand Down Expand Up @@ -43,7 +43,7 @@ export const PieceDetails = () => {
return (
<div className="p-6 max-w-7xl mx-auto">
<div className="mb-6">
<GoBackLink />
<GoHomeLink />
</div>
<div className="flex items-center gap-2 mb-4">
{/* Show title only when details are loaded/loading, not on invalid ID state */}
Expand Down
4 changes: 2 additions & 2 deletions subgraph-client/src/pages/ProofSetDetails.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { ActivityTabs } from '@/components/ProofSetDetails/ActivityTabs'
import { HeatmapSection } from '@/components/ProofSetDetails/HeatmapSection'
import useProofSetDetails from '@/hooks/useProofSetDetails'
import { ProofSetActivityChart } from '@/components/ProofSetDetails/ProofSetActivityChart'
import GoBackLink from '@/components/go-back'
import GoHomeLink from '@/components/go-home'

const ITEMS_PER_PAGE = 10
const ROOTS_PER_PAGE = 100
Expand Down Expand Up @@ -69,7 +69,7 @@ export const ProofSetDetails = () => {
return (
<div className="p-6 max-w-7xl mx-auto">
<div className="mb-6">
<GoBackLink />
<GoHomeLink />
</div>
<div className="flex items-center gap-2 mb-4">
{/* Show title only if core proofSet data loaded, avoid showing before ID is confirmed valid */}
Expand Down
4 changes: 2 additions & 2 deletions subgraph-client/src/pages/ProviderDetails.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { ProviderOverviewCard } from '@/components/ProviderDetails/ProviderOverv
import { ProviderActivityChart } from '@/components/ProviderDetails/ProviderActivityChart'
import { ProviderProofSetsTable } from '@/components/ProviderDetails/ProviderProofSetsTable'
import useProviderPageData from '@/hooks/useProviderPageData'
import GoBackLink from '@/components/go-back'
import GoHomeLink from '@/components/go-home'

export const ProviderDetails = () => {
const ITEMS_PER_PAGE = 10
Expand Down Expand Up @@ -36,7 +36,7 @@ export const ProviderDetails = () => {
return (
<div className="p-6 max-w-7xl mx-auto">
<div className="mb-6">
<GoBackLink />
<GoHomeLink />
</div>
<div className="flex items-center gap-2 mb-4">
{/* Show title only when details are loaded/loading, not on invalid ID state */}
Expand Down
4 changes: 2 additions & 2 deletions subgraph-client/src/pages/ServiceDetails.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import { serviceDetailsQuery, serviceProvidersQuery } from '@/utility/queries'
import { CopyableText } from '@/components/shared/CopyableText'
import { ProofSetsTable } from '@/components/ProofSets/ProofSetsTable'
import { ProvidersTable } from '@/components/Providers/ProvidersTable'
import GoBackLink from '@/components/go-back'
import GoHomeLink from '@/components/go-home'

const ITEMS_PER_PAGE = 10

Expand Down Expand Up @@ -114,7 +114,7 @@ export const ServiceDetails = () => {
return (
<div className="p-6 max-w-7xl mx-auto">
<div className="mb-6">
<GoBackLink />
<GoHomeLink />
</div>
<div className="mb-4">
<h1 className="text-2xl font-bold mb-2">Service Contract Details</h1>
Expand Down
Loading