Skip to content

Commit

Permalink
fix some bugs (#201)
Browse files Browse the repository at this point in the history
* fix some bugs

* add $

* add more chars
  • Loading branch information
shrimalmadhur authored Apr 16, 2024
1 parent 3059172 commit cff8107
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 3 deletions.
1 change: 1 addition & 0 deletions chainio/clients/elcontracts/writer.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ func (w *ELChainWriter) RegisterAsOperator(ctx context.Context, operator types.O
opDetails := delegationmanager.IDelegationManagerOperatorDetails{
EarningsReceiver: gethcommon.HexToAddress(operator.EarningsReceiverAddress),
StakerOptOutWindowBlocks: operator.StakerOptOutWindowBlocks,
DelegationApprover: gethcommon.HexToAddress(operator.DelegationApproverAddress),
}

noSendTxOpts, err := w.txMgr.GetNoSendTxOpts()
Expand Down
2 changes: 1 addition & 1 deletion types/operator_metadata_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ func TestOperatorMetadata(t *testing.T) {
name: "Valid metadata with twitter.com url",
metadata: OperatorMetadata{
Name: "Ethereum Utopia",
Description: "Madhur's first operator is best in this world+&~#",
Description: "Madhur's first operator is best in this world+&~#$—",
Logo: "https://goerli-operator-metadata.s3.amazonaws.com/eigenlayer.png",
Twitter: "https://twitter.com/test",
Website: "https://test.com",
Expand Down
3 changes: 2 additions & 1 deletion utils/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,14 @@ package utils

import (
"errors"
"fmt"
"strings"
)

var (
ErrInvalidUrl = errors.New("invalid url")
ErrInvalidGithubRawUrl = errors.New("invalid github raw url")
ErrInvalidText = errors.New("text is invalid")
ErrInvalidText = fmt.Errorf("invalid text format, doesn't conform to regex %s", TextRegex)
ErrTextTooLong = errors.New("text should be less than 500 characters")
ErrEmptyText = errors.New("text is empty")
ErrInvalidImageExtension = errors.New(
Expand Down
4 changes: 3 additions & 1 deletion utils/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ import (

const (
PngMimeType = "image/png"

TextRegex = `^[a-zA-Z0-9 +.,;:?!'"\-_/()\[\]~&#$—]+$`
)

var (
Expand Down Expand Up @@ -228,7 +230,7 @@ func ValidateText(text string) error {
}

// Regular expression to validate text
textPattern := regexp.MustCompile(`^[a-zA-Z0-9 +.,;:?!'"\-_/()\[\]~&#]+$`)
textPattern := regexp.MustCompile(TextRegex)

// Check if the URL matches the regular expression
if !textPattern.MatchString(text) {
Expand Down

0 comments on commit cff8107

Please sign in to comment.