Skip to content

Commit

Permalink
feat(app.go): import authz module (#559)
Browse files Browse the repository at this point in the history
* add authz

* lint

* fix simulation tests
  • Loading branch information
lumtis authored Feb 23, 2022
1 parent d09ee16 commit dfeb8aa
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 11 deletions.
16 changes: 16 additions & 0 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ import (
authtx "github.com/cosmos/cosmos-sdk/x/auth/tx"
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
"github.com/cosmos/cosmos-sdk/x/auth/vesting"
"github.com/cosmos/cosmos-sdk/x/authz"
authzkeeper "github.com/cosmos/cosmos-sdk/x/authz/keeper"
authzmodule "github.com/cosmos/cosmos-sdk/x/authz/module"
"github.com/cosmos/cosmos-sdk/x/bank"
bankkeeper "github.com/cosmos/cosmos-sdk/x/bank/keeper"
banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"
Expand Down Expand Up @@ -160,6 +163,7 @@ var (
crisis.AppModuleBasic{},
slashing.AppModuleBasic{},
feegrantmodule.AppModuleBasic{},
authzmodule.AppModuleBasic{},
ibc.AppModuleBasic{},
upgrade.AppModuleBasic{},
evidence.AppModuleBasic{},
Expand Down Expand Up @@ -238,6 +242,7 @@ type App struct {
EvidenceKeeper evidencekeeper.Keeper
TransferKeeper ibctransferkeeper.Keeper
FeeGrantKeeper feegrantkeeper.Keeper
AuthzKeeper authzkeeper.Keeper
FundraisingKeeper fundraisingkeeper.Keeper

// make scoped keepers public for test purposes
Expand Down Expand Up @@ -295,6 +300,7 @@ func New(
ibchost.StoreKey,
upgradetypes.StoreKey,
feegrant.StoreKey,
authzkeeper.StoreKey,
evidencetypes.StoreKey,
ibctransfertypes.StoreKey,
capabilitytypes.StoreKey,
Expand Down Expand Up @@ -337,6 +343,11 @@ func New(
app.AuthKeeper = authkeeper.NewAccountKeeper(
appCodec, keys[authtypes.StoreKey], app.GetSubspace(authtypes.ModuleName), authtypes.ProtoBaseAccount, maccPerms,
)
app.AuthzKeeper = authzkeeper.NewKeeper(
keys[authzkeeper.StoreKey],
appCodec,
app.BaseApp.MsgServiceRouter(),
)
app.BankKeeper = bankkeeper.NewBaseKeeper(
appCodec, keys[banktypes.StoreKey], app.AuthKeeper, app.GetSubspace(banktypes.ModuleName), app.ModuleAccountAddrs(),
)
Expand Down Expand Up @@ -494,6 +505,7 @@ func New(
bank.NewAppModule(appCodec, app.BankKeeper, app.AuthKeeper),
capability.NewAppModule(appCodec, *app.CapabilityKeeper),
feegrantmodule.NewAppModule(appCodec, app.AuthKeeper, app.BankKeeper, app.FeeGrantKeeper, app.interfaceRegistry),
authzmodule.NewAppModule(appCodec, app.AuthzKeeper, app.AuthKeeper, app.BankKeeper, app.interfaceRegistry),
crisis.NewAppModule(&app.CrisisKeeper, skipGenesisInvariants),
gov.NewAppModule(appCodec, app.GovKeeper, app.AuthKeeper, app.BankKeeper),
mint.NewAppModule(appCodec, app.MintKeeper, app.AuthKeeper),
Expand Down Expand Up @@ -535,6 +547,7 @@ func New(
govtypes.ModuleName,
stakingtypes.ModuleName,
feegrant.ModuleName,
authz.ModuleName,
fundraisingtypes.ModuleName,
)

Expand All @@ -557,6 +570,8 @@ func New(
genutiltypes.ModuleName,
evidencetypes.ModuleName,
ibctransfertypes.ModuleName,
feegrant.ModuleName,
authz.ModuleName,
profilemoduletypes.ModuleName,
launchmoduletypes.ModuleName,
campaignmoduletypes.ModuleName,
Expand All @@ -576,6 +591,7 @@ func New(
bank.NewAppModule(appCodec, app.BankKeeper, app.AuthKeeper),
capability.NewAppModule(appCodec, *app.CapabilityKeeper),
feegrantmodule.NewAppModule(appCodec, app.AuthKeeper, app.BankKeeper, app.FeeGrantKeeper, app.interfaceRegistry),
authzmodule.NewAppModule(appCodec, app.AuthzKeeper, app.AuthKeeper, app.BankKeeper, app.interfaceRegistry),
gov.NewAppModule(appCodec, app.GovKeeper, app.AuthKeeper, app.BankKeeper),
mint.NewAppModule(appCodec, app.MintKeeper, app.AuthKeeper),
staking.NewAppModule(appCodec, app.StakingKeeper, app.AuthKeeper, app.BankKeeper),
Expand Down
16 changes: 5 additions & 11 deletions x/launch/simulation/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ import (
"fmt"
"math/rand"

profiletypes "github.com/tendermint/spn/x/profile/types"

sdk "github.com/cosmos/cosmos-sdk/types"
simtypes "github.com/cosmos/cosmos-sdk/types/simulation"

Expand Down Expand Up @@ -80,9 +78,8 @@ func FindRandomChain(
continue
}
// check if the coordinator is still in the store and active
var coord profiletypes.Coordinator
coord, found = k.GetProfileKeeper().GetCoordinator(ctx, c.CoordinatorID)
if !found || !coord.Active {
coord, coordFound := k.GetProfileKeeper().GetCoordinator(ctx, c.CoordinatorID)
if !coordFound || !coord.Active {
continue
}
chain = c
Expand All @@ -104,17 +101,14 @@ func FindRandomRequest(
r.Shuffle(len(requests), func(i, j int) {
requests[i], requests[j] = requests[j], requests[i]
})
var chain types.Chain
var chainFound bool
for _, req := range requests {
chain, chainFound = k.GetChain(ctx, req.LaunchID)
chain, chainFound := k.GetChain(ctx, req.LaunchID)
if !chainFound || chain.LaunchTriggered {
continue
}
// check if the coordinator is still in the store and active
var coord profiletypes.Coordinator
coord, found = k.GetProfileKeeper().GetCoordinator(ctx, chain.CoordinatorID)
if !found || !coord.Active {
coord, coordFound := k.GetProfileKeeper().GetCoordinator(ctx, chain.CoordinatorID)
if !coordFound || !coord.Active {
continue
}

Expand Down

0 comments on commit dfeb8aa

Please sign in to comment.