-
Notifications
You must be signed in to change notification settings - Fork 55
/
keys.go
37 lines (29 loc) · 972 Bytes
/
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
package types
import (
"bytes"
)
const (
// ModuleName is the name of the budget module
ModuleName = "budget"
// RouterKey is the message router key for the budget module
RouterKey = ModuleName
// StoreKey is the default store key for the budget module
StoreKey = ModuleName
// QuerierRoute is the querier route for the budget module
QuerierRoute = ModuleName
)
var (
// Keys for store prefixes
TotalCollectedCoinsKeyPrefix = []byte{0x11}
)
// GetTotalCollectedCoinsKey creates the key for the total collected coins for a budget.
func GetTotalCollectedCoinsKey(budgetName string) []byte {
return append(TotalCollectedCoinsKeyPrefix, []byte(budgetName)...)
}
// ParseTotalCollectedCoinsKey parses the total collected coins key and returns the budget name.
func ParseTotalCollectedCoinsKey(key []byte) (budgetName string) {
if !bytes.HasPrefix(key, TotalCollectedCoinsKeyPrefix) {
panic("key does not have proper prefix")
}
return string(key[1:])
}