Skip to content

Commit

Permalink
UPT fendermint blcok result attributes decode
Browse files Browse the repository at this point in the history
  • Loading branch information
davcrypto committed Oct 13, 2023
1 parent 39dfb19 commit 5c59a3f
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions infrastructure/tendermint/parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -206,9 +206,17 @@ func parseBlockResultsEvents(rawEvents []RawBlockResultsEvent) []model.BlockResu
for _, rawEvent := range rawEvents {
attributes := make([]model.BlockResultsEventAttribute, 0, len(rawEvent.Attributes))
for _, rawAttribute := range rawEvent.Attributes {
key, err := base64Decode(rawAttribute.Key)
if err != nil {
key = rawAttribute.Key
}
value, err := base64Decode(rawAttribute.Value)
if err != nil {
value = rawAttribute.Value
}
attributes = append(attributes, model.BlockResultsEventAttribute{
Key: mustBase64Decode(rawAttribute.Key),
Value: mustBase64Decode(rawAttribute.Value),
Key: key,
Value: value,
Index: rawAttribute.Index,
})
}
Expand Down Expand Up @@ -262,6 +270,14 @@ func mustBase64Decode(s string) string {
return string(decoded)
}

func base64Decode(s string) (string, error) {
decoded, err := base64.StdEncoding.DecodeString(s)
if err != nil {
return "", err
}
return string(decoded), nil
}

func parseBlockResultsConsensusParamsUpdates(rawUpdates RawBlockResultsConsensusParamUpdates) model.BlockResultsConsensusParamUpdates {
var validatorPubKeyTypes []string
if rawUpdates.Validator.PubKeyTypes == nil {
Expand Down

0 comments on commit 5c59a3f

Please sign in to comment.