Skip to content
Merged
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions .changelog/v2.0.2/improvements/27-underlying-ante.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- Enable customization of underlying ante handler in `SigVerificationDecorator` ([#27](https://github.com/noble-assets/forwarding/pull/27))
3 changes: 3 additions & 0 deletions .changelog/v2.0.2/summary.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
*Apr 9, 2025*

This is a non-consensus breaking patch release to the v2 line.
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
# CHANGELOG

## v2.0.2

*Apr 9, 2025*

This is a non-consensus breaking patch release to the v2 line.

### IMPROVEMENTS

- Enable customization of underlying ante handler in `SigVerificationDecorator` ([#27](https://github.com/noble-assets/forwarding/pull/27))

## v2.0.1

*Feb 10, 2025*
Expand Down
14 changes: 10 additions & 4 deletions ante.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@ package forwarding

import (
storetypes "cosmossdk.io/store/types"
txsigning "cosmossdk.io/x/tx/signing"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/tx/signing"
"github.com/cosmos/cosmos-sdk/x/auth/ante"
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"

"github.com/noble-assets/forwarding/v2/types"
)

Expand All @@ -45,17 +45,23 @@ func SigVerificationGasConsumer(

//

var _ sdk.AnteDecorator = SigVerificationDecorator{}

type SigVerificationDecorator struct {
underlying ante.SigVerificationDecorator
bank types.BankKeeper
underlying sdk.AnteDecorator
}

var _ sdk.AnteDecorator = SigVerificationDecorator{}

func NewSigVerificationDecorator(ak ante.AccountKeeper, bk types.BankKeeper, signModeHandler *txsigning.HandlerMap) SigVerificationDecorator {
func NewSigVerificationDecorator(bk types.BankKeeper, underlying sdk.AnteDecorator) SigVerificationDecorator {
if underlying == nil {
panic("underlying ante decorator cannot be nil")
}

return SigVerificationDecorator{
underlying: ante.NewSigVerificationDecorator(ak, signModeHandler),
bank: bk,
underlying: underlying,
}
}

Expand Down
10 changes: 9 additions & 1 deletion simapp/ante.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,11 @@ func NewAnteHandler(options HandlerOptions) (sdk.AnteHandler, error) {
return nil, errors.Wrap(errorstypes.ErrLogic, "sign mode handler is required for ante builder")
}

sigVerificationDecorator := forwarding.NewSigVerificationDecorator(
options.BankKeeper,
ante.NewSigVerificationDecorator(options.AccountKeeper, options.SignModeHandler),
)

anteDecorators := []sdk.AnteDecorator{
ante.NewSetUpContextDecorator(), // outermost AnteDecorator. SetUpContext must be called first
ante.NewExtensionOptionsDecorator(options.ExtensionOptionChecker),
Expand All @@ -44,7 +49,10 @@ func NewAnteHandler(options HandlerOptions) (sdk.AnteHandler, error) {
ante.NewSetPubKeyDecorator(options.AccountKeeper), // SetPubKeyDecorator must be called before all signature verification decorators
ante.NewValidateSigCountDecorator(options.AccountKeeper),
ante.NewSigGasConsumeDecorator(options.AccountKeeper, options.SigGasConsumer),
forwarding.NewSigVerificationDecorator(options.AccountKeeper, options.BankKeeper, options.SignModeHandler),

// Custom signature verification for Forwarding accounts.
sigVerificationDecorator,

ante.NewIncrementSequenceDecorator(options.AccountKeeper),
}

Expand Down