-
Notifications
You must be signed in to change notification settings - Fork 184
/
keys.go
48 lines (37 loc) 路 1.27 KB
/
keys.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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
package types
import (
sdk "github.com/cosmos/cosmos-sdk/types"
)
const (
// ModuleName is the name of the contract module
ModuleName = "compute"
// StoreKey is the string store representation
StoreKey = ModuleName
// TStoreKey is the string transient store representation
TStoreKey = "transient_" + ModuleName
// QuerierRoute is the querier route for the staking module
QuerierRoute = ModuleName
// RouterKey is the msg router key for the staking module
RouterKey = ModuleName
)
// nolint
var (
KeyLastCodeID = []byte("lastCodeId")
KeyLastInstanceID = []byte("lastContractId")
CodeKeyPrefix = []byte{0x01}
ContractKeyPrefix = []byte{0x02}
ContractStorePrefix = []byte{0x03}
)
// GetCodeKey constructs the key for retreiving the ID for the WASM code
func GetCodeKey(contractID uint64) []byte {
contractIDBz := sdk.Uint64ToBigEndian(contractID)
return append(CodeKeyPrefix, contractIDBz...)
}
// GetContractAddressKey returns the key for the WASM contract instance
func GetContractAddressKey(addr sdk.AccAddress) []byte {
return append(ContractKeyPrefix, addr...)
}
// GetContractStorePrefixKey returns the store prefix for the WASM contract instance
func GetContractStorePrefixKey(addr sdk.AccAddress) []byte {
return append(ContractStorePrefix, addr...)
}