mirror of
https://gitlab.com/pulsechaincom/prysm-pulse.git
synced 2025-01-09 19:21:19 +00:00
4c47756aed
* remove validation package * structs cleanup * merge with apimiddleware removal * more validation and Bls capitalization * builder test fix * use strconv for uint->str conversions * use DecodeHexWithLength * use exact param names * rename http package to httputil * change conversions to fmt.Sprintf * handle query paramsd and route variables * spans and receiver name * split structs, move bytes helper * missing ok check * fix reference to indexed failure * errors fixup * add godoc to helper * fix BLS casing and chainhead ref * review * fix import in tests * gzl
37 lines
1.0 KiB
Go
37 lines
1.0 KiB
Go
package beacon_api
|
|
|
|
import (
|
|
"bytes"
|
|
"context"
|
|
"encoding/json"
|
|
|
|
"github.com/pkg/errors"
|
|
"github.com/prysmaticlabs/prysm/v4/beacon-chain/rpc/eth/shared"
|
|
ethpb "github.com/prysmaticlabs/prysm/v4/proto/prysm/v1alpha1"
|
|
)
|
|
|
|
func (c *beaconApiValidatorClient) submitValidatorRegistrations(ctx context.Context, registrations []*ethpb.SignedValidatorRegistrationV1) error {
|
|
const endpoint = "/eth/v1/validator/register_validator"
|
|
|
|
jsonRegistration := make([]*shared.SignedValidatorRegistration, len(registrations))
|
|
|
|
for index, registration := range registrations {
|
|
jsonRegistration[index] = shared.SignedValidatorRegistrationFromConsensus(registration)
|
|
}
|
|
|
|
marshalledJsonRegistration, err := json.Marshal(jsonRegistration)
|
|
if err != nil {
|
|
return errors.Wrap(err, "failed to marshal registration")
|
|
}
|
|
|
|
errJson, err := c.jsonRestHandler.Post(ctx, endpoint, nil, bytes.NewBuffer(marshalledJsonRegistration), nil)
|
|
if err != nil {
|
|
return errors.Wrap(err, msgUnexpectedError)
|
|
}
|
|
if errJson != nil {
|
|
return errJson
|
|
}
|
|
|
|
return nil
|
|
}
|