-
Notifications
You must be signed in to change notification settings - Fork 802
/
keys.go
129 lines (105 loc) · 3.5 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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
package types
import (
"encoding/binary"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/ethereum/go-ethereum/common"
)
const (
// module name
ModuleName = "evm"
RouterKey = ModuleName
// StoreKey is string representation of the store key for auth
StoreKey = "evm"
MemStoreKey = "evm_mem"
// QuerierRoute is the querier route for auth
QuerierRoute = ModuleName
)
var (
EVMAddressToSeiAddressKeyPrefix = []byte{0x01}
SeiAddressToEVMAddressKeyPrefix = []byte{0x02}
StateKeyPrefix = []byte{0x03}
TransientStateKeyPrefix = []byte{0x04} // deprecated
AccountTransientStateKeyPrefix = []byte{0x05} // deprecated
TransientModuleStateKeyPrefix = []byte{0x06} // deprecated
CodeKeyPrefix = []byte{0x07}
CodeHashKeyPrefix = []byte{0x08}
CodeSizeKeyPrefix = []byte{0x09}
NonceKeyPrefix = []byte{0x0a}
ReceiptKeyPrefix = []byte{0x0b}
WhitelistedCodeHashesForBankSendPrefix = []byte{0x0c}
BlockBloomPrefix = []byte{0x0d}
TxHashesPrefix = []byte{0x0e}
WhitelistedCodeHashesForDelegateCallPrefix = []byte{0x0f}
//mem
TxHashPrefix = []byte{0x10}
TxBloomPrefix = []byte{0x11}
ReplaySeenAddrPrefix = []byte{0x12}
ReplayedHeight = []byte{0x13}
ReplayInitialHeight = []byte{0x14}
PointerRegistryPrefix = []byte{0x15}
PointerCWCodePrefix = []byte{0x16}
PointerReverseRegistryPrefix = []byte{0x17}
AnteSurplusPrefix = []byte{0x18}
)
var (
PointerERC20NativePrefix = []byte{0x0}
PointerERC20CW20Prefix = []byte{0x1}
PointerERC721CW721Prefix = []byte{0x2}
PointerCW20ERC20Prefix = []byte{0x3}
PointerCW721ERC721Prefix = []byte{0x4}
)
func EVMAddressToSeiAddressKey(evmAddress common.Address) []byte {
return append(EVMAddressToSeiAddressKeyPrefix, evmAddress[:]...)
}
func SeiAddressToEVMAddressKey(seiAddress sdk.AccAddress) []byte {
return append(SeiAddressToEVMAddressKeyPrefix, seiAddress...)
}
func StateKey(evmAddress common.Address) []byte {
return append(StateKeyPrefix, evmAddress[:]...)
}
func ReceiptKey(txHash common.Hash) []byte {
return append(ReceiptKeyPrefix, txHash[:]...)
}
func BlockBloomKey(height int64) []byte {
bz := make([]byte, 8)
binary.BigEndian.PutUint64(bz, uint64(height))
return append(BlockBloomPrefix, bz...)
}
func TxHashesKey(height int64) []byte {
bz := make([]byte, 8)
binary.BigEndian.PutUint64(bz, uint64(height))
return append(TxHashesPrefix, bz...)
}
func PointerERC20NativeKey(token string) []byte {
return append(
append(PointerRegistryPrefix, PointerERC20NativePrefix...),
[]byte(token)...,
)
}
func PointerERC20CW20Key(cw20Address string) []byte {
return append(
append(PointerRegistryPrefix, PointerERC20CW20Prefix...),
[]byte(cw20Address)...,
)
}
func PointerERC721CW721Key(cw721Address string) []byte {
return append(
append(PointerRegistryPrefix, PointerERC721CW721Prefix...),
[]byte(cw721Address)...,
)
}
func PointerCW20ERC20Key(erc20Addr common.Address) []byte {
return append(
append(PointerRegistryPrefix, PointerCW20ERC20Prefix...),
erc20Addr[:]...,
)
}
func PointerCW721ERC721Key(erc721Addr common.Address) []byte {
return append(
append(PointerRegistryPrefix, PointerCW721ERC721Prefix...),
erc721Addr[:]...,
)
}
func PointerReverseRegistryKey(addr common.Address) []byte {
return append(PointerReverseRegistryPrefix, addr[:]...)
}