-
Notifications
You must be signed in to change notification settings - Fork 28
/
msg_ibc_create_client.go
58 lines (45 loc) · 1.46 KB
/
msg_ibc_create_client.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
package event
import (
"bytes"
entity_event "github.com/crypto-com/chain-indexing/entity/event"
ibc_model "github.com/crypto-com/chain-indexing/usecase/model/ibc"
jsoniter "github.com/json-iterator/go"
"github.com/luci/go-render/render"
)
const MSG_IBC_CREATE_CLIENT = "/ibc.core.client.v1.MsgCreateClient"
const MSG_IBC_CREATE_CLIENT_CREATED = "/ibc.core.client.v1.MsgCreateClient.Created"
const MSG_IBC_CREATE_CLIENT_FAILED = "/ibc.core.client.v1.MsgCreateClient.Failed"
type MsgIBCCreateClient struct {
MsgBase
Params ibc_model.MsgCreateClientParams `json:"params"`
}
func NewMsgIBCCreateClient(msgCommonParams MsgCommonParams, params ibc_model.MsgCreateClientParams) *MsgIBCCreateClient {
return &MsgIBCCreateClient{
NewMsgBase(MsgBaseParams{
MsgName: MSG_IBC_CREATE_CLIENT,
Version: 1,
MsgCommonParams: msgCommonParams,
}),
params,
}
}
// ToJSON encodes the event into JSON string payload
func (event *MsgIBCCreateClient) ToJSON() (string, error) {
encoded, err := jsoniter.Marshal(event)
if err != nil {
return "", err
}
return string(encoded), nil
}
func (event *MsgIBCCreateClient) String() string {
return render.Render(event)
}
func DecodeMsgIBCCreateClient(encoded []byte) (entity_event.Event, error) {
jsonDecoder := jsoniter.NewDecoder(bytes.NewReader(encoded))
jsonDecoder.DisallowUnknownFields()
var event *MsgIBCCreateClient
if err := jsonDecoder.Decode(&event); err != nil {
return nil, err
}
return event, nil
}