Skip to content

Commit

Permalink
Handle Wasm Event Encoding Types
Browse files Browse the repository at this point in the history
  • Loading branch information
joelsmith-2019 committed Oct 9, 2024
1 parent 1301b60 commit 8581971
Showing 1 changed file with 15 additions and 9 deletions.
24 changes: 15 additions & 9 deletions node/pkg/watchers/ibc/wasm_attrs.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package ibc

import (
"encoding/base64"
"fmt"
"strconv"

Expand Down Expand Up @@ -75,22 +76,27 @@ func (wa *WasmAttributes) Parse(logger *zap.Logger, event gjson.Result) error {
if !valueBase.Exists() {
return fmt.Errorf("event attribute does not have a value: %s", attribute.String())
}
// keyRaw, err := base64.StdEncoding.DecodeString(keyBase.String())

key := keyBase.String()
value := valueBase.String()

keyRaw, err := base64.StdEncoding.DecodeString(keyBase.String())
if err == nil {
key = string(keyRaw)
}
// if err != nil {
// return fmt.Errorf("event attribute key is invalid base64: %s", attribute.String())
// }
// valueRaw, err := base64.StdEncoding.DecodeString(valueBase.String())

valueRaw, err := base64.StdEncoding.DecodeString(valueBase.String())
if err == nil {
value = string(valueRaw)
}
// if err != nil {
// return fmt.Errorf("event attribute value is invalid base64: %s", attribute.String())
// }

// key := string(keyRaw)
// value := string(valueRaw)

// TODO: JOEL - VALIDATE WASM EVENTS ARE NO LONGER BASE64 ENCODED

key := keyBase.String()
value := valueBase.String()
// TODO: JOEL - Some Wasm Events aren't Base64 encoded

if _, ok := wa.m[key]; ok {
return fmt.Errorf("duplicate key in event: %s", key)
Expand Down

0 comments on commit 8581971

Please sign in to comment.