/
keys.go
50 lines (39 loc) · 1.68 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
package types
import (
"github.com/merlin-network/fury/utils"
)
const (
// ModuleName is the name of the house module
ModuleName = "house"
// StoreKey is the string store representation
StoreKey = ModuleName
// QuerierRoute is the querier route for the house module
QuerierRoute = ModuleName
// RouterKey is the msg router key for the house module
RouterKey = ModuleName
)
// module accounts constants
const (
// HouseParticipationFeeName defines the account name for house participation fee
HouseParticipationFeeName = "house_participation_fee_pool"
)
var (
DepositKeyPrefix = []byte{0x00} // prefix for keys that store deposits
WithdrawalKeyPrefix = []byte{0x01} // prefix for keys that store withdrawals
)
// GetDepositKey creates the key for deposit bond with sport event and participation
func GetDepositKey(depositorAddr string, sportEventUID string, participationIndex uint64) []byte {
return append(GetDepositListPrefix(depositorAddr), append(utils.StrBytes(sportEventUID), utils.Uint64ToBytes(participationIndex)...)...)
}
// GetDepositListPrefix creates the key for deposit bond with sport event
func GetDepositListPrefix(depositorAddr string) []byte {
return utils.StrBytes(depositorAddr)
}
// GetWithdrawalKey creates the key for withdrawal bond with sport event and deposit
func GetWithdrawalKey(depositorAddr string, sportEventUID string, participationIndex uint64, id uint64) []byte {
return append(GetDepositKey(depositorAddr, sportEventUID, participationIndex), utils.Uint64ToBytes(id)...)
}
// GetWithdrawalListPrefix creates the key for withdrawals bond with sport event
func GetWithdrawalListPrefix(depositorAddr string) []byte {
return utils.StrBytes(depositorAddr)
}