-
Notifications
You must be signed in to change notification settings - Fork 5
/
channel_recv_packet.go
45 lines (38 loc) · 1.26 KB
/
channel_recv_packet.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
package ibc
import (
"fmt"
. "github.com/kaifei-bianjie/msg-parser/modules"
"github.com/kaifei-bianjie/msg-parser/utils"
)
type DocMsgRecvPacket struct {
PacketId string `bson:"packet_id"`
Packet Packet `bson:"packet"`
ProofCommitment string `bson:"proof_commitment"`
ProofHeight Height `bson:"proof_height"`
Signer string `bson:"signer"`
}
func (m *DocMsgRecvPacket) GetType() string {
return MsgTypeRecvPacket
}
func (m *DocMsgRecvPacket) BuildMsg(v interface{}) {
msg := v.(*MsgRecvPacket)
m.Signer = msg.Signer
m.ProofHeight = loadHeight(msg.ProofHeight)
m.ProofCommitment = utils.MarshalJsonIgnoreErr(msg.ProofCommitment)
m.Packet = loadPacket(msg.Packet)
m.PacketId = fmt.Sprintf("%v%v%v%v%v", msg.Packet.SourcePort, msg.Packet.SourceChannel,
msg.Packet.DestinationPort, msg.Packet.DestinationChannel, msg.Packet.Sequence)
}
func (m *DocMsgRecvPacket) HandleTxMsg(v SdkMsg) MsgDocInfo {
var (
addrs []string
msg MsgRecvPacket
)
utils.UnMarshalJsonIgnoreErr(utils.MarshalJsonIgnoreErr(v), &msg)
packetData := UnmarshalPacketData(msg.Packet.GetData())
addrs = append(addrs, msg.Signer, packetData.Receiver, packetData.Sender)
handler := func() (Msg, []string) {
return m, addrs
}
return CreateMsgDocInfo(v, handler)
}