github.com/Finschia/finschia-sdk@v0.48.1/x/foundation/keeper/internal/keeper.go (about) 1 package internal 2 3 import ( 4 "github.com/Finschia/ostracon/libs/log" 5 6 "github.com/Finschia/finschia-sdk/baseapp" 7 "github.com/Finschia/finschia-sdk/codec" 8 sdk "github.com/Finschia/finschia-sdk/types" 9 "github.com/Finschia/finschia-sdk/x/foundation" 10 paramtypes "github.com/Finschia/finschia-sdk/x/params/types" 11 ) 12 13 // Keeper defines the foundation module Keeper 14 type Keeper struct { 15 // The codec for binary encoding/decoding. 16 cdc codec.Codec 17 18 // The (unexposed) keys used to access the stores from the Context. 19 storeKey sdk.StoreKey 20 21 router *baseapp.MsgServiceRouter 22 23 // keepers 24 authKeeper foundation.AuthKeeper 25 bankKeeper foundation.BankKeeper 26 27 feeCollectorName string 28 29 config foundation.Config 30 31 // The address capable of executing privileged messages, including: 32 // - MsgUpdateParams 33 // - MsgUpdateDecisionPolicy 34 // - MsgUpdateMembers 35 // - MsgWithdrawFromTreasury 36 // 37 // Typically, this should be the x/foundation module account. 38 authority string 39 40 paramSpace paramtypes.Subspace 41 } 42 43 func NewKeeper( 44 cdc codec.Codec, 45 key sdk.StoreKey, 46 router *baseapp.MsgServiceRouter, 47 authKeeper foundation.AuthKeeper, 48 bankKeeper foundation.BankKeeper, 49 feeCollectorName string, 50 config foundation.Config, 51 authority string, 52 paramSpace paramtypes.Subspace, 53 ) Keeper { 54 if _, err := sdk.AccAddressFromBech32(authority); err != nil { 55 panic("authority is not a valid acc address") 56 } 57 58 // authority is x/foundation module account for now. 59 if authority != foundation.DefaultAuthority().String() { 60 panic("x/foundation authority must be the module account") 61 } 62 63 // set KeyTable if it has not already been set 64 if !paramSpace.HasKeyTable() { 65 paramSpace = paramSpace.WithKeyTable(foundation.ParamKeyTable()) 66 } 67 68 return Keeper{ 69 cdc: cdc, 70 storeKey: key, 71 router: router, 72 authKeeper: authKeeper, 73 bankKeeper: bankKeeper, 74 feeCollectorName: feeCollectorName, 75 config: config, 76 authority: authority, 77 paramSpace: paramSpace, 78 } 79 } 80 81 // GetAuthority returns the x/foundation module's authority. 82 func (k Keeper) GetAuthority() string { 83 return k.authority 84 } 85 86 // Logger returns a module-specific logger. 87 func (k Keeper) Logger(ctx sdk.Context) log.Logger { 88 return ctx.Logger().With("module", "x/"+foundation.ModuleName) 89 }