mirror of
https://github.com/OffchainLabs/prysm.git
synced 2026-01-10 07:58:22 -05:00
29 lines
901 B
Go
29 lines
901 B
Go
package beacon_api
|
|
|
|
import (
|
|
"bytes"
|
|
"context"
|
|
"encoding/json"
|
|
|
|
"github.com/OffchainLabs/prysm/v7/api/server/structs"
|
|
ethpb "github.com/OffchainLabs/prysm/v7/proto/prysm/v1alpha1"
|
|
"github.com/pkg/errors"
|
|
)
|
|
|
|
func (c *beaconApiValidatorClient) submitValidatorRegistrations(ctx context.Context, registrations []*ethpb.SignedValidatorRegistrationV1) error {
|
|
const endpoint = "/eth/v1/validator/register_validator"
|
|
|
|
jsonRegistration := make([]*structs.SignedValidatorRegistration, len(registrations))
|
|
|
|
for index, registration := range registrations {
|
|
jsonRegistration[index] = structs.SignedValidatorRegistrationFromConsensus(registration)
|
|
}
|
|
|
|
marshalledJsonRegistration, err := json.Marshal(jsonRegistration)
|
|
if err != nil {
|
|
return errors.Wrap(err, "failed to marshal registration")
|
|
}
|
|
|
|
return c.jsonRestHandler.Post(ctx, endpoint, nil, bytes.NewBuffer(marshalledJsonRegistration), nil)
|
|
}
|