/
client_create.go
50 lines (39 loc) · 1.27 KB
/
client_create.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
package ibc
import (
"encoding/json"
. "github.com/kaifei-bianjie/common-parser/modules"
. "github.com/kaifei-bianjie/cschain-mod-parser/modules"
"gitlab.bianjie.ai/cschain/cschain/modules/ibc/core/types"
)
// MsgCreateClient defines a message to create an IBC client
type DocMsgCreateClient struct {
ClientID string `bson:"client_id" yaml:"client_id"`
ClientState string `bson:"client_state"`
ConsensusState string `bson:"consensus_state"`
Signer string `bson:"signer" yaml:"signer"`
}
func (m *DocMsgCreateClient) GetType() string {
return MsgTypeCreateClient
}
func (m *DocMsgCreateClient) BuildMsg(v interface{}) {
msg := v.(*MsgCreateClient)
if clientState, err := types.UnpackClientState(msg.ClientState); err == nil {
data, _ := json.Marshal(clientState)
m.ClientState = string(data)
}
if consensusState, err := types.UnpackConsensusState(msg.ConsensusState); err == nil {
data, _ := json.Marshal(consensusState)
m.ConsensusState = string(data)
}
m.ClientID = msg.ClientID
m.Signer = msg.Signer
}
func (m *DocMsgCreateClient) HandleTxMsg(v SdkMsg) MsgDocInfo {
var addrs []string
msg := v.(*MsgCreateClient)
addrs = append(addrs, msg.Signer)
handler := func() (Msg, []string) {
return m, addrs
}
return CreateMsgDocInfo(v, handler)
}