Skip to content

Commit

Permalink
Feature: add chain_id to head response
Browse files Browse the repository at this point in the history
  • Loading branch information
aopoltorzhicky committed May 28, 2024
1 parent 6de65c6 commit e421590
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 3 deletions.
8 changes: 5 additions & 3 deletions cmd/api/docs/docs.go

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

5 changes: 5 additions & 0 deletions cmd/api/docs/swagger.json

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

4 changes: 4 additions & 0 deletions cmd/api/docs/swagger.yaml

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

2 changes: 2 additions & 0 deletions cmd/api/handler/responses/state.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import (
type State struct {
Id uint64 `example:"321" format:"int64" json:"id" swaggertype:"integer"`
Name string `example:"indexer" format:"string" json:"name" swaggertype:"string"`
ChainID string `example:"astria-dusk-7" format:"string" json:"chain_id" swaggertype:"string"`
LastHeight pkgTypes.Level `example:"100" format:"int64" json:"last_height" swaggertype:"integer"`
LastHash string `example:"652452A670018D629CC116E510BA88C1CABE061336661B1F3D206D248BD558AF" format:"string" json:"hash" swaggertype:"string"`
LastTime time.Time `example:"2023-07-04T03:10:57+00:00" format:"date-time" json:"last_time" swaggertype:"string"`
Expand All @@ -30,6 +31,7 @@ func NewState(state storage.State) State {
return State{
Id: state.Id,
Name: state.Name,
ChainID: state.ChainId,
LastHeight: state.LastHeight,
LastHash: hex.EncodeToString(state.LastHash),
LastTime: state.LastTime,
Expand Down
2 changes: 2 additions & 0 deletions cmd/api/handler/state_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ var (
testState = storage.State{
Id: 1,
Name: "test",
ChainId: "chain-id",
LastHeight: 100,
LastTime: testTime,
TotalTx: 1234,
Expand Down Expand Up @@ -83,6 +84,7 @@ func (s *StateTestSuite) TestHead() {
s.Require().NoError(err)
s.Require().EqualValues(1, state.Id)
s.Require().EqualValues("test", state.Name)
s.Require().EqualValues("chain-id", state.ChainID)
s.Require().EqualValues(100, state.LastHeight)
s.Require().EqualValues(1234, state.TotalTx)
s.Require().EqualValues(123, state.TotalAccounts)
Expand Down

0 comments on commit e421590

Please sign in to comment.