Skip to content

Commit

Permalink
feat: use v2.0 for issuing credential
Browse files Browse the repository at this point in the history
Signed-off-by: Akiff Manji <amanji@petridish.dev>
  • Loading branch information
amanji committed Oct 25, 2023
1 parent ad0fa01 commit 2e75d5f
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ def send_credential(identifier, credential_type):
issued_credential = DCIssuedCredential(
dc_definition_id=definition.id,
dc_connection_id=connection.id,
credential_exchange_id=response['credential_exchange_id']
credential_exchange_id=response['cred_ex_id']
)
issued_credential.save()

Expand Down Expand Up @@ -210,9 +210,9 @@ def webhook_notification(topic_name: str):
connection.connection_state = json_input['state']
connection.is_active = True
connection.save()
elif topic_name == 'issue_credential':
issued_credential = DCIssuedCredential.find_by_credential_exchange_id(json_input['credential_exchange_id'])
if issued_credential and json_input['state'] == 'credential_issued':
elif topic_name == 'issue_credential_v2_0':
issued_credential = DCIssuedCredential.find_by_credential_exchange_id(json_input['cred_ex_id'])
if issued_credential and json_input['state'] in ('credential-issued', 'done'):
issued_credential.date_of_issue = datetime.utcnow()
issued_credential.is_issued = True
issued_credential.save()
Expand Down
28 changes: 16 additions & 12 deletions legal-api/src/legal_api/services/digital_credentials.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ class DigitalCredentialsService:
'business_type',
'given_names',
],
'schema_name': 'digital_business_card', # do not change schema name. this is the name registered in aca-py agent
'schema_version': '1.0.0' # if attributes changes update schema_version to re-register
'schema_name': 'digital_business_card', # do not change schema name. this is the name registered in aca-py agent
'schema_version': '1.0.0' # if attributes changes update schema_version to re-register
}

def __init__(self):
Expand Down Expand Up @@ -176,22 +176,26 @@ def issue_credential(self,
comment: str = '') -> Optional[dict]:
"""Send holder a credential, automating entire flow."""
try:
response = requests.post(self.api_url + '/issue-credential/send',
response = requests.post(self.api_url + '/issue-credential-2.0/send',
headers=self._get_headers(),
data=json.dumps({
'auto_remove': True,
'auto_remove': 'true',
'comment': comment,
'connection_id': connection_id,
'cred_def_id': definition.credential_definition_id,
'credential_proposal': {
'@type': 'issue-credential/1.0/credential-preview',
'credential_preview': {
'@type': 'issue-credential/2.0/credential-preview',
'attributes': data
},
'issuer_did': self.public_issuer_did,
'schema_id': definition.schema_id,
'schema_issuer_did': self.public_schema_did,
'schema_name': definition.schema_name,
'schema_version': definition.schema_version,
'filter': {
'indy': {
'cred_def_id': definition.credential_definition_id,
'issuer_did': self.public_issuer_did,
'schema_id': definition.schema_id,
'schema_issuer_did': self.public_schema_did,
'schema_name': definition.schema_name,
'schema_version': definition.schema_version,
}
},
'trace': True
}))
response.raise_for_status()
Expand Down

0 comments on commit 2e75d5f

Please sign in to comment.