Skip to content

Commit

Permalink
Merge pull request #515 from comdex-official/auction-alias-refactor
Browse files Browse the repository at this point in the history
All module remove alias and refactor code
  • Loading branch information
dheerajkd30 authored Oct 19, 2022
2 parents bbfe28a + cdcba9a commit a1b9996
Show file tree
Hide file tree
Showing 25 changed files with 269 additions and 647 deletions.
9 changes: 6 additions & 3 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -840,11 +840,14 @@ 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),
esm.NewAppModule(app.cdc, app.EsmKeeper, 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),
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),
auction.NewAppModule(app.cdc, app.AuctionKeeper, app.AccountKeeper, app.BankKeeper, app.CollectorKeeper,
app.LiquidationKeeper, app.AssetKeeper, app.MarketKeeper, app.EsmKeeper, app.VaultKeeper, app.TokenmintKeeper),
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
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ require (
github.com/CosmWasm/wasmd v0.27.0
github.com/CosmWasm/wasmvm v1.0.0
github.com/bandprotocol/bandchain-packet v0.0.3
github.com/cosmos/ibc-go/v3 v3.3.0
github.com/cosmos/cosmos-sdk v0.45.9
github.com/cosmos/ibc-go/v3 v3.3.0
github.com/gogo/protobuf v1.3.3
github.com/golang/protobuf v1.5.2
github.com/gorilla/mux v1.8.0
Expand Down
11 changes: 6 additions & 5 deletions x/auction/abci.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package auction

import (
"github.com/comdex-official/comdex/x/auction/expected"
"github.com/cosmos/cosmos-sdk/telemetry"
sdk "github.com/cosmos/cosmos-sdk/types"

Expand All @@ -9,15 +10,15 @@ import (
"github.com/comdex-official/comdex/x/auction/types"
)

func BeginBlocker(ctx sdk.Context, k keeper.Keeper) {
func BeginBlocker(ctx sdk.Context, k keeper.Keeper, assetKeeper expected.AssetKeeper, collectorKeeper expected.CollectorKeeper, esmKeeper expected.EsmKeeper) {
defer telemetry.ModuleMeasureSince(types.ModuleName, ctx.BlockTime(), telemetry.MetricKeyBeginBlocker)

_ = utils.ApplyFuncIfNoError(ctx, func(ctx sdk.Context) error {
auctionMapData, auctionMappingFound := k.GetAllAuctionMappingForApp(ctx)
auctionMapData, auctionMappingFound := collectorKeeper.GetAllAuctionMappingForApp(ctx)
if auctionMappingFound {
for _, data := range auctionMapData {
killSwitchParams, _ := k.GetKillSwitchData(ctx, data.AppId)
esmStatus, found := k.GetESMStatus(ctx, data.AppId)
killSwitchParams, _ := esmKeeper.GetKillSwitchData(ctx, data.AppId)
esmStatus, found := esmKeeper.GetESMStatus(ctx, data.AppId)
status := false
if found {
status = esmStatus.Status
Expand Down Expand Up @@ -47,7 +48,7 @@ func BeginBlocker(ctx sdk.Context, k keeper.Keeper) {
// }
//}

apps, appsFound := k.GetApps(ctx)
apps, appsFound := assetKeeper.GetApps(ctx)

if appsFound {
for _, app := range apps {
Expand Down
259 changes: 0 additions & 259 deletions x/auction/keeper/alias.go

This file was deleted.

10 changes: 5 additions & 5 deletions x/auction/keeper/auction.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,21 +47,21 @@ func (k Keeper) AddAuctionParams(ctx sdk.Context, auctionParamsBinding *bindings
}

func (k Keeper) makeFalseForFlags(ctx sdk.Context, appID, assetID uint64) error {
auctionLookupTable, found := k.GetAuctionMappingForApp(ctx, appID, assetID)
auctionLookupTable, found := k.collector.GetAuctionMappingForApp(ctx, appID, assetID)
if !found {
return auctiontypes.ErrorInvalidAddress
}

auctionLookupTable.IsAuctionActive = false
err := k.SetAuctionMappingForApp(ctx, auctionLookupTable)
err := k.collector.SetAuctionMappingForApp(ctx, auctionLookupTable)
if err != nil {
return err
}
return nil
}

func (k Keeper) CalcDollarValueForToken(ctx sdk.Context, id uint64, rate sdk.Dec, amt sdk.Int) (price sdk.Dec, err error) {
asset, found := k.GetAsset(ctx, id)
asset, found := k.asset.GetAsset(ctx, id)
if !found {
return sdk.ZeroDec(), assettypes.ErrorAssetDoesNotExist
}
Expand All @@ -72,11 +72,11 @@ func (k Keeper) CalcDollarValueForToken(ctx sdk.Context, id uint64, rate sdk.Dec
}

func (k Keeper) GetAmountOfOtherToken(ctx sdk.Context, id1 uint64, rate1 sdk.Dec, amt1 sdk.Int, id2 uint64, rate2 sdk.Dec) (sdk.Dec, sdk.Int, error) {
asset1, found := k.GetAsset(ctx, id1)
asset1, found := k.asset.GetAsset(ctx, id1)
if !found {
return sdk.ZeroDec(), sdk.ZeroInt(), assettypes.ErrorAssetDoesNotExist
}
asset2, found := k.GetAsset(ctx, id2)
asset2, found := k.asset.GetAsset(ctx, id2)
if !found {
return sdk.ZeroDec(), sdk.ZeroInt(), assettypes.ErrorAssetDoesNotExist
}
Expand Down
Loading

0 comments on commit a1b9996

Please sign in to comment.