Skip to content

Commit

Permalink
cleanup accountedpool module
Browse files Browse the repository at this point in the history
  • Loading branch information
jelysn committed Dec 13, 2023
1 parent 98e9d5b commit f29854e
Show file tree
Hide file tree
Showing 32 changed files with 66 additions and 1,066 deletions.
2 changes: 0 additions & 2 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -730,7 +730,6 @@ func NewElysApp(
appCodec,
keys[accountedpoolmoduletypes.StoreKey],
keys[accountedpoolmoduletypes.MemStoreKey],
app.GetSubspace(accountedpoolmoduletypes.ModuleName),
app.BankKeeper,
)
accountedPoolModule := accountedpoolmodule.NewAppModule(appCodec, app.AccountedPoolKeeper, app.AccountKeeper, app.BankKeeper)
Expand Down Expand Up @@ -1497,7 +1496,6 @@ func initParamsKeeper(appCodec codec.BinaryCodec, legacyAmino *codec.LegacyAmino
paramsKeeper.Subspace(burnermoduletypes.ModuleName)
paramsKeeper.Subspace(ammmoduletypes.ModuleName)
paramsKeeper.Subspace(marginmoduletypes.ModuleName)
paramsKeeper.Subspace(accountedpoolmoduletypes.ModuleName)
paramsKeeper.Subspace(transferhooktypes.ModuleName)
paramsKeeper.Subspace(clockmoduletypes.ModuleName)
paramsKeeper.Subspace(stablestaketypes.ModuleName)
Expand Down
3 changes: 0 additions & 3 deletions app/setup_handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import (
slashingtypes "github.com/cosmos/cosmos-sdk/x/slashing/types"
stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"
upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types"
accountedpooltypes "github.com/elys-network/elys/x/accountedpool/types"
ammtypes "github.com/elys-network/elys/x/amm/types"
assetprofiletypes "github.com/elys-network/elys/x/assetprofile/types"
burnertypes "github.com/elys-network/elys/x/burner/types"
Expand Down Expand Up @@ -79,8 +78,6 @@ func setUpgradeHandler(app *ElysApp) {
keyTable = oracletypes.ParamKeyTable() //nolint:staticcheck
case tokenomicstypes.ModuleName:
keyTable = tokenomicstypes.ParamKeyTable() //nolint:staticcheck
case accountedpooltypes.ModuleName:
keyTable = accountedpooltypes.ParamKeyTable() //nolint:staticcheck
case clocktypes.ModuleName:
keyTable = clocktypes.ParamKeyTable() //nolint:staticcheck
case transferhooktypes.ModuleName:
Expand Down
4 changes: 1 addition & 3 deletions proto/elys/accountedpool/genesis.proto
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,12 @@ syntax = "proto3";
package elys.accountedpool;

import "gogoproto/gogo.proto";
import "elys/accountedpool/params.proto";
import "elys/accountedpool/accounted_pool.proto";

option go_package = "github.com/elys-network/elys/x/accountedpool/types";

// GenesisState defines the tvl module's genesis state.
message GenesisState {
Params params = 1 [(gogoproto.nullable) = false];
repeated AccountedPool accounted_pool_list = 2 [(gogoproto.nullable) = false];
repeated AccountedPool accounted_pool_list = 1 [(gogoproto.nullable) = false];
}

11 changes: 0 additions & 11 deletions proto/elys/accountedpool/params.proto

This file was deleted.

19 changes: 0 additions & 19 deletions proto/elys/accountedpool/query.proto
Original file line number Diff line number Diff line change
Expand Up @@ -5,39 +5,20 @@ package elys.accountedpool;
import "gogoproto/gogo.proto";
import "google/api/annotations.proto";
import "cosmos/base/query/v1beta1/pagination.proto";
import "elys/accountedpool/params.proto";
import "elys/accountedpool/accounted_pool.proto";

option go_package = "github.com/elys-network/elys/x/accountedpool/types";

// Query defines the gRPC querier service.
service Query {

// Parameters queries the parameters of the module.
rpc Params (QueryParamsRequest) returns (QueryParamsResponse) {
option (google.api.http).get = "/elys-network/elys/accountedpool/params";

}

// Queries a list of AccountedPool items.
rpc AccountedPool (QueryGetAccountedPoolRequest) returns (QueryGetAccountedPoolResponse) {
option (google.api.http).get = "/elys-network/elys/accountedpool/accounted_pool/{pool_id}";

}
rpc AccountedPoolAll (QueryAllAccountedPoolRequest) returns (QueryAllAccountedPoolResponse) {
option (google.api.http).get = "/elys-network/elys/accountedpool/accounted_pool";

}
}
// QueryParamsRequest is request type for the Query/Params RPC method.
message QueryParamsRequest {}

// QueryParamsResponse is response type for the Query/Params RPC method.
message QueryParamsResponse {

// params holds all the parameters of this module.
Params params = 1 [(gogoproto.nullable) = false];
}

message QueryGetAccountedPoolRequest {
uint64 pool_id = 1;
Expand Down
1 change: 0 additions & 1 deletion wasmbindings/types/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,6 @@ func AllCapabilities() []string {

type ElysQuery struct {
// accountedpool queriers
AccountedPoolParams *accountedpooltypes.QueryParamsRequest `json:"accounted_pool_params,omitempty"`
AccountedPoolAccountedPool *accountedpooltypes.QueryGetAccountedPoolRequest `json:"accounted_pool_accounted_pool,omitempty"`
AccountedPoolAccountedPoolAll *accountedpooltypes.QueryAllAccountedPoolRequest `json:"accounted_pool_accounted_pool_all,omitempty"`

Expand Down
1 change: 0 additions & 1 deletion x/accountedpool/client/cli/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ func GetQueryCmd(queryRoute string) *cobra.Command {
RunE: client.ValidateCmd,
}

cmd.AddCommand(CmdQueryParams())
cmd.AddCommand(CmdListAccountedPool())
cmd.AddCommand(CmdShowAccountedPool())
// this line is used by starport scaffolding # 1
Expand Down
5 changes: 2 additions & 3 deletions x/accountedpool/client/cli/query_accounted_pool.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (
func CmdListAccountedPool() *cobra.Command {
cmd := &cobra.Command{
Use: "list-accounted-pool",
Short: "list all accounted-pool",
Short: "list all accounted pools",
RunE: func(cmd *cobra.Command, args []string) error {
clientCtx, err := client.GetClientQueryContext(cmd)
if err != nil {
Expand Down Expand Up @@ -59,8 +59,7 @@ func CmdShowAccountedPool() *cobra.Command {

queryClient := types.NewQueryClient(clientCtx)

argIndex := args[0]
poolId, err := strconv.ParseUint(argIndex, 10, 64)
poolId, err := strconv.ParseUint(args[0], 10, 64)
if err != nil {
return err
}
Expand Down
36 changes: 0 additions & 36 deletions x/accountedpool/client/cli/query_params.go

This file was deleted.

2 changes: 0 additions & 2 deletions x/accountedpool/client/wasm/querier.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@ func NewQuerier(keeper *keeper.Keeper) *Querier {

func (oq *Querier) HandleQuery(ctx sdk.Context, query wasmbindingstypes.ElysQuery) ([]byte, error) {
switch {
case query.AccountedPoolParams != nil:
return oq.queryParams(ctx, query.AccountedPoolParams)
case query.AccountedPoolAccountedPool != nil:
return oq.queryAccountedPool(ctx, query.AccountedPoolAccountedPool)
case query.AccountedPoolAccountedPoolAll != nil:
Expand Down
22 changes: 0 additions & 22 deletions x/accountedpool/client/wasm/query_params.go

This file was deleted.

3 changes: 0 additions & 3 deletions x/accountedpool/genesis.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,11 @@ func InitGenesis(ctx sdk.Context, k keeper.Keeper, genState types.GenesisState)
for _, elem := range genState.AccountedPoolList {
k.SetAccountedPool(ctx, elem)
}
// this line is used by starport scaffolding # genesis/module/init
k.SetParams(ctx, &genState.Params)
}

// ExportGenesis returns the module's exported genesis
func ExportGenesis(ctx sdk.Context, k keeper.Keeper) *types.GenesisState {
genesis := types.DefaultGenesis()
genesis.Params = k.GetParams(ctx)

genesis.AccountedPoolList = k.GetAllAccountedPool(ctx)
// this line is used by starport scaffolding # genesis/module/export
Expand Down
2 changes: 0 additions & 2 deletions x/accountedpool/genesis_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@ import (

func TestGenesis(t *testing.T) {
genesisState := types.GenesisState{
Params: types.DefaultParams(),

AccountedPoolList: []types.AccountedPool{
{
PoolId: (uint64)(0),
Expand Down
23 changes: 5 additions & 18 deletions x/accountedpool/keeper/accounted_pool.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,22 +10,14 @@ import (
func (k Keeper) SetAccountedPool(ctx sdk.Context, accountedPool types.AccountedPool) {
store := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefix(types.AccountedPoolKeyPrefix))
b := k.cdc.MustMarshal(&accountedPool)
store.Set(types.AccountedPoolKey(
accountedPool.PoolId,
), b)
store.Set(types.AccountedPoolKey(accountedPool.PoolId), b)
}

// GetAccountedPool returns a accountedPool from its index
func (k Keeper) GetAccountedPool(
ctx sdk.Context,
PoolId uint64,
) (val types.AccountedPool, found bool) {
func (k Keeper) GetAccountedPool(ctx sdk.Context, PoolId uint64) (val types.AccountedPool, found bool) {
store := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefix(types.AccountedPoolKeyPrefix))

b := store.Get(types.AccountedPoolKey(
PoolId,
))

b := store.Get(types.AccountedPoolKey(PoolId))
if b == nil {
return val, false
}
Expand All @@ -35,14 +27,9 @@ func (k Keeper) GetAccountedPool(
}

// RemoveAccountedPool removes a accountedPool from the store
func (k Keeper) RemoveAccountedPool(
ctx sdk.Context,
poolId uint64,
) {
func (k Keeper) RemoveAccountedPool(ctx sdk.Context, poolId uint64) {
store := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefix(types.AccountedPoolKeyPrefix))
store.Delete(types.AccountedPoolKey(
poolId,
))
store.Delete(types.AccountedPoolKey(poolId))
}

// GetAllAccountedPool returns all accountedPool
Expand Down
4 changes: 1 addition & 3 deletions x/accountedpool/keeper/accounted_pool_initiate.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
package keeper

import (
"errors"

sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/elys-network/elys/x/accountedpool/types"
ammtypes "github.com/elys-network/elys/x/amm/types"
Expand All @@ -13,7 +11,7 @@ func (k Keeper) InitiateAccountedPool(ctx sdk.Context, ammPool ammtypes.Pool) er
// Check if already exists
exists := k.PoolExists(ctx, poolId)
if exists {
return errors.New("already existed pool!")
return types.ErrPoolDoesNotExist
}

// Initiate pool
Expand Down
7 changes: 3 additions & 4 deletions x/accountedpool/keeper/accounted_pool_update.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
package keeper

import (
"errors"

sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/elys-network/elys/x/accountedpool/types"
ammtypes "github.com/elys-network/elys/x/amm/types"
margintypes "github.com/elys-network/elys/x/margin/types"
)
Expand All @@ -13,13 +12,13 @@ func (k Keeper) UpdateAccountedPool(ctx sdk.Context, ammPool ammtypes.Pool, marg
// Check if already exists
exists := k.PoolExists(ctx, poolId)
if !exists {
return errors.New("pool doesn't exist!")
return types.ErrPoolDoesNotExist
}

// Get accounted pool
accountedPool, found := k.GetAccountedPool(ctx, poolId)
if !found {
return errors.New("pool doesn't exist!")
return types.ErrPoolDoesNotExist
}

// Accounted Pool balance =
Expand Down
9 changes: 0 additions & 9 deletions x/accountedpool/keeper/keeper.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import (
"github.com/cosmos/cosmos-sdk/codec"
storetypes "github.com/cosmos/cosmos-sdk/store/types"
sdk "github.com/cosmos/cosmos-sdk/types"
paramtypes "github.com/cosmos/cosmos-sdk/x/params/types"

"github.com/elys-network/elys/x/accountedpool/types"
)
Expand All @@ -17,7 +16,6 @@ type (
cdc codec.BinaryCodec
storeKey storetypes.StoreKey
memKey storetypes.StoreKey
paramstore paramtypes.Subspace
bankKeeper types.BankKeeper
}
)
Expand All @@ -26,19 +24,12 @@ func NewKeeper(
cdc codec.BinaryCodec,
storeKey,
memKey storetypes.StoreKey,
ps paramtypes.Subspace,
bk types.BankKeeper,
) *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,
paramstore: ps,
bankKeeper: bk,
}
}
Expand Down
34 changes: 0 additions & 34 deletions x/accountedpool/keeper/params.go

This file was deleted.

Loading

0 comments on commit f29854e

Please sign in to comment.