Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Return combined v1 and v2 FP list #156

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 21 additions & 12 deletions docs/docs.go
Original file line number Diff line number Diff line change
Expand Up @@ -801,6 +801,21 @@ const docTemplate = `{
}
}
},
"indexerdbmodel.FinalityProviderState": {
"type": "string",
"enum": [
"FINALITY_PROVIDER_STATUS_INACTIVE",
"FINALITY_PROVIDER_STATUS_ACTIVE",
"FINALITY_PROVIDER_STATUS_JAILED",
"FINALITY_PROVIDER_STATUS_SLASHED"
],
"x-enum-varnames": [
"FinalityProviderStatus_FINALITY_PROVIDER_STATUS_INACTIVE",
"FinalityProviderStatus_FINALITY_PROVIDER_STATUS_ACTIVE",
"FinalityProviderStatus_FINALITY_PROVIDER_STATUS_JAILED",
"FinalityProviderStatus_FINALITY_PROVIDER_STATUS_SLASHED"
]
},
"indexertypes.BbnStakingParams": {
"type": "object",
"properties": {
Expand Down Expand Up @@ -906,17 +921,6 @@ const docTemplate = `{
}
}
},
"types.FinalityProviderQueryingState": {
"type": "string",
"enum": [
"active",
"standby"
],
"x-enum-varnames": [
"FinalityProviderStateActive",
"FinalityProviderStateStandby"
]
},
"v1handlers.DelegationCheckPublicResponse": {
"type": "object",
"properties": {
Expand Down Expand Up @@ -1235,7 +1239,10 @@ const docTemplate = `{
"$ref": "#/definitions/types.FinalityProviderDescription"
},
"state": {
"$ref": "#/definitions/types.FinalityProviderQueryingState"
"$ref": "#/definitions/indexerdbmodel.FinalityProviderState"
},
"transition_required": {
"type": "boolean"
}
}
},
Expand Down Expand Up @@ -1350,6 +1357,7 @@ const docTemplate = `{
"PENDING",
"VERIFIED",
"ACTIVE",
"SLASHED",
"TIMELOCK_UNBONDING",
"EARLY_UNBONDING",
"TIMELOCK_WITHDRAWABLE",
Expand All @@ -1367,6 +1375,7 @@ const docTemplate = `{
"StatePending",
"StateVerified",
"StateActive",
"StateSlashed",
"StateTimelockUnbonding",
"StateEarlyUnbonding",
"StateTimelockWithdrawable",
Expand Down
33 changes: 21 additions & 12 deletions docs/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -793,6 +793,21 @@
}
}
},
"indexerdbmodel.FinalityProviderState": {
"type": "string",
"enum": [
"FINALITY_PROVIDER_STATUS_INACTIVE",
"FINALITY_PROVIDER_STATUS_ACTIVE",
"FINALITY_PROVIDER_STATUS_JAILED",
"FINALITY_PROVIDER_STATUS_SLASHED"
],
"x-enum-varnames": [
"FinalityProviderStatus_FINALITY_PROVIDER_STATUS_INACTIVE",
"FinalityProviderStatus_FINALITY_PROVIDER_STATUS_ACTIVE",
"FinalityProviderStatus_FINALITY_PROVIDER_STATUS_JAILED",
"FinalityProviderStatus_FINALITY_PROVIDER_STATUS_SLASHED"
]
},
"indexertypes.BbnStakingParams": {
"type": "object",
"properties": {
Expand Down Expand Up @@ -898,17 +913,6 @@
}
}
},
"types.FinalityProviderQueryingState": {
"type": "string",
"enum": [
"active",
"standby"
],
"x-enum-varnames": [
"FinalityProviderStateActive",
"FinalityProviderStateStandby"
]
},
"v1handlers.DelegationCheckPublicResponse": {
"type": "object",
"properties": {
Expand Down Expand Up @@ -1227,7 +1231,10 @@
"$ref": "#/definitions/types.FinalityProviderDescription"
},
"state": {
"$ref": "#/definitions/types.FinalityProviderQueryingState"
"$ref": "#/definitions/indexerdbmodel.FinalityProviderState"
},
"transition_required": {
"type": "boolean"
}
}
},
Expand Down Expand Up @@ -1342,6 +1349,7 @@
"PENDING",
"VERIFIED",
"ACTIVE",
"SLASHED",
"TIMELOCK_UNBONDING",
"EARLY_UNBONDING",
"TIMELOCK_WITHDRAWABLE",
Expand All @@ -1359,6 +1367,7 @@
"StatePending",
"StateVerified",
"StateActive",
"StateSlashed",
"StateTimelockUnbonding",
"StateEarlyUnbonding",
"StateTimelockWithdrawable",
Expand Down
26 changes: 17 additions & 9 deletions docs/swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,18 @@ definitions:
next_key:
type: string
type: object
indexerdbmodel.FinalityProviderState:
enum:
- FINALITY_PROVIDER_STATUS_INACTIVE
- FINALITY_PROVIDER_STATUS_ACTIVE
- FINALITY_PROVIDER_STATUS_JAILED
- FINALITY_PROVIDER_STATUS_SLASHED
type: string
x-enum-varnames:
- FinalityProviderStatus_FINALITY_PROVIDER_STATUS_INACTIVE
- FinalityProviderStatus_FINALITY_PROVIDER_STATUS_ACTIVE
- FinalityProviderStatus_FINALITY_PROVIDER_STATUS_JAILED
- FinalityProviderStatus_FINALITY_PROVIDER_STATUS_SLASHED
indexertypes.BbnStakingParams:
properties:
covenant_pks:
Expand Down Expand Up @@ -178,14 +190,6 @@ definitions:
website:
type: string
type: object
types.FinalityProviderQueryingState:
enum:
- active
- standby
type: string
x-enum-varnames:
- FinalityProviderStateActive
- FinalityProviderStateStandby
v1handlers.DelegationCheckPublicResponse:
properties:
code:
Expand Down Expand Up @@ -394,7 +398,9 @@ definitions:
description:
$ref: '#/definitions/types.FinalityProviderDescription'
state:
$ref: '#/definitions/types.FinalityProviderQueryingState'
$ref: '#/definitions/indexerdbmodel.FinalityProviderState'
transition_required:
type: boolean
type: object
v2service.NetworkInfoPublic:
properties:
Expand Down Expand Up @@ -469,6 +475,7 @@ definitions:
- PENDING
- VERIFIED
- ACTIVE
- SLASHED
- TIMELOCK_UNBONDING
- EARLY_UNBONDING
- TIMELOCK_WITHDRAWABLE
Expand All @@ -486,6 +493,7 @@ definitions:
- StatePending
- StateVerified
- StateActive
- StateSlashed
- StateTimelockUnbonding
- StateEarlyUnbonding
- StateTimelockWithdrawable
Expand Down
13 changes: 0 additions & 13 deletions internal/indexer/db/model/finality_providers.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,8 @@ package indexerdbmodel

import (
"encoding/json"
"fmt"

dbmodel "github.com/babylonlabs-io/staking-api-service/internal/shared/db/model"
"github.com/babylonlabs-io/staking-api-service/internal/shared/types"
)

type FinalityProviderState string
Expand Down Expand Up @@ -57,14 +55,3 @@ func DecodeFinalityProviderPaginationToken(token string) (*IndexerFinalityProvid
err := json.Unmarshal([]byte(token), &pagination)
return &pagination, err
}

func FromStringToFinalityProviderState(s string) (types.FinalityProviderQueryingState, error) {
switch s {
case "active":
return types.FinalityProviderStateActive, nil
case "standby":
return types.FinalityProviderStateStandby, nil
default:
return "", fmt.Errorf("invalid finality provider state: %s", s)
}
}
17 changes: 0 additions & 17 deletions internal/shared/api/handlers/handler/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import (
"net/http"
"regexp"

indexerdbmodel "github.com/babylonlabs-io/staking-api-service/internal/indexer/db/model"
"github.com/babylonlabs-io/staking-api-service/internal/shared/config"
"github.com/babylonlabs-io/staking-api-service/internal/shared/services/service"
"github.com/babylonlabs-io/staking-api-service/internal/shared/types"
Expand Down Expand Up @@ -206,19 +205,3 @@ func ParseFPSearchQuery(r *http.Request, queryName string, isOptional bool) (str

return str, nil
}

func ParseFPStateQuery(r *http.Request, isOptional bool) (types.FinalityProviderQueryingState, *types.Error) {
state := r.URL.Query().Get("state")
if state == "" {
if isOptional {
return "", nil
}
}
stateEnum, err := indexerdbmodel.FromStringToFinalityProviderState(state)
if err != nil {
return "", types.NewErrorWithMsg(
http.StatusBadRequest, types.BadRequest, err.Error(),
)
}
return stateEnum, nil
}
2 changes: 1 addition & 1 deletion internal/shared/services/services.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ func New(
if err != nil {
return nil, err
}
v2Service, err := v2service.New(ctx, cfg, clients, dbClients)
v2Service, err := v2service.New(ctx, cfg, clients, dbClients, finalityProviders)
if err != nil {
return nil, err
}
Expand Down
7 changes: 0 additions & 7 deletions internal/shared/types/finality_providers.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,6 @@ import (
"path/filepath"
)

type FinalityProviderQueryingState string

const (
FinalityProviderStateActive FinalityProviderQueryingState = "active"
FinalityProviderStateStandby FinalityProviderQueryingState = "standby"
)

type FinalityProviderDescription struct {
Moniker string `json:"moniker"`
Identity string `json:"identity"`
Expand Down
Loading
Loading