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

Use enums for status field #47

Merged
merged 1 commit into from
May 16, 2024
Merged
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
11 changes: 10 additions & 1 deletion listener/internal/api/types/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,18 @@ type SignatureRequestDecoded struct {
SignatureRequest
}

type Status string

// create enum with status
const (
Unknown Status = "unknown"
Active Status = "active"
Inactive Status = "inactive"
)

type SignatureRequestDecodedWithActive struct {
SignatureRequestDecoded
Status string `json:"status"` // "unknown" | "active" | "inactive"
Status Status `json:"status"` // "unknown" | "active" | "inactive"
}

type DecodedPayload struct {
Expand Down
4 changes: 2 additions & 2 deletions listener/internal/api/validation/GetActiveValidators.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ func GetActiveValidators(requestsDecoded []types.SignatureRequestDecoded, beacon
if _, isActive := activeValidatorMap[req.Pubkey]; isActive {
activeValidators = append(activeValidators, types.SignatureRequestDecodedWithActive{
SignatureRequestDecoded: req,
Status: "active",
Status: types.Active,
})
} else {
// do not append inactive validators
Expand All @@ -127,7 +127,7 @@ func GetSignatureRequestsDecodedWithUnknown(requests []types.SignatureRequestDec
for _, req := range requests {
signatureRequestsDecodedWithActive = append(signatureRequestsDecodedWithActive, types.SignatureRequestDecodedWithActive{
SignatureRequestDecoded: req,
Status: "unknown",
Status: types.Unknown,
})
}
return signatureRequestsDecodedWithActive
Expand Down
4 changes: 2 additions & 2 deletions listener/internal/api/validation/VerifySignature_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ func TestVerifySignature(t *testing.T) {
Network: "mainnet",
Tag: "solo"},
},
Status: "active",
Status: types.Active,
}

// Validate the signature
Expand Down Expand Up @@ -93,7 +93,7 @@ func TestVerifySignatureError(t *testing.T) {
Tag: "solo",
},
},
Status: "active",
Status: types.Active,
}

// Validate the signature
Expand Down
Loading