-
Notifications
You must be signed in to change notification settings - Fork 29
/
client-tx.go
46 lines (40 loc) · 1.1 KB
/
client-tx.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
package tendermint
import (
"time"
"github.com/cometbft/cometbft/light"
sdk "github.com/cosmos/cosmos-sdk/types"
clienttypes "github.com/cosmos/ibc-go/v7/modules/core/02-client/types"
commitmenttypes "github.com/cosmos/ibc-go/v7/modules/core/23-commitment/types"
tmclient "github.com/cosmos/ibc-go/v7/modules/light-clients/07-tendermint"
)
func createClient(
dstHeader *tmclient.Header,
trustingPeriod, unbondingPeriod time.Duration,
signer sdk.AccAddress) *clienttypes.MsgCreateClient {
if err := dstHeader.ValidateBasic(); err != nil {
panic(err)
}
// Blank Client State
clientState := tmclient.NewClientState(
dstHeader.GetHeader().GetChainID(),
tmclient.NewFractionFromTm(light.DefaultTrustLevel),
trustingPeriod,
unbondingPeriod,
time.Minute*10,
dstHeader.GetHeight().(clienttypes.Height),
commitmenttypes.GetSDKSpecs(),
[]string{"upgrade", "upgradedIBCState"},
)
msg, err := clienttypes.NewMsgCreateClient(
clientState,
dstHeader.ConsensusState(),
signer.String(),
)
if err != nil {
panic(err)
}
if err = msg.ValidateBasic(); err != nil {
panic(err)
}
return msg
}