mirror of
https://github.com/OffchainLabs/prysm.git
synced 2026-01-08 23:18:15 -05:00
* WIP migrating keymanager api changes * gaz * fixing more tests * fixing unit tests * fixing deepsource * fixing visibility of package * fixing more package visability issues * gaz * fixing test * moving routes to proper location * removing whitespae for linting * Update validator/rpc/handlers_keymanager.go Co-authored-by: Radosław Kapka <rkapka@wp.pl> * radek's comments --------- Co-authored-by: Radosław Kapka <rkapka@wp.pl>
49 lines
1.6 KiB
Go
49 lines
1.6 KiB
Go
package apimiddleware
|
|
|
|
import (
|
|
"github.com/pkg/errors"
|
|
"github.com/prysmaticlabs/prysm/v4/api/gateway/apimiddleware"
|
|
)
|
|
|
|
// ValidatorEndpointFactory creates endpoints used for running validator API calls through the API Middleware.
|
|
type ValidatorEndpointFactory struct {
|
|
}
|
|
|
|
func (f *ValidatorEndpointFactory) IsNil() bool {
|
|
return f == nil
|
|
}
|
|
|
|
// Paths is a collection of all valid validator API paths.
|
|
func (*ValidatorEndpointFactory) Paths() []string {
|
|
return []string{
|
|
"/eth/v1/keystores",
|
|
"/eth/v1/validator/{pubkey}/feerecipient",
|
|
"/eth/v1/validator/{pubkey}/gas_limit",
|
|
}
|
|
}
|
|
|
|
// Create returns a new endpoint for the provided API path.
|
|
func (*ValidatorEndpointFactory) Create(path string) (*apimiddleware.Endpoint, error) {
|
|
endpoint := apimiddleware.DefaultEndpoint()
|
|
switch path {
|
|
case "/eth/v1/keystores":
|
|
endpoint.GetResponse = &ListKeystoresResponseJson{}
|
|
endpoint.PostRequest = &ImportKeystoresRequestJson{}
|
|
endpoint.PostResponse = &ImportKeystoresResponseJson{}
|
|
endpoint.DeleteRequest = &DeleteKeystoresRequestJson{}
|
|
endpoint.DeleteResponse = &DeleteKeystoresResponseJson{}
|
|
case "/eth/v1/validator/{pubkey}/feerecipient":
|
|
endpoint.GetResponse = &GetFeeRecipientByPubkeyResponseJson{}
|
|
endpoint.PostRequest = &SetFeeRecipientByPubkeyRequestJson{}
|
|
endpoint.DeleteRequest = &DeleteFeeRecipientByPubkeyRequestJson{}
|
|
case "/eth/v1/validator/{pubkey}/gas_limit":
|
|
endpoint.GetResponse = &GetGasLimitResponseJson{}
|
|
endpoint.PostRequest = &SetGasLimitRequestJson{}
|
|
endpoint.DeleteRequest = &DeleteGasLimitRequestJson{}
|
|
default:
|
|
return nil, errors.New("invalid path")
|
|
}
|
|
endpoint.Path = path
|
|
return &endpoint, nil
|
|
}
|