-
Notifications
You must be signed in to change notification settings - Fork 0
/
grant_allowance.go
47 lines (40 loc) · 1.3 KB
/
grant_allowance.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 feegrant
import (
"encoding/json"
"github.com/bianjieai/chain-parser/common-parser/codec"
. "github.com/bianjieai/chain-parser/common-parser/modules"
. "github.com/bianjieai/chain-parser/cosmosmod-parser/modules"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/sirupsen/logrus"
)
type DocTxMsgGrantAllowance struct {
Granter string `bson:"granter"`
Grantee string `bson:"grantee"`
Allowance interface{} `bson:"allowance"`
}
func (m *DocTxMsgGrantAllowance) GetType() string {
return MsgTypeGrantAllowance
}
func (m *DocTxMsgGrantAllowance) BuildMsg(v interface{}) {
msg := v.(*MsgGrantAllowance)
m.Granter = msg.Granter
m.Grantee = msg.Grantee
marshalJSON, err := codec.GetMarshaler().MarshalJSON(msg.Allowance)
if err != nil {
logrus.Errorf("DocTxMsgGrantAllowance codec.GetMarshaler().MarshalJSON err:%v", err)
}
var msgInterface interface{}
if err = json.Unmarshal(marshalJSON, &msgInterface); err != nil {
logrus.Errorf("DocTxMsgGrantAllowance json.Unmarshal err:%v", err)
}
m.Allowance = msgInterface
}
func (m *DocTxMsgGrantAllowance) HandleTxMsg(v sdk.Msg) MsgDocInfo {
var addrs []string
msg := v.(*MsgGrantAllowance)
addrs = append(addrs, msg.Granter, msg.Grantee)
handler := func() (Msg, []string) {
return m, addrs
}
return CreateMsgDocInfo(v, handler)
}