Skip to content

Commit

Permalink
fix(gov): Add value decoder for attribute key "sender" (berachain#1397)
Browse files Browse the repository at this point in the history
<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

- **New Features**
- Improved governance contract with enhanced address conversion
capabilities.
- Enhanced telemetry and metrics collection within the application for
better performance monitoring.
- Expanded Ethereum execution layer functionality with new backend
integration.

- **Refactor**
- Streamlined configuration initialization for improved application
setup.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->

---------

Co-authored-by: ocnc <[email protected]>
Co-authored-by: itsdevbear <[email protected]>
  • Loading branch information
3 people authored Jan 9, 2024
1 parent 44fbc24 commit 0855077
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
8 changes: 8 additions & 0 deletions cosmos/precompile/governance/governance.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ func (c *Contract) CustomValueDecoders() ethprecompile.ValueDecoders {
return ethprecompile.ValueDecoders{
AttributeProposalSender: log.ConvertCommonHexAddress,
AttributeProposalVote: ConvertStringToVote,
sdk.AttributeKeySender: c.ConvertAccAddressFromString,
}
}

Expand Down Expand Up @@ -564,3 +565,10 @@ func ConvertStringToVote(attributeValue string) (any, error) {
}
return vote, nil
}

// ConvertAccAddressFromString converts a Cosmos string representing a account address to a
// common.Address.
func (c *Contract) ConvertAccAddressFromString(attributeValue string) (any, error) {
// extract the sdk.AccAddress from string value as common.Address
return cosmlib.EthAddressFromString(c.addressCodec, attributeValue)
}
2 changes: 1 addition & 1 deletion cosmos/precompile/governance/governance_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ var _ = Describe("Governance Precompile", func() {
It("Should have precompile tests and custom value decoders", func() {
_, err := sf.Build(contract, nil)
Expect(err).ToNot(HaveOccurred())
Expect(contract.CustomValueDecoders()).To(HaveLen(2))
Expect(contract.CustomValueDecoders()).To(HaveLen(3))
})

When("Unmarshal message and return any", func() {
Expand Down

0 comments on commit 0855077

Please sign in to comment.