File tree 3 files changed +22
-6
lines changed
3 files changed +22
-6
lines changed Original file line number Diff line number Diff line change @@ -136,7 +136,7 @@ def add(
136
136
137
137
def add_didcomm (
138
138
self ,
139
- endpoint : str ,
139
+ service_endpoint : str ,
140
140
recipient_keys : List [VerificationMethod ],
141
141
routing_keys : List [VerificationMethod ] = None ,
142
142
* ,
@@ -150,7 +150,7 @@ def add_didcomm(
150
150
priority = priority or self ._determine_next_priority ()
151
151
service = DIDCommService .make (
152
152
id = self ._did .ref (ident ),
153
- service_endpoint = endpoint ,
153
+ service_endpoint = service_endpoint ,
154
154
recipient_keys = [vmethod .id for vmethod in recipient_keys ],
155
155
routing_keys = [vmethod .id for vmethod in routing_keys ],
156
156
type = type_ ,
@@ -228,7 +228,7 @@ def from_doc(cls, doc: DIDDocument) -> "DIDDocumentBuilder":
228
228
def build (self ) -> DIDDocument :
229
229
"""Build document."""
230
230
return DIDDocument .construct (
231
- id = str ( self .id ) ,
231
+ id = self .id ,
232
232
context = self .context ,
233
233
also_known_as = self .also_known_as ,
234
234
controller = self .controller ,
Original file line number Diff line number Diff line change @@ -148,6 +148,13 @@ def to_json(self):
148
148
"""Serialize DID Document to JSON."""
149
149
return self .json ()
150
150
151
+ @classmethod
152
+ def construct (cls , ** data ):
153
+ """Construct and index."""
154
+ doc = super (Resource , cls ).construct (** data )
155
+ doc ._index_resources ()
156
+ return doc
157
+
151
158
152
159
PossibleMethodTypes = Union [KnownVerificationMethods , UnknownVerificationMethod ]
153
160
PossibleServiceTypes = Union [DIDCommService , UnknownService ]
Original file line number Diff line number Diff line change @@ -415,10 +415,10 @@ def test_programmatic_construction_didcomm():
415
415
ExampleVerificationMethod , public_key_example = "abcd"
416
416
)
417
417
builder .service .add_didcomm (
418
- endpoint = "https://example.com" , recipient_keys = [key ], routing_keys = [route ]
418
+ service_endpoint = "https://example.com" ,
419
+ recipient_keys = [key ],
420
+ routing_keys = [route ],
419
421
)
420
- print (builder .build ())
421
- print (builder .build ().serialize ())
422
422
assert builder .build ().serialize () == {
423
423
"@context" : ["https://www.w3.org/ns/did/v1" ],
424
424
"id" : "did:example:123" ,
@@ -598,6 +598,15 @@ def test_key_rotation_from_doc():
598
598
}
599
599
600
600
601
+ def test_build_and_dereference ():
602
+ builder = DIDDocumentBuilder ("did:example:123" )
603
+ builder .verification_method .add (
604
+ Ed25519VerificationKey2018 , public_key_base58 = "test" , ident = "1"
605
+ )
606
+ doc = builder .build ()
607
+ assert doc .dereference ("#1" )
608
+
609
+
601
610
def test_dereference_and_membership_check ():
602
611
doc_raw = {
603
612
"@context" : "https://www.w3.org/ns/did/v1" ,
You can’t perform that action at this time.
0 commit comments