Skip to content

Commit

Permalink
fix: blank v2 proof request notification (#1400)
Browse files Browse the repository at this point in the history
Signed-off-by: Bryce McMath <[email protected]>
  • Loading branch information
bryce-mcmath authored Jan 17, 2025
1 parent 8d99026 commit a94474e
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 18 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -66,4 +66,4 @@
"@hyperledger/[email protected]": "patch:@hyperledger/indy-vdr-react-native@npm%3A0.2.2#./.yarn/patches/@hyperledger-indy-vdr-react-native-npm-0.2.2-627d424b96.patch",
"@hyperledger/[email protected]": "patch:@hyperledger/indy-vdr-shared@npm%3A0.2.2#./.yarn/patches/@hyperledger-indy-vdr-shared-npm-0.2.2-b989282fc6.patch"
}
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { V1RequestPresentationMessage } from '@credo-ts/anoncreds'
import { AnonCredsProofRequest, V1RequestPresentationMessage } from '@credo-ts/anoncreds'
import {
Agent,
BasicMessageRecord,
Expand Down Expand Up @@ -265,20 +265,27 @@ const NotificationListItem: React.FC<NotificationListItemProps> = ({
} catch (error) {
logger.error('Error finding request message:', error as CredoError)
}
if (message instanceof V1RequestPresentationMessage && message.indyProofRequest) {
details = {
type: InfoBoxType.Info,
title: t('ProofRequest.NewProofRequest'),
body: message.indyProofRequest.name ?? message.comment ?? '',
buttonTitle: undefined,
}
} else {
details = {
type: InfoBoxType.Info,
title: t('ProofRequest.NewProofRequest'),
body: message?.comment ?? '',
buttonTitle: undefined,
}

// message.comment is the common fallback title for both v1 and v2 proof requests
let body: string = message?.comment ?? ''

if (message instanceof V1RequestPresentationMessage) {
body = message.indyProofRequest?.name ?? body
}

if (message instanceof V2RequestPresentationMessage) {
// workaround for getting proof request name in v2 proof request
// https://github.com/openwallet-foundation/credo-ts/blob/5f08bc67e3d1cc0ab98e7cce7747fedd2bf71ec1/packages/core/src/modules/proofs/protocol/v2/messages/V2RequestPresentationMessage.ts#L78
const attachment = message.requestAttachments.find((attachment) => attachment.id === 'indy')
const name = attachment?.getDataAsJson<AnonCredsProofRequest>()?.name ?? null
body = name ?? body
}

details = {
type: InfoBoxType.Info,
title: t('ProofRequest.NewProofRequest'),
body,
buttonTitle: undefined,
}
break
}
Expand Down
2 changes: 1 addition & 1 deletion packages/legacy/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -238,4 +238,4 @@
"typescript"
]
}
}
}
2 changes: 1 addition & 1 deletion packages/remote-logs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,4 +58,4 @@
"react-native": "0.72.17",
"react-native-logs": "^5.1.0"
}
}
}

0 comments on commit a94474e

Please sign in to comment.