forked from cosmos/ibc-apps
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdepinject.go
63 lines (50 loc) · 1.43 KB
/
depinject.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
package ratelimit
import (
modulev1 "github.com/cosmos/ibc-apps/modules/rate-limiting/v8/api/ratelimit/module/v1"
"github.com/cosmos/ibc-apps/modules/rate-limiting/v8/keeper"
"github.com/cosmos/ibc-apps/modules/rate-limiting/v8/types"
"cosmossdk.io/core/appmodule"
"cosmossdk.io/core/store"
"cosmossdk.io/depinject"
"github.com/cosmos/cosmos-sdk/codec"
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
paramstypes "github.com/cosmos/cosmos-sdk/x/params/types"
)
var _ depinject.OnePerModuleType = AppModule{}
// IsOnePerModuleType implements the depinject.OnePerModuleType interface.
func (am AppModule) IsOnePerModuleType() {}
func init() {
appmodule.Register(&modulev1.Module{},
appmodule.Provide(ProvideModule),
)
}
type ModuleInputs struct {
depinject.In
Config *modulev1.Module
Cdc codec.Codec
StoreService store.KVStoreService
Subspace paramstypes.Subspace
BankKeeper types.BankKeeper
}
type ModuleOutputs struct {
depinject.Out
Keeper *keeper.Keeper
Module appmodule.AppModule
}
func ProvideModule(in ModuleInputs) ModuleOutputs {
if in.Config.Authority == "" {
panic("authority for x/ratelimit module must be set")
}
authority := authtypes.NewModuleAddressOrBech32Address(in.Config.Authority)
k := keeper.NewKeeper(
in.Cdc,
in.StoreService,
in.Subspace,
authority.String(),
in.BankKeeper,
nil,
nil,
)
m := NewAppModule(in.Cdc, *k)
return ModuleOutputs{Keeper: k, Module: m}
}