Skip to content

Commit

Permalink
Add nativedex module to Althea L1
Browse files Browse the repository at this point in the history
  • Loading branch information
ChristianBorst committed Apr 19, 2024
1 parent adbdeab commit 5f3e4ae
Showing 1 changed file with 25 additions and 2 deletions.
27 changes: 25 additions & 2 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,9 @@ import (
"github.com/althea-net/althea-L1/x/microtx"
microtxkeeper "github.com/althea-net/althea-L1/x/microtx/keeper"
microtxtypes "github.com/althea-net/althea-L1/x/microtx/types"
"github.com/althea-net/althea-L1/x/nativedex"
nativedexkeeper "github.com/althea-net/althea-L1/x/nativedex/keeper"
nativedextypes "github.com/althea-net/althea-L1/x/nativedex/types"
"github.com/althea-net/althea-L1/x/onboarding"
onboardingkeeper "github.com/althea-net/althea-L1/x/onboarding/keeper"
onboardingtypes "github.com/althea-net/althea-L1/x/onboarding/types"
Expand Down Expand Up @@ -193,6 +196,7 @@ var (
lockup.AppModuleBasic{},
microtx.AppModuleBasic{},
onboarding.AppModuleBasic{},
nativedex.AppModuleBasic{},
evm.AppModuleBasic{},
erc20.AppModuleBasic{},
feemarket.AppModuleBasic{},
Expand All @@ -214,6 +218,7 @@ var (
microtxtypes.ModuleName: nil,
gasfreetypes.ModuleName: nil,
onboardingtypes.ModuleName: nil,
nativedextypes.ModuleName: nil,
feemarkettypes.ModuleName: nil,
icatypes.ModuleName: nil,
}
Expand Down Expand Up @@ -272,6 +277,7 @@ type AltheaApp struct { // nolint: golint
MicrotxKeeper *microtxkeeper.Keeper
GasfreeKeeper *gasfreekeeper.Keeper
OnboardingKeeper *onboardingkeeper.Keeper
NativedexKeeper *nativedexkeeper.Keeper

// make scoped keepers public for test purposes
ScopedIBCKeeper *capabilitykeeper.ScopedKeeper
Expand Down Expand Up @@ -368,6 +374,9 @@ func (app AltheaApp) ValidateMembers() {
if app.OnboardingKeeper == nil {
panic("Nil OnboardingKeeper")
}
if app.NativedexKeeper == nil {
panic("Nil NativedexKeeper")
}

// scoped keepers
if app.ScopedIBCKeeper == nil {
Expand Down Expand Up @@ -422,7 +431,7 @@ func NewAltheaApp(
icahosttypes.StoreKey,

lockuptypes.StoreKey, microtxtypes.StoreKey, gasfreetypes.StoreKey,
onboardingtypes.StoreKey,
onboardingtypes.StoreKey, nativedextypes.StoreKey,
)
// Transient keys which only last for a block before being wiped
// Params uses thsi to track whether some parameter changed this block or not
Expand Down Expand Up @@ -656,14 +665,23 @@ func NewAltheaApp(
authtypes.FeeCollectorName,
)
app.CrisisKeeper = &crisisKeeper

// Nativedex allows management of the native DEX instance from the Cosmos side
nativedexKeeper := nativedexkeeper.NewKeeper(
keys[nativedextypes.StoreKey], appCodec, app.GetSubspace(nativedextypes.ModuleName),
app.Erc20Keeper,
)
app.NativedexKeeper = &nativedexKeeper

// Register custom governance proposal logic via router keys and handler functions
govRouter := govtypes.NewRouter()
govRouter.AddRoute(govtypes.RouterKey, govtypes.ProposalHandler).
AddRoute(paramsproposal.RouterKey, params.NewParamChangeProposalHandler(paramsKeeper)).
AddRoute(distrtypes.RouterKey, distr.NewCommunityPoolSpendProposalHandler(distrKeeper)).
AddRoute(upgradetypes.RouterKey, upgrade.NewSoftwareUpgradeProposalHandler(upgradeKeeper)).
AddRoute(ibcclienttypes.RouterKey, ibcclient.NewClientProposalHandler(ibcKeeper.ClientKeeper)).
AddRoute(erc20types.RouterKey, erc20.NewErc20ProposalHandler(&erc20Keeper))
AddRoute(erc20types.RouterKey, erc20.NewErc20ProposalHandler(&erc20Keeper)).
AddRoute(nativedextypes.RouterKey, nativedex.NewNativeDexProposalHandler(&nativedexKeeper))

govKeeper := govkeeper.NewKeeper(
appCodec,
Expand Down Expand Up @@ -787,6 +805,7 @@ func NewAltheaApp(
lockup.NewAppModule(lockupKeeper, bankKeeper),
microtx.NewAppModule(microtxKeeper, accountKeeper),
onboarding.NewAppModule(onboardingKeeper),
nativedex.NewAppModule(nativedexKeeper, accountKeeper),
)
app.MM = &mm

Expand Down Expand Up @@ -821,6 +840,7 @@ func NewAltheaApp(
microtxtypes.ModuleName,
erc20types.ModuleName,
onboardingtypes.ModuleName,
nativedextypes.ModuleName,
icatypes.ModuleName,
)

Expand Down Expand Up @@ -850,6 +870,7 @@ func NewAltheaApp(
gasfreetypes.ModuleName,
lockuptypes.ModuleName,
microtxtypes.ModuleName,
nativedextypes.ModuleName,
erc20types.ModuleName,
)

Expand Down Expand Up @@ -878,6 +899,7 @@ func NewAltheaApp(
microtxtypes.ModuleName,
erc20types.ModuleName,
onboardingtypes.ModuleName,
nativedextypes.ModuleName,
crisistypes.ModuleName,
icatypes.ModuleName,
)
Expand Down Expand Up @@ -1170,6 +1192,7 @@ func initParamsKeeper(appCodec codec.BinaryCodec, legacyAmino *codec.LegacyAmino
paramsKeeper.Subspace(feemarkettypes.ModuleName)
paramsKeeper.Subspace(icahosttypes.SubModuleName)
paramsKeeper.Subspace(onboardingtypes.ModuleName)
paramsKeeper.Subspace(nativedextypes.ModuleName)

return paramsKeeper
}
Expand Down

0 comments on commit 5f3e4ae

Please sign in to comment.