-
Notifications
You must be signed in to change notification settings - Fork 66
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #59 from Fairblock/audit-fixes-2
Merge audit-fixes-2 to main
- Loading branch information
Showing
192 changed files
with
23,276 additions
and
5,192 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
package app | ||
|
||
import ( | ||
"fairyring/blockbuster" | ||
pepante "fairyring/x/pep/ante" | ||
pepkeeper "fairyring/x/pep/keeper" | ||
|
||
sdk "github.com/cosmos/cosmos-sdk/types" | ||
"github.com/cosmos/cosmos-sdk/x/auth/ante" | ||
) | ||
|
||
type FairyringHandlerOptions struct { | ||
BaseOptions ante.HandlerOptions | ||
Mempool blockbuster.Mempool | ||
KeyShareLane pepante.KeyShareLane | ||
TxDecoder sdk.TxDecoder | ||
TxEncoder sdk.TxEncoder | ||
PepKeeper pepkeeper.Keeper | ||
} | ||
|
||
// NewFairyringAnteHandler wraps all of the default Cosmos SDK AnteDecorators with the Fairyring AnteHandler. | ||
func NewFairyringAnteHandler(options FairyringHandlerOptions) sdk.AnteHandler { | ||
if options.BaseOptions.AccountKeeper == nil { | ||
panic("account keeper is required for ante builder") | ||
} | ||
|
||
if options.BaseOptions.BankKeeper == nil { | ||
panic("bank keeper is required for ante builder") | ||
} | ||
|
||
if options.BaseOptions.SignModeHandler == nil { | ||
panic("sign mode handler is required for ante builder") | ||
} | ||
|
||
if options.BaseOptions.FeegrantKeeper == nil { | ||
panic("fee grant keeper is required for ante builder") | ||
} | ||
|
||
anteDecorators := []sdk.AnteDecorator{ | ||
ante.NewSetUpContextDecorator(), // outermost AnteDecorator. SetUpContext must be called first | ||
ante.NewExtensionOptionsDecorator(options.BaseOptions.ExtensionOptionChecker), | ||
ante.NewValidateBasicDecorator(), | ||
ante.NewTxTimeoutHeightDecorator(), | ||
ante.NewValidateMemoDecorator(options.BaseOptions.AccountKeeper), | ||
ante.NewConsumeGasForTxSizeDecorator(options.BaseOptions.AccountKeeper), | ||
ante.NewDeductFeeDecorator( | ||
options.BaseOptions.AccountKeeper, | ||
options.BaseOptions.BankKeeper, | ||
options.BaseOptions.FeegrantKeeper, | ||
options.BaseOptions.TxFeeChecker, | ||
), | ||
ante.NewSetPubKeyDecorator(options.BaseOptions.AccountKeeper), // SetPubKeyDecorator must be called before all signature verification decorators | ||
ante.NewValidateSigCountDecorator(options.BaseOptions.AccountKeeper), | ||
ante.NewSigGasConsumeDecorator(options.BaseOptions.AccountKeeper, options.BaseOptions.SigGasConsumer), | ||
ante.NewSigVerificationDecorator(options.BaseOptions.AccountKeeper, options.BaseOptions.SignModeHandler), | ||
ante.NewIncrementSequenceDecorator(options.BaseOptions.AccountKeeper), | ||
pepante.NewPepDecorator(options.PepKeeper, options.TxEncoder, options.KeyShareLane, options.Mempool), | ||
} | ||
|
||
return sdk.ChainAnteDecorators(anteDecorators...) | ||
} |
Oops, something went wrong.