1
1
package ante
2
2
3
3
import (
4
+ "cosmossdk.io/core/appmodule/v2"
5
+ "cosmossdk.io/core/transaction"
4
6
errorsmod "cosmossdk.io/errors"
5
7
storetypes "cosmossdk.io/store/types"
6
8
"cosmossdk.io/x/auth/migrations/legacytx"
@@ -18,15 +20,20 @@ import (
18
20
// If ValidateBasic passes, decorator calls next AnteHandler in chain. Note,
19
21
// ValidateBasicDecorator decorator will not get executed on ReCheckTx since it
20
22
// is not dependent on application state.
21
- type ValidateBasicDecorator struct {}
23
+ type ValidateBasicDecorator struct {
24
+ env appmodule.Environment
25
+ }
22
26
23
- func NewValidateBasicDecorator () ValidateBasicDecorator {
24
- return ValidateBasicDecorator {}
27
+ func NewValidateBasicDecorator (env appmodule.Environment ) ValidateBasicDecorator {
28
+ return ValidateBasicDecorator {
29
+ env : env ,
30
+ }
25
31
}
26
32
27
33
func (vbd ValidateBasicDecorator ) AnteHandle (ctx sdk.Context , tx sdk.Tx , _ bool , next sdk.AnteHandler ) (sdk.Context , error ) {
28
34
// no need to validate basic on recheck tx, call next antehandler
29
- if ctx .ExecMode () == sdk .ExecModeReCheck {
35
+ txService := vbd .env .TransactionService
36
+ if txService .ExecMode (ctx ) == transaction .ExecModeReCheck {
30
37
return next (ctx , tx , false )
31
38
}
32
39
@@ -36,7 +43,7 @@ func (vbd ValidateBasicDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, _ bool,
36
43
}
37
44
}
38
45
39
- return next (ctx , tx , ctx . ExecMode () == sdk . ExecModeSimulate )
46
+ return next (ctx , tx , false )
40
47
}
41
48
42
49
// ValidateMemoDecorator will validate memo given the parameters passed in
@@ -69,7 +76,7 @@ func (vmd ValidateMemoDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, _ bool,
69
76
}
70
77
}
71
78
72
- return next (ctx , tx , ctx . ExecMode () == sdk . ExecModeSimulate )
79
+ return next (ctx , tx , false )
73
80
}
74
81
75
82
// ConsumeTxSizeGasDecorator will take in parameters and consume gas proportional
@@ -101,7 +108,8 @@ func (cgts ConsumeTxSizeGasDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, _ b
101
108
ctx .GasMeter ().ConsumeGas (params .TxSizeCostPerByte * storetypes .Gas (len (ctx .TxBytes ())), "txSize" )
102
109
103
110
// simulate gas cost for signatures in simulate mode
104
- if ctx .ExecMode () == sdk .ExecModeSimulate {
111
+ txService := cgts .ak .Environment ().TransactionService
112
+ if txService .ExecMode (ctx ) == transaction .ExecModeSimulate {
105
113
// in simulate mode, each element should be a nil signature
106
114
sigs , err := sigTx .GetSignaturesV2 ()
107
115
if err != nil {
@@ -143,7 +151,7 @@ func (cgts ConsumeTxSizeGasDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, _ b
143
151
}
144
152
}
145
153
146
- return next (ctx , tx , ctx . ExecMode () == sdk . ExecModeSimulate )
154
+ return next (ctx , tx , false )
147
155
}
148
156
149
157
// isIncompleteSignature tests whether SignatureData is fully filled in for simulation purposes
@@ -206,5 +214,5 @@ func (txh TxTimeoutHeightDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, _ boo
206
214
)
207
215
}
208
216
209
- return next (ctx , tx , ctx . ExecMode () == sdk . ExecModeSimulate )
217
+ return next (ctx , tx , false )
210
218
}
0 commit comments