-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(types): add event validation and tag marshal
- Loading branch information
1 parent
b1e475c
commit 2e478bb
Showing
7 changed files
with
203 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
PACKAGES=$(shell go list ./... | grep -v 'tests' | grep -v 'grpc/gen') | ||
|
||
ifneq (,$(filter $(OS),Windows_NT MINGW64)) | ||
EXE = .exe | ||
RM = del /q | ||
else | ||
RM = rm -rf | ||
endif | ||
|
||
### Tools needed for development | ||
devtools: | ||
@echo "Installing devtools" | ||
go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest | ||
go install mvdan.cc/gofumpt@latest | ||
go install github.com/ethereum/go-ethereum/cmd/abigen@latest | ||
|
||
### Testing | ||
unit_test: | ||
go test $(PACKAGES) | ||
|
||
### Formatting the code | ||
fmt: | ||
gofumpt -l -w . | ||
go mod tidy | ||
|
||
check: | ||
golangci-lint run --timeout=20m0s | ||
|
||
### pre commit | ||
pre-commit: fmt check unit_test | ||
@echo ready to commit... | ||
|
||
.PHONY: build |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,30 @@ | ||
package types | ||
|
||
type Tag []string | ||
|
||
// Marshal Tag. Used for Serialization so string escaping should be as in RFC8259. | ||
func (tag Tag) MarshalTo(dst []byte) []byte { | ||
dst = append(dst, '[') | ||
for i, s := range tag { | ||
if i > 0 { | ||
dst = append(dst, ',') | ||
} | ||
dst = EscapeString(dst, s) | ||
} | ||
dst = append(dst, ']') | ||
return dst | ||
} | ||
|
||
// MarshalTo appends the JSON encoded byte of Tags as [][]string to dst. | ||
// String escaping is as described in RFC8259. | ||
func MarshalTo(tags []Tag, dst []byte) []byte { | ||
dst = append(dst, '[') | ||
for i, tag := range tags { | ||
if i > 0 { | ||
dst = append(dst, ',') | ||
} | ||
dst = tag.MarshalTo(dst) | ||
} | ||
dst = append(dst, ']') | ||
return dst | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters