-
Notifications
You must be signed in to change notification settings - Fork 39
/
keys.go
86 lines (73 loc) · 2.25 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
package types
import (
"encoding/binary"
)
const (
// ModuleName is the module name constant used in many places
ModuleName = "treasury"
// StoreKey is the string store representation
StoreKey = ModuleName
// RouterKey is the message route for treasury
RouterKey = ModuleName
// QuerierRoute is the querier route for treasury
QuerierRoute = ModuleName
)
// BurnModuleName is special purpose module name to perform burn coins
// burn address = terra1sk06e3dyexuq4shw77y3dsv480xv42mq73anxu
const BurnModuleName = "burn"
// Keys for treasury store
// Items are stored with the following key: values
//
// - 0x01: sdk.Dec
//
// - 0x02: sdk.Dec
//
// - 0x03<denom_Bytes>: sdk.Int
//
// - 0x04: sdk.Coins
//
// - 0x05: sdk.Coins
//
// - 0x06<epoch_Bytes>: sdk.Dec
//
// - 0x07<epoch_Bytes>: sdk.Dec
//
// - 0x08<epoch_Bytes>: sdk.Int
//
// - 0x09: int64
var (
// Keys for store prefixes
TaxRateKey = []byte{0x01} // a key for a tax-rate
RewardWeightKey = []byte{0x02} // a key for a reward-weight
TaxCapKey = []byte{0x03} // prefix for each key to a tax-cap
TaxProceedsKey = []byte{0x04} // a key for a tax-proceeds
EpochInitialIssuanceKey = []byte{0x05} // a key for an initial epoch issuance
CumulativeHeightKey = []byte{0x09} // a key for a cumulated height
BurnTaxExemptionListPrefix = []byte{0x20} // prefix for burn tax exemption list
// Keys for store prefixes of internal purpose variables
TRKey = []byte{0x06} // prefix for each key to a TR
SRKey = []byte{0x07} // prefix for each key to a SR
TSLKey = []byte{0x08} // prefix for each key to a TSL
)
// GetTaxCapKey - stored by *denom*
func GetTaxCapKey(denom string) []byte {
return append(TaxCapKey, []byte(denom)...)
}
// GetTRKey - stored by *epoch*
func GetTRKey(epoch int64) []byte {
return GetSubkeyByEpoch(TRKey, epoch)
}
// GetSRKey - stored by *epoch*
func GetSRKey(epoch int64) []byte {
return GetSubkeyByEpoch(SRKey, epoch)
}
// GetTSLKey - stored by *epoch*
func GetTSLKey(epoch int64) []byte {
return GetSubkeyByEpoch(TSLKey, epoch)
}
// GetSubkeyByEpoch - stored by *epoch*
func GetSubkeyByEpoch(prefix []byte, epoch int64) []byte {
b := make([]byte, 8)
binary.LittleEndian.PutUint64(b, uint64(epoch))
return append(prefix, b...)
}