-
Notifications
You must be signed in to change notification settings - Fork 55
/
keys.go
68 lines (56 loc) 路 2.02 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 (
sdk "github.com/cosmos/cosmos-sdk/types"
utils "github.com/crescent-network/crescent/v5/types"
)
const (
// ModuleName defines the module name
ModuleName = "liquidfarming"
// StoreKey defines the primary module store key
StoreKey = ModuleName
// RouterKey is the message route key
RouterKey = ModuleName
// QuerierRoute defines the module's query routing key
QuerierRoute = ModuleName
)
// keys for the store prefixes
var (
LastLiquidFarmIdKey = []byte{0xe1}
LastRewardsAuctionEndTimeKey = []byte{0xe3}
LiquidFarmKeyPrefix = []byte{0xe4}
RewardsAuctionKeyPrefix = []byte{0xe5}
BidKeyPrefix = []byte{0xe6}
)
// GetLiquidFarmKey returns the store key to retrieve the liquid farm object
// by the given id.
func GetLiquidFarmKey(liquidFarmId uint64) []byte {
return utils.Key(LiquidFarmKeyPrefix, sdk.Uint64ToBigEndian(liquidFarmId))
}
// GetRewardsAuctionKey returns the store key to retrieve the rewards auction object
// by the given liquid farm id and rewards auction id.
func GetRewardsAuctionKey(liquidFarmId, auctionId uint64) []byte {
return utils.Key(
RewardsAuctionKeyPrefix,
sdk.Uint64ToBigEndian(liquidFarmId),
sdk.Uint64ToBigEndian(auctionId))
}
func GetRewardsAuctionsByLiquidFarmIteratorPrefix(liquidFarmId uint64) []byte {
return utils.Key(RewardsAuctionKeyPrefix, sdk.Uint64ToBigEndian(liquidFarmId))
}
// GetBidKey returns the store key to retrieve the bid object
// by the given liquid farm id, rewards auction id and bidder address.
func GetBidKey(liquidFarmId, auctionId uint64, bidderAddr sdk.AccAddress) []byte {
return utils.Key(
BidKeyPrefix,
sdk.Uint64ToBigEndian(liquidFarmId),
sdk.Uint64ToBigEndian(auctionId),
bidderAddr)
}
// GetBidsByRewardsAuctionIteratorPrefix returns the prefix to iterate all bids
// by the given rewards auction id.
func GetBidsByRewardsAuctionIteratorPrefix(liquidFarmId, auctionId uint64) []byte {
return utils.Key(
BidKeyPrefix,
sdk.Uint64ToBigEndian(liquidFarmId),
sdk.Uint64ToBigEndian(auctionId))
}