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