-
Notifications
You must be signed in to change notification settings - Fork 0
/
config.go
95 lines (78 loc) · 2.4 KB
/
config.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
package ibctesting
import (
"time"
"github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1"
connectiontypes "github.com/cosmos/ibc-go/modules/core/03-connection/types"
"github.com/cosmos/ibc-go/modules/core/exported"
ibctmtypes "github.com/cosmos/ibc-go/modules/light-clients/07-tendermint/types"
ibcmocktypes "github.com/datachainlab/ibc-mock-client/modules/light-clients/xx-mock/types"
trustedethereumtypes "github.com/datachainlab/ibc-trusted-ethereum-client/modules/light-clients/trusted-ethereum/types"
"github.com/datachainlab/ibc-trusted-ethereum-client/tests/testing/types"
)
type ClientConfig interface {
GetClientType() string
}
type TrustedEthereumConfig struct {
Diversifier string
PrivateKey *secp256k1.PrivKey
}
func (cfg *TrustedEthereumConfig) GetClientType() string {
return trustedethereumtypes.TrustedEthereum
}
func NewTrustedEthereumConfig(diversifier string) *TrustedEthereumConfig {
return &TrustedEthereumConfig{
Diversifier: diversifier,
PrivateKey: secp256k1.GenPrivKey(),
}
}
type MockConfig struct {
}
func NewMockConfig() *MockConfig {
return &MockConfig{}
}
func (cfg *MockConfig) GetClientType() string {
return ibcmocktypes.Mock
}
type TendermintConfig struct {
TrustLevel ibctmtypes.Fraction
TrustingPeriod time.Duration
UnbondingPeriod time.Duration
MaxClockDrift time.Duration
AllowUpdateAfterExpiry bool
AllowUpdateAfterMisbehaviour bool
}
func NewTendermintConfig() *TendermintConfig {
return &TendermintConfig{
TrustLevel: types.DefaultTrustLevel,
TrustingPeriod: types.TrustingPeriod,
UnbondingPeriod: types.UnbondingPeriod,
MaxClockDrift: types.MaxClockDrift,
AllowUpdateAfterExpiry: false,
AllowUpdateAfterMisbehaviour: false,
}
}
func (tmcfg *TendermintConfig) GetClientType() string {
return exported.Tendermint
}
type ConnectionConfig struct {
DelayPeriod uint64
Version *connectiontypes.Version
}
func NewConnectionConfig() *ConnectionConfig {
return &ConnectionConfig{
DelayPeriod: types.DefaultDelayPeriod,
Version: types.ConnectionVersion,
}
}
type ChannelConfig struct {
PortID string
Version string
Order types.ChannelOrder
}
func NewChannelConfig() *ChannelConfig {
return &ChannelConfig{
PortID: types.TransferPort,
Version: types.DefaultChannelVersion,
Order: types.UNORDERED,
}
}