-
Notifications
You must be signed in to change notification settings - Fork 18
/
keys.go
90 lines (64 loc) · 2.76 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
package types
import (
"bytes"
sdk "github.com/cosmos/cosmos-sdk/types"
)
const (
// ModuleName defines the module name
ModuleName = "datapool"
// 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_datapool"
// this line is used by starport scaffolding # ibc/keys/name
)
var (
// KeyPoolNextNumber defines key to store next Pool ID to be used
KeyPoolNextNumber = []byte{0x01}
// KeyPrefixPools defines key to store Pools
KeyPrefixPools = []byte{0x02}
// KeyPrefixOracleCerts defines key to store oracle certs
KeyPrefixOracleCerts = []byte{0x03}
// KeyPrefixNFTRedeemReceipts define key to store redeemed receipts
KeyPrefixNFTRedeemReceipts = []byte{0x04}
KeyPrefixSalesHistory = []byte{0x05}
// KeyPrefixInstantRevenueDistribution defines key to distribution reward pool
KeyPrefixInstantRevenueDistribution = []byte{0x06}
// KeyPrefixDataPassRedeemHistory defines key to store redeem receipts by address
KeyPrefixDataPassRedeemHistory = []byte{0x07}
KeyIndexSeparator = []byte{0xFF}
)
func GetKeyPrefixPools(poolID uint64) []byte {
return append(KeyPrefixPools, sdk.Uint64ToBigEndian(poolID)...)
}
func GetKeyPrefixDataValidateCerts(poolID, round uint64) []byte {
return append(KeyPrefixOracleCerts, CombineKeys(sdk.Uint64ToBigEndian(poolID), sdk.Uint64ToBigEndian(round))...)
}
func GetKeyPrefixDataValidateCert(poolID, round uint64, dataHash []byte) []byte {
return CombineKeys(GetKeyPrefixDataValidateCerts(poolID, round), dataHash)
}
func GetKeyPrefixSalesHistories(poolID, round uint64) []byte {
return append(KeyPrefixSalesHistory, CombineKeys(sdk.Uint64ToBigEndian(poolID), sdk.Uint64ToBigEndian(round))...)
}
func GetKeyPrefixSalesHistory(poolID, round uint64, seller string) []byte {
return CombineKeys(GetKeyPrefixSalesHistories(poolID, round), []byte(seller))
}
func GetKeyPrefixNFTRedeemReceiptByPoolID(poolID uint64) []byte {
return append(KeyPrefixNFTRedeemReceipts, sdk.Uint64ToBigEndian(poolID)...)
}
func GetKeyPrefixNFTRedeemReceipt(poolID, round, dataPassID uint64) []byte {
return CombineKeys(GetKeyPrefixNFTRedeemReceiptByPoolID(poolID), sdk.Uint64ToBigEndian(round), sdk.Uint64ToBigEndian(dataPassID))
}
func GetKeyPrefixDataPassRedeemHistory(redeemer string) []byte {
return append(KeyPrefixDataPassRedeemHistory, []byte(redeemer)...)
}
func GetKeyPrefixDataPassRedeemHistoryByPool(redeemer string, poolID uint64) []byte {
return CombineKeys(GetKeyPrefixDataPassRedeemHistory(redeemer), sdk.Uint64ToBigEndian(poolID))
}
func CombineKeys(keys ...[]byte) []byte {
return bytes.Join(keys, KeyIndexSeparator)
}