Skip to content

Commit

Permalink
refactor: clean up vestings module
Browse files Browse the repository at this point in the history
  • Loading branch information
Lockwarr committed Dec 22, 2023
1 parent 1f52c4f commit fc479da
Show file tree
Hide file tree
Showing 23 changed files with 100 additions and 1,618 deletions.
2 changes: 1 addition & 1 deletion app/keepers/keepers.go
Original file line number Diff line number Diff line change
Expand Up @@ -494,7 +494,7 @@ func (appKeepers *AppKeepers) NewAppKeepers(
appKeepers.keys[vestingstypes.MemStoreKey],
appKeepers.AccountKeeper,
appKeepers.BankKeeper,
appKeepers.GetSubspace(vestingstypes.ModuleName),
authtypes.NewModuleAddress(govtypes.ModuleName).String(),
)
appKeepers.VestingsModule = vestings.NewAppModule(appCodec, *appKeepers.VestingsKeeper)

Expand Down
4 changes: 2 additions & 2 deletions proto/buf.lock
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,5 @@ deps:
- remote: buf.build
owner: googleapis
repository: googleapis
commit: 711e289f6a384c4caeebaff7c6931ade
digest: shake256:e08fb55dad7469f69df00304eed31427d2d1576e9aab31e6bf86642688e04caaf0372f15fe6974cf79432779a635b3ea401ca69c943976dc42749524e4c25d94
commit: 28151c0d0a1641bf938a7672c500e01d
digest: shake256:49215edf8ef57f7863004539deff8834cfb2195113f0b890dd1f67815d9353e28e668019165b9d872395871eeafcbab3ccfdb2b5f11734d3cca95be9e8d139de
10 changes: 0 additions & 10 deletions proto/nolus/vestings/v1beta1/genesis.proto

This file was deleted.

9 changes: 0 additions & 9 deletions proto/nolus/vestings/v1beta1/params.proto

This file was deleted.

25 changes: 0 additions & 25 deletions proto/nolus/vestings/v1beta1/query.proto

This file was deleted.

15 changes: 8 additions & 7 deletions x/mint/abci.go
Original file line number Diff line number Diff line change
Expand Up @@ -192,11 +192,12 @@ func BeginBlocker(ctx sdk.Context, k keeper.Keeper) {
defer telemetry.ModuleSetGauge(types.ModuleName, float32(coinAmount.Uint64()), "minted_tokens")
}

ctx.EventManager().EmitEvent(
sdk.NewEvent(
types.EventTypeMint,
sdk.NewAttribute(types.AttributeKeyDenom, params.MintDenom),
sdk.NewAttribute(sdk.AttributeKeyAmount, coinAmount.String()),
),
)
// refactor: make sure event is emitted from the baseapp - https://github.com/cosmos/cosmos-sdk/blob/main/UPGRADING.md#all-2
// ctx.EventManager().EmitEvent(
// sdk.NewEvent(
// types.EventTypeMint,
// sdk.NewAttribute(types.AttributeKeyDenom, params.MintDenom),
// sdk.NewAttribute(sdk.AttributeKeyAmount, coinAmount.String()),
// ),
// )
}
9 changes: 5 additions & 4 deletions x/tax/keeper/taxdecorator.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,12 @@ func (dtd DeductTaxDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simulate bo
return ctx, err
}

events := sdk.Events{sdk.NewEvent(sdk.EventTypeTx,
sdk.NewAttribute(sdk.AttributeKeyFee, feeTx.GetFee().String()),
)}
// refactor: make sure event is emitted from the baseapp - https://github.com/cosmos/cosmos-sdk/blob/main/UPGRADING.md#all-2
// events := sdk.Events{sdk.NewEvent(sdk.EventTypeTx,
// sdk.NewAttribute(sdk.AttributeKeyFee, feeTx.GetFee().String()),
// )}

ctx.EventManager().EmitEvents(events)
// ctx.EventManager().EmitEvents(events)

return next(ctx, tx, simulate)
}
Expand Down
7 changes: 4 additions & 3 deletions x/tax/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,9 @@ import (
const ConsensusVersion = 3

var (
_ module.AppModule = AppModule{}
_ module.AppModuleBasic = AppModuleBasic{}
_ module.AppModule = AppModule{}
_ module.AppModuleBasic = AppModuleBasic{}
_ module.AppModuleSimulation = AppModule{}
)

// ----------------------------------------------------------------------------
Expand Down Expand Up @@ -140,7 +141,7 @@ func (am AppModule) RegisterServices(cfg module.Configurator) {

m := keeper.NewMigrator(am.keeper, am.legacySubspace)

if err := cfg.RegisterMigration(types.ModuleName, 1, m.Migrate2to3); err != nil {
if err := cfg.RegisterMigration(types.ModuleName, 2, m.Migrate2to3); err != nil {
panic(fmt.Sprintf("failed to migrate x/%s from version 2 to 3: %v", types.ModuleName, err))
}
}
Expand Down
55 changes: 0 additions & 55 deletions x/vestings/client/cli/query.go

This file was deleted.

20 changes: 0 additions & 20 deletions x/vestings/genesis.go

This file was deleted.

18 changes: 0 additions & 18 deletions x/vestings/keeper/grpc_query.go

This file was deleted.

51 changes: 26 additions & 25 deletions x/vestings/keeper/keeper.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,55 +8,56 @@ import (
storetypes "github.com/cosmos/cosmos-sdk/store/types"
sdk "github.com/cosmos/cosmos-sdk/types"
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
paramtypes "github.com/cosmos/cosmos-sdk/x/params/types"

"github.com/Nolus-Protocol/nolus-core/x/vestings/types"
)

type (
Keeper struct {
cdc codec.BinaryCodec
storeKey storetypes.StoreKey
memKey storetypes.StoreKey
type Keeper struct {
cdc codec.BinaryCodec
storeKey storetypes.StoreKey
memKey storetypes.StoreKey

accountKeeper types.AccountKeeper
bankKeeper types.BankKeeper
accountKeeper types.AccountKeeper
bankKeeper types.BankKeeper

paramstore paramtypes.Subspace
}
)
// the address capable of executing a MsgUpdateParams message. Typically, this
// should be the x/gov module account.
authority string
}

func NewKeeper(
cdc codec.BinaryCodec,
storeKey,
memKey storetypes.StoreKey,

accountKeeper types.AccountKeeper, bankKeeper types.BankKeeper, ps paramtypes.Subspace,
accountKeeper types.AccountKeeper,
bankKeeper types.BankKeeper,
authority string,
) *Keeper {
// set KeyTable if it has not already been set
if !ps.HasKeyTable() {
ps = ps.WithKeyTable(types.ParamKeyTable())
}

return &Keeper{
cdc: cdc,
storeKey: storeKey,
memKey: memKey,

accountKeeper: accountKeeper, bankKeeper: bankKeeper, paramstore: ps,
cdc: cdc,
storeKey: storeKey,
memKey: memKey,
accountKeeper: accountKeeper,
bankKeeper: bankKeeper,
authority: authority,
}
}

// GetAuthority returns the x/mint module's authority.
func (k Keeper) GetAuthority() string {
return k.authority
}

func (k Keeper) Logger(ctx sdk.Context) log.Logger {
return ctx.Logger().With("module", fmt.Sprintf("x/%s", types.ModuleName))
}

// GetModuleAccountBalance gets the airdrop coin balance of module account.
// GetModuleAccountAddress gets the module account address.
func (k Keeper) GetModuleAccountAddress(_ sdk.Context) sdk.AccAddress {
return k.accountKeeper.GetModuleAddress(types.ModuleName)
}

// GetModuleAccountBalance gets the airdrop coin balance of module account.
// GetModuleAccount gets the module account.
func (k Keeper) GetModuleAccount(ctx sdk.Context, moduleName string) authtypes.AccountI {
return k.accountKeeper.GetModuleAccount(ctx, moduleName)
}
22 changes: 11 additions & 11 deletions x/vestings/keeper/keeper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (

"github.com/cosmos/cosmos-sdk/client"
sdk "github.com/cosmos/cosmos-sdk/types"
moduletestutil "github.com/cosmos/cosmos-sdk/types/module/testutil"
"github.com/stretchr/testify/suite"

nolusapp "github.com/Nolus-Protocol/nolus-core/app"
Expand All @@ -18,18 +19,17 @@ type KeeperTestSuite struct {
txBuilder client.TxBuilder
}

// refactor: fix when simulation refactoring is done
// func (s *KeeperTestSuite) SetupTest(isCheckTx bool) {
// tempDir := s.T().TempDir()
// s.app, s.ctx = nolusapp.CreateTestApp(isCheckTx, tempDir)
// s.ctx = s.ctx.WithBlockHeight(1)
func (s *KeeperTestSuite) SetupTest(isCheckTx bool) {
tempDir := s.T().TempDir()
s.app, s.ctx = nolusapp.CreateTestApp(isCheckTx, tempDir)
s.ctx = s.ctx.WithBlockHeight(1)

// // set up TxConfig
// encodingConfig := sims.MakeTestEncodingConfig()
// s.clientCtx = client.Context{}.WithTxConfig(encodingConfig.TxConfig)
// s.txBuilder = s.clientCtx.TxConfig.NewTxBuilder()
// s.Require().NoError(s.txBuilder.SetMsgs([]sdk.Msg{}...))
// }
// set up TxConfig
encodingConfig := moduletestutil.MakeTestEncodingConfig()
s.clientCtx = client.Context{}.WithTxConfig(encodingConfig.TxConfig)
s.txBuilder = s.clientCtx.TxConfig.NewTxBuilder()
s.Require().NoError(s.txBuilder.SetMsgs([]sdk.Msg{}...))
}

func TestKeeperTestSuite(t *testing.T) {
suite.Run(t, new(KeeperTestSuite))
Expand Down
13 changes: 7 additions & 6 deletions x/vestings/keeper/msg_server_create_vesting_account.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,12 +76,13 @@ func (k msgServer) CreateVestingAccount(goCtx context.Context, msg *types.MsgCre
return nil, err
}

ctx.EventManager().EmitEvent(
sdk.NewEvent(
sdk.EventTypeMessage,
sdk.NewAttribute(sdk.AttributeKeyModule, vestingtypes.ModuleName),
),
)
// refactor: make sure event is commited from the baseapp - https://github.com/cosmos/cosmos-sdk/blob/main/UPGRADING.md#all-2
// ctx.EventManager().EmitEvent(
// sdk.NewEvent(
// sdk.EventTypeMessage,
// sdk.NewAttribute(sdk.AttributeKeyModule, vestingtypes.ModuleName),
// ),
// )

return &types.MsgCreateVestingAccountResponse{}, nil
}
17 changes: 0 additions & 17 deletions x/vestings/keeper/params.go

This file was deleted.

Loading

0 comments on commit fc479da

Please sign in to comment.