Fix endpoint last-txs to fit portal explorer requirements (#286)
This commit is contained in:
parent
c0a3ed2ea9
commit
fd51f0a819
|
@ -608,13 +608,13 @@ const docTemplate = `{
|
||||||
"parameters": [
|
"parameters": [
|
||||||
{
|
{
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"description": "Time Span, default: 1h, examples: 30m, 1h, 1d, 2w, 3mo, 1y, all.",
|
"description": "Time Span, default: 1d, supported values: [1d, 1w, 1mo]",
|
||||||
"name": "timeSpan",
|
"name": "timeSpan",
|
||||||
"in": "query"
|
"in": "query"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"description": "Sample Rate, default: 1m, examples: 30s, 1m, 1h, 1d, 2w, 3mo, 1y.",
|
"description": "Sample Rate, default: 1h, supported values: [1h, 1d]",
|
||||||
"name": "sampleRate",
|
"name": "sampleRate",
|
||||||
"in": "query"
|
"in": "query"
|
||||||
}
|
}
|
||||||
|
@ -2327,7 +2327,17 @@ const docTemplate = `{
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"transactions.ScorecardsResponse": {
|
"transactions.ScorecardsResponse": {
|
||||||
"type": "object"
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"24h_tx_count": {
|
||||||
|
"description": "Number of VAAs emitted in the last 24 hours (does not include Pyth messages).",
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"total_tx_count": {
|
||||||
|
"description": "Number of VAAs emitted since the creation of the network (does not include Pyth messages)",
|
||||||
|
"type": "string"
|
||||||
|
}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
"transactions.TransactionCountResult": {
|
"transactions.TransactionCountResult": {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
|
@ -2391,7 +2401,9 @@ const docTemplate = `{
|
||||||
28,
|
28,
|
||||||
29,
|
29,
|
||||||
30,
|
30,
|
||||||
3104
|
32,
|
||||||
|
3104,
|
||||||
|
10002
|
||||||
],
|
],
|
||||||
"x-enum-varnames": [
|
"x-enum-varnames": [
|
||||||
"ChainIDUnset",
|
"ChainIDUnset",
|
||||||
|
@ -2422,7 +2434,9 @@ const docTemplate = `{
|
||||||
"ChainIDXpla",
|
"ChainIDXpla",
|
||||||
"ChainIDBtc",
|
"ChainIDBtc",
|
||||||
"ChainIDBase",
|
"ChainIDBase",
|
||||||
"ChainIDWormchain"
|
"ChainIDSei",
|
||||||
|
"ChainIDWormchain",
|
||||||
|
"ChainIDSepolia"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"vaa.VaaDoc": {
|
"vaa.VaaDoc": {
|
||||||
|
|
|
@ -601,13 +601,13 @@
|
||||||
"parameters": [
|
"parameters": [
|
||||||
{
|
{
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"description": "Time Span, default: 1h, examples: 30m, 1h, 1d, 2w, 3mo, 1y, all.",
|
"description": "Time Span, default: 1d, supported values: [1d, 1w, 1mo]",
|
||||||
"name": "timeSpan",
|
"name": "timeSpan",
|
||||||
"in": "query"
|
"in": "query"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"description": "Sample Rate, default: 1m, examples: 30s, 1m, 1h, 1d, 2w, 3mo, 1y.",
|
"description": "Sample Rate, default: 1h, supported values: [1h, 1d]",
|
||||||
"name": "sampleRate",
|
"name": "sampleRate",
|
||||||
"in": "query"
|
"in": "query"
|
||||||
}
|
}
|
||||||
|
@ -2320,7 +2320,17 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"transactions.ScorecardsResponse": {
|
"transactions.ScorecardsResponse": {
|
||||||
"type": "object"
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"24h_tx_count": {
|
||||||
|
"description": "Number of VAAs emitted in the last 24 hours (does not include Pyth messages).",
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"total_tx_count": {
|
||||||
|
"description": "Number of VAAs emitted since the creation of the network (does not include Pyth messages)",
|
||||||
|
"type": "string"
|
||||||
|
}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
"transactions.TransactionCountResult": {
|
"transactions.TransactionCountResult": {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
|
@ -2384,7 +2394,9 @@
|
||||||
28,
|
28,
|
||||||
29,
|
29,
|
||||||
30,
|
30,
|
||||||
3104
|
32,
|
||||||
|
3104,
|
||||||
|
10002
|
||||||
],
|
],
|
||||||
"x-enum-varnames": [
|
"x-enum-varnames": [
|
||||||
"ChainIDUnset",
|
"ChainIDUnset",
|
||||||
|
@ -2415,7 +2427,9 @@
|
||||||
"ChainIDXpla",
|
"ChainIDXpla",
|
||||||
"ChainIDBtc",
|
"ChainIDBtc",
|
||||||
"ChainIDBase",
|
"ChainIDBase",
|
||||||
"ChainIDWormchain"
|
"ChainIDSei",
|
||||||
|
"ChainIDWormchain",
|
||||||
|
"ChainIDSepolia"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"vaa.VaaDoc": {
|
"vaa.VaaDoc": {
|
||||||
|
|
|
@ -483,6 +483,15 @@ definitions:
|
||||||
type: number
|
type: number
|
||||||
type: object
|
type: object
|
||||||
transactions.ScorecardsResponse:
|
transactions.ScorecardsResponse:
|
||||||
|
properties:
|
||||||
|
24h_tx_count:
|
||||||
|
description: Number of VAAs emitted in the last 24 hours (does not include
|
||||||
|
Pyth messages).
|
||||||
|
type: string
|
||||||
|
total_tx_count:
|
||||||
|
description: Number of VAAs emitted since the creation of the network (does
|
||||||
|
not include Pyth messages)
|
||||||
|
type: string
|
||||||
type: object
|
type: object
|
||||||
transactions.TransactionCountResult:
|
transactions.TransactionCountResult:
|
||||||
properties:
|
properties:
|
||||||
|
@ -534,7 +543,9 @@ definitions:
|
||||||
- 28
|
- 28
|
||||||
- 29
|
- 29
|
||||||
- 30
|
- 30
|
||||||
|
- 32
|
||||||
- 3104
|
- 3104
|
||||||
|
- 10002
|
||||||
type: integer
|
type: integer
|
||||||
x-enum-varnames:
|
x-enum-varnames:
|
||||||
- ChainIDUnset
|
- ChainIDUnset
|
||||||
|
@ -565,7 +576,9 @@ definitions:
|
||||||
- ChainIDXpla
|
- ChainIDXpla
|
||||||
- ChainIDBtc
|
- ChainIDBtc
|
||||||
- ChainIDBase
|
- ChainIDBase
|
||||||
|
- ChainIDSei
|
||||||
- ChainIDWormchain
|
- ChainIDWormchain
|
||||||
|
- ChainIDSepolia
|
||||||
vaa.VaaDoc:
|
vaa.VaaDoc:
|
||||||
properties:
|
properties:
|
||||||
appId:
|
appId:
|
||||||
|
@ -1009,13 +1022,11 @@ paths:
|
||||||
and sample rate.
|
and sample rate.
|
||||||
operationId: get-last-transactions
|
operationId: get-last-transactions
|
||||||
parameters:
|
parameters:
|
||||||
- description: 'Time Span, default: 1h, examples: 30m, 1h, 1d, 2w, 3mo, 1y,
|
- description: 'Time Span, default: 1d, supported values: [1d, 1w, 1mo]'
|
||||||
all.'
|
|
||||||
in: query
|
in: query
|
||||||
name: timeSpan
|
name: timeSpan
|
||||||
type: string
|
type: string
|
||||||
- description: 'Sample Rate, default: 1m, examples: 30s, 1m, 1h, 1d, 2w, 3mo,
|
- description: 'Sample Rate, default: 1h, supported values: [1h, 1d]'
|
||||||
1y.'
|
|
||||||
in: query
|
in: query
|
||||||
name: sampleRate
|
name: sampleRate
|
||||||
type: string
|
type: string
|
||||||
|
|
|
@ -233,10 +233,7 @@ func ExtractAppId(c *fiber.Ctx, l *zap.Logger) string {
|
||||||
|
|
||||||
func ExtractTimeSpan(c *fiber.Ctx, l *zap.Logger) (string, error) {
|
func ExtractTimeSpan(c *fiber.Ctx, l *zap.Logger) (string, error) {
|
||||||
// get the timeSpan from query params
|
// get the timeSpan from query params
|
||||||
timeSpanStr := c.Query("timeSpan", "1h")
|
timeSpanStr := c.Query("timeSpan", "1d")
|
||||||
if timeSpanStr == "all" {
|
|
||||||
return timeSpanStr, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// validate the timeSpan
|
// validate the timeSpan
|
||||||
if !isValidTimeSpan(timeSpanStr) {
|
if !isValidTimeSpan(timeSpanStr) {
|
||||||
|
@ -245,17 +242,15 @@ func ExtractTimeSpan(c *fiber.Ctx, l *zap.Logger) (string, error) {
|
||||||
return timeSpanStr, nil
|
return timeSpanStr, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// isValidTimeSpan check if the timeSpan is valid
|
// isValidTimeSpan check that the timeSpan is valid.
|
||||||
func isValidTimeSpan(timeSpan string) bool {
|
func isValidTimeSpan(timeSpan string) bool {
|
||||||
return regexp.MustCompile(`^all$|^\d+[mhdwy]$|^\dmo$`).MatchString(timeSpan)
|
return regexp.MustCompile(`^1d$|^1w$|^1mo$`).MatchString(timeSpan)
|
||||||
}
|
}
|
||||||
|
|
||||||
func ExtractSampleRate(c *fiber.Ctx, l *zap.Logger) (string, error) {
|
func ExtractSampleRate(c *fiber.Ctx, l *zap.Logger) (string, error) {
|
||||||
// get the sampleRate from query params
|
// get the sampleRate from query params
|
||||||
sampleRateStr := c.Query("sampleRate", "1m")
|
sampleRateStr := c.Query("sampleRate", "1h")
|
||||||
if sampleRateStr == "1y" {
|
|
||||||
return sampleRateStr, nil
|
|
||||||
}
|
|
||||||
// validate the sampleRate
|
// validate the sampleRate
|
||||||
if !isValidSampleRate(sampleRateStr) {
|
if !isValidSampleRate(sampleRateStr) {
|
||||||
return "", response.NewInvalidQueryParamError(c, "INVALID <sampleRate> QUERY PARAMETER", nil)
|
return "", response.NewInvalidQueryParamError(c, "INVALID <sampleRate> QUERY PARAMETER", nil)
|
||||||
|
@ -264,7 +259,7 @@ func ExtractSampleRate(c *fiber.Ctx, l *zap.Logger) (string, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func isValidSampleRate(sampleRate string) bool {
|
func isValidSampleRate(sampleRate string) bool {
|
||||||
return regexp.MustCompile(`^\d+[smhdwy]$|^\dmo$`).MatchString(sampleRate)
|
return regexp.MustCompile(`^1h$|^1d$`).MatchString(sampleRate)
|
||||||
}
|
}
|
||||||
|
|
||||||
func ExtractTime(c *fiber.Ctx, queryParam string) (*time.Time, error) {
|
func ExtractTime(c *fiber.Ctx, queryParam string) (*time.Time, error) {
|
||||||
|
|
|
@ -28,8 +28,8 @@ func NewController(transactionsService *transactions.Service, logger *zap.Logger
|
||||||
// @Description Returns the number of transactions [vaa] by a defined time span and sample rate.
|
// @Description Returns the number of transactions [vaa] by a defined time span and sample rate.
|
||||||
// @Tags Wormscan
|
// @Tags Wormscan
|
||||||
// @ID get-last-transactions
|
// @ID get-last-transactions
|
||||||
// @Param timeSpan query string false "Time Span, default: 1h, examples: 30m, 1h, 1d, 2w, 3mo, 1y, all."
|
// @Param timeSpan query string false "Time Span, default: 1d, supported values: [1d, 1w, 1mo]"
|
||||||
// @Param sampleRate query string false "Sample Rate, default: 1m, examples: 30s, 1m, 1h, 1d, 2w, 3mo, 1y."
|
// @Param sampleRate query string false "Sample Rate, default: 1h, supported values: [1h, 1d]"
|
||||||
// @Success 200 {object} []transactions.TransactionCountResult
|
// @Success 200 {object} []transactions.TransactionCountResult
|
||||||
// @Failure 400
|
// @Failure 400
|
||||||
// @Failure 500
|
// @Failure 500
|
||||||
|
|
Loading…
Reference in New Issue