-
Notifications
You must be signed in to change notification settings - Fork 40
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
[Gateway] health check on gateway UI/frontend #1729
Merged
Merged
Changes from 20 commits
Commits
Show all changes
22 commits
Select commit
Hold shift + click to select a range
92d7197
wip: add an endpoint for health check
Jennievon 9896ed7
feat: add endpoint for health check
Jennievon e8beeee
add ui for health check on Tenscan
Jennievon e64a7c5
Merge branch 'main' of https://github.com/ten-protocol/go-ten into je…
Jennievon 2394bbf
Merge branch 'main' of https://github.com/ten-protocol/go-ten into je…
Jennievon e71c46e
Merge branch 'jennifer/2624-add-a-health-indicator-for-testnet-on-ten…
Jennievon ba87900
Refactor health status method names
Jennievon 6386d90
Merge branch 'main' of https://github.com/ten-protocol/go-ten into je…
Jennievon d87f71a
Refactor health check function calls
Jennievon 1e681f3
Merge branch 'jennifer/2624-add-a-health-indicator-for-testnet-on-ten…
Jennievon 566d935
feat: endpoint to fetch testnet health status
Jennievon be80a1b
wip: testnet health check status
Jennievon e2e35c6
Merge branch 'main' of https://github.com/ten-protocol/go-ten into je…
Jennievon 92bc4b7
Merge branch 'main' of https://github.com/ten-protocol/go-ten into je…
Jennievon 7f5cd34
create rpcClient and tenClinet to call health
zkokelj 6084191
Merge branch 'jennifer/health-check-on-gateway' of https://github.com…
Jennievon 2f86d09
feat: update health status
Jennievon 2303441
feat: format health response
Jennievon d470675
Merge branch 'jennifer/health-check-on-gateway' of https://github.com…
Jennievon 11dc8fd
Merge branch 'main' of https://github.com/ten-protocol/go-ten into je…
Jennievon b7da853
Update getHealthStatus API route
Jennievon aa86490
fix useEffect warning msgs
Jennievon 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,14 @@ | ||
import { ResponseDataInterface } from "@/types/interfaces"; | ||
import { httpRequest } from "."; | ||
import { pathToUrl } from "@/routes/router"; | ||
import { apiRoutes } from "@/routes"; | ||
|
||
export const fetchTestnetStatus = async (): Promise< | ||
ResponseDataInterface<any> | ||
> => { | ||
return await httpRequest<ResponseDataInterface<any>>({ | ||
method: "post", | ||
url: pathToUrl(apiRoutes.getHealthStatus), | ||
data: { jsonrpc: "2.0", method: "obscuro_health", params: [], id: 1 }, | ||
}); | ||
}; | ||
45 changes: 45 additions & 0 deletions
45
tools/walletextension/frontend/src/components/health-indicator.tsx
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,45 @@ | ||
import React, { useEffect } from "react"; | ||
import { Badge, badgeVariants } from "./ui/badge"; | ||
import useGatewayService from "@/services/useGatewayService"; | ||
import { Skeleton } from "./ui/skeleton"; | ||
|
||
const HealthIndicator = () => { | ||
const { getTestnetStatus } = useGatewayService(); | ||
const [loading, setLoading] = React.useState(false); | ||
const [status, setStatus] = React.useState<boolean>(); | ||
|
||
const testnetStatus = async () => { | ||
setLoading(true); | ||
try { | ||
const status = await getTestnetStatus(); | ||
return status; | ||
} catch (error) { | ||
console.error(error); | ||
} finally { | ||
setLoading(false); | ||
} | ||
}; | ||
|
||
useEffect(() => { | ||
testnetStatus().then((res) => setStatus(res?.result)); | ||
}, []); | ||
Jennievon marked this conversation as resolved.
Show resolved
Hide resolved
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ./src/components/health-indicator.tsx |
||
|
||
return ( | ||
<div className="flex items-center space-x-2 border rounded-lg p-2"> | ||
<h3 className="text-sm">Testnet Status: </h3> | ||
{loading ? ( | ||
<Skeleton className="h-4 w-10" /> | ||
) : ( | ||
<Badge | ||
variant={ | ||
(status ? "success" : "destructive") as keyof typeof badgeVariants | ||
} | ||
> | ||
{status ? "Live" : "Down"} | ||
</Badge> | ||
)} | ||
</div> | ||
); | ||
}; | ||
Jennievon marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
export default HealthIndicator; |
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
Oops, something went wrong.
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.
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.
The
fetchTestnetStatus
function is well-structured and uses thehttpRequest
function to make a POST request. The use ofasync/await
is consistent with modern asynchronous patterns in JavaScript. However, the use ofany
as a generic type forResponseDataInterface
should be avoided if a more specific type can be used to enhance type safety.Committable suggestion