chore: remove todo: "abstract out staking message back to staking" (backport #21266) (#21299)

Co-authored-by: james.zhang <68689915+zenzenless@users.noreply.github.com>
This commit is contained in:
mergify[bot] 2024-08-14 10:21:13 +00:00 committed by GitHub
parent d32e1eab16
commit a7a9bcb0f7
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 15 additions and 5 deletions

View File

@ -12,7 +12,6 @@ import (
cfg "github.com/cometbft/cometbft/config"
"cosmossdk.io/core/address"
stakingtypes "cosmossdk.io/x/staking/types"
"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/codec"
@ -120,11 +119,12 @@ func CollectTxs(txJSONDecoder sdk.TxDecoder, moniker, genTxsDir string,
// genesis transactions must be single-message
msgs := genTx.GetMsgs()
// TODO abstract out staking message validation back to staking
msg := msgs[0].(*stakingtypes.MsgCreateValidator)
msg, ok := msgs[0].(msgWithMoniker)
if !ok {
return appGenTxs, persistentPeers, fmt.Errorf("expected msgWithMoniker, got %T", msgs[0])
}
// exclude itself from persistent peers
if msg.Description.Moniker != moniker {
if msg.GetMoniker() != moniker {
addressesIPs = append(addressesIPs, nodeAddrIP)
}
}
@ -134,3 +134,8 @@ func CollectTxs(txJSONDecoder sdk.TxDecoder, moniker, genTxsDir string,
return appGenTxs, persistentPeers, nil
}
// MsgWithMoniker must have GetMoniker() method to use CollectTx
type msgWithMoniker interface {
GetMoniker() string
}

View File

@ -90,6 +90,11 @@ func (msg MsgCreateValidator) Validate(ac address.Codec) error {
return nil
}
// GetMoniker returns the moniker of the validator
func (msg MsgCreateValidator) GetMoniker() string {
return msg.Description.GetMoniker()
}
// UnpackInterfaces implements UnpackInterfacesMessage.UnpackInterfaces
func (msg MsgCreateValidator) UnpackInterfaces(unpacker gogoprotoany.AnyUnpacker) error {
var pubKey cryptotypes.PubKey