Skip to content

Commit

Permalink
set customizable authority
Browse files Browse the repository at this point in the history
  • Loading branch information
julienrbrt committed Jul 20, 2022
1 parent bff04dc commit 4aecd3c
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 4 deletions.
11 changes: 10 additions & 1 deletion simapp/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -193,8 +193,17 @@ func NewSimApp(
app = &SimApp{}
appBuilder *runtime.AppBuilder

// authorities definition
bankAuthority = banktypes.Authority(authtypes.NewModuleAddress(govtypes.ModuleName))

// merge the app.yaml and the appOpts in one config
appConfig = depinject.Configs(AppConfig, depinject.Supply(appOpts))
appConfig = depinject.Configs(
AppConfig,
depinject.Supply(
appOpts,
bankAuthority,
),
)
)

if err := depinject.Inject(appConfig,
Expand Down
6 changes: 3 additions & 3 deletions x/bank/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,12 @@ import (
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/module"
simtypes "github.com/cosmos/cosmos-sdk/types/simulation"
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
"github.com/cosmos/cosmos-sdk/x/bank/client/cli"
"github.com/cosmos/cosmos-sdk/x/bank/exported"
"github.com/cosmos/cosmos-sdk/x/bank/keeper"
v1bank "github.com/cosmos/cosmos-sdk/x/bank/migrations/v1"
"github.com/cosmos/cosmos-sdk/x/bank/simulation"
"github.com/cosmos/cosmos-sdk/x/bank/types"
govtypes "github.com/cosmos/cosmos-sdk/x/gov/types"
)

// ConsensusVersion defines the current x/bank module consensus version.
Expand Down Expand Up @@ -233,6 +231,7 @@ type bankInputs struct {
Key *store.KVStoreKey

AccountKeeper types.AccountKeeper
Authority types.Authority

// LegacySubspace is used solely for migration of x/params managed parameters
LegacySubspace exported.Subspace
Expand Down Expand Up @@ -267,8 +266,9 @@ func provideModule(in bankInputs) bankOutputs {
in.Key,
in.AccountKeeper,
blockedAddresses,
authtypes.NewModuleAddress(govtypes.ModuleName).String(),
in.Authority.String(),
)
m := NewAppModule(in.Cdc, bankKeeper, in.AccountKeeper, in.LegacySubspace)

return bankOutputs{BankKeeper: bankKeeper, Module: runtime.WrapAppModule(m)}
}
11 changes: 11 additions & 0 deletions x/bank/types/authority.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package types

import (
sdk "github.com/cosmos/cosmos-sdk/types"
)

type Authority sdk.AccAddress

func (a Authority) String() string {
return sdk.AccAddress(a).String()
}

0 comments on commit 4aecd3c

Please sign in to comment.