-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathinterface.go
96 lines (85 loc) · 2.75 KB
/
interface.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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
package bitxid
// Doc represents did doc
type Doc interface {
Marshal() ([]byte, error)
Unmarshal(docBytes []byte) error
GetID() DID
IsValidFormat() bool
GetType() int
}
// TableItem represents the table item of a registry table
type TableItem interface {
Marshal() ([]byte, error)
Unmarshal(itemBytes []byte) error
GetID() DID
}
// DocDB represents did Doc db (used under InternalDocDB mode)
type DocDB interface {
Create(doc Doc) (string, error)
Update(doc Doc) (string, error)
Get(did DID, typ DIDType) (Doc, error)
Delete(did DID)
Has(did DID) bool
Close() error
}
// RegistryTable represents state table of a registry
type RegistryTable interface {
CreateItem(item TableItem) error
UpdateItem(item TableItem) error
GetItem(did DID, typ DIDType) (TableItem, error)
HasItem(did DID) bool
DeleteItem(did DID)
Close() error
}
// BasicManager represents basic did management that should be used
// by other type of did management registry.
type BasicManager interface {
SetupGenesis() error
GetSelfID() DID
GetAdmins() []DID
AddAdmin(caller DID) error
RemoveAdmin(caller DID) error
HasAdmin(caller DID) bool
}
// ChainDIDManager represents chain did management registry
type ChainDIDManager interface {
BasicManager
HasChainDID(chainDID DID) bool
Apply(caller DID, chainDID DID) error
AuditApply(chainDID DID, result bool) error
Audit(chainDID DID, status StatusType) error
Register(chainDID DID, addr string, hash []byte) (string, []byte, error)
RegisterWithDoc(doc Doc) (string, []byte, error)
Update(chainDID DID, addr string, hash []byte) (string, []byte, error)
UpdateWithDoc(doc Doc) (string, []byte, error)
Freeze(chainDID DID) error
UnFreeze(chainDID DID) error
Resolve(chainDID DID) (*ChainItem, *ChainDoc, bool, error)
Delete(chainDID DID) error
}
// AccountDIDManager represents account did management registry
type AccountDIDManager interface {
BasicManager
GetChainDID() DID
HasAccountDID(did DID) bool
Register(did DID, addr string, hash []byte) (string, []byte, error)
RegisterWithDoc(doc Doc) (string, []byte, error)
Update(did DID, addr string, hash []byte) (string, []byte, error)
UpdateWithDoc(doc Doc) (string, []byte, error)
Freeze(did DID) error
UnFreeze(did DID) error
Delete(did DID) error
Resolve(did DID) (*AccountItem, *AccountDoc, bool, error)
}
// VCManager interface for verifiable credential management registry
type VCManager interface {
CreateClaimTyp(ct *ClaimTyp) (string, error)
GetClaimTyp(ctid string) (*ClaimTyp, error)
DeleteClaimtyp(ctid string)
GetAllClaimTyps() ([]*ClaimTyp, error)
StoreVC(c *Credential) (string, error)
GetVC(cid string) (*Credential, error)
DeleteVC(cid string)
// IssueVC(did DID, claimContent string, claimTye string, signature Sig) ([]byte, error)
// RevokeVC(did DID) error
}