github.com/InjectiveLabs/sdk-go@v1.53.0/chain/wasmx/types/key.go (about)

     1  package types
     2  
     3  import (
     4  	sdk "github.com/cosmos/cosmos-sdk/types"
     5  )
     6  
     7  const (
     8  	// ModuleName is set to xwasm and not wasmx to avoid Potential key collision between KVStores
     9  	// (see assertNoPrefix in cosmos-sdk/types/store.go)
    10  	ModuleName = "xwasm"
    11  	StoreKey   = ModuleName
    12  	TStoreKey  = "transient_xwasm"
    13  )
    14  
    15  var (
    16  	ContractsByGasPricePrefix = []byte{0x01} // key to the smart contract execution request ID
    17  	ContractsIndexPrefix      = []byte{0x02}
    18  	ParamsKey                 = []byte{0x10}
    19  )
    20  
    21  func GetContractsByGasPriceKey(gasPrice uint64, address sdk.AccAddress) []byte {
    22  	return append(ContractsByGasPricePrefix, getGasPriceAddressInfix(gasPrice, address)...)
    23  }
    24  
    25  func getGasPriceAddressInfix(gasPrice uint64, address sdk.AccAddress) []byte {
    26  	return append(sdk.Uint64ToBigEndian(gasPrice), address.Bytes()...)
    27  }
    28  
    29  // GetContractsIndexKey provides the key for the contract address => gasPrice
    30  func GetContractsIndexKey(address sdk.AccAddress) []byte {
    31  	return append(ContractsIndexPrefix, address.Bytes()...)
    32  }