github.com/fibonacci-chain/fbc@v0.0.0-20231124064014-c7636198c1e9/libs/cosmos-sdk/baseapp/helpers.go (about)

     1  package baseapp
     2  
     3  import (
     4  	"regexp"
     5  
     6  	abci "github.com/fibonacci-chain/fbc/libs/tendermint/abci/types"
     7  
     8  	sdk "github.com/fibonacci-chain/fbc/libs/cosmos-sdk/types"
     9  )
    10  
    11  var isAlphaNumeric = regexp.MustCompile(`^[a-zA-Z0-9]+$`).MatchString
    12  
    13  func (app *BaseApp) Check(tx sdk.Tx) (sdk.GasInfo, *sdk.Result, error) {
    14  	info, e := app.runTx(runTxModeCheck, nil, tx, LatestSimulateTxHeight)
    15  	return info.gInfo, info.result, e
    16  }
    17  
    18  func (app *BaseApp) Simulate(txBytes []byte, tx sdk.Tx, height int64, overridesBytes []byte, from ...string) (sdk.GasInfo, *sdk.Result, error) {
    19  	info := &runTxInfo{
    20  		overridesBytes: overridesBytes,
    21  	}
    22  	e := app.runtxWithInfo(info, runTxModeSimulate, txBytes, tx, height, from...)
    23  	return info.gInfo, info.result, e
    24  }
    25  
    26  func (app *BaseApp) Deliver(tx sdk.Tx) (sdk.GasInfo, *sdk.Result, error) {
    27  	info, e := app.runTx(runTxModeDeliver, nil, tx, LatestSimulateTxHeight)
    28  	return info.gInfo, info.result, e
    29  }
    30  
    31  // Context with current {check, deliver}State of the app used by tests.
    32  func (app *BaseApp) NewContext(isCheckTx bool, header abci.Header) (ctx sdk.Context) {
    33  	if isCheckTx {
    34  		ctx = sdk.NewContext(app.checkState.ms, header, true, app.logger)
    35  		ctx.SetMinGasPrices(app.minGasPrices)
    36  		return
    37  	}
    38  
    39  	ctx = sdk.NewContext(app.deliverState.ms, header, false, app.logger)
    40  	return
    41  }