-
Notifications
You must be signed in to change notification settings - Fork 368
/
keys.go
49 lines (39 loc) · 1.59 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
package types
import (
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/address"
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
"github.com/ethereum/go-ethereum/common"
)
const (
// ModuleName name that will be used throughout the module
ModuleName = "evmutil"
StoreKey = "utilevm" // note: cannot be emvutil due to collision with x/evm
// RouterKey Top level router key
RouterKey = ModuleName
)
// KVStore keys
var (
// AccountStoreKeyPrefix is the prefix for keys that store accounts
AccountStoreKeyPrefix = []byte{0x00}
// DeployedCosmosCoinContractKeyPrefix is the key for storing deployed KavaWrappedCosmosCoinERC20s contract addresses
DeployedCosmosCoinContractKeyPrefix = []byte{0x01}
)
// AccountStoreKey turns an address to a key used to get the account from the store
func AccountStoreKey(addr sdk.AccAddress) []byte {
return append(AccountStoreKeyPrefix, address.MustLengthPrefix(addr)...)
}
// DeployedCosmosCoinContractKey gives the store key that holds the address of the deployed ERC20
// that wraps the given cosmosDenom sdk.Coin
func DeployedCosmosCoinContractKey(cosmosDenom string) []byte {
return append(DeployedCosmosCoinContractKeyPrefix, []byte(cosmosDenom)...)
}
// DenomFromDeployedCosmosCoinContractKey is the inverse of DeployedCosmosCoinContractKey
func DenomFromDeployedCosmosCoinContractKey(key []byte) string {
return string(key[1:])
}
// ModuleAddress is the native module address for EVM
var ModuleEVMAddress common.Address
func init() {
ModuleEVMAddress = common.BytesToAddress(authtypes.NewModuleAddress(ModuleName).Bytes())
}