-
Notifications
You must be signed in to change notification settings - Fork 44
/
keys.go
98 lines (79 loc) · 3.83 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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
package types
import (
"strings"
)
// DONTCOVER
const (
ModuleName = "profiles"
RouterKey = ModuleName
StoreKey = ModuleName
ActionSaveProfile = "save_profile"
ActionDeleteProfile = "delete_profile"
ActionRequestDTag = "request_dtag_transfer"
ActionAcceptDTagTransfer = "accept_dtag_transfer_request"
ActionRefuseDTagTransferRequest = "refuse_dtag_transfer_request"
ActionCancelDTagTransferRequest = "cancel_dtag_transfer_request"
ActionLinkChainAccount = "link_chain_account"
ActionUnlinkChainAccount = "unlink_chain_account"
ActionLinkApplication = "link_application"
ActionUnlinkApplication = "unlink_application"
DoNotModify = "[do-not-modify]"
// IBCPortID is the default port id that profiles module binds to.
IBCPortID = "ibc-profiles"
// Version defines the current version the IBC profiles module supports
Version = "desmos-1"
)
var (
// IBCPortKey defines the key to store the port ID in store
IBCPortKey = []byte{0x01}
DTagPrefix = []byte{0x10}
DTagTransferRequestPrefix = []byte{0x11}
ChainLinksPrefix = []byte{0x12}
ApplicationLinkPrefix = []byte{0x13}
ApplicationLinkClientIDPrefix = []byte{0x14}
)
// DTagStoreKey turns a DTag into the key used to store the address associated with it into the store
func DTagStoreKey(dTag string) []byte {
return append(DTagPrefix, []byte(strings.ToLower(dTag))...)
}
// IncomingDTagTransferRequestsPrefix returns the prefix used to store all the DTag transfer requests that
// have been made towards the given recipient
func IncomingDTagTransferRequestsPrefix(recipient string) []byte {
return append(DTagTransferRequestPrefix, []byte(recipient)...)
}
// DTagTransferRequestStoreKey returns the store key used to save the DTag transfer request made
// from the sender towards the recipient
func DTagTransferRequestStoreKey(sender, recipient string) []byte {
return append(IncomingDTagTransferRequestsPrefix(recipient), []byte(sender)...)
}
// UserChainLinksPrefix returns the store prefix used to identify all the chain links for the given user
func UserChainLinksPrefix(user string) []byte {
return append(ChainLinksPrefix, []byte(user)...)
}
// UserChainLinksChainPrefix returns the store prefix used to identify all the chain links for the given user and chain
func UserChainLinksChainPrefix(user, chainName string) []byte {
return append(UserChainLinksPrefix(user), []byte(chainName)...)
}
// ChainLinksStoreKey returns the store key used to store the chain links containing the given data
func ChainLinksStoreKey(user, chainName, address string) []byte {
return append(UserChainLinksChainPrefix(user, chainName), []byte(address)...)
}
// UserApplicationLinksPrefix returns the store prefix used to identify all the application links for the given user
func UserApplicationLinksPrefix(user string) []byte {
return append(ApplicationLinkPrefix, []byte(user)...)
}
// UserApplicationLinksApplicationPrefix returns the store prefix used to identify all the application
// links for the given user and application
func UserApplicationLinksApplicationPrefix(user, application string) []byte {
return append(UserApplicationLinksPrefix(user), []byte(strings.ToLower(application))...)
}
// UserApplicationLinkKey returns the key used to store the data about the application link
// of the given user for the specified application and username
func UserApplicationLinkKey(user, application, username string) []byte {
return append(UserApplicationLinksApplicationPrefix(user, application), []byte(strings.ToLower(username))...)
}
// ApplicationLinkClientIDKey returns the key used to store the reference to the application link
// associated with the specified client id
func ApplicationLinkClientIDKey(clientID string) []byte {
return append(ApplicationLinkClientIDPrefix, []byte(clientID)...)
}