Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

All module remove alias and refactor code #515

Merged
merged 9 commits into from
Oct 19, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)

Check warning

Code scanning / CodeQL

Panic in BeginBock or EndBlock consensus methods

Possible panics in BeginBock- or EndBlock-related consensus methods could cause a chain halt
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)

Check warning

Code scanning / CodeQL

Panic in BeginBock or EndBlock consensus methods

Possible panics in BeginBock- or EndBlock-related consensus methods could cause a chain halt
esmStatus, found := esmKeeper.GetESMStatus(ctx, data.AppId)

Check warning

Code scanning / CodeQL

Panic in BeginBock or EndBlock consensus methods

Possible panics in BeginBock- or EndBlock-related consensus methods could cause a chain halt
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)

Check warning

Code scanning / CodeQL

Panic in BeginBock or EndBlock consensus methods

Possible panics in BeginBock- or EndBlock-related consensus methods could cause a chain halt

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