Skip to content

Commit

Permalink
Merge pull request #253 from scorpioborn/feature/reward-module-basis
Browse files Browse the repository at this point in the history
Feature / Reward module and subaccount integration
  • Loading branch information
3eyedraga authored Oct 1, 2023
2 parents 3721330 + c618040 commit 5bd66c2
Show file tree
Hide file tree
Showing 489 changed files with 23,562 additions and 1,429 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
*.test
*gentxs
*node*
*__debug__*


# Output of the go coverage tool, specifically when used with LiteIDE
Expand Down
20 changes: 12 additions & 8 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ import (
"os"
"path/filepath"

"github.com/gorilla/mux"
"github.com/rakyll/statik/fs"
"github.com/spf13/cast"

"github.com/cosmos/cosmos-sdk/baseapp"
"github.com/cosmos/cosmos-sdk/client"
nodeservice "github.com/cosmos/cosmos-sdk/client/grpc/node"
Expand All @@ -30,20 +34,20 @@ import (
paramstypes "github.com/cosmos/cosmos-sdk/x/params/types"
upgradeclient "github.com/cosmos/cosmos-sdk/x/upgrade/client"
upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types"
ibcclientHandler "github.com/cosmos/ibc-go/v5/modules/core/02-client/client"
"github.com/gorilla/mux"
"github.com/rakyll/statik/fs"
"github.com/sge-network/sge/app/keepers"
sgeappparams "github.com/sge-network/sge/app/params"
"github.com/sge-network/sge/app/upgrades"
v1 "github.com/sge-network/sge/app/upgrades/v1"
"github.com/spf13/cast"

abci "github.com/tendermint/tendermint/abci/types"
tmjson "github.com/tendermint/tendermint/libs/json"
"github.com/tendermint/tendermint/libs/log"
tmos "github.com/tendermint/tendermint/libs/os"
dbm "github.com/tendermint/tm-db"

ibcclientHandler "github.com/cosmos/ibc-go/v5/modules/core/02-client/client"

"github.com/sge-network/sge/app/keepers"
sgeappparams "github.com/sge-network/sge/app/params"
"github.com/sge-network/sge/app/upgrades"
v1 "github.com/sge-network/sge/app/upgrades/v1"

// unnamed import of statik for swagger UI support
_ "github.com/cosmos/cosmos-sdk/client/docs/statik"
)
Expand Down
7 changes: 5 additions & 2 deletions app/app_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,14 @@ package app_test
import (
"testing"

sdksimapp "github.com/cosmos/cosmos-sdk/simapp"
"github.com/sge-network/sge/app"
"github.com/stretchr/testify/require"

"github.com/tendermint/tendermint/libs/log"
tmdb "github.com/tendermint/tm-db"

sdksimapp "github.com/cosmos/cosmos-sdk/simapp"

"github.com/sge-network/sge/app"
)

func TestApp(t *testing.T) {
Expand Down
1 change: 1 addition & 0 deletions app/encoding.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package app

import (
"github.com/cosmos/cosmos-sdk/std"

"github.com/sge-network/sge/app/params"
)

Expand Down
3 changes: 2 additions & 1 deletion app/export.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,13 @@ import (
"fmt"
"log"

tmproto "github.com/tendermint/tendermint/proto/tendermint/types"

servertypes "github.com/cosmos/cosmos-sdk/server/types"
sdk "github.com/cosmos/cosmos-sdk/types"
slashingtypes "github.com/cosmos/cosmos-sdk/x/slashing/types"
"github.com/cosmos/cosmos-sdk/x/staking"
stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"
tmproto "github.com/tendermint/tendermint/proto/tendermint/types"
)

// ExportAppStateAndValidators exports the state of the application for a genesis
Expand Down
7 changes: 4 additions & 3 deletions app/export_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@ package app_test
import (
"testing"

simappUtil "github.com/sge-network/sge/testutil/simapp"
"github.com/stretchr/testify/require"

"github.com/sge-network/sge/testutil/simapp"
)

func TestExport(t *testing.T) {
Expand All @@ -23,8 +24,8 @@ func TestExport(t *testing.T) {
}
for _, tc := range testCases {
t.Run(tc.name, func(t *testing.T) {
tApp, _, err := simappUtil.GetTestObjectsWithOptions(
simappUtil.Options{
tApp, _, err := simapp.GetTestObjectsWithOptions(
simapp.Options{
CreateGenesisValidators: true,
},
)
Expand Down
83 changes: 70 additions & 13 deletions app/keepers/keepers.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,14 @@ import (
orderbookmodulekeeper "github.com/sge-network/sge/x/orderbook/keeper"
orderbookmoduletypes "github.com/sge-network/sge/x/orderbook/types"

subaccountmodule "github.com/sge-network/sge/x/subaccount"
subaccountmodulekeeper "github.com/sge-network/sge/x/subaccount/keeper"
subaccountmoduletypes "github.com/sge-network/sge/x/subaccount/types"

rewardmodule "github.com/sge-network/sge/x/reward"
rewardmodulekeeper "github.com/sge-network/sge/x/reward/keeper"
rewardmoduletypes "github.com/sge-network/sge/x/reward/types"

// unnamed import of statik for swagger UI support
_ "github.com/cosmos/cosmos-sdk/client/docs/statik"
)
Expand Down Expand Up @@ -114,19 +122,23 @@ type AppKeepers struct {
GroupKeeper groupkeeper.Keeper

//// SGE keepers \\\\
BetKeeper *betmodulekeeper.Keeper
MarketKeeper *marketmodulekeeper.Keeper
MintKeeper mintkeeper.Keeper
HouseKeeper *housemodulekeeper.Keeper
OrderbookKeeper *orderbookmodulekeeper.Keeper
OVMKeeper *ovmmodulekeeper.Keeper
BetKeeper *betmodulekeeper.Keeper
MarketKeeper *marketmodulekeeper.Keeper
MintKeeper mintkeeper.Keeper
HouseKeeper *housemodulekeeper.Keeper
OrderbookKeeper *orderbookmodulekeeper.Keeper
OVMKeeper *ovmmodulekeeper.Keeper
RewardKeeper *rewardmodulekeeper.Keeper
SubaccountKeeper *subaccountmodulekeeper.Keeper

//// SGE modules \\\\
BetModule betmodule.AppModule
MarketModule marketmodule.AppModule
HouseModule housemodule.AppModule
OrderbookModule orderbookmodule.AppModule
OVMModule ovmmodule.AppModule
BetModule betmodule.AppModule
MarketModule marketmodule.AppModule
HouseModule housemodule.AppModule
OrderbookModule orderbookmodule.AppModule
OVMModule ovmmodule.AppModule
RewardModule rewardmodule.AppModule
SubaccountModule subaccountmodule.AppModule

// make scoped keepers public for test purposes
ScopedIBCKeeper capabilitykeeper.ScopedKeeper
Expand Down Expand Up @@ -381,7 +393,7 @@ func NewAppKeeper(
appKeepers.SlashingKeeper,
)

//// SGE keepers \\\\
// // SGE keepers \\\\

appKeepers.OrderbookKeeper = orderbookmodulekeeper.NewKeeper(
appCodec,
Expand Down Expand Up @@ -436,7 +448,42 @@ func NewAppKeeper(
)
appKeepers.OrderbookKeeper.SetHouseKeeper(appKeepers.HouseKeeper)

//// SGE modules \\\\
appKeepers.SubaccountKeeper = subaccountmodulekeeper.NewKeeper(
appCodec,
appKeepers.keys[subaccountmoduletypes.StoreKey],
appKeepers.GetSubspace(subaccountmoduletypes.ModuleName),
appKeepers.AccountKeeper,
appKeepers.BankKeeper,
appKeepers.OVMKeeper,
appKeepers.BetKeeper,
appKeepers.OrderbookKeeper,
appKeepers.HouseKeeper,
)

appKeepers.RewardKeeper = rewardmodulekeeper.NewKeeper(
appCodec,
appKeepers.keys[rewardmoduletypes.StoreKey],
appKeepers.keys[rewardmoduletypes.MemStoreKey],
appKeepers.GetSubspace(rewardmoduletypes.ModuleName),
appKeepers.BetKeeper,
appKeepers.OVMKeeper,
appKeepers.SubaccountKeeper,
rewardmodulekeeper.SdkExpectedKeepers{
AuthzKeeper: appKeepers.AuthzKeeper,
BankKeeper: appKeepers.BankKeeper,
AccountKeeper: appKeepers.AccountKeeper,
},
)

// ** Hooks ** \\

appKeepers.OrderbookKeeper.SetHooks(
orderbookmoduletypes.NewMultiOrderBookHooks(
appKeepers.SubaccountKeeper.Hooks(),
),
)

// // SGE modules \\\\

appKeepers.BetModule = betmodule.NewAppModule(
appCodec,
Expand Down Expand Up @@ -468,6 +515,14 @@ func NewAppKeeper(
appKeepers.AccountKeeper,
appKeepers.BankKeeper,
)
appKeepers.RewardModule = rewardmodule.NewAppModule(
appCodec,
*appKeepers.RewardKeeper,
appKeepers.AccountKeeper,
appKeepers.BankKeeper,
)

appKeepers.SubaccountModule = subaccountmodule.NewAppModule(*appKeepers.SubaccountKeeper)

//// IBC modules \\\\
appKeepers.IBCModule = ibc.NewAppModule(appKeepers.IBCKeeper)
Expand Down Expand Up @@ -530,6 +585,8 @@ func initParamsKeeper(appCodec codec.BinaryCodec,
paramsKeeper.Subspace(orderbookmoduletypes.ModuleName)
paramsKeeper.Subspace(ovmmoduletypes.ModuleName)
paramsKeeper.Subspace(housemoduletypes.ModuleName)
paramsKeeper.Subspace(rewardmoduletypes.ModuleName)
paramsKeeper.Subspace(subaccountmoduletypes.ModuleName)

return paramsKeeper
}
8 changes: 6 additions & 2 deletions app/keepers/keys.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,21 @@ import (
slashingtypes "github.com/cosmos/cosmos-sdk/x/slashing/types"
stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"
upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types"

icacontrollertypes "github.com/cosmos/ibc-go/v5/modules/apps/27-interchain-accounts/controller/types"
icahosttypes "github.com/cosmos/ibc-go/v5/modules/apps/27-interchain-accounts/host/types"
ibcfeetypes "github.com/cosmos/ibc-go/v5/modules/apps/29-fee/types"
ibctransfertypes "github.com/cosmos/ibc-go/v5/modules/apps/transfer/types"
ibchost "github.com/cosmos/ibc-go/v5/modules/core/24-host"

betmoduletypes "github.com/sge-network/sge/x/bet/types"
ovmmoduletypes "github.com/sge-network/sge/x/ovm/types"

housemoduletypes "github.com/sge-network/sge/x/house/types"
marketmoduletypes "github.com/sge-network/sge/x/market/types"
minttypes "github.com/sge-network/sge/x/mint/types"
orderbookmoduletypes "github.com/sge-network/sge/x/orderbook/types"
ovmmoduletypes "github.com/sge-network/sge/x/ovm/types"
rewardmoduletypes "github.com/sge-network/sge/x/reward/types"
subaccounttypes "github.com/sge-network/sge/x/subaccount/types"

// unnamed import of statik for swagger UI support
_ "github.com/cosmos/cosmos-sdk/client/docs/statik"
Expand All @@ -49,6 +51,8 @@ func (appKeepers *AppKeepers) GenerateKeys() {
marketmoduletypes.StoreKey,
ovmmoduletypes.StoreKey,
housemoduletypes.StoreKey,
rewardmoduletypes.StoreKey,
subaccounttypes.StoreKey,
)

// Define transient store keys
Expand Down
36 changes: 25 additions & 11 deletions app/modules.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ import (
stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"
"github.com/cosmos/cosmos-sdk/x/upgrade"
upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types"

ica "github.com/cosmos/ibc-go/v5/modules/apps/27-interchain-accounts"
icatypes "github.com/cosmos/ibc-go/v5/modules/apps/27-interchain-accounts/types"
ibcfee "github.com/cosmos/ibc-go/v5/modules/apps/29-fee"
Expand All @@ -43,24 +44,25 @@ import (
ibctransfertypes "github.com/cosmos/ibc-go/v5/modules/apps/transfer/types"
ibc "github.com/cosmos/ibc-go/v5/modules/core"
ibchost "github.com/cosmos/ibc-go/v5/modules/core/24-host"
sgeappparams "github.com/sge-network/sge/app/params"
"github.com/sge-network/sge/x/mint"
minttypes "github.com/sge-network/sge/x/mint/types"

sgeappparams "github.com/sge-network/sge/app/params"
betmodule "github.com/sge-network/sge/x/bet"
betmoduletypes "github.com/sge-network/sge/x/bet/types"

housemodule "github.com/sge-network/sge/x/house"
housemoduletypes "github.com/sge-network/sge/x/house/types"
marketmodule "github.com/sge-network/sge/x/market"
marketmoduletypes "github.com/sge-network/sge/x/market/types"

mintmodule "github.com/sge-network/sge/x/mint"
minttypes "github.com/sge-network/sge/x/mint/types"
orderbookmodule "github.com/sge-network/sge/x/orderbook"
orderbookmoduletypes "github.com/sge-network/sge/x/orderbook/types"

ovmmodule "github.com/sge-network/sge/x/ovm"
ovmmoduletypes "github.com/sge-network/sge/x/ovm/types"
subaccountmodule "github.com/sge-network/sge/x/subaccount"
subaccounttypes "github.com/sge-network/sge/x/subaccount/types"

housemodule "github.com/sge-network/sge/x/house"
housemoduletypes "github.com/sge-network/sge/x/house/types"
rewardmodule "github.com/sge-network/sge/x/reward"
rewardmoduletypes "github.com/sge-network/sge/x/reward/types"

// unnamed import of statik for swagger UI support
_ "github.com/cosmos/cosmos-sdk/client/docs/statik"
Expand All @@ -84,6 +86,7 @@ var mAccPerms = map[string][]string{
betmoduletypes.BetFeeCollectorFunder{}.GetModuleAcc(): nil,
housemoduletypes.HouseFeeCollectorFunder{}.GetModuleAcc(): nil,
orderbookmoduletypes.OrderBookLiquidityFunder{}.GetModuleAcc(): nil,
rewardmoduletypes.RewardPoolFunder{}.GetModuleAcc(): nil,
}

// ModuleBasics defines the module BasicManager is in charge of setting up basic,
Expand All @@ -95,7 +98,7 @@ var ModuleBasics = module.NewBasicManager(
bank.AppModuleBasic{},
capability.AppModuleBasic{},
staking.AppModuleBasic{},
mint.AppModuleBasic{},
mintmodule.AppModuleBasic{},
distr.AppModuleBasic{},
gov.NewAppModuleBasic(getGovProposalHandlers()),
params.AppModuleBasic{},
Expand All @@ -118,6 +121,8 @@ var ModuleBasics = module.NewBasicManager(
orderbookmodule.AppModuleBasic{},
ovmmodule.AppModuleBasic{},
housemodule.AppModuleBasic{},
rewardmodule.AppModuleBasic{},
subaccountmodule.AppModuleBasic{},
)

func appModules(
Expand All @@ -140,7 +145,7 @@ func appModules(
capability.NewAppModule(appCodec, *app.CapabilityKeeper),
crisis.NewAppModule(&app.CrisisKeeper, skipGenesisInvariants),
gov.NewAppModule(appCodec, app.GovKeeper, app.AccountKeeper, app.BankKeeper),
mint.NewAppModule(appCodec, app.MintKeeper, app.AccountKeeper, app.BankKeeper),
mintmodule.NewAppModule(appCodec, app.MintKeeper, app.AccountKeeper, app.BankKeeper),
slashing.NewAppModule(
appCodec,
app.SlashingKeeper,
Expand Down Expand Up @@ -189,6 +194,8 @@ func appModules(
app.OrderbookModule,
app.OVMModule,
app.HouseModule,
app.RewardModule,
app.SubaccountModule,
// this line is u
}
}
Expand All @@ -214,7 +221,7 @@ func simulationModules(
app.interfaceRegistry,
),
gov.NewAppModule(appCodec, app.GovKeeper, app.AccountKeeper, app.BankKeeper),
mint.NewAppModule(appCodec, app.MintKeeper, app.AccountKeeper, nil),
mintmodule.NewAppModule(appCodec, app.MintKeeper, app.AccountKeeper, nil),
staking.NewAppModule(appCodec, app.StakingKeeper, app.AccountKeeper, app.BankKeeper),
distr.NewAppModule(
appCodec,
Expand Down Expand Up @@ -251,6 +258,7 @@ func simulationModules(
app.BetModule,
app.MarketModule,
app.OVMModule,
app.RewardModule,
}
}

Expand Down Expand Up @@ -285,6 +293,8 @@ func orderBeginBlockers() []string {
orderbookmoduletypes.ModuleName,
ovmmoduletypes.ModuleName,
housemoduletypes.ModuleName,
rewardmoduletypes.ModuleName,
subaccounttypes.ModuleName,
}
}

Expand Down Expand Up @@ -316,6 +326,8 @@ func orderEndBlockers() []string {
orderbookmoduletypes.ModuleName,
ovmmoduletypes.ModuleName,
housemoduletypes.ModuleName,
rewardmoduletypes.ModuleName,
subaccounttypes.ModuleName,
}
}

Expand Down Expand Up @@ -347,5 +359,7 @@ func orderInitBlockers() []string {
orderbookmoduletypes.ModuleName,
ovmmoduletypes.ModuleName,
housemoduletypes.ModuleName,
rewardmoduletypes.ModuleName,
subaccounttypes.ModuleName,
}
}
Loading

0 comments on commit 5bd66c2

Please sign in to comment.