github.com/fibonacci-chain/fbc@v0.0.0-20231124064014-c7636198c1e9/x/wasm/types/ante.go (about)

     1  package types
     2  
     3  import (
     4  	sdk "github.com/fibonacci-chain/fbc/libs/cosmos-sdk/types"
     5  )
     6  
     7  type contextKey int
     8  
     9  const (
    10  	// private type creates an interface key for Context that cannot be accessed by any other package
    11  	contextKeyTXCount contextKey = iota
    12  )
    13  
    14  // WithTXCounter stores a transaction counter value in the context
    15  func WithTXCounter(ctx sdk.Context, counter uint32) sdk.Context {
    16  	return ctx.WithValue(contextKeyTXCount, counter)
    17  }
    18  
    19  // TXCounter returns the tx counter value and found bool from the context.
    20  // The result will be (0, false) for external queries or simulations where no counter available.
    21  func TXCounter(ctx sdk.Context) (uint32, bool) {
    22  	val, ok := ctx.Value(contextKeyTXCount).(uint32)
    23  	return val, ok
    24  }