-
Notifications
You must be signed in to change notification settings - Fork 95
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #301 from ComposableFi/configure-staking-middlewar…
…e-module-into-cosmos-chain integrate staking middleware module into cosmos chain
- Loading branch information
Showing
10 changed files
with
201 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
package types | ||
|
||
import ( | ||
"github.com/cosmos/cosmos-sdk/codec" | ||
"github.com/cosmos/cosmos-sdk/codec/legacy" | ||
codectypes "github.com/cosmos/cosmos-sdk/codec/types" | ||
cryptocodec "github.com/cosmos/cosmos-sdk/crypto/codec" | ||
"github.com/cosmos/cosmos-sdk/types/msgservice" | ||
authzcodec "github.com/cosmos/cosmos-sdk/x/authz/codec" | ||
govcodec "github.com/cosmos/cosmos-sdk/x/gov/codec" | ||
groupcodec "github.com/cosmos/cosmos-sdk/x/group/codec" | ||
|
||
sdk "github.com/cosmos/cosmos-sdk/types" | ||
) | ||
|
||
// RegisterLegacyAminoCodec registers the account interfaces and concrete types on the | ||
// provided LegacyAmino codec. These types are used for Amino JSON serialization | ||
func RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) { | ||
legacy.RegisterAminoMsg(cdc, &MsgSetPower{}, "composable/MsgSetPower") | ||
} | ||
|
||
func RegisterInterfaces(registry codectypes.InterfaceRegistry) { | ||
registry.RegisterImplementations( | ||
(*sdk.Msg)(nil), | ||
&MsgSetPower{}, | ||
) | ||
msgservice.RegisterMsgServiceDesc(registry, &_Msg_serviceDesc) | ||
} | ||
|
||
var ( | ||
amino = codec.NewLegacyAmino() | ||
ModuleCdc = codec.NewAminoCodec(amino) | ||
) | ||
|
||
func init() { | ||
RegisterLegacyAminoCodec(amino) | ||
cryptocodec.RegisterCrypto(amino) | ||
sdk.RegisterLegacyAminoCodec(amino) | ||
|
||
// Register all Amino interfaces and concrete types on the authz and gov Amino codec so that this can later be | ||
// used to properly serialize MsgGrant, MsgExec and MsgSubmitProposal instances | ||
RegisterLegacyAminoCodec(authzcodec.Amino) | ||
RegisterLegacyAminoCodec(govcodec.Amino) | ||
RegisterLegacyAminoCodec(groupcodec.Amino) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
package types | ||
|
||
import ( | ||
errorsmod "cosmossdk.io/errors" | ||
"github.com/cosmos/cosmos-sdk/codec/legacy" | ||
sdk "github.com/cosmos/cosmos-sdk/types" | ||
) | ||
|
||
var _ sdk.Msg = &MsgSetPower{} | ||
|
||
// Route Implements Msg. | ||
func (m MsgSetPower) Route() string { return sdk.MsgTypeURL(&m) } | ||
|
||
// Type Implements Msg. | ||
func (m MsgSetPower) Type() string { return sdk.MsgTypeURL(&m) } | ||
|
||
// GetSigners returns the expected signers for a MsgMintAndAllocateExp . | ||
func (m MsgSetPower) GetSigners() []sdk.AccAddress { | ||
daoAccount, err := sdk.AccAddressFromBech32(m.FromAddress) | ||
if err != nil { | ||
panic(err) | ||
} | ||
return []sdk.AccAddress{daoAccount} | ||
} | ||
|
||
// GetSignBytes Implements Msg. | ||
func (m MsgSetPower) GetSignBytes() []byte { | ||
return sdk.MustSortJSON(legacy.Cdc.MustMarshalJSON(&m)) | ||
} | ||
|
||
// ValidateBasic does a sanity check on the provided data. | ||
func (m MsgSetPower) ValidateBasic() error { | ||
_, err := sdk.AccAddressFromBech32(m.FromAddress) | ||
if err != nil { | ||
return errorsmod.Wrap(err, "from address must be valid address") | ||
} | ||
return nil | ||
} | ||
|
||
func NewMsgSetPower(fromAddr sdk.AccAddress) *MsgSetPower { | ||
return &MsgSetPower{ | ||
FromAddress: fromAddr.String(), | ||
} | ||
} |
Oops, something went wrong.