Skip to content

Commit

Permalink
Merge pull request #798 from comdex-official/feature/dev
Browse files Browse the repository at this point in the history
icq added
  • Loading branch information
dheerajkd30 authored Jun 23, 2023
2 parents d7a8b66 + f830d38 commit 34ac618
Show file tree
Hide file tree
Showing 5 changed files with 92 additions and 21 deletions.
63 changes: 42 additions & 21 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -175,10 +175,13 @@ import (
liquiditykeeper "github.com/comdex-official/comdex/x/liquidity/keeper"
liquiditytypes "github.com/comdex-official/comdex/x/liquidity/types"

icq "github.com/cosmos/ibc-apps/modules/async-icq/v4"
icqkeeper "github.com/cosmos/ibc-apps/modules/async-icq/v4/keeper"
icqtypes "github.com/cosmos/ibc-apps/modules/async-icq/v4/types"

cwasm "github.com/comdex-official/comdex/app/wasm"

mv11 "github.com/comdex-official/comdex/app/upgrades/mainnet/v11"
tv11_4 "github.com/comdex-official/comdex/app/upgrades/testnet/v11_4"
mv12 "github.com/comdex-official/comdex/app/upgrades/mainnet/v12"
)

const (
Expand Down Expand Up @@ -339,6 +342,7 @@ type App struct {
ScopedIBCOracleKeeper capabilitykeeper.ScopedKeeper
ScopedBandoracleKeeper capabilitykeeper.ScopedKeeper
ScopedICAHostKeeper capabilitykeeper.ScopedKeeper
ScopedICQKeeper capabilitykeeper.ScopedKeeper

BandoracleKeeper bandoraclemodulekeeper.Keeper
AssetKeeper assetkeeper.Keeper
Expand All @@ -364,6 +368,7 @@ type App struct {
Ics20WasmHooks *ibchooks.WasmHooks
HooksICS4Wrapper ibchooks.ICS4Middleware
PacketForwardKeeper *packetforwardkeeper.Keeper
ICQKeeper *icqkeeper.Keeper

WasmKeeper wasm.Keeper
ContractKeeper *wasmkeeper.PermissionedKeeper
Expand Down Expand Up @@ -401,7 +406,7 @@ func New(
markettypes.StoreKey, bandoraclemoduletypes.StoreKey, lockertypes.StoreKey,
wasm.StoreKey, authzkeeper.StoreKey, auctiontypes.StoreKey, tokenminttypes.StoreKey,
rewardstypes.StoreKey, feegrant.StoreKey, liquiditytypes.StoreKey, esmtypes.ModuleName, lendtypes.StoreKey,
ibchookstypes.StoreKey, packetforwardtypes.StoreKey,
ibchookstypes.StoreKey, icqtypes.StoreKey, packetforwardtypes.StoreKey,
)
)

Expand Down Expand Up @@ -456,6 +461,7 @@ func New(
app.ParamsKeeper.Subspace(liquiditytypes.ModuleName)
app.ParamsKeeper.Subspace(rewardstypes.ModuleName)
app.ParamsKeeper.Subspace(ibcratelimittypes.ModuleName)
app.ParamsKeeper.Subspace(icqtypes.ModuleName)
app.ParamsKeeper.Subspace(packetforwardtypes.ModuleName).WithKeyTable(packetforwardtypes.ParamKeyTable())

// set the BaseApp's parameter store
Expand All @@ -480,6 +486,7 @@ func New(
scopedWasmKeeper = app.CapabilityKeeper.ScopeToModule(wasm.ModuleName)
scopedICAHostKeeper = app.CapabilityKeeper.ScopeToModule(icahosttypes.SubModuleName)
scopedBandoracleKeeper = app.CapabilityKeeper.ScopeToModule(bandoraclemoduletypes.ModuleName)
scopedICQKeeper = app.CapabilityKeeper.ScopeToModule(icqtypes.ModuleName)
)

// add keepers
Expand Down Expand Up @@ -758,6 +765,24 @@ func New(
&app.LendKeeper,
)

// ICQ Keeper
icqKeeper := icqkeeper.NewKeeper(
appCodec,
app.keys[icqtypes.StoreKey],
app.GetSubspace(icqtypes.ModuleName),
app.IbcKeeper.ChannelKeeper, // may be replaced with middleware
app.IbcKeeper.ChannelKeeper,
&app.IbcKeeper.PortKeeper,
app.ScopedICQKeeper,
app.GRPCQueryRouter(),
)
app.ICQKeeper = &icqKeeper

// Create Async ICQ module
icqModule := icq.NewIBCModule(*app.ICQKeeper)

// Note: the sealing is done after creating wasmd and wiring that up

wasmDir := filepath.Join(homePath, "wasm")
wasmConfig, err := wasm.ReadWasmConfig(appOptions)
if err != nil {
Expand Down Expand Up @@ -833,6 +858,7 @@ func New(
ibcRouter.AddRoute(bandoraclemoduletypes.ModuleName, bandOracleIBCModule)
ibcRouter.AddRoute(wasm.ModuleName, wasm.NewIBCHandler(app.WasmKeeper, app.IbcKeeper.ChannelKeeper, app.IbcKeeper.ChannelKeeper))
ibcRouter.AddRoute(icahosttypes.SubModuleName, icaHostIBCModule)
ibcRouter.AddRoute(icqtypes.ModuleName, icqModule)
app.IbcKeeper.SetRouter(ibcRouter)
// Create evidence Keeper for to register the IBC light client misbehaviour evidence route
app.EvidenceKeeper = *evidencekeeper.NewKeeper(
Expand Down Expand Up @@ -887,6 +913,7 @@ func New(
rewards.NewAppModule(app.cdc, app.Rewardskeeper, app.AccountKeeper, app.BankKeeper),
ibcratelimitmodule.NewAppModule(*app.RateLimitingICS4Wrapper),
ibchooks.NewAppModule(app.AccountKeeper),
icq.NewAppModule(*app.ICQKeeper),
packetforward.NewAppModule(app.PacketForwardKeeper),
)

Expand Down Expand Up @@ -930,6 +957,7 @@ func New(
esmtypes.ModuleName,
ibcratelimittypes.ModuleName,
ibchookstypes.ModuleName,
icqtypes.ModuleName,
packetforwardtypes.ModuleName,
)

Expand Down Expand Up @@ -969,6 +997,7 @@ func New(
esmtypes.ModuleName,
ibcratelimittypes.ModuleName,
ibchookstypes.ModuleName,
icqtypes.ModuleName,
packetforwardtypes.ModuleName,
)

Expand Down Expand Up @@ -1012,6 +1041,7 @@ func New(
crisistypes.ModuleName,
ibcratelimittypes.ModuleName,
ibchookstypes.ModuleName,
icqtypes.ModuleName,
packetforwardtypes.ModuleName,
)

Expand Down Expand Up @@ -1082,6 +1112,7 @@ func New(
app.ScopedIBCOracleKeeper = scopedIBCOracleKeeper
app.ScopedICAHostKeeper = scopedICAHostKeeper
app.ScopedBandoracleKeeper = scopedBandoracleKeeper
app.ScopedICQKeeper = scopedICQKeeper

app.ScopedWasmKeeper = scopedWasmKeeper
return app
Expand Down Expand Up @@ -1338,6 +1369,7 @@ func (a *App) ModuleAccountsPermissions() map[string][]string {
rewardstypes.ModuleName: {authtypes.Minter, authtypes.Burner},
icatypes.ModuleName: nil,
assettypes.ModuleName: nil,
icqtypes.ModuleName: nil,
}
}

Expand All @@ -1350,18 +1382,10 @@ func (a *App) registerUpgradeHandlers() {
panic(err)
}

switch {
case upgradeInfo.Name == tv11_4.UpgradeName:
a.UpgradeKeeper.SetUpgradeHandler(
tv11_4.UpgradeName,
tv11_4.CreateUpgradeHandlerV114(a.mm, a.configurator, a.AssetKeeper),
)
case upgradeInfo.Name == mv11.UpgradeName:
a.UpgradeKeeper.SetUpgradeHandler(
mv11.UpgradeName,
mv11.CreateUpgradeHandlerV11(a.mm, a.configurator, a.LiquidityKeeper, a.AssetKeeper, a.BankKeeper, a.AccountKeeper, a.Rewardskeeper, a.ICAHostKeeper),
)
}
a.UpgradeKeeper.SetUpgradeHandler(
mv12.UpgradeName,
mv12.CreateUpgradeHandlerV12(a.mm, a.configurator, a.ICQKeeper),
)

var storeUpgrades *storetypes.StoreUpgrades

Expand All @@ -1375,13 +1399,10 @@ func (a *App) registerUpgradeHandlers() {

func upgradeHandlers(upgradeInfo storetypes.UpgradeInfo, a *App, storeUpgrades *storetypes.StoreUpgrades) *storetypes.StoreUpgrades {
switch {
case upgradeInfo.Name == tv11_4.UpgradeName && !a.UpgradeKeeper.IsSkipHeight(upgradeInfo.Height):
storeUpgrades = &storetypes.StoreUpgrades{
Added: []string{ibchookstypes.StoreKey, packetforwardtypes.StoreKey},
}
case upgradeInfo.Name == mv11.UpgradeName && !a.UpgradeKeeper.IsSkipHeight(upgradeInfo.Height):

case upgradeInfo.Name == mv12.UpgradeName && !a.UpgradeKeeper.IsSkipHeight(upgradeInfo.Height):
storeUpgrades = &storetypes.StoreUpgrades{
Added: []string{ibchookstypes.StoreKey, packetforwardtypes.StoreKey},
Added: []string{icqtypes.StoreKey},
}
}
return storeUpgrades
Expand Down
15 changes: 15 additions & 0 deletions app/upgrades/mainnet/v12/constants.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package v12

const (
UpgradeName = "v12.0.0"
UpgradeHeight = ""
UpgradeInfo = `'{
"binaries": {
"darwin/arm64":"",
"darwin/x86_64":"",
"linux/arm64":"",
"linux/x86_64":"",
"windows/x86_64":""
}
}'`
)
29 changes: 29 additions & 0 deletions app/upgrades/mainnet/v12/upgrades.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package v12

import (
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/module"
upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types"
icqkeeper "github.com/cosmos/ibc-apps/modules/async-icq/v4/keeper"
icqtypes "github.com/cosmos/ibc-apps/modules/async-icq/v4/types"
)

func CreateUpgradeHandlerV12(
mm *module.Manager,
configurator module.Configurator,
icqkeeper *icqkeeper.Keeper,
) upgradetypes.UpgradeHandler {
return func(ctx sdk.Context, _ upgradetypes.Plan, fromVM module.VersionMap) (module.VersionMap, error) {
ctx.Logger().Info("Applying main net upgrade - v.12.0.0")

icqparams := icqtypes.DefaultParams()
icqparams.AllowQueries = append(icqparams.AllowQueries, "/cosmwasm.wasm.v1.Query/SmartContractState")
icqkeeper.SetParams(ctx, icqparams)

vm, err := mm.RunMigrations(ctx, configurator, fromVM)
if err != nil {
return nil, err
}
return vm, err
}
}
2 changes: 2 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ require (
github.com/CosmWasm/wasmvm v1.2.1
github.com/bandprotocol/bandchain-packet v0.0.3
github.com/cosmos/cosmos-sdk v0.46.11
github.com/cosmos/ibc-apps/modules/async-icq/v4 v4.0.0-20230524151648-c02fa46c2860
github.com/gogo/protobuf v1.3.3
github.com/golang/protobuf v1.5.3
github.com/gorilla/mux v1.8.0
Expand Down Expand Up @@ -38,6 +39,7 @@ require (
require (
4d63.com/gocheckcompilerdirectives v1.2.1 // indirect
4d63.com/gochecknoglobals v0.2.1 // indirect
cosmossdk.io/errors v1.0.0-beta.7 // indirect
filippo.io/edwards25519 v1.0.0-rc.1 // indirect
github.com/99designs/go-keychain v0.0.0-20191008050251-8e49817e8af4 // indirect
github.com/99designs/keyring v1.2.1 // indirect
Expand Down
4 changes: 4 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,8 @@ contrib.go.opencensus.io/exporter/stackdriver v0.12.1/go.mod h1:iwB6wGarfphGGe/e
contrib.go.opencensus.io/exporter/stackdriver v0.13.4/go.mod h1:aXENhDJ1Y4lIg4EUaVTwzvYETVNZk10Pu26tevFKLUc=
contrib.go.opencensus.io/integrations/ocsql v0.1.4/go.mod h1:8DsSdjz3F+APR+0z0WkU1aRorQCFfRxvqjUUPMbF3fE=
contrib.go.opencensus.io/resource v0.1.1/go.mod h1:F361eGI91LCmW1I/Saf+rX0+OFcigGlFvXwEGEnkRLA=
cosmossdk.io/errors v1.0.0-beta.7 h1:gypHW76pTQGVnHKo6QBkb4yFOJjC+sUGRc5Al3Odj1w=
cosmossdk.io/errors v1.0.0-beta.7/go.mod h1:mz6FQMJRku4bY7aqS/Gwfcmr/ue91roMEKAmDUDpBfE=
dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU=
filippo.io/edwards25519 v1.0.0-beta.2/go.mod h1:X+pm78QAUPtFLi1z9PYIlS/bdDnvbCOGKtZ+ACWEf7o=
filippo.io/edwards25519 v1.0.0-rc.1 h1:m0VOOB23frXZvAOK44usCgLWvtsxIoMCTBGJZlpmGfU=
Expand Down Expand Up @@ -767,6 +769,8 @@ github.com/cosmos/gorocksdb v1.2.0/go.mod h1:aaKvKItm514hKfNJpUJXnnOWeBnk2GL4+Qw
github.com/cosmos/iavl v0.19.3/go.mod h1:X9PKD3J0iFxdmgNLa7b2LYWdsGd90ToV5cAONApkEPw=
github.com/cosmos/iavl v0.19.4 h1:t82sN+Y0WeqxDLJRSpNd8YFX5URIrT+p8n6oJbJ2Dok=
github.com/cosmos/iavl v0.19.4/go.mod h1:X9PKD3J0iFxdmgNLa7b2LYWdsGd90ToV5cAONApkEPw=
github.com/cosmos/ibc-apps/modules/async-icq/v4 v4.0.0-20230524151648-c02fa46c2860 h1:25/KpA4WJqdFjKFsa3VEL0ctWRovkEsqIn2phCAi9v0=
github.com/cosmos/ibc-apps/modules/async-icq/v4 v4.0.0-20230524151648-c02fa46c2860/go.mod h1:X/dLZ6QxTImzno7qvD6huLhh6ZZBcRt2URn4YCLcXFY=
github.com/cosmos/ibc-go v1.0.0/go.mod h1:2wHKQUa+BLJMEyN635KrHfmTTwSNHBtXcqdY8JWGuXA=
github.com/cosmos/ibc-go/v4 v4.4.2 h1:PG4Yy0/bw6Hvmha3RZbc53KYzaCwuB07Ot4GLyzcBvo=
github.com/cosmos/ibc-go/v4 v4.4.2/go.mod h1:j/kD2JCIaV5ozvJvaEkWhLxM2zva7/KTM++EtKFYcB8=
Expand Down

0 comments on commit 34ac618

Please sign in to comment.