Skip to content

Commit

Permalink
chore: remove todo: "abstract out staking message back to staking" (#…
Browse files Browse the repository at this point in the history
…21266)

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
  • Loading branch information
zenzenless and coderabbitai[bot] authored Aug 14, 2024
1 parent cacea0f commit ec17e1e
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
15 changes: 10 additions & 5 deletions x/genutil/collect.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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)
}
}
Expand All @@ -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
}
5 changes: 5 additions & 0 deletions x/staking/types/msg.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit ec17e1e

Please sign in to comment.