Skip to content

Commit

Permalink
fix: apply suggestions from strath
Browse files Browse the repository at this point in the history
Co-authored-by: StrathCole <[email protected]>
  • Loading branch information
fragwuerdig and StrathCole authored Mar 7, 2024
1 parent aa87018 commit de22d6a
Showing 1 changed file with 13 additions and 15 deletions.
28 changes: 13 additions & 15 deletions custom/auth/ante/min_initial_deposit.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,28 +27,26 @@ func NewMinInitialDepositDecorator(govKeeper govkeeper.Keeper, treasuryKeeper Tr

// IsMsgSubmitProposal checks whether the input msg is a MsgSubmitProposal
func IsMsgSubmitProposal(msg sdk.Msg) bool {
_, okv1beta1 := msg.(*govv1beta1.MsgSubmitProposal)
_, okv1 := msg.(*govv1.MsgSubmitProposal)
return okv1beta1 || okv1
switch msg.(type) {
case *govv1beta1.MsgSubmitProposal, *govv1.MsgSubmitProposal:
return true
default:
return false
}
}

// HandleCheckMinInitialDeposit
func HandleCheckMinInitialDeposit(ctx sdk.Context, msg sdk.Msg, govKeeper govkeeper.Keeper, treasuryKeeper TreasuryKeeper) (err error) {
submitPropMsgV1Beta1, okV1Beta1 := msg.(*govv1beta1.MsgSubmitProposal)
submitPropMsgV1, okV1 := msg.(*govv1.MsgSubmitProposal)

if !(okV1Beta1 || okV1) {
return fmt.Errorf("could not dereference msg as MsgSubmitProposal")
}

var initialDepositCoins sdk.Coins

if okV1Beta1 {
initialDepositCoins = submitPropMsgV1Beta1.GetInitialDeposit()
} else if okV1 {
initialDepositCoins = submitPropMsgV1.GetInitialDeposit()
switch submitPropMsg := msg.(type) {
case *govv1beta1.MsgSubmitProposal:
initialDepositCoins = submitPropMsg.GetInitialDeposit()
case *govv1.MsgSubmitProposal:
initialDepositCoins = submitPropMsg.GetInitialDeposit()
default:
return fmt.Errorf("could not dereference msg as MsgSubmitProposal")
}

minDeposit := govKeeper.GetDepositParams(ctx).MinDeposit
requiredAmount := sdk.NewDecFromInt(minDeposit[0].Amount).Mul(treasuryKeeper.GetMinInitialDepositRatio(ctx)).TruncateInt()

Expand Down

0 comments on commit de22d6a

Please sign in to comment.