Skip to content

Commit

Permalink
Add validation for grpc requests and cosmos messages
Browse files Browse the repository at this point in the history
  • Loading branch information
krhubert committed Nov 21, 2019
1 parent 6df2444 commit 7a3a9cc
Show file tree
Hide file tree
Showing 25 changed files with 489 additions and 313 deletions.
6 changes: 6 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,12 @@ issues:
exclude:
- "ineffective break statement. Did you mean to break out of the outer loop"

exclude-rules:
- path: x/xvalidator/validator.go
linters:
- golint
text: "exported var Translator should have its own declaration"

linters:
enable-all: true
disable:
Expand Down
18 changes: 10 additions & 8 deletions account/account.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

44 changes: 23 additions & 21 deletions event/event.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

70 changes: 36 additions & 34 deletions execution/execution.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions hash/hash.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,15 @@ func Decode(h string) (Hash, error) {
return Hash(hash), nil
}

// DecodeFromBytes decodes hash and checks it length.
// It returns empty hash on nil slice of bytes.
func DecodeFromBytes(data []byte) (Hash, error) {
if len(data) != size {
return nil, fmt.Errorf("hash: invalid length")
}
return Hash(data), nil
}

// IsZero reports whethere h represents empty hash.
func (h Hash) IsZero() bool {
return len(h) == 0
Expand Down
Loading

0 comments on commit 7a3a9cc

Please sign in to comment.