Skip to content

Commit

Permalink
Merge pull request #545 from comdex-official/feature/dev
Browse files Browse the repository at this point in the history
Feature/dev
  • Loading branch information
dheerajkd30 authored Oct 25, 2022
2 parents e438186 + 059a10e commit e94d78d
Show file tree
Hide file tree
Showing 9 changed files with 44 additions and 92 deletions.
9 changes: 3 additions & 6 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -840,14 +840,11 @@ func New(
bandoracleModule,
liquidation.NewAppModule(app.cdc, app.LiquidationKeeper, app.AccountKeeper, app.BankKeeper),
locker.NewAppModule(app.cdc, app.LockerKeeper, app.AccountKeeper, app.BankKeeper),
collector.NewAppModule(app.cdc, app.CollectorKeeper, app.AccountKeeper, app.BankKeeper, app.AssetKeeper,
app.AuctionKeeper, app.LockerKeeper, app.Rewardskeeper),
esm.NewAppModule(app.cdc, app.EsmKeeper, app.AccountKeeper, app.BankKeeper, app.AssetKeeper, app.VaultKeeper,
app.MarketKeeper, app.TokenmintKeeper, app.CollectorKeeper),
collector.NewAppModule(app.cdc, app.CollectorKeeper, app.AccountKeeper, app.BankKeeper),
esm.NewAppModule(app.cdc, app.EsmKeeper, app.AccountKeeper, app.BankKeeper, app.AssetKeeper),
lend.NewAppModule(app.cdc, app.LendKeeper, app.AccountKeeper, app.BankKeeper),
wasm.NewAppModule(app.cdc, &app.WasmKeeper, app.StakingKeeper, app.AccountKeeper, app.BankKeeper),
auction.NewAppModule(app.cdc, app.AuctionKeeper, app.AccountKeeper, app.BankKeeper, app.CollectorKeeper,
app.LiquidationKeeper, app.AssetKeeper, app.MarketKeeper, app.EsmKeeper, app.VaultKeeper, app.TokenmintKeeper),
auction.NewAppModule(app.cdc, app.AuctionKeeper, app.AccountKeeper, app.BankKeeper, app.CollectorKeeper, app.AssetKeeper, app.EsmKeeper),
tokenmint.NewAppModule(app.cdc, app.TokenmintKeeper, app.AccountKeeper, app.BankKeeper),
liquidity.NewAppModule(app.cdc, app.LiquidityKeeper, app.AccountKeeper, app.BankKeeper, app.AssetKeeper),
rewards.NewAppModule(app.cdc, app.Rewardskeeper, app.AccountKeeper, app.BankKeeper),
Expand Down
24 changes: 12 additions & 12 deletions app/upgrades/mainnet/v5/upgrades.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,15 +51,15 @@ func InitializeStates(
}

assets := []assettypes.Asset{
{Name: "atom", Denom: "uatom", Decimals: 1000000, IsOnChain: false, IsOraclePriceRequired: true},
{Name: "cmdx", Denom: "ucmdx", Decimals: 1000000, IsOnChain: false, IsOraclePriceRequired: true},
{Name: "cmst", Denom: "ucmst", Decimals: 1000000, IsOnChain: false, IsOraclePriceRequired: false},
{Name: "osmo", Denom: "uosmo", Decimals: 1000000, IsOnChain: false, IsOraclePriceRequired: true},
{Name: "catom", Denom: "ucatom", Decimals: 1000000, IsOnChain: false, IsOraclePriceRequired: false},
{Name: "ccmdx", Denom: "uccmdx", Decimals: 1000000, IsOnChain: false, IsOraclePriceRequired: false},
{Name: "ccmst", Denom: "uccmst", Decimals: 1000000, IsOnChain: false, IsOraclePriceRequired: false},
{Name: "cosmo", Denom: "ucosmo", Decimals: 1000000, IsOnChain: false, IsOraclePriceRequired: false},
{Name: "harbor", Denom: "uharbor", Decimals: 1000000, IsOnChain: true, IsOraclePriceRequired: false},
{Name: "ATOM", Denom: "uatom", Decimals: 1000000, IsOnChain: false, IsOraclePriceRequired: true},
{Name: "CMDX", Denom: "ucmdx", Decimals: 1000000, IsOnChain: false, IsOraclePriceRequired: true},
{Name: "CMST", Denom: "ucmst", Decimals: 1000000, IsOnChain: false, IsOraclePriceRequired: false},
{Name: "OSMO", Denom: "uosmo", Decimals: 1000000, IsOnChain: false, IsOraclePriceRequired: true},
{Name: "CATOM", Denom: "ucatom", Decimals: 1000000, IsOnChain: false, IsOraclePriceRequired: false},
{Name: "CCMDX", Denom: "uccmdx", Decimals: 1000000, IsOnChain: false, IsOraclePriceRequired: false},
{Name: "CCMST", Denom: "uccmst", Decimals: 1000000, IsOnChain: false, IsOraclePriceRequired: false},
{Name: "COSMO", Denom: "ucosmo", Decimals: 1000000, IsOnChain: false, IsOraclePriceRequired: false},
{Name: "HARBOR", Denom: "uharbor", Decimals: 1000000, IsOnChain: true, IsOraclePriceRequired: false},
}

for _, asset := range assets {
Expand Down Expand Up @@ -194,7 +194,7 @@ func InitializeStates(
AppId: 2,
AssetId: 3,
}
_, err = lockerKeeper.AddWhiteListedAsset(ctx.Context(), &locker)
_, err = lockerKeeper.AddWhiteListedAsset(ctx, &locker)
if err != nil {
panic(err)
}
Expand All @@ -203,15 +203,15 @@ func InitializeStates(
AppMappingId: 2,
AssetId: 3,
}
_, err = rewardsKeeper.Whitelist(sdk.WrapSDKContext(ctx), &reward)
_, err = rewardsKeeper.Whitelist(ctx, &reward)
if err != nil {
panic(err)
}
// whitlist for vaultInterest
vInterest := rewardstypes.WhitelistAppIdVault{
AppMappingId: 2,
}
_, err = rewardsKeeper.WhitelistAppVault(ctx.Context(), &vInterest)
_, err = rewardsKeeper.WhitelistAppVault(ctx, &vInterest)
if err != nil {
panic(err)
}
Expand Down
6 changes: 3 additions & 3 deletions app/wasm/message_plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ func WhiteListAsset(lockerKeeper lockerkeeper.Keeper, ctx sdk.Context, contractA
AppId: whiteListAsset.AppID,
AssetId: whiteListAsset.AssetID,
}
_, err := lockerKeeper.AddWhiteListedAsset(sdk.WrapSDKContext(ctx), &msg)
_, err := lockerKeeper.AddWhiteListedAsset(ctx, &msg)
if err != nil {
return err
}
Expand All @@ -168,7 +168,7 @@ func WhitelistAppIDLockerRewards(rewardsKeeper rewardskeeper.Keeper, ctx sdk.Con
AppMappingId: whiteListAsset.AppID,
AssetId: whiteListAsset.AssetID,
}
_, err := rewardsKeeper.Whitelist(sdk.WrapSDKContext(ctx), &msg)
_, err := rewardsKeeper.Whitelist(ctx, &msg)
if err != nil {
return err
}
Expand All @@ -191,7 +191,7 @@ func WhitelistAppIDVaultInterest(rewardsKeeper rewardskeeper.Keeper, ctx sdk.Con
From: contractAddr,
AppMappingId: whiteListAsset.AppID,
}
_, err := rewardsKeeper.WhitelistAppVault(sdk.WrapSDKContext(ctx), &msg)
_, err := rewardsKeeper.WhitelistAppVault(ctx, &msg)
if err != nil {
return err
}
Expand Down
38 changes: 13 additions & 25 deletions x/auction/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,16 +100,12 @@ func (AppModuleBasic) GetQueryCmd() *cobra.Command {
type AppModule struct {
AppModuleBasic

keeper keeper.Keeper
accountKeeper expected.AccountKeeper
bankKeeper expected.BankKeeper
collectKeeper expected.CollectorKeeper
liquidationKeeper expected.LiquidationKeeper
assetKeeper expected.AssetKeeper
marketKeeper expected.MarketKeeper
esmKeeper expected.EsmKeeper
vaultKeeper expected.VaultKeeper
tokenMintKeeper expected.TokenMintKeeper
keeper keeper.Keeper
accountKeeper expected.AccountKeeper
bankKeeper expected.BankKeeper
collectKeeper expected.CollectorKeeper
assetKeeper expected.AssetKeeper
esmKeeper expected.EsmKeeper
}

func NewAppModule(
Expand All @@ -118,25 +114,17 @@ func NewAppModule(
accountKeeper expected.AccountKeeper,
bankKeeper expected.BankKeeper,
collectorKeeper expected.CollectorKeeper,
liquidationKeeper expected.LiquidationKeeper,
assetKeeper expected.AssetKeeper,
marketKeeper expected.MarketKeeper,
esmKeeper expected.EsmKeeper,
vaultKeeper expected.VaultKeeper,
tokenMintKeeper expected.TokenMintKeeper,
) AppModule {
return AppModule{
AppModuleBasic: NewAppModuleBasic(cdc),
keeper: keeper,
accountKeeper: accountKeeper,
bankKeeper: bankKeeper,
collectKeeper: collectorKeeper,
liquidationKeeper: liquidationKeeper,
assetKeeper: assetKeeper,
marketKeeper: marketKeeper,
esmKeeper: esmKeeper,
vaultKeeper: vaultKeeper,
tokenMintKeeper: tokenMintKeeper,
AppModuleBasic: NewAppModuleBasic(cdc),
keeper: keeper,
accountKeeper: accountKeeper,
bankKeeper: bankKeeper,
collectKeeper: collectorKeeper,
assetKeeper: assetKeeper,
esmKeeper: esmKeeper,
}
}

Expand Down
14 changes: 0 additions & 14 deletions x/collector/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ import (
"encoding/json"
"fmt"

"github.com/comdex-official/comdex/x/collector/expected"

"github.com/gorilla/mux"
"github.com/grpc-ecosystem/grpc-gateway/runtime"
"github.com/spf13/cobra"
Expand Down Expand Up @@ -100,31 +98,19 @@ type AppModule struct {
keeper keeper.Keeper
accountKeeper types.AccountKeeper
bankKeeper types.BankKeeper
assetKeeper expected.AssetKeeper
auctionKeeper expected.AuctionKeeper
lockerKeeper expected.LockerKeeper
rewardsKeeper expected.RewardsKeeper
}

func NewAppModule(
cdc codec.Codec,
keeper keeper.Keeper,
accountKeeper types.AccountKeeper,
bankKeeper types.BankKeeper,
assetKeeper expected.AssetKeeper,
auctionKeeper expected.AuctionKeeper,
lockerKeeper expected.LockerKeeper,
rewardsKeeper expected.RewardsKeeper,
) AppModule {
return AppModule{
AppModuleBasic: NewAppModuleBasic(cdc),
keeper: keeper,
accountKeeper: accountKeeper,
bankKeeper: bankKeeper,
assetKeeper: assetKeeper,
auctionKeeper: auctionKeeper,
lockerKeeper: lockerKeeper,
rewardsKeeper: rewardsKeeper,
}
}

Expand Down
30 changes: 9 additions & 21 deletions x/esm/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,14 +101,10 @@ func (AppModuleBasic) GetQueryCmd() *cobra.Command {
type AppModule struct {
AppModuleBasic

keeper keeper.Keeper
accountKeeper types.AccountKeeper
bankKeeper types.BankKeeper
assetKeeper expected.AssetKeeper
vaultKeeper expected.VaultKeeper
marketKeeper expected.MarketKeeper
tokenMintKeeper expected.Tokenmint
collectKeeper expected.Collector
keeper keeper.Keeper
accountKeeper types.AccountKeeper
bankKeeper types.BankKeeper
assetKeeper expected.AssetKeeper
}

func NewAppModule(
Expand All @@ -117,21 +113,13 @@ func NewAppModule(
accountKeeper types.AccountKeeper,
bankKeeper types.BankKeeper,
assetKeeper expected.AssetKeeper,
vaultKeeper expected.VaultKeeper,
marketKeeper expected.MarketKeeper,
tokenMintKeeper expected.Tokenmint,
collectKeeper expected.Collector,
) AppModule {
return AppModule{
AppModuleBasic: NewAppModuleBasic(cdc),
keeper: keeper,
accountKeeper: accountKeeper,
bankKeeper: bankKeeper,
assetKeeper: assetKeeper,
vaultKeeper: vaultKeeper,
marketKeeper: marketKeeper,
tokenMintKeeper: tokenMintKeeper,
collectKeeper: collectKeeper,
AppModuleBasic: NewAppModuleBasic(cdc),
keeper: keeper,
accountKeeper: accountKeeper,
bankKeeper: bankKeeper,
assetKeeper: assetKeeper,
}
}

Expand Down
5 changes: 1 addition & 4 deletions x/locker/keeper/locker.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
package keeper

import (
"context"

sdk "github.com/cosmos/cosmos-sdk/types"
protobuftypes "github.com/gogo/protobuf/types"

Expand Down Expand Up @@ -446,8 +444,7 @@ func (k Keeper) WasmAddWhiteListedAssetQuery(ctx sdk.Context, appMappingID, Asse
return true, ""
}

func (k Keeper) AddWhiteListedAsset(c context.Context, msg *types.MsgAddWhiteListedAssetRequest) (*types.MsgAddWhiteListedAssetResponse, error) {
ctx := sdk.UnwrapSDKContext(c)
func (k Keeper) AddWhiteListedAsset(ctx sdk.Context, msg *types.MsgAddWhiteListedAssetRequest) (*types.MsgAddWhiteListedAssetResponse, error) {
esmStatus, found := k.esm.GetESMStatus(ctx, msg.AppId)
status := false
if found {
Expand Down
2 changes: 1 addition & 1 deletion x/locker/keeper/locker_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ func (s *KeeperTestSuite) TestCreateLocker() {
},
} {
s.Run(tc.name, func() {
_, err := lockerKeeper.AddWhiteListedAsset(sdk.WrapSDKContext(*ctx), &tc.msg)
_, err := lockerKeeper.AddWhiteListedAsset(*ctx, &tc.msg)
s.Require().NoError(err)
})
}
Expand Down
8 changes: 2 additions & 6 deletions x/rewards/keeper/rewards.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
package keeper

import (
"context"

sdk "github.com/cosmos/cosmos-sdk/types"
protobuftypes "github.com/gogo/protobuf/types"

Expand Down Expand Up @@ -388,8 +386,7 @@ func (k Keeper) GetExternalVaultRewardsCheck(ctx sdk.Context, appMappingID uint6
}

// Whitelist an asset of an app for internal rewards
func (k Keeper) Whitelist(goCtx context.Context, msg *types.WhitelistAsset) (*types.MsgWhitelistAssetResponse, error) {
ctx := sdk.UnwrapSDKContext(goCtx)
func (k Keeper) Whitelist(ctx sdk.Context, msg *types.WhitelistAsset) (*types.MsgWhitelistAssetResponse, error) {
klwsParams, _ := k.esm.GetKillSwitchData(ctx, msg.AppMappingId)
if klwsParams.BreakerEnable {
return nil, esmtypes.ErrCircuitBreakerEnabled
Expand All @@ -409,8 +406,7 @@ func (k Keeper) Whitelist(goCtx context.Context, msg *types.WhitelistAsset) (*ty
return &types.MsgWhitelistAssetResponse{}, nil
}

func (k Keeper) WhitelistAppVault(goCtx context.Context, msg *types.WhitelistAppIdVault) (*types.MsgWhitelistAppIdVaultResponse, error) {
ctx := sdk.UnwrapSDKContext(goCtx)
func (k Keeper) WhitelistAppVault(ctx sdk.Context, msg *types.WhitelistAppIdVault) (*types.MsgWhitelistAppIdVaultResponse, error) {
klwsParams, _ := k.esm.GetKillSwitchData(ctx, msg.AppMappingId)
if klwsParams.BreakerEnable {
return nil, esmtypes.ErrCircuitBreakerEnabled
Expand Down

0 comments on commit e94d78d

Please sign in to comment.