/
key.go
52 lines (44 loc) · 1.71 KB
/
key.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
/*
* Copyright (C) 2020 The poly network Authors
* This file is part of The poly network library.
*
* The poly network is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* The poly network is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
* You should have received a copy of the GNU Lesser General Public License
* along with The poly network . If not, see <http://www.gnu.org/licenses/>.
*/
package keeper
import (
"encoding/binary"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/polynetwork/cosmos-poly-module/lockproxy/internal/types"
)
const (
// default paramspace for params keeper
DefaultParamspace = types.ModuleName
)
var (
OperatorToLockProxyKey = []byte{0x01}
BindProxyPrefix = []byte{0x02}
BindAssetPrefix = []byte{0x03}
)
func GetOperatorToLockProxyKey(operator sdk.AccAddress) []byte {
return append(OperatorToLockProxyKey, operator...)
}
func GetBindProxyKey(proxyHash []byte, toChainId uint64) []byte {
b := make([]byte, 8)
binary.LittleEndian.PutUint64(b, toChainId)
return append(append(BindProxyPrefix, proxyHash...), b...)
}
func GetBindAssetHashKey(lockProxyHash []byte, sourceAssetHash []byte, targetChainId uint64) []byte {
b := make([]byte, 8)
binary.LittleEndian.PutUint64(b, targetChainId)
return append(append(append(BindAssetPrefix, lockProxyHash...), sourceAssetHash...), b...)
}