Skip to content

Commit

Permalink
Merge pull request #859 from comdex-official/feature/dev
Browse files Browse the repository at this point in the history
icq fix, ibc-apps replaced, rewards fix
  • Loading branch information
cgsingh33 authored Nov 6, 2023
2 parents c7c2715 + 8e0ff25 commit 81343d5
Show file tree
Hide file tree
Showing 8 changed files with 37 additions and 32 deletions.
34 changes: 13 additions & 21 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ import (
consensusparamkeeper "github.com/cosmos/cosmos-sdk/x/consensus/keeper"
consensusparamtypes "github.com/cosmos/cosmos-sdk/x/consensus/types"

packetforward "github.com/strangelove-ventures/packet-forward-middleware/v7/router"
packetforwardkeeper "github.com/strangelove-ventures/packet-forward-middleware/v7/router/keeper"
packetforwardtypes "github.com/strangelove-ventures/packet-forward-middleware/v7/router/types"
packetforward "github.com/cosmos/ibc-apps/middleware/packet-forward-middleware/v7/router"
packetforwardkeeper "github.com/cosmos/ibc-apps/middleware/packet-forward-middleware/v7/router/keeper"
packetforwardtypes "github.com/cosmos/ibc-apps/middleware/packet-forward-middleware/v7/router/types"

"github.com/rakyll/statik/fs"

Expand Down Expand Up @@ -306,6 +306,7 @@ var (
ibcfee.AppModuleBasic{},
liquidationsV2.AppModuleBasic{},
auctionsV2.AppModuleBasic{},
icq.AppModuleBasic{},
ibchooks.AppModuleBasic{},
packetforward.AppModuleBasic{},
)
Expand Down Expand Up @@ -390,10 +391,10 @@ type App struct {

// IBC modules
// transfer module
Ics20WasmHooks *ibchooks.WasmHooks
HooksICS4Wrapper ibchooks.ICS4Middleware
PacketForwardKeeper *packetforwardkeeper.Keeper
ICQKeeper *icqkeeper.Keeper
Ics20WasmHooks *ibchooks.WasmHooks
HooksICS4Wrapper ibchooks.ICS4Middleware
PacketForwardKeeper *packetforwardkeeper.Keeper
ICQKeeper *icqkeeper.Keeper

ConsensusParamsKeeper consensusparamkeeper.Keeper

Expand Down Expand Up @@ -888,7 +889,7 @@ func New(
app.IbcKeeper.ChannelKeeper, // may be replaced with middleware
app.IbcKeeper.ChannelKeeper,
&app.IbcKeeper.PortKeeper,
app.ScopedICQKeeper,
scopedICQKeeper,
app.GRPCQueryRouter(),
// NewQuerierWrapper(baseApp), // in-case of strangelove-ventures icq
)
Expand Down Expand Up @@ -1454,6 +1455,10 @@ func (a *App) ModuleAccountsPermissions() map[string][]string {
}

func (a *App) registerUpgradeHandlers() {
a.UpgradeKeeper.SetUpgradeHandler(
tv13.UpgradeName,
tv13.CreateUpgradeHandlerV13(a.mm, a.configurator, a.cdc, a.keys[capabilitytypes.ModuleName], a.CapabilityKeeper, a.WasmKeeper, a.ParamsKeeper, a.ConsensusParamsKeeper, *a.IbcKeeper, a.GovKeeper, *a.StakingKeeper, a.MintKeeper, a.SlashingKeeper, a.BandoracleKeeper),
)
// When a planned update height is reached, the old binary will panic
// writing on disk the height and name of the update that triggered it
// This will read that value, and execute the preparations for the upgrade.
Expand All @@ -1462,19 +1467,6 @@ func (a *App) registerUpgradeHandlers() {
panic(err)
}

switch {
case upgradeInfo.Name == mv12.UpgradeName:
a.UpgradeKeeper.SetUpgradeHandler(
mv12.UpgradeName,
mv12.CreateUpgradeHandlerV12(a.mm, a.configurator, a.ICQKeeper, a.NewliqKeeper, a.NewaucKeeper, a.BankKeeper, a.CollectorKeeper, a.LendKeeper, a.AuctionKeeper, a.LiquidationKeeper, a.AssetKeeper),
)
case upgradeInfo.Name == tv13.UpgradeName:
a.UpgradeKeeper.SetUpgradeHandler(
tv13.UpgradeName,
tv13.CreateUpgradeHandlerV13(a.mm, a.configurator, a.cdc, a.keys[capabilitytypes.ModuleName], a.CapabilityKeeper, a.WasmKeeper, a.ParamsKeeper, a.ConsensusParamsKeeper, *a.IbcKeeper, a.GovKeeper, *a.StakingKeeper, a.MintKeeper, a.SlashingKeeper, a.BandoracleKeeper),
)
}

var storeUpgrades *storetypes.StoreUpgrades

storeUpgrades = upgradeHandlers(upgradeInfo, a, storeUpgrades)
Expand Down
2 changes: 1 addition & 1 deletion cmd/comdex/migrate.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/x/genutil/types"
// bump47: uncomment below 1
packetforwardtypes "github.com/strangelove-ventures/packet-forward-middleware/v7/router/types"
packetforwardtypes "github.com/cosmos/ibc-apps/middleware/packet-forward-middleware/v7/router/types"
)

func Migrate(appState types.AppMap, clientCtx client.Context) types.AppMap {
Expand Down
6 changes: 3 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ require (
github.com/cometbft/cometbft-db v0.8.0
github.com/cosmos/cosmos-sdk v0.47.5
github.com/cosmos/gogoproto v1.4.10
github.com/cosmos/ibc-apps/modules/async-icq/v7 v7.0.0-20230726182236-3a9d46a7c2a4
github.com/cosmos/ibc-apps/modules/ibc-hooks/v7 v7.0.0-20230726182236-3a9d46a7c2a4
github.com/cosmos/ibc-apps/modules/async-icq/v7 v7.0.0
github.com/cosmos/ibc-apps/modules/ibc-hooks/v7 v7.0.0-20230803181732-7c8f814d3b79
github.com/golang/protobuf v1.5.3
github.com/gorilla/mux v1.8.0
github.com/grpc-ecosystem/grpc-gateway v1.16.0
Expand All @@ -28,12 +28,12 @@ require (
)

require (
github.com/cosmos/ibc-apps/middleware/packet-forward-middleware/v7 v7.0.0
github.com/cosmos/ibc-go/v7 v7.2.0
github.com/cosmos/ics23/go v0.10.0 // indirect
github.com/golangci/golangci-lint v1.51.2
github.com/rakyll/statik v0.1.7
github.com/spf13/pflag v1.0.5
github.com/strangelove-ventures/packet-forward-middleware/v7 v7.0.0-20230523193151-73dea436e53f
gopkg.in/yaml.v2 v2.4.0
mvdan.cc/gofumpt v0.5.0
)
Expand Down
12 changes: 6 additions & 6 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -1097,10 +1097,12 @@ github.com/cosmos/iavl v0.19.4/go.mod h1:X9PKD3J0iFxdmgNLa7b2LYWdsGd90ToV5cAONAp
github.com/cosmos/iavl v0.20.0-alpha4/go.mod h1:WO7FyvaZJoH65+HFOsDir7xU9FWk2w9cHXNW1XHcl7A=
github.com/cosmos/iavl v0.20.0 h1:fTVznVlepH0KK8NyKq8w+U7c2L6jofa27aFX6YGlm38=
github.com/cosmos/iavl v0.20.0/go.mod h1:WO7FyvaZJoH65+HFOsDir7xU9FWk2w9cHXNW1XHcl7A=
github.com/cosmos/ibc-apps/modules/async-icq/v7 v7.0.0-20230726182236-3a9d46a7c2a4 h1:AKzCfYLsVG9DtNzjya12u+OO0sUQpcXlecqnD/2rqGg=
github.com/cosmos/ibc-apps/modules/async-icq/v7 v7.0.0-20230726182236-3a9d46a7c2a4/go.mod h1:/P6l2bWo2AR3rrsfs0DHuFZO3Imzb93sxFD3ihrIgw4=
github.com/cosmos/ibc-apps/modules/ibc-hooks/v7 v7.0.0-20230726182236-3a9d46a7c2a4 h1:NuFmpHnENcTtZDEQf2vZzZluk5rQl3f7J4tqo9FlH/c=
github.com/cosmos/ibc-apps/modules/ibc-hooks/v7 v7.0.0-20230726182236-3a9d46a7c2a4/go.mod h1:JwHFbo1oX/ht4fPpnPvmhZr+dCkYK1Vihw+vZE9umR4=
github.com/cosmos/ibc-apps/middleware/packet-forward-middleware/v7 v7.0.0 h1:i9esYyZ5ExpZOgxrLMQhY2jDTVYiaD8yUeqXN9QBgbk=
github.com/cosmos/ibc-apps/middleware/packet-forward-middleware/v7 v7.0.0/go.mod h1:fctjEnz9xaBFOlmYYPdKL8Hs1Y3GUKilSwsJdqBb5QU=
github.com/cosmos/ibc-apps/modules/async-icq/v7 v7.0.0 h1:mMHedP3Q+mz5gpOWNz0P+X8hxPdamylrBKc/P2cFakA=
github.com/cosmos/ibc-apps/modules/async-icq/v7 v7.0.0/go.mod h1:/P6l2bWo2AR3rrsfs0DHuFZO3Imzb93sxFD3ihrIgw4=
github.com/cosmos/ibc-apps/modules/ibc-hooks/v7 v7.0.0-20230803181732-7c8f814d3b79 h1:pCxyhIxgWTabAQC5UerkITraHG3SwajdLKKMCFDWCv4=
github.com/cosmos/ibc-apps/modules/ibc-hooks/v7 v7.0.0-20230803181732-7c8f814d3b79/go.mod h1:JwHFbo1oX/ht4fPpnPvmhZr+dCkYK1Vihw+vZE9umR4=
github.com/cosmos/ibc-go/v7 v7.2.0 h1:dx0DLUl7rxdyZ8NiT6UsrbzKOJx/w7s+BOaewFRH6cg=
github.com/cosmos/ibc-go/v7 v7.2.0/go.mod h1:OOcjKIRku/j1Xs1RgKK0yvKRrJ5iFuZYMetR1n3yMlc=
github.com/cosmos/ics23/go v0.10.0 h1:iXqLLgp2Lp+EdpIuwXTYIQU+AiHj9mOC2X9ab++bZDM=
Expand Down Expand Up @@ -2807,8 +2809,6 @@ github.com/stbenjam/no-sprintf-host-port v0.1.1 h1:tYugd/yrm1O0dV+ThCbaKZh195Dfm
github.com/stbenjam/no-sprintf-host-port v0.1.1/go.mod h1:TLhvtIvONRzdmkFiio4O8LHsN9N74I+PhRquPsxpL0I=
github.com/stefanberger/go-pkcs11uri v0.0.0-20201008174630-78d3cae3a980/go.mod h1:AO3tvPzVZ/ayst6UlUKUv6rcPQInYe3IknH3jYhAKu8=
github.com/stoewer/go-strcase v1.2.0/go.mod h1:IBiWB2sKIp3wVVQ3Y035++gc+knqhUQag1KpM8ahLw8=
github.com/strangelove-ventures/packet-forward-middleware/v7 v7.0.0-20230523193151-73dea436e53f h1:NJdZ+YJ9Vf2t286L20IjFK0SxGpobF1xIp5ZQlxWetk=
github.com/strangelove-ventures/packet-forward-middleware/v7 v7.0.0-20230523193151-73dea436e53f/go.mod h1:DJNSVK8NCYHM+aZHCFkcAqPwjzwHYAjhjSMlhAGtJ3c=
github.com/streadway/amqp v0.0.0-20190404075320-75d898a42a94/go.mod h1:AZpEONHx3DKn8O/DFsRAY58/XVQiIPMTMB1SddzLXVw=
github.com/streadway/amqp v0.0.0-20190827072141-edfb9018d271/go.mod h1:AZpEONHx3DKn8O/DFsRAY58/XVQiIPMTMB1SddzLXVw=
github.com/streadway/amqp v1.0.0/go.mod h1:AZpEONHx3DKn8O/DFsRAY58/XVQiIPMTMB1SddzLXVw=
Expand Down
4 changes: 4 additions & 0 deletions x/liquidity/keeper/pool.go
Original file line number Diff line number Diff line change
Expand Up @@ -685,6 +685,10 @@ func (k Keeper) TransferFundsForSwapFeeDistribution(ctx sdk.Context, appID, requ
return sdk.Coin{}, types.ErrInvalidPoolID
}

if requestedPool.Disabled {
return sdk.Coin{}, types.ErrDisabledPool
}

pair, found := k.GetPair(ctx, appID, requestedPool.PairId)
if !found {
return sdk.Coin{}, types.ErrInvalidPairID
Expand Down
5 changes: 5 additions & 0 deletions x/liquidity/keeper/rewards.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package keeper

import (
"fmt"
"math"
"strconv"
"time"
Expand Down Expand Up @@ -169,6 +170,10 @@ func (k Keeper) GetFarmingRewardsData(ctx sdk.Context, appID uint64, coinsToDist
pair := deserializerKit.Pair
pool := deserializerKit.Pool

if pool.Disabled {
return nil, sdkerrors.Wrap(types.ErrDisabledPool, fmt.Sprintf("pool is disabled : %d", pool.Id))
}

asset, err := k.GetAssetWhoseOraclePriceExists(ctx, pair.QuoteCoinDenom, pair.BaseCoinDenom)
if err != nil {
return nil, err
Expand Down
5 changes: 4 additions & 1 deletion x/rewards/keeper/gauge.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,10 +95,13 @@ func (k Keeper) ValidateMsgCreateGaugeLiquidityMetaData(ctx sdk.Context, appID u
if poolID == kind.LiquidityMetaData.PoolId {
return sdkerrors.Wrap(types.ErrSamePoolID, fmt.Sprintf("pool id : %d", poolID))
}
_, found := k.liquidityKeeper.GetPool(ctx, appID, poolID)
pool, found := k.liquidityKeeper.GetPool(ctx, appID, poolID)
if !found {
return sdkerrors.Wrap(types.ErrInvalidPoolID, fmt.Sprintf("invalid child pool id : %d", poolID))
}
if pool.Disabled {
return sdkerrors.Wrap(types.ErrDisabledPool, fmt.Sprintf("pool is disabled : %d", poolID))
}
}

return nil
Expand Down
1 change: 1 addition & 0 deletions x/rewards/types/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,5 @@ var (
ErrInvalidAppID = sdkerrors.Register(ModuleName, 1117, "invalid app id")
ErrInternalRewardsNotFound = sdkerrors.Register(ModuleName, 1118, "Internal rewards not found")
ErrStablemintVaultFound = sdkerrors.Register(ModuleName, 1119, "Can't give reward to stablemint vault")
ErrDisabledPool = sdkerrors.Register(ModuleName, 1120, "diabled pool")
)

0 comments on commit 81343d5

Please sign in to comment.