@@ -25,79 +25,102 @@ import (
25
25
"cosmossdk.io/depinject"
26
26
)
27
27
28
- var beginBlockOrder = []string {
29
- "upgrade" ,
30
- "mint" ,
31
- "distribution" ,
32
- "slashing" ,
33
- "evidence" ,
34
- "staking" ,
35
- "auth" ,
36
- "bank" ,
37
- "gov" ,
38
- "crisis" ,
39
- "genutil" ,
40
- "authz" ,
41
- "feegrant" ,
42
- "nft" ,
43
- "group" ,
44
- "params" ,
45
- "consensus" ,
46
- "vesting" ,
47
- "circuit" ,
28
+ // Config should never need to be instantiated manually and is solely used for ModuleOption.
29
+ type Config struct {
30
+ ModuleConfigs map [string ]* appv1alpha1.ModuleConfig
31
+ BeginBlockersOrder []string
32
+ EndBlockersOrder []string
33
+ InitGenesisOrder []string
34
+ setInitGenesis bool
48
35
}
49
36
50
- var endBlockersOrder = []string {
51
- "crisis" ,
52
- "gov" ,
53
- "staking" ,
54
- "auth" ,
55
- "bank" ,
56
- "distribution" ,
57
- "slashing" ,
58
- "mint" ,
59
- "genutil" ,
60
- "evidence" ,
61
- "authz" ,
62
- "feegrant" ,
63
- "nft" ,
64
- "group" ,
65
- "params" ,
66
- "consensus" ,
67
- "upgrade" ,
68
- "vesting" ,
69
- "circuit" ,
37
+ var defaultConfig = & Config {
38
+ ModuleConfigs : make (map [string ]* appv1alpha1.ModuleConfig ),
39
+ BeginBlockersOrder : []string {
40
+ "upgrade" ,
41
+ "mint" ,
42
+ "distribution" ,
43
+ "slashing" ,
44
+ "evidence" ,
45
+ "staking" ,
46
+ "auth" ,
47
+ "bank" ,
48
+ "gov" ,
49
+ "crisis" ,
50
+ "genutil" ,
51
+ "authz" ,
52
+ "feegrant" ,
53
+ "nft" ,
54
+ "group" ,
55
+ "params" ,
56
+ "consensus" ,
57
+ "vesting" ,
58
+ "circuit" ,
59
+ },
60
+ EndBlockersOrder : []string {
61
+ "crisis" ,
62
+ "gov" ,
63
+ "staking" ,
64
+ "auth" ,
65
+ "bank" ,
66
+ "distribution" ,
67
+ "slashing" ,
68
+ "mint" ,
69
+ "genutil" ,
70
+ "evidence" ,
71
+ "authz" ,
72
+ "feegrant" ,
73
+ "nft" ,
74
+ "group" ,
75
+ "params" ,
76
+ "consensus" ,
77
+ "upgrade" ,
78
+ "vesting" ,
79
+ "circuit" ,
80
+ },
81
+ InitGenesisOrder : []string {
82
+ "auth" ,
83
+ "bank" ,
84
+ "distribution" ,
85
+ "staking" ,
86
+ "slashing" ,
87
+ "gov" ,
88
+ "mint" ,
89
+ "crisis" ,
90
+ "genutil" ,
91
+ "evidence" ,
92
+ "authz" ,
93
+ "feegrant" ,
94
+ "nft" ,
95
+ "group" ,
96
+ "params" ,
97
+ "consensus" ,
98
+ "upgrade" ,
99
+ "vesting" ,
100
+ "circuit" ,
101
+ },
102
+ setInitGenesis : true ,
70
103
}
71
104
72
- var initGenesisOrder = []string {
73
- "auth" ,
74
- "bank" ,
75
- "distribution" ,
76
- "staking" ,
77
- "slashing" ,
78
- "gov" ,
79
- "mint" ,
80
- "crisis" ,
81
- "genutil" ,
82
- "evidence" ,
83
- "authz" ,
84
- "feegrant" ,
85
- "nft" ,
86
- "group" ,
87
- "params" ,
88
- "consensus" ,
89
- "upgrade" ,
90
- "vesting" ,
91
- "circuit" ,
105
+ type ModuleOption func (config * Config )
106
+
107
+ func WithCustomBeginBlockersOrder (beginBlockOrder ... string ) ModuleOption {
108
+ return func (config * Config ) {
109
+ config .BeginBlockersOrder = beginBlockOrder
110
+ }
92
111
}
93
112
94
- // Config should never need to be instantiated manually and is solely used for ModuleOption.
95
- type Config struct {
96
- ModuleConfigs map [ string ] * appv1alpha1. ModuleConfig
97
- setInitGenesis bool
113
+ func WithCustomEndBlockersOrder ( endBlockersOrder ... string ) ModuleOption {
114
+ return func ( config * Config ) {
115
+ config . EndBlockersOrder = endBlockersOrder
116
+ }
98
117
}
99
118
100
- type ModuleOption func (config * Config )
119
+ func WithCustomInitGenesisOrder (initGenesisOrder ... string ) ModuleOption {
120
+ return func (config * Config ) {
121
+ config .InitGenesisOrder = initGenesisOrder
122
+ }
123
+ }
101
124
102
125
func BankModule () ModuleOption {
103
126
return func (config * Config ) {
@@ -285,10 +308,7 @@ func OmitInitGenesis() ModuleOption {
285
308
}
286
309
287
310
func NewAppConfig (opts ... ModuleOption ) depinject.Config {
288
- cfg := & Config {
289
- ModuleConfigs : make (map [string ]* appv1alpha1.ModuleConfig ),
290
- setInitGenesis : true ,
291
- }
311
+ cfg := defaultConfig
292
312
for _ , opt := range opts {
293
313
opt (cfg )
294
314
}
@@ -298,19 +318,19 @@ func NewAppConfig(opts ...ModuleOption) depinject.Config {
298
318
initGenesis := make ([]string , 0 )
299
319
overrides := make ([]* runtimev1alpha1.StoreKeyConfig , 0 )
300
320
301
- for _ , s := range beginBlockOrder {
321
+ for _ , s := range cfg . BeginBlockersOrder {
302
322
if _ , ok := cfg .ModuleConfigs [s ]; ok {
303
323
beginBlockers = append (beginBlockers , s )
304
324
}
305
325
}
306
326
307
- for _ , s := range endBlockersOrder {
327
+ for _ , s := range cfg . EndBlockersOrder {
308
328
if _ , ok := cfg .ModuleConfigs [s ]; ok {
309
329
endBlockers = append (endBlockers , s )
310
330
}
311
331
}
312
332
313
- for _ , s := range initGenesisOrder {
333
+ for _ , s := range cfg . InitGenesisOrder {
314
334
if _ , ok := cfg .ModuleConfigs [s ]; ok {
315
335
initGenesis = append (initGenesis , s )
316
336
}
0 commit comments