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

     1  package types
     2  
     3  import (
     4  	"fmt"
     5  
     6  	sdk "github.com/fibonacci-chain/fbc/libs/cosmos-sdk/types"
     7  )
     8  
     9  // nolint
    10  const (
    11  	// ModuleName is the name of the order module
    12  	ModuleName        = "order"
    13  	DefaultParamspace = ModuleName
    14  	DefaultCodespace  = ModuleName
    15  
    16  	// QuerierRoute is the querier route for the order module
    17  	QuerierRoute = ModuleName
    18  
    19  	// RouterKey is the msg router key for the order module
    20  	RouterKey = ModuleName
    21  
    22  	// QueryOrderDetail query endpoints supported by the governance Querier
    23  	QueryOrderDetail = "detail"
    24  	QueryDepthBook   = "depthbook"
    25  	QueryParameters  = "params"
    26  	QueryStore       = "store"
    27  	QueryDepthBookV2 = "depthbookV2"
    28  
    29  	OrderStoreKey = ModuleName
    30  )
    31  
    32  // nolint
    33  var (
    34  	// Keys for store prefixes
    35  
    36  	// iterator keys
    37  	OrderKey             = []byte{0x11}
    38  	DepthBookKey         = []byte{0x12}
    39  	OrderIDsKey          = []byte{0x13}
    40  	PriceKey             = []byte{0x14}
    41  	ExpireBlockHeightKey = []byte{0x15}
    42  	OrderNumPerBlockKey  = []byte{0x16}
    43  
    44  	// none iterator keys
    45  	RecentlyClosedOrderIDsKey = []byte{0x17}
    46  	LastExpiredBlockHeightKey = []byte{0x18}
    47  	OpenOrderNumKey           = []byte{0x19}
    48  	StoreOrderNumKey          = []byte{0x20}
    49  )
    50  
    51  // nolint
    52  func GetOrderKey(key string) []byte {
    53  	return append(OrderKey, []byte(key)...)
    54  }
    55  
    56  // nolint
    57  func GetDepthBookKey(key string) []byte {
    58  	return append(DepthBookKey, []byte(key)...)
    59  }
    60  
    61  // nolint
    62  func GetOrderIDsKey(key string) []byte {
    63  	return append(OrderIDsKey, []byte(key)...)
    64  }
    65  
    66  // nolint
    67  func GetPriceKey(key string) []byte {
    68  	return append(PriceKey, []byte(key)...)
    69  }
    70  
    71  // nolint
    72  func GetOrderNumPerBlockKey(blockHeight int64) []byte {
    73  	return append(OrderNumPerBlockKey, sdk.Uint64ToBigEndian(uint64(blockHeight))...)
    74  }
    75  
    76  // nolint
    77  func GetExpireBlockHeightKey(blockHeight int64) []byte {
    78  	return append(ExpireBlockHeightKey, sdk.Uint64ToBigEndian(uint64(blockHeight))...)
    79  }
    80  
    81  // nolint
    82  func FormatOrderIDsKey(product string, price sdk.Dec, side string) string {
    83  	return fmt.Sprintf("%v:%v:%v", product, price.String(), side)
    84  }
    85  
    86  // nolint
    87  func GetKey(it sdk.Iterator) string {
    88  	return string(it.Key()[1:])
    89  }