Skip to content

Commit

Permalink
Merge branch 'feature/rewards' into release/v7
Browse files Browse the repository at this point in the history
  • Loading branch information
faneaatiku committed May 31, 2024
2 parents e42013e + e355a8e commit 42dbcf1
Show file tree
Hide file tree
Showing 689 changed files with 367,890 additions and 3,419 deletions.
58 changes: 49 additions & 9 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ import (
"github.com/bze-alphateam/bze/x/epochs"
epochskeeper "github.com/bze-alphateam/bze/x/epochs/keeper"
epochstypes "github.com/bze-alphateam/bze/x/epochs/types"
"github.com/bze-alphateam/bze/x/rewards"
rewardsclient "github.com/bze-alphateam/bze/x/rewards/client"
rewardskeeper "github.com/bze-alphateam/bze/x/rewards/keeper"
rewardstypes "github.com/bze-alphateam/bze/x/rewards/types"
"github.com/bze-alphateam/bze/x/tradebin"
tradebinkeeper "github.com/bze-alphateam/bze/x/tradebin/keeper"
tradebintypes "github.com/bze-alphateam/bze/x/tradebin/types"
Expand Down Expand Up @@ -140,6 +144,7 @@ func getGovProposalHandlers() []govclient.ProposalHandler {
cointrunkmoduleclient.AcceptedDomainProposalHandler,
cointrunkmoduleclient.PublisherProposalHandler,
burnermoduleclient.BurnCoinsProposalHandler,
rewardsclient.ActivateTradingRewardProposalHandler,
// this line is used by starport scaffolding # stargate/app/govProposalHandler
)

Expand Down Expand Up @@ -178,6 +183,7 @@ var (
tokenfactory.AppModuleBasic{},
tradebin.AppModuleBasic{},
epochs.AppModuleBasic{},
rewards.AppModuleBasic{},
// this line is used by starport scaffolding # stargate/app/moduleBasic
)

Expand All @@ -196,6 +202,7 @@ var (
tokenfactorytypes.ModuleName: {authtypes.Minter, authtypes.Burner},
tradebintypes.ModuleName: nil,
epochstypes.ModuleName: nil,
rewardstypes.ModuleName: {authtypes.Burner},
// this line is used by starport scaffolding # stargate/app/maccPerms
}

Expand Down Expand Up @@ -264,6 +271,7 @@ type App struct {
TokenFactoryKeeper tokenfactorykeeper.Keeper
TradebinKeeper tradebinkeeper.Keeper
EpochsKeeper epochskeeper.Keeper
RewardsKeeper rewardskeeper.Keeper
// this line is used by starport scaffolding # stargate/app/keeperDeclaration

// the module manager
Expand Down Expand Up @@ -314,6 +322,7 @@ func New(
tokenfactorytypes.StoreKey,
tradebintypes.StoreKey,
epochstypes.StoreKey,
rewardstypes.StoreKey,
// this line is used by starport scaffolding # stargate/app/storeKey
)
tkeys := sdk.NewTransientStoreKeys(paramstypes.TStoreKey)
Expand Down Expand Up @@ -450,23 +459,48 @@ func New(
keys[tradebintypes.MemStoreKey],
app.GetSubspace(tradebintypes.ModuleName),
app.BankKeeper,
app.AccountKeeper,
app.DistrKeeper,
)

app.EpochsKeeper = *epochskeeper.NewKeeper(
appCodec,
keys[epochstypes.StoreKey],
keys[epochstypes.MemStoreKey],
nil, //no hooks registered
)

app.RewardsKeeper = *rewardskeeper.NewKeeper(
appCodec,
keys[rewardstypes.StoreKey],
keys[rewardstypes.MemStoreKey],
app.GetSubspace(rewardstypes.ModuleName),
app.BankKeeper,
app.DistrKeeper,
app.TradebinKeeper,
app.EpochsKeeper,
)

app.TradebinKeeper.SetOnOrderFillHooks(
[]tradebintypes.OnMarketOrderFill{
app.RewardsKeeper.GetOnOrderFillHook(),
},
)

app.EpochsKeeper.SetHooks(
[]epochstypes.EpochHook{
app.RewardsKeeper.GetDistributeAllStakingRewardsHook(),
app.RewardsKeeper.GetUnlockPendingUnlockParticipantsHook(),
app.RewardsKeeper.GetRemoveExpiredPendingTradingRewardsHook(),
app.RewardsKeeper.GetTradingRewardsDistributionHook(),
},
)

scavengeModule := scavengemodule.NewAppModule(appCodec, app.ScavengeKeeper)
cointrunkModule := cointrunkmodule.NewAppModule(appCodec, app.CointrunkKeeper, app.AccountKeeper, app.BankKeeper, app.DistrKeeper)
burnerModule := burnermodule.NewAppModule(appCodec, app.BurnerKeeper, app.AccountKeeper, app.BankKeeper)
tokenfactoryModule := tokenfactory.NewAppModule(appCodec, app.TokenFactoryKeeper, app.AccountKeeper, app.BankKeeper)
tradebinModule := tradebin.NewAppModule(appCodec, app.TradebinKeeper, app.AccountKeeper, app.BankKeeper)
tradebinModule := tradebin.NewAppModule(appCodec, app.TradebinKeeper, app.BankKeeper)
epochsModule := epochs.NewAppModule(appCodec, app.EpochsKeeper)
rewardsModule := rewards.NewAppModule(appCodec, app.RewardsKeeper, app.AccountKeeper, app.BankKeeper)
// this line is used by starport scaffolding # stargate/app/keeperDefinition

// register the proposal types
Expand All @@ -477,7 +511,8 @@ func New(
AddRoute(upgradetypes.RouterKey, upgrade.NewSoftwareUpgradeProposalHandler(app.UpgradeKeeper)).
AddRoute(ibcclienttypes.RouterKey, ibcclient.NewClientProposalHandler(app.IBCKeeper.ClientKeeper)).
AddRoute(cointrunkmoduletypes.RouterKey, cointrunkmodule.NewCointrunkProposalHandler(app.CointrunkKeeper)).
AddRoute(burnermoduletypes.RouterKey, burnermodule.NewBurnerProposalHandler(app.BurnerKeeper))
AddRoute(burnermoduletypes.RouterKey, burnermodule.NewBurnerProposalHandler(app.BurnerKeeper)).
AddRoute(rewardstypes.RouterKey, rewards.NewRewardsProposalHandler(app.RewardsKeeper))

app.GovKeeper = govkeeper.NewKeeper(
appCodec, keys[govtypes.StoreKey], app.GetSubspace(govtypes.ModuleName), app.AccountKeeper, app.BankKeeper,
Expand Down Expand Up @@ -528,6 +563,7 @@ func New(
tokenfactoryModule,
tradebinModule,
epochsModule,
rewardsModule,
// this line is used by starport scaffolding # stargate/app/appModule
)

Expand Down Expand Up @@ -560,6 +596,7 @@ func New(
tokenfactorytypes.ModuleName,
tradebintypes.ModuleName,
epochstypes.ModuleName,
rewardstypes.ModuleName,
)

app.mm.SetOrderEndBlockers(
Expand Down Expand Up @@ -587,6 +624,7 @@ func New(
tokenfactorytypes.ModuleName,
tradebintypes.ModuleName,
epochstypes.ModuleName,
rewardstypes.ModuleName,
)

// NOTE: The genutils module must occur after staking so that pools are
Expand Down Expand Up @@ -619,12 +657,14 @@ func New(
tokenfactorytypes.ModuleName,
tradebintypes.ModuleName,
epochstypes.ModuleName,
rewardstypes.ModuleName,
// this line is used by starport scaffolding # stargate/app/initGenesis
)

app.mm.RegisterInvariants(&app.CrisisKeeper)
app.mm.RegisterRoutes(app.Router(), app.QueryRouter(), encodingConfig.Amino)
app.mm.RegisterServices(module.NewConfigurator(app.appCodec, app.MsgServiceRouter(), app.GRPCQueryRouter()))
cfg := module.NewConfigurator(app.appCodec, app.MsgServiceRouter(), app.GRPCQueryRouter())
app.mm.RegisterServices(cfg)

// initialize stores
app.MountKVStores(keys)
Expand All @@ -650,7 +690,7 @@ func New(

app.SetAnteHandler(anteHandler)
app.SetEndBlocker(app.EndBlocker)
app.setupUpgradeHandlers()
app.setupUpgradeHandlers(cfg)

if loadLatest {
if err := app.LoadLatestVersion(); err != nil {
Expand All @@ -665,8 +705,7 @@ func New(
return app
}

func (app *App) setupUpgradeHandlers() {
cfg := module.NewConfigurator(app.appCodec, app.MsgServiceRouter(), app.GRPCQueryRouter())
func (app *App) setupUpgradeHandlers(cfg module.Configurator) {
app.UpgradeKeeper.SetUpgradeHandler(
v700.UpgradeName,
v700.CreateUpgradeHandler(cfg, app.mm),
Expand All @@ -683,7 +722,7 @@ func (app *App) setupUpgradeHandlers() {

if upgradeInfo.Name == v700.UpgradeName {
storeUpgrades := storetypes.StoreUpgrades{
Added: []string{tokenfactorytypes.StoreKey, tradebintypes.StoreKey, epochstypes.StoreKey},
Added: []string{tokenfactorytypes.StoreKey, tradebintypes.StoreKey, epochstypes.StoreKey, rewardstypes.StoreKey},
}

// configure store loader that checks if version == upgradeHeight and applies store upgrades
Expand Down Expand Up @@ -838,6 +877,7 @@ func initParamsKeeper(appCodec codec.BinaryCodec, legacyAmino *codec.LegacyAmino
paramsKeeper.Subspace(burnermoduletypes.ModuleName)
paramsKeeper.Subspace(tokenfactorytypes.ModuleName)
paramsKeeper.Subspace(tradebintypes.ModuleName)
paramsKeeper.Subspace(rewardstypes.ModuleName)
// this line is used by starport scaffolding # stargate/app/paramSubspace

return paramsKeeper
Expand Down
Loading

0 comments on commit 42dbcf1

Please sign in to comment.