Skip to content

Commit

Permalink
add /network/status api
Browse files Browse the repository at this point in the history
  • Loading branch information
romever committed Sep 30, 2024
1 parent cc4e1d7 commit a16c5e2
Show file tree
Hide file tree
Showing 11 changed files with 416 additions and 24 deletions.
242 changes: 241 additions & 1 deletion api/api.json
Original file line number Diff line number Diff line change
Expand Up @@ -556,6 +556,56 @@
]
}
},
"/v2/governance/votes": {
"get": {
"operationId": "GovernanceVotesHandler",
"responses": {
"200": {
"description": "A successful response.",
"schema": {
"$ref": "#/definitions/GovernanceVotesResponse"
}
}
},
"parameters": [
{
"name": "proposalId",
"in": "query",
"required": false,
"type": "integer",
"format": "int64"
},
{
"name": "validator",
"in": "query",
"required": false,
"type": "string"
},
{
"name": "page",
"in": "query",
"required": true,
"type": "integer",
"format": "int64",
"default": "1"
},
{
"name": "size",
"in": "query",
"required": true,
"type": "integer",
"format": "int64",
"default": "5"
}
],
"tags": [
"governance"
],
"consumes": [
"multipart/form-data"
]
}
},
"/v2/health": {
"get": {
"operationId": "HealthHandler",
Expand Down Expand Up @@ -988,6 +1038,33 @@
"multipart/form-data"
]
}
},
"/v2/validator/signstats": {
"get": {
"operationId": "ValidatorSignStatsHandler",
"responses": {
"200": {
"description": "A successful response.",
"schema": {
"$ref": "#/definitions/ValidatorSignStatsResponse"
}
}
},
"parameters": [
{
"name": "address",
"in": "query",
"required": true,
"type": "string"
}
],
"tags": [
"validator"
],
"consumes": [
"multipart/form-data"
]
}
}
},
"definitions": {
Expand Down Expand Up @@ -1463,7 +1540,7 @@
"burn": {
"type": "object"
},
"Escrow": {
"escrow": {
"type": "object"
},
"allowanceChange": {
Expand Down Expand Up @@ -2186,6 +2263,64 @@
"votes"
]
},
"GovernanceVotesRequest": {
"type": "object",
"properties": {
"proposalId": {
"type": "integer",
"format": "int64"
},
"validator": {
"type": "string"
},
"page": {
"type": "integer",
"format": "int64",
"default": "1"
},
"size": {
"type": "integer",
"format": "int64",
"default": "5"
}
},
"title": "GovernanceVotesRequest",
"required": [
"page",
"size"
]
},
"GovernanceVotesResponse": {
"type": "object",
"properties": {
"list": {
"type": "array",
"items": {
"$ref": "#/definitions/ProposalVote"
}
},
"page": {
"type": "integer",
"format": "int64"
},
"size": {
"type": "integer",
"format": "int64"
},
"maxPage": {
"type": "integer",
"format": "int64"
},
"totalSize": {
"type": "integer",
"format": "int64"
}
},
"title": "GovernanceVotesResponse",
"required": [
"list"
]
},
"HealthRequest": {
"type": "object",
"title": "HealthRequest"
Expand Down Expand Up @@ -2352,6 +2487,13 @@
"ProposalVote": {
"type": "object",
"properties": {
"proposalId": {
"type": "integer",
"format": "int64"
},
"title": {
"type": "string"
},
"name": {
"type": "string"
},
Expand All @@ -2374,6 +2516,8 @@
},
"title": "ProposalVote",
"required": [
"proposalId",
"title",
"name",
"icon",
"address",
Expand Down Expand Up @@ -2760,6 +2904,9 @@
"RuntimeTransactionEvmTx": {
"type": "object",
"properties": {
"hash": {
"type": "string"
},
"from": {
"type": "string"
},
Expand Down Expand Up @@ -2787,6 +2934,7 @@
},
"title": "RuntimeTransactionEvmTx",
"required": [
"hash",
"from",
"to",
"nonce",
Expand Down Expand Up @@ -3176,6 +3324,12 @@
"escrowAmountStatus": {
"$ref": "#/definitions/EscrowStatus"
},
"runtimes": {
"type": "array",
"items": {
"$ref": "#/definitions/ValidatorRuntime"
}
},
"status": {
"type": "boolean",
"format": "boolean"
Expand Down Expand Up @@ -3212,6 +3366,7 @@
"bound",
"rates",
"bounds",
"runtimes",
"status"
]
},
Expand Down Expand Up @@ -3341,6 +3496,12 @@
"escrowAmountStatus": {
"$ref": "#/definitions/EscrowStatus"
},
"runtimes": {
"type": "array",
"items": {
"$ref": "#/definitions/ValidatorRuntime"
}
},
"status": {
"type": "boolean",
"format": "boolean"
Expand Down Expand Up @@ -3395,6 +3556,85 @@
"inactive",
"delegators"
]
},
"ValidatorRuntime": {
"type": "object",
"properties": {
"name": {
"type": "string"
},
"id": {
"type": "string"
},
"online": {
"type": "boolean",
"format": "boolean"
}
},
"title": "ValidatorRuntime",
"required": [
"name",
"id",
"online"
]
},
"ValidatorSignStatsInfo": {
"type": "object",
"properties": {
"dateTime": {
"type": "integer",
"format": "int64"
},
"expected": {
"type": "integer",
"format": "int64"
},
"actual": {
"type": "integer",
"format": "int64"
}
},
"title": "ValidatorSignStatsInfo",
"required": [
"dateTime",
"expected",
"actual"
]
},
"ValidatorSignStatsRequest": {
"type": "object",
"properties": {
"address": {
"type": "string"
}
},
"title": "ValidatorSignStatsRequest",
"required": [
"address"
]
},
"ValidatorSignStatsResponse": {
"type": "object",
"properties": {
"stats": {
"type": "array",
"items": {
"$ref": "#/definitions/ValidatorSignStatsInfo"
}
},
"time": {
"type": "array",
"items": {
"type": "integer",
"format": "int64"
}
}
},
"title": "ValidatorSignStatsResponse",
"required": [
"stats",
"time"
]
}
},
"securityDefinitions": {
Expand Down
25 changes: 25 additions & 0 deletions api/internal/handler/common/networkstatushandler.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package common

import (
"net/http"

"github.com/zeromicro/go-zero/rest/httpx"
"oasisscan-backend/api/internal/logic/common"
"oasisscan-backend/api/internal/response"
"oasisscan-backend/api/internal/svc"
"oasisscan-backend/api/internal/types"
)

func NetworkStatusHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
var req types.NetworkStatusRequest
if err := httpx.Parse(r, &req); err != nil {
httpx.Error(w, err)
return
}

l := common.NewNetworkStatusLogic(r.Context(), svcCtx)
resp, err := l.NetworkStatus(&req)
response.Response(w, resp, err)
}
}
Loading

0 comments on commit a16c5e2

Please sign in to comment.