-
Notifications
You must be signed in to change notification settings - Fork 0
/
identity_update.go
54 lines (46 loc) · 1.33 KB
/
identity_update.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 identity
import (
. "github.com/bianjieai/chain-parser/common-parser/modules"
. "github.com/bianjieai/chain-parser/iritamod-parser/modules"
)
// DocMsgUpdateIdentity MsgUpdateIdentity defines a message to update an identity
type DocMsgUpdateIdentity struct {
Id string `bson:"id"`
PubKey *PubKeyInfo `bson:"pubkey"`
Certificate string `bson:"certificate"`
Credentials string `bson:"credentials"`
Owner string `bson:"owner"`
Data string `bson:"data"`
ExTemporary ExTemporary `bson:"ex"`
}
func (m *DocMsgUpdateIdentity) GetType() string {
return MsgTypeUpdateIdentity
}
func (m *DocMsgUpdateIdentity) BuildMsg(v interface{}) {
msg := v.(*MsgUpdateIdentity)
m.Id = msg.Id
m.Owner = msg.Owner
m.Data = msg.Data
if msg.PubKey != nil {
m.PubKey = &PubKeyInfo{
PubKey: msg.PubKey.PubKey,
Algorithm: int32(msg.PubKey.Algorithm),
}
}
m.Certificate = msg.Certificate
m.Credentials = msg.Credentials
if m.Certificate != "" {
m.ExTemporary = ExTemporary{
CertPubKey: getPubKeyFromCertificate(m.Certificate),
}
}
}
func (m *DocMsgUpdateIdentity) HandleTxMsg(v SdkMsg) MsgDocInfo {
var addrs []string
msg := v.(*MsgUpdateIdentity)
addrs = append(addrs, msg.Owner)
handler := func() (Msg, []string) {
return m, addrs
}
return CreateMsgDocInfo(v, handler)
}