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