-
Notifications
You must be signed in to change notification settings - Fork 44
/
keys.go
52 lines (40 loc) · 1.32 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
package types
import (
"regexp"
"cosmossdk.io/math"
sdk "github.com/cosmos/cosmos-sdk/types"
)
const (
// ModuleName defines the module name
ModuleName = "storage"
// StoreKey defines the primary module store key
StoreKey = ModuleName
// RouterKey defines the module's message routing key
RouterKey = ModuleName
// MemStoreKey defines the in-memory store key
MemStoreKey = "mem_storage"
)
var (
BucketPrefix = []byte{0x10}
ObjectPrefix = []byte{0x11}
GroupPrefix = []byte{0x12}
GroupMemberPrefix = []byte{0x13} // TODO(fynn): will be deprecated after permission module ready
validBucketName = regexp.MustCompile(`^[a-z0-9][a-z0-9\.\-]{1,61}[a-z0-9]$`)
ipAddress = regexp.MustCompile(`^(\d+\.){3}\d+$`)
)
func GetBucketKey(bucketName string) []byte {
return sdk.Keccak256([]byte(bucketName))
}
func GetObjectKey(bucketName string, objectName string) []byte {
sdk.Keccak256()
bucketKey := sdk.Keccak256([]byte(bucketName))
objectKey := sdk.Keccak256([]byte(objectName))
return append(bucketKey, objectKey...)
}
func GetGroupKey(owner string, groupName string) []byte {
groupKey := sdk.Keccak256([]byte(groupName))
return append([]byte(owner), groupKey...)
}
func GetGroupMemberKey(groupId math.Uint, memberAcc string) []byte {
return append(MustMarshalUint(groupId), []byte(memberAcc)...)
}