Skip to content

Commit

Permalink
Rebase OSS version
Browse files Browse the repository at this point in the history
  • Loading branch information
Cyson authored and Cyson committed Jun 13, 2023
1 parent 0abb096 commit 670af4f
Showing 1 changed file with 19 additions and 13 deletions.
32 changes: 19 additions & 13 deletions x/feegrant/filtered_fee.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,17 @@ func (a *AllowedMsgAllowance) GetAllowance() (FeeAllowanceI, error) {
return allowance, nil
}

// SetAllowance sets allowed fee allowance.
func (a *AllowedMsgAllowance) SetAllowance(allowance FeeAllowanceI) error {
var err error
a.Allowance, err = types.NewAnyWithValue(allowance.(proto.Message))
if err != nil {
return sdkerrors.Wrapf(sdkerrors.ErrPackAny, "cannot proto marshal %T", allowance)
}

return nil
}

// Accept method checks for the filtered messages has valid expiry
func (a *AllowedMsgAllowance) Accept(ctx sdk.Context, fee sdk.Coins, msgs []sdk.Msg) (bool, error) {
if !a.allMsgTypesAllowed(ctx, msgs) {
Expand All @@ -61,19 +72,14 @@ func (a *AllowedMsgAllowance) Accept(ctx sdk.Context, fee sdk.Coins, msgs []sdk.
return false, err
}

remove, err := allowance.Accept(ctx, fee, msgs)
if err != nil {
return false, err
}

any, err := types.NewAnyWithValue(allowance.(proto.Message))
if err != nil {
return false, err
}

a.Allowance = any

return remove, nil
remove, err := allowance.Accept(ctx, fee, msgs)
if err == nil && !remove {
if err = a.SetAllowance(allowance); err != nil {
return false, err
}
}

return remove, err
}

func (a *AllowedMsgAllowance) allowedMsgsToMap(ctx sdk.Context) map[string]bool {
Expand Down

0 comments on commit 670af4f

Please sign in to comment.