-
Notifications
You must be signed in to change notification settings - Fork 7
/
validators_service_requests.go
41 lines (38 loc) · 1.59 KB
/
validators_service_requests.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
package serverless_aws_automation
import (
"context"
"fmt"
"github.com/zeus-fyi/zeus/builds"
signing_automation_ethereum "github.com/zeus-fyi/zeus/pkg/artemis/signing_automation/ethereum"
hestia_client "github.com/zeus-fyi/zeus/pkg/hestia/client"
hestia_req_types "github.com/zeus-fyi/zeus/pkg/hestia/client/req_types"
filepaths "github.com/zeus-fyi/zeus/pkg/utils/file_io/lib/v0/paths"
strings_filter "github.com/zeus-fyi/zeus/pkg/utils/strings"
)
func CreateHestiaValidatorsServiceRequest(ctx context.Context, keystoresPath filepaths.Path, sr hestia_req_types.ServiceRequestWrapper, bearerToken, feeRecipientAddr string) {
fmt.Println("INFO: Creating Hestia Validators Service Request...")
hc := hestia_client.NewDefaultHestiaClient(bearerToken)
builds.ChangeToBuildsDir()
filter := &strings_filter.FilterOpts{StartsWith: "deposit_data", DoesNotInclude: []string{"keystores.tar.gz.age", ".DS_Store"}}
keystoresPath.FilterFiles = filter
dpSlice, err := signing_automation_ethereum.ParseValidatorDepositSliceJSON(ctx, keystoresPath)
if err != nil {
panic(err)
}
pubkeys := hestia_req_types.ValidatorServiceOrgGroupSlice{}
for _, validatorDepositInfo := range dpSlice {
pubkeys = append(pubkeys, hestia_req_types.ValidatorServiceOrgGroup{
Pubkey: validatorDepositInfo.Pubkey,
FeeRecipient: feeRecipientAddr,
})
}
hs := hestia_req_types.CreateValidatorServiceRequest{}
hs.CreateValidatorServiceRequest(pubkeys, sr)
resp, err := hc.ValidatorsServiceRequest(ctx, hs)
if err != nil {
panic(err)
}
if resp.Message == "" {
panic("ERROR: Hestia Validators Service Request failed!")
}
}