-
Notifications
You must be signed in to change notification settings - Fork 0
/
common.go
47 lines (39 loc) · 1016 Bytes
/
common.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
package msgs
import (
models "github.com/bianjieai/chain-parser/common-parser/types"
"github.com/bianjieai/chain-parser/common-parser/utils"
"github.com/cosmos/cosmos-sdk/codec/types"
sdk "github.com/cosmos/cosmos-sdk/types"
)
func CreateMsgDocInfo(msg sdk.Msg, handler func() (Msg, []string)) MsgDocInfo {
var (
docTxMsg models.TxMsg
signers []string
addrs []string
)
m, addrcollections := handler()
m.BuildMsg(msg)
docTxMsg = models.TxMsg{
Type: m.GetType(),
Msg: m,
}
_, signers = models.BuildDocSigners(msg.GetSigners())
addrs = append(addrs, signers...)
addrs = append(addrs, addrcollections...)
return MsgDocInfo{
DocTxMsg: docTxMsg,
Signers: signers,
Addrs: addrs,
}
}
// ConvertMsg
// Deprecated, use type assertion instead of this
func ConvertMsg(v interface{}, msg interface{}) {
utils.UnMarshalJsonIgnoreErr(utils.MarshalJsonIgnoreErr(v), &msg)
}
func ConvertAny(v *types.Any) string {
if v != nil {
return utils.MarshalJsonIgnoreErr(v)
}
return ""
}