Skip to content

Commit

Permalink
feat: simplify, remove msg server
Browse files Browse the repository at this point in the history
  • Loading branch information
boojamya committed Nov 8, 2024
1 parent 9884078 commit 6ded2c8
Show file tree
Hide file tree
Showing 11 changed files with 133 additions and 264 deletions.
186 changes: 86 additions & 100 deletions api/v1/tx.pulsar.go

Large diffs are not rendered by default.

39 changes: 0 additions & 39 deletions api/v1/tx_grpc.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

22 changes: 11 additions & 11 deletions client/cli/tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,8 @@ func NewCmdSubmitUpgrade() *cobra.Command {
cmd := &cobra.Command{
Use: "software-upgrade <name> [--upgrade-height <height>] [--upgrade-info <info>] [flags]",
Args: cobra.ExactArgs(1),
Short: "Submit a software upgrade proposal",
Long: "Submit a software upgrade along with an initial deposit.\n" +
Short: "Schedule a software upgrade on chain",
Long: "Schedule a software upgrade on chain.\n" +
"Please specify a unique name and height for the upgrade to take effect.\n" +
"You may include info to reference a binary download link, in a format compatible with: https://docs.cosmos.network/main/build/tooling/cosmovisor",
RunE: func(cmd *cobra.Command, args []string) error {
Expand Down Expand Up @@ -117,16 +117,16 @@ func NewCmdSubmitUpgrade() *cobra.Command {
}
}

msgs := []sdk.Msg{
&upgradetypes.MsgSoftwareUpgrade{
// AUTHORITY MODULE SPECIFIC
// set to from address, check in message server
Authority: clientCtx.FromAddress.String(),
Plan: p,
},
}
msgExecute := types.NewMsgExecute(
clientCtx.FromAddress.String(),
[]sdk.Msg{
&upgradetypes.MsgSoftwareUpgrade{
Authority: types.ModuleAddress.String(),
Plan: p,
},
})

return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msgs...)
return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msgExecute)
},
}

Expand Down
3 changes: 0 additions & 3 deletions keeper/keeper.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ type Keeper struct {
router baseapp.MessageRouter
accountKeeper types.AccountKeeper
bankKeeper types.BankKeeper
upgradeKeeper types.UpgradeKeeper
}

func NewKeeper(
Expand All @@ -37,7 +36,6 @@ func NewKeeper(
router baseapp.MessageRouter,
accountKeeper types.AccountKeeper,
bankKeeper types.BankKeeper,
upgradeKeeper types.UpgradeKeeper,
) *Keeper {
builder := collections.NewSchemaBuilder(storeService)

Expand All @@ -52,7 +50,6 @@ func NewKeeper(
router: router,
accountKeeper: accountKeeper,
bankKeeper: bankKeeper,
upgradeKeeper: upgradeKeeper,
}

schema, err := builder.Build()
Expand Down
15 changes: 0 additions & 15 deletions keeper/msg_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import (
"context"

"cosmossdk.io/errors"
upgradetypes "cosmossdk.io/x/upgrade/types"
abcitypes "github.com/cometbft/cometbft/abci/types"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/noble-assets/authority/types"
Expand Down Expand Up @@ -128,20 +127,6 @@ func (k msgServer) AcceptOwnership(ctx context.Context, msg *types.MsgAcceptOwne
})
}

func (k msgServer) SoftwareUpgrade(ctx context.Context, msg *upgradetypes.MsgSoftwareUpgrade) (*upgradetypes.MsgSoftwareUpgradeResponse, error) {
owner, _ := k.Owner.Get(ctx)
if msg.Authority != owner {
return nil, errors.Wrapf(types.ErrInvalidOwner, "expected %s, got %s", owner, msg.Authority)
}

err := k.upgradeKeeper.ScheduleUpgrade(ctx, msg.Plan)
if err != nil {
return nil, err
}

return &upgradetypes.MsgSoftwareUpgradeResponse{}, nil
}

//

func validateMsgs(msgs []sdk.Msg) error {
Expand Down
2 changes: 0 additions & 2 deletions module.go
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,6 @@ type ModuleInputs struct {
Router baseapp.MessageRouter
AccountKeeper types.AccountKeeper
BankKeeper types.BankKeeper
UpgradeKeeper types.UpgradeKeeper
}

type ModuleOutputs struct {
Expand All @@ -205,7 +204,6 @@ func ProvideModule(in ModuleInputs) ModuleOutputs {
in.Router,
in.AccountKeeper,
in.BankKeeper,
in.UpgradeKeeper,
)
m := NewAppModule(k, in.AccountKeeper)

Expand Down
3 changes: 0 additions & 3 deletions proto/noble/authority/v1/tx.proto
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ package noble.authority.v1;

import "amino/amino.proto";
import "cosmos/msg/v1/msg.proto";
import "cosmos/upgrade/v1beta1/tx.proto";
import "cosmos_proto/cosmos.proto";
import "gogoproto/gogo.proto";
import "google/protobuf/any.proto";
Expand All @@ -18,8 +17,6 @@ service Msg {

rpc TransferOwnership(MsgTransferOwnership) returns (MsgTransferOwnershipResponse);
rpc AcceptOwnership(MsgAcceptOwnership) returns (MsgAcceptOwnershipResponse);

rpc SoftwareUpgrade(cosmos.upgrade.v1beta1.MsgSoftwareUpgrade) returns (cosmos.upgrade.v1beta1.MsgSoftwareUpgradeResponse);
}

//
Expand Down
3 changes: 0 additions & 3 deletions types/codec.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
package types

import (
upgradetypes "cosmossdk.io/x/upgrade/types"
"github.com/cosmos/cosmos-sdk/codec"
codectypes "github.com/cosmos/cosmos-sdk/codec/types"
sdk "github.com/cosmos/cosmos-sdk/types"
Expand All @@ -18,15 +17,13 @@ func RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) {
cdc.RegisterConcrete(&MsgExecute{}, "noble/Execute", nil)
cdc.RegisterConcrete(&MsgTransferOwnership{}, "noble/TransferOwnership", nil)
cdc.RegisterConcrete(&MsgAcceptOwnership{}, "noble/AcceptOwnership", nil)
cdc.RegisterConcrete(&upgradetypes.MsgSoftwareUpgrade{}, "noble/SoftwareUpgrade", nil)
}

func RegisterInterfaces(registry codectypes.InterfaceRegistry) {
registry.RegisterImplementations((*sdk.Msg)(nil),
&MsgExecute{},
&MsgTransferOwnership{},
&MsgAcceptOwnership{},
&upgradetypes.MsgSoftwareUpgrade{},
)

msgservice.RegisterMsgServiceDesc(registry, &_Msg_serviceDesc)
Expand Down
5 changes: 0 additions & 5 deletions types/expected_keepers.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import (
"context"

"cosmossdk.io/core/address"
upgradetypes "cosmossdk.io/x/upgrade/types"
sdk "github.com/cosmos/cosmos-sdk/types"
)

Expand All @@ -23,7 +22,3 @@ type BankKeeper interface {
GetAllBalances(ctx context.Context, addr sdk.AccAddress) sdk.Coins
SendCoins(ctx context.Context, fromAddr, toAddr sdk.AccAddress, amt sdk.Coins) error
}

type UpgradeKeeper interface {
ScheduleUpgrade(ctx context.Context, plan upgradetypes.Plan) error
}
Loading

0 comments on commit 6ded2c8

Please sign in to comment.