Skip to content

Commit

Permalink
parse forHyperblock from block request too
Browse files Browse the repository at this point in the history
  • Loading branch information
sstanculeanu committed Jan 9, 2025
1 parent bda1e8e commit dd444df
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 6 deletions.
7 changes: 6 additions & 1 deletion api/groups/urlParams.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,12 @@ func parseBlockQueryOptions(c *gin.Context) (common.BlockQueryOptions, error) {
return common.BlockQueryOptions{}, err
}

options := common.BlockQueryOptions{WithTransactions: withTxs, WithLogs: withLogs}
forHyperblock, err := parseBoolUrlParam(c, common.UrlParameterForHyperblock)
if err != nil {
return common.BlockQueryOptions{}, err
}

options := common.BlockQueryOptions{WithTransactions: withTxs, WithLogs: withLogs, ForHyperblock: forHyperblock}
return options, nil
}

Expand Down
6 changes: 3 additions & 3 deletions api/groups/urlParams_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@ import (
)

func TestParseBlockQueryOptions(t *testing.T) {
options, err := parseBlockQueryOptions(createDummyGinContextWithQuery("withTxs=true&withLogs=true"))
options, err := parseBlockQueryOptions(createDummyGinContextWithQuery("withTxs=true&withLogs=true&forHyperblock=true"))
require.Nil(t, err)
require.Equal(t, common.BlockQueryOptions{WithTransactions: true, WithLogs: true}, options)
require.Equal(t, common.BlockQueryOptions{WithTransactions: true, WithLogs: true, ForHyperblock: true}, options)

options, err = parseBlockQueryOptions(createDummyGinContextWithQuery("withTxs=true"))
require.Nil(t, err)
require.Equal(t, common.BlockQueryOptions{WithTransactions: true, WithLogs: false}, options)
require.Equal(t, common.BlockQueryOptions{WithTransactions: true, WithLogs: false, ForHyperblock: false}, options)

options, err = parseBlockQueryOptions(createDummyGinContextWithQuery("withTxs=foobar"))
require.NotNil(t, err)
Expand Down
4 changes: 2 additions & 2 deletions cmd/proxy/config/swagger/openapi.json
Original file line number Diff line number Diff line change
Expand Up @@ -645,7 +645,7 @@
}
}
},
"/block/{shard}/by-nonce/{nonce}?withTxs=true": {
"/block/{shard}/by-nonce/{nonce}?withTxs=true&withLogs=true&forHyperblock=true": {
"get": {
"tags": [
"block"
Expand Down Expand Up @@ -725,7 +725,7 @@
}
}
},
"/block/{shard}/by-hash/{hash}?withTxs=true": {
"/block/{shard}/by-hash/{hash}?withTxs=true&withLogs=true&forHyperblock=true": {
"get": {
"tags": [
"block"
Expand Down

0 comments on commit dd444df

Please sign in to comment.