diff --git a/x/ccv/consumer/keeper/params.go b/x/ccv/consumer/keeper/params.go index 8ec4e76104..7adad420aa 100644 --- a/x/ccv/consumer/keeper/params.go +++ b/x/ccv/consumer/keeper/params.go @@ -44,19 +44,28 @@ func (k Keeper) GetParams(context.Context) (stakingtypes.Params, error) { // GetEnabled returns the enabled flag for the consumer module func (k Keeper) GetEnabled(ctx sdk.Context) bool { - params, _ := k.GetConsumerParams(ctx) //TODO @bermuell: Check behaviour for error case + params, err := k.GetConsumerParams(ctx) + if err != nil { + k.Logger(ctx).Error("error getting parameter 'enabled': %v", err) + return params.Enabled + } return params.Enabled } func (k Keeper) GetBlocksPerDistributionTransmission(ctx sdk.Context) int64 { - params, _ := k.GetConsumerParams(ctx) //TODO @bermuell: Check behaviour for error case + params, err := k.GetConsumerParams(ctx) + if err != nil { + k.Logger(ctx).Error("error getting parameter 'BlocksPerDistributionTransmission': %v", err) + return params.BlocksPerDistributionTransmission + } + return params.BlocksPerDistributionTransmission } func (k Keeper) SetBlocksPerDistributionTransmission(ctx sdk.Context, bpdt int64) { params, err := k.GetConsumerParams(ctx) if err != nil { - //TODO @bermuell: Check behaviour for error case + k.Logger(ctx).Error("error setting parameter 'BlocksPerDistributionTransmission': %v", err) return } params.BlocksPerDistributionTransmission = bpdt @@ -64,22 +73,30 @@ func (k Keeper) SetBlocksPerDistributionTransmission(ctx sdk.Context, bpdt int64 } func (k Keeper) GetDistributionTransmissionChannel(ctx sdk.Context) string { - params, _ := k.GetConsumerParams(ctx) //TODO @bermuell: Check behaviour for error case + params, err := k.GetConsumerParams(ctx) + if err != nil { + k.Logger(ctx).Error("error getting parameter 'DistributionTransmissionChannel': %v", err) + return params.DistributionTransmissionChannel + } return params.DistributionTransmissionChannel } func (k Keeper) SetDistributionTransmissionChannel(ctx sdk.Context, channel string) { params, err := k.GetConsumerParams(ctx) if err != nil { + k.Logger(ctx).Error("error setting parameter 'DistributionTransmissionChannel': %v", err) return - //TODO @bermuell: Check behaviour for error case } params.DistributionTransmissionChannel = channel k.SetParams(ctx, params) } func (k Keeper) GetProviderFeePoolAddrStr(ctx sdk.Context) string { - params, _ := k.GetConsumerParams(ctx) //TODO @bermuell: Check behaviour for error case + params, err := k.GetConsumerParams(ctx) + if err != nil { + k.Logger(ctx).Error("error getting parameter 'ProviderFeePoolAddrStr': %v", err) + return params.ProviderFeePoolAddrStr + } return params.ProviderFeePoolAddrStr } @@ -87,7 +104,7 @@ func (k Keeper) GetProviderFeePoolAddrStr(ctx sdk.Context) string { func (k Keeper) SetProviderFeePoolAddrStr(ctx sdk.Context, addr string) { params, err := k.GetConsumerParams(ctx) if err != nil { - //TODO @bermuell: Check behaviour for error case + k.Logger(ctx).Error("error setting parameter 'ProviderFeePoolAddrStr': %v", err) return } params.ProviderFeePoolAddrStr = addr @@ -96,13 +113,21 @@ func (k Keeper) SetProviderFeePoolAddrStr(ctx sdk.Context, addr string) { // GetCCVTimeoutPeriod returns the timeout period for sent ccv related ibc packets func (k Keeper) GetCCVTimeoutPeriod(ctx sdk.Context) time.Duration { - params, _ := k.GetConsumerParams(ctx) //TODO @bermuell: Check behaviour for error case + params, err := k.GetConsumerParams(ctx) + if err != nil { + k.Logger(ctx).Error("error getting parameter 'CcvTimeoutPeriod': %v", err) + return params.CcvTimeoutPeriod + } return params.CcvTimeoutPeriod } // GetTransferTimeoutPeriod returns the timeout period for sent transfer related ibc packets func (k Keeper) GetTransferTimeoutPeriod(ctx sdk.Context) time.Duration { - params, _ := k.GetConsumerParams(ctx) //TODO @bermuell: Check behaviour for error case + params, err := k.GetConsumerParams(ctx) + if err != nil { + k.Logger(ctx).Error("error getting parameter 'TransferTimeoutPeriod': %v", err) + return params.TransferTimeoutPeriod + } return params.TransferTimeoutPeriod } @@ -111,14 +136,22 @@ func (k Keeper) GetTransferTimeoutPeriod(ctx sdk.Context) time.Duration { // address during distribution events. The fraction is a string representing a // decimal number. For example "0.75" would represent 75%. func (k Keeper) GetConsumerRedistributionFrac(ctx sdk.Context) string { - params, _ := k.GetConsumerParams(ctx) //TODO @bermuell: Check behaviour for error case + params, err := k.GetConsumerParams(ctx) + if err != nil { + k.Logger(ctx).Error("error getting parameter 'ConsumerRedistributionFraction': %v", err) + return params.ConsumerRedistributionFraction + } return params.ConsumerRedistributionFraction } // GetHistoricalEntries returns the number of historical info entries to persist in store func (k Keeper) GetHistoricalEntries(ctx sdk.Context) int64 { - params, _ := k.GetConsumerParams(ctx) //TODO @bermuell: Check behaviour for error case + params, err := k.GetConsumerParams(ctx) + if err != nil { + k.Logger(ctx).Error("error getting parameter 'HistoricalEntries': %v", err) + return params.HistoricalEntries + } return params.HistoricalEntries } @@ -127,7 +160,7 @@ func (k Keeper) GetHistoricalEntries(ctx sdk.Context) int64 { func (k Keeper) SetUnbondingPeriod(ctx sdk.Context, period time.Duration) { params, err := k.GetConsumerParams(ctx) if err != nil { - //TODO @bermuell: Check behaviour for error case + k.Logger(ctx).Error("error setting parameter 'UnbondingPeriod': %v", err) return } params.UnbondingPeriod = period @@ -136,23 +169,39 @@ func (k Keeper) SetUnbondingPeriod(ctx sdk.Context, period time.Duration) { // GetUnbondingPeriod returns the unbonding period of the consumer func (k Keeper) GetUnbondingPeriod(ctx sdk.Context) time.Duration { - params, _ := k.GetConsumerParams(ctx) //TODO @bermuell: Check behaviour for error case + params, err := k.GetConsumerParams(ctx) + if err != nil { + k.Logger(ctx).Error("error getting parameter 'UnbondingPeriod': %v", err) + return params.UnbondingPeriod + } return params.UnbondingPeriod } // GetSoftOptOutThreshold returns the percentage of validators at the bottom of the set // that can opt out of running the consumer chain func (k Keeper) GetSoftOptOutThreshold(ctx sdk.Context) string { - params, _ := k.GetConsumerParams(ctx) //TODO @bermuell: Check behaviour for error case + params, err := k.GetConsumerParams(ctx) + if err != nil { + k.Logger(ctx).Error("error getting parameter 'SoftOptOutThreshold': %v", err) + return params.SoftOptOutThreshold + } return params.SoftOptOutThreshold } func (k Keeper) GetRewardDenoms(ctx sdk.Context) []string { - params, _ := k.GetConsumerParams(ctx) //TODO @bermuell: Check behaviour for error case + params, err := k.GetConsumerParams(ctx) + if err != nil { + k.Logger(ctx).Error("error getting parameter 'RewardDenoms': %v", err) + return params.RewardDenoms + } return params.RewardDenoms } func (k Keeper) GetProviderRewardDenoms(ctx sdk.Context) []string { - params, _ := k.GetConsumerParams(ctx) //TODO @bermuell: Check behaviour for error case + params, err := k.GetConsumerParams(ctx) + if err != nil { + k.Logger(ctx).Error("error getting parameter 'UnbondingPeriod': %v", err) + return params.ProviderRewardDenoms + } return params.ProviderRewardDenoms }