Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(app): Update the invalid pin error handling scenario #511

Merged
merged 1 commit into from
Jul 26, 2023

Conversation

talwinder50
Copy link
Member

@talwinder50 talwinder50 commented Jul 25, 2023

  • Used wallet sdk parsed error api to get the parsed details and category
  • Based on parsed Category (INVALID_GRANT) a messaging is shown to the user "Oops! Something went wrong!
    Try re-entering the pin or scan the new QR code."
  • For the other categories we will show what ever is been sent in the details by parsed method.
  • If user has entered wrong pin they can try re-entering or restart the operation as per the messaging.
    • If pin was wrong and user re-entered the right pin, user will be redirected to credential preview screen

Things to fix:

invalid_pin_error invalid_pin_error_handling

@cla-bot cla-bot bot added the cla-signed label Jul 25, 2023
@talwinder50 talwinder50 changed the title feat(app): Update the invalid pin error handling scenario feat(app): Update the invalid pin error handling scenario iOS Jul 25, 2023
@codecov-commenter
Copy link

codecov-commenter commented Jul 25, 2023

Codecov Report

Patch coverage: 91.30% and project coverage change: +0.01% 🎉

Comparison is base (be47cf0) 89.47% compared to head (bb01d0c) 89.48%.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #511      +/-   ##
==========================================
+ Coverage   89.47%   89.48%   +0.01%     
==========================================
  Files          93       93              
  Lines        3639     3643       +4     
==========================================
+ Hits         3256     3260       +4     
  Misses        251      251              
  Partials      132      132              
Files Changed Coverage Δ
cmd/wallet-sdk-gomobile/wrapper/error.go 87.09% <91.30%> (+1.91%) ⬆️

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

errorMessage = err.details!;
var resp = await WalletSDKPlugin.parseWalletSDKError(localizedErrorMessage: err.details);
if(resp.category == "INVALID_GRANT"){
errorMessage = "Try re-entering the pin or scan the new QR code";
Copy link
Collaborator

@DRK3 DRK3 Jul 25, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
errorMessage = "Try re-entering the pin or scan the new QR code";
errorMessage = "Try re-entering the PIN or scan a new QR code";

guard let localizedErrorMessage = arguments["localizedErrorMessage"] as? String else{
return result(FlutterError.init(code: "NATIVE_ERR",
message: "error while parsing wallet sdk error",
details: "parameter localizedErrorMessage is missed"))
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you mean localizedErrorMessage is missing?

public func parseWalletSDKError(arguments: Dictionary<String, Any>, result: @escaping FlutterResult){
guard let localizedErrorMessage = arguments["localizedErrorMessage"] as? String else{
return result(FlutterError.init(code: "NATIVE_ERR",
message: "error while parsing wallet sdk error",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
message: "error while parsing wallet sdk error",
message: "error while parsing Wallet-SDK error",

Comment on lines 548 to 553
let parsedError = WalleterrorParse(localizedErrorMessage)

var parsedErrorResult :[String:Any] = [
"category": parsedError!.category,
"details": parsedError!.details,
"code": parsedError!.code,
"traceID": parsedError!.traceID
]
result(parsedErrorResult)
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you do the force unwrap once on line 548 instead of on every line from 551-554? Like this:

let parsedError = WalleterrorParse(localizedErrorMessage)!

if (err is PlatformException &&
err.message != null &&
err.message!.isNotEmpty) {
errorMessage = err.details!;
var resp = await WalletSDKPlugin.parseWalletSDKError(localizedErrorMessage: err.details);
if(resp.category == "INVALID_GRANT"){
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if(resp.category == "INVALID_GRANT"){
if (resp.category == "INVALID_GRANT"){

if (err is PlatformException &&
err.message != null &&
err.message!.isNotEmpty) {
errorMessage = err.details!;
var resp = await WalletSDKPlugin.parseWalletSDKError(localizedErrorMessage: err.details);
if(resp.category == "INVALID_GRANT"){
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's one more error category you can add a check for: INVALID_TOKEN. In the case of INVALID_TOKEN, however, re-entering the PIN won't help, so in that case the error message should just tell the user to scan a new QR code.

Copy link
Collaborator

@DRK3 DRK3 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good overall - I suggested some recommended UI text changes and another error code we can check for to improve the user experience, however I don't see any major issues.

@talwinder50 talwinder50 force-pushed the invalidpin branch 2 times, most recently from b6a5a91 to 8205b92 Compare July 25, 2023 15:42
@talwinder50 talwinder50 requested a review from DRK3 July 25, 2023 15:42
@@ -65,6 +66,12 @@ class WalletSDK extends WalletPlatform {
}
}

Future<WalletSDKError> parseWalletSDKError({required String localizedErrorMessage}) async {
var parsedWalletError = await methodChannel.invokeMethod(
'parseWalletSDKError', <String, dynamic>{'localizedErrorMessage': localizedErrorMessage});
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can this map be made more specific?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You mean map of string , string ? Instead of dynamic

Other than that walletsdkerror is the object type we are rendering the object which we get from sdk.

I believe, It cant be more specific than that. I will change that if thats what u mean

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Even better: see if it can just be a simple string instead of a map

}

Map<String, dynamic> toJson() {
final Map<String, dynamic> data = <String, dynamic>{};
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This map looks more generic than it needs to be

return data;
}

factory WalletSDKError.fromJson(Map<String, dynamic> json) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here

@talwinder50 talwinder50 force-pushed the invalidpin branch 2 times, most recently from a3897f6 to bb01d0c Compare July 25, 2023 19:03
@talwinder50 talwinder50 requested a review from DRK3 July 25, 2023 19:06
@DRK3
Copy link
Collaborator

DRK3 commented Jul 25, 2023

The commit says "iOS", but I see android code there too. Does this also add support for the Android app, or is that going to be a separate PR?

@talwinder50 talwinder50 changed the title feat(app): Update the invalid pin error handling scenario iOS feat(app): Update the invalid pin error handling scenario Jul 25, 2023
@sonarcloud
Copy link

sonarcloud bot commented Jul 25, 2023

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 1 Code Smell

No Coverage information No Coverage information
No Duplication information No Duplication information

@talwinder50 talwinder50 merged commit c6d776b into trustbloc:main Jul 26, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants