@@ -157,138 +157,8 @@ async def icv2():
157157 )
158158
159159
160- @dataclass
161- class ConnectionlessV10CredExRecord (Minimal ):
162- """Minimal record for v1 cred ex record."""
163-
164- credential_exchange_id : str
165-
166-
167- async def icv1 ():
168- """Issue credential v1."""
169- async with Controller (base_url = ALICE ) as alice , Controller (base_url = BOB ) as bob :
170- config = (await alice .get ("/status/config" ))["config" ]
171- genesis_url = config .get ("ledger.genesis_url" )
172- public_did = (await alice .get ("/wallet/did/public" , response = DIDResult )).result
173- if not public_did :
174- public_did = (
175- await alice .post (
176- "/wallet/did/create" ,
177- json = {"method" : "sov" , "options" : {"key_type" : "ed25519" }},
178- response = DIDResult ,
179- )
180- ).result
181- assert public_did
182-
183- async with ClientSession () as session :
184- register_url = genesis_url .replace ("/genesis" , "/register" )
185- async with session .post (
186- register_url ,
187- json = {
188- "did" : public_did .did ,
189- "verkey" : public_did .verkey ,
190- "alias" : None ,
191- "role" : "ENDORSER" ,
192- },
193- ) as resp :
194- if resp .ok :
195- return await resp .json ()
196-
197- await alice .post ("/wallet/did/public" , params = params (did = public_did .did ))
198-
199- _ , cred_def = await indy_anoncred_credential_artifacts (
200- alice , ["firstname" , "lastname" ]
201- )
202-
203- attributes = {"firstname" : "Bob" , "lastname" : "Builder" }
204- offer = await alice .post (
205- "/issue-credential/create-offer" ,
206- json = {
207- "auto_issue" : False ,
208- "auto_remove" : False ,
209- "comment" : "Credential from minimal example" ,
210- "trace" : False ,
211- "cred_def_id" : cred_def .credential_definition_id ,
212- "credential_preview" : {
213- "@type" : "issue-credential/1.0/credential-preview" ,
214- "attributes" : [
215- {
216- "mime_type" : None ,
217- "name" : name ,
218- "value" : value ,
219- }
220- for name , value in attributes .items ()
221- ],
222- },
223- },
224- response = ConnectionlessV10CredExRecord ,
225- )
226- invite = await alice .post (
227- "/out-of-band/create-invitation" ,
228- json = {
229- "attachments" : [
230- {"id" : offer .credential_exchange_id , "type" : "credential-offer" }
231- ]
232- },
233- response = InvitationRecord ,
234- )
235- bob .event_queue .flush ()
236- await bob .post ("/out-of-band/receive-invitation" , json = invite .invitation )
237- bob_cred_ex = await bob .event_with_values (
238- topic = "issue_credential" ,
239- state = "offer_received" ,
240- event_type = ConnectionlessV10CredExRecord ,
241- )
242- bob_cred_ex_id = bob_cred_ex .credential_exchange_id
243-
244- alice .event_queue .flush ()
245- bob_cred_ex = await bob .post (
246- f"/issue-credential/records/{ bob_cred_ex_id } /send-request" ,
247- response = ConnectionlessV10CredExRecord ,
248- )
249-
250- alice_cred_ex = await alice .event_with_values (
251- topic = "issue_credential" ,
252- state = "request_received" ,
253- event_type = ConnectionlessV10CredExRecord ,
254- )
255- alice_cred_ex_id = alice_cred_ex .credential_exchange_id
256-
257- alice_cred_ex = await alice .post (
258- f"/issue-credential/records/{ alice_cred_ex_id } /issue" ,
259- json = {},
260- response = ConnectionlessV10CredExRecord ,
261- )
262-
263- await bob .event_with_values (
264- topic = "issue_credential" ,
265- credential_exchange_id = bob_cred_ex_id ,
266- state = "credential_received" ,
267- )
268-
269- bob_cred_ex = await bob .post (
270- f"/issue-credential/records/{ bob_cred_ex_id } /store" ,
271- json = {},
272- response = ConnectionlessV10CredExRecord ,
273- )
274- alice_cred_ex = await alice .event_with_values (
275- topic = "issue_credential" ,
276- event_type = ConnectionlessV10CredExRecord ,
277- credential_exchange_id = alice_cred_ex_id ,
278- state = "credential_acked" ,
279- )
280-
281- bob_cred_ex = await bob .event_with_values (
282- topic = "issue_credential" ,
283- event_type = ConnectionlessV10CredExRecord ,
284- credential_exchange_id = bob_cred_ex_id ,
285- state = "credential_acked" ,
286- )
287-
288-
289160async def main ():
290161 """Run."""
291- await icv1 ()
292162 await icv2 ()
293163
294164
0 commit comments