-
Notifications
You must be signed in to change notification settings - Fork 41
/
tx_msg_create_did_payload.go
40 lines (33 loc) · 1.15 KB
/
tx_msg_create_did_payload.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
package types
var _ IdentityMsg = &MsgCreateDidPayload{}
func (msg *MsgCreateDidPayload) GetSignBytes() []byte {
return ModuleCdc.MustMarshal(msg)
}
func (msg *MsgCreateDidPayload) ToDid() Did {
return Did{
Context: msg.Context,
Id: msg.Id,
Controller: msg.Controller,
VerificationMethod: msg.VerificationMethod,
Authentication: msg.Authentication,
AssertionMethod: msg.AssertionMethod,
CapabilityInvocation: msg.CapabilityInvocation,
CapabilityDelegation: msg.CapabilityDelegation,
KeyAgreement: msg.KeyAgreement,
AlsoKnownAs: msg.AlsoKnownAs,
Service: msg.Service,
}
}
// Validation
func (msg MsgCreateDidPayload) Validate(allowedNamespaces []string) error {
return msg.ToDid().Validate(allowedNamespaces)
}
func ValidMsgCreateDidPayloadRule(allowedNamespaces []string) *CustomErrorRule {
return NewCustomErrorRule(func(value interface{}) error {
casted, ok := value.(*MsgCreateDidPayload)
if !ok {
panic("ValidMsgCreateDidPayloadRule must be only applied on MsgCreateDidPayload properties")
}
return casted.Validate(allowedNamespaces)
})
}