2022-12-19 12:23:54 +00:00
|
|
|
package beacon_api
|
|
|
|
|
|
|
|
import (
|
|
|
|
"bytes"
|
2023-01-06 03:32:13 +00:00
|
|
|
"context"
|
2022-12-19 12:23:54 +00:00
|
|
|
"encoding/json"
|
|
|
|
"strconv"
|
|
|
|
|
|
|
|
"github.com/ethereum/go-ethereum/common/hexutil"
|
|
|
|
"github.com/pkg/errors"
|
2024-02-03 11:57:01 +00:00
|
|
|
"github.com/prysmaticlabs/prysm/v4/api/server/structs"
|
2023-03-17 18:52:56 +00:00
|
|
|
ethpb "github.com/prysmaticlabs/prysm/v4/proto/prysm/v1alpha1"
|
2022-12-19 12:23:54 +00:00
|
|
|
)
|
|
|
|
|
2023-01-06 03:32:13 +00:00
|
|
|
func (c *beaconApiValidatorClient) prepareBeaconProposer(ctx context.Context, recipients []*ethpb.PrepareBeaconProposerRequest_FeeRecipientContainer) error {
|
2024-02-03 11:57:01 +00:00
|
|
|
jsonRecipients := make([]*structs.FeeRecipient, len(recipients))
|
2022-12-19 12:23:54 +00:00
|
|
|
for index, recipient := range recipients {
|
2024-02-03 11:57:01 +00:00
|
|
|
jsonRecipients[index] = &structs.FeeRecipient{
|
2022-12-19 12:23:54 +00:00
|
|
|
FeeRecipient: hexutil.Encode(recipient.FeeRecipient),
|
|
|
|
ValidatorIndex: strconv.FormatUint(uint64(recipient.ValidatorIndex), 10),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
marshalledJsonRecipients, err := json.Marshal(jsonRecipients)
|
|
|
|
if err != nil {
|
|
|
|
return errors.Wrap(err, "failed to marshal recipients")
|
|
|
|
}
|
|
|
|
|
2023-12-22 22:39:20 +00:00
|
|
|
return c.jsonRestHandler.Post(ctx, "/eth/v1/validator/prepare_beacon_proposer", nil, bytes.NewBuffer(marshalledJsonRecipients), nil)
|
2022-12-19 12:23:54 +00:00
|
|
|
}
|