forked from ldej/go-acapy-client
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ledger.go
46 lines (43 loc) · 1.09 KB
/
ledger.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
package acapy
// available endpoint types: Endpoint, Profile, LinkedDomains
func (c *Client) GetDIDEndpointFromLedger(did string, endpointType string) (string, error) {
var result = struct {
Endpoint string `json:"endpoint"`
}{}
var queryParams = map[string]string{
"did": did,
"endpoint_type": endpointType,
}
err := c.get("/ledger/did-endpoint", queryParams, &result)
if err != nil {
return "", err
}
return result.Endpoint, nil
}
func (c *Client) GetDIDVerkeyFromLedger(did string) (string, error) {
var result = struct {
Verkey string `json:"verkey"`
}{}
var queryParams = map[string]string{
"did": did,
}
err := c.get("/ledger/did-verkey", queryParams, &result)
if err != nil {
return "", err
}
return result.Verkey, nil
}
// Use DID instead of NYM, as NYM is outdated
func (c *Client) GetDIDRoleFromLedger(did string) (string, error) {
var result = struct {
Role string `json:"role"`
}{}
var queryParams = map[string]string{
"did": did,
}
err := c.get("/ledger/get-nym-role", queryParams, &result)
if err != nil {
return "", err
}
return result.Role, nil
}