Skip to content

Instantly share code, notes, and snippets.

@bryanchriswhite
Created April 23, 2025 10:52
Show Gist options
  • Save bryanchriswhite/bf2f037d6d940192624bfd398710142a to your computer and use it in GitHub Desktop.
Save bryanchriswhite/bf2f037d6d940192624bfd398710142a to your computer and use it in GitHub Desktop.
Index: app/ante.go
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/app/ante.go b/app/ante.go
--- a/app/ante.go (revision 906f211b1e0bce5975ec0f89f738ca4043b2427d)
+++ b/app/ante.go (date 1745401225631)
@@ -1,6 +1,9 @@
package app
import (
+ "context"
+ "fmt"
+
storetypes "cosmossdk.io/store/types"
"github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1"
cosmostypes "github.com/cosmos/cosmos-sdk/types"
@@ -19,13 +22,14 @@
// 2. waives minimum gas/fees for transactions that contain ONLY morse claim messages (i.e. MsgClaimMorseAccount, MsgClaimMorseApplication, and MsgClaimMorseSupplier)
func newMorseClaimGasFeesWaiverAnteHandlerFn(app *App) cosmostypes.AnteHandler {
return func(sdkCtx cosmostypes.Context, tx cosmostypes.Tx, simulate bool) (cosmostypes.Context, error) {
+ feeGrantKeeper := newFeeGrantKeeper(sdkCtx, app, tx)
pocketAnte, err := newPocketAnteHandler(pocketAnteHandlerOptions{
// Default ante handler options
HandlerOptions: ante.HandlerOptions{
AccountKeeper: &app.Keepers.AccountKeeper,
BankKeeper: app.Keepers.BankKeeper,
ExtensionOptionChecker: nil,
- FeegrantKeeper: app.Keepers.FeeGrantKeeper,
+ FeegrantKeeper: feeGrantKeeper,
SignModeHandler: app.txConfig.SignModeHandler(),
},
// Pocket-specific ante handler options
@@ -41,6 +45,37 @@
}
}
+// TODO_IN_THIS_COMMIT: ...
+var _ ante.FeegrantKeeper = (*WaivedMorseClaimFeeGranter)(nil)
+
+type WaivedMorseClaimFeeGranter struct{}
+
+// TODO_IN_THIS_COMMIT: ...
+const govModuleAddress = "pokt10d07y265gmmuvt4z0w9aw880jnsr700j8yv32t"
+
+// TODO_IN_THIS_COMMIT: ...
+func (feeGranter WaivedMorseClaimFeeGranter) UseGrantedFees(
+ ctx context.Context,
+ granter cosmostypes.AccAddress,
+ grantee cosmostypes.AccAddress,
+ fee cosmostypes.Coins,
+ msgs []cosmostypes.Msg,
+) error {
+ if granter.String() == govModuleAddress {
+ return nil
+ }
+ return fmt.Errorf("%s does not allow to pay fees for %s", feeGranter, grantee)
+}
+
+// TODO_IN_THIS_COMMIT: ...
+func newFeeGrantKeeper(sdkCtx cosmostypes.Context, app *App, tx cosmostypes.Tx) ante.FeegrantKeeper {
+ if shouldWaiveMorseClaimGasFees(sdkCtx, app, tx) {
+ return new(WaivedMorseClaimFeeGranter)
+ }
+
+ return app.Keepers.FeeGrantKeeper
+}
+
// NewPocketAnteHandler returns an AnteHandler that checks and increments sequence
// numbers, checks signatures & account numbers, and deducts fees from the first
// signer.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment