Skip to content

Commit

Permalink
Add is simulate in baseapp
Browse files Browse the repository at this point in the history
  • Loading branch information
phamminh0811 committed Sep 18, 2024
1 parent 225886c commit 8172e9b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
1 change: 1 addition & 0 deletions baseapp/baseapp.go
Original file line number Diff line number Diff line change
Expand Up @@ -596,6 +596,7 @@ func (app *BaseApp) getContextForTx(mode runTxMode, txBytes []byte) sdk.Context

if mode == runTxModeSimulate {
ctx, _ = ctx.CacheContext()
ctx = ctx.WithSimulate(true)
}

if mode == runTxModeSimulateSpecial {
Expand Down
7 changes: 7 additions & 0 deletions types/context.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ type Context struct {
taxGasMeter TaxGasMeter
cacheTaxGasMeter TaxGasMeter
specialSimulate bool
simulate bool
checkTx bool
recheckTx bool // if recheckTx == true, then checkTx must also be true
minGasPrice DecCoins
Expand Down Expand Up @@ -63,6 +64,7 @@ func (c Context) BlockGasMeter() GasMeter { return c.blockGas
func (c Context) TaxGasMeter() TaxGasMeter { return c.taxGasMeter }
func (c Context) CacheTaxGasMeter() TaxGasMeter { return c.cacheTaxGasMeter }
func (c Context) IsSpecialSimulate() bool { return c.specialSimulate }
func (c Context) IsSimulate() bool { return c.simulate }
func (c Context) IsCheckTx() bool { return c.checkTx }
func (c Context) IsReCheckTx() bool { return c.recheckTx }
func (c Context) MinGasPrices() DecCoins { return c.minGasPrice }
Expand Down Expand Up @@ -234,6 +236,11 @@ func (c Context) WithSpecialSimulate(isSpecialSimulate bool) Context {
return c
}

func (c Context) WithSimulate(isSimulate bool) Context {
c.simulate = isSimulate
return c
}

// WithIsRecheckTx called with true will also set true on checkTx in order to
// enforce the invariant that if recheckTx = true then checkTx = true as well.
func (c Context) WithIsReCheckTx(isRecheckTx bool) Context {
Expand Down

0 comments on commit 8172e9b

Please sign in to comment.