Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: remove todo: "abstract out staking message back to staking" #21266

Merged
merged 7 commits into from
Aug 14, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions types/tx_msg.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ type (
GetMemo() string
}


// TxWithTimeoutTimeStamp extends the Tx interface by allowing a transaction to
// set a timeout timestamp.
TxWithTimeoutTimeStamp interface {
Expand Down
11 changes: 7 additions & 4 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,10 @@ 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 := msgs[0].(MsgWithMoniker)

// exclude itself from persistent peers
if msg.Description.Moniker != moniker {
if msg.GetMoniker() != moniker {
addressesIPs = append(addressesIPs, nodeAddrIP)
}
}
Expand All @@ -134,3 +132,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
}
zenzenless marked this conversation as resolved.
Show resolved Hide resolved
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
Loading