Skip to content

Commit

Permalink
Fix API: tx for genesis block (#242)
Browse files Browse the repository at this point in the history
  • Loading branch information
aopoltorzhicky authored Jul 8, 2024
1 parent bc0949f commit 3c7be8a
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 9 deletions.
4 changes: 2 additions & 2 deletions cmd/api/handler/requests.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ type txListRequest struct {
Limit int `query:"limit" validate:"omitempty,min=1,max=100"`
Offset int `query:"offset" validate:"omitempty,min=0"`
Sort string `query:"sort" validate:"omitempty,oneof=asc desc"`
Height uint64 `query:"height" validate:"omitempty,min=1"`
Height *uint64 `query:"height" validate:"omitempty,min=0"`
Status StringArray `query:"status" validate:"omitempty,dive,status"`
MsgType StringArray `query:"msg_type" validate:"omitempty,dive,msg_type"`
ExcludedMsgType StringArray `query:"excluded_msg_type" validate:"omitempty,dive,msg_type"`
Expand Down Expand Up @@ -92,7 +92,7 @@ type addressTxRequest struct {
Limit uint64 `query:"limit" validate:"omitempty,min=1,max=100"`
Offset uint64 `query:"offset" validate:"omitempty,min=0"`
Sort string `query:"sort" validate:"omitempty,oneof=asc desc"`
Height uint64 `query:"height" validate:"omitempty,min=1"`
Height *uint64 `query:"height" validate:"omitempty,min=0"`
Status StringArray `query:"status" validate:"omitempty,dive,status"`
MsgType StringArray `query:"msg_type" validate:"omitempty,dive,msg_type"`

Expand Down
4 changes: 2 additions & 2 deletions cmd/api/handler/tx_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,7 @@ func (s *TxTestSuite) TestListHeight() {
Offset: 0,
Sort: pgSort("desc"),
Status: []string{"success"},
Height: 1000,
Height: testsuite.Ptr(uint64(1000)),
MessageTypes: types.NewMsgTypeBitMask(types.MsgSend),
ExcludedMessageTypes: types.NewMsgTypeBitMask(),
WithMessages: true,
Expand Down Expand Up @@ -366,7 +366,7 @@ func (s *TxTestSuite) TestListExcludedMessages() {
Offset: 0,
Sort: pgSort("desc"),
Status: []string{"success"},
Height: 1000,
Height: testsuite.Ptr(uint64(1000)),
ExcludedMessageTypes: types.NewMsgTypeBitMask(types.MsgSend),
MessageTypes: types.NewMsgTypeBitMask(),
WithMessages: true,
Expand Down
4 changes: 2 additions & 2 deletions internal/storage/postgres/scopes.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ func txFilter(query *bun.SelectQuery, fltrs storage.TxFilter) *bun.SelectQuery {
return sq
})
}
if fltrs.Height > 0 {
query = query.Where("height = ?", fltrs.Height)
if fltrs.Height != nil {
query = query.Where("height = ?", *fltrs.Height)
}

if !fltrs.TimeFrom.IsZero() {
Expand Down
5 changes: 3 additions & 2 deletions internal/storage/postgres/tx_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (

"github.com/celenium-io/celestia-indexer/internal/storage"
"github.com/celenium-io/celestia-indexer/internal/storage/types"
testsuite "github.com/celenium-io/celestia-indexer/internal/test_suite"
sdk "github.com/dipdup-net/indexer-sdk/pkg/storage"
)

Expand Down Expand Up @@ -94,7 +95,7 @@ func (s *StorageTestSuite) TestTxFilterExcludedMessageTypes() {
Limit: 10,
Offset: 0,
ExcludedMessageTypes: types.NewMsgTypeBitMask(types.MsgUnjail),
Height: 1000,
Height: testsuite.Ptr(uint64(1000)),
})
s.Require().NoError(err)
s.Require().Len(txs, 1)
Expand Down Expand Up @@ -158,7 +159,7 @@ func (s *StorageTestSuite) TestTxFilterHeight() {
Limit: 10,
Offset: 0,
Status: []string{string(types.StatusSuccess)},
Height: 1000,
Height: testsuite.Ptr(uint64(1000)),
})
s.Require().NoError(err)
s.Require().Len(txs, 2)
Expand Down
2 changes: 1 addition & 1 deletion internal/storage/tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ type TxFilter struct {
Status []string
MessageTypes types.MsgTypeBits
ExcludedMessageTypes types.MsgTypeBits
Height uint64
Height *uint64
TimeFrom time.Time
TimeTo time.Time
WithMessages bool
Expand Down

0 comments on commit 3c7be8a

Please sign in to comment.