-
Notifications
You must be signed in to change notification settings - Fork 28
/
keys.go
60 lines (44 loc) · 1.81 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
49
50
51
52
53
54
55
56
57
58
59
60
package types
import (
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/address"
"github.com/sge-network/sge/utils"
)
// module constants
const (
// ModuleName defines the module name
ModuleName = "subaccount"
// StoreKey defines the primary module store key
StoreKey = ModuleName
// RouterKey is the message route for slashing
RouterKey = ModuleName
// QuerierRoute defines the module's query routing key
QuerierRoute = ModuleName
)
var (
// SubaccountIDPrefix is the key used to store the subaccount ID in the keeper KVStore
SubaccountIDPrefix = []byte{0x00}
// SubAccountOwnerPrefix is the key used to store the subaccount owner in the keeper KVStore
SubAccountOwnerPrefix = []byte{0x01}
// SubAccountOwnerReversePrefix is the key used to store the subaccount owner by ID in the keeper KVStore
SubAccountOwnerReversePrefix = []byte{0x02}
// LockedBalancePrefix is the key used to store the locked balance in the keeper KVStore
LockedBalancePrefix = []byte{0x03}
// AccountSummaryPrefix saves the balance of an account.
AccountSummaryPrefix = []byte{0x04}
)
func SubAccountOwnerKey(address sdk.AccAddress) []byte {
return append(SubAccountOwnerPrefix, address...)
}
func SubAccountKey(subAccountAddress sdk.AccAddress) []byte {
return append(SubAccountOwnerReversePrefix, subAccountAddress...)
}
func LockedBalanceKey(subAccountAddress sdk.AccAddress, unlockTime uint64) []byte {
return append(LockedBalancePrefix, append(address.MustLengthPrefix(subAccountAddress), utils.Uint64ToBytes(unlockTime)...)...)
}
func LockedBalancePrefixKey(subAccountAddress sdk.AccAddress) []byte {
return append(LockedBalancePrefix, address.MustLengthPrefix(subAccountAddress)...)
}
func AccountSummaryKey(address sdk.AccAddress) []byte {
return append(AccountSummaryPrefix, address.Bytes()...)
}