Skip to content

Commit

Permalink
fix: attribute decoding in cometbft v0.38 (#96)
Browse files Browse the repository at this point in the history
Co-authored-by: John Letey <[email protected]>
  • Loading branch information
boojamya and johnletey authored Nov 13, 2024
1 parent b4df4de commit 932f2e8
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 13 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
15 changes: 3 additions & 12 deletions noble/message_state.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 932f2e8

Please sign in to comment.