@@ -2,8 +2,10 @@ package dataverse
2
2
3
3
import (
4
4
"context"
5
+ "encoding/json"
5
6
"fmt"
6
7
"github.com/hyperledger/aries-framework-go/pkg/doc/verifiable"
8
+ "github.com/piprate/json-gold/ld"
7
9
8
10
cgschema "github.com/axone-protocol/axone-contract-schema/go/cognitarium-schema/v5"
9
11
dvschema "github.com/axone-protocol/axone-contract-schema/go/dataverse-schema/v5"
@@ -32,7 +34,7 @@ type Client interface {
32
34
// The function returns true if Result is 'permitted', false otherwise.
33
35
AskGovTellAction (context.Context , string , string , string ) (bool , error )
34
36
35
- SubmitClaims (ctx context.Context , credential * verifiable.Credential )
37
+ SubmitClaims (ctx context.Context , credential * verifiable.Credential ) error
36
38
}
37
39
38
40
type LawStoneFactory func (string ) (lsschema.QueryClient , error )
@@ -43,10 +45,6 @@ type client struct {
43
45
lawStoneFactory LawStoneFactory
44
46
}
45
47
46
- func (c * client ) SubmitClaims (_ context.Context , _ * verifiable.Credential ) {
47
- panic ("implement me" )
48
- }
49
-
50
48
func NewClient (ctx context.Context ,
51
49
grpcAddr , contractAddr string ,
52
50
opts ... grpc.DialOption ,
@@ -75,6 +73,29 @@ func NewClient(ctx context.Context,
75
73
}, nil
76
74
}
77
75
76
+ func (c * client ) SubmitClaims (_ context.Context , vc * verifiable.Credential ) error {
77
+ proc := ld .NewJsonLdProcessor ()
78
+ options := ld .NewJsonLdOptions ("" )
79
+ options .Format = "application/n-quads"
80
+
81
+ vcRaw , err := json .Marshal (vc )
82
+ if err != nil {
83
+ return err
84
+ }
85
+
86
+ var vcJSON interface {}
87
+ err = json .Unmarshal (vcRaw , & vcJSON )
88
+ if err != nil {
89
+ return err
90
+ }
91
+ rdf , err := proc .ToRDF (vcJSON , options )
92
+ if err != nil {
93
+ return err
94
+ }
95
+ fmt .Printf ("rdf: %s\n " , rdf )
96
+ return nil
97
+ }
98
+
78
99
func getCognitariumAddr (ctx context.Context , dvClient dvschema.QueryClient ) (string , error ) {
79
100
query := dvschema.QueryMsg_Dataverse {}
80
101
resp , err := dvClient .Dataverse (ctx , & query )
0 commit comments