Skip to content

Commit

Permalink
fix: msgs interface types
Browse files Browse the repository at this point in the history
  • Loading branch information
emidev98 committed Oct 29, 2023
1 parent aab8046 commit a3bff65
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 0 deletions.
13 changes: 13 additions & 0 deletions x/lifecycle-hooks/types/codec.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ package types
import (
"github.com/cosmos/cosmos-sdk/codec"
cdctypes "github.com/cosmos/cosmos-sdk/codec/types"
sdk "github.com/cosmos/cosmos-sdk/types"
govtypes "github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1"

// this line is used by starport scaffolding # 1
"github.com/cosmos/cosmos-sdk/types/msgservice"
)
Expand All @@ -13,6 +16,16 @@ func RegisterCodec(cdc *codec.LegacyAmino) {

func RegisterInterfaces(registry cdctypes.InterfaceRegistry) {
// this line is used by starport scaffolding # 3
registry.RegisterImplementations((*sdk.Msg)(nil),
&MsgFundExistentContract{},
)

registry.RegisterImplementations((*govtypes.Content)(nil),
&MsgUpdateParamsProposal{},
&MsgRegisterContractProposal{},
&MsgModifyContractProposal{},
&MsgRemoveContractProposal{},
)

msgservice.RegisterMsgServiceDesc(registry, &_Msg_serviceDesc)
}
Expand Down
45 changes: 45 additions & 0 deletions x/lifecycle-hooks/types/gov.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@ var (
_ govtypes.Content = &MsgRegisterContractProposal{}
_ govtypes.Content = &MsgModifyContractProposal{}
_ govtypes.Content = &MsgRemoveContractProposal{}

_ sdk.Msg = &MsgUpdateParamsProposal{}
_ sdk.Msg = &MsgRegisterContractProposal{}
_ sdk.Msg = &MsgModifyContractProposal{}
_ sdk.Msg = &MsgRemoveContractProposal{}
)

func init() {
Expand All @@ -43,6 +48,16 @@ func NewMsgCreateAllianceProposal(
},
}
}
func (m MsgUpdateParamsProposal) GetSignBytes() []byte {
return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(&m))
}
func (m MsgUpdateParamsProposal) GetSigners() []sdk.AccAddress {
signer, err := sdk.AccAddressFromBech32(m.Authority)
if err != nil {
panic(ErrorInvalidSigner)
}
return []sdk.AccAddress{signer}
}
func (m *MsgUpdateParamsProposal) ProposalRoute() string { return RouterKey }
func (m *MsgUpdateParamsProposal) ProposalType() string { return UpdateParamsProposalType }
func (m *MsgUpdateParamsProposal) ValidateBasic() error {
Expand Down Expand Up @@ -78,6 +93,16 @@ func NewMsgRegisterContractProposal(
ExecutionBlocksFrequency: executionBlocksFrequency,
}
}
func (m MsgRegisterContractProposal) GetSignBytes() []byte {
return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(&m))
}
func (m MsgRegisterContractProposal) GetSigners() []sdk.AccAddress {
signer, err := sdk.AccAddressFromBech32(m.Authority)
if err != nil {
panic(ErrorInvalidSigner)
}
return []sdk.AccAddress{signer}
}
func (m *MsgRegisterContractProposal) ProposalRoute() string { return RouterKey }
func (m *MsgRegisterContractProposal) ProposalType() string { return UpdateParamsProposalType }
func (m *MsgRegisterContractProposal) ValidateBasic() error {
Expand Down Expand Up @@ -112,6 +137,16 @@ func NewMsgModifyContractProposal(
ExecutionBlocksFrequency: executionBlocksFrequency,
}
}
func (m MsgModifyContractProposal) GetSignBytes() []byte {
return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(&m))
}
func (m MsgModifyContractProposal) GetSigners() []sdk.AccAddress {
signer, err := sdk.AccAddressFromBech32(m.Authority)
if err != nil {
panic(ErrorInvalidSigner)
}
return []sdk.AccAddress{signer}
}
func (m *MsgModifyContractProposal) ProposalRoute() string { return RouterKey }
func (m *MsgModifyContractProposal) ProposalType() string { return UpdateParamsProposalType }
func (m *MsgModifyContractProposal) ValidateBasic() error {
Expand Down Expand Up @@ -143,6 +178,16 @@ func NewMsgRemoveContractProposal(
DepositRefundAccount: depositRefundAccount,
}
}
func (m MsgRemoveContractProposal) GetSignBytes() []byte {
return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(&m))
}
func (m MsgRemoveContractProposal) GetSigners() []sdk.AccAddress {
signer, err := sdk.AccAddressFromBech32(m.Authority)
if err != nil {
panic(ErrorInvalidSigner)
}
return []sdk.AccAddress{signer}
}
func (m *MsgRemoveContractProposal) ProposalRoute() string { return RouterKey }
func (m *MsgRemoveContractProposal) ProposalType() string { return UpdateParamsProposalType }
func (m *MsgRemoveContractProposal) ValidateBasic() error {
Expand Down

0 comments on commit a3bff65

Please sign in to comment.