Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug fixes / tech debt + Report Tx Id paste + Incentives + Delegates #1

Open
wants to merge 119 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
119 commits
Select commit Hold shift + click to select a range
8c813b5
Update tanstack router to stable
elliotsayes Jan 13, 2024
4db5708
Fix query
elliotsayes Jan 13, 2024
e5e8025
Fix timeago
elliotsayes Jan 13, 2024
13b8cfd
Fix indexing incompatible versions
elliotsayes Jan 13, 2024
8fd833d
Delete unused file
elliotsayes Jan 13, 2024
9481c81
Fix typings
elliotsayes Jan 13, 2024
1fd27b7
Logical order
elliotsayes Jan 13, 2024
2f11a39
add fqdnKey
elliotsayes Jan 13, 2024
a122313
Update GAR format
elliotsayes Jan 13, 2024
e9e824e
Increase timeout :(
elliotsayes Jan 13, 2024
e0cd206
Fix GAR item fixture
elliotsayes Jan 13, 2024
0111468
Fix finding index
elliotsayes Jan 13, 2024
94b2164
Fix sorting
elliotsayes Jan 13, 2024
f4609e0
Use fqdnKey instead of fqdn
elliotsayes Jan 13, 2024
40b571d
Merge pull request #2 from elliotsayes/dev
elliotsayes Jan 13, 2024
2446871
Implement box
elliotsayes Jan 26, 2024
3f11601
Styling / errors
elliotsayes Jan 26, 2024
4191aa9
Paste & go
elliotsayes Jan 26, 2024
d7756d5
Add support for versions
elliotsayes Jan 26, 2024
a07834e
Fix current report schema
elliotsayes Jan 26, 2024
b6ef6b9
Parsing IncentiveContract
elliotsayes Jan 26, 2024
875a567
fetchIncentiveContractData
elliotsayes Jan 26, 2024
8b69988
Add incentiveInfo to garData
elliotsayes Jan 26, 2024
217d483
Add rewards column
elliotsayes Jan 26, 2024
9886577
Consolidate observe buttons
elliotsayes Jan 26, 2024
3db1344
No hiding context button
elliotsayes Jan 26, 2024
a12ecce
Merge pull request #3 from elliotsayes/dev
elliotsayes Jan 26, 2024
56065af
Fix links
elliotsayes Jan 26, 2024
f9eb2cb
Unnecessary log
elliotsayes Jan 26, 2024
3f0d721
Dash for no weight
elliotsayes Jan 26, 2024
141acca
Fix type
elliotsayes Jan 27, 2024
c6d0273
net config
elliotsayes Jan 27, 2024
a52f24b
Incentives + refactor
elliotsayes Jan 27, 2024
47e244b
Hack to make report query accurate & performant
elliotsayes Jan 29, 2024
9666699
Use network
elliotsayes Jan 29, 2024
86121c1
Restyle with links
elliotsayes Jan 29, 2024
fed3f0c
Restructure network config
elliotsayes Jan 29, 2024
ed01ec2
Fix bug
elliotsayes Jan 29, 2024
4b647af
Fix using defaultNetwork in some places & abstract into useGarData
elliotsayes Jan 29, 2024
f2e1a6c
Fix version whitelist
elliotsayes Jan 29, 2024
67b1cff
Remove outer card
elliotsayes Jan 31, 2024
9d7d685
Use localstorage for network
elliotsayes Jan 31, 2024
acf48c3
Styles
elliotsayes Jan 31, 2024
59c206e
Persist row state
elliotsayes Jan 31, 2024
aaa0d9f
Report list persist visibility
elliotsayes Jan 31, 2024
538c625
Persist observation list visibility
elliotsayes Jan 31, 2024
a3305fa
Fixes
elliotsayes Jan 31, 2024
5e1d960
Report summary columns
elliotsayes Jan 31, 2024
9bc00bd
Abstract into hook & refactor
elliotsayes Jan 31, 2024
9d3f4a4
Don't retry gateways
elliotsayes Jan 31, 2024
a62e28c
Install hover card
elliotsayes Feb 1, 2024
f7e01e1
Fix radix imports
elliotsayes Feb 1, 2024
8be9c2e
Incentive hover card
elliotsayes Feb 1, 2024
ba1d97c
Merge pull request #4 from elliotsayes/dev
elliotsayes Feb 1, 2024
69a92e3
Click to open
elliotsayes Feb 1, 2024
4e6803e
Merge pull request #5 from elliotsayes/dev
elliotsayes Feb 1, 2024
3e2ccb3
Merge garCache/incentive contract + fix tests
elliotsayes Feb 1, 2024
e91e6f5
Refactor networks
elliotsayes Feb 1, 2024
f975966
Typo
elliotsayes Feb 1, 2024
6aa8d97
Add default testnet
elliotsayes Feb 1, 2024
fc9ec71
Merge pull request #6 from elliotsayes/dev
elliotsayes Feb 1, 2024
e36c948
Gateway rating
elliotsayes Feb 1, 2024
4906c2e
Gateway rating
elliotsayes Feb 1, 2024
c49c84e
Merge pull request #7 from elliotsayes/dev
elliotsayes Feb 1, 2024
69f5a50
Bug
elliotsayes Feb 1, 2024
986b5a9
Merge branch 'dev'
elliotsayes Feb 1, 2024
5c14cd9
dead code
elliotsayes Feb 1, 2024
6baafc2
Distributions schema
elliotsayes Feb 1, 2024
ac04fe0
Fetching
elliotsayes Feb 1, 2024
283567f
Distribution details
elliotsayes Feb 1, 2024
7377ebd
Add piggybank for distributions
elliotsayes Feb 1, 2024
dc4f637
Format
elliotsayes Feb 1, 2024
973d89f
Add balance
elliotsayes Feb 1, 2024
569f449
Styling
elliotsayes Feb 1, 2024
6953ed5
Revert "dead code"
elliotsayes Feb 1, 2024
dc34327
Redesign network info
elliotsayes Feb 2, 2024
9da4e9d
Add additional columns!
elliotsayes Feb 2, 2024
1d4d3a4
Shorten
elliotsayes Feb 2, 2024
64fc361
Aesthetics
elliotsayes Feb 2, 2024
cd6efbc
Disable urlDerivedNetwork
elliotsayes Feb 2, 2024
698cde1
Refactor visibility state
elliotsayes Feb 2, 2024
604adea
Fix gateway rating
elliotsayes Feb 2, 2024
9188503
use ar-io for tests
elliotsayes Feb 5, 2024
afe14ca
delet dead code
elliotsayes Feb 5, 2024
48351b3
Use NetworkInfo component with hover state on tap
elliotsayes Feb 6, 2024
172678b
center columns
elliotsayes Feb 6, 2024
077d71d
1dp for rating
elliotsayes Feb 6, 2024
665c0c4
Update schema.ts
elliotsayes Feb 9, 2024
6b27793
Update schema.ts
elliotsayes Feb 9, 2024
d1ac702
enum
elliotsayes Mar 7, 2024
77cf4af
Fix link to $IO token
elliotsayes Mar 7, 2024
d68ef62
Fix link
elliotsayes Mar 13, 2024
a6d4c0f
bun install
elliotsayes Mar 20, 2024
1668d9f
Add delegates to schema
elliotsayes Mar 21, 2024
b4540cd
Add to table
elliotsayes Mar 21, 2024
e3714cf
Scroll (always maximised)
elliotsayes Mar 21, 2024
ec44970
Tweak
elliotsayes Mar 21, 2024
2e0f08b
Consistency
elliotsayes Mar 21, 2024
5e050ec
Enable hiding the label (why not :p)
elliotsayes Mar 21, 2024
62288e4
Nicer rounding
elliotsayes Mar 21, 2024
7e3e979
Merge pull request #8 from elliotsayes/dev
elliotsayes Mar 21, 2024
9df690f
Update fixtures to fix tests
elliotsayes Mar 21, 2024
f56f2bf
Clearer commenting
elliotsayes Mar 21, 2024
40e6eda
Add delegate settings
elliotsayes Mar 21, 2024
02dbee3
Hide by default
elliotsayes Mar 21, 2024
2d0e994
rename
elliotsayes Mar 21, 2024
784bee2
Fix display
elliotsayes Mar 21, 2024
afc1c20
Strikethrough in the case where disabled but nonzero proportion
elliotsayes Mar 21, 2024
b091262
Merge pull request #9 from elliotsayes/dev
elliotsayes Mar 21, 2024
05de78f
divide $io balance by 1M
elliotsayes Mar 21, 2024
7bdd0b2
Delegate heading w/ count
elliotsayes Mar 21, 2024
0fcf140
Merge pull request #10 from elliotsayes/dev
elliotsayes Mar 21, 2024
86a7bf6
Use mIoToIo
elliotsayes Mar 22, 2024
d680376
Use correct portion
elliotsayes Mar 22, 2024
d2cd8cc
Add delegate count column (hidden)
elliotsayes Mar 22, 2024
1b2a62c
Merge pull request #11 from elliotsayes/dev
elliotsayes Mar 22, 2024
2d0bf7a
Nicer garloader handling
elliotsayes Mar 22, 2024
0695fc3
2024
elliotsayes Mar 22, 2024
b10f08f
Merge pull request #12 from elliotsayes/dev
elliotsayes Mar 22, 2024
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
Binary file modified bun.lockb
Binary file not shown.
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,15 @@
"@radix-ui/react-accordion": "^1.1.2",
"@radix-ui/react-dialog": "^1.0.4",
"@radix-ui/react-dropdown-menu": "^2.0.5",
"@radix-ui/react-hover-card": "^1.0.7",
"@radix-ui/react-scroll-area": "^1.0.4",
"@radix-ui/react-select": "^2.0.0",
"@radix-ui/react-slot": "^1.0.2",
"@radix-ui/react-toast": "^1.1.5",
"@radix-ui/react-tooltip": "^1.0.7",
"@rehooks/local-storage": "^2.4.5",
"@tanstack/react-query": "^5.8.4",
"@tanstack/react-router": "0.0.1-beta.185",
"@tanstack/react-router": "^1.4.2",
"@tanstack/react-table": "^8.9.8",
"arweave-graphql": "^0.0.5",
"base64-arraybuffer": "^1.0.2",
Expand Down
4 changes: 2 additions & 2 deletions src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { QueryClient, QueryClientProvider } from '@tanstack/react-query'
import { QueryClientProvider } from '@tanstack/react-query'
import { RouterProvider } from '@tanstack/react-router'
import { queryClient } from './lib/query'
import { router } from './routes'

const queryClient = new QueryClient()

function App() {
return (
Expand Down
29 changes: 20 additions & 9 deletions src/Root.tsx
Original file line number Diff line number Diff line change
@@ -1,36 +1,47 @@
import { Outlet } from "@tanstack/react-router"
import { Link, Outlet } from "@tanstack/react-router"
import {
Card,
CardContent,
CardHeader,
CardTitle,
} from "@/components/ui/card"
import arioLogo from './assets/ar.io-white.png'
import { Toaster } from "./components/ui/toaster"
import { NetworkInfo } from "./components/NetworkInfo"
import { useNetwork } from "./hooks/useNetwork"

export const Root = () => {
const { network } = useNetwork();

return (
<>
<div className="max-h-[100vh] px-2 md:px-8 lg:px-16 py-4">
<Card>
<div>
<CardHeader>
<CardTitle className='flex flex-col md:flex-row gap-2 px-2 items-center md:items-baseline'>
<a
href='/'
<CardTitle className='flex flex-col md:flex-row px-2 items-center md:items-baseline'>
<Link
to={'/'}
className='flex items-center px-1 flex-col md:flex-row gap-2 md:gap-4'
>
<img src={arioLogo} width='100rem' />
<span className='font-ario text-3xl'>
Gateway Explorer
</span>
</a>
</Link>
{
network === "testnet" &&
<NetworkInfo nextNetwork="devnet" />
}
{
network == "devnet" &&
<NetworkInfo nextNetwork="testnet" />
}
</CardTitle>
{/* <CardDescription>List of all Gateways</CardDescription> */}
</CardHeader>
<CardContent>
<Outlet />
</CardContent>
</Card>
</div>
<div className='flex flex-col text-center text-muted-foreground gap-1 pt-2'>
<div className='flex flex-row flex-grow justify-center gap-2'>
<div className='flex'>
Expand Down Expand Up @@ -58,7 +69,7 @@ export const Root = () => {
</div>
</div>
<div>
©2023 ar.io
©2024 ar.io
</div>
{/* <div className={`${isDetailsSheetOpen ? 'h-[calc(50vh+3em)]' : 'h-[2em]'} transition-all duration-200`} /> */}
<div className={`h-[2em] transition-all duration-200`} />
Expand Down
3 changes: 1 addition & 2 deletions src/components/ColumnSelection.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import { DropdownMenuTrigger } from "@radix-ui/react-dropdown-menu"
import { Eye } from "lucide-react"
import { Table } from "@tanstack/react-table"

import { Button } from "@/components/ui/button"
import {
DropdownMenu,
DropdownMenuTrigger,
DropdownMenuCheckboxItem,
DropdownMenuContent,
DropdownMenuLabel,
Expand Down
6 changes: 3 additions & 3 deletions src/components/CurrentReport.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import { useQuery } from "@tanstack/react-query"
import { downloadCurrentReportInfoFromGateway } from "@/lib/observer/downloadObservation"
import { ReportSummaryTable } from "./ReportSummaryTable";
import { garQuery } from "@/lib/query";
import { useGarData } from "@/hooks/useGarData";

interface Props {
host: string;
Expand All @@ -12,9 +12,9 @@ export const CurrentReport = ({ host }: Props) => {
const {
data: garData,
isError: isGarError,
} = useQuery(garQuery);
} = useGarData();

const observer = garData?.find((item) => item.settings.fqdn === host)
const observer = garData?.find((item) => item.fqdnKey === host)
const observerNotFound = (garData !== undefined) && (observer === undefined);

const {
Expand Down
60 changes: 60 additions & 0 deletions src/components/DelegateSummary.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
import { z } from "zod"
import { zGatewayAddressRegistryItem } from "@/types";
import { useMemo } from "react";
import { Table, TableBody, TableCell, TableHeader, TableRow } from "./ui/table";
import { ScrollArea } from "./ui/scroll-area";
import { mIoToIo } from "@/lib/utils";

interface Props {
delegates: z.infer<typeof zGatewayAddressRegistryItem>['delegates']
}

const DelegateSummary = ({delegates}: Props) => {
const sortedDelegates = useMemo(() => {
return Object.entries(delegates).sort((a, b) => {
return b[1].delegatedStake - a[1].delegatedStake
})
}, [delegates]);

return (
<div>
<ScrollArea className="h-60 w-full pr-4" type="always">
<p className="text-lg">Delegates ({sortedDelegates.length})</p>
<Table>
<TableHeader>
<TableCell className="text-md">
Address
</TableCell>
<TableCell className="text-md text-right">
Stake
</TableCell>
</TableHeader>
<TableBody>
{sortedDelegates.map(([delegateId, delegateInfo]) => (
<TableRow key={delegateId} className="py-2">
<TableCell className="py-1">
<a
href={`https://viewblock.io/arweave/address/${delegateId}`}
target="_blank"
className="text-secondary-foreground/80 underline"
>
<code className="text-secondary-foreground/80">
{delegateId.slice(0, 5)}...{delegateId.slice(delegateId.length-5)}
</code>
</a>
</TableCell>
<TableCell className="text-right py-2">
<code className="text-secondary-foreground/80">
{mIoToIo(delegateInfo.delegatedStake).toFixed(2)}
</code>
</TableCell>
</TableRow>
))}
</TableBody>
</Table>
</ScrollArea>
</div>
)
}

export { DelegateSummary }
41 changes: 41 additions & 0 deletions src/components/DelegatedStakeHoverCard.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import { HoverCard, HoverCardContent, HoverCardTrigger } from "./ui/hover-card"
import { z } from "zod"
import { useState } from "react"
import { zGatewayAddressRegistryItem } from "@/types"
import { DelegateSummary } from "./DelegateSummary"
import { mIoToIo } from "@/lib/utils"

interface Props {
totalDelegatedStake: z.infer<typeof zGatewayAddressRegistryItem>['totalDelegatedStake']
delegates: z.infer<typeof zGatewayAddressRegistryItem>['delegates']
}

const DelegatedStakeHoverCard = ({totalDelegatedStake, delegates}: Props) => {
const [open, setOpen] = useState(false);

return (
<HoverCard
open={open}
onOpenChange={(o) => setOpen(o)}
>
<HoverCardTrigger
onClick={(e) => {
e.stopPropagation();
setOpen(true);
}}
>
<span className="line-clamp-1 underline cursor-pointer text-center">
{mIoToIo(totalDelegatedStake).toFixed(2)}
</span>
</HoverCardTrigger>
<HoverCardContent
onClick={(e) => e.stopPropagation()}
className="w-full"
>
<DelegateSummary delegates={delegates} />
</HoverCardContent>
</HoverCard>
)
}

export default DelegatedStakeHoverCard
44 changes: 44 additions & 0 deletions src/components/DistributionDetails.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import { useNetwork } from "@/hooks/useNetwork";
import { fetchDistributions } from "@/lib/distribution/fetchDistributions";
import { useQuery } from "@tanstack/react-query";
import { fetchBalanceContract } from "@/lib/balance/fetchBalance";
import { networkConfigMap } from "@/lib/networks";
import { capitalizeWord, mIoToIo } from "@/lib/utils";
import { DISTRIBUTION_PROPORTION_PER_EPOCH } from "@/lib/distribution/distribution";

const DistributionDetails = () => {
const { network } = useNetwork();
const { data: distributionsData } = useQuery({
queryKey: ['distributions', network],
queryFn: () => fetchDistributions(network),
});

const { data: balanceContractData } = useQuery({
queryKey: ['balance', network],
queryFn: () => fetchBalanceContract(network),
})

if (distributionsData === undefined || balanceContractData === undefined)
return <div>Loading...</div>;

return (
<div>
<p className="text-lg pb-0.5">
<a href={`https://viewblock.io/arweave/tx/${networkConfigMap[network].contractTxIds.garCache}`} target="_blank" className="underline cursor-pointer"><span className=" ">{capitalizeWord(network)}</span> contract</a>&nbsp;
<span className="text-sm text-secondary-foreground/80">
(block <code className="text-xs">{distributionsData.epochZeroStartHeight}</code>+)
</span>
</p>
<p className="text-secondary-foreground/80">Epoch #{distributionsData.epochPeriod}&nbsp;
<span className="text-sm">
(block <code className="text-xs">{distributionsData.epochStartHeight}</code>–<code className="text-xs">{distributionsData.epochEndHeight}</code>)
</span>
</p>
<div className="text-secondary-foreground/80">
<p className="text-sm">Distributing ~{mIoToIo(balanceContractData * DISTRIBUTION_PROPORTION_PER_EPOCH).toFixed(2)} <a href="https://docs.ar.io/token/" className="underline cursor-pointer">$IO</a> at block <code className="text-xs">{distributionsData.nextDistributionHeight}</code></p>
</div>
</div>
)
}

export { DistributionDetails }
13 changes: 10 additions & 3 deletions src/components/GarLoader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,16 @@ import { Sheet, SheetContent, SheetHeader, SheetTitle } from './ui/sheet';
import GatewayDetails from './GatewayDetails';
import { z } from 'zod';
import { zGatewayAddressRegistryItem } from '@/types';
import { garQuery } from '@/lib/query';
import { useGarData } from '@/hooks/useGarData';

const GarLoader = () => {
const {
data,
isLoading,
isFetching,
error,
} = useQuery(garQuery);
refetch,
} = useGarData();

const {
data: procData,
Expand Down Expand Up @@ -47,7 +48,13 @@ const GarLoader = () => {

const [isDetailsSheetOpen, setIsDetailsSheetOpen] = useState(false)

if (error) return <div>Error: {JSON.stringify(error)}</div>
if (error) return (
<div>
<p>Error: {JSON.stringify(error)}</p>
<button onClick={() => refetch()}>Retry</button>
</div>
)


return (
<>
Expand Down
8 changes: 3 additions & 5 deletions src/components/GarTable.stories.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,10 @@ export const MultipleItems: Story = {
},
};

import GatewayAddressRegistryCache from "../fixtures/GatewayAddressRegistryCache.json";
import { zGatewayAddressRegistryCache } from "@/types";
import IncentiveContract from "../fixtures/IncentiveContract.json";
import { extractGarItems } from "@/lib/convert";
const garCache = zGatewayAddressRegistryCache.parse(
GatewayAddressRegistryCache
);
import { incentiveContractSchema } from "@/lib/incentive/schema";
const garCache = incentiveContractSchema.parse(IncentiveContract);
const items = extractGarItems(garCache);
export const ManyItems: Story = {
args: {
Expand Down
Loading