Skip to content

Commit

Permalink
Merge branch 'main' into luke/distribution-events
Browse files Browse the repository at this point in the history
  • Loading branch information
Vvaradinov committed Nov 21, 2023
2 parents f0de9a6 + 6befcc6 commit 298aa73
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 4 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ Ref: https://keepachangelog.com/en/1.0.0/
- (erc20) [#2037](https://github.com/evmos/evmos/pull/2037) Add IsTransactions and RequiredGas tests for the ERC20 extension.
- (bank) [#2040](https://github.com/evmos/evmos/pull/2040) Add bank extension unit tests for queries.
- (bank) [#2041](https://github.com/evmos/evmos/pull/2041) Add `supplyOf` query to bank extension.
- (staking) [#2046](https://github.com/evmos/evmos/pull/2046) Format any type ConsensusPubkey into a base64 string.
- (bank) [#2045](https://github.com/evmos/evmos/pull/2045) Add unit tests for `supplyOf` query.
- (osmosis-outpost) [#2042](https://github.com/evmos/evmos/pull/2042) Add Osmosis's wasm hook validation functions to test
- (make) [#2052](https://github.com/evmos/evmos/pull/2052) Fix Makefile targets to compile ERC20 contracts.
Expand Down
13 changes: 11 additions & 2 deletions precompiles/staking/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -539,7 +539,7 @@ func (vo *ValidatorOutput) FromResponse(res *stakingtypes.QueryValidatorResponse
return ValidatorOutput{
Validator: ValidatorInfo{
OperatorAddress: res.Validator.OperatorAddress,
ConsensusPubkey: res.Validator.ConsensusPubkey.String(),
ConsensusPubkey: FormatConsensusPubkey(res.Validator.ConsensusPubkey),
Jailed: res.Validator.Jailed,
Status: uint8(stakingtypes.BondStatus_value[res.Validator.Status.String()]),
Tokens: res.Validator.Tokens.BigInt(),
Expand Down Expand Up @@ -574,7 +574,7 @@ func (vo *ValidatorsOutput) FromResponse(res *stakingtypes.QueryValidatorsRespon
for i, v := range res.Validators {
vo.Validators[i] = ValidatorInfo{
OperatorAddress: v.OperatorAddress,
ConsensusPubkey: v.ConsensusPubkey.String(),
ConsensusPubkey: FormatConsensusPubkey(v.ConsensusPubkey),
Jailed: v.Jailed,
Status: uint8(stakingtypes.BondStatus_value[v.Status.String()]),
Tokens: v.Tokens.BigInt(),
Expand Down Expand Up @@ -781,3 +781,12 @@ func checkDelegationUndelegationArgs(args []interface{}) (common.Address, string

return delegatorAddr, validatorAddress, amount, nil
}

// FormatConsensusPubkey format ConsensusPubkey into a base64 string
func FormatConsensusPubkey(consensusPubkey *codectypes.Any) string {
ed25519pk, ok := consensusPubkey.GetCachedValue().(cryptotypes.PubKey)
if ok {
return base64.StdEncoding.EncodeToString(ed25519pk.Bytes())
}
return consensusPubkey.String()
}
3 changes: 1 addition & 2 deletions precompiles/staking/utils_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package staking_test

import (
"encoding/json"
"fmt"
"math/big"
"time"

Expand Down Expand Up @@ -418,7 +417,7 @@ func (s *PrecompileTestSuite) assertValidatorsResponse(validators []staking.Vali
s.Require().Equal(int64(0), validators[i].UnbondingTime)
s.Require().Equal(int64(0), validators[i].Commission.Int64())
s.Require().Equal(int64(0), validators[i].MinSelfDelegation.Int64())
s.Require().Contains(validators[i].ConsensusPubkey, fmt.Sprintf("%v", s.validators[j].ConsensusPubkey.Value))
s.Require().Equal(validators[i].ConsensusPubkey, staking.FormatConsensusPubkey(s.validators[j].ConsensusPubkey))
}
}

Expand Down

0 comments on commit 298aa73

Please sign in to comment.