-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add relay queues to staff tools (#2522)
- Loading branch information
Showing
6 changed files
with
215 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
import MetaTags from '@components/Common/MetaTags'; | ||
import useStaffMode from '@components/utils/hooks/useStaffMode'; | ||
import { Mixpanel } from '@lib/mixpanel'; | ||
import { t } from '@lingui/macro'; | ||
import { APP_NAME, POLYGONSCAN_URL } from 'data/constants'; | ||
import Errors from 'data/errors'; | ||
import { useRelayQueuesQuery } from 'lens'; | ||
import type { NextPage } from 'next'; | ||
import type { FC } from 'react'; | ||
import { useEffect } from 'react'; | ||
import Custom404 from 'src/pages/404'; | ||
import { PAGEVIEW } from 'src/tracking'; | ||
import { Card, GridItemEight, GridItemFour, GridLayout, Spinner } from 'ui'; | ||
|
||
import StaffToolsSidebar from './Sidebar'; | ||
|
||
interface RelayProps { | ||
address: string; | ||
queue: number; | ||
relayer: string; | ||
} | ||
|
||
export const Relay: FC<RelayProps> = ({ address, queue, relayer }) => { | ||
function getRelayerName(name: string): string { | ||
const words = name.split('_'); | ||
const capitalizedWords = words.map((word) => word.charAt(0).toUpperCase() + word.slice(1).toLowerCase()); | ||
|
||
return capitalizedWords.join(' '); | ||
} | ||
|
||
return ( | ||
<Card className="flex w-full flex-wrap items-center justify-between p-5" forceRounded> | ||
<div> | ||
<b>{getRelayerName(relayer)}</b> | ||
<div> | ||
<a className="text-sm" href={`${POLYGONSCAN_URL}/address/${address}`} target="_blank"> | ||
{address} | ||
</a> | ||
</div> | ||
</div> | ||
<div className="flex flex-col items-center"> | ||
<b className="text-xl">{queue}</b> | ||
<span className="lt-text-gray-500">Transactions</span> | ||
</div> | ||
</Card> | ||
); | ||
}; | ||
|
||
const RelayQueues: NextPage = () => { | ||
const { allowed } = useStaffMode(); | ||
|
||
useEffect(() => { | ||
Mixpanel.track(PAGEVIEW, { page: 'stafftools', subpage: 'relayqueues' }); | ||
}, []); | ||
|
||
const { data, loading, error } = useRelayQueuesQuery({ | ||
pollInterval: 5000 | ||
}); | ||
|
||
if (!allowed) { | ||
return <Custom404 />; | ||
} | ||
|
||
const sortedRelays = data?.relayQueues | ||
.map((relay) => ({ | ||
...relay, | ||
queue: relay.queue | ||
})) | ||
.sort((a, b) => b.queue - a.queue); | ||
|
||
return ( | ||
<GridLayout> | ||
<MetaTags title={t`Stafftools | Relay queues • ${APP_NAME}`} /> | ||
<GridItemFour> | ||
<StaffToolsSidebar /> | ||
</GridItemFour> | ||
<GridItemEight className="space-y-5"> | ||
<Card className="p-5"> | ||
{error ? ( | ||
<b className="text-red-500">{Errors.SomethingWentWrong}</b> | ||
) : loading ? ( | ||
<div className="flex justify-center"> | ||
<Spinner size="sm" /> | ||
</div> | ||
) : ( | ||
<section className="space-y-3"> | ||
<h1 className="mb-4 text-xl font-bold">Relay queues</h1> | ||
<div className="space-y-3"> | ||
{sortedRelays?.map(({ address, queue, relayer }) => ( | ||
<Relay key={address} address={address} queue={queue} relayer={relayer} /> | ||
))} | ||
</div> | ||
</section> | ||
)} | ||
</Card> | ||
</GridItemEight> | ||
</GridLayout> | ||
); | ||
}; | ||
|
||
export default RelayQueues; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import RelayQueues from '@components/StaffTools/RelayQueues'; | ||
|
||
export default RelayQueues; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
query RelayQueues { | ||
relayQueues { | ||
relayer | ||
address | ||
queue | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
bf7e06a
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
ui – ./apps/storybook
ui-lenster.vercel.app
lenster-ui.vercel.app
ui-git-main-lenster.vercel.app
ui.lenster.xyz
bf7e06a
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
web – ./apps/web
web-lenster.vercel.app
lenster.xyz
web-git-main-lenster.vercel.app
lenster.vercel.app
bf7e06a
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
prerender – ./apps/prerender
prerender-git-main-lenster.vercel.app
prerender-lenster.vercel.app
prerender.lenster.xyz