Skip to content

Commit

Permalink
feat: localstatequery rest endpoints (part 1) (#134)
Browse files Browse the repository at this point in the history
Signed-off-by: Chris Gianelloni <[email protected]>
  • Loading branch information
wolf31o2 authored Mar 24, 2024
1 parent 136036e commit 0286c60
Show file tree
Hide file tree
Showing 5 changed files with 531 additions and 2 deletions.
120 changes: 120 additions & 0 deletions docs/docs.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

120 changes: 120 additions & 0 deletions docs/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,81 @@
"host": "localhost",
"basePath": "/api",
"paths": {
"/localstatequery/current-era": {
"get": {
"produces": [
"application/json"
],
"tags": [
"localstatequery"
],
"summary": "Query Current Era",
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/api.responseLocalStateQueryCurrentEra"
}
},
"500": {
"description": "Internal Server Error",
"schema": {
"$ref": "#/definitions/api.responseApiError"
}
}
}
}
},
"/localstatequery/system-start": {
"get": {
"produces": [
"application/json"
],
"tags": [
"localstatequery"
],
"summary": "Query System Start",
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/api.responseLocalStateQuerySystemStart"
}
},
"500": {
"description": "Internal Server Error",
"schema": {
"$ref": "#/definitions/api.responseApiError"
}
}
}
}
},
"/localstatequery/tip": {
"get": {
"produces": [
"application/json"
],
"tags": [
"localstatequery"
],
"summary": "Query Chain Tip",
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/api.responseLocalStateQueryTip"
}
},
"500": {
"description": "Internal Server Error",
"schema": {
"$ref": "#/definitions/api.responseApiError"
}
}
}
}
},
"/localtxmonitor/has_tx/{tx_hash}": {
"get": {
"consumes": [
Expand Down Expand Up @@ -165,6 +240,51 @@
}
}
},
"api.responseLocalStateQueryCurrentEra": {
"type": "object",
"properties": {
"id": {
"type": "integer"
},
"name": {
"type": "string"
}
}
},
"api.responseLocalStateQuerySystemStart": {
"type": "object",
"properties": {
"day": {
"type": "integer"
},
"picoseconds": {
"type": "integer"
},
"year": {
"type": "integer"
}
}
},
"api.responseLocalStateQueryTip": {
"type": "object",
"properties": {
"block_no": {
"type": "integer"
},
"epoch_no": {
"type": "integer"
},
"era": {
"type": "string"
},
"hash": {
"type": "string"
},
"slot_no": {
"type": "integer"
}
}
},
"api.responseLocalTxMonitorHasTx": {
"type": "object",
"properties": {
Expand Down
77 changes: 77 additions & 0 deletions docs/swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,35 @@ definitions:
example: error message
type: string
type: object
api.responseLocalStateQueryCurrentEra:
properties:
id:
type: integer
name:
type: string
type: object
api.responseLocalStateQuerySystemStart:
properties:
day:
type: integer
picoseconds:
type: integer
year:
type: integer
type: object
api.responseLocalStateQueryTip:
properties:
block_no:
type: integer
epoch_no:
type: integer
era:
type: string
hash:
type: string
slot_no:
type: integer
type: object
api.responseLocalTxMonitorHasTx:
properties:
has_tx:
Expand Down Expand Up @@ -44,6 +73,54 @@ info:
title: cardano-node-api
version: "1.0"
paths:
/localstatequery/current-era:
get:
produces:
- application/json
responses:
"200":
description: OK
schema:
$ref: '#/definitions/api.responseLocalStateQueryCurrentEra'
"500":
description: Internal Server Error
schema:
$ref: '#/definitions/api.responseApiError'
summary: Query Current Era
tags:
- localstatequery
/localstatequery/system-start:
get:
produces:
- application/json
responses:
"200":
description: OK
schema:
$ref: '#/definitions/api.responseLocalStateQuerySystemStart'
"500":
description: Internal Server Error
schema:
$ref: '#/definitions/api.responseApiError'
summary: Query System Start
tags:
- localstatequery
/localstatequery/tip:
get:
produces:
- application/json
responses:
"200":
description: OK
schema:
$ref: '#/definitions/api.responseLocalStateQueryTip'
"500":
description: Internal Server Error
schema:
$ref: '#/definitions/api.responseApiError'
summary: Query Chain Tip
tags:
- localstatequery
/localtxmonitor/has_tx/{tx_hash}:
get:
consumes:
Expand Down
4 changes: 2 additions & 2 deletions internal/api/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,10 @@ import (
// @host localhost
// @Schemes http
// @BasePath /api

// @contact.name Blink Labs
// @contact.url https://blinklabs.io
// @contact.email [email protected]

//
// @license.name Apache 2.0
// @license.url http://www.apache.org/licenses/LICENSE-2.0.html
func Start(cfg *config.Config) error {
Expand Down Expand Up @@ -75,6 +74,7 @@ func Start(cfg *config.Config) error {

// Configure API routes
apiGroup := router.Group("/api")
configureLocalStateQueryRoutes(apiGroup)
configureLocalTxMonitorRoutes(apiGroup)
configureLocalTxSubmissionRoutes(apiGroup)

Expand Down
Loading

0 comments on commit 0286c60

Please sign in to comment.