diff --git a/go.mod b/go.mod index 9f36a6c8..c95a1f0f 100644 --- a/go.mod +++ b/go.mod @@ -3,7 +3,7 @@ module github.com/Layr-Labs/eigensdk-go go 1.21 require ( - github.com/consensys/gnark-crypto v0.11.2 + github.com/consensys/gnark-crypto v0.12.0 github.com/ethereum/go-ethereum v1.12.2 github.com/prometheus/client_golang v1.17.0 github.com/stretchr/testify v1.8.4 diff --git a/go.sum b/go.sum index 1303854c..e4f72b2b 100644 --- a/go.sum +++ b/go.sum @@ -26,8 +26,8 @@ github.com/cockroachdb/redact v1.1.3 h1:AKZds10rFSIj7qADf0g46UixK8NNLwWTNdCIGS5w github.com/cockroachdb/redact v1.1.3/go.mod h1:BVNblN9mBWFyMyqK1k3AAiSxhvhfK2oOZZ2lK+dpvRg= github.com/consensys/bavard v0.1.13 h1:oLhMLOFGTLdlda/kma4VOJazblc7IM5y5QPd2A/YjhQ= github.com/consensys/bavard v0.1.13/go.mod h1:9ItSMtA/dXMAiL7BG6bqW2m3NdSEObYWoH223nGHukI= -github.com/consensys/gnark-crypto v0.11.2 h1:GJjjtWJ+db1xGao7vTsOgAOGgjfPe7eRGPL+xxMX0qE= -github.com/consensys/gnark-crypto v0.11.2/go.mod h1:v2Gy7L/4ZRosZ7Ivs+9SfUDr0f5UlG+EM5t7MPHiLuY= +github.com/consensys/gnark-crypto v0.12.0 h1:1OnSpOykNkUIBIBJKdhwy2p0JlW5o+Az02ICzZmvvdg= +github.com/consensys/gnark-crypto v0.12.0/go.mod h1:v2Gy7L/4ZRosZ7Ivs+9SfUDr0f5UlG+EM5t7MPHiLuY= github.com/cpuguy83/go-md2man/v2 v2.0.2 h1:p1EgwI/C7NhT0JmVkwCD2ZBK8j4aeHQX2pMHHBfMQ6w= github.com/cpuguy83/go-md2man/v2 v2.0.2/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o= github.com/crate-crypto/go-kzg-4844 v0.3.0 h1:UBlWE0CgyFqqzTI+IFyCzA7A3Zw4iip6uzRv5NIXG0A= diff --git a/types/operator_metadata.go b/types/operator_metadata.go index 84473df5..b8015c6a 100644 --- a/types/operator_metadata.go +++ b/types/operator_metadata.go @@ -9,12 +9,30 @@ import ( "strings" ) +// OperatorMetadata is the metadata operator uploads while registering +// itself to eigenlayer type OperatorMetadata struct { - Name string `yaml:"name" json:"name"` - Website string `yaml:"website" json:"website"` - Description string `yaml:"description" json:"description"` - Logo string `yaml:"logo" json:"logo"` - TwitterProfileUrl string `yaml:"twitter_profile_url" json:"twitter_profile_url"` + + // Name of the operator + // It is a required field + Name string `yaml:"name" json:"name"` + + // Website of the operator + // It is a required field + Website string `yaml:"website" json:"website"` + + // Description of the operator. There is a 200-character limit + // It is a required field + Description string `yaml:"description" json:"description"` + + // Logo of the operator. This should be a link to a image file + // which is publicly accessible + // It is a required field + Logo string `yaml:"logo" json:"logo"` + + // Twitter handle of the operator + // It is an optional field + Twitter string `yaml:"twitter" json:"twitter"` } func (om *OperatorMetadata) Validate() error { @@ -26,6 +44,10 @@ func (om *OperatorMetadata) Validate() error { return errors.New("description is required") } + if len(om.Description) > 200 { + return errors.New("description should be less than 200 characters") + } + if len(om.Logo) == 0 { return errors.New("logo is required") } @@ -42,8 +64,8 @@ func (om *OperatorMetadata) Validate() error { } } - if len(om.TwitterProfileUrl) != 0 { - err := checkIfUrlIsValid(om.TwitterProfileUrl) + if len(om.Twitter) != 0 { + err := checkIfUrlIsValid(om.Twitter) if err != nil { fmt.Println("error validating twitter profile url") return err diff --git a/types/operator_metadata_test.go b/types/operator_metadata_test.go index 9a996910..724686dd 100644 --- a/types/operator_metadata_test.go +++ b/types/operator_metadata_test.go @@ -11,132 +11,143 @@ func TestOperatorMetadata(t *testing.T) { { name: "Valid metadata", metadata: OperatorMetadata{ - Name: "test", - Description: "test", - Logo: "https://test.com/test.png", - TwitterProfileUrl: "https://twitter.com/test", - Website: "https://test.com", + Name: "test", + Description: "test", + Logo: "https://test.com/test.png", + Twitter: "https://twitter.com/test", + Website: "https://test.com", }, wantErr: false, }, { name: "Invalid metadata - no name", metadata: OperatorMetadata{ - Name: "", - Description: "test", - Logo: "https://test.com/test.png", - TwitterProfileUrl: "https://twitter.com/test", - Website: "https://test.com", + Name: "", + Description: "test", + Logo: "https://test.com/test.png", + Twitter: "https://twitter.com/test", + Website: "https://test.com", }, wantErr: true, }, { name: "Invalid metadata - no description", metadata: OperatorMetadata{ - Name: "test", - Description: "", - Logo: "https://test.com/test.png", - TwitterProfileUrl: "https://twitter.com/test", - Website: "https://test.com", + Name: "test", + Description: "", + Logo: "https://test.com/test.png", + Twitter: "https://twitter.com/test", + Website: "https://test.com", + }, + wantErr: true, + }, + { + name: "Invalid metadata - description > 500 characters", + metadata: OperatorMetadata{ + Name: "test", + Description: "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.", + Logo: "https://test.com/test.png", + Twitter: "https://twitter.com/test", + Website: "https://test.com", }, wantErr: true, }, { name: "Invalid metadata - no logo", metadata: OperatorMetadata{ - Name: "test", - Description: "test", - Logo: "", - TwitterProfileUrl: "https://twitter.com/test", - Website: "https://test.com", + Name: "test", + Description: "test", + Logo: "", + Twitter: "https://twitter.com/test", + Website: "https://test.com", }, wantErr: true, }, { name: "Invalid metadata - invalid logo extension", metadata: OperatorMetadata{ - Name: "test", - Description: "test", - Logo: "https://test.com/test.exe", - TwitterProfileUrl: "https://twitter.com/test", - Website: "https://test.com", + Name: "test", + Description: "test", + Logo: "https://test.com/test.exe", + Twitter: "https://twitter.com/test", + Website: "https://test.com", }, wantErr: true, }, { name: "Invalid metadata - invalid logo no extension", metadata: OperatorMetadata{ - Name: "test", - Description: "test", - Logo: "https://test.com/test", - TwitterProfileUrl: "https://twitter.com/test", - Website: "https://test.com", + Name: "test", + Description: "test", + Logo: "https://test.com/test", + Twitter: "https://twitter.com/test", + Website: "https://test.com", }, wantErr: true, }, { name: "Invalid metadata - invalid website url #1", metadata: OperatorMetadata{ - Name: "test", - Description: "test", - Logo: "https://test.com/test.png", - TwitterProfileUrl: "https://twitter.com/test", - Website: "https", + Name: "test", + Description: "test", + Logo: "https://test.com/test.png", + Twitter: "https://twitter.com/test", + Website: "https", }, wantErr: true, }, { name: "Invalid metadata - invalid website url #2", metadata: OperatorMetadata{ - Name: "test", - Description: "test", - Logo: "https://test.com/test.png", - TwitterProfileUrl: "https://twitter.com/test", - Website: "https:/test.com", + Name: "test", + Description: "test", + Logo: "https://test.com/test.png", + Twitter: "https://twitter.com/test", + Website: "https:/test.com", }, wantErr: true, }, { name: "Invalid metadata - invalid website url #3", metadata: OperatorMetadata{ - Name: "test", - Description: "test", - Logo: "https://test.com/test.png", - TwitterProfileUrl: "https://twitter.com/test", - Website: "ps://test.com", + Name: "test", + Description: "test", + Logo: "https://test.com/test.png", + Twitter: "https://twitter.com/test", + Website: "ps://test.com", }, wantErr: true, }, { name: "Invalid metadata - invalid twitter url #1", metadata: OperatorMetadata{ - Name: "test", - Description: "test", - Logo: "https://test.com/test.png", - TwitterProfileUrl: "http", - Website: "https://test.com", + Name: "test", + Description: "test", + Logo: "https://test.com/test.png", + Twitter: "http", + Website: "https://test.com", }, wantErr: true, }, { name: "Invalid metadata - invalid twitter url #2", metadata: OperatorMetadata{ - Name: "test", - Description: "test", - Logo: "https://test.com/test.png", - TwitterProfileUrl: "ht://twitter.com/test", - Website: "https:/test.com", + Name: "test", + Description: "test", + Logo: "https://test.com/test.png", + Twitter: "ht://twitter.com/test", + Website: "https:/test.com", }, wantErr: true, }, { name: "Invalid metadata - invalid twitter url #3", metadata: OperatorMetadata{ - Name: "test", - Description: "test", - Logo: "https://test.com/test.png", - TwitterProfileUrl: "https://twitt", - Website: "ps://test.com", + Name: "test", + Description: "test", + Logo: "https://test.com/test.png", + Twitter: "https://twitt", + Website: "ps://test.com", }, wantErr: true, }, diff --git a/types/operator_test.go b/types/operator_test.go index cfb9478f..e0dda700 100644 --- a/types/operator_test.go +++ b/types/operator_test.go @@ -9,11 +9,11 @@ import ( func TestOperatorValidate(t *testing.T) { metadata := OperatorMetadata{ - Name: "test", - Description: "test", - Logo: "https://test.com/test.png", - TwitterProfileUrl: "https://twitter.com/test", - Website: "https://test.com", + Name: "test", + Description: "test", + Logo: "https://test.com/test.png", + Twitter: "https://twitter.com/test", + Website: "https://test.com", } var tests = []struct {