-
Notifications
You must be signed in to change notification settings - Fork 3.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
refactor: Set defaults in middlewares instead of NewDefaultTxHandler
#11557
Conversation
@@ -299,6 +299,10 @@ type sigGasConsumeTxHandler struct { | |||
// CONTRACT: Pubkeys are set in context for all signers before this middleware runs | |||
// CONTRACT: Tx must implement SigVerifiableTx interface | |||
func SigGasConsumeMiddleware(ak AccountKeeper, sigGasConsumer SignatureVerificationGasConsumer) tx.Middleware { | |||
if sigGasConsumer == nil { | |||
sigGasConsumer = DefaultSigVerificationGasConsumer | |||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same as
cosmos-sdk/x/auth/middleware/fee.go
Lines 31 to 34 in f133317
func DeductFeeMiddleware(ak AccountKeeper, bk types.BankKeeper, fk FeegrantKeeper, tfc TxFeeChecker) tx.Middleware { | |
if tfc == nil { | |
tfc = checkTxFeeWithValidatorMinGasPrices | |
} |
and
cosmos-sdk/x/auth/middleware/ext.go
Lines 35 to 38 in f133317
func NewExtensionOptionsMiddleware(checker ExtensionOptionChecker) tx.Middleware { | |
if checker == nil { | |
checker = rejectExtensionOption | |
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm, love the cleanup
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Description
If tx handler
options.{ExtensionOptionChecker, TxFeeChecker}
is not set, we fallback to a default option provided by the SDK. These default are set in 2 places, which is redundant:NewDefaultTxHandler
Proposing here to only set the default once, inside each middleware constructor
Author Checklist
All items are required. Please add a note to the item if the item is not applicable and
please add links to any relevant follow up issues.
I have...
!
to the type prefix if API or client breaking changeCHANGELOG.md
Reviewers Checklist
All items are required. Please add a note if the item is not applicable and please add
your handle next to the items reviewed if you only reviewed selected items.
I have...
!
in the type prefix if API or client breaking change