Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: make configurator.Config public (backport #16624) #16626

Merged
merged 1 commit into from
Jun 20, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 23 additions & 22 deletions testutil/configurator/configurator.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,15 +91,16 @@ var initGenesisOrder = []string{
"circuit",
}

type appConfig struct {
// Config should never need to be instantiated manually and is solely used for ModuleOption.
type Config struct {
moduleConfigs map[string]*appv1alpha1.ModuleConfig
setInitGenesis bool
}

type ModuleOption func(config *appConfig)
type ModuleOption func(config *Config)

func BankModule() ModuleOption {
return func(config *appConfig) {
return func(config *Config) {
config.moduleConfigs["bank"] = &appv1alpha1.ModuleConfig{
Name: "bank",
Config: appconfig.WrapAny(&bankmodulev1.Module{}),
Expand All @@ -108,7 +109,7 @@ func BankModule() ModuleOption {
}

func AuthModule() ModuleOption {
return func(config *appConfig) {
return func(config *Config) {
config.moduleConfigs["auth"] = &appv1alpha1.ModuleConfig{
Name: "auth",
Config: appconfig.WrapAny(&authmodulev1.Module{
Expand All @@ -128,7 +129,7 @@ func AuthModule() ModuleOption {
}

func ParamsModule() ModuleOption {
return func(config *appConfig) {
return func(config *Config) {
config.moduleConfigs["params"] = &appv1alpha1.ModuleConfig{
Name: "params",
Config: appconfig.WrapAny(&paramsmodulev1.Module{}),
Expand All @@ -137,7 +138,7 @@ func ParamsModule() ModuleOption {
}

func TxModule() ModuleOption {
return func(config *appConfig) {
return func(config *Config) {
config.moduleConfigs["tx"] = &appv1alpha1.ModuleConfig{
Name: "tx",
Config: appconfig.WrapAny(&txconfigv1.Config{}),
Expand All @@ -146,7 +147,7 @@ func TxModule() ModuleOption {
}

func StakingModule() ModuleOption {
return func(config *appConfig) {
return func(config *Config) {
config.moduleConfigs["staking"] = &appv1alpha1.ModuleConfig{
Name: "staking",
Config: appconfig.WrapAny(&stakingmodulev1.Module{}),
Expand All @@ -155,7 +156,7 @@ func StakingModule() ModuleOption {
}

func SlashingModule() ModuleOption {
return func(config *appConfig) {
return func(config *Config) {
config.moduleConfigs["slashing"] = &appv1alpha1.ModuleConfig{
Name: "slashing",
Config: appconfig.WrapAny(&slashingmodulev1.Module{}),
Expand All @@ -164,7 +165,7 @@ func SlashingModule() ModuleOption {
}

func GenutilModule() ModuleOption {
return func(config *appConfig) {
return func(config *Config) {
config.moduleConfigs["genutil"] = &appv1alpha1.ModuleConfig{
Name: "genutil",
Config: appconfig.WrapAny(&genutilmodulev1.Module{}),
Expand All @@ -173,7 +174,7 @@ func GenutilModule() ModuleOption {
}

func DistributionModule() ModuleOption {
return func(config *appConfig) {
return func(config *Config) {
config.moduleConfigs["distribution"] = &appv1alpha1.ModuleConfig{
Name: "distribution",
Config: appconfig.WrapAny(&distrmodulev1.Module{}),
Expand All @@ -182,7 +183,7 @@ func DistributionModule() ModuleOption {
}

func FeegrantModule() ModuleOption {
return func(config *appConfig) {
return func(config *Config) {
config.moduleConfigs["feegrant"] = &appv1alpha1.ModuleConfig{
Name: "feegrant",
Config: appconfig.WrapAny(&feegrantmodulev1.Module{}),
Expand All @@ -191,7 +192,7 @@ func FeegrantModule() ModuleOption {
}

func VestingModule() ModuleOption {
return func(config *appConfig) {
return func(config *Config) {
config.moduleConfigs["vesting"] = &appv1alpha1.ModuleConfig{
Name: "vesting",
Config: appconfig.WrapAny(&vestingmodulev1.Module{}),
Expand All @@ -200,7 +201,7 @@ func VestingModule() ModuleOption {
}

func GovModule() ModuleOption {
return func(config *appConfig) {
return func(config *Config) {
config.moduleConfigs["gov"] = &appv1alpha1.ModuleConfig{
Name: "gov",
Config: appconfig.WrapAny(&govmodulev1.Module{}),
Expand All @@ -209,7 +210,7 @@ func GovModule() ModuleOption {
}

func ConsensusModule() ModuleOption {
return func(config *appConfig) {
return func(config *Config) {
config.moduleConfigs["consensus"] = &appv1alpha1.ModuleConfig{
Name: "consensus",
Config: appconfig.WrapAny(&consensusmodulev1.Module{}),
Expand All @@ -218,7 +219,7 @@ func ConsensusModule() ModuleOption {
}

func MintModule() ModuleOption {
return func(config *appConfig) {
return func(config *Config) {
config.moduleConfigs["mint"] = &appv1alpha1.ModuleConfig{
Name: "mint",
Config: appconfig.WrapAny(&mintmodulev1.Module{}),
Expand All @@ -233,7 +234,7 @@ func MintModule() ModuleOption {
}

func EvidenceModule() ModuleOption {
return func(config *appConfig) {
return func(config *Config) {
config.moduleConfigs["evidence"] = &appv1alpha1.ModuleConfig{
Name: "evidence",
Config: appconfig.WrapAny(&evidencemodulev1.Module{}),
Expand All @@ -242,7 +243,7 @@ func EvidenceModule() ModuleOption {
}

func AuthzModule() ModuleOption {
return func(config *appConfig) {
return func(config *Config) {
config.moduleConfigs["authz"] = &appv1alpha1.ModuleConfig{
Name: "authz",
Config: appconfig.WrapAny(&authzmodulev1.Module{}),
Expand All @@ -251,7 +252,7 @@ func AuthzModule() ModuleOption {
}

func GroupModule() ModuleOption {
return func(config *appConfig) {
return func(config *Config) {
config.moduleConfigs["group"] = &appv1alpha1.ModuleConfig{
Name: "group",
Config: appconfig.WrapAny(&groupmodulev1.Module{}),
Expand All @@ -260,7 +261,7 @@ func GroupModule() ModuleOption {
}

func NFTModule() ModuleOption {
return func(config *appConfig) {
return func(config *Config) {
config.moduleConfigs["nft"] = &appv1alpha1.ModuleConfig{
Name: "nft",
Config: appconfig.WrapAny(&nftmodulev1.Module{}),
Expand All @@ -269,7 +270,7 @@ func NFTModule() ModuleOption {
}

func CircuitModule() ModuleOption {
return func(config *appConfig) {
return func(config *Config) {
config.moduleConfigs["circuit"] = &appv1alpha1.ModuleConfig{
Name: "circuit",
Config: appconfig.WrapAny(&circuitmodulev1.Module{}),
Expand All @@ -278,13 +279,13 @@ func CircuitModule() ModuleOption {
}

func OmitInitGenesis() ModuleOption {
return func(config *appConfig) {
return func(config *Config) {
config.setInitGenesis = false
}
}

func NewAppConfig(opts ...ModuleOption) depinject.Config {
cfg := &appConfig{
cfg := &Config{
moduleConfigs: make(map[string]*appv1alpha1.ModuleConfig),
setInitGenesis: true,
}
Expand Down