-
Notifications
You must be signed in to change notification settings - Fork 41
/
keys.go
68 lines (51 loc) · 2.36 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
package types
import spntypes "github.com/tendermint/spn/pkg/types"
const (
// ModuleName defines the module name
ModuleName = "campaign"
// 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
// MemStoreKey defines the in-memory store key
MemStoreKey = "mem_campaign"
// CampaignKey is the prefix to retrieve all Campaign
CampaignKey = "Campaign/value/"
// CampaignCounterKey is the prefix to store campaign count
CampaignCounterKey = "Campaign/count/"
// TotalSharesKey is the prefix to retrieve TotalShares
TotalSharesKey = "TotalShares/value/"
// CampaignChainsKeyPrefix is the prefix to retrieve all CampaignChains
CampaignChainsKeyPrefix = "CampaignChains/value/"
// MainnetAccountKeyPrefix is the prefix to retrieve all MainnetAccount
MainnetAccountKeyPrefix = "MainnetAccount/value/"
// MainnetVestingAccountKeyPrefix is the prefix to retrieve all MainnetVestingAccount
MainnetVestingAccountKeyPrefix = "MainnetVestingAccount/value/"
)
func KeyPrefix(p string) []byte {
return []byte(p)
}
// CampaignChainsKey returns the store key to retrieve a CampaignChains from the index fields
func CampaignChainsKey(campaignID uint64) []byte {
return append(spntypes.UintBytes(campaignID), byte('/'))
}
// AccountKeyPath returns the store key path without prefix for an account defined by a campaign ID and an address
func AccountKeyPath(campaignID uint64, address string) []byte {
campaignIDBytes := append(spntypes.UintBytes(campaignID), byte('/'))
addressBytes := append([]byte(address), byte('/'))
return append(campaignIDBytes, addressBytes...)
}
// MainnetAccountAllKey returns the store key to retrieve all MainnetAccount by campaign id
func MainnetAccountAllKey(campaignID uint64) []byte {
prefixBytes := []byte(MainnetAccountKeyPrefix)
campaignIDBytes := append(spntypes.UintBytes(campaignID), byte('/'))
return append(prefixBytes, campaignIDBytes...)
}
// MainnetVestingAccountAllKey returns the store key to retrieve all MainnetVestingAccount by campaign id
func MainnetVestingAccountAllKey(campaignID uint64) []byte {
prefixBytes := []byte(MainnetVestingAccountKeyPrefix)
campaignIDBytes := append(spntypes.UintBytes(campaignID), byte('/'))
return append(prefixBytes, campaignIDBytes...)
}