-
Notifications
You must be signed in to change notification settings - Fork 9
/
keys.go
63 lines (50 loc) · 1.81 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
package types
import (
"crypto/sha256"
"fmt"
sdk "github.com/cosmos/cosmos-sdk/types"
)
const (
// ModuleName defines the IBC swap name
ModuleName = "swap"
// Version defines the current version the IBC swap
// module supports
Version = "ics100-1"
// PortID is the default port id that swap module binds to
PortID = ModuleName
// StoreKey is the store key string for IBC swap
StoreKey = ModuleName
// RouterKey is the message route for IBC swap
RouterKey = ModuleName
// QuerierRoute is the querier route for IBC swap
QuerierRoute = ModuleName
MaxOrderCount = 10000000000000
)
var (
// PortKey defines the key to store the port ID in store
PortKey = []byte{0x01}
// LimitOrderBookKey defines the key to store the denomination trace info in store
//LimitOrderBookKey = []byte{0x02}
//LimitOrderBookKeyIndexKey = []byte{0x03}
// OTCOrderBookKey defines the key to store the denomination trace info in store
OTCOrderBookKey = []byte{0x04}
OTCOrderBookKeyCountKey = []byte{0x05}
OTCOrderBookKeyIndexKey = []byte{0x06}
)
// GetEscrowAddress returns the escrow address for the specified channel.
// The escrow address follows the format as outlined in ADR 028:
// https://github.com/cosmos/cosmos-sdk/blob/master/docs/architecture/adr-028-public-key-addresses.md
func GetEscrowAddress(portID, channelID string) sdk.AccAddress {
// a slash is used to create domain separation between port and channel identifiers to
// prevent address collisions between escrow addresses created for different channels
contents := fmt.Sprintf("%s/%s", portID, channelID)
// ADR 028 AddressHash construction
preImage := []byte(Version)
preImage = append(preImage, 0)
preImage = append(preImage, contents...)
hash := sha256.Sum256(preImage)
return hash[:20]
}
func KeyPrefix(key string) []byte {
return []byte(key)
}