From 932f2e80f9138487e831f0102e378fc5147c187d Mon Sep 17 00:00:00 2001 From: Dan Kanefsky <56059752+boojamya@users.noreply.github.com> Date: Wed, 13 Nov 2024 13:15:58 -0500 Subject: [PATCH] fix: attribute decoding in cometbft v0.38 (#96) Co-authored-by: John Letey --- README.md | 2 +- noble/message_state.go | 15 +++------------ 2 files changed, 4 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index d4a1f7d..f30fbf1 100644 --- a/README.md +++ b/README.md @@ -102,6 +102,6 @@ abigen --abi ethereum/abi/MessageTransmitter.json --pkg contracts- --type Messag ### Useful links [Relayer Flow Charts](./docs/flows.md) -[USDC faucet](https://usdcfaucet.com/) +[USDC faucet](https://faucet.circle.com) [Circle Docs/Contract Addresses](https://developers.circle.com/stablecoins/docs/evm-smart-contracts) diff --git a/noble/message_state.go b/noble/message_state.go index 20e6f4a..55f959d 100644 --- a/noble/message_state.go +++ b/noble/message_state.go @@ -27,19 +27,10 @@ func txToMessageState(tx *ctypes.ResultTx) ([]*types.MessageState, error) { 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)) - } - if string(decodedKey) == "message" { - decodedValue, err := base64.StdEncoding.DecodeString(attr.Value) - if err != nil { - parseErrs = errors.Join(parseErrs, fmt.Errorf("error decoding attr.value: %w", err)) - continue - } - encoded := decodedValue[1 : len(decodedValue)-1] + if attr.Key == "message" { + encoded := attr.Value[1 : len(attr.Value)-1] // Because we are using cometBFT v0.38, we need to decode the value twice. - rawMessageSentBytes, err := base64.StdEncoding.DecodeString(string(encoded)) + rawMessageSentBytes, err := base64.StdEncoding.DecodeString(encoded) if err != nil { parseErrs = errors.Join(parseErrs, fmt.Errorf("failed to decode message: %w", err)) continue