Skip to content

Commit

Permalink
cli/actions fixed (ReadYamlConfig moved here)
Browse files Browse the repository at this point in the history
  • Loading branch information
pablodeymo committed Nov 11, 2024
1 parent 8a36b73 commit ac30630
Show file tree
Hide file tree
Showing 7 changed files with 50 additions and 11 deletions.
3 changes: 1 addition & 2 deletions cli/actions/deposit_into_strategy.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import (
"log"
"math/big"

sdkutils "github.com/Layr-Labs/eigensdk-go/utils"
"github.com/Layr-Labs/incredible-squaring-avs/core/config"
"github.com/Layr-Labs/incredible-squaring-avs/operator"
"github.com/Layr-Labs/incredible-squaring-avs/types"
Expand All @@ -18,7 +17,7 @@ func DepositIntoStrategy(ctx *cli.Context) error {

configPath := ctx.GlobalString(config.ConfigFileFlag.Name)
nodeConfig := types.NodeConfig{}
err := sdkutils.ReadYamlConfig(configPath, &nodeConfig)
err := ReadYamlConfig(configPath, &nodeConfig)
if err != nil {
return err
}
Expand Down
3 changes: 1 addition & 2 deletions cli/actions/print_operator_status.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"encoding/json"
"log"

sdkutils "github.com/Layr-Labs/eigensdk-go/utils"
"github.com/Layr-Labs/incredible-squaring-avs/core/config"
"github.com/Layr-Labs/incredible-squaring-avs/operator"
"github.com/Layr-Labs/incredible-squaring-avs/types"
Expand All @@ -15,7 +14,7 @@ func PrintOperatorStatus(ctx *cli.Context) error {

configPath := ctx.GlobalString(config.ConfigFileFlag.Name)
nodeConfig := types.NodeConfig{}
err := sdkutils.ReadYamlConfig(configPath, &nodeConfig)
err := ReadYamlConfig(configPath, &nodeConfig)
if err != nil {
return err
}
Expand Down
35 changes: 35 additions & 0 deletions cli/actions/read_config.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package actions

import (
"errors"
"log"
"os"
"path/filepath"

"gopkg.in/yaml.v3"
)

func ReadYamlConfig(path string, o interface{}) error {
if _, err := os.Stat(path); errors.Is(err, os.ErrNotExist) {
log.Fatal("Path ", path, " does not exist")
}
b, err := ReadFile(path)
if err != nil {
return err
}

err = yaml.Unmarshal(b, o)
if err != nil {
log.Fatalf("unable to parse file with error %#v", err)
}

return nil
}

func ReadFile(path string) ([]byte, error) {
b, err := os.ReadFile(filepath.Clean(path))
if err != nil {
return nil, err
}
return b, nil
}
3 changes: 1 addition & 2 deletions cli/actions/register_operator_with_avs.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import (
"os"

sdkecdsa "github.com/Layr-Labs/eigensdk-go/crypto/ecdsa"
sdkutils "github.com/Layr-Labs/eigensdk-go/utils"
"github.com/Layr-Labs/incredible-squaring-avs/core/config"
"github.com/Layr-Labs/incredible-squaring-avs/operator"
"github.com/Layr-Labs/incredible-squaring-avs/types"
Expand All @@ -17,7 +16,7 @@ func RegisterOperatorWithAvs(ctx *cli.Context) error {

configPath := ctx.GlobalString(config.ConfigFileFlag.Name)
nodeConfig := types.NodeConfig{}
err := sdkutils.ReadYamlConfig(configPath, &nodeConfig)
err := ReadYamlConfig(configPath, &nodeConfig)
if err != nil {
return err
}
Expand Down
6 changes: 3 additions & 3 deletions cli/actions/register_operator_with_eigenlayer.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ package actions

import (
"encoding/json"
"github.com/urfave/cli"
"log"

sdkutils "github.com/Layr-Labs/eigensdk-go/utils"
"github.com/urfave/cli"

"github.com/Layr-Labs/incredible-squaring-avs/core/config"
"github.com/Layr-Labs/incredible-squaring-avs/operator"
"github.com/Layr-Labs/incredible-squaring-avs/types"
Expand All @@ -15,7 +15,7 @@ func RegisterOperatorWithEigenlayer(ctx *cli.Context) error {

configPath := ctx.GlobalString(config.ConfigFileFlag.Name)
nodeConfig := types.NodeConfig{}
err := sdkutils.ReadYamlConfig(configPath, &nodeConfig)
err := ReadYamlConfig(configPath, &nodeConfig)
if err != nil {
return err
}
Expand Down
5 changes: 3 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ go 1.21
toolchain go1.21.0

require (
github.com/Layr-Labs/eigensdk-go v0.1.12
github.com/Layr-Labs/eigensdk-go v0.1.13-0.20241108213203-a5ad59992469
github.com/ethereum/go-ethereum v1.14.0
github.com/prometheus/client_golang v1.19.0
github.com/stretchr/testify v1.9.0
Expand Down Expand Up @@ -59,7 +59,7 @@ require (
github.com/deckarep/golang-set/v2 v2.1.0 // indirect
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.0.1 // indirect
github.com/distribution/reference v0.5.0 // indirect
github.com/docker/docker v25.0.5+incompatible // indirect
github.com/docker/docker v25.0.6+incompatible // indirect
github.com/docker/go-connections v0.5.0 // indirect
github.com/docker/go-units v0.5.0 // indirect
github.com/ethereum/c-kzg-4844 v1.0.0 // indirect
Expand Down Expand Up @@ -108,6 +108,7 @@ require (
github.com/opencontainers/image-spec v1.1.0 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/posthog/posthog-go v1.2.24 // indirect
github.com/power-devops/perfstat v0.0.0-20210106213030-5aafc221ea8c // indirect
github.com/prometheus/client_model v0.5.0 // indirect
github.com/prometheus/common v0.48.0 // indirect
Expand Down
6 changes: 6 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ github.com/Layr-Labs/eigensdk-go v0.1.7-0.20240425202952-954cd7661775 h1:xQQ4xnl
github.com/Layr-Labs/eigensdk-go v0.1.7-0.20240425202952-954cd7661775/go.mod h1:ECU8/Ocsf+dGcN2rs8I1PScq4dOkQqY+vgwnq30Ov4M=
github.com/Layr-Labs/eigensdk-go v0.1.12 h1:Drf59iJLvnTm2Om9AwAyUMiZeJaTI8ZameIrnhjopSY=
github.com/Layr-Labs/eigensdk-go v0.1.12/go.mod h1:XcLVDtlB1vOPj63D236b451+SC75B8gwgkpNhYHSxNs=
github.com/Layr-Labs/eigensdk-go v0.1.13-0.20241108213203-a5ad59992469 h1:zBmTZdIio/xzftdBvyCOLMGtRhmmqRbwSufHjL5dNbI=
github.com/Layr-Labs/eigensdk-go v0.1.13-0.20241108213203-a5ad59992469/go.mod h1:QsDfVTmN1BCYl3OAZKMRqdloyXUQ6UOYjS1QZbB9aP4=
github.com/Microsoft/go-winio v0.6.1 h1:9/kr64B9VUZrLm5YYwbGtUJnMgqWVOdUAXu6Migciow=
github.com/Microsoft/go-winio v0.6.1/go.mod h1:LRdKpFKfdobln8UmuiYcKPot9D2v6svN5+sAH+4kjUM=
github.com/Microsoft/hcsshim v0.11.4 h1:68vKo2VN8DE9AdN4tnkWnmdhqdbpUFM8OF3Airm7fz8=
Expand Down Expand Up @@ -140,6 +142,8 @@ github.com/docker/docker v25.0.3+incompatible h1:D5fy/lYmY7bvZa0XTZ5/UJPljor41F+
github.com/docker/docker v25.0.3+incompatible/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk=
github.com/docker/docker v25.0.5+incompatible h1:UmQydMduGkrD5nQde1mecF/YnSbTOaPeFIeP5C4W+DE=
github.com/docker/docker v25.0.5+incompatible/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk=
github.com/docker/docker v25.0.6+incompatible h1:5cPwbwriIcsua2REJe8HqQV+6WlWc1byg2QSXzBxBGg=
github.com/docker/docker v25.0.6+incompatible/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk=
github.com/docker/go-connections v0.5.0 h1:USnMq7hx7gwdVZq1L49hLXaFtUdTADjXGp+uj1Br63c=
github.com/docker/go-connections v0.5.0/go.mod h1:ov60Kzw0kKElRwhNs9UlUHAE/F9Fe6GLaXnqyDdmEXc=
github.com/docker/go-units v0.5.0 h1:69rxXcBk27SvSaaxTtLh/8llcHD8vYHT7WSdRZ/jvr4=
Expand Down Expand Up @@ -390,6 +394,8 @@ github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/posthog/posthog-go v1.2.24 h1:A+iG4saBJemo++VDlcWovbYf8KFFNUfrCoJtsc40RPA=
github.com/posthog/posthog-go v1.2.24/go.mod h1:uYC2l1Yktc8E+9FAHJ9QZG4vQf/NHJPD800Hsm7DzoM=
github.com/power-devops/perfstat v0.0.0-20210106213030-5aafc221ea8c h1:ncq/mPwQF4JjgDlrVEn3C11VoGHZN7m8qihwgMEtzYw=
github.com/power-devops/perfstat v0.0.0-20210106213030-5aafc221ea8c/go.mod h1:OmDBASR4679mdNQnz2pUhc2G8CO2JrUAVFDRBDP/hJE=
github.com/prometheus/client_golang v1.19.0 h1:ygXvpU1AoN1MhdzckN+PyD9QJOSD4x7kmXYlnfbA6JU=
Expand Down

0 comments on commit ac30630

Please sign in to comment.