-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
feat: add relay queues to staff tools #2522
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Check warning
Code scanning / CodeQL
Potentially unsafe external link