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
Show file tree
Hide file tree
Changes from all commits
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
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
Loading