Skip to content

Commit 9877394

Browse files
committed
fix the mapping if multiple credenials are pat of transactionData mapping
Signed-off-by: Johannes Tuerk <johannes.tuerk@lissi.id>
1 parent b5a9ec9 commit 9877394

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

src/WalletFramework.Oid4Vc/Oid4Vp/TransactionDatas/TransactionDataFun.cs

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
using LanguageExt;
22
using WalletFramework.Core.Base64Url;
33
using WalletFramework.Core.Functional;
4+
using WalletFramework.Core.Functional.Enumerable;
45
using WalletFramework.Oid4Vc.Oid4Vp.Errors;
56
using WalletFramework.Oid4Vc.Oid4Vp.Models;
67
using WalletFramework.Oid4Vc.Oid4Vp.TransactionDatas.Errors;
@@ -122,21 +123,24 @@ internal static Validation<AuthorizationRequestCancellation, PresentationRequest
122123

123124
foreach (var txData in transactionDatas)
124125
{
125-
var found = indexedCandidates.FirstOrDefault(tuple =>
126+
var findings = indexedCandidates.Where(tuple =>
126127
{
127128
return new[] { tuple.candidate }.FindCandidateForTransactionData(txData).IsSuccess;
128-
});
129+
}).ToList();
129130

130-
if (found == default)
131+
if (findings.IsEmpty())
131132
{
132133
return new InvalidTransactionDataError(
133134
$"No credentials found that satisfy the transaction data with type {txData.GetTransactionDataType().AsString()}",
134135
presentationRequest).ToInvalid<PresentationRequest>();
135136
}
136137

137138
// Update the candidate with the transaction data
138-
var updated = found.candidate.AddTransactionDatas([txData]);
139-
updatedCandidates[(found.setIdx, found.candIdx)] = updated;
139+
foreach (var found in findings)
140+
{
141+
var updated = found.candidate.AddTransactionDatas([txData]);
142+
updatedCandidates[(found.setIdx, found.candIdx)] = updated;
143+
}
140144
}
141145

142146
// Reconstruct sets with updated candidates

0 commit comments

Comments
 (0)