diff --git a/pkg/converter/converter.go b/pkg/converter/converter.go index a1902c4..2a35ced 100644 --- a/pkg/converter/converter.go +++ b/pkg/converter/converter.go @@ -7,6 +7,7 @@ import ( "github.com/cosmos/cosmos-sdk/codec" codecTyped "github.com/cosmos/cosmos-sdk/codec/types" "github.com/cosmos/cosmos-sdk/std" + sdkTypes "github.com/cosmos/cosmos-sdk/types" slashingTypes "github.com/cosmos/cosmos-sdk/x/slashing/types" stakingTypes "github.com/cosmos/cosmos-sdk/x/staking/types" ) @@ -82,3 +83,24 @@ func (c *Converter) ValidatorFromCosmosValidator( SigningInfo: valSigningInfo, } } + +func (c *Converter) SetValidatorConsumerConsensusAddr(validator *types.Validator, consumerKey string) error { + consAddress, err := sdkTypes.ConsAddressFromBech32(consumerKey) + if err != nil { + return err + } + + validator.ConsensusAddressValcons = consAddress.String() + validator.ConsensusAddressHex = fmt.Sprintf("%x", consAddress) + + return nil +} + +func (c *Converter) GetConsKeyFromBech32(addr string) (string, error) { + consAddress, err := sdkTypes.ConsAddressFromBech32(addr) + if err != nil { + return "", err + } + + return consAddress.String(), nil +} diff --git a/pkg/data/manager.go b/pkg/data/manager.go index 76ebe61..7ea82eb 100644 --- a/pkg/data/manager.go +++ b/pkg/data/manager.go @@ -230,6 +230,9 @@ func (m *Manager) GetValidatorsAndSigningInfoForConsumerChain(height int64) (typ } validator := m.converter.ValidatorFromCosmosValidator(validatorRaw, &signingInfo) + if err := m.converter.SetValidatorConsumerConsensusAddr(validator, consensusAddr); err != nil { + m.logger.Warn().Err(err).Msg("Could not set validator consumer consensus address") + } mutex.Lock() validators[index] = validator