Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: attribute decoding in cometbft v0.38 #96

Merged
merged 2 commits into from
Nov 13, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 2 additions & 9 deletions noble/message_state.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,19 +27,12 @@
var parsed bool
var parseErrs error
for _, attr := range event.Attributes {
decodedKey, err := base64.StdEncoding.DecodeString(attr.Key)
if err != nil {
parseErrs = errors.Join(parseErrs, fmt.Errorf("failed to decode attribute key: %w", err))
}
decodedKey := attr.Key
if string(decodedKey) == "message" {

Check failure on line 31 in noble/message_state.go

View workflow job for this annotation

GitHub Actions / golangci-lint

unnecessary conversion (unconvert)
decodedValue, err := base64.StdEncoding.DecodeString(attr.Value)
if err != nil {
parseErrs = errors.Join(parseErrs, fmt.Errorf("error decoding attr.value: %w", err))
continue
}
decodedValue := attr.Value
encoded := decodedValue[1 : len(decodedValue)-1]
// Because we are using cometBFT v0.38, we need to decode the value twice.
rawMessageSentBytes, err := base64.StdEncoding.DecodeString(string(encoded))

Check failure on line 35 in noble/message_state.go

View workflow job for this annotation

GitHub Actions / golangci-lint

unnecessary conversion (unconvert)
if err != nil {
parseErrs = errors.Join(parseErrs, fmt.Errorf("failed to decode message: %w", err))
continue
Expand Down
Loading