Skip to content

Commit

Permalink
feat(vesting): update to sdk047
Browse files Browse the repository at this point in the history
  • Loading branch information
bdeneux committed Apr 7, 2023
1 parent e8d4f90 commit d823c27
Show file tree
Hide file tree
Showing 11 changed files with 1,357 additions and 1,212 deletions.
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -403,6 +403,7 @@ mock: ## Generate all the mocks (for tests)
@echo "${COLOR_CYAN} 🧱 Generating all the mocks${COLOR_RESET}"
@go install github.com/golang/mock/mockgen@v1.6.0
@mockgen -source=x/mint/types/expected_keepers.go -package testutil -destination x/mint/testutil/expected_keepers_mocks.go
@mockgen -source=x/vesting/types/expected_keepers.go -package testutil -destination x/vesting/testutil/expected_keepers_mocks.go
@mockgen -source=x/logic/types/expected_keepers.go -package testutil -destination x/logic/testutil/expected_keepers_mocks.go
@mockgen -destination x/logic/testutil/gas_mocks.go -package testutil github.com/cosmos/cosmos-sdk/store/types GasMeter
@mockgen -destination x/logic/testutil/fs_mocks.go -package testutil -source=x/logic/fs/fs.go
Expand Down
2 changes: 1 addition & 1 deletion app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -427,7 +427,7 @@ func New(
app.AccountKeeper,
app.BankKeeper,
authtypes.FeeCollectorName,
authtypes.NewModuleAddress(govtypes.ModuleName),
authtypes.NewModuleAddress(govtypes.ModuleName).String(),
)

app.DistrKeeper = distrkeeper.NewKeeper(
Expand Down
18 changes: 0 additions & 18 deletions x/vesting/client/testutil/cli_test.go

This file was deleted.

225 changes: 0 additions & 225 deletions x/vesting/client/testutil/suite.go

This file was deleted.

16 changes: 1 addition & 15 deletions x/vesting/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ package vesting
import (
"encoding/json"

abci "github.com/cometbft/cometbft/abci/types"
"github.com/grpc-ecosystem/grpc-gateway/runtime"
"github.com/spf13/cobra"
abci "github.com/tendermint/tendermint/abci/types"

"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/codec"
Expand Down Expand Up @@ -87,25 +87,11 @@ func NewAppModule(ak keeper.AccountKeeper, bk types.BankKeeper) AppModule {
// RegisterInvariants performs a no-op; there are no invariants to enforce.
func (AppModule) RegisterInvariants(_ sdk.InvariantRegistry) {}

// Deprecated: Route returns the module's message router and handler.
func (am AppModule) Route() sdk.Route {
return sdk.Route{}
}

// QuerierRoute returns an empty string as the module contains no query
// functionality.
func (AppModule) QuerierRoute() string { return "" }

// RegisterServices registers module services.
func (am AppModule) RegisterServices(cfg module.Configurator) {
types.RegisterMsgServer(cfg.MsgServer(), NewMsgServerImpl(am.accountKeeper, am.bankKeeper))
}

// LegacyQuerierHandler performs a no-op.
func (am AppModule) LegacyQuerierHandler(_ *codec.LegacyAmino) sdk.Querier {
return nil
}

// InitGenesis performs a no-op.
func (am AppModule) InitGenesis(_ sdk.Context, _ codec.JSONCodec, _ json.RawMessage) []abci.ValidatorUpdate {
return []abci.ValidatorUpdate{}
Expand Down
31 changes: 4 additions & 27 deletions x/vesting/msg_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,13 +87,6 @@ func (s msgServer) CreateVestingAccount(goCtx context.Context,
return nil, err
}

ctx.EventManager().EmitEvent(
sdk.NewEvent(
sdk.EventTypeMessage,
sdk.NewAttribute(sdk.AttributeKeyModule, types.AttributeValueCategory),
),
)

return &types.MsgCreateVestingAccountResponse{}, nil
}

Expand Down Expand Up @@ -150,13 +143,6 @@ func (s msgServer) CreatePermanentLockedAccount(goCtx context.Context,
return nil, err
}

ctx.EventManager().EmitEvent(
sdk.NewEvent(
sdk.EventTypeMessage,
sdk.NewAttribute(sdk.AttributeKeyModule, types.AttributeValueCategory),
),
)

return &types.MsgCreatePermanentLockedAccountResponse{}, nil
}

Expand Down Expand Up @@ -187,6 +173,10 @@ func (s msgServer) CreatePeriodicVestingAccount(goCtx context.Context,
totalCoins = totalCoins.Add(period.Amount...)
}

if err := bk.IsSendEnabledCoins(ctx, totalCoins...); err != nil {
return nil, err
}

baseAccount := authtypes.NewBaseAccountWithAddress(to)
baseAccount = ak.NewAccount(ctx, baseAccount).(*authtypes.BaseAccount)
vestingAccount := types.NewPeriodicVestingAccount(baseAccount, totalCoins.Sort(), msg.StartTime, msg.VestingPeriods)
Expand All @@ -212,12 +202,6 @@ func (s msgServer) CreatePeriodicVestingAccount(goCtx context.Context,
return nil, err
}

ctx.EventManager().EmitEvent(
sdk.NewEvent(
sdk.EventTypeMessage,
sdk.NewAttribute(sdk.AttributeKeyModule, types.AttributeValueCategory),
),
)
return &types.MsgCreatePeriodicVestingAccountResponse{}, nil
}

Expand Down Expand Up @@ -277,12 +261,5 @@ func (s msgServer) CreateCliffVestingAccount(goCtx context.Context,
return nil, err
}

ctx.EventManager().EmitEvent(
sdk.NewEvent(
sdk.EventTypeMessage,
sdk.NewAttribute(sdk.AttributeKeyModule, types.AttributeValueCategory),
),
)

return &types.MsgCreateCliffVestingAccountResponse{}, nil
}
Loading

0 comments on commit d823c27

Please sign in to comment.