-
Notifications
You must be signed in to change notification settings - Fork 0
/
service_update_request_context.go
54 lines (45 loc) · 1.69 KB
/
service_update_request_context.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
package service
import (
. "github.com/bianjieai/chain-parser/common-parser/modules"
models "github.com/bianjieai/chain-parser/common-parser/types"
. "github.com/bianjieai/chain-parser/irismod-parser/modules"
"strings"
)
type (
DocMsgUpdateRequestContext struct {
RequestContextID string `bson:"request_context_id" yaml:"request_context_id"`
Providers []string `bson:"providers" yaml:"providers"`
Consumer string `bson:"consumer" yaml:"consumer"`
ServiceFeeCap []models.Coin `bson:"service_fee_cap" yaml:"service_fee_cap"`
Timeout int64 `bson:"timeout" yaml:"timeout"`
RepeatedFrequency int64 `bson:"repeated_frequency" yaml:"repeated_frequency"`
RepeatedTotal int64 `bson:"repeated_total" yaml:"repeated_total"`
}
)
func (m *DocMsgUpdateRequestContext) GetType() string {
return MsgTypeUpdateRequestContext
}
func (m *DocMsgUpdateRequestContext) BuildMsg(v interface{}) {
msg := v.(*MsgUpdateRequestContext)
var coins []models.Coin
for _, one := range msg.ServiceFeeCap {
coins = append(coins, models.Coin{Denom: one.Denom, Amount: one.Amount.String()})
}
m.RequestContextID = strings.ToUpper(msg.RequestContextId)
m.Providers = msg.Providers
m.Consumer = msg.Consumer
m.ServiceFeeCap = coins
m.Timeout = msg.Timeout
m.RepeatedFrequency = int64(msg.RepeatedFrequency)
m.RepeatedTotal = msg.RepeatedTotal
}
func (m *DocMsgUpdateRequestContext) HandleTxMsg(v SdkMsg) MsgDocInfo {
var addrs []string
msg := v.(*MsgUpdateRequestContext)
addrs = append(addrs, msg.Providers...)
addrs = append(addrs, msg.Consumer)
handler := func() (Msg, []string) {
return m, addrs
}
return CreateMsgDocInfo(v, handler)
}